chatlab-cli 0.36.0 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/{chat-command-SXW67RF7.mjs → chat-command-XPJ43KSW.mjs} +10 -10
- package/dist/chat-command-XPJ43KSW.mjs.map +1 -0
- package/dist/{chunk-BSGLH6G3.mjs → chunk-2JPFBIAG.mjs} +144 -79
- package/dist/chunk-2JPFBIAG.mjs.map +1 -0
- package/dist/{chunk-VDWI4A4U.mjs → chunk-5MJO4AJB.mjs} +2 -2
- package/dist/{chunk-GVW3BDGZ.mjs → chunk-67HNPYZJ.mjs} +3 -3
- package/dist/{chunk-UNIKQFI5.mjs → chunk-6QP47LID.mjs} +2 -2
- package/dist/{chunk-4YPNYQSP.mjs → chunk-FJOGBUXU.mjs} +390 -96
- package/dist/chunk-FJOGBUXU.mjs.map +1 -0
- package/dist/{chunk-XDF6PMVZ.mjs → chunk-JOVL7OTW.mjs} +2 -2
- package/dist/{chunk-CNEWMCGX.mjs → chunk-L7TIIVAY.mjs} +57 -57
- package/dist/chunk-L7TIIVAY.mjs.map +1 -0
- package/dist/{chunk-U2NXHIJK.mjs → chunk-NFTCEJBJ.mjs} +3 -3
- package/dist/{chunk-AAGDVTP2.mjs → chunk-NQHZPSW2.mjs} +2 -2
- package/dist/{chunk-OWOEWZIC.mjs → chunk-Q3NEL2KK.mjs} +82 -28
- package/dist/chunk-Q3NEL2KK.mjs.map +1 -0
- package/dist/{chunk-LZGOIRLV.mjs → chunk-R73XMAB2.mjs} +9 -5
- package/dist/chunk-R73XMAB2.mjs.map +1 -0
- package/dist/{chunk-JHON5FN7.mjs → chunk-X2QBH24F.mjs} +8 -3
- package/dist/chunk-X2QBH24F.mjs.map +1 -0
- package/dist/cli.mjs +9 -9
- package/dist/contacts-worker.mjs +2 -2
- package/dist/global-insight-worker.mjs +1 -1
- package/dist/{http-LVOGJFDL.mjs → http-5RVY5J5U.mjs} +12 -12
- package/dist/{import-7OU57ZHM.mjs → import-ILTWVHKU.mjs} +7 -7
- package/dist/index.mjs +12 -12
- package/dist/{mcp-CUKHTTII.mjs → mcp-Y2YXOFB4.mjs} +8 -8
- package/dist/people-relationships-worker.mjs +2 -2
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{service-KZTHBDQ5.mjs → service-ZAHXRSFD.mjs} +6 -6
- package/dist/service-ZAHXRSFD.mjs.map +1 -0
- package/dist/{src-LORFXAUE.mjs → src-OV5ZNE3Z.mjs} +10 -6
- package/dist/{stream-import-7YUWIAD6.mjs → stream-import-XOUM3Z5W.mjs} +7 -7
- package/dist/{undici-MU5I3L6Q.mjs → undici-UGXDRJLV.mjs} +193 -193
- package/dist/undici-UGXDRJLV.mjs.map +1 -0
- package/dist/{update-checker-3N7HQEP2.mjs → update-checker-UL2FBLXH.mjs} +3 -5
- package/dist/{update-checker-3N7HQEP2.mjs.map → update-checker-UL2FBLXH.mjs.map} +1 -1
- package/dist/{worker-runtime-GQ5SY7E3.mjs → worker-runtime-JNGURHDM.mjs} +5 -5
- package/dist-cli-web/assets/AISettingsTab-vvjijrc5.js +1 -0
- package/dist-cli-web/assets/AboutTab-CxI8zJNz.js +1 -0
- package/dist-cli-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-w0hHEodr.js +110 -0
- package/dist-cli-web/assets/{Alert-DJzXKcec.js → Alert-_MYcI_E2.js} +1 -1
- package/dist-cli-web/assets/ApiSettingsTab-CK7U6dVA.js +2 -0
- package/dist-cli-web/assets/BatchManageTab-1WnEqqpB.js +1 -0
- package/dist-cli-web/assets/{BufferResource-DY3P-dGs.js → BufferResource-i64DlwQT.js} +1 -1
- package/dist-cli-web/assets/{CanvasRenderer-As2MJTWZ.js → CanvasRenderer-B76mEt9A.js} +1 -1
- package/dist-cli-web/assets/ChatRecordDrawer-Bp6OSCrz.js +1 -0
- package/dist-cli-web/assets/{ChatRecordWorkspace-CVDPBmcl.js → ChatRecordWorkspace-CyfPIlIy.js} +1 -1
- package/dist-cli-web/assets/{Checkbox-4F1WAuVF.js → Checkbox-Ci7IeRw1.js} +1 -1
- package/dist-cli-web/assets/DataDirCleanupNotice-Dh63pOLt.js +1 -0
- package/dist-cli-web/assets/DatePicker.vue_vue_type_script_setup_true_lang-DqNBNa1D.js +1 -0
- package/dist-cli-web/assets/{DebugToolsPanel-BLU6SY8a.js → DebugToolsPanel-CbNsD9co.js} +1 -1
- package/dist-cli-web/assets/EChart.vue_vue_type_script_setup_true_lang-YeqmodwE.js +1 -0
- package/dist-cli-web/assets/EChartBar.vue_vue_type_script_setup_true_lang-C3pZmq0v.js +1 -0
- package/dist-cli-web/assets/{EChartLine.vue_vue_type_script_setup_true_lang-BYhukELX.js → EChartLine.vue_vue_type_script_setup_true_lang-Co6olfwv.js} +1 -1
- package/dist-cli-web/assets/{EChartWordcloud-C16xh7Tx.js → EChartWordcloud-rDusZwSq.js} +1 -1
- package/dist-cli-web/assets/{Filter-BEtPORqF.js → Filter-yxkeHO78.js} +1 -1
- package/dist-cli-web/assets/GlobalTaskBar-BlZ-fFiq.js +1 -0
- package/dist-cli-web/assets/GroupRelationshipGalaxyView-BXQBX0zJ.js +1 -0
- package/dist-cli-web/assets/{Label-Dgl3ghzT.js → Label-CFAZFBQX.js} +1 -1
- package/dist-cli-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-CwgpqtMZ.js +1 -0
- package/dist-cli-web/assets/MessageExportModal-DU71grc7.js +1 -0
- package/dist-cli-web/assets/{PageHeader-CL9AFfvl.js → PageHeader-BDPf4NuI.js} +1 -1
- package/dist-cli-web/assets/{PageTabs.vue_vue_type_script_setup_true_lang-C22kOxIK.js → PageTabs.vue_vue_type_script_setup_true_lang-_j82asQU.js} +1 -1
- package/dist-cli-web/assets/{RelationshipGalaxyCanvas-BnkcrIpk.js → RelationshipGalaxyCanvas-BODk18aA.js} +14 -14
- package/dist-cli-web/assets/RelationshipGalaxyThreeCanvas-BJyuRiC-.js +4168 -0
- package/dist-cli-web/assets/RelationshipGalaxyThreeCanvas-CCasBcBQ.css +1 -0
- package/dist-cli-web/assets/{RenderTargetSystem-CPwnC2X3.js → RenderTargetSystem-CVMvAUSv.js} +1 -1
- package/dist-cli-web/assets/RovingFocusItem-DC_06OmN.js +1 -0
- package/dist-cli-web/assets/{ScreenCaptureModal-ByKxzNQe.js → ScreenCaptureModal-DrBFDOtC.js} +1 -1
- package/dist-cli-web/assets/SectionTabs.vue_vue_type_script_setup_true_lang-C-Zj2biH.js +1 -0
- package/dist-cli-web/assets/{Select-jVtfc_xc.js → Select-DLK2LYhO.js} +1 -1
- package/dist-cli-web/assets/SettingsModal-BFkxzo0Y.css +1 -0
- package/dist-cli-web/assets/SettingsModal-DqaR4Dx5.js +2 -0
- package/dist-cli-web/assets/{StorageTab-QdcDqA6Q.js → StorageTab-B0ebN0f8.js} +1 -1
- package/dist-cli-web/assets/{Switch-DYHM64k9.js → Switch-CokhQWxm.js} +1 -1
- package/dist-cli-web/assets/{Tabs-B6Nzq2NQ.js → Tabs-D1UiZNaZ.js} +1 -1
- package/dist-cli-web/assets/Tabs-N3Q-Mpqi.js +1 -0
- package/dist-cli-web/assets/{ThemeCard.vue_vue_type_script_setup_true_lang-Bsq7gpC0.js → ThemeCard.vue_vue_type_script_setup_true_lang-OT-I0mbU.js} +1 -1
- package/dist-cli-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-Ccunouyf.js +1 -0
- package/dist-cli-web/assets/{VisuallyHiddenInput-IQpmK9yR.js → VisuallyHiddenInput-OAJEt_Y5.js} +1 -1
- package/dist-cli-web/assets/{WebGLRenderer-8JHbnkTc.js → WebGLRenderer-DuUeftYD.js} +1 -1
- package/dist-cli-web/assets/{WebGPURenderer-CLWfB4CC.js → WebGPURenderer-DoWQxiWZ.js} +1 -1
- package/dist-cli-web/assets/aiChat-CdADfRnU.js +8 -0
- package/dist-cli-web/assets/{browserAll-Cin6ghNg.js → browserAll-Cb-mtR2y.js} +1 -1
- package/dist-cli-web/assets/{cli-web-D7IBc3AX.js → cli-web-BHQCZLLg.js} +1 -1
- package/dist-cli-web/assets/{fetch-B7kuohCt.js → fetch-AvsnJLWJ.js} +1 -1
- package/dist-cli-web/assets/{fetch-BR71C0K9.js → fetch-B-6tyYWu.js} +1 -1
- package/dist-cli-web/assets/{fetch-OnnCjzee.js → fetch-B4PYy5JS.js} +1 -1
- package/dist-cli-web/assets/{fetch-_CN1EVMt.js → fetch-BbcFaCRB.js} +1 -1
- package/dist-cli-web/assets/{fetch-C8tTTsCm.js → fetch-BkA_so1e.js} +1 -1
- package/dist-cli-web/assets/{fetch-2QEQPA9q.js → fetch-BzXuAaT3.js} +1 -1
- package/dist-cli-web/assets/fetch-CW2fKvGp.js +1 -0
- package/dist-cli-web/assets/{fetch-CuUeyk0N.js → fetch-DEub4tOo.js} +1 -1
- package/dist-cli-web/assets/{fetch-1NiXh-_B.js → fetch-DLTlYnDB.js} +1 -1
- package/dist-cli-web/assets/{fetch-B2agy1hy.js → fetch-Qs38Hx1V.js} +1 -1
- package/dist-cli-web/assets/{fetch-Bk-7vxHV.js → fetch-sYDJ-Zs8.js} +1 -1
- package/dist-cli-web/assets/{fetch-DPRDSI39.js → fetch-ul8-uQIb.js} +1 -1
- package/dist-cli-web/assets/host-B6SQ6OGo.js +1 -0
- package/dist-cli-web/assets/host-DYIkQqvY.js +1 -0
- package/dist-cli-web/assets/{index-BCEk6ZpL.js → index--IEkRjKe.js} +10 -10
- package/dist-cli-web/assets/index-9iaY_EWG.js +1 -0
- package/dist-cli-web/assets/index-BnaLj2dx.css +1 -0
- package/dist-cli-web/assets/index-C7omDgiJ.js +2 -0
- package/dist-cli-web/assets/index-CHsM84U1.js +2 -0
- package/dist-cli-web/assets/index-CL8u01Pf.js +137 -0
- package/dist-cli-web/assets/{index-BIHFuCJK.js → index-CShh95fU.js} +1 -1
- package/dist-cli-web/assets/index-C_OS8Y8W.js +1 -0
- package/dist-cli-web/assets/{index-Colc58j-.js → index-D64XYYts.js} +1 -1
- package/dist-cli-web/assets/index-DrCc8p_I.css +1 -0
- package/dist-cli-web/assets/index-Dz_ddyZS.css +1 -0
- package/dist-cli-web/assets/index-UpTe1KzQ.js +1 -0
- package/dist-cli-web/assets/index-a8Hw6eD8.js +1 -0
- package/dist-cli-web/assets/index-jwjzZNKm.js +1 -0
- package/dist-cli-web/assets/index-pkxlF8Ee.js +1 -0
- package/dist-cli-web/assets/index-sWxuTsa7.js +36 -0
- package/dist-cli-web/assets/{people-page-header-DNPjaSt4.js → people-page-header-0jvXFFnh.js} +1 -1
- package/dist-cli-web/assets/{prompt-BgywZQ_g.js → prompt-BPYj29Vq.js} +1 -1
- package/dist-cli-web/assets/{semantic-index-config-builder-bji_UxYE.js → semantic-index-config-builder-vO37z355.js} +1 -1
- package/dist-cli-web/assets/service-CVoA9yNf.js +1 -0
- package/dist-cli-web/assets/{service-DpU9fa-l.js → service-D29Vftq9.js} +1 -1
- package/dist-cli-web/assets/service-DMysyLCa.js +1 -0
- package/dist-cli-web/assets/{useFormControl-De24E2zT.js → useFormControl-DVawP2DO.js} +1 -1
- package/dist-cli-web/assets/useTable-Bv3R_Hux.js +1 -0
- package/dist-cli-web/assets/useToast-BA0EwImD.js +1 -0
- package/dist-cli-web/assets/{vendor-echarts-DfAMQxdr.js → vendor-echarts-hTLhTs52.js} +5 -5
- package/dist-cli-web/assets/{vendor-echarts-wordcloud-BsaEJTPY.js → vendor-echarts-wordcloud-B8CF_NgP.js} +1 -1
- package/dist-cli-web/assets/{vendor-zrender-PFmZe1EY.js → vendor-zrender-D8psf1AA.js} +2 -2
- package/dist-cli-web/assets/{webworkerAll-BRnv6GvJ.js → webworkerAll-ZPE_yGnC.js} +1 -1
- package/dist-cli-web/index.html +2 -2
- package/package.json +4 -4
- package/dist/chat-command-SXW67RF7.mjs.map +0 -1
- package/dist/chunk-4YPNYQSP.mjs.map +0 -1
- package/dist/chunk-BSGLH6G3.mjs.map +0 -1
- package/dist/chunk-CNEWMCGX.mjs.map +0 -1
- package/dist/chunk-JHON5FN7.mjs.map +0 -1
- package/dist/chunk-LZGOIRLV.mjs.map +0 -1
- package/dist/chunk-OWOEWZIC.mjs.map +0 -1
- package/dist/service-KZTHBDQ5.mjs.map +0 -1
- package/dist/undici-MU5I3L6Q.mjs.map +0 -1
- package/dist-cli-web/assets/AISettingsTab-BmhNcUEh.js +0 -1
- package/dist-cli-web/assets/AboutTab-CFklrZt8.js +0 -1
- package/dist-cli-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-B-dIPvcs.js +0 -110
- package/dist-cli-web/assets/ApiSettingsTab-DvDm421U.js +0 -2
- package/dist-cli-web/assets/BatchManageTab-DhIDH3Q1.js +0 -1
- package/dist-cli-web/assets/ChatRecordDrawer-DHdas7Jp.js +0 -1
- package/dist-cli-web/assets/DataDirCleanupNotice-jebQ9il3.js +0 -1
- package/dist-cli-web/assets/DatePicker.vue_vue_type_script_setup_true_lang-Cal624eP.js +0 -1
- package/dist-cli-web/assets/EChart.vue_vue_type_script_setup_true_lang-CsgJ-Xn3.js +0 -1
- package/dist-cli-web/assets/GlobalTaskBar-BvNmFO7q.js +0 -1
- package/dist-cli-web/assets/GroupRelationshipGalaxyView-DEUIrvgz.js +0 -1
- package/dist-cli-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-CwDIA0UP.js +0 -1
- package/dist-cli-web/assets/MessageExportModal-DYjhBuzO.js +0 -1
- package/dist-cli-web/assets/RelationshipGalaxyThreeCanvas-CqdqveEJ.js +0 -4108
- package/dist-cli-web/assets/RelationshipGalaxyThreeCanvas-TYGOUDiv.css +0 -1
- package/dist-cli-web/assets/RovingFocusItem-j33Nsbbn.js +0 -1
- package/dist-cli-web/assets/SectionTabs.vue_vue_type_script_setup_true_lang-C6EHKB_i.js +0 -1
- package/dist-cli-web/assets/SettingsModal-CjVax3I6.css +0 -1
- package/dist-cli-web/assets/SettingsModal-Dg27piEO.js +0 -2
- package/dist-cli-web/assets/Tabs-CRZdCcU4.js +0 -1
- package/dist-cli-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-BLpQds4F.js +0 -1
- package/dist-cli-web/assets/aiChat-4JvxWGXZ.js +0 -8
- package/dist-cli-web/assets/base-D6fxqD_X.js +0 -1
- package/dist-cli-web/assets/dateFormat-Bu4-Ux3L.js +0 -1
- package/dist-cli-web/assets/index-BUz_Vl9U.js +0 -2
- package/dist-cli-web/assets/index-BWZIoPV3.css +0 -1
- package/dist-cli-web/assets/index-BYQV3OA5.js +0 -1
- package/dist-cli-web/assets/index-CVVv_6qu.js +0 -2
- package/dist-cli-web/assets/index-CacwXQL4.js +0 -1
- package/dist-cli-web/assets/index-DImo7TQN.js +0 -1
- package/dist-cli-web/assets/index-DV9zQVPV.js +0 -137
- package/dist-cli-web/assets/index-DXKS-q-w.css +0 -1
- package/dist-cli-web/assets/index-DZc5A4_J.js +0 -1
- package/dist-cli-web/assets/index-DkWTvE7d.js +0 -36
- package/dist-cli-web/assets/index-DmEn0PAI.js +0 -1
- package/dist-cli-web/assets/index-b9eEQeVt.js +0 -1
- package/dist-cli-web/assets/index-waDxab2e.css +0 -1
- package/dist-cli-web/assets/insight-time-range-MJxLEu6o.js +0 -1
- package/dist-cli-web/assets/useTable-C7BH94MF.js +0 -1
- package/dist-cli-web/assets/useToast-CxhJkhXK.js +0 -1
- /package/dist/{chunk-VDWI4A4U.mjs.map → chunk-5MJO4AJB.mjs.map} +0 -0
- /package/dist/{chunk-GVW3BDGZ.mjs.map → chunk-67HNPYZJ.mjs.map} +0 -0
- /package/dist/{chunk-UNIKQFI5.mjs.map → chunk-6QP47LID.mjs.map} +0 -0
- /package/dist/{chunk-XDF6PMVZ.mjs.map → chunk-JOVL7OTW.mjs.map} +0 -0
- /package/dist/{chunk-U2NXHIJK.mjs.map → chunk-NFTCEJBJ.mjs.map} +0 -0
- /package/dist/{chunk-AAGDVTP2.mjs.map → chunk-NQHZPSW2.mjs.map} +0 -0
- /package/dist/{http-LVOGJFDL.mjs.map → http-5RVY5J5U.mjs.map} +0 -0
- /package/dist/{import-7OU57ZHM.mjs.map → import-ILTWVHKU.mjs.map} +0 -0
- /package/dist/{mcp-CUKHTTII.mjs.map → mcp-Y2YXOFB4.mjs.map} +0 -0
- /package/dist/{src-LORFXAUE.mjs.map → src-OV5ZNE3Z.mjs.map} +0 -0
- /package/dist/{stream-import-7YUWIAD6.mjs.map → stream-import-XOUM3Z5W.mjs.map} +0 -0
- /package/dist/{worker-runtime-GQ5SY7E3.mjs.map → worker-runtime-JNGURHDM.mjs.map} +0 -0
|
@@ -192,11 +192,9 @@ async function checkForUpdatesInteractive() {
|
|
|
192
192
|
if (choice === 1) {
|
|
193
193
|
const result = await performCliSelfUpdate();
|
|
194
194
|
if (result.success) {
|
|
195
|
-
process.stderr.write(
|
|
196
|
-
` \x1B[32m\u{1F389} Updated successfully! Please restart chatlab to use the new version.\x1B[0m
|
|
195
|
+
process.stderr.write(` \x1B[32m\u{1F389} Updated successfully! Please restart clb to use the new version.\x1B[0m
|
|
197
196
|
|
|
198
|
-
`
|
|
199
|
-
);
|
|
197
|
+
`);
|
|
200
198
|
process.exit(0);
|
|
201
199
|
} else {
|
|
202
200
|
process.stderr.write(` \u274C Update failed: ${result.error}
|
|
@@ -216,4 +214,4 @@ export {
|
|
|
216
214
|
performCliSelfUpdate,
|
|
217
215
|
startPeriodicUpdateCheck
|
|
218
216
|
};
|
|
219
|
-
//# sourceMappingURL=update-checker-
|
|
217
|
+
//# sourceMappingURL=update-checker-UL2FBLXH.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/update-checker.ts"],"sourcesContent":["/**\n * CLI startup update checker — npm registry version comparison\n * with interactive prompt (Codex-style).\n *\n * Caches check results to avoid hitting npm on every invocation.\n * Respects user \"skip until next version\" preference.\n */\n\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport * as os from 'os'\nimport { execFile } from 'child_process'\nimport { getVersion } from './version'\n\nconst PACKAGE_NAME = 'chatlab-cli'\nconst CACHE_STALE_MS = 6 * 60 * 60 * 1000 // 6h — startup cache TTL\nconst PERIODIC_CHECK_MS = 24 * 60 * 60 * 1000 // 24h — long-running service interval\nconst CACHE_FILE = path.join(os.homedir(), '.chatlab', 'update-check.json')\n\ninterface UpdateCache {\n lastCheckTime: number\n latestVersion: string | null\n skippedVersion?: string\n}\n\nexport interface UpdateCommandResult {\n success: boolean\n error?: string\n}\n\nexport interface PerformCliSelfUpdateOptions {\n runCommand?: (command: string, args: string[]) => Promise<UpdateCommandResult>\n write?: (text: string) => void\n platform?: NodeJS.Platform\n}\n\nfunction readCache(): UpdateCache | null {\n try {\n if (fs.existsSync(CACHE_FILE)) {\n return JSON.parse(fs.readFileSync(CACHE_FILE, 'utf-8'))\n }\n } catch {\n // corrupted cache\n }\n return null\n}\n\nfunction writeCache(cache: UpdateCache): void {\n try {\n const dir = path.dirname(CACHE_FILE)\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })\n fs.writeFileSync(CACHE_FILE, JSON.stringify(cache), 'utf-8')\n } catch {\n // non-critical\n }\n}\n\nfunction isNewerVersion(latest: string, current: string): boolean {\n const parse = (v: string) => {\n const [core, pre] = v.split('-', 2)\n const parts = core.split('.').map(Number)\n return { major: parts[0] || 0, minor: parts[1] || 0, patch: parts[2] || 0, pre }\n }\n const l = parse(latest)\n const c = parse(current)\n if (l.major !== c.major) return l.major > c.major\n if (l.minor !== c.minor) return l.minor > c.minor\n if (l.patch !== c.patch) return l.patch > c.patch\n // Design note: prerelease users are not prompted for prerelease-to-prerelease updates.\n // Only a stable release with the same core version should supersede a prerelease build.\n if (c.pre && !l.pre) return true\n return false\n}\n\nasync function fetchLatestVersion(): Promise<string | null> {\n try {\n const resp = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {\n headers: { Accept: 'application/json' },\n signal: AbortSignal.timeout(8_000),\n })\n if (!resp.ok) return null\n const data = (await resp.json()) as { version?: string }\n return data.version || null\n } catch {\n return null\n }\n}\n\nfunction promptUser(question: string, choices: string[]): Promise<number> {\n return new Promise((resolve) => {\n let selected = 0\n\n const render = () => {\n // Move cursor up to rewrite choices (skip on first draw)\n if (rendered) process.stderr.write(`\\x1b[${choices.length}A`)\n choices.forEach((c, i) => {\n process.stderr.write(`\\x1b[2K${i === selected ? '› ' : ' '}${i + 1}. ${c}\\n`)\n })\n }\n\n process.stderr.write(`${question}\\n\\n`)\n\n if (!process.stdin.isTTY || !process.stdin.setRawMode) {\n resolve(2)\n return\n }\n\n let rendered = false\n render()\n rendered = true\n process.stderr.write('\\n')\n\n process.stdin.setRawMode(true)\n process.stdin.resume()\n\n const cleanup = () => {\n process.stdin.removeListener('data', onData)\n process.stdin.setRawMode!(false)\n process.stdin.pause()\n }\n\n const onData = (data: Buffer) => {\n const key = data.toString()\n if (key === '\\x03') {\n cleanup()\n process.exit(0)\n }\n // Arrow up / k\n if (key === '\\x1b[A' || key === 'k') {\n selected = (selected - 1 + choices.length) % choices.length\n render()\n return\n }\n // Arrow down / j\n if (key === '\\x1b[B' || key === 'j') {\n selected = (selected + 1) % choices.length\n render()\n return\n }\n // Enter — confirm current selection\n if (key === '\\r' || key === '\\n') {\n cleanup()\n process.stderr.write('\\n')\n resolve(selected + 1)\n return\n }\n // Digit key — direct choice\n if (key.length === 1) {\n const num = parseInt(key)\n if (num >= 1 && num <= choices.length) {\n cleanup()\n process.stderr.write('\\n')\n resolve(num)\n }\n }\n }\n process.stdin.on('data', onData)\n })\n}\n\nfunction runNpmUpdateCommand(\n command: string,\n args: string[],\n write: (text: string) => void\n): Promise<UpdateCommandResult> {\n return new Promise((resolve) => {\n const child = execFile(command, args, { timeout: 120_000 }, (err, _stdout, stderr) => {\n if (err) {\n resolve({ success: false, error: stderr || err.message })\n } else {\n resolve({ success: true })\n }\n })\n child.stdout?.on('data', (chunk) => write(String(chunk)))\n child.stderr?.on('data', (chunk) => write(String(chunk)))\n })\n}\n\nexport function performCliSelfUpdate(options: PerformCliSelfUpdateOptions = {}): Promise<UpdateCommandResult> {\n const platformName = options.platform ?? process.platform\n const npmCmd = platformName === 'win32' ? 'npm.cmd' : 'npm'\n const args = ['install', '-g', `${PACKAGE_NAME}@latest`]\n const write = options.write ?? ((text) => process.stderr.write(text))\n const runCommand = options.runCommand ?? ((command, commandArgs) => runNpmUpdateCommand(command, commandArgs, write))\n\n write(`\\n Running: ${npmCmd} ${args.join(' ')}\\n\\n`)\n return runCommand(npmCmd, args)\n}\n\nfunction isDevEnvironment(): boolean {\n if (process.env.CHATLAB_SKIP_UPDATE_CHECK) return true\n if (process.env.NODE_ENV === 'development') return true\n const entryFile = process.argv[1] || ''\n return entryFile.endsWith('.ts') || entryFile.endsWith('.mts')\n}\n\n/**\n * Fire-and-forget: fetch latest version from npm and update local cache.\n * Runs in background so CLI startup is never blocked by network IO.\n */\nfunction refreshCacheInBackground(existingCache: UpdateCache | null): void {\n fetchLatestVersion()\n .then((latestVersion) => {\n writeCache({\n lastCheckTime: Date.now(),\n latestVersion,\n skippedVersion: existingCache?.skippedVersion,\n })\n })\n .catch(() => {})\n}\n\n/**\n * Start a periodic background cache refresh for long-running services.\n * Immediately refreshes once on startup, then every 24h thereafter.\n * The update prompt will appear on the *next* CLI startup.\n * The timer is unref'd so it won't prevent process exit.\n */\nexport function startPeriodicUpdateCheck(): void {\n if (isDevEnvironment()) return\n refreshCacheInBackground(readCache())\n const timer = setInterval(() => {\n refreshCacheInBackground(readCache())\n }, PERIODIC_CHECK_MS)\n timer.unref()\n}\n\n/**\n * Check for updates and prompt user interactively.\n *\n * Strategy (Codex-style):\n * - Read local cache synchronously (instant, no network).\n * - If cache is stale, kick off a background fetch for *next* run.\n * - Prompt is only shown when cache already contains a newer version.\n * - This means the first run after a new release sees no prompt;\n * the second run (with fresh cache) shows it — zero startup delay.\n */\nexport async function checkForUpdatesInteractive(): Promise<void> {\n if (!process.stdin.isTTY || process.env.CI || isDevEnvironment()) return\n\n const currentVersion = getVersion()\n const cache = readCache()\n\n // Kick off background refresh if cache is missing or stale\n if (!cache || Date.now() - cache.lastCheckTime >= CACHE_STALE_MS) {\n refreshCacheInBackground(cache)\n }\n\n // Prompt is based on cached data only — no network wait\n const latestVersion = cache?.latestVersion\n if (!latestVersion || !isNewerVersion(latestVersion, currentVersion)) return\n if (cache?.skippedVersion === latestVersion) return\n\n const choice = await promptUser(` ✨ Update available! ${currentVersion} → ${latestVersion}`, [\n `Update now (runs \\`npm install -g ${PACKAGE_NAME}\\`)`,\n 'Skip',\n 'Skip until next version',\n ])\n\n if (choice === 1) {\n const result = await performCliSelfUpdate()\n if (result.success) {\n process.stderr.write(\n ` \\x1b[32m🎉 Updated successfully! Please restart chatlab to use the new version.\\x1b[0m\\n\\n`\n )\n process.exit(0)\n } else {\n process.stderr.write(` ❌ Update failed: ${result.error}\\n\\n`)\n }\n } else if (choice === 3) {\n writeCache({\n lastCheckTime: Date.now(),\n latestVersion,\n skippedVersion: latestVersion,\n })\n }\n}\n"],"mappings":"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","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/update-checker.ts"],"sourcesContent":["/**\n * CLI startup update checker — npm registry version comparison\n * with interactive prompt (Codex-style).\n *\n * Caches check results to avoid hitting npm on every invocation.\n * Respects user \"skip until next version\" preference.\n */\n\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport * as os from 'os'\nimport { execFile } from 'child_process'\nimport { getVersion } from './version'\n\nconst PACKAGE_NAME = 'chatlab-cli'\nconst CACHE_STALE_MS = 6 * 60 * 60 * 1000 // 6h — startup cache TTL\nconst PERIODIC_CHECK_MS = 24 * 60 * 60 * 1000 // 24h — long-running service interval\nconst CACHE_FILE = path.join(os.homedir(), '.chatlab', 'update-check.json')\n\ninterface UpdateCache {\n lastCheckTime: number\n latestVersion: string | null\n skippedVersion?: string\n}\n\nexport interface UpdateCommandResult {\n success: boolean\n error?: string\n}\n\nexport interface PerformCliSelfUpdateOptions {\n runCommand?: (command: string, args: string[]) => Promise<UpdateCommandResult>\n write?: (text: string) => void\n platform?: NodeJS.Platform\n}\n\nfunction readCache(): UpdateCache | null {\n try {\n if (fs.existsSync(CACHE_FILE)) {\n return JSON.parse(fs.readFileSync(CACHE_FILE, 'utf-8'))\n }\n } catch {\n // corrupted cache\n }\n return null\n}\n\nfunction writeCache(cache: UpdateCache): void {\n try {\n const dir = path.dirname(CACHE_FILE)\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })\n fs.writeFileSync(CACHE_FILE, JSON.stringify(cache), 'utf-8')\n } catch {\n // non-critical\n }\n}\n\nfunction isNewerVersion(latest: string, current: string): boolean {\n const parse = (v: string) => {\n const [core, pre] = v.split('-', 2)\n const parts = core.split('.').map(Number)\n return { major: parts[0] || 0, minor: parts[1] || 0, patch: parts[2] || 0, pre }\n }\n const l = parse(latest)\n const c = parse(current)\n if (l.major !== c.major) return l.major > c.major\n if (l.minor !== c.minor) return l.minor > c.minor\n if (l.patch !== c.patch) return l.patch > c.patch\n // Design note: prerelease users are not prompted for prerelease-to-prerelease updates.\n // Only a stable release with the same core version should supersede a prerelease build.\n if (c.pre && !l.pre) return true\n return false\n}\n\nasync function fetchLatestVersion(): Promise<string | null> {\n try {\n const resp = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {\n headers: { Accept: 'application/json' },\n signal: AbortSignal.timeout(8_000),\n })\n if (!resp.ok) return null\n const data = (await resp.json()) as { version?: string }\n return data.version || null\n } catch {\n return null\n }\n}\n\nfunction promptUser(question: string, choices: string[]): Promise<number> {\n return new Promise((resolve) => {\n let selected = 0\n\n const render = () => {\n // Move cursor up to rewrite choices (skip on first draw)\n if (rendered) process.stderr.write(`\\x1b[${choices.length}A`)\n choices.forEach((c, i) => {\n process.stderr.write(`\\x1b[2K${i === selected ? '› ' : ' '}${i + 1}. ${c}\\n`)\n })\n }\n\n process.stderr.write(`${question}\\n\\n`)\n\n if (!process.stdin.isTTY || !process.stdin.setRawMode) {\n resolve(2)\n return\n }\n\n let rendered = false\n render()\n rendered = true\n process.stderr.write('\\n')\n\n process.stdin.setRawMode(true)\n process.stdin.resume()\n\n const cleanup = () => {\n process.stdin.removeListener('data', onData)\n process.stdin.setRawMode!(false)\n process.stdin.pause()\n }\n\n const onData = (data: Buffer) => {\n const key = data.toString()\n if (key === '\\x03') {\n cleanup()\n process.exit(0)\n }\n // Arrow up / k\n if (key === '\\x1b[A' || key === 'k') {\n selected = (selected - 1 + choices.length) % choices.length\n render()\n return\n }\n // Arrow down / j\n if (key === '\\x1b[B' || key === 'j') {\n selected = (selected + 1) % choices.length\n render()\n return\n }\n // Enter — confirm current selection\n if (key === '\\r' || key === '\\n') {\n cleanup()\n process.stderr.write('\\n')\n resolve(selected + 1)\n return\n }\n // Digit key — direct choice\n if (key.length === 1) {\n const num = parseInt(key)\n if (num >= 1 && num <= choices.length) {\n cleanup()\n process.stderr.write('\\n')\n resolve(num)\n }\n }\n }\n process.stdin.on('data', onData)\n })\n}\n\nfunction runNpmUpdateCommand(\n command: string,\n args: string[],\n write: (text: string) => void\n): Promise<UpdateCommandResult> {\n return new Promise((resolve) => {\n const child = execFile(command, args, { timeout: 120_000 }, (err, _stdout, stderr) => {\n if (err) {\n resolve({ success: false, error: stderr || err.message })\n } else {\n resolve({ success: true })\n }\n })\n child.stdout?.on('data', (chunk) => write(String(chunk)))\n child.stderr?.on('data', (chunk) => write(String(chunk)))\n })\n}\n\nexport function performCliSelfUpdate(options: PerformCliSelfUpdateOptions = {}): Promise<UpdateCommandResult> {\n const platformName = options.platform ?? process.platform\n const npmCmd = platformName === 'win32' ? 'npm.cmd' : 'npm'\n const args = ['install', '-g', `${PACKAGE_NAME}@latest`]\n const write = options.write ?? ((text) => process.stderr.write(text))\n const runCommand = options.runCommand ?? ((command, commandArgs) => runNpmUpdateCommand(command, commandArgs, write))\n\n write(`\\n Running: ${npmCmd} ${args.join(' ')}\\n\\n`)\n return runCommand(npmCmd, args)\n}\n\nfunction isDevEnvironment(): boolean {\n if (process.env.CHATLAB_SKIP_UPDATE_CHECK) return true\n if (process.env.NODE_ENV === 'development') return true\n const entryFile = process.argv[1] || ''\n return entryFile.endsWith('.ts') || entryFile.endsWith('.mts')\n}\n\n/**\n * Fire-and-forget: fetch latest version from npm and update local cache.\n * Runs in background so CLI startup is never blocked by network IO.\n */\nfunction refreshCacheInBackground(existingCache: UpdateCache | null): void {\n fetchLatestVersion()\n .then((latestVersion) => {\n writeCache({\n lastCheckTime: Date.now(),\n latestVersion,\n skippedVersion: existingCache?.skippedVersion,\n })\n })\n .catch(() => {})\n}\n\n/**\n * Start a periodic background cache refresh for long-running services.\n * Immediately refreshes once on startup, then every 24h thereafter.\n * The update prompt will appear on the *next* CLI startup.\n * The timer is unref'd so it won't prevent process exit.\n */\nexport function startPeriodicUpdateCheck(): void {\n if (isDevEnvironment()) return\n refreshCacheInBackground(readCache())\n const timer = setInterval(() => {\n refreshCacheInBackground(readCache())\n }, PERIODIC_CHECK_MS)\n timer.unref()\n}\n\n/**\n * Check for updates and prompt user interactively.\n *\n * Strategy (Codex-style):\n * - Read local cache synchronously (instant, no network).\n * - If cache is stale, kick off a background fetch for *next* run.\n * - Prompt is only shown when cache already contains a newer version.\n * - This means the first run after a new release sees no prompt;\n * the second run (with fresh cache) shows it — zero startup delay.\n */\nexport async function checkForUpdatesInteractive(): Promise<void> {\n if (!process.stdin.isTTY || process.env.CI || isDevEnvironment()) return\n\n const currentVersion = getVersion()\n const cache = readCache()\n\n // Kick off background refresh if cache is missing or stale\n if (!cache || Date.now() - cache.lastCheckTime >= CACHE_STALE_MS) {\n refreshCacheInBackground(cache)\n }\n\n // Prompt is based on cached data only — no network wait\n const latestVersion = cache?.latestVersion\n if (!latestVersion || !isNewerVersion(latestVersion, currentVersion)) return\n if (cache?.skippedVersion === latestVersion) return\n\n const choice = await promptUser(` ✨ Update available! ${currentVersion} → ${latestVersion}`, [\n `Update now (runs \\`npm install -g ${PACKAGE_NAME}\\`)`,\n 'Skip',\n 'Skip until next version',\n ])\n\n if (choice === 1) {\n const result = await performCliSelfUpdate()\n if (result.success) {\n process.stderr.write(` \\x1b[32m🎉 Updated successfully! Please restart clb to use the new version.\\x1b[0m\\n\\n`)\n process.exit(0)\n } else {\n process.stderr.write(` ❌ Update failed: ${result.error}\\n\\n`)\n }\n } else if (choice === 3) {\n writeCache({\n lastCheckTime: Date.now(),\n latestVersion,\n skippedVersion: latestVersion,\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAQA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,QAAQ;AACpB,SAAS,gBAAgB;AAGzB,IAAM,eAAe;AACrB,IAAM,iBAAiB,IAAI,KAAK,KAAK;AACrC,IAAM,oBAAoB,KAAK,KAAK,KAAK;AACzC,IAAM,aAAkB,UAAQ,WAAQ,GAAG,YAAY,mBAAmB;AAmB1E,SAAS,YAAgC;AACvC,MAAI;AACF,QAAO,cAAW,UAAU,GAAG;AAC7B,aAAO,KAAK,MAAS,gBAAa,YAAY,OAAO,CAAC;AAAA,IACxD;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO;AACT;AAEA,SAAS,WAAW,OAA0B;AAC5C,MAAI;AACF,UAAM,MAAW,aAAQ,UAAU;AACnC,QAAI,CAAI,cAAW,GAAG,EAAG,CAAG,aAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAC9D,IAAG,iBAAc,YAAY,KAAK,UAAU,KAAK,GAAG,OAAO;AAAA,EAC7D,QAAQ;AAAA,EAER;AACF;AAEA,SAAS,eAAe,QAAgB,SAA0B;AAChE,QAAM,QAAQ,CAAC,MAAc;AAC3B,UAAM,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,KAAK,CAAC;AAClC,UAAM,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI,MAAM;AACxC,WAAO,EAAE,OAAO,MAAM,CAAC,KAAK,GAAG,OAAO,MAAM,CAAC,KAAK,GAAG,OAAO,MAAM,CAAC,KAAK,GAAG,IAAI;AAAA,EACjF;AACA,QAAM,IAAI,MAAM,MAAM;AACtB,QAAM,IAAI,MAAM,OAAO;AACvB,MAAI,EAAE,UAAU,EAAE,MAAO,QAAO,EAAE,QAAQ,EAAE;AAC5C,MAAI,EAAE,UAAU,EAAE,MAAO,QAAO,EAAE,QAAQ,EAAE;AAC5C,MAAI,EAAE,UAAU,EAAE,MAAO,QAAO,EAAE,QAAQ,EAAE;AAG5C,MAAI,EAAE,OAAO,CAAC,EAAE,IAAK,QAAO;AAC5B,SAAO;AACT;AAEA,eAAe,qBAA6C;AAC1D,MAAI;AACF,UAAM,OAAO,MAAM,MAAM,8BAA8B,YAAY,WAAW;AAAA,MAC5E,SAAS,EAAE,QAAQ,mBAAmB;AAAA,MACtC,QAAQ,YAAY,QAAQ,GAAK;AAAA,IACnC,CAAC;AACD,QAAI,CAAC,KAAK,GAAI,QAAO;AACrB,UAAM,OAAQ,MAAM,KAAK,KAAK;AAC9B,WAAO,KAAK,WAAW;AAAA,EACzB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,WAAW,UAAkB,SAAoC;AACxE,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,QAAI,WAAW;AAEf,UAAM,SAAS,MAAM;AAEnB,UAAI,SAAU,SAAQ,OAAO,MAAM,QAAQ,QAAQ,MAAM,GAAG;AAC5D,cAAQ,QAAQ,CAAC,GAAG,MAAM;AACxB,gBAAQ,OAAO,MAAM,UAAU,MAAM,WAAW,YAAO,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;AAAA,CAAI;AAAA,MAC/E,CAAC;AAAA,IACH;AAEA,YAAQ,OAAO,MAAM,GAAG,QAAQ;AAAA;AAAA,CAAM;AAEtC,QAAI,CAAC,QAAQ,MAAM,SAAS,CAAC,QAAQ,MAAM,YAAY;AACrD,cAAQ,CAAC;AACT;AAAA,IACF;AAEA,QAAI,WAAW;AACf,WAAO;AACP,eAAW;AACX,YAAQ,OAAO,MAAM,IAAI;AAEzB,YAAQ,MAAM,WAAW,IAAI;AAC7B,YAAQ,MAAM,OAAO;AAErB,UAAM,UAAU,MAAM;AACpB,cAAQ,MAAM,eAAe,QAAQ,MAAM;AAC3C,cAAQ,MAAM,WAAY,KAAK;AAC/B,cAAQ,MAAM,MAAM;AAAA,IACtB;AAEA,UAAM,SAAS,CAAC,SAAiB;AAC/B,YAAM,MAAM,KAAK,SAAS;AAC1B,UAAI,QAAQ,KAAQ;AAClB,gBAAQ;AACR,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,UAAI,QAAQ,YAAY,QAAQ,KAAK;AACnC,oBAAY,WAAW,IAAI,QAAQ,UAAU,QAAQ;AACrD,eAAO;AACP;AAAA,MACF;AAEA,UAAI,QAAQ,YAAY,QAAQ,KAAK;AACnC,oBAAY,WAAW,KAAK,QAAQ;AACpC,eAAO;AACP;AAAA,MACF;AAEA,UAAI,QAAQ,QAAQ,QAAQ,MAAM;AAChC,gBAAQ;AACR,gBAAQ,OAAO,MAAM,IAAI;AACzB,gBAAQ,WAAW,CAAC;AACpB;AAAA,MACF;AAEA,UAAI,IAAI,WAAW,GAAG;AACpB,cAAM,MAAM,SAAS,GAAG;AACxB,YAAI,OAAO,KAAK,OAAO,QAAQ,QAAQ;AACrC,kBAAQ;AACR,kBAAQ,OAAO,MAAM,IAAI;AACzB,kBAAQ,GAAG;AAAA,QACb;AAAA,MACF;AAAA,IACF;AACA,YAAQ,MAAM,GAAG,QAAQ,MAAM;AAAA,EACjC,CAAC;AACH;AAEA,SAAS,oBACP,SACA,MACA,OAC8B;AAC9B,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,QAAQ,SAAS,SAAS,MAAM,EAAE,SAAS,KAAQ,GAAG,CAAC,KAAK,SAAS,WAAW;AACpF,UAAI,KAAK;AACP,gBAAQ,EAAE,SAAS,OAAO,OAAO,UAAU,IAAI,QAAQ,CAAC;AAAA,MAC1D,OAAO;AACL,gBAAQ,EAAE,SAAS,KAAK,CAAC;AAAA,MAC3B;AAAA,IACF,CAAC;AACD,UAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,MAAM,OAAO,KAAK,CAAC,CAAC;AACxD,UAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,MAAM,OAAO,KAAK,CAAC,CAAC;AAAA,EAC1D,CAAC;AACH;AAEO,SAAS,qBAAqB,UAAuC,CAAC,GAAiC;AAC5G,QAAM,eAAe,QAAQ,YAAY,QAAQ;AACjD,QAAM,SAAS,iBAAiB,UAAU,YAAY;AACtD,QAAM,OAAO,CAAC,WAAW,MAAM,GAAG,YAAY,SAAS;AACvD,QAAM,QAAQ,QAAQ,UAAU,CAAC,SAAS,QAAQ,OAAO,MAAM,IAAI;AACnE,QAAM,aAAa,QAAQ,eAAe,CAAC,SAAS,gBAAgB,oBAAoB,SAAS,aAAa,KAAK;AAEnH,QAAM;AAAA,aAAgB,MAAM,IAAI,KAAK,KAAK,GAAG,CAAC;AAAA;AAAA,CAAM;AACpD,SAAO,WAAW,QAAQ,IAAI;AAChC;AAEA,SAAS,mBAA4B;AACnC,MAAI,QAAQ,IAAI,0BAA2B,QAAO;AAClD,MAAI,QAAQ,IAAI,aAAa,cAAe,QAAO;AACnD,QAAM,YAAY,QAAQ,KAAK,CAAC,KAAK;AACrC,SAAO,UAAU,SAAS,KAAK,KAAK,UAAU,SAAS,MAAM;AAC/D;AAMA,SAAS,yBAAyB,eAAyC;AACzE,qBAAmB,EAChB,KAAK,CAAC,kBAAkB;AACvB,eAAW;AAAA,MACT,eAAe,KAAK,IAAI;AAAA,MACxB;AAAA,MACA,gBAAgB,eAAe;AAAA,IACjC,CAAC;AAAA,EACH,CAAC,EACA,MAAM,MAAM;AAAA,EAAC,CAAC;AACnB;AAQO,SAAS,2BAAiC;AAC/C,MAAI,iBAAiB,EAAG;AACxB,2BAAyB,UAAU,CAAC;AACpC,QAAM,QAAQ,YAAY,MAAM;AAC9B,6BAAyB,UAAU,CAAC;AAAA,EACtC,GAAG,iBAAiB;AACpB,QAAM,MAAM;AACd;AAYA,eAAsB,6BAA4C;AAChE,MAAI,CAAC,QAAQ,MAAM,SAAS,QAAQ,IAAI,MAAM,iBAAiB,EAAG;AAElE,QAAM,iBAAiB,WAAW;AAClC,QAAM,QAAQ,UAAU;AAGxB,MAAI,CAAC,SAAS,KAAK,IAAI,IAAI,MAAM,iBAAiB,gBAAgB;AAChE,6BAAyB,KAAK;AAAA,EAChC;AAGA,QAAM,gBAAgB,OAAO;AAC7B,MAAI,CAAC,iBAAiB,CAAC,eAAe,eAAe,cAAc,EAAG;AACtE,MAAI,OAAO,mBAAmB,cAAe;AAE7C,QAAM,SAAS,MAAM,WAAW,8BAAyB,cAAc,WAAM,aAAa,IAAI;AAAA,IAC5F,qCAAqC,YAAY;AAAA,IACjD;AAAA,IACA;AAAA,EACF,CAAC;AAED,MAAI,WAAW,GAAG;AAChB,UAAM,SAAS,MAAM,qBAAqB;AAC1C,QAAI,OAAO,SAAS;AAClB,cAAQ,OAAO,MAAM;AAAA;AAAA,CAA0F;AAC/G,cAAQ,KAAK,CAAC;AAAA,IAChB,OAAO;AACL,cAAQ,OAAO,MAAM,2BAAsB,OAAO,KAAK;AAAA;AAAA,CAAM;AAAA,IAC/D;AAAA,EACF,WAAW,WAAW,GAAG;AACvB,eAAW;AAAA,MACT,eAAe,KAAK,IAAI;AAAA,MACxB;AAAA,MACA,gBAAgB;AAAA,IAClB,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -8,16 +8,16 @@ import {
|
|
|
8
8
|
createLocalEmbeddingRuntimeManager,
|
|
9
9
|
createSemanticIndexService,
|
|
10
10
|
createTransformersPipelineFactory
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-FJOGBUXU.mjs";
|
|
12
|
+
import "./chunk-JOVL7OTW.mjs";
|
|
13
|
+
import "./chunk-NQHZPSW2.mjs";
|
|
14
14
|
import "./chunk-YKMQLAVP.mjs";
|
|
15
15
|
import {
|
|
16
16
|
DatabaseManager,
|
|
17
17
|
StaticPathProvider,
|
|
18
18
|
createDatabaseManagerAdapter,
|
|
19
19
|
initAppLogger
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Q3NEL2KK.mjs";
|
|
21
21
|
import "./chunk-VSOWNKPA.mjs";
|
|
22
22
|
|
|
23
23
|
// ../../packages/node-runtime/src/semantic-index/worker-runtime.ts
|
|
@@ -83,4 +83,4 @@ export {
|
|
|
83
83
|
createSemanticIndexWorkerRuntime,
|
|
84
84
|
createSemanticIndexWorkerServiceFactory
|
|
85
85
|
};
|
|
86
|
-
//# sourceMappingURL=worker-runtime-
|
|
86
|
+
//# sourceMappingURL=worker-runtime-JNGURHDM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ch as Lt,ci as at,cj as St,r as F,f as V,ck as Gt,g as Ht,a as ue,aM as Vt,aN as Pt,cl as Xt,o as l,c as se,w as W,b as Te,e,l as R,m as ze,P as Ze,ad as Je,aQ as Zt,bk as st,aP as Ye,x as Fe,J as Le,c8 as Jt,cm as Yt,i as t,h as m,a6 as S,p as s,z as i,ap as De,$ as Qt,a5 as Ie,a4 as Se,a3 as ye,Z as ea,F as re,j as fe,a1 as ht,a7 as We,a8 as Ut,bS as mt,bT as Me,n as Re,bd as Ne,az as Ge,ar as ta,as as aa,aR as sa,aS as oa,aT as na,bA as ia,cb as la,aX as ra,av as yt,au as da,aO as ca,cn as ua,y as gt,co as ma,cp as bt,bh as ga,K as pt,cq as ot,cr as pa,am as va,cs as fa}from"./index-sWxuTsa7.js";import{a as Qe,_ as zt}from"./Tabs-D1UiZNaZ.js";import{T as Pe}from"./Tabs-N3Q-Mpqi.js";import{_ as xa}from"./Alert-_MYcI_E2.js";import{_ as Rt}from"./Select-DLK2LYhO.js";import{c as ha,s as ya}from"./clamp-jFYhBC76.js";import{u as ba}from"./useFormControl-DVawP2DO.js";import{V as _a}from"./VisuallyHiddenInput-OAJEt_Y5.js";import{u as ka,a as Ft,c as wa,i as At,b as $a}from"./semantic-index-config-builder-vO37z355.js";import{_ as vt}from"./Switch-CokhQWxm.js";import{u as Nt}from"./prompt-BPYj29Vq.js";import{_ as Dt}from"./Checkbox-Ci7IeRw1.js";import"./vendor-snapdom--nZvo8Sg.js";import"./RovingFocusItem-DC_06OmN.js";import"./Label-CFAZFBQX.js";let nt=new Map,ct=!1;try{ct=new Intl.NumberFormat("de-DE",{signDisplay:"exceptZero"}).resolvedOptions().signDisplay==="exceptZero"}catch{}let Xe=!1;try{Xe=new Intl.NumberFormat("de-DE",{style:"unit",unit:"degree"}).resolvedOptions().style==="unit"}catch{}const Bt={degree:{narrow:{default:"°","ja-JP":" 度","zh-TW":"度","sl-SI":" °"}}};class Et{format(o){let a="";if(!ct&&this.options.signDisplay!=null?a=Ma(this.numberFormatter,this.options.signDisplay,o):a=this.numberFormatter.format(o),this.options.style==="unit"&&!Xe){var c;let{unit:n,unitDisplay:d="short",locale:x}=this.resolvedOptions();if(!n)return a;let p=(c=Bt[n])===null||c===void 0?void 0:c[d];a+=p[x]||p.default}return a}formatToParts(o){return this.numberFormatter.formatToParts(o)}formatRange(o,a){if(typeof this.numberFormatter.formatRange=="function")return this.numberFormatter.formatRange(o,a);if(a<o)throw new RangeError("End date must be >= start date");return`${this.format(o)} – ${this.format(a)}`}formatRangeToParts(o,a){if(typeof this.numberFormatter.formatRangeToParts=="function")return this.numberFormatter.formatRangeToParts(o,a);if(a<o)throw new RangeError("End date must be >= start date");let c=this.numberFormatter.formatToParts(o),n=this.numberFormatter.formatToParts(a);return[...c.map(d=>({...d,source:"startRange"})),{type:"literal",value:" – ",source:"shared"},...n.map(d=>({...d,source:"endRange"}))]}resolvedOptions(){let o=this.numberFormatter.resolvedOptions();return!ct&&this.options.signDisplay!=null&&(o={...o,signDisplay:this.options.signDisplay}),!Xe&&this.options.style==="unit"&&(o={...o,style:"unit",unit:this.options.unit,unitDisplay:this.options.unitDisplay}),o}constructor(o,a={}){this.numberFormatter=Ca(o,a),this.options=a}}function Ca(r,o={}){let{numberingSystem:a}=o;if(a&&r.includes("-nu-")&&(r.includes("-u-")||(r+="-u-"),r+=`-nu-${a}`),o.style==="unit"&&!Xe){var c;let{unit:x,unitDisplay:p="short"}=o;if(!x)throw new Error('unit option must be provided with style: "unit"');if(!(!((c=Bt[x])===null||c===void 0)&&c[p]))throw new Error(`Unsupported unit ${x} with unitDisplay = ${p}`);o={...o,style:"decimal"}}let n=r+(o?Object.entries(o).sort((x,p)=>x[0]<p[0]?-1:1).join():"");if(nt.has(n))return nt.get(n);let d=new Intl.NumberFormat(r,o);return nt.set(n,d),d}function Ma(r,o,a){if(o==="auto")return r.format(a);if(o==="never")return r.format(Math.abs(a));{let c=!1;if(o==="always"?c=a>0||Object.is(a,0):o==="exceptZero"&&(Object.is(a,-0)||Object.is(a,0)?a=Math.abs(a):c=a>0),c){let n=r.format(-a),d=r.format(a),x=n.replace(d,"").replace(/\u200e|\u061C/,"");return[...x].length!==1&&console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case"),n.replace(d,"!!!").replace(x,"+").replace("!!!",d)}else return r.format(a)}}const Ia=new RegExp("^.*\\(.*\\).*$"),Sa=["latn","arab","hanidec","deva","beng","fullwide"];class Kt{parse(o){return it(this.locale,this.options,o).parse(o)}isValidPartialNumber(o,a,c){return it(this.locale,this.options,o).isValidPartialNumber(o,a,c)}getNumberingSystem(o){return it(this.locale,this.options,o).options.numberingSystem}constructor(o,a={}){this.locale=o,this.options=a}}const _t=new Map;function it(r,o,a){let c=kt(r,o);if(!r.includes("-nu-")&&!c.isValidPartialNumber(a)){for(let n of Sa)if(n!==c.options.numberingSystem){let d=kt(r+(r.includes("-u-")?"-nu-":"-u-nu-")+n,o);if(d.isValidPartialNumber(a))return d}}return c}function kt(r,o){let a=r+(o?Object.entries(o).sort((n,d)=>n[0]<d[0]?-1:1).join():""),c=_t.get(a);return c||(c=new Va(r,o),_t.set(a,c)),c}class Va{parse(o){let a=this.sanitize(o);if(this.symbols.group&&(a=qe(a,this.symbols.group,"")),this.symbols.decimal&&(a=a.replace(this.symbols.decimal,".")),this.symbols.minusSign&&(a=a.replace(this.symbols.minusSign,"-")),a=a.replace(this.symbols.numeral,this.symbols.index),this.options.style==="percent"){let x=a.indexOf("-");a=a.replace("-",""),a=a.replace("+","");let p=a.indexOf(".");p===-1&&(p=a.length),a=a.replace(".",""),p-2===0?a=`0.${a}`:p-2===-1?a=`0.0${a}`:p-2===-2?a="0.00":a=`${a.slice(0,p-2)}.${a.slice(p-2)}`,x>-1&&(a=`-${a}`)}let c=a?+a:NaN;if(isNaN(c))return NaN;if(this.options.style==="percent"){var n,d;let x={...this.options,style:"decimal",minimumFractionDigits:Math.min(((n=this.options.minimumFractionDigits)!==null&&n!==void 0?n:0)+2,20),maximumFractionDigits:Math.min(((d=this.options.maximumFractionDigits)!==null&&d!==void 0?d:0)+2,20)};return new Kt(this.locale,x).parse(new Et(this.locale,x).format(c))}return this.options.currencySign==="accounting"&&Ia.test(o)&&(c=-1*c),c}sanitize(o){return o=o.replace(this.symbols.literals,""),this.symbols.minusSign&&(o=o.replace("-",this.symbols.minusSign)),this.options.numberingSystem==="arab"&&(this.symbols.decimal&&(o=o.replace(",",this.symbols.decimal),o=o.replace("،",this.symbols.decimal)),this.symbols.group&&(o=qe(o,".",this.symbols.group))),this.symbols.group==="’"&&o.includes("'")&&(o=qe(o,"'",this.symbols.group)),this.options.locale==="fr-FR"&&this.symbols.group&&(o=qe(o," ",this.symbols.group),o=qe(o,/\u00A0/g,this.symbols.group)),o}isValidPartialNumber(o,a=-1/0,c=1/0){return o=this.sanitize(o),this.symbols.minusSign&&o.startsWith(this.symbols.minusSign)&&a<0?o=o.slice(this.symbols.minusSign.length):this.symbols.plusSign&&o.startsWith(this.symbols.plusSign)&&c>0&&(o=o.slice(this.symbols.plusSign.length)),this.symbols.group&&o.startsWith(this.symbols.group)||this.symbols.decimal&&o.indexOf(this.symbols.decimal)>-1&&this.options.maximumFractionDigits===0?!1:(this.symbols.group&&(o=qe(o,this.symbols.group,"")),o=o.replace(this.symbols.numeral,""),this.symbols.decimal&&(o=o.replace(this.symbols.decimal,"")),o.length===0)}constructor(o,a={}){this.locale=o,a.roundingIncrement!==1&&a.roundingIncrement!=null&&(a.maximumFractionDigits==null&&a.minimumFractionDigits==null?(a.maximumFractionDigits=0,a.minimumFractionDigits=0):a.maximumFractionDigits==null?a.maximumFractionDigits=a.minimumFractionDigits:a.minimumFractionDigits==null&&(a.minimumFractionDigits=a.maximumFractionDigits)),this.formatter=new Intl.NumberFormat(o,a),this.options=this.formatter.resolvedOptions(),this.symbols=Ua(o,this.formatter,this.options,a);var c,n;this.options.style==="percent"&&(((c=this.options.minimumFractionDigits)!==null&&c!==void 0?c:0)>18||((n=this.options.maximumFractionDigits)!==null&&n!==void 0?n:0)>18)&&console.warn("NumberParser cannot handle percentages with greater than 18 decimal places, please reduce the number in your options.")}}const wt=new Set(["decimal","fraction","integer","minusSign","plusSign","group"]),Pa=[0,4,2,1,11,20,3,7,100,21,.1,1.1];function Ua(r,o,a,c){var n,d,x,p;let f=new Intl.NumberFormat(r,{...a,minimumSignificantDigits:1,maximumSignificantDigits:21,roundingIncrement:1,roundingPriority:"auto",roundingMode:"halfExpand"}),P=f.formatToParts(-10000.111),U=f.formatToParts(10000.111),I=Pa.map(_=>f.formatToParts(_));var N;let b=(N=(n=P.find(_=>_.type==="minusSign"))===null||n===void 0?void 0:n.value)!==null&&N!==void 0?N:"-",G=(d=U.find(_=>_.type==="plusSign"))===null||d===void 0?void 0:d.value;!G&&(c?.signDisplay==="exceptZero"||c?.signDisplay==="always")&&(G="+");let y=(x=new Intl.NumberFormat(r,{...a,minimumFractionDigits:2,maximumFractionDigits:2}).formatToParts(.001).find(_=>_.type==="decimal"))===null||x===void 0?void 0:x.value,h=(p=P.find(_=>_.type==="group"))===null||p===void 0?void 0:p.value,v=P.filter(_=>!wt.has(_.type)).map(_=>$t(_.value)),D=I.flatMap(_=>_.filter(T=>!wt.has(T.type)).map(T=>$t(T.value))),A=[...new Set([...v,...D])].sort((_,T)=>T.length-_.length),X=A.length===0?new RegExp("[\\p{White_Space}]","gu"):new RegExp(`${A.join("|")}|[\\p{White_Space}]`,"gu"),K=[...new Intl.NumberFormat(a.locale,{useGrouping:!1}).format(9876543210)].reverse(),B=new Map(K.map((_,T)=>[_,T])),M=new RegExp(`[${K.join("")}]`,"g");return{minusSign:b,plusSign:G,decimal:y,group:h,literals:X,numeral:M,index:_=>String(B.get(_))}}function qe(r,o,a){return r.replaceAll?r.replaceAll(o,a):r.split(o).join(a)}function $t(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qt(r){const{disabled:o}=r,a=F(),c=Gt(),n=()=>window.clearTimeout(a.value),d=N=>{n(),!o.value&&(c.trigger(),a.value=window.setTimeout(()=>{d(60)},N))},x=()=>{d(400)},p=()=>{n()},f=F(!1),P=V(()=>Ht(r.target)),U=N=>{N.button!==0||f.value||(N.preventDefault(),f.value=!0,x())},I=()=>{f.value=!1,p()};return Lt&&(at(P||window,"pointerdown",U),at(window,"pointerup",I),at(window,"pointercancel",I)),{isPressed:f,onTrigger:c.on}}function Ct(r,o=F({})){return St(()=>new Et(r.value,o.value))}function za(r,o=F({})){return St(()=>new Kt(r.value,o.value))}function Mt(r,o,a){let c=r==="+"?o+a:o-a;if(o%1!==0||a%1!==0){const n=o.toString().split("."),d=a.toString().split("."),x=n[1]&&n[1].length||0,p=d[1]&&d[1].length||0,f=10**Math.max(x,p);o=Math.round(o*f),a=Math.round(a*f),c=r==="+"?o+a:o-a,c/=f}return c}const[ft,Ra]=Zt("NumberFieldRoot");var Fa=ue({inheritAttrs:!1,__name:"NumberFieldRoot",props:{defaultValue:{type:Number,required:!1,default:void 0},modelValue:{type:[Number,null],required:!1},min:{type:Number,required:!1},max:{type:Number,required:!1},step:{type:Number,required:!1,default:1},stepSnapping:{type:Boolean,required:!1,default:!0},focusOnChange:{type:Boolean,required:!1,default:!0},formatOptions:{type:null,required:!1},locale:{type:String,required:!1},disabled:{type:Boolean,required:!1},readonly:{type:Boolean,required:!1},disableWheelChange:{type:Boolean,required:!1},invertWheelChange:{type:Boolean,required:!1},id:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue"],setup(r,{emit:o}){const a=r,c=o,{disabled:n,readonly:d,disableWheelChange:x,invertWheelChange:p,min:f,max:P,step:U,stepSnapping:I,formatOptions:N,id:b,locale:G}=Vt(a),C=Pt(a,"modelValue",c,{defaultValue:a.defaultValue,passive:a.modelValue===void 0}),{primitiveElement:y,currentElement:h}=Je(),v=Xt(G),D=ba(h),A=F(),X=V(()=>!st(C.value)&&(de(C.value)===f.value||f.value&&!isNaN(C.value)?Mt("-",C.value,U.value)<f.value:!1)),K=V(()=>!st(C.value)&&(de(C.value)===P.value||P.value&&!isNaN(C.value)?Mt("+",C.value,U.value)>P.value:!1));function B(ee,le=1){if(a.focusOnChange&&A.value?.focus(),a.disabled||a.readonly)return;const H=q.parse(A.value?.value??"");isNaN(H)?C.value=f.value??0:ee==="increase"?C.value=de(H+(U.value??1)*le):C.value=de(H-(U.value??1)*le)}function M(ee=1){B("increase",ee)}function g(ee=1){B("decrease",ee)}function _(ee){ee==="min"&&f.value!==void 0?C.value=de(f.value):ee==="max"&&P.value!==void 0&&(C.value=de(P.value))}const T=Ct(v,N),q=za(v,N),w=V(()=>T.resolvedOptions().maximumFractionDigits>0?"decimal":"numeric"),$=Ct(v,N),J=V(()=>st(C.value)||isNaN(C.value)?"":$.format(C.value));function O(ee){return q.isValidPartialNumber(ee,f.value,P.value)}function oe(ee){A.value&&(A.value.value=ee)}function de(ee){let le;return U.value===void 0||isNaN(U.value)||!I.value?le=ha(ee,f.value,P.value):le=ya(ee,f.value,P.value,U.value),le=q.parse(T.format(le)),le}function me(ee){const le=q.parse(ee);return C.value=isNaN(le)?void 0:de(le),ee.length?(isNaN(le),oe(J.value)):oe(ee)}return Ra({modelValue:C,handleDecrease:g,handleIncrease:M,handleMinMaxValue:_,inputMode:w,inputEl:A,onInputElement:ee=>A.value=ee,textValue:J,readonly:d,validate:O,applyInputValue:me,disabled:n,disableWheelChange:x,invertWheelChange:p,max:P,min:f,isDecreaseDisabled:X,isIncreaseDisabled:K,id:b}),(ee,le)=>(l(),se(e(Ze),ze(ee.$attrs,{ref_key:"primitiveElement",ref:y,role:"group",as:ee.as,"as-child":ee.asChild,"data-disabled":e(n)?"":void 0,"data-readonly":e(d)?"":void 0}),{default:W(()=>[Te(ee.$slots,"default",{modelValue:e(C),textValue:J.value,readonly:e(d)}),e(D)&&ee.name?(l(),se(e(_a),{key:0,type:"text",value:e(C),name:ee.name,disabled:e(n),readonly:e(d),required:ee.required},null,8,["value","name","disabled","readonly","required"])):R("v-if",!0)]),_:3},16,["as","as-child","data-disabled","data-readonly"]))}}),Aa=Fa,Na=ue({__name:"NumberFieldDecrement",props:{disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(r){const o=r,a=ft(),c=V(()=>a.disabled?.value||a.readonly.value||o.disabled||a.isDecreaseDisabled.value),{primitiveElement:n,currentElement:d}=Je(),{isPressed:x,onTrigger:p}=qt({target:d,disabled:c});return p(()=>{a.handleDecrease()}),(f,P)=>(l(),se(e(Ze),ze(o,{ref_key:"primitiveElement",ref:n,tabindex:"-1","aria-label":"Decrease",type:f.as==="button"?"button":void 0,style:{userSelect:e(x)?"none":void 0},disabled:c.value?"":void 0,"data-disabled":c.value?"":void 0,"data-pressed":e(x)?"true":void 0,onContextmenu:P[0]||(P[0]=Ye(()=>{},["prevent"]))}),{default:W(()=>[Te(f.$slots,"default")]),_:3},16,["type","style","disabled","data-disabled","data-pressed"]))}}),Da=Na,Ba=ue({__name:"NumberFieldIncrement",props:{disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(r){const o=r,a=ft(),c=V(()=>a.disabled?.value||a.readonly.value||o.disabled||a.isIncreaseDisabled.value),{primitiveElement:n,currentElement:d}=Je(),{isPressed:x,onTrigger:p}=qt({target:d,disabled:c});return p(()=>{a.handleIncrease()}),(f,P)=>(l(),se(e(Ze),ze(o,{ref_key:"primitiveElement",ref:n,tabindex:"-1","aria-label":"Increase",type:f.as==="button"?"button":void 0,style:{userSelect:e(x)?"none":void 0},disabled:c.value?"":void 0,"data-disabled":c.value?"":void 0,"data-pressed":e(x)?"true":void 0,onContextmenu:P[0]||(P[0]=Ye(()=>{},["prevent"]))}),{default:W(()=>[Te(f.$slots,"default")]),_:3},16,["type","style","disabled","data-disabled","data-pressed"]))}}),Ea=Ba,Ka=ue({__name:"NumberFieldInput",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},setup(r){const o=r,{primitiveElement:a,currentElement:c}=Je(),n=ft(),d=Yt(),{isComposing:x,handleCompositionStart:p,handleCompositionEnd:f}=ka();function P(b){if(!(x.value||b.isComposing))switch(b.key){case d.ARROW_UP:b.preventDefault(),n.handleIncrease();break;case d.ARROW_DOWN:b.preventDefault(),n.handleDecrease();break;case d.PAGE_UP:b.preventDefault(),n.handleIncrease(10);break;case d.PAGE_DOWN:b.preventDefault(),n.handleDecrease(10);break;case d.HOME:b.preventDefault(),n.handleMinMaxValue("min");break;case d.END:b.preventDefault(),n.handleMinMaxValue("max");break;case d.ENTER:n.applyInputValue(b.target?.value);break}}function U(b){n.disableWheelChange.value||b.target===Jt()&&(Math.abs(b.deltaY)<=Math.abs(b.deltaX)||(b.preventDefault(),b.deltaY>0?n.invertWheelChange.value?n.handleDecrease():n.handleIncrease():b.deltaY<0&&(n.invertWheelChange.value?n.handleIncrease():n.handleDecrease())))}Fe(()=>{n.onInputElement(c.value)});const I=F(n.textValue.value);Le(()=>n.textValue.value,()=>{I.value=n.textValue.value},{immediate:!0,deep:!0});function N(){requestAnimationFrame(()=>{I.value=n.textValue.value})}return(b,G)=>(l(),se(e(Ze),ze(o,{id:e(n).id.value,ref_key:"primitiveElement",ref:a,value:I.value,role:"spinbutton",type:"text",tabindex:"0",inputmode:e(n).inputMode.value,disabled:e(n).disabled.value?"":void 0,"data-disabled":e(n).disabled.value?"":void 0,readonly:e(n).readonly.value?"":void 0,"data-readonly":e(n).readonly.value?"":void 0,autocomplete:"off",autocorrect:"off",spellcheck:"false","aria-roledescription":"Number field","aria-valuenow":e(n).modelValue.value,"aria-valuemin":e(n).min.value,"aria-valuemax":e(n).max.value,onKeydown:P,onWheel:U,onBeforeinput:G[0]||(G[0]=C=>{if(C.isComposing)return;const y=C.target;let h=y.value.slice(0,y.selectionStart??void 0)+(C.data??"")+y.value.slice(y.selectionEnd??void 0);e(n).validate(h)||C.preventDefault()}),onInput:G[1]||(G[1]=C=>{const y=C.target;I.value=y.value}),onChange:N,onBlur:G[2]||(G[2]=C=>e(n).applyInputValue(C.target?.value)),onCompositionstart:e(p),onCompositionend:e(f)}),{default:W(()=>[Te(b.$slots,"default")]),_:3},16,["id","value","inputmode","disabled","data-disabled","readonly","data-readonly","aria-valuenow","aria-valuemin","aria-valuemax","onCompositionstart","onCompositionend"]))}}),qa=Ka;const Ta=["innerHTML"],Tt=ue({__name:"AlertTips",props:{icon:{},content:{},color:{}},setup(r){return(o,a)=>{const c=xa;return l(),se(c,{color:r.color||"error",variant:"outline",icon:r.icon||"i-lucide-terminal",class:"p-2"},{title:W(()=>[t("p",{innerHTML:r.content},null,8,Ta)]),_:1},8,["color","icon"])}}}),Wa={key:0,class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"},Oa={key:0,class:"font-normal text-gray-400"},ja={class:"flex gap-2"},La={key:1,class:"mt-1 text-xs text-gray-500"},Ga={key:2,class:"mt-2"},Ha={key:0,class:"flex items-center gap-1 text-sm text-green-600 dark:text-green-400"},Xa={key:1,class:"flex items-center gap-1 text-sm text-amber-600 dark:text-amber-400"},He=ue({__name:"ApiKeyInput",props:{modelValue:{},placeholder:{default:""},label:{default:"API Key"},optionalText:{default:""},hint:{default:""},validateLoading:{type:Boolean,default:!1},validateDisabled:{type:Boolean,default:!1},validateText:{default:""},validationResult:{default:"idle"},validationMessage:{default:""}},emits:["update:modelValue","validate"],setup(r,{emit:o}){const a=r,c=o,n=V(()=>!!a.validateText),d=F(!1);function x(p){c("update:modelValue",p)}return(p,f)=>{const P=Ie,U=De,I=Se;return l(),m("div",null,[r.label?(l(),m("label",Wa,[S(s(r.label)+" ",1),r.optionalText?(l(),m("span",Oa,s(r.optionalText),1)):R("",!0)])):R("",!0),t("div",ja,[i(U,{"model-value":r.modelValue,type:d.value?"text":"password",placeholder:r.placeholder,ui:{trailing:"pe-1"},class:"flex-1","onUpdate:modelValue":x},Qt({_:2},[r.modelValue?{name:"trailing",fn:W(()=>[i(P,{color:"neutral",variant:"link",size:"sm",icon:d.value?"i-heroicons-eye-slash":"i-heroicons-eye","aria-label":d.value?"Hide":"Show","aria-pressed":d.value,onClick:f[0]||(f[0]=N=>d.value=!d.value)},null,8,["icon","aria-label","aria-pressed"])]),key:"0"}:void 0]),1032,["model-value","type","placeholder"]),n.value?(l(),se(P,{key:0,loading:r.validateLoading,disabled:r.validateDisabled,variant:"soft",onClick:f[1]||(f[1]=N=>c("validate"))},{default:W(()=>[S(s(r.validateText),1)]),_:1},8,["loading","disabled"])):R("",!0)]),r.hint?(l(),m("p",La,s(r.hint),1)):R("",!0),r.validationMessage?(l(),m("div",Ga,[r.validationResult==="valid"?(l(),m("div",Ha,[i(I,{name:"i-heroicons-check-circle",class:"h-4 w-4"}),S(" "+s(r.validationMessage),1)])):r.validationResult==="invalid"?(l(),m("div",Xa,[i(I,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4"}),S(" "+s(r.validationMessage),1)])):R("",!0)])):R("",!0)])}}}),Za={class:"flex max-h-[80vh] min-h-[400px] flex-col p-6"},Ja={class:"mb-4 flex items-center justify-between"},Ya={class:"text-lg font-semibold text-gray-900 dark:text-white"},Qa={class:"flex items-center gap-2"},es={class:"min-h-0 flex-1 overflow-y-auto"},ts={key:0,class:"flex flex-col items-center justify-center py-12"},as={class:"text-sm text-gray-500"},ss={key:1,class:"flex flex-col items-center justify-center py-12"},os={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},ns={class:"mt-1 max-w-sm text-center text-xs text-gray-500"},is={key:2,class:"flex flex-col items-center justify-center py-12"},ls={class:"text-sm text-gray-500"},rs={key:3,class:"space-y-1"},ds={class:"min-w-0 flex-1"},cs={class:"truncate text-sm font-medium text-gray-800 dark:text-gray-200"},us={class:"flex items-center gap-2"},ms={key:0,class:"truncate text-xs text-gray-400"},gs={key:1,class:"shrink-0 rounded bg-gray-100 px-1.5 py-0.5 text-[10px] font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400"},ps={key:0,disabled:"",class:"ml-3 flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs text-green-500"},vs={class:"mt-4 flex items-center justify-between border-t border-gray-100 pt-4 dark:border-gray-800"},fs={class:"text-xs text-gray-400"},xs=ue({__name:"RemoteModelBrowser",props:ht({models:{},loading:{type:Boolean},error:{},addedModelIds:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:ht(["add","addAll","refresh"],["update:open"]),setup(r,{emit:o}){const{t:a}=ye(),c=ea(r,"open"),n=r,d=o,x=F(""),p=V(()=>{const U=x.value.toLowerCase().trim();return U?n.models.filter(I=>I.id.toLowerCase().includes(U)||I.name.toLowerCase().includes(U)||I.ownedBy&&I.ownedBy.toLowerCase().includes(U)):n.models}),f=V(()=>p.value.filter(U=>!n.addedModelIds.has(U.id)));function P(){d("addAll",f.value)}return(U,I)=>{const N=Se,b=Ie,G=De,C=We;return l(),se(C,{open:c.value,ui:{content:"max-w-2xl z-[102]",overlay:"z-[101]"},"onUpdate:open":I[4]||(I[4]=y=>c.value=y)},{content:W(()=>[t("div",Za,[t("div",Ja,[t("h3",Ya,s(e(a)("settings.aiConfig.modal.fetchModelsTitle")),1),t("div",Qa,[p.value.length>0&&f.value.length>0?(l(),se(b,{key:0,size:"xs",variant:"soft",onClick:P},{default:W(()=>[i(N,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.addAllModels"))+" ("+s(f.value.length)+") ",1)]),_:1})):R("",!0),i(b,{size:"xs",variant:"ghost",loading:r.loading,onClick:I[0]||(I[0]=y=>d("refresh"))},{default:W(()=>[i(N,{name:"i-heroicons-arrow-path",class:"h-4 w-4"})]),_:1},8,["loading"])])]),i(G,{modelValue:x.value,"onUpdate:modelValue":I[1]||(I[1]=y=>x.value=y),placeholder:e(a)("settings.aiConfig.modal.searchModels"),class:"mb-3",ui:{leading:"pointer-events-none"}},{leading:W(()=>[i(N,{name:"i-heroicons-magnifying-glass",class:"h-4 w-4 text-gray-400"})]),_:1},8,["modelValue","placeholder"]),t("div",es,[r.loading?(l(),m("div",ts,[i(N,{name:"i-heroicons-arrow-path",class:"mb-3 h-8 w-8 animate-spin text-gray-400"}),t("p",as,s(e(a)("settings.aiConfig.modal.fetchModelsLoading")),1)])):r.error?(l(),m("div",ss,[i(N,{name:"i-heroicons-exclamation-triangle",class:"mb-3 h-8 w-8 text-amber-400"}),t("p",os,s(e(a)("settings.aiConfig.modal.fetchModelsError")),1),t("p",ns,s(r.error),1),i(b,{size:"xs",variant:"soft",class:"mt-3",onClick:I[2]||(I[2]=y=>d("refresh"))},{default:W(()=>[S(s(e(a)("common.retry")),1)]),_:1})])):p.value.length===0?(l(),m("div",is,[i(N,{name:"i-heroicons-cube-transparent",class:"mb-3 h-8 w-8 text-gray-300"}),t("p",ls,s(x.value?e(a)("common.noResults"):e(a)("settings.aiConfig.modal.fetchModelsEmpty")),1)])):(l(),m("div",rs,[(l(!0),m(re,null,fe(p.value,y=>(l(),m("div",{key:y.id,class:"flex items-center justify-between rounded-lg px-3 py-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[t("div",ds,[t("p",cs,s(y.id),1),t("div",us,[y.ownedBy?(l(),m("span",ms,s(y.ownedBy),1)):R("",!0),y.contextWindow?(l(),m("span",gs,s(y.contextWindow>=1e6?(y.contextWindow/1048576).toFixed(1)+"M":Math.round(y.contextWindow/1024)+"K"),1)):R("",!0)])]),r.addedModelIds.has(y.id)?(l(),m("button",ps,[i(N,{name:"i-heroicons-check",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.modelAdded")),1)])):(l(),se(b,{key:1,size:"xs",variant:"soft",class:"ml-3 shrink-0",onClick:h=>d("add",y)},{default:W(()=>[i(N,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("common.add")),1)]),_:1},8,["onClick"]))]))),128))]))]),t("div",vs,[t("p",fs,s(e(a)("settings.aiConfig.modal.fetchModelsCount",{total:r.models.length,shown:p.value.length})),1),i(b,{variant:"soft",onClick:I[3]||(I[3]=y=>c.value=!1)},{default:W(()=>[S(s(e(a)("common.close")),1)]),_:1})])])]),_:1},8,["open"])}}});function lt(r){return r.provider==="openai-compatible"||r.provider.startsWith("custom:")?!r.apiKeySet||(r.baseUrl?.includes("localhost")??!1)?"local":"openai-compat":"preset"}function It(r){if(!(r.mode==="edit"&&!!r.existingApiKeySet&&!r.hasNewApiKey&&r.originalProvider===r.currentProvider&&r.originalConnectionMode===r.currentConnectionMode))return!1;if(r.currentConnectionMode==="openai-compat"){const a=c=>c?.trim().replace(/\/+$/,"")||"";return a(r.originalBaseUrl)===a(r.currentBaseUrl)}return!0}const Ae="openai-completions",hs=[{value:"openai-completions",labelKey:"settings.aiConfig.modal.apiFormatOpenAI"},{value:"anthropic-messages",labelKey:"settings.aiConfig.modal.apiFormatAnthropic"},{value:"google-generative-ai",labelKey:"settings.aiConfig.modal.apiFormatGemini"},{value:"openai-responses",labelKey:"settings.aiConfig.modal.apiFormatOpenAIResponses"}],ys=["doubao","siliconflow"];function bs(r){const{t:o,locale:a}=ye(),c=Ut(),n=mt();function d(u){const j=`providers.${u}.name`,L=o(j);return L===j?u:L}const x=V(()=>JSON.parse(localStorage.getItem(`chatlab_app_config_${a.value}`)||localStorage.getItem("chatlab_app_config")||"{}").aiTips||{}),p=F("preset"),f=V(()=>[{label:o("settings.aiConfig.modal.presetService"),value:"preset"},{label:o("settings.aiConfig.modal.thirdPartyService"),value:"openai-compat"},{label:o("settings.aiConfig.modal.localService"),value:"local"}]),P=F(!1),U=F(!1),I=F(!1),N=F(""),b=F(!1),G=F(""),C=F(""),y=F(void 0),h=F([]),v=F({provider:"",apiKey:"",model:"",baseUrl:"",apiFormat:Ae,customName:""}),D=F("idle"),A=F(""),X=V(()=>n.providerRegistry.filter(u=>!(!c.locale.startsWith("zh")&&ys.includes(u.id)))),K=V(()=>X.value.filter(u=>u.kind==="official"&&u.id!=="openai-compatible")),B=V(()=>X.value.filter(u=>!u.builtin)),M=V(()=>n.providerRegistry.find(u=>u.id===v.value.provider)),g=V(()=>p.value==="local"),_=V(()=>p.value==="openai-compat"),T=V(()=>p.value==="preset"),q=V(()=>g.value||_.value),w=V(()=>v.value.provider?n.getModelsByProviderId(v.value.provider).filter(u=>!u.capabilities.includes("embedding")&&!u.capabilities.includes("ranking")):[]),$=V(()=>q.value?h.value.map(u=>({label:u.name,value:u.id})):w.value.map(u=>({label:u.name,value:u.id}))),J=V(()=>{if(!v.value.model)return!1;if(q.value)return h.value.some(j=>j.id===v.value.model);const u=w.value.find(j=>j.id===v.value.model);return u?!u.builtin:!1}),O=V(()=>{if(!v.value.model)return;const u=v.value.provider||"openai-compatible";return(n.getModelById(u,v.value.model)||n.findModelAcrossProviders(v.value.model))?.contextWindow}),oe=V(()=>{const{provider:u,apiKey:j,baseUrl:L}=v.value;return It({mode:r.mode.value,existingApiKeySet:r.config.value?.apiKeySet,hasNewApiKey:!!j.trim(),originalProvider:r.config.value?.provider,currentProvider:u,originalConnectionMode:r.config.value?lt(r.config.value):void 0,currentConnectionMode:p.value,originalBaseUrl:r.config.value?.baseUrl,currentBaseUrl:L.trim()||void 0})}),de=V(()=>{const{provider:u,apiKey:j,baseUrl:L,model:Q}=v.value,te=oe.value;return g.value?L.trim()&&Q.trim():_.value?L.trim()&&(j.trim()||te)&&Q.trim():u?j.trim()||te:!1}),me=V(()=>hs.map(u=>({label:o(u.labelKey),value:u.value}))),ee=V(()=>r.mode.value==="add"?o("settings.aiConfig.modal.addConfig"):o("settings.aiConfig.modal.editConfig")),le={gemini:"google-generative-ai",anthropic:"anthropic-messages"},H={"openai-completions":"/chat/completions","openai-responses":"/responses","anthropic-messages":"/v1/messages"},ne=V(()=>{const j=v.value.baseUrl?.trim()||(T.value?M.value?.defaultBaseUrl:"");if(!j)return"";const L=T.value?le[v.value.provider]||Ae:v.value.apiFormat||Ae,Q=j.replace(/\/+$/,"");let te;if(L==="anthropic-messages")te=Q.replace(/\/v1\/?$/,"");else if(L==="openai-completions"||L==="openai-responses")try{const pe=new URL(Q);!Q.endsWith("/v1")&&(pe.pathname==="/"||pe.pathname==="")?te=Q+"/v1":te=Q}catch{te=Q}else te=Q;const ve=H[L];return ve?te+ve:te});function ke(){p.value="preset",h.value=[];const u=K.value[0]?.id||"",j=u?n.getModelsByProviderId(u):[],L=j.find(te=>te.recommendedFor.includes("chat")),Q=u?n.providerRegistry.find(te=>te.id===u):null;v.value={provider:u,apiKey:"",model:L?.id||j[0]?.id||"",baseUrl:Q?.defaultBaseUrl||"",apiFormat:Ae,customName:""},D.value="idle",A.value=""}function be(u){const j=n.providerRegistry.find(te=>te.id===u.provider),L=u.provider==="openai-compatible"||u.provider.startsWith("custom:"),Q=!!(u.model&&n.getModelById(u.provider,u.model));L?(p.value=lt(u),u.customModels&&u.customModels.length>0?h.value=[...u.customModels]:h.value=u.model?[{id:u.model,name:u.model}]:[]):(p.value="preset",h.value=[]),v.value={provider:u.provider,apiKey:u.apiKey||"",model:L?u.model||"":Q&&u.model||"",baseUrl:u.baseUrl||j?.defaultBaseUrl||"",apiFormat:u.apiFormat||Ae,customName:u.name||""},D.value="idle",A.value=""}function Ue(u){v.value.provider=u,D.value="idle",A.value="",v.value.baseUrl=n.providerRegistry.find(Q=>Q.id===u)?.defaultBaseUrl||"";const j=n.getModelsByProviderId(u),L=j.filter(Q=>Q.recommendedFor.includes("chat"));v.value.model=L[0]?.id||j[0]?.id||"",v.value.apiKey=""}function z(u){if(p.value=u,D.value="idle",A.value="",u==="local")v.value.provider="openai-compatible",v.value.baseUrl="http://localhost:11434",v.value.model=h.value[0]?.id||"",v.value.apiKey="";else if(u==="openai-compat")v.value.provider="openai-compatible",v.value.baseUrl="",v.value.model=h.value[0]?.id||"",v.value.apiKey="";else{h.value=[];const j=K.value[0]?.id||"";v.value.provider=j,v.value.baseUrl=n.providerRegistry.find(te=>te.id===j)?.defaultBaseUrl||"";const L=j?n.getModelsByProviderId(j):[],Q=L.filter(te=>te.recommendedFor.includes("chat"));v.value.model=Q[0]?.id||L[0]?.id||"",v.value.apiKey=""}}const Y=F(!1),ae=F([]),xe=F(""),ge=F(!1),ce=V(()=>q.value?new Set(h.value.map(u=>u.id)):new Set(w.value.map(u=>u.id))),_e=V(()=>T.value?le[v.value.provider]||Ae:v.value.apiFormat||Ae),Z=V(()=>{if(_e.value==="anthropic-messages")return!1;const u=v.value.baseUrl||M.value?.defaultBaseUrl||"",j=v.value.apiKey.trim()||g.value||oe.value;return!!(u.trim()&&j)});async function we(){const u=v.value.baseUrl||M.value?.defaultBaseUrl||"",j=v.value.apiKey||(g.value?"sk-no-key-required":""),L=oe.value;if(!u||!j&&!L)return;const Q=!j&&L?r.config.value?.id:void 0;Y.value=!0,xe.value="",ge.value=!0;try{const te=await Me().fetchRemoteModels(v.value.provider||"openai-compatible",j,u,_e.value,Q);if(te.success&&te.models){const ve=v.value.provider||"openai-compatible";ae.value=te.models.map(pe=>{if(pe.contextWindow)return pe;const xt=n.getModelById(ve,pe.id)||n.findModelAcrossProviders(pe.id);return xt?.contextWindow?{...pe,contextWindow:xt.contextWindow}:pe})}else xe.value=te.error||o("settings.aiConfig.modal.fetchModelsError")}catch(te){xe.value=String(te)}finally{Y.value=!1}}async function he(u){if(q.value){h.value.some(L=>L.id===u.id)||h.value.push({id:u.id,name:u.name});const j=v.value.provider||"openai-compatible";if(u.contextWindow&&!n.getModelById(j,u.id)?.contextWindow)try{await Me().addCustomModel({id:u.id,providerId:j,name:u.name,contextWindow:u.contextWindow,capabilities:["chat"],recommendedFor:[],description:"",status:"stable"}),await n.refreshConfigs()}catch{}}else{const j=v.value.provider||"openai-compatible";if(!w.value.some(L=>L.id===u.id))try{await Me().addCustomModel({id:u.id,providerId:j,name:u.name,contextWindow:u.contextWindow||void 0,capabilities:["chat"],recommendedFor:[],description:"",status:"stable"}),await n.refreshConfigs()}catch{}}v.value.model||(v.value.model=u.id)}async function et(u){for(const j of u)await he(j)}function Ve(){G.value="",C.value="",y.value=void 0,b.value=!0}async function tt(){const u=C.value.trim(),j=G.value.trim()||u;if(!u)return;if(q.value){h.value.some(Q=>Q.id===u)||h.value.push({id:u,name:j}),v.value.model=u,b.value=!1;return}const L=v.value.provider||"openai-compatible";try{await Me().addCustomModel({id:u,providerId:L,name:j,contextWindow:y.value||void 0,capabilities:["chat"],recommendedFor:[],description:"",status:"stable"}),await n.refreshConfigs(),v.value.model=u,b.value=!1}catch(Q){console.error("添加自定义模型失败:",Q)}}const Oe=F(!1),Be=F(void 0),Ee=F("");function E(){const u=v.value.model;if(!u)return;const j=v.value.provider||"openai-compatible",L=n.getModelById(j,u);Be.value=L?.contextWindow??void 0,Ee.value=L?.name??"",Oe.value=!0}async function $e(){const u=v.value.model;if(!u)return;const j=v.value.provider||"openai-compatible";try{const L={contextWindow:Be.value||void 0};Ee.value.trim()&&(L.name=Ee.value.trim());const Q=Me();(await Q.updateCustomModel(j,u,L)).success||await Q.addCustomModel({id:u,providerId:j,name:Ee.value.trim()||u,contextWindow:Be.value||void 0,capabilities:["chat"],recommendedFor:[],description:"",status:"stable"}),await n.refreshConfigs()}catch(L){console.error("编辑模型失败:",L)}Oe.value=!1}async function ie(u){if(q.value){const L=h.value.findIndex(Q=>Q.id===u);L!==-1&&h.value.splice(L,1),v.value.model===u&&(v.value.model=h.value[0]?.id||"");return}const j=v.value.provider||"openai-compatible";try{if(await Me().deleteCustomModel(j,u),await n.refreshConfigs(),v.value.model===u){const L=w.value;v.value.model=L[0]?.id||""}}catch(L){console.error("删除自定义模型失败:",L)}}async function Ce(){const{provider:u,baseUrl:j}=v.value,L=v.value.apiKey.trim(),Q=oe.value;if(T.value){if(!u||!L&&!Q){D.value="idle",A.value="";return}}else if(!j||_.value&&!L&&!Q)return;P.value=!0,D.value="idle";const te=!L&&Q?r.config.value?.id:void 0;try{const ve=!L&&Q?"":L||"sk-no-key-required",pe=await Me().validateApiKey(u||"openai-compatible",ve,j||void 0,v.value.model||void 0,void 0,te);D.value=pe.success?"valid":"invalid",pe.success?A.value=o("settings.aiConfig.modal.validationSuccess"):A.value=pe.error||o("settings.aiConfig.modal.validationFailed")}catch(ve){D.value="invalid",A.value=o("settings.aiConfig.modal.validationError")+String(ve)}finally{P.value=!1}}function Ke(){if(q.value&&v.value.baseUrl)try{return new URL(v.value.baseUrl).hostname}catch{return o("settings.aiConfig.modal.customService")}const u=M.value;if(u)return d(u.id)||u.name;const j=r.providers.value.find(L=>L.id===v.value.provider);return j?j.name:v.value.baseUrl||o("settings.aiConfig.modal.customService")}async function k(){U.value=!0;try{const u=v.value.provider;let j=v.value.apiKey.trim();!j&&g.value&&(j="sk-no-key-required");const L=v.value.customName.trim()||Ke(),Q=q.value&&h.value.length>0?h.value.map(te=>({id:te.id,name:te.name})):void 0;if(r.mode.value==="add"){const te=q.value&&v.value.apiFormat||void 0,ve=await Me().addConfig({name:L,provider:u,apiKey:j,model:v.value.model.trim()||void 0,baseUrl:v.value.baseUrl.trim()||void 0,apiFormat:te,customModels:Q});ve.success?(r.onClose(),r.onSaved()):console.error("添加配置失败:",ve.error)}else{const te=q.value&&v.value.apiFormat||void 0,ve={name:L,provider:u,model:v.value.model.trim()||void 0,baseUrl:v.value.baseUrl.trim()||void 0,apiFormat:te,customModels:Q};(v.value.apiKey.trim()||g.value)&&(ve.apiKey=j);const pe=await Me().updateConfig(r.config.value.id,ve);pe.success?(r.onClose(),r.onSaved()):console.error("更新配置失败:",pe.error)}}catch(u){console.error("保存配置失败:",u)}finally{U.value=!1}}async function je(){if(!de.value)return;if(D.value==="valid")return k();const u=!!v.value.apiKey.trim();if(It({mode:r.mode.value,existingApiKeySet:r.config.value?.apiKeySet,hasNewApiKey:u,originalProvider:r.config.value?.provider,currentProvider:v.value.provider,originalConnectionMode:r.config.value?lt(r.config.value):void 0,currentConnectionMode:p.value,originalBaseUrl:r.config.value?.baseUrl,currentBaseUrl:v.value.baseUrl.trim()||void 0}))return k();P.value=!0;try{const L=v.value.apiKey.trim()||"sk-no-key-required",Q=await Me().validateApiKey(v.value.provider||"openai-compatible",L,v.value.baseUrl.trim()||void 0,v.value.model.trim()||void 0);if(Q.success)return D.value="valid",A.value="",k();D.value="invalid",N.value=Q.error||o("settings.aiConfig.modal.validationFailed"),I.value=!0}catch(L){N.value=String(L),I.value=!0}finally{P.value=!1}}function Ot(){I.value=!1,k()}function jt(){I.value=!1}return Le(r.open,u=>{u&&(r.mode.value==="edit"&&r.config.value?be(r.config.value):ke())}),Le(()=>v.value.apiKey,()=>{D.value="idle",A.value=""}),{getLocalizedProviderName:d,aiTips:x,connectionMode:p,connectionModeItems:f,isValidating:P,isSaving:U,showValidationFailConfirm:I,validationFailMessage:N,showAddModelDialog:b,newModelName:G,newModelId:C,newModelContextWindow:y,formData:v,validationResult:D,validationMessage:A,officialProviders:K,customProviders:B,currentProviderDef:M,isLocalMode:g,isOpenAICompat:_,isPresetMode:T,isCompatMode:q,modelTabItems:$,selectedModelIsCustom:J,selectedModelContextWindow:O,canSave:de,canReuseStoredKey:oe,apiFormatItems:me,modalTitle:ee,resolvedApiUrl:ne,isFetchingModels:Y,remoteModels:ae,remoteModelsError:xe,showRemoteModelBrowser:ge,addedModelIds:ce,canFetchModels:Z,showEditModelDialog:Oe,editModelContextWindow:Be,editModelName:Ee,selectProvider:Ue,onConnectionModeChange:z,openAddModelDialog:Ve,confirmAddModel:tt,openEditModelDialog:E,confirmEditModel:$e,deleteCustomModel:ie,validateKey:Ce,saveConfig:je,confirmSaveAnyway:Ot,cancelSave:jt,fetchRemoteModels:we,addRemoteModel:he,addAllRemoteModels:et}}const _s={class:"flex min-h-[min(640px,80vh)] max-h-[80vh] flex-col p-6"},ks={class:"mb-4 text-lg font-semibold text-gray-900 dark:text-white"},ws={class:"min-h-0 flex-1 overflow-y-auto pr-1"},$s={class:"space-y-4"},Cs={class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"},Ms={class:"flex flex-wrap gap-2"},Is=["onClick"],Ss=["onClick"],Vs={key:0,class:"mt-3 rounded-lg border border-gray-100 bg-gray-50/50 px-3 py-2 dark:border-gray-800 dark:bg-gray-800/50"},Ps={class:"flex gap-3"},Us=["href"],zs=["href"],Rs={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Fs={class:"mt-1 text-[10px] text-gray-400"},As={key:0,class:"mt-1.5 flex items-center gap-1 text-[11px] text-gray-400 dark:text-gray-500"},Ns={class:"ml-0.5 break-all rounded bg-gray-100 px-1 py-0.5 font-mono text-[10px] text-gray-500 dark:bg-gray-800 dark:text-gray-400"},Ds={class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"},Bs={key:1,class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},Es={key:0,class:"ml-2"},Ks={key:2,class:"mt-1 flex items-center gap-1 text-xs text-red-500 dark:text-red-400"},qs={class:"mt-2 flex items-center gap-2"},Ts={class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"},Ws={class:"flex gap-2"},Os={key:0,class:"mt-1.5 flex items-center gap-1 text-[11px] text-gray-400 dark:text-gray-500"},js={class:"ml-0.5 break-all rounded bg-gray-100 px-1 py-0.5 font-mono text-[10px] text-gray-500 dark:bg-gray-800 dark:text-gray-400"},Ls={class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"},Gs={key:1,class:"flex items-center gap-1 text-xs text-red-500 dark:text-red-400"},Hs={key:2,class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},Xs={key:0,class:"ml-2"},Zs={key:3,class:"mt-1 flex items-center gap-1 text-xs text-red-500 dark:text-red-400"},Js={class:"mt-2 flex items-center gap-2"},Ys={key:0},Qs={key:0,class:"flex items-center gap-1 text-sm text-green-600 dark:text-green-400"},eo={key:1,class:"flex items-center gap-1 text-sm text-amber-600 dark:text-amber-400"},to={class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"},ao={class:"mt-1 text-xs text-gray-500"},so={key:0,class:"mt-1.5 flex items-center gap-1 text-[11px] text-gray-400 dark:text-gray-500"},oo={class:"ml-0.5 break-all rounded bg-gray-100 px-1 py-0.5 font-mono text-[10px] text-gray-500 dark:bg-gray-800 dark:text-gray-400"},no={class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"},io={key:1,class:"flex items-center gap-1 text-xs text-red-500 dark:text-red-400"},lo={key:2,class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},ro={key:0,class:"ml-2"},co={key:3,class:"mt-1 flex items-center gap-1 text-xs text-red-500 dark:text-red-400"},uo={class:"mt-2 flex items-center gap-2"},mo={key:3},go={class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"},po={key:4},vo={class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"},fo={class:"font-normal text-gray-400"},xo={class:"mt-4 flex shrink-0 justify-end gap-2 border-t border-gray-100 pt-4 dark:border-gray-800"},ho={class:"p-6"},yo={class:"mb-4 flex items-start gap-3"},bo={class:"font-medium text-gray-900 dark:text-white"},_o={class:"mt-1 text-sm text-gray-600 dark:text-gray-400"},ko={class:"mt-2 text-sm text-gray-500 dark:text-gray-400"},wo={class:"flex justify-end gap-2"},$o={class:"p-5"},Co={class:"mb-4 text-base font-semibold text-gray-900 dark:text-white"},Mo={class:"space-y-3"},Io={class:"mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300"},So={class:"mt-1 text-[10px] text-gray-400"},Vo={class:"mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300"},Po={class:"font-normal text-gray-400"},Uo={class:"mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300"},zo={class:"flex items-center gap-2"},Ro={class:"mt-1.5 flex flex-wrap gap-1"},Fo=["onClick"],Ao={class:"mt-1 text-[10px] text-gray-400"},No={class:"mt-4 flex justify-end gap-2"},Do={class:"p-5"},Bo={class:"mb-4 text-base font-semibold text-gray-900 dark:text-white"},Eo={class:"space-y-3"},Ko={class:"mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300"},qo={class:"text-sm text-gray-600 dark:text-gray-400"},To={class:"mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300"},Wo={class:"font-normal text-gray-400"},Oo={class:"mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300"},jo={class:"flex items-center gap-2"},Lo={class:"mt-1.5 flex flex-wrap gap-1"},Go=["onClick"],Ho={class:"mt-1 text-[10px] text-gray-400"},Xo={class:"mt-4 flex justify-end gap-2"},Zo=ue({__name:"AIModelEditModal",props:{open:{type:Boolean},mode:{},config:{},providers:{}},emits:["update:open","saved"],setup(r,{emit:o}){const{t:a}=ye(),c=r,n=o,{getLocalizedProviderName:d,aiTips:x,connectionMode:p,connectionModeItems:f,isValidating:P,isSaving:U,showValidationFailConfirm:I,validationFailMessage:N,showAddModelDialog:b,newModelName:G,newModelId:C,newModelContextWindow:y,formData:h,validationResult:v,validationMessage:D,officialProviders:A,customProviders:X,currentProviderDef:K,isLocalMode:B,isOpenAICompat:M,isPresetMode:g,modelTabItems:_,selectedModelIsCustom:T,selectedModelContextWindow:q,canSave:w,canReuseStoredKey:$,apiFormatItems:J,modalTitle:O,resolvedApiUrl:oe,isFetchingModels:de,remoteModels:me,remoteModelsError:ee,showRemoteModelBrowser:le,addedModelIds:H,canFetchModels:ne,showEditModelDialog:ke,editModelContextWindow:be,editModelName:Ue,selectProvider:z,onConnectionModeChange:Y,openAddModelDialog:ae,confirmAddModel:xe,openEditModelDialog:ge,confirmEditModel:ce,deleteCustomModel:_e,validateKey:Z,saveConfig:we,confirmSaveAnyway:he,cancelSave:et,fetchRemoteModels:Ve,addRemoteModel:tt,addAllRemoteModels:Oe}=bs({...Vt(c),onClose:()=>n("update:open",!1),onSaved:()=>n("saved")});function Be(){n("update:open",!1)}return(Ee,E)=>{const $e=De,ie=Se,Ce=Ie,Ke=We;return l(),m(re,null,[i(Ke,{open:r.open,ui:{content:"max-w-2xl z-[101]",overlay:"z-[100]"},"onUpdate:open":E[23]||(E[23]=k=>n("update:open",k))},{content:W(()=>[t("div",_s,[t("h3",ks,s(e(O)),1),t("div",ws,[t("div",$s,[i(Pe,{"model-value":e(p),items:e(f),size:"sm","onUpdate:modelValue":e(Y)},null,8,["model-value","items","onUpdate:modelValue"]),e(g)?(l(),m(re,{key:0},[t("div",null,[t("label",Cs,s(e(a)("settings.aiConfig.modal.aiProvider")),1),t("div",Ms,[(l(!0),m(re,null,fe(e(A),k=>(l(),m("button",{key:k.id,class:Re(["rounded-lg border-2 px-3 py-1.5 text-xs font-medium transition-colors",[e(h).provider===k.id?"border-transparent bg-primary-500 text-white hover:bg-primary-600 dark:bg-primary-500 dark:text-white dark:hover:bg-primary-400":"border-gray-200 bg-white text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-page-dark dark:text-gray-400 dark:hover:border-gray-600"]]),onClick:je=>e(z)(k.id)},s(e(d)(k.id)||k.name),11,Is))),128)),(l(!0),m(re,null,fe(e(X),k=>(l(),m("button",{key:k.id,class:Re(["rounded-lg border-2 px-3 py-1.5 text-xs font-medium transition-colors",[e(h).provider===k.id?"border-transparent bg-primary-500 text-white hover:bg-primary-600 dark:bg-primary-500 dark:text-white dark:hover:bg-primary-400":"border-dashed border-gray-300 bg-white text-gray-500 hover:border-gray-400 dark:border-gray-600 dark:bg-page-dark dark:text-gray-400"]]),onClick:je=>e(z)(k.id)},s(k.name),11,Ss))),128))]),e(K)&&(e(K).website||e(K).consoleUrl)?(l(),m("div",Vs,[t("div",Ps,[e(K).website?(l(),m("a",{key:0,href:e(K).website,target:"_blank",rel:"noopener",class:"text-xs text-primary-500 hover:underline"},s(e(a)("settings.aiConfig.modal.visitWebsite")),9,Us)):R("",!0),e(K).consoleUrl?(l(),m("a",{key:1,href:e(K).consoleUrl,target:"_blank",rel:"noopener",class:"text-xs text-primary-500 hover:underline"},s(e(a)("settings.aiConfig.modal.getApiKey")),9,zs)):R("",!0)])])):R("",!0)]),i(He,{modelValue:e(h).apiKey,"onUpdate:modelValue":E[0]||(E[0]=k=>e(h).apiKey=k),placeholder:r.mode==="edit"&&r.config?.apiKeySet?e(a)("settings.aiConfig.modal.apiKeyPlaceholderEdit"):e(a)("settings.aiConfig.modal.apiKeyPlaceholder"),"validate-loading":e(P),"validate-disabled":!e(h).apiKey&&!e($),"validate-text":e(a)("settings.aiConfig.modal.validate"),"validation-result":e(v),"validation-message":e(D),onValidate:e(Z)},null,8,["modelValue","placeholder","validate-loading","validate-disabled","validate-text","validation-result","validation-message","onValidate"]),t("div",null,[t("label",Rs,s(e(a)("settings.aiConfig.modal.apiEndpoint")),1),i($e,{modelValue:e(h).baseUrl,"onUpdate:modelValue":E[1]||(E[1]=k=>e(h).baseUrl=k),class:"mt-2 w-full",placeholder:e(K)?.defaultBaseUrl||"https://api.example.com/v1"},null,8,["modelValue","placeholder"]),t("p",Fs,s(e(a)("settings.aiConfig.modal.apiEndpointOverrideHint")),1),e(oe)?(l(),m("p",As,[i(ie,{name:"i-heroicons-link",class:"h-3 w-3 shrink-0"}),t("span",null,s(e(a)("settings.aiConfig.modal.resolvedUrl")),1),t("code",Ns,s(e(oe)),1)])):R("",!0)]),t("div",null,[t("label",Ds,s(e(a)("settings.aiConfig.modal.model")),1),e(_).length>0?(l(),se(Pe,{key:0,modelValue:e(h).model,"onUpdate:modelValue":E[2]||(E[2]=k=>e(h).model=k),items:e(_),size:"xs"},null,8,["modelValue","items"])):R("",!0),e(h).model?(l(),m("p",Bs,[S(s(e(a)("settings.aiConfig.modal.customModelId"))+": "+s(e(h).model)+" ",1),e(q)?(l(),m("span",Es," · "+s(e(a)("settings.aiConfig.modal.contextWindow"))+": "+s(e(q)>=1e6?(e(q)/1048576).toFixed(1)+"M":Math.round(e(q)/1024)+"K"),1)):R("",!0)])):R("",!0),e(h).model&&!e(q)?(l(),m("p",Ks,[i(ie,{name:"i-heroicons-exclamation-triangle",class:"h-3.5 w-3.5 shrink-0"}),S(" "+s(e(a)("settings.aiConfig.modal.contextWindowMissing")),1)])):R("",!0),t("div",qs,[e(ne)?(l(),m("button",{key:0,class:"flex items-center gap-1 rounded-md border border-dashed border-primary-300 px-2 py-1 text-xs text-primary-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-primary-700 dark:text-primary-400 dark:hover:border-primary-500",onClick:E[3]||(E[3]=(...k)=>e(Ve)&&e(Ve)(...k))},[i(ie,{name:"i-heroicons-cloud-arrow-down",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.fetchModels")),1)])):R("",!0),e(K)?.supportsCustomModels?(l(),m("button",{key:1,class:"flex items-center gap-1 rounded-md border border-dashed border-gray-300 px-2 py-1 text-xs text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-500 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:E[4]||(E[4]=(...k)=>e(ae)&&e(ae)(...k))},[i(ie,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.addCustomModel")),1)])):R("",!0),e(h).model?(l(),m("button",{key:2,class:"flex items-center gap-1 rounded-md border border-dashed border-gray-300 px-2 py-1 text-xs text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-500 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:E[5]||(E[5]=(...k)=>e(ge)&&e(ge)(...k))},[i(ie,{name:"i-heroicons-pencil-square",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.editModel")),1)])):R("",!0),e(T)?(l(),m("button",{key:3,class:"flex items-center gap-1 rounded-md border border-dashed border-red-200 px-2 py-1 text-xs text-red-400 transition-colors hover:border-red-400 hover:text-red-500 dark:border-red-800 dark:hover:border-red-500",onClick:E[6]||(E[6]=k=>e(_e)(e(h).model))},[i(ie,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.deleteCustomModel")),1)])):R("",!0)])])],64)):e(B)?(l(),m(re,{key:1},[i(He,{modelValue:e(h).apiKey,"onUpdate:modelValue":E[7]||(E[7]=k=>e(h).apiKey=k),placeholder:e(a)("settings.aiConfig.modal.apiKeyPlaceholderLocal"),"optional-text":e(a)("settings.aiConfig.modal.optional"),hint:e(a)("settings.aiConfig.modal.apiKeyHintLocal")},null,8,["modelValue","placeholder","optional-text","hint"]),t("div",null,[t("label",Ts,s(e(a)("settings.aiConfig.modal.apiEndpoint")),1),t("div",Ws,[i($e,{modelValue:e(h).baseUrl,"onUpdate:modelValue":E[8]||(E[8]=k=>e(h).baseUrl=k),placeholder:"http://localhost:11434",class:"flex-1"},null,8,["modelValue"]),i(Ce,{loading:e(P),disabled:!e(h).baseUrl,variant:"soft",onClick:e(Z)},{default:W(()=>[S(s(e(a)("settings.aiConfig.modal.validate")),1)]),_:1},8,["loading","disabled","onClick"])]),e(oe)?(l(),m("p",Os,[i(ie,{name:"i-heroicons-link",class:"h-3 w-3 shrink-0"}),t("span",null,s(e(a)("settings.aiConfig.modal.resolvedUrl")),1),t("code",js,s(e(oe)),1)])):R("",!0)]),t("div",null,[t("label",Ls,s(e(a)("settings.aiConfig.modal.model")),1),e(_).length>0?(l(),se(Pe,{key:0,modelValue:e(h).model,"onUpdate:modelValue":E[9]||(E[9]=k=>e(h).model=k),items:e(_),size:"xs"},null,8,["modelValue","items"])):(l(),m("p",Gs,[i(ie,{name:"i-heroicons-exclamation-triangle",class:"h-3.5 w-3.5 shrink-0"}),S(" "+s(e(a)("settings.aiConfig.modal.modelRequired")),1)])),e(h).model?(l(),m("p",Hs,[S(s(e(a)("settings.aiConfig.modal.customModelId"))+": "+s(e(h).model)+" ",1),e(q)?(l(),m("span",Xs," · "+s(e(a)("settings.aiConfig.modal.contextWindow"))+": "+s(e(q)>=1e6?(e(q)/1048576).toFixed(1)+"M":Math.round(e(q)/1024)+"K"),1)):R("",!0)])):R("",!0),e(h).model&&!e(q)?(l(),m("p",Zs,[i(ie,{name:"i-heroicons-exclamation-triangle",class:"h-3.5 w-3.5 shrink-0"}),S(" "+s(e(a)("settings.aiConfig.modal.contextWindowMissing")),1)])):R("",!0),t("div",Js,[e(ne)?(l(),m("button",{key:0,class:"flex items-center gap-1 rounded-md border border-dashed border-primary-300 px-2 py-1 text-xs text-primary-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-primary-700 dark:text-primary-400 dark:hover:border-primary-500",onClick:E[10]||(E[10]=(...k)=>e(Ve)&&e(Ve)(...k))},[i(ie,{name:"i-heroicons-cloud-arrow-down",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.fetchModels")),1)])):R("",!0),e(K)?.supportsCustomModels?(l(),m("button",{key:1,class:"flex items-center gap-1 rounded-md border border-dashed border-gray-300 px-2 py-1 text-xs text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-500 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:E[11]||(E[11]=(...k)=>e(ae)&&e(ae)(...k))},[i(ie,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.addCustomModel")),1)])):R("",!0),e(h).model?(l(),m("button",{key:2,class:"flex items-center gap-1 rounded-md border border-dashed border-gray-300 px-2 py-1 text-xs text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-500 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:E[12]||(E[12]=(...k)=>e(ge)&&e(ge)(...k))},[i(ie,{name:"i-heroicons-pencil-square",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.editModel")),1)])):R("",!0),e(T)?(l(),m("button",{key:3,class:"flex items-center gap-1 rounded-md border border-dashed border-red-200 px-2 py-1 text-xs text-red-400 transition-colors hover:border-red-400 hover:text-red-500 dark:border-red-800 dark:hover:border-red-500",onClick:E[13]||(E[13]=k=>e(_e)(e(h).model))},[i(ie,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.deleteCustomModel")),1)])):R("",!0)])]),e(D)?(l(),m("div",Ys,[e(v)==="valid"?(l(),m("div",Qs,[i(ie,{name:"i-heroicons-check-circle",class:"h-4 w-4"}),S(" "+s(e(D)),1)])):e(v)==="invalid"?(l(),m("div",eo,[i(ie,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4"}),S(" "+s(e(D)),1)])):R("",!0)])):R("",!0)],64)):e(M)?(l(),m(re,{key:2},[e(x).thirdPartyApi?.show?(l(),se(Tt,{key:0,icon:"i-heroicons-exclamation-triangle",content:e(x).thirdPartyApi?.content},null,8,["content"])):R("",!0),i(He,{modelValue:e(h).apiKey,"onUpdate:modelValue":E[14]||(E[14]=k=>e(h).apiKey=k),placeholder:r.mode==="edit"&&r.config?.apiKeySet?e(a)("settings.aiConfig.modal.apiKeyPlaceholderEdit"):e(a)("settings.aiConfig.modal.apiKeyPlaceholder"),"validate-loading":e(P),"validate-disabled":!e(h).apiKey&&!e($)||!e(h).baseUrl,"validate-text":e(a)("settings.aiConfig.modal.validate"),"validation-result":e(v),"validation-message":e(D),onValidate:e(Z)},null,8,["modelValue","placeholder","validate-loading","validate-disabled","validate-text","validation-result","validation-message","onValidate"]),t("div",null,[t("label",to,s(e(a)("settings.aiConfig.modal.apiEndpoint")),1),i($e,{modelValue:e(h).baseUrl,"onUpdate:modelValue":E[15]||(E[15]=k=>e(h).baseUrl=k),class:"w-full",placeholder:"https://api.example.com"},null,8,["modelValue"]),t("p",ao,s(e(a)("settings.aiConfig.modal.apiEndpointHint")),1),e(oe)?(l(),m("p",so,[i(ie,{name:"i-heroicons-link",class:"h-3 w-3 shrink-0"}),t("span",null,s(e(a)("settings.aiConfig.modal.resolvedUrl")),1),t("code",oo,s(e(oe)),1)])):R("",!0)]),t("div",null,[t("label",no,s(e(a)("settings.aiConfig.modal.model")),1),e(_).length>0?(l(),se(Pe,{key:0,modelValue:e(h).model,"onUpdate:modelValue":E[16]||(E[16]=k=>e(h).model=k),items:e(_),size:"xs"},null,8,["modelValue","items"])):(l(),m("p",io,[i(ie,{name:"i-heroicons-exclamation-triangle",class:"h-3.5 w-3.5 shrink-0"}),S(" "+s(e(a)("settings.aiConfig.modal.modelRequired")),1)])),e(h).model?(l(),m("p",lo,[S(s(e(a)("settings.aiConfig.modal.customModelId"))+": "+s(e(h).model)+" ",1),e(q)?(l(),m("span",ro," · "+s(e(a)("settings.aiConfig.modal.contextWindow"))+": "+s(e(q)>=1e6?(e(q)/1048576).toFixed(1)+"M":Math.round(e(q)/1024)+"K"),1)):R("",!0)])):R("",!0),e(h).model&&!e(q)?(l(),m("p",co,[i(ie,{name:"i-heroicons-exclamation-triangle",class:"h-3.5 w-3.5 shrink-0"}),S(" "+s(e(a)("settings.aiConfig.modal.contextWindowMissing")),1)])):R("",!0),t("div",uo,[e(ne)?(l(),m("button",{key:0,class:"flex items-center gap-1 rounded-md border border-dashed border-primary-300 px-2 py-1 text-xs text-primary-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-primary-700 dark:text-primary-400 dark:hover:border-primary-500",onClick:E[17]||(E[17]=(...k)=>e(Ve)&&e(Ve)(...k))},[i(ie,{name:"i-heroicons-cloud-arrow-down",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.fetchModels")),1)])):R("",!0),e(K)?.supportsCustomModels?(l(),m("button",{key:1,class:"flex items-center gap-1 rounded-md border border-dashed border-gray-300 px-2 py-1 text-xs text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-500 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:E[18]||(E[18]=(...k)=>e(ae)&&e(ae)(...k))},[i(ie,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.addCustomModel")),1)])):R("",!0),e(h).model?(l(),m("button",{key:2,class:"flex items-center gap-1 rounded-md border border-dashed border-gray-300 px-2 py-1 text-xs text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-500 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:E[19]||(E[19]=(...k)=>e(ge)&&e(ge)(...k))},[i(ie,{name:"i-heroicons-pencil-square",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.editModel")),1)])):R("",!0),e(T)?(l(),m("button",{key:3,class:"flex items-center gap-1 rounded-md border border-dashed border-red-200 px-2 py-1 text-xs text-red-400 transition-colors hover:border-red-400 hover:text-red-500 dark:border-red-800 dark:hover:border-red-500",onClick:E[20]||(E[20]=k=>e(_e)(e(h).model))},[i(ie,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),S(" "+s(e(a)("settings.aiConfig.modal.deleteCustomModel")),1)])):R("",!0)])])],64)):R("",!0),e(g)?R("",!0):(l(),m("div",mo,[t("label",go,s(e(a)("settings.aiConfig.modal.apiFormat")),1),i(Pe,{modelValue:e(h).apiFormat,"onUpdate:modelValue":E[21]||(E[21]=k=>e(h).apiFormat=k),items:e(J),size:"xs"},null,8,["modelValue","items"])])),e(h).provider||!e(g)?(l(),m("div",po,[t("label",vo,[S(s(e(a)("settings.aiConfig.modal.configName"))+" ",1),t("span",fo,s(e(a)("settings.aiConfig.modal.optional")),1)]),i($e,{modelValue:e(h).customName,"onUpdate:modelValue":E[22]||(E[22]=k=>e(h).customName=k),class:"w-full",placeholder:e(g)?e(a)("settings.aiConfig.modal.configNamePlaceholderPreset"):e(a)("settings.aiConfig.modal.configNamePlaceholderCustom")},null,8,["modelValue","placeholder"])])):R("",!0)])]),t("div",xo,[i(Ce,{variant:"soft",onClick:Be},{default:W(()=>[S(s(e(a)("common.cancel")),1)]),_:1}),i(Ce,{color:"primary",disabled:!e(w),loading:e(U)||e(P),onClick:e(we)},{default:W(()=>[S(s(r.mode==="add"?e(a)("common.add"):e(a)("common.save")),1)]),_:1},8,["disabled","loading","onClick"])])])]),_:1},8,["open"]),i(Ke,{open:e(I),ui:{content:"z-[102]",overlay:"z-[101]"},"onUpdate:open":E[24]||(E[24]=k=>I.value=k)},{content:W(()=>[t("div",ho,[t("div",yo,[i(ie,{name:"i-heroicons-exclamation-triangle",class:"mt-0.5 h-6 w-6 shrink-0 text-amber-500"}),t("div",null,[t("h4",bo,s(e(a)("settings.aiConfig.modal.validationFailedTitle")),1),t("p",_o,s(e(N)),1),t("p",ko,s(e(a)("settings.aiConfig.modal.saveAnywayHint")),1)])]),t("div",wo,[i(Ce,{variant:"soft",onClick:e(et)},{default:W(()=>[S(s(e(a)("common.cancel")),1)]),_:1},8,["onClick"]),i(Ce,{color:"warning",onClick:e(he)},{default:W(()=>[S(s(e(a)("settings.aiConfig.modal.saveAnyway")),1)]),_:1},8,["onClick"])])])]),_:1},8,["open"]),i(xs,{open:e(le),"onUpdate:open":E[25]||(E[25]=k=>Ne(le)?le.value=k:null),models:e(me),loading:e(de),error:e(ee),"added-model-ids":e(H),onAdd:e(tt),onAddAll:e(Oe),onRefresh:e(Ve)},null,8,["open","models","loading","error","added-model-ids","onAdd","onAddAll","onRefresh"]),i(Ke,{open:e(b),ui:{content:"z-[102]",overlay:"z-[101]"},"onUpdate:open":E[30]||(E[30]=k=>b.value=k)},{content:W(()=>[t("div",$o,[t("h4",Co,s(e(a)("settings.aiConfig.modal.addCustomModel")),1),t("div",Mo,[t("div",null,[t("label",Io,s(e(a)("settings.aiConfig.modal.customModelId")),1),i($e,{modelValue:e(C),"onUpdate:modelValue":E[26]||(E[26]=k=>Ne(C)?C.value=k:null),class:"w-full",placeholder:"gpt-4o-custom, deepseek-r1, ..."},null,8,["modelValue"]),t("p",So,s(e(a)("settings.aiConfig.modal.customModelIdHint")),1)]),t("div",null,[t("label",Vo,[S(s(e(a)("settings.aiConfig.modal.customModelDisplayName"))+" ",1),t("span",Po,s(e(a)("settings.aiConfig.modal.optional")),1)]),i($e,{modelValue:e(G),"onUpdate:modelValue":E[27]||(E[27]=k=>Ne(G)?G.value=k:null),class:"w-full",placeholder:e(C)||e(a)("settings.aiConfig.modal.customModelDisplayNamePlaceholder")},null,8,["modelValue","placeholder"])]),t("div",null,[t("label",Uo,s(e(a)("settings.aiConfig.modal.contextWindow")),1),t("div",zo,[i($e,{modelValue:e(y),"onUpdate:modelValue":E[28]||(E[28]=k=>Ne(y)?y.value=k:null),modelModifiers:{number:!0,optional:!0},class:"flex-1",type:"number",placeholder:e(a)("settings.aiConfig.modal.contextWindowPlaceholder")},null,8,["modelValue","placeholder"])]),t("div",Ro,[(l(),m(re,null,fe([{label:"64K",value:65536},{label:"128K",value:128e3},{label:"200K",value:2e5},{label:"1M",value:1048576}],k=>t("button",{key:k.value,class:Re(["rounded border px-1.5 py-0.5 text-[10px] transition-colors",[e(y)===k.value?"border-primary-400 bg-primary-50 text-primary-600 dark:border-primary-600 dark:bg-primary-900/30 dark:text-primary-400":"border-gray-200 text-gray-500 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-600"]]),onClick:je=>y.value=k.value},s(k.label),11,Fo)),64))]),t("p",Ao,s(e(a)("settings.aiConfig.modal.contextWindowHint")),1)])]),t("div",No,[i(Ce,{variant:"soft",onClick:E[29]||(E[29]=k=>b.value=!1)},{default:W(()=>[S(s(e(a)("common.cancel")),1)]),_:1}),i(Ce,{color:"primary",disabled:!e(C).trim(),onClick:e(xe)},{default:W(()=>[S(s(e(a)("common.add")),1)]),_:1},8,["disabled","onClick"])])])]),_:1},8,["open"]),i(Ke,{open:e(ke),ui:{content:"z-[102]",overlay:"z-[101]"},"onUpdate:open":E[34]||(E[34]=k=>ke.value=k)},{content:W(()=>[t("div",Do,[t("h4",Bo,s(e(a)("settings.aiConfig.modal.editModel")),1),t("div",Eo,[t("div",null,[t("label",Ko,s(e(a)("settings.aiConfig.modal.customModelId")),1),t("p",qo,s(e(h).model),1)]),t("div",null,[t("label",To,[S(s(e(a)("settings.aiConfig.modal.customModelDisplayName"))+" ",1),t("span",Wo,s(e(a)("settings.aiConfig.modal.optional")),1)]),i($e,{modelValue:e(Ue),"onUpdate:modelValue":E[31]||(E[31]=k=>Ne(Ue)?Ue.value=k:null),class:"w-full",placeholder:e(h).model||e(a)("settings.aiConfig.modal.customModelDisplayNamePlaceholder")},null,8,["modelValue","placeholder"])]),t("div",null,[t("label",Oo,s(e(a)("settings.aiConfig.modal.contextWindow")),1),t("div",jo,[i($e,{modelValue:e(be),"onUpdate:modelValue":E[32]||(E[32]=k=>Ne(be)?be.value=k:null),modelModifiers:{number:!0,optional:!0},class:"flex-1",type:"number",placeholder:e(a)("settings.aiConfig.modal.contextWindowPlaceholder")},null,8,["modelValue","placeholder"])]),t("div",Lo,[(l(),m(re,null,fe([{label:"64K",value:65536},{label:"128K",value:128e3},{label:"200K",value:2e5},{label:"1M",value:1048576}],k=>t("button",{key:k.value,class:Re(["rounded border px-1.5 py-0.5 text-[10px] transition-colors",[e(be)===k.value?"border-primary-400 bg-primary-50 text-primary-600 dark:border-primary-600 dark:bg-primary-900/30 dark:text-primary-400":"border-gray-200 text-gray-500 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-600"]]),onClick:je=>be.value=k.value},s(k.label),11,Go)),64))]),t("p",Ho,s(e(a)("settings.aiConfig.modal.contextWindowHint")),1)])]),t("div",Xo,[i(Ce,{variant:"soft",onClick:E[33]||(E[33]=k=>ke.value=!1)},{default:W(()=>[S(s(e(a)("common.cancel")),1)]),_:1}),i(Ce,{color:"primary",onClick:e(ce)},{default:W(()=>[S(s(e(a)("common.save")),1)]),_:1},8,["onClick"])])])]),_:1},8,["open"])],64)}}}),Jo={key:0,class:"flex items-center justify-center py-12"},Yo={key:1,class:"space-y-6"},Qo={class:"mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},en={class:"rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-800/50"},tn={key:0,class:"divide-y divide-gray-200 dark:divide-gray-700"},an={class:"flex items-center gap-3"},sn={class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gray-200 text-gray-500 dark:bg-gray-700 dark:text-gray-400"},on={class:"flex min-w-0 items-center gap-2"},nn={class:"w-28 shrink-0 truncate text-sm font-medium text-gray-900 dark:text-white"},ln={class:"flex min-w-0 items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},rn={class:"truncate"},dn={class:"truncate"},cn={class:"flex items-center gap-1"},un={key:1,class:"flex flex-col items-center justify-center py-8"},mn={class:"mt-2 text-sm text-gray-500 dark:text-gray-400"},gn={class:"text-xs text-gray-400 dark:text-gray-500"},pn={class:"border-t border-gray-200 px-4 py-3 dark:border-gray-700"},vn=ue({__name:"AIModelConfigTab",emits:["config-changed"],setup(r,{expose:o,emit:a}){const{t:c,locale:n}=ye(),d=a,x=V(()=>JSON.parse(localStorage.getItem(`chatlab_app_config_${n.value}`)||localStorage.getItem("chatlab_app_config")||"{}").aiTips||{}),p=mt(),{configs:f,providers:P,providerRegistry:U,isLoading:I,isMaxConfigs:N}=Ge(p),b=F(!1),G=F("add"),C=F(null);function y(){G.value="add",C.value=null,b.value=!0}function h(M){G.value="edit",C.value=M,b.value=!0}async function v(){await p.refreshConfigs(),d("config-changed")}async function D(M){try{const g=await Me().deleteConfig(M);g.success?(await p.refreshConfigs(),d("config-changed")):console.error("删除配置失败:",g.error)}catch(g){console.error("删除配置失败:",g)}}function A(M){const g=`providers.${M}.name`,_=c(g);return _!==g?_:p.getProviderName(M)}function X(M){const g=U.value.find(_=>_.id===M);return!g||g.kind==="official"||g.kind==="openai-compatible"?null:g.kind==="aggregator"?c("settings.aiConfig.providerKind.aggregator"):g.builtin?null:c("settings.aiConfig.providerKind.custom")}function K(M,g){return g?p.getModelById(M,g)?.name||g:c("settings.aiConfig.defaultModel")}function B(){p.refreshConfigs()}return o({refresh:B}),Fe(()=>{p.isInitialized?p.refreshConfigs():p.init()}),(M,g)=>{const _=Se,T=Qe,q=Ie;return l(),m(re,null,[e(I)?(l(),m("div",Jo,[i(_,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):(l(),m("div",Yo,[t("div",null,[t("h4",Qo,[i(_,{name:"i-heroicons-sparkles",class:"h-4 w-4 text-violet-500"}),S(" "+s(e(c)("settings.aiConfig.title")),1)]),e(f).length===0&&x.value.configTab?.show?(l(),se(Tt,{key:0,content:x.value.configTab?.content},null,8,["content"])):R("",!0),t("div",en,[e(f).length>0?(l(),m("div",tn,[(l(!0),m(re,null,fe(e(f),w=>(l(),m("div",{key:w.id,class:"group flex items-center justify-between px-4 py-2.5 transition-colors hover:bg-gray-100/50 dark:hover:bg-gray-700/30"},[t("div",an,[t("div",sn,[i(_,{name:"i-heroicons-sparkles",class:"h-3.5 w-3.5"})]),t("div",on,[t("span",nn,s(w.name),1),g[2]||(g[2]=t("span",{class:"h-3.5 w-px shrink-0 bg-gray-200 dark:bg-gray-700"},null,-1)),t("span",ln,[t("span",rn,s(A(w.provider)),1),X(w.provider)?(l(),se(T,{key:0,color:"neutral",variant:"subtle",size:"xs"},{default:W(()=>[S(s(X(w.provider)),1)]),_:2},1024)):R("",!0),g[1]||(g[1]=t("span",{class:"shrink-0"},"·",-1)),t("span",dn,s(K(w.provider,w.model)),1)])])]),t("div",cn,[i(q,{size:"xs",color:"neutral",variant:"ghost",icon:"i-heroicons-pencil-square",onClick:$=>h(w)},null,8,["onClick"]),i(q,{size:"xs",color:"error",variant:"ghost",icon:"i-heroicons-trash",onClick:$=>D(w.id)},null,8,["onClick"])])]))),128))])):(l(),m("div",un,[i(_,{name:"i-heroicons-sparkles",class:"h-8 w-8 text-gray-300 dark:text-gray-600"}),t("p",mn,s(e(c)("settings.aiConfig.empty.title")),1),t("p",gn,s(e(c)("settings.aiConfig.empty.description")),1)])),t("div",pn,[i(q,{variant:"soft",disabled:e(N),size:"sm",onClick:y},{default:W(()=>[i(_,{name:"i-heroicons-plus",class:"mr-1.5 h-3.5 w-3.5"}),S(" "+s(e(N)?e(c)("settings.aiConfig.maxConfigs"):e(c)("settings.aiConfig.addConfig")),1)]),_:1},8,["disabled"])])])])])),i(Zo,{open:b.value,"onUpdate:open":g[0]||(g[0]=w=>b.value=w),mode:G.value,config:C.value,providers:e(P),onSaved:v},null,8,["open","mode","config","providers"])],64)}}}),fn={class:"space-y-6"},xn={key:0,class:"rounded-lg border-2 border-dashed border-gray-200 py-8 text-center dark:border-gray-700"},hn={class:"text-sm text-gray-500 dark:text-gray-400"},yn={key:1},bn={class:"mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},_n={class:"space-y-5 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},kn={class:"mb-2"},wn={class:"text-sm font-medium text-gray-900 dark:text-white"},$n={class:"text-xs text-gray-500 dark:text-gray-400"},Cn={class:"flex items-center gap-3"},Mn={class:"flex-1"},In={class:"mb-1 block text-xs text-gray-400 dark:text-gray-500"},Sn={class:"flex-1"},Vn={class:"mb-1 block text-xs text-gray-400 dark:text-gray-500"},Pn={class:"mb-2"},Un={class:"text-sm font-medium text-gray-900 dark:text-white"},zn={class:"text-xs text-gray-500 dark:text-gray-400"},Rn={class:"flex items-center gap-3"},Fn={class:"flex-1"},An={class:"mb-1 block text-xs text-gray-400 dark:text-gray-500"},Nn={class:"flex-1"},Dn={class:"mb-1 block text-xs text-gray-400 dark:text-gray-500"},rt="__follow__",Bn=ue({__name:"AIDefaultModelTab",emits:["config-changed"],setup(r,{emit:o}){const{t:a}=ye(),c=o,n=mt(),{configs:d,defaultAssistant:x,fastModel:p,modelCatalog:f}=Ge(n);function P(D){const A=d.value.find(B=>B.id===D);if(!A)return[];if(A.customModels&&A.customModels.length>0)return A.customModels.map(B=>({label:B.name||B.id,value:B.id}));const K=f.value.filter(B=>B.providerId===A.provider&&!B.capabilities.includes("embedding")&&!B.capabilities.includes("ranking")).map(B=>({label:B.name||B.id,value:B.id}));return A.model&&!K.some(B=>B.value===A.model)&&K.unshift({label:A.model,value:A.model}),K}const U=V(()=>d.value.map(D=>({label:D.name,value:D.id}))),I=V(()=>{const D=x.value?.configId;return D?P(D):[]}),N=V({get:()=>x.value?.configId??"",set:D=>{if(!D)return;const X=P(D)[0]?.value??"";n.setDefaultAssistantModel(D,X),c("config-changed")}}),b=V({get:()=>x.value?.modelId??"",set:D=>{const A=x.value?.configId;A&&D&&(n.setDefaultAssistantModel(A,D),c("config-changed"))}}),G=V(()=>[{label:a("settings.defaultModel.fastModel.followAssistant"),value:rt},...U.value]),C=V(()=>{const D=p.value?.configId;return D?P(D):[]}),y=V(()=>p.value!==null),h=V({get:()=>p.value?.configId??rt,set:D=>{if(D===rt)n.setFastModel(null);else{const X=P(D)[0]?.value??"";n.setFastModel({configId:D,modelId:X})}c("config-changed")}}),v=V({get:()=>p.value?.modelId??"",set:D=>{const A=p.value?.configId;A&&D&&(n.setFastModel({configId:A,modelId:D}),c("config-changed"))}});return Fe(()=>{n.isInitialized||n.init()}),(D,A)=>{const X=Se,K=Rt;return l(),m("div",fn,[e(d).length===0?(l(),m("div",xn,[i(X,{name:"i-heroicons-cpu-chip",class:"mx-auto mb-2 h-8 w-8 text-gray-300 dark:text-gray-600"}),t("p",hn,s(e(a)("settings.defaultModel.noConfigs")),1)])):(l(),m("div",yn,[t("h4",bn,[i(X,{name:"i-heroicons-cpu-chip",class:"h-4 w-4 text-violet-500"}),S(" "+s(e(a)("settings.defaultModel.title")),1)]),t("div",_n,[t("div",null,[t("div",kn,[t("p",wn,s(e(a)("settings.defaultModel.assistantModel.label")),1),t("p",$n,s(e(a)("settings.defaultModel.assistantModel.description")),1)]),t("div",Cn,[t("div",Mn,[t("span",In,s(e(a)("settings.defaultModel.selectProvider")),1),i(K,{modelValue:N.value,"onUpdate:modelValue":A[0]||(A[0]=B=>N.value=B),items:U.value,ui:{content:"z-[200]"},class:"w-full",size:"sm"},null,8,["modelValue","items"])]),t("div",Sn,[t("span",Vn,s(e(a)("settings.defaultModel.selectModel")),1),I.value.length>0?(l(),se(K,{key:0,modelValue:b.value,"onUpdate:modelValue":A[1]||(A[1]=B=>b.value=B),items:I.value,ui:{content:"z-[200]"},class:"w-full",size:"sm"},null,8,["modelValue","items"])):(l(),se(K,{key:1,items:[],disabled:"",class:"w-full",size:"sm"}))])])]),t("div",null,[t("div",Pn,[t("p",Un,s(e(a)("settings.defaultModel.fastModel.label")),1),t("p",zn,s(e(a)("settings.defaultModel.fastModel.description")),1)]),t("div",Rn,[t("div",Fn,[t("span",An,s(e(a)("settings.defaultModel.selectProvider")),1),i(K,{modelValue:h.value,"onUpdate:modelValue":A[2]||(A[2]=B=>h.value=B),items:G.value,ui:{content:"z-[200]"},class:"w-full",size:"sm"},null,8,["modelValue","items"])]),t("div",Nn,[t("span",Dn,s(e(a)("settings.defaultModel.selectModel")),1),y.value&&C.value.length>0?(l(),se(K,{key:0,modelValue:v.value,"onUpdate:modelValue":A[3]||(A[3]=B=>v.value=B),items:C.value,ui:{content:"z-[200]"},class:"w-full",size:"sm"},null,8,["modelValue","items"])):(l(),se(K,{key:1,items:[],disabled:"",class:"w-full",size:"sm"}))])])])])]))])}}}),En={slots:{root:"relative inline-flex items-center",base:["w-full rounded-md border-0 placeholder:text-dimmed disabled:cursor-not-allowed disabled:opacity-75","transition-colors"],increment:"absolute flex items-center",decrement:"absolute flex items-center"},variants:{fieldGroup:{horizontal:{root:"group has-focus-visible:z-[1]",base:"group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none"},vertical:{root:"group has-focus-visible:z-[1]",base:"group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none"}},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},size:{xs:"px-2 py-1 text-sm/4 gap-1",sm:"px-2.5 py-1.5 text-sm/4 gap-1.5",md:"px-2.5 py-1.5 text-base/5 gap-1.5",lg:"px-3 py-2 text-base/5 gap-2",xl:"px-3 py-2 text-base gap-2"},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented",soft:"text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented",ghost:"text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent focus:outline-none"},disabled:{true:{increment:"opacity-75 cursor-not-allowed",decrement:"opacity-75 cursor-not-allowed"}},orientation:{horizontal:{base:"text-center",increment:"inset-y-0 end-0 pe-1",decrement:"inset-y-0 start-0 ps-1"},vertical:{increment:"top-0 end-0 pe-1 [&>button]:py-0 scale-80",decrement:"bottom-0 end-0 pe-1 [&>button]:py-0 scale-80"}},highlight:{true:""},fixed:{false:""},increment:{false:""},decrement:{false:""}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 focus-visible:outline-3 focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 focus-visible:outline-3 focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 focus-visible:outline-3 focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{orientation:"horizontal",decrement:!1,class:"text-start"},{decrement:!0,size:"xs",class:"ps-7"},{decrement:!0,size:"sm",class:"ps-8"},{decrement:!0,size:"md",class:"ps-9"},{decrement:!0,size:"lg",class:"ps-10"},{decrement:!0,size:"xl",class:"ps-11"},{increment:!0,size:"xs",class:"pe-7"},{increment:!0,size:"sm",class:"pe-8"},{increment:!0,size:"md",class:"pe-9"},{increment:!0,size:"lg",class:"pe-10"},{increment:!0,size:"xl",class:"pe-11"},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline"}},Wt=Object.assign({inheritAttrs:!1},{__name:"InputNumber",props:{as:{type:null,required:!1},placeholder:{type:String,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},highlight:{type:Boolean,required:!1},fixed:{type:Boolean,required:!1},orientation:{type:null,required:!1,default:"horizontal"},increment:{type:[Boolean,Object],required:!1,default:!0},incrementIcon:{type:null,required:!1},incrementDisabled:{type:Boolean,required:!1},decrement:{type:[Boolean,Object],required:!1,default:!0},decrementIcon:{type:null,required:!1},decrementDisabled:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},min:{type:Number,required:!1},max:{type:Number,required:!1},step:{type:Number,required:!1},stepSnapping:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},required:{type:Boolean,required:!1},id:{type:String,required:!1},name:{type:String,required:!1},formatOptions:{type:null,required:!1},disableWheelChange:{type:Boolean,required:!1},invertWheelChange:{type:Boolean,required:!1},readonly:{type:Boolean,required:!1},focusOnChange:{type:Boolean,required:!1},locale:{type:String,required:!1}},emits:["update:modelValue","blur","change"],setup(r,{expose:o,emit:a}){const c=r,n=a,d=ta("inputNumber",c),x=Pt(d,"modelValue",n,{defaultValue:d.defaultValue}),{t:p}=aa(),f=da(),P=sa(oa(d,"as","stepSnapping","formatOptions","disableWheelChange","invertWheelChange","required","readonly","focusOnChange","locale"),n),{emitFormBlur:U,emitFormFocus:I,emitFormChange:N,emitFormInput:b,id:G,color:C,size:y,name:h,highlight:v,disabled:D,ariaAttrs:A}=na(c),{orientation:X,size:K}=ia(c),B=V(()=>K.value||y.value),M=V(()=>yt({extend:yt(En),...f.ui?.inputNumber||{}})({color:C.value??d.color,variant:d.variant,size:B.value??d.size,highlight:v.value??d.highlight,fixed:d.fixed,orientation:d.orientation,fieldGroup:X.value,increment:d.orientation==="vertical"?!!d.increment||!!d.decrement:!!d.increment,decrement:d.orientation==="vertical"?!1:!!d.decrement})),g=V(()=>d.incrementIcon||(d.orientation==="horizontal"?f.ui.icons.plus:f.ui.icons.chevronUp)),_=V(()=>d.decrementIcon||(d.orientation==="horizontal"?f.ui.icons.minus:f.ui.icons.chevronDown)),T=la("inputRef");function q(J){d.modelModifiers?.optional&&(x.value=J=J??void 0);const O=new Event("change",{target:{value:J}});n("change",O),N(),b()}function w(J){U(),n("blur",J)}function $(){d.autofocus&&T.value?.$el?.focus()}return Fe(()=>{setTimeout(()=>{$()},d.autofocusDelay)}),o({inputRef:ra(()=>T.value?.$el)}),(J,O)=>(l(),se(e(Aa),ze(e(P),{id:e(G),"default-value":e(d).defaultValue,"model-value":e(x),min:e(d).min,max:e(d).max,step:e(d).step,"data-slot":"root",class:M.value.root({class:[e(d).ui?.root,e(d).class]}),name:e(h),disabled:e(D),"onUpdate:modelValue":O[0]||(O[0]=oe=>q(oe))}),{default:W(()=>[i(e(qa),ze({...J.$attrs,...e(A)},{ref_key:"inputRef",ref:T,placeholder:e(d).placeholder,required:e(d).required,"data-slot":"base",class:M.value.base({class:e(d).ui?.base}),onBlur:w,onFocus:e(I)}),null,16,["placeholder","required","class","onFocus"]),e(d).increment?(l(),m("div",{key:0,"data-slot":"increment",class:Re(M.value.increment({class:e(d).ui?.increment}))},[i(e(Ea),{"as-child":"",disabled:e(D)||e(d).incrementDisabled},{default:W(()=>[Te(J.$slots,"increment",{},()=>[i(Ie,ze({icon:g.value,color:e(C),size:B.value,variant:"link","aria-label":e(p)("inputNumber.increment")},typeof e(d).increment=="object"?e(d).increment:void 0),null,16,["icon","color","size","aria-label"])])]),_:3},8,["disabled"])],2)):R("",!0),e(d).decrement?(l(),m("div",{key:1,"data-slot":"decrement",class:Re(M.value.decrement({class:e(d).ui?.decrement}))},[i(e(Da),{"as-child":"",disabled:e(D)||e(d).decrementDisabled},{default:W(()=>[Te(J.$slots,"decrement",{},()=>[i(Ie,ze({icon:_.value,color:e(C),size:B.value,variant:"link","aria-label":e(p)("inputNumber.decrement")},typeof e(d).decrement=="object"?e(d).decrement:void 0),null,16,["icon","color","size","aria-label"])])]),_:3},8,["disabled"])],2)):R("",!0)]),_:3},16,["id","default-value","model-value","min","max","step","class","name","disabled"]))}}),Kn={class:"space-y-6"},qn={class:"mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},Tn={class:"space-y-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},Wn={class:"flex items-center justify-between"},On={class:"flex-1 pr-4"},jn={class:"text-sm font-medium text-gray-900 dark:text-white"},Ln={class:"text-xs text-gray-500 dark:text-gray-400"},Gn={class:"flex items-center justify-between"},Hn={class:"flex-1 pr-4"},Xn={class:"text-sm font-medium text-gray-900 dark:text-white"},Zn={class:"text-xs text-gray-500 dark:text-gray-400"},Jn={class:"flex flex-col items-end gap-1"},Yn={class:"max-w-64 text-right text-xs text-gray-500 dark:text-gray-400"},Qn={class:"mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},ei={class:"space-y-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},ti={class:"flex items-center justify-between"},ai={class:"flex-1 pr-4"},si={class:"text-sm font-medium text-gray-900 dark:text-white"},oi={class:"text-xs text-gray-500 dark:text-gray-400"},ni={class:"mb-2"},ii={class:"text-sm font-medium text-gray-900 dark:text-white"},li={class:"text-xs text-gray-500 dark:text-gray-400"},ri={class:"flex items-center gap-4"},di={class:"flex items-center gap-2"},ci={class:"text-xs text-gray-500 dark:text-gray-400"},ui={class:"flex items-center gap-2"},mi={class:"text-xs text-gray-500 dark:text-gray-400"},gi=ue({__name:"AIPromptConfigTab",props:{setSectionRef:{type:Function}},emits:["config-changed"],setup(r,{emit:o}){const{t:a}=ye(),c=Nt(),{aiGlobalSettings:n}=Ge(c),d=r,x=o;function p(C,y){d.setSectionRef?.(C,y)}const f=V({get:()=>n.value.maxMessagesPerRequest,set:C=>{const y=Math.max(0,Math.min(5e4,C||1e3));c.updateAIGlobalSettings({maxMessagesPerRequest:y}),x("config-changed")}}),P=V({get:()=>n.value.enableAutoSkill??!0,set:C=>{c.updateAIGlobalSettings({enableAutoSkill:C}),x("config-changed")}}),U=V(()=>[{label:a("settings.aiPrompt.chatPreferences.chartAutoMode.explicit"),value:"explicit"},{label:a("settings.aiPrompt.chatPreferences.chartAutoMode.suggest"),value:"suggest"},{label:a("settings.aiPrompt.chatPreferences.chartAutoMode.aggressive"),value:"aggressive"}]),I=V({get:()=>n.value.chartAutoMode??"suggest",set:C=>{c.updateAIGlobalSettings({chartAutoMode:C}),x("config-changed")}}),N=V(()=>a(`settings.aiPrompt.chatPreferences.chartAutoMode.${I.value}Hint`)),b=V({get:()=>n.value.searchContextBefore??3,set:C=>{const y=Math.max(0,Math.min(20,C??3));c.updateAIGlobalSettings({searchContextBefore:y}),x("config-changed")}}),G=V({get:()=>n.value.searchContextAfter??3,set:C=>{const y=Math.max(0,Math.min(20,C??3));c.updateAIGlobalSettings({searchContextAfter:y}),x("config-changed")}});return(C,y)=>{const h=Se,v=vt,D=zt,A=Wt;return l(),m("div",Kn,[t("div",{ref:X=>p("skill",X)},[t("h4",qn,[i(h,{name:"i-heroicons-bolt",class:"h-4 w-4 text-amber-500"}),S(" "+s(e(a)("settings.aiPrompt.chatPreferences.title")),1)]),t("div",Tn,[t("div",Wn,[t("div",On,[t("p",jn,s(e(a)("settings.aiPrompt.chatPreferences.enableAutoSkill")),1),t("p",Ln,s(e(a)("settings.aiPrompt.chatPreferences.enableAutoSkillDesc")),1)]),i(v,{modelValue:P.value,"onUpdate:modelValue":y[0]||(y[0]=X=>P.value=X)},null,8,["modelValue"])]),t("div",Gn,[t("div",Hn,[t("p",Xn,s(e(a)("settings.aiPrompt.chatPreferences.chartAutoMode.title")),1),t("p",Zn,s(e(a)("settings.aiPrompt.chatPreferences.chartAutoMode.description")),1)]),t("div",Jn,[i(D,{modelValue:I.value,"onUpdate:modelValue":y[1]||(y[1]=X=>I.value=X),items:U.value,disabled:!P.value,size:"xs"},null,8,["modelValue","items","disabled"]),t("p",Yn,s(N.value),1)])])])],512),t("div",{ref:X=>p("chat",X)},[t("h4",Qn,[i(h,{name:"i-heroicons-chat-bubble-left-right",class:"h-4 w-4 text-green-500"}),S(" "+s(e(a)("settings.aiPrompt.chatSettings.title")),1)]),t("div",ei,[t("div",ti,[t("div",ai,[t("p",si,s(e(a)("settings.aiPrompt.maxMessages.title")),1),t("p",oi,s(e(a)("settings.aiPrompt.maxMessages.description")),1)]),i(A,{modelValue:f.value,"onUpdate:modelValue":y[2]||(y[2]=X=>f.value=X),min:0,max:5e4,class:"w-30"},null,8,["modelValue"])]),t("div",null,[t("div",ni,[t("p",ii,s(e(a)("settings.aiPrompt.searchContext.title")),1),t("p",li,s(e(a)("settings.aiPrompt.searchContext.description")),1)]),t("div",ri,[t("div",di,[t("span",ci,s(e(a)("settings.aiPrompt.searchContext.before")),1),i(A,{modelValue:b.value,"onUpdate:modelValue":y[3]||(y[3]=X=>b.value=X),min:0,max:20,class:"w-24"},null,8,["modelValue"])]),t("div",ui,[t("span",mi,s(e(a)("settings.aiPrompt.searchContext.after")),1),i(A,{modelValue:G.value,"onUpdate:modelValue":y[4]||(y[4]=X=>G.value=X),min:0,max:20,class:"w-24"},null,8,["modelValue"])])])])])],512)])}}}),pi={class:"space-y-6"},vi={class:"mb-1 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},fi={class:"text-xs text-gray-500 dark:text-gray-400"},xi={class:"space-y-3 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},hi={class:"flex items-center justify-between"},yi={class:"flex-1 pr-4"},bi={class:"text-sm font-medium text-gray-900 dark:text-white"},_i={class:"text-xs text-gray-500 dark:text-gray-400"},ki={class:"flex items-center justify-between"},wi={class:"flex-1 pr-4"},$i={class:"text-sm font-medium text-gray-900 dark:text-white"},Ci={class:"text-xs text-gray-500 dark:text-gray-400"},Mi={key:0,class:"ml-6 flex items-center justify-between"},Ii={class:"text-xs text-gray-500 dark:text-gray-400"},Si={class:"flex items-center justify-between"},Vi={class:"flex-1 pr-4"},Pi={class:"text-sm font-medium text-gray-900 dark:text-white"},Ui={class:"text-xs text-gray-500 dark:text-gray-400"},zi={class:"flex items-center justify-between"},Ri={class:"flex-1 pr-4"},Fi={class:"text-sm font-medium text-gray-900 dark:text-white"},Ai={class:"text-xs text-gray-500 dark:text-gray-400"},Ni={class:"flex items-center justify-between"},Di={class:"flex-1 pr-4"},Bi={class:"text-sm font-medium text-gray-900 dark:text-white"},Ei={class:"text-xs text-gray-500 dark:text-gray-400"},Ki={key:1,class:"ml-4 space-y-3"},qi={key:0},Ti={class:"mb-2 flex items-center justify-between gap-3"},Wi={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Oi={class:"space-y-2"},ji={class:"flex items-center gap-2 px-2.5 py-2"},Li=["onClick"],Gi={class:"min-w-0 flex-1"},Hi={class:"block truncate text-xs font-medium text-gray-700 dark:text-gray-200"},Xi={key:0,class:"block truncate text-[10px] text-gray-400"},Zi={class:"shrink-0 text-[10px] text-gray-400"},Ji={key:0,class:"border-t border-gray-100 px-2 py-1.5 dark:border-gray-800"},Yi=["checked","onChange"],Qi={class:"flex-1 text-xs text-gray-700 dark:text-gray-300"},el={key:0,class:"shrink-0 text-[10px] text-gray-400"},tl={class:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-400"},al={key:0,class:"mb-2 space-y-1.5"},sl=["checked","onChange"],ol={class:"flex-1 text-xs text-gray-700 dark:text-gray-300"},nl=["title"],il={class:"space-y-3 rounded-md border border-dashed border-gray-300 p-3 dark:border-gray-600"},ll={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},rl={class:"grid grid-cols-[auto_1fr] items-center gap-x-3 gap-y-2"},dl={class:"text-[11px] text-gray-500 dark:text-gray-400 whitespace-nowrap"},cl={class:"text-[11px] text-gray-500 dark:text-gray-400 whitespace-nowrap"},ul={key:0,class:"mt-1 text-xs text-red-500"},ml={class:"text-[11px] text-gray-500 dark:text-gray-400 whitespace-nowrap"},gl={class:"mb-2 text-sm font-medium text-gray-900 dark:text-white"},pl={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},vl={class:"mb-3 flex gap-2"},fl={key:0,class:"flex flex-wrap gap-2"},xl=ue({__name:"AIPreprocessTab",setup(r){const{t:o,te:a}=ye(),c=Ut(),{aiPreprocessConfig:n}=Ge(c);Fe(()=>c.ensureDesensitizeRules());const d=F(""),x=F({}),p=["credentials","global_contact","global_financial","global_network","region_cn","region_us","region_jp","region_kr"];function f(){const w=d.value.trim();if(w){if(n.value.blacklistKeywords.includes(w)){d.value="";return}n.value.blacklistKeywords.push(w),d.value=""}}function P(w){n.value.blacklistKeywords.splice(w,1)}const U=V(()=>n.value.desensitizeRules.filter(w=>w.builtin)),I=V(()=>n.value.desensitizeRules.filter(w=>!w.builtin)),N=V(()=>{const w=new Map;for(const $ of U.value){const J=$.group??"global_contact";w.set(J,[...w.get(J)??[],$])}return p.map($=>({id:$,rules:w.get($)??[]})).filter($=>$.rules.length>0)}),b=F({name:"",pattern:"",replacement:""}),G=F("");function C(w){const $=`settings.desensitize.rules.${w.id}`;return a($)?o($):w.label}function y(w){const $=`settings.desensitize.rules.${w.id}_desc`;return a($)?o($):""}function h(w){const $=`settings.desensitize.groups.${w}`;return a($)?o($):w}function v(w){const $=`settings.desensitize.groups.${w}_desc`;return a($)?o($):""}function D(w){return x.value[w]??!1}function A(w){x.value={...x.value,[w]:!D(w)}}function X(w){const $=w.filter(J=>J.enabled).length;return{checked:w.length>0&&$===w.length,indeterminate:$>0&&$<w.length}}function K(w,$){n.value.desensitizeBuiltinRuleOverrides={...n.value.desensitizeBuiltinRuleOverrides??{},[w]:$}}function B(w){const $=n.value.desensitizeRules.find(J=>J.id===w);$&&($.enabled=!$.enabled,$.builtin&&K($.id,$.enabled))}function M(w,$){w.enabled=$,w.builtin&&K(w.id,$)}function g(w,$){for(const J of w)M(J,$)}function _(){const w={...n.value.desensitizeBuiltinRuleOverrides??{}};for(const $ of U.value)delete w[$.id],$.enabled=!0;n.value.desensitizeBuiltinRuleOverrides=w}function T(){const w=b.value.name.trim(),$=b.value.pattern.trim(),J=b.value.replacement.trim();if(!(!w||!$||!J)){try{new RegExp($),G.value=""}catch{G.value=o("settings.aiPreprocess.desensitizeRuleInvalidRegex");return}n.value.desensitizeRules.push({id:`custom_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,label:w,pattern:$,replacement:J,enabled:!0,builtin:!1,locales:[]}),b.value={name:"",pattern:"",replacement:""}}}function q(w){const $=n.value.desensitizeRules.findIndex(J=>J.id===w);$!==-1&&n.value.desensitizeRules.splice($,1)}return(w,$)=>{const J=Se,O=vt,oe=Wt,de=Dt,me=Ie,ee=De,le=Qe;return l(),m("div",pi,[t("div",null,[t("h4",vi,[i(J,{name:"i-heroicons-funnel",class:"h-4 w-4 text-amber-500"}),S(" "+s(e(o)("settings.aiPreprocess.title")),1)]),t("p",fi,s(e(o)("settings.aiPreprocess.description")),1)]),t("div",xi,[t("div",hi,[t("div",yi,[t("p",bi,s(e(o)("settings.aiPreprocess.dataCleaning")),1),t("p",_i,s(e(o)("settings.aiPreprocess.dataCleaningDesc")),1)]),i(O,{modelValue:e(n).dataCleaning,"onUpdate:modelValue":$[0]||($[0]=H=>e(n).dataCleaning=H)},null,8,["modelValue"])]),t("div",ki,[t("div",wi,[t("p",$i,s(e(o)("settings.aiPreprocess.mergeConsecutive")),1),t("p",Ci,s(e(o)("settings.aiPreprocess.mergeConsecutiveDesc")),1)]),i(O,{modelValue:e(n).mergeConsecutive,"onUpdate:modelValue":$[1]||($[1]=H=>e(n).mergeConsecutive=H)},null,8,["modelValue"])]),e(n).mergeConsecutive?(l(),m("div",Mi,[t("p",Ii,s(e(o)("settings.aiPreprocess.mergeWindow")),1),i(oe,{modelValue:e(n).mergeWindowSeconds,"onUpdate:modelValue":$[2]||($[2]=H=>e(n).mergeWindowSeconds=H),min:30,max:600,step:30,class:"w-28"},null,8,["modelValue"])])):R("",!0),t("div",Si,[t("div",Vi,[t("p",Pi,s(e(o)("settings.aiPreprocess.denoise")),1),t("p",Ui,s(e(o)("settings.aiPreprocess.denoiseDesc")),1)]),i(O,{modelValue:e(n).denoise,"onUpdate:modelValue":$[3]||($[3]=H=>e(n).denoise=H)},null,8,["modelValue"])]),t("div",zi,[t("div",Ri,[t("p",Fi,s(e(o)("settings.aiPreprocess.anonymizeNames")),1),t("p",Ai,s(e(o)("settings.aiPreprocess.anonymizeNamesDesc")),1)]),i(O,{modelValue:e(n).anonymizeNames,"onUpdate:modelValue":$[4]||($[4]=H=>e(n).anonymizeNames=H)},null,8,["modelValue"])]),t("div",Ni,[t("div",Di,[t("p",Bi,s(e(o)("settings.aiPreprocess.desensitize")),1),t("p",Ei,s(e(o)("settings.aiPreprocess.desensitizeDesc")),1)]),i(O,{modelValue:e(n).desensitize,"onUpdate:modelValue":$[5]||($[5]=H=>e(n).desensitize=H)},null,8,["modelValue"])]),e(n).desensitize?(l(),m("div",Ki,[U.value.length>0?(l(),m("div",qi,[t("div",Ti,[t("p",Wi,s(e(o)("settings.aiPreprocess.desensitizeBuiltin")),1),t("button",{type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",onClick:_},[i(J,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5"}),S(" "+s(e(o)("settings.aiPreprocess.desensitizeResetBuiltin")),1)])]),t("div",Oi,[(l(!0),m(re,null,fe(N.value,H=>(l(),m("div",{key:H.id,class:"rounded-md border border-gray-200 bg-white dark:border-gray-700 dark:bg-page-dark/40"},[t("div",ji,[i(de,{"model-value":X(H.rules).checked,indeterminate:X(H.rules).indeterminate,size:"xs","onUpdate:modelValue":ne=>g(H.rules,!!ne)},null,8,["model-value","indeterminate","onUpdate:modelValue"]),t("button",{type:"button",class:"flex min-w-0 flex-1 items-center gap-2 text-left",onClick:ne=>A(H.id)},[i(J,{name:D(H.id)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3.5 w-3.5 shrink-0 text-gray-400"},null,8,["name"]),t("span",Gi,[t("span",Hi,s(h(H.id)),1),v(H.id)?(l(),m("span",Xi,s(v(H.id)),1)):R("",!0)]),t("span",Zi,s(H.rules.filter(ne=>ne.enabled).length)+"/"+s(H.rules.length),1)],8,Li)]),D(H.id)?(l(),m("div",Ji,[(l(!0),m(re,null,fe(H.rules,ne=>(l(),m("label",{key:ne.id,class:"flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700/50"},[t("input",{type:"checkbox",checked:ne.enabled,class:"h-3.5 w-3.5 rounded border-gray-300 text-primary-500 focus:ring-primary-500",onChange:ke=>B(ne.id)},null,40,Yi),t("span",Qi,s(C(ne)),1),y(ne)?(l(),m("span",el,s(y(ne)),1)):R("",!0)]))),128))])):R("",!0)]))),128))])])):R("",!0),t("div",null,[t("p",tl,s(e(o)("settings.aiPreprocess.desensitizeCustom")),1),I.value.length>0?(l(),m("div",al,[(l(!0),m(re,null,fe(I.value,H=>(l(),m("div",{key:H.id,class:"flex items-center gap-2.5 rounded-md px-2 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700/50"},[t("input",{type:"checkbox",checked:H.enabled,class:"h-3.5 w-3.5 rounded border-gray-300 text-primary-500 focus:ring-primary-500",onChange:ne=>B(H.id)},null,40,sl),t("span",ol,s(H.label),1),t("code",{class:"max-w-40 shrink-0 truncate text-[10px] text-gray-400",title:H.pattern},s(H.pattern),9,nl),i(me,{icon:"i-heroicons-x-mark",variant:"ghost",size:"2xs",color:"error",onClick:ne=>q(H.id)},null,8,["onClick"])]))),128))])):R("",!0),t("div",il,[t("p",ll,s(e(o)("settings.aiPreprocess.desensitizeAddCustom")),1),t("div",rl,[t("label",dl,s(e(o)("settings.aiPreprocess.desensitizeRuleName"))+": ",1),i(ee,{modelValue:b.value.name,"onUpdate:modelValue":$[6]||($[6]=H=>b.value.name=H),placeholder:e(o)("settings.aiPreprocess.desensitizeRuleNamePlaceholder"),size:"xs",class:"w-full"},null,8,["modelValue","placeholder"]),t("label",cl,s(e(o)("settings.aiPreprocess.desensitizeRulePattern"))+": ",1),t("div",null,[i(ee,{modelValue:b.value.pattern,"onUpdate:modelValue":$[7]||($[7]=H=>b.value.pattern=H),placeholder:e(o)("settings.aiPreprocess.desensitizeRulePatternPlaceholder"),size:"xs",class:"w-full font-mono"},null,8,["modelValue","placeholder"]),G.value?(l(),m("p",ul,s(G.value),1)):R("",!0)]),t("label",ml,s(e(o)("settings.aiPreprocess.desensitizeRuleReplacement"))+": ",1),i(ee,{modelValue:b.value.replacement,"onUpdate:modelValue":$[8]||($[8]=H=>b.value.replacement=H),placeholder:e(o)("settings.aiPreprocess.desensitizeRuleReplacementPlaceholder"),size:"xs",class:"w-full"},null,8,["modelValue","placeholder"])]),i(me,{size:"xs",variant:"soft",block:"",disabled:!b.value.name.trim()||!b.value.pattern.trim()||!b.value.replacement.trim(),onClick:T},{default:W(()=>[S(s(e(o)("settings.aiPreprocess.desensitizeRuleAdd")),1)]),_:1},8,["disabled"])])])])):R("",!0)]),t("div",null,[t("h4",gl,s(e(o)("settings.aiPreprocess.blacklist")),1),t("p",pl,s(e(o)("settings.aiPreprocess.blacklistDesc")),1),t("div",vl,[i(ee,{modelValue:d.value,"onUpdate:modelValue":$[9]||($[9]=H=>d.value=H),placeholder:e(o)("settings.aiPreprocess.blacklistPlaceholder"),class:"flex-1",size:"sm",onKeydown:ca(Ye(f,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"]),i(me,{size:"sm",variant:"soft",disabled:!d.value.trim(),onClick:f},{default:W(()=>[S(s(e(o)("settings.aiPreprocess.blacklistAdd")),1)]),_:1},8,["disabled"])]),e(n).blacklistKeywords.length>0?(l(),m("div",fl,[(l(!0),m(re,null,fe(e(n).blacklistKeywords,(H,ne)=>(l(),se(le,{key:H,variant:"subtle",color:"error",class:"cursor-pointer",onClick:ke=>P(ne)},{default:W(()=>[S(s(H)+" ",1),i(J,{name:"i-heroicons-x-mark",class:"ml-1 h-3 w-3"})]),_:2},1032,["onClick"]))),128))])):R("",!0)])])}}}),hl={class:"mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},yl={class:"space-y-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},bl={class:"flex items-center justify-between"},_l={class:"flex-1 pr-4"},kl={class:"text-sm font-medium text-gray-900 dark:text-white"},wl={class:"text-xs text-gray-500 dark:text-gray-400"},$l={class:"flex items-center justify-between"},Cl={class:"flex-1 pr-4"},Ml={class:"text-sm font-medium text-gray-900 dark:text-white"},Il={class:"text-xs text-gray-500 dark:text-gray-400"},Sl=ue({__name:"AIExportSettingsTab",emits:["config-changed"],setup(r,{emit:o}){const{t:a}=ye(),c=o,n=Nt(),{aiGlobalSettings:d}=Ge(n),x=V(()=>[{label:"Markdown",value:"markdown"},{label:a("settings.aiPrompt.exportFormat.txtLabel"),value:"txt"}]),p=V({get:()=>d.value.exportFormat??"markdown",set:U=>{n.updateAIGlobalSettings({exportFormat:U}),c("config-changed")}}),f=V(()=>[{label:"CSV",value:"csv"},{label:"JSON",value:"json"}]),P=V({get:()=>d.value.sqlExportFormat??"csv",set:U=>{n.updateAIGlobalSettings({sqlExportFormat:U}),c("config-changed")}});return(U,I)=>{const N=Se,b=zt;return l(),m("div",null,[t("h4",hl,[i(N,{name:"i-heroicons-arrow-down-tray",class:"h-4 w-4 text-blue-500"}),S(" "+s(e(a)("settings.aiPrompt.exportSettings.title")),1)]),t("div",yl,[t("div",bl,[t("div",_l,[t("p",kl,s(e(a)("settings.aiPrompt.exportFormat.title")),1),t("p",wl,s(e(a)("settings.aiPrompt.exportFormat.description")),1)]),i(b,{modelValue:p.value,"onUpdate:modelValue":I[0]||(I[0]=G=>p.value=G),items:x.value,size:"xs"},null,8,["modelValue","items"])]),t("div",$l,[t("div",Cl,[t("p",Ml,s(e(a)("settings.aiPrompt.sqlExportFormat.title")),1),t("p",Il,s(e(a)("settings.aiPrompt.sqlExportFormat.description")),1)]),i(b,{modelValue:P.value,"onUpdate:modelValue":I[1]||(I[1]=G=>P.value=G),items:f.value,size:"xs"},null,8,["modelValue","items"])])])])}}}),Vl={class:"space-y-3"},Pl={class:"flex items-center justify-between"},Ul={class:"flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},zl={class:"mt-0.5 text-xs text-gray-500 dark:text-gray-400"},Rl={class:"flex items-center justify-between rounded-lg border border-gray-200 bg-gray-50 px-4 py-3 dark:border-gray-700 dark:bg-gray-800/50"},Fl={class:"text-sm text-gray-700 dark:text-gray-300"},Al={class:"text-xs text-gray-400"},Nl={class:"flex items-center justify-between rounded-lg border border-gray-200 bg-gray-50 px-4 py-3 dark:border-gray-700 dark:bg-gray-800/50"},Dl={class:"text-sm text-gray-700 dark:text-gray-300"},Bl={class:"text-xs text-gray-400"},El={class:"flex items-center gap-2"},Kl={class:"text-xs text-gray-500"},ql={class:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-3 dark:border-gray-700 dark:bg-gray-800/50"},Tl={class:"flex items-center justify-between"},Wl={class:"text-sm text-gray-700 dark:text-gray-300"},Ol={key:0,class:"mt-1 flex items-center gap-3 text-xs"},jl={class:"text-gray-500"},Ll={class:"text-green-600 dark:text-green-400"},Gl={key:0,class:"text-amber-600 dark:text-amber-400"},Hl={key:1,class:"mt-1 flex items-center gap-1 text-xs text-gray-400"},Xl={class:"flex items-center gap-2"},Zl={key:0,class:"mt-3 space-y-2"},Jl={class:"flex items-center justify-between text-xs"},Yl={class:"text-gray-500"},Ql={class:"font-medium text-gray-700 dark:text-gray-300"},er={class:"p-5"},tr={class:"mb-4 flex items-center gap-3"},ar={class:"flex h-10 w-10 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},sr={class:"text-lg font-semibold text-gray-900 dark:text-white"},or={class:"space-y-3 text-sm text-gray-600 dark:text-gray-400"},nr={class:"rounded-lg border border-red-200 bg-red-50 p-3 dark:border-red-800/50 dark:bg-red-900/20"},ir={class:"text-xs text-red-700 dark:text-red-400"},lr={class:"mt-5 flex justify-end gap-2"},rr=30,dr=ue({__name:"SessionIndexSection",setup(r){const{t:o}=ye(),a=F(rr),c=F("standard"),n=V(()=>[{label:o("settings.ai.session.summaryBrief"),value:"brief"},{label:o("settings.ai.session.summaryStandard"),value:"standard"}]),d=F([]),x=F(!1),p=F(!1),f=F({current:0,total:0,currentName:""}),P=F(!1),U=V(()=>{const K=d.value.length,B=d.value.filter(g=>g.hasIndex).length,M=K-B;return{total:K,generated:B,notGenerated:M}}),I=V(()=>f.value.total===0?0:Math.round(f.value.current/f.value.total*100));function N(){a.value<1&&(a.value=1),a.value>1440&&(a.value=1440),bt({session_gap_threshold:a.value*60})}function b(){const K=ga();a.value=Math.round(K/60)}function G(K){c.value=K,bt({summary_strategy:K})}async function C(){x.value=!0;try{const[K,B]=await Promise.all([pt().getSessions(),ot().getAllIndexStats()]),M=new Map(B.map(g=>[g.sessionId,g]));d.value=K.map(g=>{const _=M.get(g.id);return{id:g.id,name:g.name,hasIndex:_?.hasIndex??!1,sessionCount:_?.sessionCount??0}})}catch(K){console.error("加载会话索引状态失败:",K)}finally{x.value=!1}}async function y(){const K=d.value.filter(M=>!M.hasIndex);if(K.length===0)return;p.value=!0,f.value={current:0,total:K.length,currentName:""};const B=a.value*60;for(let M=0;M<K.length;M++){const g=K[M];f.value={current:M,total:K.length,currentName:g.name};try{const _=await ot().generate(g.id,B),T=d.value.find(q=>q.id===g.id);T&&(T.hasIndex=!0,T.sessionCount=_)}catch(_){console.error(`生成会话 ${g.name} 索引失败:`,_)}}f.value={current:K.length,total:K.length,currentName:""},p.value=!1}function h(){P.value=!1,v()}async function v(){if(d.value.length===0)return;p.value=!0,f.value={current:0,total:d.value.length,currentName:""};const K=a.value*60;for(let B=0;B<d.value.length;B++){const M=d.value[B];f.value={current:B,total:d.value.length,currentName:M.name};try{const g=await ot().generate(M.id,K);M.hasIndex=!0,M.sessionCount=g}catch(g){console.error(`生成会话 ${M.name} 索引失败:`,g)}}f.value={current:d.value.length,total:d.value.length,currentName:""},p.value=!1}const D=F(null);let A=null,X=!1;return Fe(()=>{b(),c.value=ua(),A=new IntersectionObserver(K=>{K[0]?.isIntersecting&&!X&&(X=!0,C(),A?.disconnect())},{threshold:.1}),D.value&&A.observe(D.value)}),gt(()=>{A?.disconnect()}),(K,B)=>{const M=Se,g=Ie,_=De,T=ma,q=We;return l(),m("div",{ref_key:"sectionRef",ref:D,class:"space-y-6"},[t("div",Vl,[t("div",Pl,[t("div",null,[t("h3",Ul,[i(M,{name:"i-heroicons-clock",class:"h-4 w-4 text-blue-500"}),S(" "+s(e(o)("settings.ai.session.title")),1)]),t("p",zl,s(e(o)("settings.ai.session.description")),1)]),i(g,{icon:"i-heroicons-arrow-path",variant:"ghost",size:"xs",loading:x.value,onClick:C},null,8,["loading"])]),t("div",Rl,[t("div",null,[t("span",Fl,s(e(o)("settings.ai.session.summaryStrategy")),1),t("p",Al,s(e(o)("settings.ai.session.summaryStrategyHelp")),1)]),i(Pe,{"model-value":c.value,items:n.value,size:"xs","onUpdate:modelValue":G},null,8,["model-value","items"])]),t("div",Nl,[t("div",null,[t("span",Dl,s(e(o)("settings.ai.session.defaultThreshold")),1),t("p",Bl,s(e(o)("settings.ai.session.thresholdHelp")),1)]),t("div",El,[i(_,{modelValue:a.value,"onUpdate:modelValue":B[0]||(B[0]=w=>a.value=w),modelModifiers:{number:!0},type:"number",min:1,max:1440,size:"xs",class:"w-20",onBlur:N},null,8,["modelValue"]),t("span",Kl,s(e(o)("settings.ai.session.thresholdUnit")),1)])]),t("div",ql,[t("div",Tl,[t("div",null,[t("span",Wl,s(e(o)("settings.ai.session.batchTitle")),1),x.value?(l(),m("div",Hl,[i(M,{name:"i-heroicons-arrow-path",class:"h-3 w-3 animate-spin"}),S(" "+s(e(o)("settings.ai.session.loadingStatus")),1)])):(l(),m("div",Ol,[t("span",jl,s(e(o)("settings.ai.session.totalSessions",{count:U.value.total})),1),t("span",Ll,s(e(o)("settings.ai.session.generatedCount",{count:U.value.generated})),1),U.value.notGenerated>0?(l(),m("span",Gl,s(e(o)("settings.ai.session.notGeneratedCount",{count:U.value.notGenerated})),1)):R("",!0)]))]),t("div",Xl,[U.value.notGenerated>0?(l(),se(g,{key:0,size:"xs",color:"primary",loading:p.value,disabled:x.value,onClick:y},{default:W(()=>[p.value?R("",!0):(l(),se(M,{key:0,name:"i-heroicons-sparkles",class:"mr-1 h-3 w-3"})),S(" "+s(e(o)("settings.ai.session.batchGenerate")),1)]),_:1},8,["loading","disabled"])):R("",!0),i(g,{size:"xs",variant:"soft",loading:p.value,disabled:x.value||U.value.total===0,onClick:B[1]||(B[1]=w=>P.value=!0)},{default:W(()=>[p.value?R("",!0):(l(),se(M,{key:0,name:"i-heroicons-arrow-path",class:"mr-1 h-3 w-3"})),S(" "+s(e(o)("settings.ai.session.batchRegenerate")),1)]),_:1},8,["loading","disabled"])])]),p.value?(l(),m("div",Zl,[t("div",Jl,[t("span",Yl,s(e(o)("settings.ai.session.generating"))+" "+s(f.value.currentName),1),t("span",Ql,s(f.value.current)+"/"+s(f.value.total)+" ("+s(I.value)+"%) ",1)]),i(T,{value:I.value,size:"sm"},null,8,["value"])])):R("",!0)])]),i(q,{open:P.value,"onUpdate:open":B[3]||(B[3]=w=>P.value=w),ui:{content:"z-[101]",overlay:"z-[100]"}},{content:W(()=>[t("div",er,[t("div",tr,[t("div",ar,[i(M,{name:"i-heroicons-exclamation-triangle",class:"h-5 w-5 text-red-600 dark:text-red-400"})]),t("h3",sr,s(e(o)("settings.ai.session.batchRegenerateConfirmTitle")),1)]),t("div",or,[t("p",null,s(e(o)("settings.ai.session.batchRegenerateConfirmMessage")),1),t("div",nr,[t("p",ir,s(e(o)("settings.ai.session.batchRegenerateConfirmWarning")),1)])]),t("div",lr,[i(g,{variant:"ghost",onClick:B[2]||(B[2]=w=>P.value=!1)},{default:W(()=>[S(s(e(o)("common.cancel")),1)]),_:1}),i(g,{color:"error",onClick:h},{default:W(()=>[S(s(e(o)("settings.ai.session.batchRegenerate")),1)]),_:1})])])]),_:1},8,["open"])],512)}}}),cr={class:"flex max-h-[80vh] flex-col p-5"},ur={class:"mb-3 text-base font-semibold text-gray-900 dark:text-white"},mr={class:"mb-3 flex items-center gap-2"},gr={key:0,class:"mb-2 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-700 dark:border-amber-800/50 dark:bg-amber-900/20 dark:text-amber-400"},pr={key:1,class:"flex items-center gap-2 py-8 text-sm text-gray-400"},vr={key:2,class:"min-h-0 flex-1 space-y-1 overflow-y-auto"},fr=["onClick"],xr={class:"min-w-0 flex-1"},hr={class:"truncate text-sm text-gray-800 dark:text-gray-200"},yr={class:"flex items-center gap-2 text-xs text-gray-400"},br={key:0,class:"text-blue-500"},_r={class:"mt-3 flex items-center justify-between border-t border-gray-200 pt-3 dark:border-gray-700"},kr={class:"text-xs text-gray-500"},wr={class:"flex gap-2"},$r={class:"p-5"},Cr={class:"mb-3 text-base font-semibold text-gray-900 dark:text-white"},Mr={class:"mb-3 text-sm text-gray-600 dark:text-gray-400"},Ir={class:"mb-4 max-h-32 overflow-y-auto rounded border border-gray-200 p-2 text-xs text-gray-500 dark:border-gray-700"},Sr={class:"flex justify-end gap-2"},Vr=ue({__name:"SemanticIndexConversationPicker",props:{modelValue:{type:Boolean},apiMode:{type:Boolean}},emits:["update:modelValue","saved"],setup(r,{emit:o}){const a=r,c=o,{t:n}=ye(),d=pt(),x=Ft(),p=V({get:()=>a.modelValue,set:M=>c("update:modelValue",M)}),f=F([]),P=F(!1),U=F(!1),I=F(""),N=F("all"),b=F(new Set),G=F(new Set),C=F(!1),y=V(()=>[{label:n("settings.ai.semanticIndex.picker.all"),value:"all"},{label:n("settings.ai.semanticIndex.picker.group"),value:"group"},{label:n("settings.ai.semanticIndex.picker.private"),value:"private"}]),h=V(()=>{const M=I.value.trim().toLowerCase();return f.value.filter(g=>!(N.value!=="all"&&g.type!==N.value||M&&!g.name.toLowerCase().includes(M)))}),v=V(()=>{let M=0;for(const g of f.value)b.value.has(g.id)&&(M+=g.messageCount);return{count:b.value.size,messages:M}}),D=V(()=>f.value.filter(M=>{if(!G.value.has(M.id)||b.value.has(M.id))return!1;const g=M.status;return g?g.indexStatus==="completed"||g.running||g.queued||g.indexStatus==="failed"&&g.chunkCount>0:!1}));async function A(){P.value=!0;try{const M=await d.getSessions(),g=await x.statusForSessions(M.map(q=>q.id)),_=new Map(g.map(q=>[q.sessionId,q]));f.value=M.map(q=>({id:q.id,name:q.name,type:q.type==="private"?"private":"group",messageCount:q.messageCount,status:_.get(q.id)??null}));const T=new Set(g.filter(q=>q.enabled).map(q=>q.sessionId));G.value=new Set(T),b.value=new Set(T)}catch(M){console.error("[semantic-index] picker load failed:",M)}finally{P.value=!1}}function X(M){const g=new Set(b.value);g.has(M)?g.delete(M):g.add(M),b.value=g}function K(){if(D.value.length>0){C.value=!0;return}B()}async function B(){C.value=!1,U.value=!0;try{const M=[...b.value].filter(_=>!G.value.has(_)),g=[...G.value].filter(_=>!b.value.has(_));for(const _ of M)await x.enable(_);for(const _ of g)await x.remove(_);c("saved"),p.value=!1}catch(M){console.error("[semantic-index] picker save failed:",M)}finally{U.value=!1}}return Le(()=>a.modelValue,M=>{M&&A()}),(M,g)=>{const _=De,T=Rt,q=Se,w=Dt,$=Ie,J=We;return l(),m(re,null,[i(J,{open:p.value,"onUpdate:open":g[4]||(g[4]=O=>p.value=O),ui:{content:"z-[101] max-w-2xl",overlay:"z-[100]"}},{content:W(()=>[t("div",cr,[t("h3",ur,s(e(n)("settings.ai.semanticIndex.picker.title")),1),t("div",mr,[i(_,{modelValue:I.value,"onUpdate:modelValue":g[0]||(g[0]=O=>I.value=O),icon:"i-heroicons-magnifying-glass",size:"sm",class:"flex-1",placeholder:e(n)("settings.ai.semanticIndex.picker.searchPlaceholder")},null,8,["modelValue","placeholder"]),i(T,{modelValue:N.value,"onUpdate:modelValue":g[1]||(g[1]=O=>N.value=O),items:y.value,size:"sm",class:"w-28"},null,8,["modelValue","items"])]),r.apiMode?(l(),m("p",gr,s(e(n)("settings.ai.semanticIndex.apiCostWarning")),1)):R("",!0),P.value?(l(),m("div",pr,[i(q,{name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin"}),S(" "+s(e(n)("common.loading")),1)])):(l(),m("div",vr,[(l(!0),m(re,null,fe(h.value,O=>(l(),m("div",{key:O.id,class:"flex cursor-pointer items-center gap-3 rounded-lg px-2 py-2 hover:bg-gray-50 dark:hover:bg-gray-800/50",onClick:oe=>X(O.id)},[i(w,{"model-value":b.value.has(O.id),"onUpdate:modelValue":oe=>X(O.id),onClick:g[2]||(g[2]=Ye(()=>{},["stop"]))},null,8,["model-value","onUpdate:modelValue"]),t("div",xr,[t("div",hr,s(O.name),1),t("div",yr,[t("span",null,s(O.type==="group"?e(n)("settings.ai.semanticIndex.picker.group"):e(n)("settings.ai.semanticIndex.picker.private")),1),t("span",null,s(e(n)("settings.ai.semanticIndex.picker.messages",{count:O.messageCount})),1),O.status?.enabled?(l(),m("span",br,s(e(n)("settings.ai.semanticIndex.picker.enabled")),1)):R("",!0)])])],8,fr))),128))])),t("div",_r,[t("span",kr,s(e(n)("settings.ai.semanticIndex.picker.selectedSummary",{count:v.value.count,messages:v.value.messages})),1),t("div",wr,[i($,{variant:"ghost",onClick:g[3]||(g[3]=O=>p.value=!1)},{default:W(()=>[S(s(e(n)("common.cancel")),1)]),_:1}),i($,{color:"primary",loading:U.value,onClick:K},{default:W(()=>[S(s(e(n)("common.save")),1)]),_:1},8,["loading"])])])])]),_:1},8,["open"]),i(J,{open:C.value,"onUpdate:open":g[6]||(g[6]=O=>C.value=O),ui:{content:"z-[103]",overlay:"z-[102]"}},{content:W(()=>[t("div",$r,[t("h3",Cr,s(e(n)("settings.ai.semanticIndex.picker.confirmRemoveTitle")),1),t("p",Mr,s(e(n)("settings.ai.semanticIndex.picker.confirmRemoveMessage")),1),t("ul",Ir,[(l(!0),m(re,null,fe(D.value,O=>(l(),m("li",{key:O.id,class:"truncate"},s(O.name),1))),128))]),t("div",Sr,[i($,{variant:"ghost",onClick:g[5]||(g[5]=O=>C.value=!1)},{default:W(()=>[S(s(e(n)("common.cancel")),1)]),_:1}),i($,{color:"error",loading:U.value,onClick:B},{default:W(()=>[S(s(e(n)("common.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"])],64)}}}),ut=[{modelId:"onnx-community/Qwen3-Embedding-0.6B-ONNX",name:"Qwen3-Embedding-0.6B",approxMB:593,recommended:!0,zhOnly:!1},{modelId:"Xenova/bge-base-zh-v1.5",name:"BGE base zh",approxMB:390,recommended:!1,zhOnly:!0}],dt=[{id:"openai-compatible",label:"OpenAI Compatible",baseUrl:"",model:""},{id:"openai",label:"OpenAI",baseUrl:"https://api.openai.com/v1",model:"text-embedding-3-small"},{id:"ollama",label:"Ollama",baseUrl:"http://localhost:11434/v1",model:"nomic-embed-text"},{id:"qwen",label:"通义千问",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode/v1",model:"text-embedding-v3",zhOnly:!0},{id:"zhipu",label:"智谱",baseUrl:"https://open.bigmodel.cn/api/paas/v4",model:"embedding-3",zhOnly:!0},{id:"siliconflow",label:"SiliconFlow",baseUrl:"https://api.siliconflow.cn/v1",model:"BAAI/bge-m3"}],Pr={class:"space-y-4 p-5"},Ur={class:"flex items-center justify-between gap-3"},zr={class:"text-base font-semibold text-gray-900 dark:text-white"},Rr={key:0,class:"space-y-2"},Fr={class:"grid gap-2 sm:grid-cols-2"},Ar=["onClick"],Nr={class:"flex w-full items-center justify-between"},Dr={class:"text-sm font-medium text-gray-900 dark:text-white"},Br={class:"text-xs text-gray-500"},Er={class:"space-y-1.5 rounded-lg border border-gray-200 p-3 dark:border-gray-700"},Kr={class:"block text-xs font-medium text-gray-600 dark:text-gray-400"},qr={key:0,class:"text-xs text-amber-600 dark:text-amber-400"},Tr={class:"text-xs text-gray-400"},Wr={key:1,class:"space-y-3"},Or={class:"mb-1 block text-xs font-medium text-gray-600 dark:text-gray-400"},jr={class:"mb-1 block text-xs font-medium text-gray-600 dark:text-gray-400"},Lr={class:"rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-700 dark:border-amber-800/50 dark:bg-amber-900/20 dark:text-amber-400"},Gr={class:"text-xs text-gray-400"},Hr={class:"flex justify-end gap-2 border-t border-gray-200 pt-3 dark:border-gray-700"},Xr=ue({__name:"SemanticIndexModelModal",props:{open:{type:Boolean},config:{},apiKeySet:{type:Boolean},saving:{type:Boolean}},emits:["update:open","confirm"],setup(r,{emit:o}){const a=r,c=o,{t:n,locale:d}=ye(),x=F("local"),p=F(ut[0].modelId),f=F("huggingface"),P=F("openai-compatible"),U=F(""),I=F(""),N=F(""),b=V(()=>d.value.startsWith("zh")),G=!pa,C=V(()=>ut.filter(_=>!_.zhOnly||b.value)),y=V(()=>dt.filter(_=>!_.zhOnly||b.value||_.id===P.value)),h=V(()=>[{label:n("settings.ai.semanticIndex.modeLocal"),value:"local"},{label:n("settings.ai.semanticIndex.modeApi"),value:"api"}]),v=V(()=>[{label:n("settings.ai.semanticIndex.downloadSourceOfficial"),value:"huggingface"},{label:n("settings.ai.semanticIndex.downloadSourceMirror"),value:"hf-mirror"}]),D=V(()=>wa(a.config,U.value,a.apiKeySet)),A=V(()=>At(U.value)),X=V(()=>x.value==="local"?!!p.value:!!U.value.trim()&&!!I.value.trim()&&(!A.value||D.value||!!N.value.trim()));function K(){const _=a.config;x.value=_?.mode??"local",p.value=_?.local.modelId??"",f.value=_?.local.downloadSource??"huggingface",U.value=_?.api?.baseUrl??"",I.value=_?.api?.model??"",N.value="";const T=dt.find(q=>q.baseUrl===_?.api?.baseUrl);P.value=T?.id??"openai-compatible"}Le(()=>a.open,_=>{_&&K()});function B(_){P.value=String(_);const T=dt.find(q=>q.id===P.value);T&&T.id!=="openai-compatible"&&(U.value=T.baseUrl,I.value=T.model)}function M(){c("update:open",!1)}function g(){X.value&&c("confirm",{mode:x.value,localModelId:p.value,localDownloadSource:f.value,apiBaseUrl:U.value,apiModel:I.value,apiKey:N.value})}return(_,T)=>{const q=Qe,w=De,$=Ie,J=We;return l(),se(J,{open:r.open,ui:{content:"z-[101] max-w-lg",overlay:"z-[100]"},"onUpdate:open":T[5]||(T[5]=O=>c("update:open",O))},{content:W(()=>[t("div",Pr,[t("div",Ur,[t("h3",zr,s(e(n)("settings.ai.semanticIndex.modelModalTitle")),1),i(Pe,{"model-value":x.value,items:h.value,size:"xs","onUpdate:modelValue":T[0]||(T[0]=O=>x.value=O)},null,8,["model-value","items"])]),x.value==="local"?(l(),m("div",Rr,[t("div",Fr,[(l(!0),m(re,null,fe(C.value,O=>(l(),m("button",{key:O.modelId,type:"button",class:Re(["flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition",p.value===O.modelId?"border-blue-500 bg-blue-50 dark:border-blue-400 dark:bg-blue-900/20":"border-gray-200 hover:border-gray-300 dark:border-gray-700 dark:hover:border-gray-600"]),onClick:oe=>p.value=O.modelId},[t("div",Nr,[t("span",Dr,s(O.name),1),O.recommended?(l(),se(q,{key:0,color:"primary",variant:"soft",size:"xs"},{default:W(()=>[S(s(e(n)("settings.ai.semanticIndex.recommended")),1)]),_:1})):R("",!0)]),t("span",Br,s(e(n)("settings.ai.semanticIndex.approxSize",{mb:O.approxMB})),1)],10,Ar))),128))]),t("div",Er,[t("label",Kr,s(e(n)("settings.ai.semanticIndex.modelDownloadSource")),1),i(Pe,{"model-value":f.value,items:v.value,size:"xs","onUpdate:modelValue":T[1]||(T[1]=O=>f.value=O)},null,8,["model-value","items"]),f.value==="hf-mirror"?(l(),m("p",qr,s(e(n)("settings.ai.semanticIndex.mirrorSourceHint")),1)):R("",!0)]),t("p",Tr,s(e(n)(e(G)?"settings.ai.semanticIndex.localRuntimeDownloadHint":"settings.ai.semanticIndex.localDownloadHint")),1)])):(l(),m("div",Wr,[t("div",null,[t("label",Or,s(e(n)("settings.ai.semanticIndex.apiTemplate")),1),i(Pe,{"model-value":P.value,items:y.value.map(O=>({label:O.label,value:O.id})),size:"xs","onUpdate:modelValue":B},null,8,["model-value","items"])]),t("div",null,[T[6]||(T[6]=t("label",{class:"mb-1 block text-xs font-medium text-gray-600 dark:text-gray-400"},"Base URL",-1)),i(w,{modelValue:U.value,"onUpdate:modelValue":T[2]||(T[2]=O=>U.value=O),size:"sm",class:"w-full",placeholder:"https://api.example.com/v1"},null,8,["modelValue"])]),t("div",null,[t("label",jr,s(e(n)("settings.ai.semanticIndex.modelName")),1),i(w,{modelValue:I.value,"onUpdate:modelValue":T[3]||(T[3]=O=>I.value=O),size:"sm",class:"w-full",placeholder:"text-embedding-3-small"},null,8,["modelValue"])]),i(He,{modelValue:N.value,"onUpdate:modelValue":T[4]||(T[4]=O=>N.value=O),placeholder:D.value?e(n)("settings.ai.semanticIndex.apiKeySaved"):"",hint:e(n)("settings.ai.semanticIndex.apiKeyHint")},null,8,["modelValue","placeholder","hint"]),t("p",Lr,s(e(n)("settings.ai.semanticIndex.apiCostWarning")),1)])),t("p",Gr,s(e(n)("settings.ai.semanticIndex.changeRebuildHint")),1),t("div",Hr,[i($,{variant:"ghost",disabled:r.saving,onClick:M},{default:W(()=>[S(s(e(n)("common.cancel")),1)]),_:1},8,["disabled"]),i($,{color:"primary",loading:r.saving,disabled:!X.value,onClick:g},{default:W(()=>[S(s(e(n)("common.confirm")),1)]),_:1},8,["loading","disabled"])])])]),_:1},8,["open"])}}}),Zr={class:"flex items-start justify-between gap-3"},Jr={class:"min-w-0"},Yr={class:"flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},Qr={class:"mt-0.5 text-xs text-gray-500 dark:text-gray-400"},ed={class:"space-y-2 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},td={class:"flex items-center justify-between gap-3"},ad={class:"min-w-0"},sd={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},od={class:"mt-0.5 flex min-w-0 items-center gap-2 text-xs"},nd={class:"truncate text-gray-700 dark:text-gray-300"},id={key:0,class:"truncate text-gray-400"},ld={key:1,class:"text-gray-400"},rd={key:0,class:"text-xs text-amber-500"},dd={key:1,class:"flex items-center gap-1.5 text-xs text-blue-500 dark:text-blue-400"},cd={key:2,class:"text-xs text-red-500"},ud={class:"space-y-3 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},md={class:"flex items-center justify-between"},gd={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},pd={class:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs"},vd={class:"text-gray-500"},fd={class:"text-green-600 dark:text-green-400"},xd={key:0,class:"text-blue-600 dark:text-blue-400"},hd={key:1,class:"text-gray-500"},yd={key:2,class:"text-amber-600 dark:text-amber-400"},bd={key:3,class:"text-red-600 dark:text-red-400"},_d={class:"text-gray-500"},kd={class:"flex flex-wrap items-center gap-2"},wd={key:0,class:"text-xs text-amber-500"},$d={key:0,class:"space-y-2"},Cd={class:"text-xs font-medium text-gray-500"},Md={class:"max-h-72 space-y-2 overflow-y-auto"},Id={class:"min-w-0"},Sd={class:"truncate text-sm text-gray-800 dark:text-gray-200"},Vd={class:"flex items-center gap-2 text-xs"},Pd=["title"],Ud={key:0,class:"mt-1 flex items-center gap-2"},zd={class:"h-1.5 max-w-[160px] flex-1 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},Rd={class:"shrink-0 text-[11px] text-gray-400"},Fd={class:"flex shrink-0 items-center gap-1"},Ad={class:"p-5"},Nd={class:"mb-4 flex items-center gap-3"},Dd={class:"flex h-10 w-10 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},Bd={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ed={class:"text-sm text-gray-600 dark:text-gray-400"},Kd={class:"mt-5 flex justify-end gap-2"},qd=ue({__name:"SemanticIndexSection",setup(r){const{t:o}=ye(),a=Ft(),c=F(!1),n=F(!1),d=F(!0),x=F(!1),p=F(null),f=F("idle"),P=F(!1);let U=null;function I(z){return z==="installing-runtime"||z==="downloading-model"}function N(){U||(U=setInterval(async()=>{try{const z=await a.getConfig();f.value=z.modelStatus,I(z.modelStatus)||b()}catch{b()}},2e3))}function b(){U&&(clearInterval(U),U=null)}const G=V(()=>n.value&&p.value?.mode==="api"),C=V(()=>{const z=p.value;return!n.value||!z?!1:z.mode==="local"?!!z.local.modelId:!!z.api?.baseUrl&&!!z.api?.model&&(!At(z.api.baseUrl)||c.value)}),y=V(()=>{const z=p.value;if(!n.value||!z)return null;if(z.mode==="local"){const ae=ut.find(ge=>ge.modelId===z.local.modelId),xe=z.local.downloadSource==="hf-mirror"?"downloadSourceMirror":"downloadSourceOfficial";return{type:o("settings.ai.semanticIndex.modeLocal"),name:ae?.name??z.local.modelId,sub:o(`settings.ai.semanticIndex.${xe}`)}}let Y=z.api?.baseUrl??"";try{Y=new URL(Y).host}catch{}return{type:o("settings.ai.semanticIndex.modeApi"),name:z.api?.model??"",sub:Y}}),h=F([]),v=F(new Map),D=F(!1),A=F(null),X=F(!1),K=F(!1),B=F(!1),M=F(!1),g=V(()=>{const z=h.value;let Y=0,ae=0,xe=0,ge=0,ce=0,_e=0,Z=0;for(const he of z)_e+=he.indexedMessages,Z+=he.totalMessages,he.needsRebuild?ae++:he.running||he.queued||he.indexStatus==="running"?xe++:he.indexStatus==="completed"?Y++:he.indexStatus==="failed"?ce++:ge++;const we=Z>0?Math.round(_e/Z*100):0;return{enabled:z.length,completed:Y,needsRebuild:ae,building:xe,pending:ge,failed:ce,indexedMessages:_e,totalMessages:Z,coverage:we}}),_=V(()=>h.value.filter(z=>!z.running&&!z.queued&&(z.needsRebuild||z.indexStatus!=="completed"||!!z.hasNewMessages)).length);async function T(z,Y){x.value=!0;try{const ae=await a.setConfig(z,Y);return p.value=ae.config,c.value=ae.apiKeySet,n.value=ae.configured,d.value=ae.config.enabled,f.value=ae.modelStatus,I(ae.modelStatus)&&N(),await de(),!0}catch(ae){return console.error("[semantic-index] save config failed:",ae),!1}finally{x.value=!1}}async function q(z){const Y=$a(p.value,z);await T(Y,z.apiKey.trim()||void 0)&&(P.value=!1)}async function w(z){const Y=p.value;!Y||Y.enabled===z||await T({...Y,enabled:z})}const $=V(()=>h.value.some(ne));let J=null;function O(){J&&(clearTimeout(J),J=null)}function oe(){O(),$.value&&(J=setTimeout(async()=>{try{h.value=await a.listEnabled()}catch(z){console.error("[semantic-index] poll statuses failed:",z)}oe()},1500))}async function de(){D.value=!0;try{const[z,Y]=await Promise.all([a.listEnabled(),pt().getSessions()]);h.value=z,v.value=new Map(Y.map(ae=>[ae.id,ae.name]))}catch(z){console.error("[semantic-index] load statuses failed:",z)}finally{D.value=!1}oe()}async function me(z,Y){A.value=Y;try{await a[z](Y),await de()}catch(ae){console.error(`[semantic-index] ${z} failed:`,ae)}finally{A.value=null}}async function ee(){X.value=!0;try{h.value=await a.buildPending(),oe()}catch(z){console.error("[semantic-index] build pending failed:",z)}finally{X.value=!1}}async function le(){B.value=!1,K.value=!0;try{await a.cleanup(),await de()}catch(z){console.error("[semantic-index] cleanup failed:",z)}finally{K.value=!1}}function H(z){const Y="settings.ai.semanticIndex.state";return z.needsRebuild?{label:o(`${Y}.needsRebuild`),color:"text-amber-600 dark:text-amber-400"}:z.running||z.queued||z.indexStatus==="running"?{label:o(`${Y}.building`),color:"text-blue-600 dark:text-blue-400"}:z.indexStatus==="completed"?{label:o(`${Y}.completed`),color:"text-green-600 dark:text-green-400"}:z.indexStatus==="failed"?{label:o(`${Y}.failed`),color:"text-red-600 dark:text-red-400"}:z.indexStatus==="paused"?{label:o(`${Y}.paused`),color:"text-gray-500"}:{label:o(`${Y}.pending`),color:"text-gray-500"}}function ne(z){return z.running||z.queued||z.indexStatus==="running"}const ke=F(null);let be=null,Ue=!1;return Fe(async()=>{try{const z=await a.getConfig();p.value=z.config,c.value=z.apiKeySet,n.value=z.configured,d.value=z.config.enabled,f.value=z.modelStatus,I(z.modelStatus)&&N()}catch(z){console.error("[semantic-index] load config failed:",z)}be=new IntersectionObserver(z=>{z[0]?.isIntersecting&&!Ue&&(Ue=!0,de(),be?.disconnect())},{threshold:.1}),ke.value&&be.observe(ke.value)}),gt(()=>{be?.disconnect(),O(),b()}),(z,Y)=>{const ae=Se,xe=vt,ge=Qe,ce=Ie,_e=We;return l(),m("div",{ref_key:"sectionRef",ref:ke,class:"space-y-6"},[t("div",Zr,[t("div",Jr,[t("h3",Yr,[i(ae,{name:"i-heroicons-circle-stack",class:"h-4 w-4 text-blue-500"}),S(" "+s(e(o)("settings.ai.semanticIndex.title")),1)]),t("p",Qr,s(e(o)("settings.ai.semanticIndex.description")),1)]),i(xe,{"model-value":d.value,loading:x.value,class:"mt-0.5 shrink-0","onUpdate:modelValue":w},null,8,["model-value","loading"])]),d.value?(l(),m(re,{key:0},[t("div",ed,[t("div",td,[t("div",ad,[t("span",sd,s(e(o)("settings.ai.semanticIndex.vectorModel")),1),t("div",od,[y.value?(l(),m(re,{key:0},[i(ge,{color:G.value?"neutral":"primary",variant:"soft",size:"xs"},{default:W(()=>[S(s(y.value.type),1)]),_:1},8,["color"]),t("span",nd,s(y.value.name),1),y.value.sub?(l(),m("span",id,s(y.value.sub),1)):R("",!0)],64)):(l(),m("span",ld,s(e(o)("settings.ai.semanticIndex.noModelSelected")),1))])]),i(ce,{size:"xs",color:y.value?"neutral":"primary",variant:y.value?"soft":"solid",class:"shrink-0",onClick:Y[0]||(Y[0]=Z=>P.value=!0)},{default:W(()=>[S(s(y.value?e(o)("settings.ai.semanticIndex.switchModel"):e(o)("settings.ai.semanticIndex.selectModel")),1)]),_:1},8,["color","variant"])]),C.value?R("",!0):(l(),m("p",rd,s(e(o)("settings.ai.semanticIndex.configFirst")),1)),I(f.value)?(l(),m("p",dd,[i(ae,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 animate-spin shrink-0"}),S(" "+s(f.value==="installing-runtime"?e(o)("settings.ai.semanticIndex.runtimeInstalling"):e(o)("settings.ai.semanticIndex.modelDownloading")),1)])):f.value==="error"?(l(),m("p",cd,s(e(o)("settings.ai.semanticIndex.modelError")),1)):R("",!0)]),i(Xr,{open:P.value,"onUpdate:open":Y[1]||(Y[1]=Z=>P.value=Z),config:n.value?p.value:null,"api-key-set":c.value,saving:x.value,onConfirm:q},null,8,["open","config","api-key-set","saving"]),C.value?(l(),m(re,{key:0},[t("div",ud,[t("div",md,[t("span",gd,s(e(o)("settings.ai.semanticIndex.overview")),1),i(ce,{icon:"i-heroicons-arrow-path",variant:"ghost",size:"xs",loading:D.value,onClick:de},null,8,["loading"])]),t("div",pd,[t("span",vd,s(e(o)("settings.ai.semanticIndex.enabledCount",{count:g.value.enabled})),1),t("span",fd,s(e(o)("settings.ai.semanticIndex.state.completed"))+" "+s(g.value.completed),1),g.value.building>0?(l(),m("span",xd,s(e(o)("settings.ai.semanticIndex.state.building"))+" "+s(g.value.building),1)):R("",!0),g.value.pending>0?(l(),m("span",hd,s(e(o)("settings.ai.semanticIndex.state.pending"))+" "+s(g.value.pending),1)):R("",!0),g.value.needsRebuild>0?(l(),m("span",yd,s(e(o)("settings.ai.semanticIndex.state.needsRebuild"))+" "+s(g.value.needsRebuild),1)):R("",!0),g.value.failed>0?(l(),m("span",bd,s(e(o)("settings.ai.semanticIndex.state.failed"))+" "+s(g.value.failed),1)):R("",!0),t("span",_d,s(e(o)("settings.ai.semanticIndex.coverage",{percent:g.value.coverage})),1)]),t("div",kd,[i(ce,{size:"xs",variant:"soft",icon:"i-heroicons-check-circle",onClick:Y[2]||(Y[2]=Z=>M.value=!0)},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.selectConversations")),1)]),_:1}),i(ce,{size:"xs",color:"primary",loading:X.value,disabled:!C.value||_.value===0,onClick:ee},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.buildPending")),1)]),_:1},8,["loading","disabled"]),i(ce,{size:"xs",variant:"soft",loading:K.value,onClick:Y[3]||(Y[3]=Z=>B.value=!0)},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.cleanup")),1)]),_:1},8,["loading"]),C.value?R("",!0):(l(),m("span",wd,s(e(o)("settings.ai.semanticIndex.configFirst")),1))])]),h.value.length>0?(l(),m("div",$d,[t("span",Cd,s(e(o)("settings.ai.semanticIndex.enabledSessions")),1),t("div",Md,[(l(!0),m(re,null,fe(h.value,Z=>(l(),m("div",{key:Z.sessionId,class:"flex items-center justify-between rounded-lg border border-gray-200 px-3 py-2 dark:border-gray-700"},[t("div",Id,[t("div",Sd,s(v.value.get(Z.sessionId)||Z.sessionId),1),t("div",Vd,[t("span",{class:Re(H(Z).color)},s(H(Z).label),3),Z.error?(l(),m("span",{key:0,class:"truncate text-red-500",title:Z.error},s(Z.error),9,Pd)):R("",!0)]),ne(Z)?(l(),m("div",Ud,[t("div",zd,[t("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-500",style:va({width:`${Z.totalMessages>0?Math.round(Z.indexedMessages/Z.totalMessages*100):0}%`})},null,4)]),t("span",Rd,s(Z.indexedMessages)+"/"+s(Z.totalMessages),1)])):R("",!0)]),t("div",Fd,[ne(Z)?(l(),m(re,{key:0},[i(ce,{size:"xs",variant:"ghost",loading:A.value===Z.sessionId,onClick:we=>me("pause",Z.sessionId)},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.action.pause")),1)]),_:1},8,["loading","onClick"]),i(ce,{size:"xs",variant:"ghost",color:"error",disabled:A.value===Z.sessionId,onClick:we=>me("cancel",Z.sessionId)},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.action.cancel")),1)]),_:1},8,["disabled","onClick"])],64)):Z.indexStatus==="completed"&&!Z.needsRebuild?(l(),se(ce,{key:1,size:"xs",variant:"ghost",loading:A.value===Z.sessionId,onClick:we=>me("rebuild",Z.sessionId)},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.action.rebuild")),1)]),_:1},8,["loading","onClick"])):Z.needsRebuild?(l(),se(ce,{key:2,size:"xs",variant:"ghost",loading:A.value===Z.sessionId,onClick:we=>me("rebuild",Z.sessionId)},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.action.rebuild")),1)]),_:1},8,["loading","onClick"])):(l(),se(ce,{key:3,size:"xs",variant:"ghost",loading:A.value===Z.sessionId,onClick:we=>me("build",Z.sessionId)},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.action.build")),1)]),_:1},8,["loading","onClick"])),i(ce,{size:"xs",variant:"ghost",color:"neutral",disabled:A.value===Z.sessionId,onClick:we=>me("remove",Z.sessionId)},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.action.remove")),1)]),_:1},8,["disabled","onClick"])])]))),128))])])):R("",!0),i(Vr,{modelValue:M.value,"onUpdate:modelValue":Y[4]||(Y[4]=Z=>M.value=Z),"api-mode":G.value,onSaved:de},null,8,["modelValue","api-mode"]),i(_e,{open:B.value,"onUpdate:open":Y[6]||(Y[6]=Z=>B.value=Z),ui:{content:"z-[101]",overlay:"z-[100]"}},{content:W(()=>[t("div",Ad,[t("div",Nd,[t("div",Dd,[i(ae,{name:"i-heroicons-trash",class:"h-5 w-5 text-red-600 dark:text-red-400"})]),t("h3",Bd,s(e(o)("settings.ai.semanticIndex.cleanup")),1)]),t("p",Ed,s(e(o)("settings.ai.semanticIndex.cleanupConfirm")),1),t("div",Kd,[i(ce,{variant:"ghost",onClick:Y[5]||(Y[5]=Z=>B.value=!1)},{default:W(()=>[S(s(e(o)("common.cancel")),1)]),_:1}),i(ce,{color:"error",onClick:le},{default:W(()=>[S(s(e(o)("settings.ai.semanticIndex.cleanup")),1)]),_:1})])])]),_:1},8,["open"])],64)):R("",!0)],64)):R("",!0)],512)}}});function Td(r,o={}){const a=o.scrollBehavior??"smooth",c=o.scrollLockDuration??500,n=F(r.value[0]?.id||""),d=F(!1),x=F(null),p=F({});function f(N,b){p.value[N]=b}function P(N){const b=p.value[N];!b||!x.value||(d.value=!0,b.scrollIntoView({behavior:a,block:"start"}),setTimeout(()=>{d.value=!1},c))}function U(){if(d.value||!x.value)return;const N=x.value,b=N.getBoundingClientRect(),G=50;if(N.scrollHeight-N.scrollTop-N.clientHeight<5){const y=r.value[r.value.length-1];y&&(n.value=y.id);return}for(const y of r.value){const h=p.value[y.id];if(!h)continue;const v=h.getBoundingClientRect();if(v.top<=b.top+G&&v.bottom>b.top+G){n.value=y.id;break}}}Fe(()=>{x.value?.addEventListener("scroll",U)}),gt(()=>{x.value?.removeEventListener("scroll",U)});function I(N){const b=p.value[N];!b||!x.value||(d.value=!0,b.scrollIntoView({behavior:a,block:"start"}),n.value=N,setTimeout(()=>{d.value=!1},c))}return{activeNav:n,scrollContainerRef:x,sectionRefs:p,setSectionRef:f,handleNavChange:P,scrollToId:I}}const Wd={class:"flex h-full gap-6"},Od={class:"w-36 shrink-0"},jd={class:"space-y-8"},lc=ue({__name:"AISettingsTab",emits:["config-changed"],setup(r,{expose:o,emit:a}){const{t:c}=ye(),n=a,d=V(()=>[{id:"model",label:c("settings.tabs.aiConfig")},{id:"defaultModel",label:c("settings.tabs.aiDefaultModel")},{id:"semanticIndex",label:c("settings.tabs.semanticIndex")},{id:"skill",label:c("settings.tabs.chatPreferences")},{id:"chat",label:c("settings.aiPrompt.chatSettings.title")},{id:"preprocess",label:c("settings.tabs.aiPreprocess")},{id:"sessionIndex",label:c("settings.tabs.sessionManage")},{id:"export",label:c("settings.aiPrompt.exportSettings.title")}]),{activeNav:x,scrollContainerRef:p,setSectionRef:f,handleNavChange:P,scrollToId:U}=Td(d);function I(){n("config-changed")}function N(G){U(G)}o({scrollToSection:N});const b=F(null);return b.value,(G,C)=>(l(),m("div",Wd,[t("div",Od,[i(e(fa),{modelValue:e(x),"onUpdate:modelValue":C[0]||(C[0]=y=>Ne(x)?x.value=y:null),items:d.value,orientation:"vertical",onChange:e(P)},null,8,["modelValue","items","onChange"])]),t("div",{ref_key:"scrollContainerRef",ref:p,class:"min-w-0 flex-1 overflow-y-auto"},[t("div",jd,[t("div",{ref:y=>e(f)("model",y)},[i(vn,{ref_key:"aiModelConfigRef",ref:b,onConfigChanged:I},null,512)],512),t("div",{ref:y=>e(f)("defaultModel",y)},[i(Bn,{onConfigChanged:I})],512),t("div",{ref:y=>e(f)("semanticIndex",y)},[i(qd)],512),i(gi,{"set-section-ref":e(f),onConfigChanged:I},null,8,["set-section-ref"]),t("div",{ref:y=>e(f)("preprocess",y)},[i(xl)],512),t("div",{ref:y=>e(f)("sessionIndex",y)},[i(dr)],512),t("div",{ref:y=>e(f)("export",y)},[i(Sl,{onConfigChanged:I})],512)])],512)]))}});export{lc as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as D}from"./Switch-CokhQWxm.js";import{a as j,a3 as z,ax as B,a8 as L,I as M,ay as N,az as F,r as h,x as I,o as x,h as f,i as e,z as r,a4 as R,a6 as i,p as a,e as s,w as v,n as $,a5 as H,l as O,aA as d,aB as P}from"./index-sWxuTsa7.js";import{u as q}from"./useToast-BA0EwImD.js";import"./Label-CFAZFBQX.js";import"./useFormControl-DVawP2DO.js";import"./VisuallyHiddenInput-OAJEt_Y5.js";import"./vendor-snapdom--nZvo8Sg.js";const G={class:"space-y-6 pr-1"},J={class:"mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},K={class:"rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},Q={class:"flex items-center justify-between"},W={class:"flex items-center gap-3"},X={class:"flex h-12 w-12 items-center justify-center rounded-xl bg-linear-to-br from-pink-500 to-pink-600"},Y={class:"text-xs text-gray-500 dark:text-gray-400"},Z={class:"mt-1 text-xs text-gray-400"},ee={class:"mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},te={class:"rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},se={class:"flex items-center justify-between"},oe={class:"text-sm font-medium text-gray-900 dark:text-white"},ae={class:"text-xs text-gray-500 dark:text-gray-400"},re={class:"mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},ne={class:"rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},ie={class:"flex items-center justify-between"},ce={class:"text-sm font-medium text-gray-900 dark:text-white"},le={class:"text-xs text-gray-500 dark:text-gray-400"},de={key:0},ue={class:"mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white"},ge={class:"rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50"},me={class:"flex items-center justify-between"},he={class:"text-sm font-medium text-gray-900 dark:text-white"},ke=j({__name:"AboutTab",setup(be){const{t}=z(),u=q(),w=B(),b=L(),k=M(),p=N(),{debugMode:U}=F(b),S=p.isAuthenticated;function V(){k.closeSettings(),p.logout(),w.push({name:"login"})}const g=h(t("common.loading")),c=h(!1),m=h(!0);async function A(){try{g.value=await d().getVersion()}catch(o){console.error("Failed to get version:",o),g.value=t("settings.about.unknown")}}async function C(){try{m.value=await d().getAnalyticsEnabled()}catch(o){console.error("Failed to get analytics status:",o)}}async function E(o){try{await d().setAnalyticsEnabled(o),m.value=o}catch(l){console.error("Failed to set analytics:",l)}}async function T(){c.value=!0;try{const o=await d().checkUpdate();if(!o)return;o.error?u.fail(t("settings.about.updateCheckFailed",{error:o.error})):o.hasUpdate?u.success(t("settings.about.newVersionAvailable",{version:o.latestVersion}),{duration:15e3,description:P?void 0:t("settings.about.webUpdateHint")}):u.success(t("settings.about.upToDate"))}catch(o){console.error("Update check failed:",o)}finally{c.value=!1}}return I(()=>{A(),C()}),(o,l)=>{const n=R,_=H,y=D;return x(),f("div",G,[e("div",null,[e("h3",J,[r(n,{name:"i-heroicons-information-circle",class:"h-4 w-4 text-blue-500"}),i(" "+a(s(t)("settings.about.title")),1)]),e("div",K,[e("div",Q,[e("div",W,[e("div",X,[r(n,{name:"i-heroicons-chat-bubble-left-right",class:"h-6 w-6 text-white"})]),e("div",null,[l[0]||(l[0]=e("p",{class:"text-sm font-semibold text-gray-900 dark:text-white"},"ChatLab",-1)),e("p",Y,a(s(t)("settings.about.description")),1),e("p",Z,a(s(t)("settings.about.version"))+" "+a(g.value),1)])]),r(_,{disabled:c.value,color:"primary",variant:"soft",size:"sm",onClick:T},{default:v(()=>[r(n,{name:"i-heroicons-arrow-path",class:$(["mr-1 h-4 w-4",{"animate-spin":c.value}])},null,8,["class"]),i(" "+a(c.value?s(t)("settings.about.checking"):s(t)("settings.about.checkUpdate")),1)]),_:1},8,["disabled"])])])]),e("div",null,[e("h3",ee,[r(n,{name:"i-heroicons-shield-check",class:"h-4 w-4 text-purple-500"}),i(" "+a(s(t)("settings.about.privacy.title")),1)]),e("div",te,[e("div",se,[e("div",null,[e("p",oe,a(s(t)("settings.about.privacy.analytics")),1),e("p",ae,a(s(t)("settings.about.privacy.analyticsDesc")),1)]),r(y,{"model-value":m.value,"onUpdate:modelValue":E},null,8,["model-value"])])])]),e("div",null,[e("h3",re,[r(n,{name:"i-heroicons-wrench-screwdriver",class:"h-4 w-4 text-orange-500"}),i(" "+a(s(t)("settings.about.developer.title")),1)]),e("div",ne,[e("div",ie,[e("div",null,[e("p",ce,a(s(t)("settings.about.developer.debugMode")),1),e("p",le,a(s(t)("settings.about.developer.debugModeDesc")),1)]),r(y,{"model-value":s(U),"onUpdate:modelValue":s(b).setDebugMode},null,8,["model-value","onUpdate:modelValue"])])])]),s(S)?(x(),f("div",de,[e("h3",ue,[r(n,{name:"i-heroicons-arrow-right-on-rectangle",class:"h-4 w-4 text-red-500"}),i(" "+a(s(t)("common.login.logoutTitle")),1)]),e("div",ge,[e("div",me,[e("div",null,[e("p",he,a(s(t)("common.login.logoutDesc")),1)]),r(_,{color:"error",variant:"soft",size:"sm",onClick:V},{default:v(()=>[r(n,{name:"i-heroicons-arrow-right-on-rectangle",class:"mr-1 h-4 w-4"}),i(" "+a(s(t)("common.login.logout")),1)]),_:1})])])])):O("",!0)])}}});export{ke as default};
|