@forsion/unit 2.13.0 → 2.13.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.
Files changed (144) hide show
  1. package/main.mjs +5 -3
  2. package/package.json +1 -1
  3. package/release.json +5 -5
  4. package/web/assets/{ArtificialView-BSv3Mx5C.js → ArtificialView-XwHMLUFb.js} +1 -1
  5. package/web/assets/{AutomationBuilder-BuiHtVB-.js → AutomationBuilder-hqs0QhMt.js} +1 -1
  6. package/web/assets/{CalendarConfigView-BJtG6cqN.js → CalendarConfigView-DKib8Oed.js} +1 -1
  7. package/web/assets/{CalendarView-C-FX1RED.js → CalendarView-DJ5iOzvu.js} +1 -1
  8. package/web/assets/{CapabilityMenu-kx1TIJYN.js → CapabilityMenu-SwVlZ06x.js} +1 -1
  9. package/web/assets/{CheckboxInput-eW7xdiRS.js → CheckboxInput-BC-5a_C9.js} +1 -1
  10. package/web/assets/{Chrome-B77-lQyh.js → Chrome-HdfyYV3i.js} +1 -1
  11. package/web/assets/{CodeView-Df3AiSIi.js → CodeView-CFL6yQ-6.js} +3 -3
  12. package/web/assets/{DashboardGridView-MlO1dpuo.js → DashboardGridView-B9DCWYVb.js} +12 -12
  13. package/web/assets/{EventCard-CDmeCbI8.js → EventCard-B_ndpqH_.js} +1 -1
  14. package/web/assets/{ExcalidrawCanvas-D9vkBh_5.js → ExcalidrawCanvas-BQ4KKLJP.js} +1 -1
  15. package/web/assets/{FloatingToc-tART_jC4.js → FloatingToc-Ce9GamvH.js} +1 -1
  16. package/web/assets/{HomepageView-Trqmd3RV.js → HomepageView-RCOfcVbE.js} +1 -1
  17. package/web/assets/{ImageStudioPanels-BfCVTnKC.js → ImageStudioPanels-lkS_y2uM.js} +2 -2
  18. package/web/assets/{ImageStudioView-KJhx0wJk.js → ImageStudioView-UPv52acl.js} +1 -1
  19. package/web/assets/{InlineFiles-BHwivGbQ.js → InlineFiles-CQbQumkf.js} +1 -1
  20. package/web/assets/{MarkdownBlock-D8LgHFYY.js → MarkdownBlock-CkqiwPXa.js} +19 -19
  21. package/web/assets/{ModelPill-DrW2cG0l.js → ModelPill-CY-rU1RU.js} +2 -2
  22. package/web/assets/{MuseLibraryView-CW78Uivf.js → MuseLibraryView-CtTHlVnT.js} +2 -2
  23. package/web/assets/{MuseView-Cb6R_l4i.js → MuseView-CC2A7MBs.js} +2 -2
  24. package/web/assets/{PageHistoryPanel-BQs9IWTP.js → PageHistoryPanel-KhKT1DLy.js} +2 -2
  25. package/web/assets/{PdfAnnotator-BFTBkxvO.js → PdfAnnotator-DUyrgY-t.js} +1 -1
  26. package/web/assets/{ProductView-mB-S0j81.js → ProductView-CgsIYZqD.js} +1 -1
  27. package/web/assets/{RightPanel-BVZeVO3c.js → RightPanel-BHDgqTFs.js} +3 -3
  28. package/web/assets/RunLocationPicker-DBnXYV5B.js +38 -0
  29. package/web/assets/{SidebarRow-D77yrSLf.js → SidebarRow-BAJxbMcx.js} +1 -1
  30. package/web/assets/{SketchCard-CAAr_cqF.js → SketchCard-BGYz-bXP.js} +1 -1
  31. package/web/assets/{StudioGuestSurface-DthpuVGg.js → StudioGuestSurface-lt6znmkl.js} +1 -1
  32. package/web/assets/{TodoListView-C3ZkMIIf.js → TodoListView-DPKhee6i.js} +1 -1
  33. package/web/assets/{Tooltip-D9Dt9ZTr.js → Tooltip-ZxrDqN4p.js} +1 -1
  34. package/web/assets/{UnifiedPage-C75y-MKT.js → UnifiedPage-BX6ZQL0h.js} +27 -27
  35. package/web/assets/{amadeus-manual.en-D5wZKuag.js → amadeus-manual.en-DzRWr4BL.js} +15 -15
  36. package/web/assets/{amadeus-manual.zh-Br5fidrj.js → amadeus-manual.zh-DW32DkL7.js} +15 -15
  37. package/web/assets/{appStore-B1ynyt42.js → appStore-DWP8UET9.js} +99 -79
  38. package/web/assets/appStore-wtOILggO.css +1 -0
  39. package/web/assets/{arrow-up-right-R10mR2I6.js → arrow-up-right-DrCXuWS7.js} +1 -1
  40. package/web/assets/{astryxBridge-CU_kQTEl.js → astryxBridge-D-m4_kYt.js} +3 -3
  41. package/web/assets/{automationListSource-B8EIRmDW.js → automationListSource-C8BNy6RY.js} +1 -1
  42. package/web/assets/{book-open-DBJ3dDpw.js → book-open-OLNm7OaB.js} +1 -1
  43. package/web/assets/{calendarNavStore-DGvUlU5N.js → calendarNavStore-Cylfvv3s.js} +1 -1
  44. package/web/assets/{canvasPrefs-DwL_OAAo.js → canvasPrefs-8taQ42Cz.js} +1 -1
  45. package/web/assets/{chatBoxSurface-Lq-2qfd3.js → chatBoxSurface-CIlzs45H.js} +1 -1
  46. package/web/assets/{circle-question-mark-HPZpZQxd.js → circle-question-mark-XbAFplz1.js} +1 -1
  47. package/web/assets/{circle-x-BZfe7d6S.js → circle-x-fcReAZaE.js} +1 -1
  48. package/web/assets/{client-DxGbwZLy.js → client-0MPbodA6.js} +1 -1
  49. package/web/assets/{code-xml-joKQ-qGS.js → code-xml-Cuna8Kh4.js} +1 -1
  50. package/web/assets/{codeStudioStore-C7rGKlOC.js → codeStudioStore-BBU62GTy.js} +1 -1
  51. package/web/assets/{codingNavigation-CjeWG4xm.js → codingNavigation-DDlPpPk5.js} +7 -7
  52. package/web/assets/{create-BjBRKATq.js → create-BGtEfCcg.js} +2 -2
  53. package/web/assets/{dashboardSurface-Cojgf_-U.js → dashboardSurface-BYM3C7WG.js} +1 -1
  54. package/web/assets/{deskCapture-DnGWk1iq.js → deskCapture-BiUCmqfc.js} +1 -1
  55. package/web/assets/{diff2html-Cd1rVi_Z.js → diff2html-BNp2FTbk.js} +1 -1
  56. package/web/assets/{docx-preview-CK0k1mUD.js → docx-preview-CFznGVOU.js} +1 -1
  57. package/web/assets/{emoji-Cjm3bKiF.js → emoji-6zl4yfOS.js} +1 -1
  58. package/web/assets/{floatingTocSurface-Dd1pT5j5.js → floatingTocSurface-DreXPCa6.js} +1 -1
  59. package/web/assets/{foldActions-Dm-uAt3L.js → foldActions-05QcQziQ.js} +1 -1
  60. package/web/assets/{folder-CvZyHIgb.js → folder-BpsfOHD4.js} +1 -1
  61. package/web/assets/{folder-plus-BRScGQ9m.js → folder-plus-BeQHr4AZ.js} +1 -1
  62. package/web/assets/{gestures-CZQVefU0.js → gestures-DQBCcK4y.js} +1 -1
  63. package/web/assets/{hand-D3QspKYq.js → hand-Bko7ms15.js} +1 -1
  64. package/web/assets/{hard-drive-BQsHSala.js → hard-drive-BpuI5ebj.js} +1 -1
  65. package/web/assets/{i18n.generated-BZRHO2Nc.js → i18n.generated-BuLjnmY8.js} +1 -1
  66. package/web/assets/{imageStudio-Cy3_437s.js → imageStudio-BLVNKmEG.js} +2 -2
  67. package/web/assets/{index-BPhwi4-v.js → index-BF10xp_K.js} +1 -1
  68. package/web/assets/{index-GjLSlygt.js → index-BHm6K743.js} +1 -1
  69. package/web/assets/{index-Bh_nLVTc.js → index-BM2o7PeV.js} +5 -5
  70. package/web/assets/{index-BcVGjCAJ.js → index-BgnNNv3e.js} +1 -1
  71. package/web/assets/{index-CcOag8eb.js → index-C0Gy2NQ6.js} +1 -1
  72. package/web/assets/{index-0AYHATDX.js → index-C1doZp5H.js} +1 -1
  73. package/web/assets/{index-9BmmlTjY.js → index-C4L6vjd_.js} +1 -1
  74. package/web/assets/{index-8ag1K7AZ.js → index-CD3yIkOA.js} +1 -1
  75. package/web/assets/{index-Dkd-nl1u.js → index-CJeUgjPU.js} +1 -1
  76. package/web/assets/{index-B5GxvbNm.js → index-CLHoq1w-.js} +1 -1
  77. package/web/assets/{index-DElrDw66.js → index-CUZI62qU.js} +1 -1
  78. package/web/assets/{index-BgtO11q8.js → index-Cff42k7q.js} +1 -1
  79. package/web/assets/{index-Dj-PygjB.js → index-Ck_O3Jdd.js} +1 -1
  80. package/web/assets/index-CuiYK18N.js +1 -0
  81. package/web/assets/{index-Bpc3R3DS.js → index-CwcOeZdT.js} +1 -1
  82. package/web/assets/{index-DJLWTPtq.js → index-D6AycQIz.js} +1 -1
  83. package/web/assets/{index-C9yo04Ck.js → index-D7gVhvNY.js} +1 -1
  84. package/web/assets/{index-BnWj6ggb.js → index-D9UZQy42.js} +1 -1
  85. package/web/assets/{index-D6mpAJ9S.js → index-DuBQ0j2g.js} +1 -1
  86. package/web/assets/{index-1FhRiJ_X.js → index-OD1gSX3h.js} +1 -1
  87. package/web/assets/{index-DNE_PBJt.js → index-Uo5tswys.js} +1 -1
  88. package/web/assets/{index-BgDZGDqt.js → index-o8cj0pRH.js} +1 -1
  89. package/web/assets/{index-BdZaheMZ.js → index-rHjhbwvm.js} +1 -1
  90. package/web/assets/{index-4E9nrhwf.js → index-rggq2czF.js} +1 -1
  91. package/web/assets/{index-D0FLFLfh.js → index-sCXThwqZ.js} +1 -1
  92. package/web/assets/{invitePage-B4gMvEKi.js → invitePage-b0HGvMj6.js} +1 -1
  93. package/web/assets/{ipc-CPhL3bPp.js → ipc-CxAyeo8q.js} +1 -1
  94. package/web/assets/{jszip.min-DAJT9RUA.js → jszip.min-B94KpE21.js} +1 -1
  95. package/web/assets/{layout-grid-DfUfnvDS.js → layout-grid-BBVuEdWG.js} +1 -1
  96. package/web/assets/{linkFollow-C6PHGUxk.js → linkFollow-B7ivDZMM.js} +5 -5
  97. package/web/assets/{list-tree-DaGpnIYu.js → list-tree-4-0QDbLu.js} +1 -1
  98. package/web/assets/{listFold-Q_8mh5ZG.js → listFold-DLuxXiIj.js} +1 -1
  99. package/web/assets/{lock-DQ_yL4nF.js → lock-CnbZm4vo.js} +1 -1
  100. package/web/assets/{log-out-DFwTeh2X.js → log-out-BEynWaHa.js} +1 -1
  101. package/web/assets/{main-NgUPPqDn.css → main-BiS_5wrB.css} +1 -1
  102. package/web/assets/main-sIq2N9Z5.js +20 -0
  103. package/web/assets/{markdownEditorSurface-e_oMhqx-.js → markdownEditorSurface-ZSJ3RHAv.js} +1 -1
  104. package/web/assets/{mdMarkStore-DjN4bf1T.js → mdMarkStore-DQHDjG7s.js} +2 -2
  105. package/web/assets/{mdMarks-cmL6vzR-.js → mdMarks-DbIcRa0O.js} +1 -1
  106. package/web/assets/{message-square-plus-CEHkduIL.js → message-square-plus-CpiKDvle.js} +1 -1
  107. package/web/assets/{messages-CBtmbpur.js → messages-_jta1lSI.js} +1 -1
  108. package/web/assets/minus-C9ndHJ9O.js +1 -0
  109. package/web/assets/{mobileEntry-qR7BAROr.js → mobileEntry-CPmU_c4m.js} +1 -1
  110. package/web/assets/{nativeDownload-CziEyW_p.js → nativeDownload-BYT082bY.js} +1 -1
  111. package/web/assets/{pageChrome-DFz_AAzZ.js → pageChrome-D3Niv1JM.js} +1 -1
  112. package/web/assets/{pageTree-yVO1_fSy.js → pageTree-CgfvpzIj.js} +1 -1
  113. package/web/assets/{pen-tool-uxsFELYC.js → pen-tool-BXEFnU2i.js} +1 -1
  114. package/web/assets/{pencil-BSbra1Ra.js → pencil-cqvCkekG.js} +1 -1
  115. package/web/assets/pluginChat-BbBukMuN.js +2 -0
  116. package/web/assets/{redo-2-BK5LMNa5.js → redo-2-BO7wCDwy.js} +1 -1
  117. package/web/assets/{rotate-ccw-HedfU4na.js → rotate-ccw-BvipPIjC.js} +1 -1
  118. package/web/assets/{sharePage-CpzDpuU1.js → sharePage-XbN50US7.js} +2 -2
  119. package/web/assets/{shareViewer-BwzH2bIs.js → shareViewer-BaYogetW.js} +1 -1
  120. package/web/assets/{star-CgYon3z4.js → star-BQWMXnn7.js} +1 -1
  121. package/web/assets/tableSurface-BXqqidd1.js +1 -0
  122. package/web/assets/{terminal-krsPf1mc.js → terminal-l9k6RDrH.js} +1 -1
  123. package/web/assets/{terminalView-4e2_u5_I.js → terminalView-Cpnt5_0P.js} +1 -1
  124. package/web/assets/{type-GJYLEhY-.js → type-CFoaj2eD.js} +1 -1
  125. package/web/assets/{undo-2-DCTs4Ro4.js → undo-2-DusxpdLa.js} +1 -1
  126. package/web/assets/{unitAccount-D3xjX3cu.js → unitAccount-DwutFPPw.js} +1 -1
  127. package/web/assets/{unitBridge-D5JcIkAP.js → unitBridge-CcgQpkqV.js} +1 -1
  128. package/web/assets/{unitCloudTransport-B44L3x6M.js → unitCloudTransport-vA7cLDts.js} +1 -1
  129. package/web/assets/{unitOwnerAccess-CRUHWGpf.js → unitOwnerAccess-LBlJ1YfA.js} +1 -1
  130. package/web/assets/{unitShim-_VzxvdEG.js → unitShim-B_M9IrbC.js} +3 -3
  131. package/web/assets/{upload-MVVRQtkj.js → upload-ZrOj6tXA.js} +1 -1
  132. package/web/assets/{userSpaces-CI4eqEgh.js → userSpaces-uJOnsedR.js} +1 -1
  133. package/web/assets/viewportLock-D3SNkwS2.js +631 -0
  134. package/web/assets/{workflow-DzeW9OXR.js → workflow-DPoG4QE2.js} +1 -1
  135. package/web/assets/{zoom-in-CovPsw4g.js → zoom-in-lbTgzdQP.js} +1 -1
  136. package/web/index.html +27 -7
  137. package/web/assets/RunLocationPicker-CyVa0RJa.js +0 -38
  138. package/web/assets/appStore-BC_CQv-L.css +0 -1
  139. package/web/assets/index-BaRySZ-M.js +0 -1
  140. package/web/assets/main-CwqZ_ymb.js +0 -19
  141. package/web/assets/minus-BUT48dAC.js +0 -1
  142. package/web/assets/pluginChat-BMFnf_j2.js +0 -2
  143. package/web/assets/tableSurface-CmDwnKnd.js +0 -1
  144. package/web/assets/viewportLock-BH26xHQO.js +0 -611
package/main.mjs CHANGED
@@ -3265,7 +3265,7 @@ init_control();
3265
3265
  // desktop/package.json
3266
3266
  var package_default = {
3267
3267
  name: "forsion-desktop",
3268
- version: "2.13.0",
3268
+ version: "2.13.1",
3269
3269
  description: "Forsion Desktop \u2014 AI \u9A71\u52A8\u7684\u5E94\u7528\u751F\u6001\u7CFB\u7EDF\u7684\u684C\u9762\u7AEF(Electron):Tangu Agent \u5F15\u64CE + LCL \u53EF\u505C\u9760\u5DE5\u4F5C\u533A\u6846\u67B6 + \u53EF\u63D2\u62D4\u529F\u80FD\u7A7A\u95F4(\u5BF9\u8BDD/\u7B14\u8BB0/\u65E5\u5386/\u6536\u4EF6\u7BB1/\u7F16\u7801),\u6309\u4EA7\u54C1\u6863\u6848\u88C1\u51FA\u5168\u5BB6\u6876\u4E0E\u5355\u54C1\u53D1\u884C\u7248",
3270
3270
  author: "Forsion",
3271
3271
  private: true,
@@ -3306,6 +3306,7 @@ var package_default = {
3306
3306
  "e2e:recall": "node scripts/recall-rewind.e2e.cjs",
3307
3307
  "e2e:chatevents": "node scripts/chat-events.e2e.cjs",
3308
3308
  "e2e:computerhistory": "node scripts/computer-history.e2e.cjs",
3309
+ "e2e:appdock": "node scripts/app-dock.e2e.cjs",
3309
3310
  "e2e:remotesafety": "node scripts/remote-safety.e2e.cjs",
3310
3311
  "e2e:chatshimmer": "node scripts/chat-shimmer.e2e.cjs",
3311
3312
  "e2e:runstats": "node scripts/chat-runstats.e2e.cjs",
@@ -3317,6 +3318,7 @@ var package_default = {
3317
3318
  "e2e:coreplugins": "node scripts/core-plugins.e2e.cjs",
3318
3319
  "e2e:restart-update": "node scripts/restart-update.e2e.cjs",
3319
3320
  "e2e:market-submissions": "node scripts/market-submissions.e2e.cjs",
3321
+ "e2e:storepages": "node scripts/store-pages.e2e.cjs",
3320
3322
  "e2e:market-auto-update": "node scripts/market-auto-update.e2e.cjs",
3321
3323
  "e2e:account": "node scripts/account-center.shot.cjs",
3322
3324
  "e2e:accountpopups": "node scripts/account-popups.shot.cjs",
@@ -3588,8 +3590,8 @@ var package_default = {
3588
3590
  "@dnd-kit/sortable": "^10.0.0",
3589
3591
  "@dnd-kit/utilities": "^3.2.2",
3590
3592
  "@excalidraw/excalidraw": "npm:@zsviczian/excalidraw@0.18.122",
3591
- "@forsion/extend": "0.7.1",
3592
- "@forsion/tangu-computer-use": "0.6.1",
3593
+ "@forsion/extend": "0.8.1",
3594
+ "@forsion/tangu-computer-use": "0.6.2",
3593
3595
  "@milkdown/kit": "^7.21.2",
3594
3596
  "@milkdown/plugin-math": "^7.5.9",
3595
3597
  "@milkdown/react": "^7.21.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsion/unit",
3
- "version": "2.13.0",
3
+ "version": "2.13.1",
4
4
  "type": "module",
5
5
  "description": "Forsion Unit: the independently runnable Forsion framework (plugin host and Web UI), prebuilt.",
6
6
  "license": "SEE LICENSE IN LICENSE",
package/release.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
- "desktopVersion": "2.13.0",
3
- "desktopTag": "v2.13.0",
4
- "desktopCommit": "a3ff47a34939b04600374b8b242b9916853a105c",
2
+ "desktopVersion": "2.13.1",
3
+ "desktopTag": "v2.13.1",
4
+ "desktopCommit": "d34f6593e95c10bcd97928e7518daba544eabefd",
5
5
  "unitRevision": 0,
6
6
  "prerelease": false,
7
- "sourceCommit": "a3ff47a34939b04600374b8b242b9916853a105c",
7
+ "sourceCommit": "d34f6593e95c10bcd97928e7518daba544eabefd",
8
8
  "sourceDirty": false,
9
- "builtAt": "2026-10-06T10:15:03.149Z",
9
+ "builtAt": "2026-10-06T16:44:52.470Z",
10
10
  "commercialServerIncluded": false
11
11
  }
@@ -1 +1 @@
1
- import{u as P,d,j as t}from"./index-Bh_nLVTc.js";import{F as D,a5 as T,aB as M,mm as R,eQ as V,hh as W,br as q,aa as y,mn as N,bn as B,a4 as U,bI as _,d_ as H,aq as $,mo as J,fJ as K,p as O,u as Q}from"./appStore-B1ynyt42.js";import"./client-DxGbwZLy.js";import{u as X}from"./codeStudioStore-C7rGKlOC.js";import{C as G}from"./CapabilityMenu-kx1TIJYN.js";import{c as Y}from"./nativeDownload-CziEyW_p.js";/* empty css */import{C as Z}from"./code-xml-joKQ-qGS.js";import{P as aa}from"./pencil-BSbra1Ra.js";import{A as ta}from"./arrow-up-right-R10mR2I6.js";import"./ipc-CPhL3bPp.js";const ia=[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],ea=D("monitor-down",ia);let v=0;const f=Y((i,l)=>({items:[],status:"loading",async load(){const m=window.tangu?.productsList;if(!m){i({status:"error"});return}const r=++v;l().status!=="ready"&&i({status:"loading"});try{const n=await m();r===v&&i({items:n,status:"ready"})}catch{r===v&&l().status!=="ready"&&i({status:"error"})}}})),b=i=>i instanceof Error?i.message:String(i);function wa(){const{t:i,locale:l}=P(),m=f(a=>a.items),r=f(a=>a.status),n=f(a=>a.load),[k]=d.useState(()=>f.getState().status!=="ready"),[S,o]=d.useState(null),w=T(a=>a.spaces.some(e=>e.id==="coding"))&&!!M("code-studio"),[z,g]=d.useState(()=>Date.now());d.useEffect(()=>{n();const a=()=>{g(Date.now()),n()};return window.addEventListener("focus",a),()=>{window.removeEventListener("focus",a)}},[n]),d.useEffect(()=>{const a=setInterval(()=>{document.hidden||g(Date.now())},6e4);return()=>clearInterval(a)},[]);const u=(a,e,s=!1)=>Q.getState().toast(i(a,e),s),L=a=>{O.getState().openView("product",{id:a.id},"main",{newTab:!0})},C=a=>{window.tangu?.openDetached?.([{type:"product",params:{id:a.id}}])},p=a=>{y("coding"),requestAnimationFrame(()=>{X.getState().openProject(a.root,a.name)})},E=async a=>{const e=window.tangu?.productsShortcut;if(e){o(a.id);try{const{key:s,error:c,vars:h}=J(await e(a.id,i("artificial.shortcut.fallbackName")));u(s,h,c)}catch(s){u("artificial.toast.shortcutFailed",{detail:b(s)},!0)}finally{o(null)}}},I=async a=>{const e=window.tangu?.productsUpdate;if(!e)return;const s=(await K(i("artificial.rename.title"),a.name,{label:i("artificial.rename.label")}))?.trim();if(!(!s||s===a.name)){o(a.id);try{await e(a.id,{name:s}),await n()}catch(c){u("artificial.toast.renameFailed",{detail:b(c)},!0)}finally{o(null)}}},A=async a=>{const e=window.tangu?.productsTrash;if(!(!e||!window.confirm(i(a.external?"artificial.remove.confirm":"artificial.trash.confirm",{name:a.name})))){o(a.id);try{await e(a.id,{action:a.external?"unregister":"trash",dirId:a.dirId}),await n()}catch(s){u("artificial.toast.trashFailed",{detail:b(s)},!0)}finally{o(null)}}},F=a=>{const e=N(a.kind),s=e.icon,c=S===a.id,h=[...e.canLaunch&&window.tangu?.openDetached?[{id:"open-window",label:i("artificial.action.openWindow"),icon:t.jsx(B,{size:14}),onSelect:()=>C(a)}]:[],...w?[{id:"edit",label:i("artificial.action.edit"),icon:t.jsx(Z,{size:14}),onSelect:()=>p(a)}]:[],...e.canShortcut&&window.tangu?.productsShortcut?[{id:"shortcut",label:i("artificial.action.shortcut"),icon:t.jsx(ea,{size:14}),onSelect:()=>{E(a)}}]:[],...window.tangu?.revealHostPath?[{id:"reveal",label:i("artificial.action.reveal"),icon:t.jsx(U,{size:14}),onSelect:()=>{window.tangu?.revealHostPath?.(a.root)}}]:[],...window.tangu?.productsUpdate?[{id:"rename",label:i("artificial.action.rename"),icon:t.jsx(aa,{size:14}),onSelect:()=>{I(a)}}]:[],...window.tangu?.productsTrash?[{id:"trash",label:i(a.external?"artificial.action.remove":"artificial.action.trash"),icon:t.jsx(_,{size:14}),danger:!0,onSelect:()=>{A(a)}}]:[]],j=c||!e.canLaunch&&!w;return t.jsxs("div",{className:"newtab-card art-card","data-artificial-card":!0,"data-product-id":a.id,"data-kind":a.kind,children:[t.jsxs("button",{className:"art-card-main","data-action":"open",disabled:j,"aria-label":e.canLaunch?i("artificial.action.open",{name:a.name}):`${i("artificial.action.edit")} · ${a.name}`,onClick:()=>e.canLaunch?L(a):p(a),children:[t.jsx("span",{className:"newtab-card-ic",children:t.jsx(s,{size:18})}),t.jsx("span",{className:"art-card-name",title:a.name,children:a.name}),!j&&t.jsx(ta,{size:14,className:"art-card-go","aria-hidden":!0})]}),t.jsxs("div",{className:"art-card-foot",children:[t.jsxs("div",{className:"art-card-meta",children:[t.jsx("span",{children:H(a.updatedAt,{now:z,locale:l})}),a.published&&t.jsx("span",{className:"art-badge","data-badge":"published",children:i("artificial.badge.published")}),a.kind==="plugin"&&a.devLoad&&t.jsx("span",{className:"art-badge","data-badge":"devload",children:i("artificial.badge.devLoad")})]}),h.length>0&&t.jsx(G,{label:i("artificial.action.more",{name:a.name}),className:"icon-btn art-card-more",disabled:c,items:h,children:t.jsx($,{size:14})})]})]},a.id)},x=R(m);return t.jsx("div",{className:"art-root","data-artificial-root":!0,children:t.jsxs("div",{className:"art-inner",children:[t.jsxs("div",{className:"art-head",children:[t.jsx(V,{size:18}),t.jsxs("div",{className:"art-titles",children:[t.jsx("div",{className:"art-title",children:i("view.artificial")}),t.jsx("div",{className:"art-sub",children:i("artificial.subtitle")})]}),t.jsx("button",{className:"icon-btn","data-action":"refresh",title:i("artificial.refresh"),"aria-label":i("artificial.refresh"),onClick:()=>{n()},children:t.jsx(W,{size:14})})]}),r==="loading"&&t.jsxs("div",{className:"art-loading","data-state":"loading",children:[t.jsx(q,{variant:"list"}),t.jsx("span",{className:"art-sr-only",role:"status",children:i("artificial.loading")})]}),r==="error"&&t.jsxs("div",{className:"art-state",role:"alert","data-state":"error",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.loadFailed")}),t.jsx("button",{className:"btn sm","data-action":"retry",onClick:()=>{n()},children:i("common.retry")})]}),r==="ready"&&!x.length&&t.jsxs("div",{className:"art-state","data-state":"empty",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.empty.title")}),t.jsx("p",{children:i("artificial.empty.body")}),w&&t.jsx("button",{className:"btn primary sm","data-action":"go-coding",onClick:()=>y("coding"),children:i("artificial.empty.cta")})]}),r==="ready"&&x.length>0&&t.jsx("div",{className:k?"sk-fade-in":void 0,children:x.map(a=>t.jsxs("div",{className:"newtab-sec","data-kind-group":a.kind,children:[t.jsx("div",{className:"newtab-sec-title",children:i(N(a.kind).labelKey)}),t.jsx("div",{className:"newtab-grid art-grid",children:a.items.map(F)})]},a.kind))})]})})}export{wa as ArtificialView};
1
+ import{u as P,d,j as t}from"./index-BM2o7PeV.js";import{F as D,a5 as T,aB as M,mo as R,eR as V,hj as W,bs as q,aa as y,mp as N,b0 as B,a4 as U,bJ as $,d$ as H,ar as _,mq as J,fL as K,p as O,u as X}from"./appStore-DWP8UET9.js";import"./client-0MPbodA6.js";import{u as G}from"./codeStudioStore-BBU62GTy.js";import{C as Q}from"./CapabilityMenu-SwVlZ06x.js";import{c as Y}from"./nativeDownload-BYT082bY.js";/* empty css */import{C as Z}from"./code-xml-Cuna8Kh4.js";import{P as aa}from"./pencil-cqvCkekG.js";import{A as ta}from"./arrow-up-right-DrCXuWS7.js";import"./ipc-CxAyeo8q.js";const ia=[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],ea=D("monitor-down",ia);let v=0;const f=Y((i,l)=>({items:[],status:"loading",async load(){const m=window.tangu?.productsList;if(!m){i({status:"error"});return}const r=++v;l().status!=="ready"&&i({status:"loading"});try{const n=await m();r===v&&i({items:n,status:"ready"})}catch{r===v&&l().status!=="ready"&&i({status:"error"})}}})),b=i=>i instanceof Error?i.message:String(i);function wa(){const{t:i,locale:l}=P(),m=f(a=>a.items),r=f(a=>a.status),n=f(a=>a.load),[k]=d.useState(()=>f.getState().status!=="ready"),[S,o]=d.useState(null),w=T(a=>a.spaces.some(e=>e.id==="coding"))&&!!M("code-studio"),[z,g]=d.useState(()=>Date.now());d.useEffect(()=>{n();const a=()=>{g(Date.now()),n()};return window.addEventListener("focus",a),()=>{window.removeEventListener("focus",a)}},[n]),d.useEffect(()=>{const a=setInterval(()=>{document.hidden||g(Date.now())},6e4);return()=>clearInterval(a)},[]);const u=(a,e,s=!1)=>X.getState().toast(i(a,e),s),L=a=>{O.getState().openView("product",{id:a.id},"main",{newTab:!0})},C=a=>{window.tangu?.openDetached?.([{type:"product",params:{id:a.id}}])},p=a=>{y("coding"),requestAnimationFrame(()=>{G.getState().openProject(a.root,a.name)})},E=async a=>{const e=window.tangu?.productsShortcut;if(e){o(a.id);try{const{key:s,error:c,vars:h}=J(await e(a.id,i("artificial.shortcut.fallbackName")));u(s,h,c)}catch(s){u("artificial.toast.shortcutFailed",{detail:b(s)},!0)}finally{o(null)}}},A=async a=>{const e=window.tangu?.productsUpdate;if(!e)return;const s=(await K(i("artificial.rename.title"),a.name,{label:i("artificial.rename.label")}))?.trim();if(!(!s||s===a.name)){o(a.id);try{await e(a.id,{name:s}),await n()}catch(c){u("artificial.toast.renameFailed",{detail:b(c)},!0)}finally{o(null)}}},F=async a=>{const e=window.tangu?.productsTrash;if(!(!e||!window.confirm(i(a.external?"artificial.remove.confirm":"artificial.trash.confirm",{name:a.name})))){o(a.id);try{await e(a.id,{action:a.external?"unregister":"trash",dirId:a.dirId}),await n()}catch(s){u("artificial.toast.trashFailed",{detail:b(s)},!0)}finally{o(null)}}},I=a=>{const e=N(a.kind),s=e.icon,c=S===a.id,h=[...e.canLaunch&&window.tangu?.openDetached?[{id:"open-window",label:i("artificial.action.openWindow"),icon:t.jsx(B,{size:14}),onSelect:()=>C(a)}]:[],...w?[{id:"edit",label:i("artificial.action.edit"),icon:t.jsx(Z,{size:14}),onSelect:()=>p(a)}]:[],...e.canShortcut&&window.tangu?.productsShortcut?[{id:"shortcut",label:i("artificial.action.shortcut"),icon:t.jsx(ea,{size:14}),onSelect:()=>{E(a)}}]:[],...window.tangu?.revealHostPath?[{id:"reveal",label:i("artificial.action.reveal"),icon:t.jsx(U,{size:14}),onSelect:()=>{window.tangu?.revealHostPath?.(a.root)}}]:[],...window.tangu?.productsUpdate?[{id:"rename",label:i("artificial.action.rename"),icon:t.jsx(aa,{size:14}),onSelect:()=>{A(a)}}]:[],...window.tangu?.productsTrash?[{id:"trash",label:i(a.external?"artificial.action.remove":"artificial.action.trash"),icon:t.jsx($,{size:14}),danger:!0,onSelect:()=>{F(a)}}]:[]],j=c||!e.canLaunch&&!w;return t.jsxs("div",{className:"newtab-card art-card","data-artificial-card":!0,"data-product-id":a.id,"data-kind":a.kind,children:[t.jsxs("button",{className:"art-card-main","data-action":"open",disabled:j,"aria-label":e.canLaunch?i("artificial.action.open",{name:a.name}):`${i("artificial.action.edit")} · ${a.name}`,onClick:()=>e.canLaunch?L(a):p(a),children:[t.jsx("span",{className:"newtab-card-ic",children:t.jsx(s,{size:18})}),t.jsx("span",{className:"art-card-name",title:a.name,children:a.name}),!j&&t.jsx(ta,{size:14,className:"art-card-go","aria-hidden":!0})]}),t.jsxs("div",{className:"art-card-foot",children:[t.jsxs("div",{className:"art-card-meta",children:[t.jsx("span",{children:H(a.updatedAt,{now:z,locale:l})}),a.published&&t.jsx("span",{className:"art-badge","data-badge":"published",children:i("artificial.badge.published")}),a.kind==="plugin"&&a.devLoad&&t.jsx("span",{className:"art-badge","data-badge":"devload",children:i("artificial.badge.devLoad")})]}),h.length>0&&t.jsx(Q,{label:i("artificial.action.more",{name:a.name}),className:"icon-btn art-card-more",disabled:c,items:h,children:t.jsx(_,{size:14})})]})]},a.id)},x=R(m);return t.jsx("div",{className:"art-root","data-artificial-root":!0,children:t.jsxs("div",{className:"art-inner",children:[t.jsxs("div",{className:"art-head",children:[t.jsx(V,{size:18}),t.jsxs("div",{className:"art-titles",children:[t.jsx("div",{className:"art-title",children:i("view.artificial")}),t.jsx("div",{className:"art-sub",children:i("artificial.subtitle")})]}),t.jsx("button",{className:"icon-btn","data-action":"refresh",title:i("artificial.refresh"),"aria-label":i("artificial.refresh"),onClick:()=>{n()},children:t.jsx(W,{size:14})})]}),r==="loading"&&t.jsxs("div",{className:"art-loading","data-state":"loading",children:[t.jsx(q,{variant:"list"}),t.jsx("span",{className:"art-sr-only",role:"status",children:i("artificial.loading")})]}),r==="error"&&t.jsxs("div",{className:"art-state",role:"alert","data-state":"error",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.loadFailed")}),t.jsx("button",{className:"btn sm","data-action":"retry",onClick:()=>{n()},children:i("common.retry")})]}),r==="ready"&&!x.length&&t.jsxs("div",{className:"art-state","data-state":"empty",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.empty.title")}),t.jsx("p",{children:i("artificial.empty.body")}),w&&t.jsx("button",{className:"btn primary sm","data-action":"go-coding",onClick:()=>y("coding"),children:i("artificial.empty.cta")})]}),r==="ready"&&x.length>0&&t.jsx("div",{className:k?"sk-fade-in":void 0,children:x.map(a=>t.jsxs("div",{className:"newtab-sec","data-kind-group":a.kind,children:[t.jsx("div",{className:"newtab-sec-title",children:i(N(a.kind).labelKey)}),t.jsx("div",{className:"newtab-grid art-grid",children:a.items.map(I)})]},a.kind))})]})})}export{wa as ArtificialView};
@@ -1 +1 @@
1
- import{d as o,j as e,u as pe}from"./index-Bh_nLVTc.js";import{F as Ye,bo as Qe,qI as le,fy as Ze,kn as et,aJ as tt,dC as at,fL as nt,fH as it,hB as lt,hw as st,gK as ot,hE as rt,qJ as dt,h as ut,b as ct,fl as ie,aS as mt,qK as ht,qL as $e,qM as Ie,qN as Fe,a2 as Re,K as qe,hy as be,ap as bt,aK as xt,qO as pt,bI as xe,qP as vt,qQ as gt,bG as jt,bH as ft,G as yt,J as Nt,_ as _t,gE as Ct,qR as kt,qS as wt,s as St,qT as Et,qU as Pt,u as $t}from"./appStore-B1ynyt42.js";import{C as Ft}from"./CapabilityMenu-kx1TIJYN.js";import{u as Rt}from"./gestures-CZQVefU0.js";import{a as qt,C as Dt}from"./Chrome-B77-lQyh.js";import{d as Tt,e as zt,f as It,g as Mt}from"./canvasPrefs-DwL_OAAo.js";import{R as At}from"./rotate-ccw-HedfU4na.js";import"./messages-CBtmbpur.js";import{W as De}from"./workflow-DzeW9OXR.js";import{C as Ht}from"./circle-question-mark-HPZpZQxd.js";const Lt=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Vt=Ye("bell",Lt);function Wt({controller:i,open:c,title:b,onClose:C,children:h}){const[g]=o.useState(()=>document.createElement("div"));g.className="auto-extension";const a=o.useRef(null),k=o.useRef(C);k.current=C;const v=o.useRef(b);return v.current=b,o.useEffect(()=>{if(!(!i||!c)){try{a.current=i.open({id:"automation-context",title:()=>v.current,mount:f=>(f.appendChild(g),()=>g.remove()),onClose:()=>k.current()})}catch{k.current()}return()=>{a.current?.close(),a.current=null}}},[i,c,g]),c?i?Qe.createPortal(h,g):e.jsx("div",{className:"auto-extension auto-extension-inline",children:h}):null}const sa=["reminder","briefing","table","button"];function Ot(i,c){return i?i==="briefing"||i==="button"?[{...le("agent_run"),prompt:c(`automation.ux.${i}.prompt`)}]:[{...le("notify"),title:c(`automation.ux.${i}.name`),body:c(`automation.ux.${i}.body`)}]:[le("notify")]}function Te(i,c,b){if(i.type==="notify")return i.title.trim()?null:"notify";if(i.type==="agent_run")return i.agentSlug?i.prompt.trim()?null:"prompt":"agent";if(i.type==="db_row_add"||i.type==="db_row_edit"){if(!/\.db$/i.test(i.dbPath.trim()))return"table";if(!i.cells.some(h=>h.k.trim()))return"cells";if(i.type==="db_row_edit"){if(c!=="db_changed"&&(!i.rowId.trim()&&!i.matchColumn.trim()||i.rowFrom.trim()))return"row";if(i.matchColumn.trim()&&!i.matchValue.trim())return"match"}return null}const C=b.find(h=>h.name===i.tool);if(!C)return"tool";if((C.parameters.required||[]).some(h=>!(i.argValues[h]||"").trim()))return"args";for(const[h,g]of Object.entries(i.argValues)){if(!g.trim())continue;const a=C.parameters.properties?.[h];if(a?.type==="number"&&!Number.isFinite(Number(g)))return"args";if(a?.type==="object"||a?.type==="array")try{const k=JSON.parse(g);if(a.type==="array"?!Array.isArray(k):!k||typeof k!="object"||Array.isArray(k))return"json"}catch{return"json"}}return null}function Bt(i){return(i||[]).map(c=>({value:`{{row.${c.id}}}`,label:c.name}))}const Kt=i=>({x:0,y:i*132,w:244,h:84}),Ut=({nodes:i,selected:c,onSelect:b,children:C})=>{const{t:h}=pe(),g=o.useId().replace(/:/g,""),a=o.useRef(null),[k,v]=o.useState({}),[f,$]=o.useState(Tt),[I,F]=o.useState(zt),x=Ze(a),m=new Map(i.map((n,s)=>[n.id,k[n.id]||Kt(s)])),P=i.map(n=>n.id).join(","),p=Rt(a,x,{boxes:()=>m,identity:()=>P,commit:n=>v(s=>({...s,...Object.fromEntries(n)})),hitKey:n=>n.closest("[data-flow-node]")?.dataset.flowNode||null,onEnterEdit:b,onDoubleClick:n=>{n&&b(n)},minW:244,minH:84,repel:!0},f);o.useEffect(()=>p.bind(a.current),[p.bind]),o.useEffect(()=>x.bindWheel(a.current),[x.bindWheel]);const q=o.useRef(()=>x.fitTo([...m.values()],64));q.current=()=>x.fitTo([...m.values()],64),o.useEffect(()=>{v({});const n=requestAnimationFrame(()=>q.current());return()=>cancelAnimationFrame(n)},[P]),o.useEffect(()=>{const n=new ResizeObserver(()=>q.current());return a.current&&n.observe(a.current),()=>n.disconnect()},[]);const M=n=>p.live?.get(n)||m.get(n);return e.jsx("div",{className:"auto-canvas-shell am-app",children:e.jsxs("div",{className:"auto-canvas amx-stage",ref:a,tabIndex:0,"aria-label":h("automation.ux.flow"),onPointerUpCapture:n=>{if(p.busy)return;const s=document.elementFromPoint(n.clientX,n.clientY)?.closest("[data-flow-node]");s&&a.current?.contains(s)&&b(s.dataset.flowNode)},children:[e.jsx("div",{className:"amx-stage-grid",style:et(x.vp)}),e.jsxs("div",{className:"auto-canvas-world",style:{transform:`translate(${x.vp.x}px, ${x.vp.y}px) scale(${x.vp.z})`},children:[e.jsxs("svg",{className:"auto-canvas-edges","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsx("marker",{id:g,markerWidth:"8",markerHeight:"8",refX:"6",refY:"3",orient:"auto",children:e.jsx("path",{d:"M0,0 L6,3 L0,6",fill:"none",stroke:"currentColor"})})}),i.slice(1).map((n,s)=>{const y=M(i[s].id),w=M(n.id),A=y.x+y.w/2,H=y.y+y.h,X=w.x+w.w/2,V=w.y;return e.jsx("path",{d:`M${A},${H} C${A},${H+28} ${X},${V-28} ${X},${V}`,markerEnd:`url(#${g})`},n.id)})]}),i.map(n=>{const s=M(n.id);return e.jsxs("div",{"data-flow-node":n.id,role:"button",tabIndex:0,"aria-pressed":c===n.id,className:`auto-flow-node ${c===n.id?"selected":""}`,style:{left:s.x,top:s.y,width:s.w,height:s.h},onClick:()=>b(n.id),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),b(n.id))},children:[e.jsx("span",{className:"auto-flow-icon",children:n.icon}),e.jsx("strong",{children:n.title}),e.jsx("span",{className:"auto-flow-status",title:h(n.ready?"automation.ux.ready":"automation.ux.incomplete"),children:n.ready?e.jsx(tt,{size:13}):e.jsx(at,{size:13})}),e.jsx("span",{className:"auto-flow-subtitle",children:n.subtitle})]},n.id)}),p.marquee&&e.jsx("div",{className:"amx-stage-marquee",style:{left:p.marquee.x,top:p.marquee.y,width:p.marquee.w,height:p.marquee.h}})]}),C&&e.jsx("div",{className:"amx-stage-tools auto-canvas-tools",children:C}),e.jsx(qt,{zoom:x.vp.z,onZoomBy:n=>{const{w:s,h:y}=nt(a.current);x.setVp(it(x.vp,x.vp.z*n,s/2,y/2))},onFit:()=>q.current(),snap:f,onSnap:n=>{$(n),Mt(n)},mini:I,onMini:n=>{F(n),It(n)},extra:e.jsx("button",{type:"button",title:h("automation.ux.arrange"),onClick:()=>{v({}),requestAnimationFrame(()=>q.current())},children:e.jsx(At,{size:12})})}),I&&e.jsx(Dt,{hostRef:a,vp:x.vp,items:i.map(n=>({key:n.id,kind:"card",box:M(n.id)})),onCenter:x.centerOn})]})})},ze=({label:i,value:c,onChange:b,multiline:C,maxLength:h=4e3,placeholder:g,columns:a,hasRow:k})=>{const{t:v}=pe(),f=o.useId(),$=o.useRef(null),I=o.useRef({start:c.length,end:c.length}),F=m=>{if(!m)return;const{start:P,end:p}=I.current;c.length-(p-P)+m.length>h||(b(c.slice(0,P)+m+c.slice(p)),requestAnimationFrame(()=>{$.current?.focus(),$.current?.setSelectionRange(P+m.length,P+m.length)}))},x={id:f,ref:$,value:c,maxLength:h,placeholder:g,onChange:m=>b(m.target.value),onSelect:m=>{I.current={start:m.currentTarget.selectionStart??c.length,end:m.currentTarget.selectionEnd??c.length}}};return e.jsxs("div",{className:"field auto-template-field",children:[e.jsxs("div",{className:"auto-field-heading",children:[e.jsx("label",{htmlFor:f,children:i}),e.jsxs("select",{"aria-label":v("automation.ux.insertVariable",{field:i}),value:"",onChange:m=>F(m.target.value),children:[e.jsx("option",{value:"",children:v("automation.ux.variables")}),e.jsx("option",{value:"{{today}}",children:v("automation.ux.today")}),e.jsx("option",{value:"{{now}}",children:v("automation.ux.now")}),k&&e.jsxs("optgroup",{label:v("automation.ux.triggerRow"),children:[e.jsx("option",{value:"{{row.id}}",children:v("automation.ux.rowId")}),Bt(a).map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))]})]})]}),C?e.jsx("textarea",{...x}):e.jsx("input",{type:"text",...x})]})};function Gt(){const i=new Date(Date.now()+36e5);i.setMinutes(0,0,0);const c=b=>String(b).padStart(2,"0");return`${i.getFullYear()}-${c(i.getMonth()+1)}-${c(i.getDate())}T${c(i.getHours())}:00`}const Jt=({editing:i,starter:c,fixedManual:b,onSaved:C,onCancel:h,extendView:g})=>{const{t:a}=pe(),k=lt(),v=st(),f=v.actionsCatalog,[$,I]=o.useState(i?.desc||(c?a(`automation.ux.${c}.name`):"")),[F,x]=o.useState("trigger"),[m,P]=o.useState(!1),p=t=>{x(t),P(!0)},[q,M]=o.useState(i?.enabled??!!b),n=i?.cond,[s,y]=o.useState(n?n.type==="event_seen"?"event_seen":n.type==="file_chars_gte"?"file_chars_gte":n.type==="manual"?"manual":n.type==="db_changed"?"db_changed":"timer":b||c==="button"?"manual":c==="table"?"db_changed":"timer"),[w,A]=o.useState(n?.type==="at"?"at":n?.type==="every"?"every":"daily_at"),[H,X]=o.useState(n?.type==="daily_at"?n.time:"09:00"),V=!!i&&ot(i),[Y,Me]=o.useState(n?.type==="at"&&!V?n.datetime.replace(" ","T"):Gt()),Q=n?.type==="every"?/^(\d+)([mhd])$/.exec(n.interval):null,[Z,Ae]=o.useState(Q?Q[1]:"1"),[ve,He]=o.useState(Q?Q[2]:"h"),[se,Le]=o.useState(n?.type==="event_seen"?n.match:""),[oe,Ve]=o.useState(n?.type==="file_chars_gte"?n.path:""),[re,We]=o.useState(n?.type==="file_chars_gte"?String(n.n):"100"),[R,Oe]=o.useState(n?.type==="db_changed"?n.path:""),[T,ge]=o.useState(n?.type==="db_changed"?n.event:"row_added"),[L,je]=o.useState(()=>rt(n)),fe=(t,u)=>je(r=>u?r.includes(t)?r:[...r,t]:r.filter(l=>l!==t)),[de,Be]=o.useState(n?.type==="db_changed"&&n.equals||""),[W,ue]=o.useState(()=>dt(n)),ce=(t,u)=>ue(r=>r.map((l,d)=>d===t?{...l,...u}:l));o.useEffect(()=>{ut()},[]);const ye=ct(t=>t.files),O=o.useMemo(()=>ye.filter(t=>/\.db$/i.test(t)),[ye]);o.useEffect(()=>{for(const t of O)ie.getState().load(t,t)},[O]);const Ne=ie(mt(t=>O.filter(u=>t.entries[u]?.data?.source!==void 0))),ee=o.useMemo(()=>O.filter(t=>!Ne.includes(t)),[O,Ne]),B=ie(t=>s==="db_changed"&&R?t.entries[R]?.data?.columns:void 0),K=o.useMemo(()=>B?.filter(t=>t.type!=="formula"&&t.type!=="lookup"),[B]),[S,te]=o.useState(()=>i?ht(i):Ot(c,a)),[me,Ke]=o.useState(i&&!i.actions?.length&&!i.agentSlug&&i.prompt||""),[U,_e]=o.useState(()=>$e(i,s)),Ce=o.useRef(!1);o.useEffect(()=>{!i&&!Ce.current&&_e($e(null,s))},[s,i]);const[G,ke]=o.useState(!1),[we,ae]=o.useState(""),Ue=t=>{if(S.length>=24)return;const u=le(t);te(r=>[...r,u]),p(String(u.key))},Se=S.some(t=>t.type==="agent_run"),j=(t,u)=>te(r=>r.map(l=>l.key===t?{...l,...u}:l)),Ee=(t,u)=>te(r=>{const l=t+u;if(l<0||l>=r.length)return r;const d=[...r];return[d[t],d[l]]=[d[l],d[t]],d});if(Ie(i))return e.jsxs("div",{className:"auto-builder",children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(De,{size:17})," ",a("automation.builder.editTitle")]}),e.jsx("div",{className:"auto-node",children:e.jsx("div",{className:"auto-hint",children:a("automation.builder.unsupported")})}),e.jsx("div",{className:"auto-builder-actions",children:e.jsx("button",{className:"btn ghost",onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})})]});const Pe=!(s==="timer"&&(w==="daily_at"&&!/^\d{1,2}:\d{2}$/.test(H)||w==="at"&&!Y||w==="every"&&(!Number.isInteger(Number(Z))||Number(Z)<1))||s==="event_seen"&&!se.trim()||s==="file_chars_gte"&&(!oe.trim()||!(Number(re)>0))||s==="db_changed"&&(!/\.db$/i.test(R.trim())||T==="cell_changed"&&!L.length||W.length>Fe||W.some(t=>t.column.trim()&&(t.op==="eq"||t.op==="ne")&&!t.value.trim()))),E=[];$.trim()||E.push({node:"trigger",text:a("automation.ux.issue.name")}),Pe||E.push({node:"trigger",text:a("automation.ux.issue.trigger")}),!S.length&&(!i||s==="manual")&&E.push({node:"review",text:a("automation.ux.issue.steps")}),S.forEach((t,u)=>{const r=Te(t,s,f);r&&E.push({node:String(t.key),text:`${u+1}. ${a(`automation.ux.issue.${r}`)}`})}),s!=="timer"&&s!=="manual"&&(!U.trim()||!Number.isFinite(Number(U))||Number(U)<0)&&E.push({node:"review",text:a("automation.ux.issue.cooldown")});const ne=E.length===0,Ge=async()=>{if(!ne||G)return;const t=s==="timer"?w:s;if(t==="at"&&(Ct(Y)?.getTime()??0)<Date.now()-5*6e4){ae(a("automation.builder.atPast"));return}const u=d=>ie.getState().entries[d]?.data?.source!==void 0;if([...t==="db_changed"?[R.trim()]:[],...S.filter(d=>d.type==="db_row_add"||d.type==="db_row_edit").map(d=>d.dbPath.trim())].filter(Boolean).some(u)){ae(a("automation.builder.dbNoteView"));return}ke(!0),ae("");const l=kt(S,f);try{const d=await wt(St(),{id:i?.id,actor:"user",desc:$.trim(),cond_type:t,time:t==="daily_at"?H:void 0,datetime:t==="at"?Y:void 0,interval:t==="every"?`${Math.floor(Number(Z))}${ve}`:void 0,match:t==="event_seen"?se.trim():void 0,path:t==="file_chars_gte"?oe.trim():t==="db_changed"?R.trim():void 0,n:t==="file_chars_gte"?Number(re):void 0,event:t==="db_changed"?T:void 0,column_id:t==="db_changed"&&T==="cell_changed"?L[0]:void 0,column_ids:t==="db_changed"&&T==="cell_changed"&&L.length>1?L:void 0,equals:t==="db_changed"&&T==="cell_changed"&&de.trim()?de.trim():void 0,where:t==="db_changed"?Pt(W):void 0,vault:t==="db_changed"&&i?.cond.type==="db_changed"?i.cond.vault:void 0,prompt:S.length?void 0:me.trim()||void 0,cooldown_hours:Et(s,U),actions:S.length?l:null,enabled:q});if(C){v.bump(),C(d);return}v.acceptSaved(d),$t.getState().toast(a("automation.ux.saved"))}catch(d){ae(String(d?.message||d))}finally{ke(!1)}},he=t=>t==="notify"?e.jsx(Vt,{size:14}):t==="agent_run"?e.jsx(yt,{size:14}):t==="db_row_add"||t==="db_row_edit"?e.jsx(Nt,{size:14}):e.jsx(_t,{size:14}),Je=[{id:"trigger",title:a("automation.builder.trigger"),subtitle:a(`automation.builder.${s==="timer"?"condTimer":s==="manual"?"condManual":s==="db_changed"?"condDb":s==="event_seen"?"condEvent":"condFile"}`),icon:e.jsx(Re,{size:17}),ready:Pe&&!!$.trim()},...S.map((t,u)=>({id:String(t.key),title:`${u+1}. ${a(`automation.step.${t.type}`)}`,subtitle:t.title||t.prompt||t.dbPath||t.tool||a("automation.ux.setupHint"),icon:he(t.type),ready:!Te(t,s,f)})),...!S.length&&i&&s!=="manual"?[{id:"muse",title:a("automation.builder.museFallback"),subtitle:me||a("automation.builder.museFallbackHint"),icon:e.jsx(qe,{size:17}),ready:!0}]:[],{id:"review",title:a("automation.ux.finish"),subtitle:a(ne?"automation.ux.allReady":"automation.ux.finishHint"),icon:e.jsx(be,{size:17}),ready:ne}],Xe=e.jsxs(e.Fragment,{children:[e.jsxs(Ft,{label:a("automation.ux.addStep"),className:"btn ghost sm",disabled:G||S.length>=24,items:["notify","agent_run","db_row_add","db_row_edit","tool_call"].map(t=>({id:t,label:a(`automation.step.${t}`),icon:he(t),disabled:t==="tool_call"&&!f.length,onSelect:()=>Ue(t)})),children:[e.jsx(bt,{size:14}),a("automation.ux.addStep")]}),e.jsx("button",{className:"icon-btn",title:a("automation.ux.help"),onClick:()=>p("help"),children:e.jsx(Ht,{size:15})})]});return e.jsxs("div",{className:`auto-builder auto-workflow-builder ${b?"auto-builder-embedded":""}`,children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(De,{size:17}),e.jsx("span",{children:a(i?"automation.builder.editTitle":"automation.builder.title")}),e.jsx("button",{className:"btn ghost sm",disabled:G,onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})]}),e.jsx("div",{className:"auto-builder-workspace",hidden:!g&&m,children:e.jsx(Ut,{nodes:Je,selected:m?F:"",onSelect:p,children:Xe})}),e.jsxs(Wt,{controller:g,open:m,title:a("automation.ux.setup"),onClose:()=>P(!1),children:[!g&&e.jsxs("button",{className:"btn ghost sm auto-inline-back",onClick:()=>P(!1),children:[e.jsx(xt,{size:14}),a("automation.ux.flow")]}),e.jsxs("div",{className:"auto-inspector","aria-label":a("automation.ux.setup"),children:[e.jsxs("div",{className:"auto-node",hidden:F!=="trigger",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(Re,{size:14})}),a("automation.builder.trigger")]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.desc")}),e.jsx("input",{"aria-label":a("automation.builder.desc"),type:"text",value:$,maxLength:200,placeholder:a("automation.builder.descPh"),onChange:t=>I(t.target.value)})]}),!b&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.condType")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:s==="timer"?"active":"",onClick:()=>y("timer"),children:a("automation.builder.condTimer")}),e.jsx("button",{className:s==="event_seen"?"active":"",onClick:()=>y("event_seen"),children:a("automation.builder.condEvent")}),e.jsx("button",{className:s==="file_chars_gte"?"active":"",onClick:()=>y("file_chars_gte"),children:a("automation.builder.condFile")}),e.jsx("button",{className:s==="db_changed"?"active":"",onClick:()=>y("db_changed"),children:a("automation.builder.condDb")}),e.jsx("button",{className:s==="manual"?"active":"",onClick:()=>y("manual"),children:a("automation.builder.condManual")})]})]}),s==="db_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:R,onChange:t=>{Oe(t.target.value),je([])},children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(t=>e.jsx("option",{value:t,children:t},t)),R&&!ee.includes(R)&&e.jsx("option",{value:R,children:R})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEvent")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:T==="row_added"?"active":"",onClick:()=>ge("row_added"),children:a("automation.builder.dbEventRow")}),e.jsx("button",{className:T==="cell_changed"?"active":"",onClick:()=>ge("cell_changed"),children:a("automation.builder.dbEventCell")})]})]}),T==="cell_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbColumn")}),e.jsxs("div",{className:"auto-checks",children:[(K??[]).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:L.includes(t.id),onChange:u=>fe(t.id,u.target.checked)}),t.name]},t.id)),L.filter(t=>!(K??[]).some(u=>u.id===t)).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:!0,onChange:()=>fe(t,!1)}),"(",t,")"]},t)),!K&&e.jsx("span",{className:"auto-hint",children:a("automation.builder.dbColsLoading")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbColumnsHint")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEquals")}),e.jsx("input",{type:"text",value:de,maxLength:200,placeholder:a("automation.builder.dbEqualsPh"),onChange:t=>Be(t.target.value)})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbWhere")}),W.map((t,u)=>e.jsxs("div",{className:"auto-inline",children:[e.jsxs("select",{value:t.column,onChange:r=>ce(u,{column:r.target.value}),children:[e.jsx("option",{value:"",children:a(B?"automation.builder.dbPickCol":"automation.builder.dbColsLoading")}),(B??[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id)),t.column&&!(B??[]).some(r=>r.id===t.column)&&e.jsxs("option",{value:t.column,children:["(",t.column,")"]})]}),e.jsx("select",{value:t.op,onChange:r=>ce(u,{op:r.target.value}),children:pt.map(r=>e.jsx("option",{value:r,children:a(r==="eq"?"automation.builder.dbWhereOpEq":r==="ne"?"automation.builder.dbWhereOpNe":r==="empty"?"automation.builder.dbWhereOpEmpty":"automation.builder.dbWhereOpNotEmpty")},r))}),e.jsx("input",{type:"text",value:t.value,maxLength:200,disabled:t.op==="empty"||t.op==="notempty",placeholder:a("automation.builder.dbWhereValPh"),onChange:r=>ce(u,{value:r.target.value})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>ue(r=>r.filter((l,d)=>d!==u)),children:e.jsx(xe,{size:12})})]},u)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbWhereAdd"),disabled:W.length>=Fe,onClick:()=>ue(t=>[...t,{column:"",op:"eq",value:""}]),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbWhereHint")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbHint")})]}),s==="manual"&&e.jsx("div",{className:"auto-hint",children:a("automation.builder.manualHint")}),s==="timer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.timerMode")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:w==="daily_at"?"active":"",onClick:()=>A("daily_at"),children:a("automation.builder.timerDaily")}),e.jsx("button",{className:w==="at"?"active":"",onClick:()=>A("at"),children:a("automation.builder.timerOnce")}),e.jsx("button",{className:w==="every"?"active":"",onClick:()=>A("every"),children:a("automation.builder.timerEvery")})]})]}),w==="daily_at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.time")}),e.jsx("input",{type:"time",value:H,onChange:t=>X(t.target.value)})]}),w==="at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.datetime")}),e.jsx("input",{type:"datetime-local",value:Y,onChange:t=>Me(t.target.value)}),e.jsx("div",{className:"auto-hint",children:a(V?"automation.builder.expiredReset":"automation.builder.onceHint")})]}),w==="every"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.interval")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"number",value:Z,min:1,style:{width:90},onChange:t=>Ae(t.target.value)}),e.jsxs("select",{value:ve,onChange:t=>He(t.target.value),children:[e.jsx("option",{value:"m",children:a("automation.builder.unitM")}),e.jsx("option",{value:"h",children:a("automation.builder.unitH")}),e.jsx("option",{value:"d",children:a("automation.builder.unitD")})]})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.everyHint")})]})]}),s==="event_seen"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.match")}),e.jsx("input",{type:"text",list:"auto-event-catalog",value:se,maxLength:120,placeholder:a("automation.builder.matchPh"),onChange:t=>Le(t.target.value)}),e.jsxs("datalist",{id:"auto-event-catalog",children:[vt.map(t=>e.jsx("option",{value:t},t)),gt().map(t=>e.jsx("option",{value:t.name,label:t.label},t.name))]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.matchHint")})]}),s==="file_chars_gte"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.path")}),e.jsx("input",{type:"text",value:oe,placeholder:"~/Forsion/Notes/xxx.md",onChange:t=>Ve(t.target.value)})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.chars")}),e.jsx("input",{type:"number",value:re,min:1,onChange:t=>We(t.target.value)})]})]})]}),S.map((t,u)=>{const r=t.type==="tool_call"?f.find(l=>l.name===t.tool):void 0;return e.jsxs("div",{className:"auto-node",hidden:F!==String(t.key),children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:he(t.type)}),a("automation.builder.stepN",{n:String(u+1)})," · ",a(`automation.step.${t.type}`),e.jsxs("span",{className:"auto-step-tools",children:[e.jsx("button",{className:"icon-btn",disabled:u===0,title:a("automation.builder.moveUp"),onClick:()=>Ee(u,-1),children:e.jsx(jt,{size:12})}),e.jsx("button",{className:"icon-btn",disabled:u===S.length-1,title:a("automation.builder.moveDown"),onClick:()=>Ee(u,1),children:e.jsx(ft,{size:12})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>{te(l=>l.filter(d=>d.key!==t.key)),p("trigger")},children:e.jsx(xe,{size:12})})]})]}),t.type==="notify"&&e.jsxs(e.Fragment,{children:[e.jsx(ze,{label:a("automation.builder.notifyTitle"),value:t.title,maxLength:200,placeholder:a("automation.builder.notifyTitlePh"),onChange:l=>j(t.key,{title:l}),columns:K,hasRow:s==="db_changed"}),e.jsx(ze,{label:a("automation.builder.notifyBody"),value:t.body,multiline:!0,onChange:l=>j(t.key,{body:l}),columns:K,hasRow:s==="db_changed"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.notifyHint")})]}),t.type==="agent_run"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.runner")}),e.jsxs("select",{value:t.agentSlug,onChange:l=>j(t.key,{agentSlug:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.runnerPick")}),k.filter(l=>l.slug!=="muse").map(l=>e.jsx("option",{value:l.slug,children:l.name},l.slug))]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:t.prompt,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:l=>j(t.key,{prompt:l.target.value})})]})]}),(t.type==="db_row_add"||t.type==="db_row_edit")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:t.dbPath,onChange:l=>j(t.key,{dbPath:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(l=>e.jsx("option",{value:l,children:l},l)),t.dbPath&&!ee.includes(t.dbPath)&&e.jsx("option",{value:t.dbPath,children:t.dbPath})]})]}),t.type==="db_row_edit"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowId")}),e.jsx("input",{type:"text",value:t.rowId,placeholder:a(s==="db_changed"?"automation.builder.dbRowIdPh":"automation.builder.dbRowIdRequired"),onChange:l=>j(t.key,{rowId:l.target.value})})]}),t.type==="db_row_edit"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowFrom")}),e.jsx("input",{type:"text",value:t.rowFrom,maxLength:200,placeholder:a("automation.builder.dbRowFromPh"),onChange:l=>j(t.key,{rowFrom:l.target.value})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbMatch")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:t.matchColumn,maxLength:200,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:l=>j(t.key,{matchColumn:l.target.value})}),e.jsx("input",{type:"text",value:t.matchValue,maxLength:2e3,placeholder:a("automation.builder.dbMatchValPh"),onChange:l=>j(t.key,{matchValue:l.target.value})})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbTargetHint")})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbCells")}),t.cells.map((l,d)=>e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:l.k,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:z=>j(t.key,{cells:t.cells.map((N,D)=>D===d?{...N,k:z.target.value}:N)})}),e.jsx("input",{type:"text",value:l.v,placeholder:a(d===0?"automation.builder.dbCellValPh":"automation.builder.dbCellVal"),onChange:z=>j(t.key,{cells:t.cells.map((N,D)=>D===d?{...N,v:z.target.value}:N)})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),disabled:t.cells.length<=1,onClick:()=>j(t.key,{cells:t.cells.filter((z,N)=>N!==d)}),children:e.jsx(xe,{size:12})})]},d)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbCellAdd"),onClick:()=>j(t.key,{cells:[...t.cells,{k:"",v:""}]}),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbCellsHint")})]}),t.type==="db_row_add"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbSkipIfEmpty")}),e.jsx("input",{type:"text",value:t.skipIfEmpty,maxLength:200,placeholder:a("automation.builder.dbSkipIfEmptyPh"),onChange:l=>j(t.key,{skipIfEmpty:l.target.value})})]})]}),t.type==="tool_call"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.tool")}),e.jsxs("select",{value:t.tool,onChange:l=>{const d=f.find(N=>N.name===l.target.value),z=Object.fromEntries((d?.parameters.required||[]).filter(N=>d?.parameters.properties?.[N]?.type==="boolean").map(N=>[N,"false"]));j(t.key,{tool:l.target.value,argValues:z})},children:[e.jsx("option",{value:"",children:a("automation.builder.toolPick")}),f.map(l=>e.jsxs("option",{value:l.name,children:[l.name,l.dangerous?" ⚠":""]},l.name))]}),r&&e.jsxs("div",{className:"auto-hint",children:[r.description,r.dangerous?` · ${a("automation.builder.dangerous")}`:""]})]}),r&&Object.entries(r.parameters.properties||{}).map(([l,d])=>{const z=(r.parameters.required||[]).includes(l),N=`${l}${z?" *":""}`,D=t.argValues[l]||"",J=_=>j(t.key,{argValues:{...t.argValues,[l]:_}});return e.jsxs("div",{className:"field",children:[e.jsx("label",{title:d.description||"",children:N}),d.enum?.length?e.jsxs("select",{value:D,onChange:_=>J(_.target.value),children:[e.jsx("option",{value:""}),d.enum.map(_=>e.jsx("option",{value:_,children:_},_))]}):d.type==="boolean"?e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:D==="true",onChange:_=>J(_.target.checked?"true":"false")})," ",d.description||""]}):d.type==="number"?e.jsx("input",{type:"number",value:D,onChange:_=>J(_.target.value)}):d.type==="string"?e.jsx("textarea",{rows:2,value:D,placeholder:d.description||"",onChange:_=>J(_.target.value)}):e.jsx("textarea",{rows:2,value:D,placeholder:`JSON — ${d.description||""}`,onChange:_=>J(_.target.value)})]},l)})]})]},t.key)}),S.length===0&&i&&s!=="manual"&&e.jsxs("div",{className:"auto-node auto-node-muse",hidden:F!=="muse",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(qe,{size:14})}),a("automation.builder.museFallback")]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.museFallbackHint")}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:me,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:t=>Ke(t.target.value)})]})]}),e.jsxs("div",{className:"auto-node auto-review",hidden:F!=="review",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx(be,{size:16}),a("automation.ux.review")]}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.enableHint")}),e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:q,onChange:t=>M(t.target.checked)}),a("automation.ux.enabledLabel")]}),E.length?e.jsxs("div",{className:"auto-validation",role:"status",children:[e.jsx("strong",{children:a("automation.ux.checklist")}),E.map((t,u)=>e.jsx("button",{onClick:()=>p(t.node),children:t.text},u))]}):e.jsxs("p",{className:"auto-ready",children:[e.jsx(be,{size:14}),a("automation.ux.allReady")]}),s!=="timer"&&s!=="manual"&&e.jsxs("div",{className:"auto-guard",children:[e.jsx("label",{children:a("automation.builder.cooldown")}),e.jsx("input",{type:"number",value:U,min:Se?1:s==="db_changed"?0:.25,step:"1",onChange:t=>{Ce.current=!0,_e(t.target.value)}}),e.jsx("span",{className:"auto-hint",children:a(Se?"automation.builder.cooldownAgentHint":s==="db_changed"?"automation.builder.cooldownDbHint":"automation.builder.cooldownHint")})]})]}),e.jsxs("div",{className:"auto-node",hidden:F!=="help",children:[e.jsx("h3",{children:a("automation.ux.flow")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.canvasOrder")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.nativeHint")})]})]})]}),e.jsxs("div",{className:"auto-builder-actions auto-builder-footer",children:[e.jsx("div",{className:"auto-save-status","aria-live":"polite",children:we?e.jsx("span",{role:"alert",children:we}):E.length?e.jsxs("button",{onClick:()=>p(E[0].node),children:[E[0].text,E.length>1?` (+${E.length-1})`:""]}):e.jsx("span",{children:a("automation.ux.allReady")})}),e.jsx("button",{className:"btn ghost sm",onClick:()=>p("review"),children:a("automation.ux.review")}),e.jsx("button",{className:"btn sm",disabled:!ne||G,onClick:()=>{Ge()},children:G?"…":a(q?"automation.ux.saveEnabled":"automation.ux.savePaused")})]})]})},oa=Object.freeze(Object.defineProperty({__proto__:null,AutomationBuilder:Jt,hasUnsupportedParts:Ie},Symbol.toStringTag,{value:"Module"}));export{Wt as A,Vt as B,sa as S,Jt as a,oa as b};
1
+ import{d as o,j as e,u as pe}from"./index-BM2o7PeV.js";import{F as Ye,bp as Qe,qK as le,fA as Ze,kp as et,aJ as tt,dD as at,fN as nt,fJ as it,hD as lt,hy as st,gM as ot,hG as rt,qL as dt,h as ut,b as ct,fn as ie,aS as mt,qM as ht,qN as $e,qO as Te,qP as Fe,a2 as qe,K as Re,hA as be,aq as bt,aK as xt,qQ as pt,bJ as xe,qR as vt,qS as gt,bH as jt,bI as ft,G as yt,J as Nt,_ as _t,gG as Ct,qT as kt,qU as wt,s as St,qV as Et,qW as Pt,u as $t}from"./appStore-DWP8UET9.js";import{C as Ft}from"./CapabilityMenu-SwVlZ06x.js";import{u as qt}from"./gestures-DQBCcK4y.js";import{a as Rt,C as Dt}from"./Chrome-HdfyYV3i.js";import{d as At,e as Mt,f as Tt,g as zt}from"./canvasPrefs-8taQ42Cz.js";import{R as It}from"./rotate-ccw-BvipPIjC.js";import"./messages-_jta1lSI.js";import{W as De}from"./workflow-DPoG4QE2.js";import{C as Ht}from"./circle-question-mark-XbAFplz1.js";const Vt=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Wt=Ye("bell",Vt);function Lt({controller:i,open:c,title:b,onClose:C,children:h}){const[g]=o.useState(()=>document.createElement("div"));g.className="auto-extension";const a=o.useRef(null),k=o.useRef(C);k.current=C;const v=o.useRef(b);return v.current=b,o.useEffect(()=>{if(!(!i||!c)){try{a.current=i.open({id:"automation-context",title:()=>v.current,mount:f=>(f.appendChild(g),()=>g.remove()),onClose:()=>k.current()})}catch{k.current()}return()=>{a.current?.close(),a.current=null}}},[i,c,g]),c?i?Qe.createPortal(h,g):e.jsx("div",{className:"auto-extension auto-extension-inline",children:h}):null}const sa=["reminder","briefing","table","button"];function Ot(i,c){return i?i==="briefing"||i==="button"?[{...le("agent_run"),prompt:c(`automation.ux.${i}.prompt`)}]:[{...le("notify"),title:c(`automation.ux.${i}.name`),body:c(`automation.ux.${i}.body`)}]:[le("notify")]}function Ae(i,c,b){if(i.type==="notify")return i.title.trim()?null:"notify";if(i.type==="agent_run")return i.agentSlug?i.prompt.trim()?null:"prompt":"agent";if(i.type==="db_row_add"||i.type==="db_row_edit"){if(!/\.db$/i.test(i.dbPath.trim()))return"table";if(!i.cells.some(h=>h.k.trim()))return"cells";if(i.type==="db_row_edit"){if(c!=="db_changed"&&(!i.rowId.trim()&&!i.matchColumn.trim()||i.rowFrom.trim()))return"row";if(i.matchColumn.trim()&&!i.matchValue.trim())return"match"}return null}const C=b.find(h=>h.name===i.tool);if(!C)return"tool";if((C.parameters.required||[]).some(h=>!(i.argValues[h]||"").trim()))return"args";for(const[h,g]of Object.entries(i.argValues)){if(!g.trim())continue;const a=C.parameters.properties?.[h];if(a?.type==="number"&&!Number.isFinite(Number(g)))return"args";if(a?.type==="object"||a?.type==="array")try{const k=JSON.parse(g);if(a.type==="array"?!Array.isArray(k):!k||typeof k!="object"||Array.isArray(k))return"json"}catch{return"json"}}return null}function Bt(i){return(i||[]).map(c=>({value:`{{row.${c.id}}}`,label:c.name}))}const Ut=i=>({x:0,y:i*132,w:244,h:84}),Kt=({nodes:i,selected:c,onSelect:b,children:C})=>{const{t:h}=pe(),g=o.useId().replace(/:/g,""),a=o.useRef(null),[k,v]=o.useState({}),[f,$]=o.useState(At),[T,F]=o.useState(Mt),x=Ze(a),m=new Map(i.map((n,s)=>[n.id,k[n.id]||Ut(s)])),P=i.map(n=>n.id).join(","),p=qt(a,x,{boxes:()=>m,identity:()=>P,commit:n=>v(s=>({...s,...Object.fromEntries(n)})),hitKey:n=>n.closest("[data-flow-node]")?.dataset.flowNode||null,onEnterEdit:b,onDoubleClick:n=>{n&&b(n)},minW:244,minH:84,repel:!0},f);o.useEffect(()=>p.bind(a.current),[p.bind]),o.useEffect(()=>x.bindWheel(a.current),[x.bindWheel]);const R=o.useRef(()=>x.fitTo([...m.values()],64));R.current=()=>x.fitTo([...m.values()],64),o.useEffect(()=>{v({});const n=requestAnimationFrame(()=>R.current());return()=>cancelAnimationFrame(n)},[P]),o.useEffect(()=>{const n=new ResizeObserver(()=>R.current());return a.current&&n.observe(a.current),()=>n.disconnect()},[]);const z=n=>p.live?.get(n)||m.get(n);return e.jsx("div",{className:"auto-canvas-shell am-app",children:e.jsxs("div",{className:"auto-canvas amx-stage",ref:a,tabIndex:0,"aria-label":h("automation.ux.flow"),onPointerUpCapture:n=>{if(p.busy)return;const s=document.elementFromPoint(n.clientX,n.clientY)?.closest("[data-flow-node]");s&&a.current?.contains(s)&&b(s.dataset.flowNode)},children:[e.jsx("div",{className:"amx-stage-grid",style:et(x.vp)}),e.jsxs("div",{className:"auto-canvas-world",style:{transform:`translate(${x.vp.x}px, ${x.vp.y}px) scale(${x.vp.z})`},children:[e.jsxs("svg",{className:"auto-canvas-edges","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsx("marker",{id:g,markerWidth:"8",markerHeight:"8",refX:"6",refY:"3",orient:"auto",children:e.jsx("path",{d:"M0,0 L6,3 L0,6",fill:"none",stroke:"currentColor"})})}),i.slice(1).map((n,s)=>{const y=z(i[s].id),w=z(n.id),I=y.x+y.w/2,H=y.y+y.h,X=w.x+w.w/2,W=w.y;return e.jsx("path",{d:`M${I},${H} C${I},${H+28} ${X},${W-28} ${X},${W}`,markerEnd:`url(#${g})`},n.id)})]}),i.map(n=>{const s=z(n.id);return e.jsxs("div",{"data-flow-node":n.id,role:"button",tabIndex:0,"aria-pressed":c===n.id,className:`auto-flow-node ${c===n.id?"selected":""}`,style:{left:s.x,top:s.y,width:s.w,height:s.h},onClick:()=>b(n.id),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),b(n.id))},children:[e.jsx("span",{className:"auto-flow-icon",children:n.icon}),e.jsx("strong",{children:n.title}),e.jsx("span",{className:"auto-flow-status",title:h(n.ready?"automation.ux.ready":"automation.ux.incomplete"),children:n.ready?e.jsx(tt,{size:13}):e.jsx(at,{size:13})}),e.jsx("span",{className:"auto-flow-subtitle",children:n.subtitle})]},n.id)}),p.marquee&&e.jsx("div",{className:"amx-stage-marquee",style:{left:p.marquee.x,top:p.marquee.y,width:p.marquee.w,height:p.marquee.h}})]}),C&&e.jsx("div",{className:"amx-stage-tools auto-canvas-tools",children:C}),e.jsx(Rt,{zoom:x.vp.z,onZoomBy:n=>{const{w:s,h:y}=nt(a.current);x.setVp(it(x.vp,x.vp.z*n,s/2,y/2))},onFit:()=>R.current(),snap:f,onSnap:n=>{$(n),zt(n)},mini:T,onMini:n=>{F(n),Tt(n)},extra:e.jsx("button",{type:"button",title:h("automation.ux.arrange"),onClick:()=>{v({}),requestAnimationFrame(()=>R.current())},children:e.jsx(It,{size:12})})}),T&&e.jsx(Dt,{hostRef:a,vp:x.vp,items:i.map(n=>({key:n.id,kind:"card",box:z(n.id)})),onCenter:x.centerOn})]})})},Me=({label:i,value:c,onChange:b,multiline:C,maxLength:h=4e3,placeholder:g,columns:a,hasRow:k})=>{const{t:v}=pe(),f=o.useId(),$=o.useRef(null),T=o.useRef({start:c.length,end:c.length}),F=m=>{if(!m)return;const{start:P,end:p}=T.current;c.length-(p-P)+m.length>h||(b(c.slice(0,P)+m+c.slice(p)),requestAnimationFrame(()=>{$.current?.focus(),$.current?.setSelectionRange(P+m.length,P+m.length)}))},x={id:f,ref:$,value:c,maxLength:h,placeholder:g,onChange:m=>b(m.target.value),onSelect:m=>{T.current={start:m.currentTarget.selectionStart??c.length,end:m.currentTarget.selectionEnd??c.length}}};return e.jsxs("div",{className:"field auto-template-field",children:[e.jsxs("div",{className:"auto-field-heading",children:[e.jsx("label",{htmlFor:f,children:i}),e.jsxs("select",{"aria-label":v("automation.ux.insertVariable",{field:i}),value:"",onChange:m=>F(m.target.value),children:[e.jsx("option",{value:"",children:v("automation.ux.variables")}),e.jsx("option",{value:"{{today}}",children:v("automation.ux.today")}),e.jsx("option",{value:"{{now}}",children:v("automation.ux.now")}),k&&e.jsxs("optgroup",{label:v("automation.ux.triggerRow"),children:[e.jsx("option",{value:"{{row.id}}",children:v("automation.ux.rowId")}),Bt(a).map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))]})]})]}),C?e.jsx("textarea",{...x}):e.jsx("input",{type:"text",...x})]})};function Gt(){const i=new Date(Date.now()+36e5);i.setMinutes(0,0,0);const c=b=>String(b).padStart(2,"0");return`${i.getFullYear()}-${c(i.getMonth()+1)}-${c(i.getDate())}T${c(i.getHours())}:00`}const Jt=({editing:i,starter:c,fixedManual:b,onSaved:C,onCancel:h,extendView:g})=>{const{t:a}=pe(),k=lt(),v=st(),f=v.actionsCatalog,[$,T]=o.useState(i?.desc||(c?a(`automation.ux.${c}.name`):"")),[F,x]=o.useState("trigger"),[m,P]=o.useState(!1),p=t=>{x(t),P(!0)},[R,z]=o.useState(i?.enabled??!!b),n=i?.cond,[s,y]=o.useState(n?n.type==="event_seen"?"event_seen":n.type==="file_chars_gte"?"file_chars_gte":n.type==="manual"?"manual":n.type==="db_changed"?"db_changed":"timer":b||c==="button"?"manual":c==="table"?"db_changed":"timer"),[w,I]=o.useState(n?.type==="at"?"at":n?.type==="every"?"every":"daily_at"),[H,X]=o.useState(n?.type==="daily_at"?n.time:"09:00"),W=!!i&&ot(i),[Y,ze]=o.useState(n?.type==="at"&&!W?n.datetime.replace(" ","T"):Gt()),Q=n?.type==="every"?/^(\d+)([mhd])$/.exec(n.interval):null,[Z,Ie]=o.useState(Q?Q[1]:"1"),[ve,He]=o.useState(Q?Q[2]:"h"),[se,Ve]=o.useState(n?.type==="event_seen"?n.match:""),[oe,We]=o.useState(n?.type==="file_chars_gte"?n.path:""),[re,Le]=o.useState(n?.type==="file_chars_gte"?String(n.n):"100"),[q,Oe]=o.useState(n?.type==="db_changed"?n.path:""),[A,ge]=o.useState(n?.type==="db_changed"?n.event:"row_added"),[V,je]=o.useState(()=>rt(n)),fe=(t,u)=>je(r=>u?r.includes(t)?r:[...r,t]:r.filter(l=>l!==t)),[de,Be]=o.useState(n?.type==="db_changed"&&n.equals||""),[L,ue]=o.useState(()=>dt(n)),ce=(t,u)=>ue(r=>r.map((l,d)=>d===t?{...l,...u}:l));o.useEffect(()=>{ut()},[]);const ye=ct(t=>t.files),O=o.useMemo(()=>ye.filter(t=>/\.db$/i.test(t)),[ye]);o.useEffect(()=>{for(const t of O)ie.getState().load(t,t)},[O]);const Ne=ie(mt(t=>O.filter(u=>t.entries[u]?.data?.source!==void 0))),ee=o.useMemo(()=>O.filter(t=>!Ne.includes(t)),[O,Ne]),B=ie(t=>s==="db_changed"&&q?t.entries[q]?.data?.columns:void 0),U=o.useMemo(()=>B?.filter(t=>t.type!=="formula"&&t.type!=="lookup"),[B]),[S,te]=o.useState(()=>i?ht(i):Ot(c,a)),[me,Ue]=o.useState(i&&!i.actions?.length&&!i.agentSlug&&i.prompt||""),[K,_e]=o.useState(()=>$e(i,s)),Ce=o.useRef(!1);o.useEffect(()=>{!i&&!Ce.current&&_e($e(null,s))},[s,i]);const[G,ke]=o.useState(!1),[we,ae]=o.useState(""),Ke=t=>{if(S.length>=24)return;const u=le(t);te(r=>[...r,u]),p(String(u.key))},Se=S.some(t=>t.type==="agent_run"),j=(t,u)=>te(r=>r.map(l=>l.key===t?{...l,...u}:l)),Ee=(t,u)=>te(r=>{const l=t+u;if(l<0||l>=r.length)return r;const d=[...r];return[d[t],d[l]]=[d[l],d[t]],d});if(Te(i))return e.jsxs("div",{className:"auto-builder",children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(De,{size:17})," ",a("automation.builder.editTitle")]}),e.jsx("div",{className:"auto-node",children:e.jsx("div",{className:"auto-hint",children:a("automation.builder.unsupported")})}),e.jsx("div",{className:"auto-builder-actions",children:e.jsx("button",{className:"btn ghost",onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})})]});const Pe=!(s==="timer"&&(w==="daily_at"&&!/^\d{1,2}:\d{2}$/.test(H)||w==="at"&&!Y||w==="every"&&(!Number.isInteger(Number(Z))||Number(Z)<1))||s==="event_seen"&&!se.trim()||s==="file_chars_gte"&&(!oe.trim()||!(Number(re)>0))||s==="db_changed"&&(!/\.db$/i.test(q.trim())||A==="cell_changed"&&!V.length||L.length>Fe||L.some(t=>t.column.trim()&&(t.op==="eq"||t.op==="ne")&&!t.value.trim()))),E=[];$.trim()||E.push({node:"trigger",text:a("automation.ux.issue.name")}),Pe||E.push({node:"trigger",text:a("automation.ux.issue.trigger")}),!S.length&&(!i||s==="manual")&&E.push({node:"review",text:a("automation.ux.issue.steps")}),S.forEach((t,u)=>{const r=Ae(t,s,f);r&&E.push({node:String(t.key),text:`${u+1}. ${a(`automation.ux.issue.${r}`)}`})}),s!=="timer"&&s!=="manual"&&(!K.trim()||!Number.isFinite(Number(K))||Number(K)<0)&&E.push({node:"review",text:a("automation.ux.issue.cooldown")});const ne=E.length===0,Ge=async()=>{if(!ne||G)return;const t=s==="timer"?w:s;if(t==="at"&&(Ct(Y)?.getTime()??0)<Date.now()-5*6e4){ae(a("automation.builder.atPast"));return}const u=d=>ie.getState().entries[d]?.data?.source!==void 0;if([...t==="db_changed"?[q.trim()]:[],...S.filter(d=>d.type==="db_row_add"||d.type==="db_row_edit").map(d=>d.dbPath.trim())].filter(Boolean).some(u)){ae(a("automation.builder.dbNoteView"));return}ke(!0),ae("");const l=kt(S,f);try{const d=await wt(St(),{id:i?.id,actor:"user",desc:$.trim(),cond_type:t,time:t==="daily_at"?H:void 0,datetime:t==="at"?Y:void 0,interval:t==="every"?`${Math.floor(Number(Z))}${ve}`:void 0,match:t==="event_seen"?se.trim():void 0,path:t==="file_chars_gte"?oe.trim():t==="db_changed"?q.trim():void 0,n:t==="file_chars_gte"?Number(re):void 0,event:t==="db_changed"?A:void 0,column_id:t==="db_changed"&&A==="cell_changed"?V[0]:void 0,column_ids:t==="db_changed"&&A==="cell_changed"&&V.length>1?V:void 0,equals:t==="db_changed"&&A==="cell_changed"&&de.trim()?de.trim():void 0,where:t==="db_changed"?Pt(L):void 0,vault:t==="db_changed"&&i?.cond.type==="db_changed"?i.cond.vault:void 0,prompt:S.length?void 0:me.trim()||void 0,cooldown_hours:Et(s,K),actions:S.length?l:null,enabled:R});if(C){v.bump(),C(d);return}v.acceptSaved(d),$t.getState().toast(a("automation.ux.saved"))}catch(d){ae(String(d?.message||d))}finally{ke(!1)}},he=t=>t==="notify"?e.jsx(Wt,{size:14}):t==="agent_run"?e.jsx(yt,{size:14}):t==="db_row_add"||t==="db_row_edit"?e.jsx(Nt,{size:14}):e.jsx(_t,{size:14}),Je=[{id:"trigger",title:a("automation.builder.trigger"),subtitle:a(`automation.builder.${s==="timer"?"condTimer":s==="manual"?"condManual":s==="db_changed"?"condDb":s==="event_seen"?"condEvent":"condFile"}`),icon:e.jsx(qe,{size:17}),ready:Pe&&!!$.trim()},...S.map((t,u)=>({id:String(t.key),title:`${u+1}. ${a(`automation.step.${t.type}`)}`,subtitle:t.title||t.prompt||t.dbPath||t.tool||a("automation.ux.setupHint"),icon:he(t.type),ready:!Ae(t,s,f)})),...!S.length&&i&&s!=="manual"?[{id:"muse",title:a("automation.builder.museFallback"),subtitle:me||a("automation.builder.museFallbackHint"),icon:e.jsx(Re,{size:17}),ready:!0}]:[],{id:"review",title:a("automation.ux.finish"),subtitle:a(ne?"automation.ux.allReady":"automation.ux.finishHint"),icon:e.jsx(be,{size:17}),ready:ne}],Xe=e.jsxs(e.Fragment,{children:[e.jsxs(Ft,{label:a("automation.ux.addStep"),className:"btn ghost sm",disabled:G||S.length>=24,items:["notify","agent_run","db_row_add","db_row_edit","tool_call"].map(t=>({id:t,label:a(`automation.step.${t}`),icon:he(t),disabled:t==="tool_call"&&!f.length,onSelect:()=>Ke(t)})),children:[e.jsx(bt,{size:14}),a("automation.ux.addStep")]}),e.jsx("button",{className:"icon-btn",title:a("automation.ux.help"),onClick:()=>p("help"),children:e.jsx(Ht,{size:15})})]});return e.jsxs("div",{className:`auto-builder auto-workflow-builder ${b?"auto-builder-embedded":""}`,children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(De,{size:17}),e.jsx("span",{children:a(i?"automation.builder.editTitle":"automation.builder.title")}),e.jsx("button",{className:"btn ghost sm",disabled:G,onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})]}),e.jsx("div",{className:"auto-builder-workspace",hidden:!g&&m,children:e.jsx(Kt,{nodes:Je,selected:m?F:"",onSelect:p,children:Xe})}),e.jsxs(Lt,{controller:g,open:m,title:a("automation.ux.setup"),onClose:()=>P(!1),children:[!g&&e.jsxs("button",{className:"btn ghost sm auto-inline-back",onClick:()=>P(!1),children:[e.jsx(xt,{size:14}),a("automation.ux.flow")]}),e.jsxs("div",{className:"auto-inspector","aria-label":a("automation.ux.setup"),children:[e.jsxs("div",{className:"auto-node",hidden:F!=="trigger",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(qe,{size:14})}),a("automation.builder.trigger")]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.desc")}),e.jsx("input",{"aria-label":a("automation.builder.desc"),type:"text",value:$,maxLength:200,placeholder:a("automation.builder.descPh"),onChange:t=>T(t.target.value)})]}),!b&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.condType")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:s==="timer"?"active":"",onClick:()=>y("timer"),children:a("automation.builder.condTimer")}),e.jsx("button",{className:s==="event_seen"?"active":"",onClick:()=>y("event_seen"),children:a("automation.builder.condEvent")}),e.jsx("button",{className:s==="file_chars_gte"?"active":"",onClick:()=>y("file_chars_gte"),children:a("automation.builder.condFile")}),e.jsx("button",{className:s==="db_changed"?"active":"",onClick:()=>y("db_changed"),children:a("automation.builder.condDb")}),e.jsx("button",{className:s==="manual"?"active":"",onClick:()=>y("manual"),children:a("automation.builder.condManual")})]})]}),s==="db_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:q,onChange:t=>{Oe(t.target.value),je([])},children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(t=>e.jsx("option",{value:t,children:t},t)),q&&!ee.includes(q)&&e.jsx("option",{value:q,children:q})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEvent")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:A==="row_added"?"active":"",onClick:()=>ge("row_added"),children:a("automation.builder.dbEventRow")}),e.jsx("button",{className:A==="cell_changed"?"active":"",onClick:()=>ge("cell_changed"),children:a("automation.builder.dbEventCell")})]})]}),A==="cell_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbColumn")}),e.jsxs("div",{className:"auto-checks",children:[(U??[]).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:V.includes(t.id),onChange:u=>fe(t.id,u.target.checked)}),t.name]},t.id)),V.filter(t=>!(U??[]).some(u=>u.id===t)).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:!0,onChange:()=>fe(t,!1)}),"(",t,")"]},t)),!U&&e.jsx("span",{className:"auto-hint",children:a("automation.builder.dbColsLoading")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbColumnsHint")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEquals")}),e.jsx("input",{type:"text",value:de,maxLength:200,placeholder:a("automation.builder.dbEqualsPh"),onChange:t=>Be(t.target.value)})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbWhere")}),L.map((t,u)=>e.jsxs("div",{className:"auto-inline",children:[e.jsxs("select",{value:t.column,onChange:r=>ce(u,{column:r.target.value}),children:[e.jsx("option",{value:"",children:a(B?"automation.builder.dbPickCol":"automation.builder.dbColsLoading")}),(B??[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id)),t.column&&!(B??[]).some(r=>r.id===t.column)&&e.jsxs("option",{value:t.column,children:["(",t.column,")"]})]}),e.jsx("select",{value:t.op,onChange:r=>ce(u,{op:r.target.value}),children:pt.map(r=>e.jsx("option",{value:r,children:a(r==="eq"?"automation.builder.dbWhereOpEq":r==="ne"?"automation.builder.dbWhereOpNe":r==="empty"?"automation.builder.dbWhereOpEmpty":"automation.builder.dbWhereOpNotEmpty")},r))}),e.jsx("input",{type:"text",value:t.value,maxLength:200,disabled:t.op==="empty"||t.op==="notempty",placeholder:a("automation.builder.dbWhereValPh"),onChange:r=>ce(u,{value:r.target.value})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>ue(r=>r.filter((l,d)=>d!==u)),children:e.jsx(xe,{size:12})})]},u)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbWhereAdd"),disabled:L.length>=Fe,onClick:()=>ue(t=>[...t,{column:"",op:"eq",value:""}]),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbWhereHint")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbHint")})]}),s==="manual"&&e.jsx("div",{className:"auto-hint",children:a("automation.builder.manualHint")}),s==="timer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.timerMode")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:w==="daily_at"?"active":"",onClick:()=>I("daily_at"),children:a("automation.builder.timerDaily")}),e.jsx("button",{className:w==="at"?"active":"",onClick:()=>I("at"),children:a("automation.builder.timerOnce")}),e.jsx("button",{className:w==="every"?"active":"",onClick:()=>I("every"),children:a("automation.builder.timerEvery")})]})]}),w==="daily_at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.time")}),e.jsx("input",{type:"time",value:H,onChange:t=>X(t.target.value)})]}),w==="at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.datetime")}),e.jsx("input",{type:"datetime-local",value:Y,onChange:t=>ze(t.target.value)}),e.jsx("div",{className:"auto-hint",children:a(W?"automation.builder.expiredReset":"automation.builder.onceHint")})]}),w==="every"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.interval")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"number",value:Z,min:1,style:{width:90},onChange:t=>Ie(t.target.value)}),e.jsxs("select",{value:ve,onChange:t=>He(t.target.value),children:[e.jsx("option",{value:"m",children:a("automation.builder.unitM")}),e.jsx("option",{value:"h",children:a("automation.builder.unitH")}),e.jsx("option",{value:"d",children:a("automation.builder.unitD")})]})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.everyHint")})]})]}),s==="event_seen"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.match")}),e.jsx("input",{type:"text",list:"auto-event-catalog",value:se,maxLength:120,placeholder:a("automation.builder.matchPh"),onChange:t=>Ve(t.target.value)}),e.jsxs("datalist",{id:"auto-event-catalog",children:[vt.map(t=>e.jsx("option",{value:t},t)),gt().map(t=>e.jsx("option",{value:t.name,label:t.label},t.name))]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.matchHint")})]}),s==="file_chars_gte"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.path")}),e.jsx("input",{type:"text",value:oe,placeholder:"~/Forsion/Notes/xxx.md",onChange:t=>We(t.target.value)})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.chars")}),e.jsx("input",{type:"number",value:re,min:1,onChange:t=>Le(t.target.value)})]})]})]}),S.map((t,u)=>{const r=t.type==="tool_call"?f.find(l=>l.name===t.tool):void 0;return e.jsxs("div",{className:"auto-node",hidden:F!==String(t.key),children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:he(t.type)}),a("automation.builder.stepN",{n:String(u+1)})," · ",a(`automation.step.${t.type}`),e.jsxs("span",{className:"auto-step-tools",children:[e.jsx("button",{className:"icon-btn",disabled:u===0,title:a("automation.builder.moveUp"),onClick:()=>Ee(u,-1),children:e.jsx(jt,{size:12})}),e.jsx("button",{className:"icon-btn",disabled:u===S.length-1,title:a("automation.builder.moveDown"),onClick:()=>Ee(u,1),children:e.jsx(ft,{size:12})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>{te(l=>l.filter(d=>d.key!==t.key)),p("trigger")},children:e.jsx(xe,{size:12})})]})]}),t.type==="notify"&&e.jsxs(e.Fragment,{children:[e.jsx(Me,{label:a("automation.builder.notifyTitle"),value:t.title,maxLength:200,placeholder:a("automation.builder.notifyTitlePh"),onChange:l=>j(t.key,{title:l}),columns:U,hasRow:s==="db_changed"}),e.jsx(Me,{label:a("automation.builder.notifyBody"),value:t.body,multiline:!0,onChange:l=>j(t.key,{body:l}),columns:U,hasRow:s==="db_changed"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.notifyHint")})]}),t.type==="agent_run"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.runner")}),e.jsxs("select",{value:t.agentSlug,onChange:l=>j(t.key,{agentSlug:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.runnerPick")}),k.filter(l=>l.slug!=="muse").map(l=>e.jsx("option",{value:l.slug,children:l.name},l.slug))]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:t.prompt,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:l=>j(t.key,{prompt:l.target.value})})]})]}),(t.type==="db_row_add"||t.type==="db_row_edit")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:t.dbPath,onChange:l=>j(t.key,{dbPath:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(l=>e.jsx("option",{value:l,children:l},l)),t.dbPath&&!ee.includes(t.dbPath)&&e.jsx("option",{value:t.dbPath,children:t.dbPath})]})]}),t.type==="db_row_edit"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowId")}),e.jsx("input",{type:"text",value:t.rowId,placeholder:a(s==="db_changed"?"automation.builder.dbRowIdPh":"automation.builder.dbRowIdRequired"),onChange:l=>j(t.key,{rowId:l.target.value})})]}),t.type==="db_row_edit"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowFrom")}),e.jsx("input",{type:"text",value:t.rowFrom,maxLength:200,placeholder:a("automation.builder.dbRowFromPh"),onChange:l=>j(t.key,{rowFrom:l.target.value})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbMatch")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:t.matchColumn,maxLength:200,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:l=>j(t.key,{matchColumn:l.target.value})}),e.jsx("input",{type:"text",value:t.matchValue,maxLength:2e3,placeholder:a("automation.builder.dbMatchValPh"),onChange:l=>j(t.key,{matchValue:l.target.value})})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbTargetHint")})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbCells")}),t.cells.map((l,d)=>e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:l.k,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:M=>j(t.key,{cells:t.cells.map((N,D)=>D===d?{...N,k:M.target.value}:N)})}),e.jsx("input",{type:"text",value:l.v,placeholder:a(d===0?"automation.builder.dbCellValPh":"automation.builder.dbCellVal"),onChange:M=>j(t.key,{cells:t.cells.map((N,D)=>D===d?{...N,v:M.target.value}:N)})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),disabled:t.cells.length<=1,onClick:()=>j(t.key,{cells:t.cells.filter((M,N)=>N!==d)}),children:e.jsx(xe,{size:12})})]},d)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbCellAdd"),onClick:()=>j(t.key,{cells:[...t.cells,{k:"",v:""}]}),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbCellsHint")})]}),t.type==="db_row_add"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbSkipIfEmpty")}),e.jsx("input",{type:"text",value:t.skipIfEmpty,maxLength:200,placeholder:a("automation.builder.dbSkipIfEmptyPh"),onChange:l=>j(t.key,{skipIfEmpty:l.target.value})})]})]}),t.type==="tool_call"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.tool")}),e.jsxs("select",{value:t.tool,onChange:l=>{const d=f.find(N=>N.name===l.target.value),M=Object.fromEntries((d?.parameters.required||[]).filter(N=>d?.parameters.properties?.[N]?.type==="boolean").map(N=>[N,"false"]));j(t.key,{tool:l.target.value,argValues:M})},children:[e.jsx("option",{value:"",children:a("automation.builder.toolPick")}),f.map(l=>e.jsxs("option",{value:l.name,children:[l.name,l.dangerous?" ⚠":""]},l.name))]}),r&&e.jsxs("div",{className:"auto-hint",children:[r.description,r.dangerous?` · ${a("automation.builder.dangerous")}`:""]})]}),r&&Object.entries(r.parameters.properties||{}).map(([l,d])=>{const M=(r.parameters.required||[]).includes(l),N=`${l}${M?" *":""}`,D=t.argValues[l]||"",J=_=>j(t.key,{argValues:{...t.argValues,[l]:_}});return e.jsxs("div",{className:"field",children:[e.jsx("label",{title:d.description||"",children:N}),d.enum?.length?e.jsxs("select",{value:D,onChange:_=>J(_.target.value),children:[e.jsx("option",{value:""}),d.enum.map(_=>e.jsx("option",{value:_,children:_},_))]}):d.type==="boolean"?e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:D==="true",onChange:_=>J(_.target.checked?"true":"false")})," ",d.description||""]}):d.type==="number"?e.jsx("input",{type:"number",value:D,onChange:_=>J(_.target.value)}):d.type==="string"?e.jsx("textarea",{rows:2,value:D,placeholder:d.description||"",onChange:_=>J(_.target.value)}):e.jsx("textarea",{rows:2,value:D,placeholder:`JSON — ${d.description||""}`,onChange:_=>J(_.target.value)})]},l)})]})]},t.key)}),S.length===0&&i&&s!=="manual"&&e.jsxs("div",{className:"auto-node auto-node-muse",hidden:F!=="muse",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(Re,{size:14})}),a("automation.builder.museFallback")]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.museFallbackHint")}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:me,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:t=>Ue(t.target.value)})]})]}),e.jsxs("div",{className:"auto-node auto-review",hidden:F!=="review",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx(be,{size:16}),a("automation.ux.review")]}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.enableHint")}),e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:R,onChange:t=>z(t.target.checked)}),a("automation.ux.enabledLabel")]}),E.length?e.jsxs("div",{className:"auto-validation",role:"status",children:[e.jsx("strong",{children:a("automation.ux.checklist")}),E.map((t,u)=>e.jsx("button",{onClick:()=>p(t.node),children:t.text},u))]}):e.jsxs("p",{className:"auto-ready",children:[e.jsx(be,{size:14}),a("automation.ux.allReady")]}),s!=="timer"&&s!=="manual"&&e.jsxs("div",{className:"auto-guard",children:[e.jsx("label",{children:a("automation.builder.cooldown")}),e.jsx("input",{type:"number",value:K,min:Se?1:s==="db_changed"?0:.25,step:"1",onChange:t=>{Ce.current=!0,_e(t.target.value)}}),e.jsx("span",{className:"auto-hint",children:a(Se?"automation.builder.cooldownAgentHint":s==="db_changed"?"automation.builder.cooldownDbHint":"automation.builder.cooldownHint")})]})]}),e.jsxs("div",{className:"auto-node",hidden:F!=="help",children:[e.jsx("h3",{children:a("automation.ux.flow")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.canvasOrder")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.nativeHint")})]})]})]}),e.jsxs("div",{className:"auto-builder-actions auto-builder-footer",children:[e.jsx("div",{className:"auto-save-status","aria-live":"polite",children:we?e.jsx("span",{role:"alert",children:we}):E.length?e.jsxs("button",{onClick:()=>p(E[0].node),children:[E[0].text,E.length>1?` (+${E.length-1})`:""]}):e.jsx("span",{children:a("automation.ux.allReady")})}),e.jsx("button",{className:"btn ghost sm",onClick:()=>p("review"),children:a("automation.ux.review")}),e.jsx("button",{className:"btn sm",disabled:!ne||G,onClick:()=>{Ge()},children:G?"…":a(R?"automation.ux.saveEnabled":"automation.ux.savePaused")})]})]})},oa=Object.freeze(Object.defineProperty({__proto__:null,AutomationBuilder:Jt,hasUnsupportedParts:Te},Symbol.toStringTag,{value:"Module"}));export{Lt as A,Wt as B,sa as S,Jt as a,oa as b};
@@ -1 +1 @@
1
- import{j as a,u as q,d,r as la}from"./index-Bh_nLVTc.js";import{p as oa,bl as ra,j2 as ia,i_ as J,j4 as ma,j6 as da,iU as ua,jP as fa,jb as F,jm as ha,j7 as pa,b as _,iV as ga,iW as xa,iX as ba,iY as ja,jQ as j,iZ as D,jg as va,je as Ca,jd as Na,G as wa,W as X,J as $,ap as Da,ar as aa,ah as Q,fJ as H,f5 as Sa,jR as ea,jS as za,jT as Z,jU as K,jV as Ma,fl as ka,jW as ya,jX as Aa,R as Pa,jY as Fa}from"./appStore-B1ynyt42.js";import"./client-DxGbwZLy.js";import{A as qa}from"./astryxBridge-CU_kQTEl.js";import{u as O}from"./calendarNavStore-DGvUlU5N.js";import{C as Ea}from"./CapabilityMenu-kx1TIJYN.js";import{H as Ia}from"./hard-drive-BQsHSala.js";import{S as Ta}from"./star-CgYon3z4.js";import{C as Ra}from"./CheckboxInput-eW7xdiRS.js";import{U as La}from"./upload-MVVRQtkj.js";import"./nativeDownload-CziEyW_p.js";import"./ipc-CPhL3bPp.js";import"./Tooltip-D9Dt9ZTr.js";la({"calcfg.prevMonth":{zh:"上个月",en:"Previous month"},"calcfg.nextMonth":{zh:"下个月",en:"Next month"},"calcfg.jumpToDay":{zh:"跳转到这一天",en:"Jump to this day"},"calcfg.cloud":{zh:"云端",en:"Cloud"},"calcfg.title":{zh:"日历",en:"Calendars"},"calcfg.empty":{zh:"还没有加入日历的多维表。",en:"No databases added to the calendar yet."},"calcfg.eventColor":{zh:"事件颜色",en:"Event color"},"calcfg.fetchFailed":{zh:"拉取失败",en:"Fetch failed"},"calcfg.isDefaultAria":{zh:"{name} 是新建默认日历",en:"{name} is the default calendar for new events"},"calcfg.setDefaultAria":{zh:"将 {name} 设为新建默认日历",en:"Make {name} the default calendar for new events"},"calcfg.defaultCalendar":{zh:"新建默认日历",en:"Default calendar for new events"},"calcfg.setAsDefault":{zh:"设为新建默认日历",en:"Set as default for new events"},"calcfg.showInCalendar":{zh:"在日历中显示",en:"Show in calendar"},"calcfg.more":{zh:"更多",en:"More"},"calcfg.addCalendar":{zh:"添加日历",en:"Add calendar"},"calcfg.addDatabase":{zh:"添加多维表",en:"Add database"},"calcfg.subscribeExternal":{zh:"订阅外部日历",en:"Subscribe to external calendar"},"calcfg.subscribeHint":{zh:"粘贴 .ics 订阅地址(Google / Outlook / Apple 日历「密钥地址」都行)",en:"Paste an .ics subscription URL (Google, Outlook, or Apple Calendar's private address all work)"},"calcfg.importIcs":{zh:"导入 .ics 文件",en:"Import .ics file"},"calcfg.fileTooLarge":{zh:"文件过大(> {mb}MB)",en:"File too large (over {mb} MB)"},"calcfg.notIcs":{zh:"这不是一个 .ics 日历文件",en:"That isn't an .ics calendar file"},"calcfg.readFailed":{zh:"读取失败:{msg}",en:"Failed to read: {msg}"},"calcfg.renameCalendar":{zh:"重命名日历",en:"Rename calendar"},"calcfg.renameSub":{zh:"重命名订阅",en:"Rename subscription"},"calcfg.rename":{zh:"重命名",en:"Rename"},"calcfg.refreshNow":{zh:"立即刷新",en:"Refresh now"},"calcfg.unsubscribe":{zh:"取消订阅",en:"Unsubscribe"},"calcfg.setDefaultDb":{zh:"设为默认库",en:"Set as default"},"calcfg.openInNewTab":{zh:"在新标签打开",en:"Open in new tab"},"calcfg.columnMapping":{zh:"日历设置(列映射)",en:"Calendar settings (column mapping)"},"calcfg.removeFromCalendar":{zh:"从日历移除",en:"Remove from calendar"},"calcfg.searchDbPlaceholder":{zh:"搜索要加入日历的多维表…",en:"Search databases to add to the calendar…"},"calcfg.noCandidates":{zh:"没有含日期属性的可添加多维表",en:"No databases with a date property available to add"},"calcfg.footHint":{zh:"只有含「日期」属性的多维表会出现在这里",en:"Only databases with a Date property appear here"},"calcfg.weekStart":{zh:"一周开始于",en:"Week starts on"},"calcfg.weekStart.auto":{zh:"跟随语言({day})",en:"Default ({day})"},"calcfg.weekStart.sun":{zh:"周日",en:"Sunday"},"calcfg.weekStart.mon":{zh:"周一",en:"Monday"}});function Ha(){const{t:s}=q(),n=Z(c=>c.pref),p=Z(c=>c.setPref),i=c=>s(c===1?"calcfg.weekStart.mon":"calcfg.weekStart.sun"),u=[{value:"auto",label:s("calcfg.weekStart.auto",{day:i(Fa())})},{value:0,label:i(0)},{value:1,label:i(1)}],f=u.find(c=>c.value===n)??u[0];return a.jsxs("div",{className:"amx-calcfg-weekstart","data-week-start":n,children:[a.jsx("span",{className:"amx-calcfg-weekstart-label",children:s("calcfg.weekStart")}),a.jsxs(Ea,{label:`${s("calcfg.weekStart")} · ${f.label}`,className:"capability-menu-trigger amx-calcfg-weekstart-btn",selection:!0,items:u.map(c=>({id:`week-start:${c.value}`,label:c.label,selected:c.value===n,onSelect:()=>p(c.value)})),children:[a.jsx("span",{children:f.label}),a.jsx(aa,{size:13})]})]})}function se(){return a.jsx(qa,{children:a.jsxs("div",{className:"amx-calside",children:[a.jsx(Oa,{}),a.jsx(Wa,{})]})})}const W=s=>new Date(s.getFullYear(),s.getMonth(),1);function Oa(){const{t:s}=q(),n=oa(t=>(t.mainTabs,((t.api?ra(t.api):null)?.params??{}).__type==="calendar")),p=O(t=>t.visibleStart),i=O(t=>t.visibleEnd),u=O(t=>t.requestJump),f=d.useMemo(()=>ia(new Date),[]),[c,h]=d.useState(()=>W(f));d.useEffect(()=>{if(n&&p&&i){const t=J(p),b=ma(t,Math.floor(da(J(i),t)/2));h(W(b))}},[n,p,i]);const v=ua(),x=d.useMemo(()=>fa(c),[c,v]),C=F(f,!0),o=t=>{if(!n||!p||!i)return!1;const b=F(t,!0);return b>=p&&b<=i},N=t=>{h(W(t)),n&&u(F(t,!0))};return a.jsxs("div",{className:"amx-mini",children:[a.jsxs("div",{className:"amx-mini-head",children:[a.jsx("button",{className:"amx-mini-nav",onClick:()=>h(new Date(c.getFullYear(),c.getMonth()-1,1)),"aria-label":s("calcfg.prevMonth"),children:"‹"}),a.jsx("span",{className:"amx-mini-title",children:ha(c)}),a.jsx("button",{className:"amx-mini-nav",onClick:()=>h(new Date(c.getFullYear(),c.getMonth()+1,1)),"aria-label":s("calcfg.nextMonth"),children:"›"})]}),a.jsx("div",{className:"amx-mini-dow",children:pa().map(t=>a.jsx("span",{children:t},t))}),a.jsx("div",{className:"amx-mini-grid",children:x.map(t=>{const b=t.getMonth()!==c.getMonth(),E=F(t,!0)===C;return a.jsx("button",{className:`amx-mini-day${b?" out":""}${E?" today":""}${o(t)?" band":""}`,onClick:()=>N(t),title:n?s("calcfg.jumpToDay"):void 0,children:t.getDate()},+t)})})]})}function Wa(){const{t:s}=q(),n=_(e=>e.vaultRoot)??"",i=_(e=>e.vaultSide)==="cloud"?s("calcfg.cloud"):n.split(/[\\/]/).pop()||n,u=ga(),f=xa(),c=ba(),h=ja(),v=j(e=>e.errors),x=D(e=>e.byVault),C=D(e=>e.setColor),o=D(e=>e.toggleHidden),N=D(e=>e.setDefault),t=D(e=>e.addMember),b=D(e=>e.removeMember),[E,I]=d.useState(!1),[T,S]=d.useState(null),[B,k]=d.useState(null),[m,g]=d.useState(null),[z,y]=d.useState(null),sa=d.useMemo(()=>new Set(u.map(e=>e.db.path)),[u]),U=[...u.map(e=>({db:e.db})),...f.map(e=>({db:e,readonly:!0,kind:"agent"})),...c.map(e=>({db:e,readonly:!0,kind:"other"})),...h.map(e=>({db:e,readonly:!0,kind:"ics"}))],V=va(n,x),ta=e=>{g(null),H(s("calcfg.renameCalendar"),e.name).then(r=>{const l=r?.trim();l&&l!==e.name&&ka.getState().mutate(e.path,A=>({...A,name:l}))})},M=e=>e.slice(6),Y=e=>v[M(e)],na=()=>{H(s("calcfg.subscribeExternal"),"",{label:s("calcfg.subscribeHint")}).then(e=>{const r=e?.trim();r&&j.getState().add(r)})},ca=()=>{const e=document.createElement("input");e.type="file",e.accept=".ics,text/calendar",e.onchange=()=>{const r=e.files?.[0];if(r){if(r.size>K){k(s("calcfg.fileTooLarge",{mb:K/1024/1024}));return}k(null),r.text().then(l=>{j.getState().importText(Ma(l)||r.name.replace(/\.ics$/i,""),l)||k(s("calcfg.notIcs"))}).catch(l=>k(s("calcfg.readFailed",{msg:l?.message||String(l)})))}},e.click()};return a.jsxs("div",{className:"amx-calcfg",children:[a.jsx("div",{className:"amx-calcfg-head",children:s("calcfg.title")}),U.length===0&&a.jsx("div",{className:"amx-calcfg-empty",children:s("calcfg.empty")}),a.jsx("div",{className:"amx-calcfg-list",children:U.map(({db:e,readonly:r,kind:l},A)=>{const R=Ca(n,x,e.path,A),L=!Na(n,x,e.path),P=V?V===e.path:A===0;return a.jsxs("div",{className:"amx-calcfg-row",children:[a.jsx("span",{className:"amx-calcfg-type","aria-hidden":"true",children:l==="agent"?a.jsx(wa,{size:14}):l==="ics"?a.jsx(X,{size:14}):l==="other"?a.jsx(Ia,{size:14}):a.jsx($,{size:14})}),a.jsx("span",{className:"amx-calcfg-swatch",style:{background:L?R:"transparent",borderColor:R},children:a.jsx("input",{type:"color",value:R,onChange:w=>C(n,e.path,w.target.value),title:s("calcfg.eventColor")})}),a.jsxs("span",{className:`amx-calcfg-name${L?"":" off"}`,title:Y(e.path)||e.name,children:[e.name,l==="ics"&&Y(e.path)&&a.jsxs("span",{className:"amx-cal-vault",children:[" · ",s("calcfg.fetchFailed")]}),(()=>{const w=l==="agent"?"":l==="other"?e.vaultLabel||"":i;return w?a.jsxs("span",{className:"amx-cal-vault",children:[" · ",w]}):null})()]}),!r&&a.jsx("button",{className:`amx-calcfg-def${P?" on":""}`,"aria-label":P?s("calcfg.isDefaultAria",{name:e.name}):s("calcfg.setDefaultAria",{name:e.name}),title:s(P?"calcfg.defaultCalendar":"calcfg.setAsDefault"),onClick:()=>N(n,e.path),children:a.jsx(Ta,{size:13,fill:P?"currentColor":"none"})}),a.jsx(Ra,{label:s("calcfg.showInCalendar"),isLabelHidden:!0,size:"sm",value:L,onChange:()=>o(n,e.path)}),(!r||l==="ics")&&a.jsx("button",{className:"amx-calcfg-more",title:s("calcfg.more"),onClick:w=>{const G=w.currentTarget.getBoundingClientRect();g({db:e,ics:l==="ics",x:Math.min(G.left,window.innerWidth-180),y:G.bottom+4})},children:"⋯"})]},e.path)})}),a.jsxs("button",{className:"amx-calcfg-add amx-calcfg-add-main",onClick:e=>{const r=e.currentTarget.getBoundingClientRect();S({x:Math.max(12,r.left),y:r.bottom+4})},children:[a.jsx(Da,{size:14})," ",s("calcfg.addCalendar")," ",a.jsx(aa,{size:13})]}),B&&a.jsx("div",{className:"amx-calcfg-hint",style:{color:"var(--danger)"},children:B}),a.jsx(Ha,{}),T&&a.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>S(null),children:a.jsxs(Q,{className:"amx-db-pop amx-calcfg-addmenu",x:T.x,y:T.y,onMouseDown:e=>e.stopPropagation(),children:[a.jsxs("button",{className:"amx-db-opt",onClick:()=>{S(null),I(!0)},children:[a.jsx($,{size:14})," ",s("calcfg.addDatabase")]}),a.jsxs("button",{className:"amx-db-opt",onClick:()=>{S(null),na()},children:[a.jsx(X,{size:14})," ",s("calcfg.subscribeExternal")]}),a.jsxs("button",{className:"amx-db-opt",onClick:()=>{S(null),ca()},children:[a.jsx(La,{size:14})," ",s("calcfg.importIcs")]})]})}),m&&a.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>g(null),children:a.jsx(Q,{className:"amx-db-pop amx-calcfg-menu",x:m.x,y:m.y,onMouseDown:e=>e.stopPropagation(),children:m.ics?a.jsxs(a.Fragment,{children:[!!j.getState().subs.find(e=>e.id===M(m.db.path))?.url&&a.jsx("button",{className:"amx-db-opt",onClick:()=>{j.getState().refresh(M(m.db.path)),g(null)},children:s("calcfg.refreshNow")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{const e=M(m.db.path),r=m.db.name;g(null),H(s("calcfg.renameSub"),r).then(l=>{l?.trim()&&j.getState().rename(e,l.trim())})},children:s("calcfg.rename")}),a.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{j.getState().remove(M(m.db.path)),g(null)},children:s("calcfg.unsubscribe")})]}):a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"amx-db-opt",onClick:()=>ta(m.db),children:s("calcfg.rename")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{N(n,m.db.path),g(null)},children:s("calcfg.setDefaultDb")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{Sa(m.db.path),g(null)},children:s("calcfg.openInNewTab")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{y(m.db),g(null)},children:s("calcfg.columnMapping")}),a.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{b(n,m.db.path),g(null)},children:s("calcfg.removeFromCalendar")})]})})}),E&&a.jsx($a,{memberPaths:sa,onClose:()=>I(!1),onAdd:(e,r,l)=>{t(n,e.path,r,l),I(!1)}}),z&&a.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>y(null),children:a.jsx("div",{className:"amx-db-pop amx-calpick-pop",onMouseDown:e=>e.stopPropagation(),children:a.jsx(ea,{dbName:z.name,columns:z.columns,initial:za(n,x,z.path),onCancel:()=>y(null),onConfirm:(e,r)=>{t(n,z.path,e,r),y(null)}})})})]})}function $a({memberPaths:s,onClose:n,onAdd:p}){const{t:i}=q(),u=ya(),[f,c]=d.useState(""),[h,v]=d.useState(null),x=d.useMemo(()=>u.filter(o=>!s.has(o.path)&&o.columns.some(Aa)),[u,s]),C=f?x.filter(o=>o.name.toLowerCase().includes(f.toLowerCase())):x;return a.jsx("div",{className:"amx-qf-scrim",onMouseDown:n,children:h?a.jsx("div",{className:"amx-qf-card",onMouseDown:o=>o.stopPropagation(),children:a.jsx(ea,{dbName:h.name,columns:h.columns,onCancel:()=>v(null),onConfirm:(o,N)=>p(h,o,N)})}):a.jsxs("div",{className:"amx-qf",onMouseDown:o=>o.stopPropagation(),children:[a.jsxs("div",{className:"amx-qf-head",children:[a.jsx(Pa,{size:16,className:"amx-qf-searchicon"}),a.jsx("input",{autoFocus:!0,className:"amx-qf-input",placeholder:i("calcfg.searchDbPlaceholder"),value:f,onChange:o=>c(o.target.value)})]}),a.jsxs("div",{className:"amx-qf-list",children:[C.map(o=>a.jsxs("button",{className:"amx-qf-row",onClick:()=>v(o),children:[a.jsx("span",{className:"amx-qf-icon",children:a.jsx($,{size:15})}),a.jsx("span",{className:"amx-qf-title",children:o.name||o.path}),a.jsx("span",{className:"amx-qf-sub",children:o.path.replace(/\\/g,"/").split("/").slice(0,-1).join("/")||"/"})]},o.path)),C.length===0&&a.jsx("div",{className:"amx-qf-empty",children:i("calcfg.noCandidates")})]}),a.jsx("div",{className:"amx-qf-foot",children:i("calcfg.footHint")})]})})}export{se as CalendarConfigView};
1
+ import{j as a,u as F,d,r as la}from"./index-BM2o7PeV.js";import{p as oa,bn as ra,j4 as ia,j0 as V,j6 as ma,j8 as da,iW as ua,jR as fa,jd as q,jo as ha,j9 as pa,b as J,iX as ga,iY as xa,iZ as ba,i_ as ja,jS as j,i$ as D,ji as va,jg as Ca,jf as Na,G as wa,W as X,J as $,aq as Da,as as aa,ah as Z,fL as H,f7 as Sa,jT as ea,jU as za,jV as Q,jW as K,jX as Ma,fn as ka,jY as ya,jZ as Aa,R as Pa,j_ as qa}from"./appStore-DWP8UET9.js";import"./client-0MPbodA6.js";import{A as Fa}from"./astryxBridge-D-m4_kYt.js";import{u as O}from"./calendarNavStore-Cylfvv3s.js";import{C as Ea}from"./CapabilityMenu-SwVlZ06x.js";import{H as Ia}from"./hard-drive-BpuI5ebj.js";import{S as Ta}from"./star-BQWMXnn7.js";import{C as La}from"./CheckboxInput-BC-5a_C9.js";import{U as Ra}from"./upload-ZrOj6tXA.js";import"./nativeDownload-BYT082bY.js";import"./ipc-CxAyeo8q.js";import"./Tooltip-ZxrDqN4p.js";la({"calcfg.prevMonth":{zh:"上个月",en:"Previous month"},"calcfg.nextMonth":{zh:"下个月",en:"Next month"},"calcfg.jumpToDay":{zh:"跳转到这一天",en:"Jump to this day"},"calcfg.cloud":{zh:"云端",en:"Cloud"},"calcfg.title":{zh:"日历",en:"Calendars"},"calcfg.empty":{zh:"还没有加入日历的多维表。",en:"No databases added to the calendar yet."},"calcfg.eventColor":{zh:"事件颜色",en:"Event color"},"calcfg.fetchFailed":{zh:"拉取失败",en:"Fetch failed"},"calcfg.isDefaultAria":{zh:"{name} 是新建默认日历",en:"{name} is the default calendar for new events"},"calcfg.setDefaultAria":{zh:"将 {name} 设为新建默认日历",en:"Make {name} the default calendar for new events"},"calcfg.defaultCalendar":{zh:"新建默认日历",en:"Default calendar for new events"},"calcfg.setAsDefault":{zh:"设为新建默认日历",en:"Set as default for new events"},"calcfg.showInCalendar":{zh:"在日历中显示",en:"Show in calendar"},"calcfg.more":{zh:"更多",en:"More"},"calcfg.addCalendar":{zh:"添加日历",en:"Add calendar"},"calcfg.addDatabase":{zh:"添加多维表",en:"Add database"},"calcfg.subscribeExternal":{zh:"订阅外部日历",en:"Subscribe to external calendar"},"calcfg.subscribeHint":{zh:"粘贴 .ics 订阅地址(Google / Outlook / Apple 日历「密钥地址」都行)",en:"Paste an .ics subscription URL (Google, Outlook, or Apple Calendar's private address all work)"},"calcfg.importIcs":{zh:"导入 .ics 文件",en:"Import .ics file"},"calcfg.fileTooLarge":{zh:"文件过大(> {mb}MB)",en:"File too large (over {mb} MB)"},"calcfg.notIcs":{zh:"这不是一个 .ics 日历文件",en:"That isn't an .ics calendar file"},"calcfg.readFailed":{zh:"读取失败:{msg}",en:"Failed to read: {msg}"},"calcfg.renameCalendar":{zh:"重命名日历",en:"Rename calendar"},"calcfg.renameSub":{zh:"重命名订阅",en:"Rename subscription"},"calcfg.rename":{zh:"重命名",en:"Rename"},"calcfg.refreshNow":{zh:"立即刷新",en:"Refresh now"},"calcfg.unsubscribe":{zh:"取消订阅",en:"Unsubscribe"},"calcfg.setDefaultDb":{zh:"设为默认库",en:"Set as default"},"calcfg.openInNewTab":{zh:"在新标签打开",en:"Open in new tab"},"calcfg.columnMapping":{zh:"日历设置(列映射)",en:"Calendar settings (column mapping)"},"calcfg.removeFromCalendar":{zh:"从日历移除",en:"Remove from calendar"},"calcfg.searchDbPlaceholder":{zh:"搜索要加入日历的多维表…",en:"Search databases to add to the calendar…"},"calcfg.noCandidates":{zh:"没有含日期属性的可添加多维表",en:"No databases with a date property available to add"},"calcfg.footHint":{zh:"只有含「日期」属性的多维表会出现在这里",en:"Only databases with a Date property appear here"},"calcfg.weekStart":{zh:"一周开始于",en:"Week starts on"},"calcfg.weekStart.auto":{zh:"跟随语言({day})",en:"Default ({day})"},"calcfg.weekStart.sun":{zh:"周日",en:"Sunday"},"calcfg.weekStart.mon":{zh:"周一",en:"Monday"}});function Ha(){const{t:s}=F(),n=Q(c=>c.pref),p=Q(c=>c.setPref),i=c=>s(c===1?"calcfg.weekStart.mon":"calcfg.weekStart.sun"),u=[{value:"auto",label:s("calcfg.weekStart.auto",{day:i(qa())})},{value:0,label:i(0)},{value:1,label:i(1)}],f=u.find(c=>c.value===n)??u[0];return a.jsxs("div",{className:"amx-calcfg-weekstart","data-week-start":n,children:[a.jsx("span",{className:"amx-calcfg-weekstart-label",children:s("calcfg.weekStart")}),a.jsxs(Ea,{label:`${s("calcfg.weekStart")} · ${f.label}`,className:"capability-menu-trigger amx-calcfg-weekstart-btn",selection:!0,items:u.map(c=>({id:`week-start:${c.value}`,label:c.label,selected:c.value===n,onSelect:()=>p(c.value)})),children:[a.jsx("span",{children:f.label}),a.jsx(aa,{size:13})]})]})}function se(){return a.jsx(Fa,{children:a.jsxs("div",{className:"amx-calside",children:[a.jsx(Oa,{}),a.jsx(Wa,{})]})})}const W=s=>new Date(s.getFullYear(),s.getMonth(),1);function Oa(){const{t:s}=F(),n=oa(t=>(t.mainTabs,((t.api?ra(t.api):null)?.params??{}).__type==="calendar")),p=O(t=>t.visibleStart),i=O(t=>t.visibleEnd),u=O(t=>t.requestJump),f=d.useMemo(()=>ia(new Date),[]),[c,h]=d.useState(()=>W(f));d.useEffect(()=>{if(n&&p&&i){const t=V(p),b=ma(t,Math.floor(da(V(i),t)/2));h(W(b))}},[n,p,i]);const v=ua(),x=d.useMemo(()=>fa(c),[c,v]),C=q(f,!0),o=t=>{if(!n||!p||!i)return!1;const b=q(t,!0);return b>=p&&b<=i},N=t=>{h(W(t)),n&&u(q(t,!0))};return a.jsxs("div",{className:"amx-mini",children:[a.jsxs("div",{className:"amx-mini-head",children:[a.jsx("button",{className:"amx-mini-nav",onClick:()=>h(new Date(c.getFullYear(),c.getMonth()-1,1)),"aria-label":s("calcfg.prevMonth"),children:"‹"}),a.jsx("span",{className:"amx-mini-title",children:ha(c)}),a.jsx("button",{className:"amx-mini-nav",onClick:()=>h(new Date(c.getFullYear(),c.getMonth()+1,1)),"aria-label":s("calcfg.nextMonth"),children:"›"})]}),a.jsx("div",{className:"amx-mini-dow",children:pa().map(t=>a.jsx("span",{children:t},t))}),a.jsx("div",{className:"amx-mini-grid",children:x.map(t=>{const b=t.getMonth()!==c.getMonth(),E=q(t,!0)===C;return a.jsx("button",{className:`amx-mini-day${b?" out":""}${E?" today":""}${o(t)?" band":""}`,onClick:()=>N(t),title:n?s("calcfg.jumpToDay"):void 0,children:t.getDate()},+t)})})]})}function Wa(){const{t:s}=F(),n=J(e=>e.vaultRoot)??"",i=J(e=>e.vaultSide)==="cloud"?s("calcfg.cloud"):n.split(/[\\/]/).pop()||n,u=ga(),f=xa(),c=ba(),h=ja(),v=j(e=>e.errors),x=D(e=>e.byVault),C=D(e=>e.setColor),o=D(e=>e.toggleHidden),N=D(e=>e.setDefault),t=D(e=>e.addMember),b=D(e=>e.removeMember),[E,I]=d.useState(!1),[T,S]=d.useState(null),[B,k]=d.useState(null),[m,g]=d.useState(null),[z,y]=d.useState(null),sa=d.useMemo(()=>new Set(u.map(e=>e.db.path)),[u]),Y=[...u.map(e=>({db:e.db})),...f.map(e=>({db:e,readonly:!0,kind:"agent"})),...c.map(e=>({db:e,readonly:!0,kind:"other"})),...h.map(e=>({db:e,readonly:!0,kind:"ics"}))],_=va(n,x),ta=e=>{g(null),H(s("calcfg.renameCalendar"),e.name).then(r=>{const l=r?.trim();l&&l!==e.name&&ka.getState().mutate(e.path,A=>({...A,name:l}))})},M=e=>e.slice(6),G=e=>v[M(e)],na=()=>{H(s("calcfg.subscribeExternal"),"",{label:s("calcfg.subscribeHint")}).then(e=>{const r=e?.trim();r&&j.getState().add(r)})},ca=()=>{const e=document.createElement("input");e.type="file",e.accept=".ics,text/calendar",e.onchange=()=>{const r=e.files?.[0];if(r){if(r.size>K){k(s("calcfg.fileTooLarge",{mb:K/1024/1024}));return}k(null),r.text().then(l=>{j.getState().importText(Ma(l)||r.name.replace(/\.ics$/i,""),l)||k(s("calcfg.notIcs"))}).catch(l=>k(s("calcfg.readFailed",{msg:l?.message||String(l)})))}},e.click()};return a.jsxs("div",{className:"amx-calcfg",children:[a.jsx("div",{className:"amx-calcfg-head",children:s("calcfg.title")}),Y.length===0&&a.jsx("div",{className:"amx-calcfg-empty",children:s("calcfg.empty")}),a.jsx("div",{className:"amx-calcfg-list",children:Y.map(({db:e,readonly:r,kind:l},A)=>{const L=Ca(n,x,e.path,A),R=!Na(n,x,e.path),P=_?_===e.path:A===0;return a.jsxs("div",{className:"amx-calcfg-row",children:[a.jsx("span",{className:"amx-calcfg-type","aria-hidden":"true",children:l==="agent"?a.jsx(wa,{size:14}):l==="ics"?a.jsx(X,{size:14}):l==="other"?a.jsx(Ia,{size:14}):a.jsx($,{size:14})}),a.jsx("span",{className:"amx-calcfg-swatch",style:{background:R?L:"transparent",borderColor:L},children:a.jsx("input",{type:"color",value:L,onChange:w=>C(n,e.path,w.target.value),title:s("calcfg.eventColor")})}),a.jsxs("span",{className:`amx-calcfg-name${R?"":" off"}`,title:G(e.path)||e.name,children:[e.name,l==="ics"&&G(e.path)&&a.jsxs("span",{className:"amx-cal-vault",children:[" · ",s("calcfg.fetchFailed")]}),(()=>{const w=l==="agent"?"":l==="other"?e.vaultLabel||"":i;return w?a.jsxs("span",{className:"amx-cal-vault",children:[" · ",w]}):null})()]}),!r&&a.jsx("button",{className:`amx-calcfg-def${P?" on":""}`,"aria-label":P?s("calcfg.isDefaultAria",{name:e.name}):s("calcfg.setDefaultAria",{name:e.name}),title:s(P?"calcfg.defaultCalendar":"calcfg.setAsDefault"),onClick:()=>N(n,e.path),children:a.jsx(Ta,{size:13,fill:P?"currentColor":"none"})}),a.jsx(La,{label:s("calcfg.showInCalendar"),isLabelHidden:!0,size:"sm",value:R,onChange:()=>o(n,e.path)}),(!r||l==="ics")&&a.jsx("button",{className:"amx-calcfg-more",title:s("calcfg.more"),onClick:w=>{const U=w.currentTarget.getBoundingClientRect();g({db:e,ics:l==="ics",x:Math.min(U.left,window.innerWidth-180),y:U.bottom+4})},children:"⋯"})]},e.path)})}),a.jsxs("button",{className:"amx-calcfg-add amx-calcfg-add-main",onClick:e=>{const r=e.currentTarget.getBoundingClientRect();S({x:Math.max(12,r.left),y:r.bottom+4})},children:[a.jsx(Da,{size:14})," ",s("calcfg.addCalendar")," ",a.jsx(aa,{size:13})]}),B&&a.jsx("div",{className:"amx-calcfg-hint",style:{color:"var(--danger)"},children:B}),a.jsx(Ha,{}),T&&a.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>S(null),children:a.jsxs(Z,{className:"amx-db-pop amx-calcfg-addmenu",x:T.x,y:T.y,onMouseDown:e=>e.stopPropagation(),children:[a.jsxs("button",{className:"amx-db-opt",onClick:()=>{S(null),I(!0)},children:[a.jsx($,{size:14})," ",s("calcfg.addDatabase")]}),a.jsxs("button",{className:"amx-db-opt",onClick:()=>{S(null),na()},children:[a.jsx(X,{size:14})," ",s("calcfg.subscribeExternal")]}),a.jsxs("button",{className:"amx-db-opt",onClick:()=>{S(null),ca()},children:[a.jsx(Ra,{size:14})," ",s("calcfg.importIcs")]})]})}),m&&a.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>g(null),children:a.jsx(Z,{className:"amx-db-pop amx-calcfg-menu",x:m.x,y:m.y,onMouseDown:e=>e.stopPropagation(),children:m.ics?a.jsxs(a.Fragment,{children:[!!j.getState().subs.find(e=>e.id===M(m.db.path))?.url&&a.jsx("button",{className:"amx-db-opt",onClick:()=>{j.getState().refresh(M(m.db.path)),g(null)},children:s("calcfg.refreshNow")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{const e=M(m.db.path),r=m.db.name;g(null),H(s("calcfg.renameSub"),r).then(l=>{l?.trim()&&j.getState().rename(e,l.trim())})},children:s("calcfg.rename")}),a.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{j.getState().remove(M(m.db.path)),g(null)},children:s("calcfg.unsubscribe")})]}):a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"amx-db-opt",onClick:()=>ta(m.db),children:s("calcfg.rename")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{N(n,m.db.path),g(null)},children:s("calcfg.setDefaultDb")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{Sa(m.db.path),g(null)},children:s("calcfg.openInNewTab")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{y(m.db),g(null)},children:s("calcfg.columnMapping")}),a.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{b(n,m.db.path),g(null)},children:s("calcfg.removeFromCalendar")})]})})}),E&&a.jsx($a,{memberPaths:sa,onClose:()=>I(!1),onAdd:(e,r,l)=>{t(n,e.path,r,l),I(!1)}}),z&&a.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>y(null),children:a.jsx("div",{className:"amx-db-pop amx-calpick-pop",onMouseDown:e=>e.stopPropagation(),children:a.jsx(ea,{dbName:z.name,columns:z.columns,initial:za(n,x,z.path),onCancel:()=>y(null),onConfirm:(e,r)=>{t(n,z.path,e,r),y(null)}})})})]})}function $a({memberPaths:s,onClose:n,onAdd:p}){const{t:i}=F(),u=ya(),[f,c]=d.useState(""),[h,v]=d.useState(null),x=d.useMemo(()=>u.filter(o=>!s.has(o.path)&&o.columns.some(Aa)),[u,s]),C=f?x.filter(o=>o.name.toLowerCase().includes(f.toLowerCase())):x;return a.jsx("div",{className:"amx-qf-scrim",onMouseDown:n,children:h?a.jsx("div",{className:"amx-qf-card",onMouseDown:o=>o.stopPropagation(),children:a.jsx(ea,{dbName:h.name,columns:h.columns,onCancel:()=>v(null),onConfirm:(o,N)=>p(h,o,N)})}):a.jsxs("div",{className:"amx-qf",onMouseDown:o=>o.stopPropagation(),children:[a.jsxs("div",{className:"amx-qf-head",children:[a.jsx(Pa,{size:16,className:"amx-qf-searchicon"}),a.jsx("input",{autoFocus:!0,className:"amx-qf-input",placeholder:i("calcfg.searchDbPlaceholder"),value:f,onChange:o=>c(o.target.value)})]}),a.jsxs("div",{className:"amx-qf-list",children:[C.map(o=>a.jsxs("button",{className:"amx-qf-row",onClick:()=>v(o),children:[a.jsx("span",{className:"amx-qf-icon",children:a.jsx($,{size:15})}),a.jsx("span",{className:"amx-qf-title",children:o.name||o.path}),a.jsx("span",{className:"amx-qf-sub",children:o.path.replace(/\\/g,"/").split("/").slice(0,-1).join("/")||"/"})]},o.path)),C.length===0&&a.jsx("div",{className:"amx-qf-empty",children:i("calcfg.noCandidates")})]}),a.jsx("div",{className:"amx-qf-foot",children:i("calcfg.footHint")})]})})}export{se as CalendarConfigView};