@xopcai/xopc 0.0.299 → 0.0.302

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 (140) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-C-DSdak3.js → activity-store-DCi5rh4e.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BnrB5fWD.js → agent-avatar-dicebear-C0zP6W2B.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D0ITeUFb.js +1 -0
  6. package/dist/gateway/static/root/assets/{agents-DNxSNGao.js → agents-DcfWhk2S.js} +1 -1
  7. package/dist/gateway/static/root/assets/{api-DS4w0i5N.js → api-CAV9PN9i.js} +1 -1
  8. package/dist/gateway/static/root/assets/api-fPapljyb.js +1 -0
  9. package/dist/gateway/static/root/assets/app-management-settings-panel-U3yDRzKF.js +1 -0
  10. package/dist/gateway/static/root/assets/appearance-settings-ZFjV_opr.js +1 -0
  11. package/dist/gateway/static/root/assets/apps-page-FgMHY1Pr.js +1 -0
  12. package/dist/gateway/static/root/assets/{archive-plugin-CISHdvCz.js → archive-plugin-MaKWrpgC.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-c0q_Q6IQ.js → attachment-load-IfqbP2BN.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automations-page-BOiNdKcv.js → automations-page-CeI2NGSO.js} +1 -1
  15. package/dist/gateway/static/root/assets/automations-workspace-DxaiBwrD.js +6 -0
  16. package/dist/gateway/static/root/assets/{binary-plugins-BO1hALPX.js → binary-plugins-jvQ6FaBZ.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-BWzZ4hDH.js → block-editor-B7U3qlB3.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automation-inputs-DvwCwLOp.js → browser-automation-inputs-BGT0xoTv.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-automations-page-B8LfUUco.js → browser-automations-page-DvLAwoiQ.js} +1 -1
  20. package/dist/gateway/static/root/assets/browser-settings-page-CHrfg3BX.js +3 -0
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-DpYDPk_o.js +8 -0
  22. package/dist/gateway/static/root/assets/{channels-settings-BBX7Gp4q.js → channels-settings-DMq-NBUQ.js} +1 -1
  23. package/dist/gateway/static/root/assets/{channels-status-swr-CgtFOwNh.js → channels-status-swr-C_icwbWj.js} +1 -1
  24. package/dist/gateway/static/root/assets/{chat-terminal-dock-CLYsf1w_.js → chat-terminal-dock-BtL71IOs.js} +1 -1
  25. package/dist/gateway/static/root/assets/computer-settings-page-Bu6ZJtmS.js +1 -0
  26. package/dist/gateway/static/root/assets/{connectors-page-BVUnp0UV.js → connectors-page-LsEiI9L5.js} +1 -1
  27. package/dist/gateway/static/root/assets/{cron-expression-DKSgHs4I.js → cron-expression-B25FHn4w.js} +1 -1
  28. package/dist/gateway/static/root/assets/{date-picker-DRTglPVS.js → date-picker-CzVHO7z9.js} +1 -1
  29. package/dist/gateway/static/root/assets/{dependency-picker-_-7WsbTH.js → dependency-picker-BNugauiZ.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-CR7n2K67.js → desktop-pet-DTy_3-OY.js} +1 -1
  31. package/dist/gateway/static/root/assets/desktop-pet-settings-CXfnejTb.js +1 -0
  32. package/dist/gateway/static/root/assets/device-pairing-wizard-CxKwfncn.js +1 -0
  33. package/dist/gateway/static/root/assets/extension-debug-page-C3F7RiGW.js +1 -0
  34. package/dist/gateway/static/root/assets/{extension-page-EZC07dGv.js → extension-page-C0jhcCT_.js} +1 -1
  35. package/dist/gateway/static/root/assets/extension-settings-page-CNvJQkrr.js +1 -0
  36. package/dist/gateway/static/root/assets/figtree-latin-ext-wght-normal-DCwSJGxG.woff2 +0 -0
  37. package/dist/gateway/static/root/assets/figtree-latin-wght-normal-D_ZTVpCC.woff2 +0 -0
  38. package/dist/gateway/static/root/assets/{gateway-config-swr-B2xVR9gt.js → gateway-config-swr-D5AM8cyQ.js} +1 -1
  39. package/dist/gateway/static/root/assets/gateway-settings-CQTcIvlZ.js +1 -0
  40. package/dist/gateway/static/root/assets/{gateway-startup-retry-c7s8h7px.js → gateway-startup-retry-CSJWdnFs.js} +1 -1
  41. package/dist/gateway/static/root/assets/{heartbeat-settings-BAMr_vYa.js → heartbeat-settings-Cd1VJsHe.js} +1 -1
  42. package/dist/gateway/static/root/assets/{home-page-DG19Sjrn.js → home-page-B_uyfCGq.js} +1 -1
  43. package/dist/gateway/static/root/assets/{image-generation-api-DUjbV88R.js → image-generation-api-BNh604hw.js} +1 -1
  44. package/dist/gateway/static/root/assets/{imports-page-BaQmVh_d.js → imports-page-DXNfRmk9.js} +1 -1
  45. package/dist/gateway/static/root/assets/index-BAqVpc1H.css +1 -0
  46. package/dist/gateway/static/root/assets/index-hlU8MUEz.js +79 -0
  47. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CgW5_XVP.js +1 -0
  48. package/dist/gateway/static/root/assets/{local-app-workbench-page-h48NEuKs.js → local-app-workbench-page-C4h3qDRL.js} +2 -2
  49. package/dist/gateway/static/root/assets/{local-apps-page-DFMrfoGF.js → local-apps-page-DyrFxW3G.js} +1 -1
  50. package/dist/gateway/static/root/assets/{locale-store-CwuCkjo7.js → locale-store-DLK05Y1a.js} +1 -1
  51. package/dist/gateway/static/root/assets/logs-page-Goy_QHfL.js +2 -0
  52. package/dist/gateway/static/root/assets/{management-settings-Dib_yIDQ.js → management-settings-DgQyGEpR.js} +1 -1
  53. package/dist/gateway/static/root/assets/{markdown-view-3YQc6QFV.js → markdown-view-B8maDRWh.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-DlZXjN6z.js → media-plugins-5DakFba_.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-C9h8SImu.js +3 -0
  56. package/dist/gateway/static/root/assets/note-detail-panel-lcZby9NY.js +5 -0
  57. package/dist/gateway/static/root/assets/notes-page-CDGPPI-W.js +8 -0
  58. package/dist/gateway/static/root/assets/{page-tabs-BLzm5EXm.js → page-tabs-DzJpglJJ.js} +1 -1
  59. package/dist/gateway/static/root/assets/{preview-open-alternatives-B6QLKIZy.js → preview-open-alternatives-Dj6LJsuQ.js} +1 -1
  60. package/dist/gateway/static/root/assets/{proactive-page-W_uN2_ie.js → proactive-page-CwudBdrQ.js} +1 -1
  61. package/dist/gateway/static/root/assets/{product-open-page-DLm3cUhY.js → product-open-page-CujZXOea.js} +1 -1
  62. package/dist/gateway/static/root/assets/project-detail-page-CyAf_sK-.js +1 -0
  63. package/dist/gateway/static/root/assets/{projects-page-DT7zmH0f.js → projects-page-BW5m_HhZ.js} +1 -1
  64. package/dist/gateway/static/root/assets/{registry-api-Cxx1-pCg.js → registry-api-BMFL4vis.js} +1 -1
  65. package/dist/gateway/static/root/assets/remote-access-hub-B4JgwB0s.js +1 -0
  66. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DV554qyN.js +5 -0
  67. package/dist/gateway/static/root/assets/{schema-form-BTLg2fN1.js → schema-form-Bh2Er67B.js} +1 -1
  68. package/dist/gateway/static/root/assets/sessions-page-D5SmvlQ1.js +1 -0
  69. package/dist/gateway/static/root/assets/settings-advanced-gate-DDALROy_.js +1 -0
  70. package/dist/gateway/static/root/assets/settings-form-section-BsdM7P1d.js +1 -0
  71. package/dist/gateway/static/root/assets/{settings-page-BR9XJ0j9.js → settings-page-3yEAqoME.js} +1 -1
  72. package/dist/gateway/static/root/assets/settings-page-layout-X1x-2Cp9.js +1 -0
  73. package/dist/gateway/static/root/assets/{setup-status-panel-BSo76NwE.js → setup-status-panel-BOHNZ-S3.js} +1 -1
  74. package/dist/gateway/static/root/assets/{share-preview-page-Dx2IpPEp.js → share-preview-page-wV056nz2.js} +1 -1
  75. package/dist/gateway/static/root/assets/shares-settings-io4NzfJL.js +1 -0
  76. package/dist/gateway/static/root/assets/skill-reload-api-CERFaxLj.js +1 -0
  77. package/dist/gateway/static/root/assets/{skills-page-CaX9EQtn.js → skills-page-CtwUqvsE.js} +1 -1
  78. package/dist/gateway/static/root/assets/{skills-page.utils-CxWdcFKs.js → skills-page.utils-dHBD7YqU.js} +1 -1
  79. package/dist/gateway/static/root/assets/{system-settings-panel-BkiXkDSq.js → system-settings-panel-lItR5Kah.js} +1 -1
  80. package/dist/gateway/static/root/assets/task-detail-page-CCKc67a-.js +1 -0
  81. package/dist/gateway/static/root/assets/{theme-store-Dt7ob2wD.js → theme-store-KfFEGMlp.js} +1 -1
  82. package/dist/gateway/static/root/assets/tunnel-api-DPyLgmWw.js +1 -0
  83. package/dist/gateway/static/root/assets/{use-autosave-BHxjmV8l.js → use-autosave-DO50_g_S.js} +1 -1
  84. package/dist/gateway/static/root/assets/user-model-page-CcnGgH1n.js +2 -0
  85. package/dist/gateway/static/root/assets/{voice-api-key-field-BCNM-BaQ.js → voice-api-key-field-k7tWLXzM.js} +1 -1
  86. package/dist/gateway/static/root/assets/{voice-config-api-De1DTzxK.js → voice-config-api-bZqN8-UF.js} +1 -1
  87. package/dist/gateway/static/root/assets/{work-discovery-overlay-tig5sF-Q.js → work-discovery-overlay-BHI6gO_u.js} +1 -1
  88. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-OcS30LVZ.js → workflow-run-setup-panel-jEMtNIG8.js} +1 -1
  89. package/dist/gateway/static/root/assets/workflows-page-CX4bcAD-.js +6 -0
  90. package/dist/gateway/static/root/index.html +10 -10
  91. package/dist/package.js +1 -1
  92. package/dist/src/agent/service/process-direct-one-shot.js +1 -0
  93. package/dist/src/config/schema.js +1 -1
  94. package/dist/src/gateway/automation-agent-session.js +9 -2
  95. package/dist/src/gateway/heartbeat/service.js +2 -2
  96. package/dist/src/gateway/service/config-coordinator.js +1 -1
  97. package/dist/src/gateway/service/run-gateway-agent.js +2 -3
  98. package/dist/src/heartbeat/index.js +1 -1
  99. package/dist/src/notifications/plain-text.d.ts +1 -0
  100. package/dist/src/notifications/plain-text.js +14 -0
  101. package/dist/src/notifications/planner.js +2 -1
  102. package/dist/src/storage/sqlite/session-repository.js +21 -1
  103. package/dist/src/storage/sqlite/transcript-repository.js +11 -2
  104. package/dist/src/workflows/service/workflow-session-bridge.js +5 -1
  105. package/package.json +5 -5
  106. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CaA7l5Xv.js +0 -1
  107. package/dist/gateway/static/root/assets/api-BhJmc8E-.js +0 -1
  108. package/dist/gateway/static/root/assets/app-management-settings-panel-Dfrcz-vZ.js +0 -1
  109. package/dist/gateway/static/root/assets/appearance-settings-BLB_xmtb.js +0 -1
  110. package/dist/gateway/static/root/assets/apps-page-Bg-7fqIS.js +0 -1
  111. package/dist/gateway/static/root/assets/automations-workspace-DDdsNbjH.js +0 -6
  112. package/dist/gateway/static/root/assets/browser-settings-page-BtZbX85K.js +0 -3
  113. package/dist/gateway/static/root/assets/capabilities-settings-panel-mNpAFqTf.js +0 -8
  114. package/dist/gateway/static/root/assets/computer-model-settings-DYWcZu2X.js +0 -1
  115. package/dist/gateway/static/root/assets/computer-settings-page-B4pC7mRs.js +0 -1
  116. package/dist/gateway/static/root/assets/desktop-pet-settings-Bu7g83kd.js +0 -1
  117. package/dist/gateway/static/root/assets/device-pairing-wizard-D5z7BvaO.js +0 -1
  118. package/dist/gateway/static/root/assets/extension-debug-page-BI8pvu2u.js +0 -1
  119. package/dist/gateway/static/root/assets/extension-settings-page-DLYC6gVA.js +0 -1
  120. package/dist/gateway/static/root/assets/gateway-settings-C17LDur8.js +0 -1
  121. package/dist/gateway/static/root/assets/index-B7JCOaCc.js +0 -81
  122. package/dist/gateway/static/root/assets/index-Bt6a_Yxc.css +0 -2
  123. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-DfNQK_hR.js +0 -1
  124. package/dist/gateway/static/root/assets/logs-page-CD9MfQDD.js +0 -2
  125. package/dist/gateway/static/root/assets/messages-D6CRVWtT.js +0 -3
  126. package/dist/gateway/static/root/assets/note-detail-panel-CS0W3ESn.js +0 -5
  127. package/dist/gateway/static/root/assets/notes-page-BNMVGN6Y.js +0 -8
  128. package/dist/gateway/static/root/assets/project-detail-page-Gfze4S0P.js +0 -1
  129. package/dist/gateway/static/root/assets/remote-access-hub-CXQkXSU2.js +0 -1
  130. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DHkNbhpP.js +0 -5
  131. package/dist/gateway/static/root/assets/sessions-page-CxTLRoxv.js +0 -1
  132. package/dist/gateway/static/root/assets/settings-advanced-gate-BgtDlDZh.js +0 -1
  133. package/dist/gateway/static/root/assets/settings-form-section-D9rWLTBX.js +0 -1
  134. package/dist/gateway/static/root/assets/settings-page-layout-CsUQKRq0.js +0 -1
  135. package/dist/gateway/static/root/assets/shares-settings-BMF0Bo06.js +0 -1
  136. package/dist/gateway/static/root/assets/skill-reload-api-DNBw3BJR.js +0 -1
  137. package/dist/gateway/static/root/assets/task-detail-page-UBuGZQkl.js +0 -1
  138. package/dist/gateway/static/root/assets/tunnel-api-CEXwG7vJ.js +0 -1
  139. package/dist/gateway/static/root/assets/user-model-page-Dvtr3CPj.js +0 -2
  140. package/dist/gateway/static/root/assets/workflows-page-AqlMn0Bx.js +0 -6
@@ -0,0 +1,6 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as o,r as s}from"./popover-select-DldSX8GX.js";import{t as c}from"./circle-check-C23XjkUj.js";import{t as l}from"./markdown-view-B8maDRWh.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./cn-JdwAhgNB.js";import{n as p}from"./locale-store-DLK05Y1a.js";import{t as m}from"./messages-C9h8SImu.js";import{a as h,n as g,o as _,r as v,s as y,t as b}from"./dist-BGTk37IG.js";import{i as x}from"./vendor-swr-BIWyz7Rc.js";import{t as S}from"./button-CGlRPNzi.js";import{t as C}from"./skeleton-BwbyijEw.js";import{An as w,Dn as T,Fu as ee,Ic as E,Jc as D,Jl as O,Lu as k,Mn as te,Mu as ne,Nu as A,On as j,So as M,Tc as N,Ua as P,Wc as F,Xc as I,Ys as L,bc as R,fl as z,ga as B,jc as re,kn as ie,l as V,lu as ae,nd as oe,oc as se,pn as ce,ra as le,y as ue,yl as H}from"./index-hlU8MUEz.js";import{a as U,i as W,o as de,r as G}from"./cron-expression-B25FHn4w.js";import{a as fe,i as pe,n as me,r as K,t as he}from"./workflow-run-setup-panel-jEMtNIG8.js";import{i as ge,n as _e,r as q,t as ve}from"./browser-automation-inputs-BGT0xoTv.js";var J=e(t(),1),ye=n(),be=U();function xe(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function Y(e,t){let n=e===7?0:e;return new Date(Date.UTC(2023,0,1)+n*864e5).toLocaleDateString(t,{weekday:`short`,timeZone:`UTC`})}function Se(e,t){return e.length<=1?e[0]??``:t.startsWith(`zh`)?e.join(`、`):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Ce(e){return e.length===5&&e.every((e,t)=>e===t+1)}function we(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function Te(e,t,n,r){try{let i=be.CronExpressionParser.parse(e,{...r?.timezone?{tz:r.timezone}:{}}).fields,a=G(i.minute.values),o=G(i.hour.values),s=G(i.dayOfWeek.values),c=G(i.dayOfMonth.values);if(a.length===60&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.everyMinute;if(!i.minute.isWildcard&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&a.length>1){let e=W(a);if(e!=null&&e>0)return n.everyNMinutes.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length>1&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard){let e=W(o);if(e!=null&&e>0)return n.everyNHours.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&o.length===24)return n.hourly;let l=!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length===1?xe(o[0],a[0],t):``;if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.dailyAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Ce(s))return n.weekdaysAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&we(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=Y(s[0],t);return n.weeklyOn.replace(`{{day}}`,e).replace(`{{time}}`,l)}if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length>1){let e=Se(s.map(e=>Y(e,t)),t);return n.daysAt.replace(`{{days}}`,e).replace(`{{time}}`,l)}return l&&!i.dayOfMonth.isWildcard&&c.length===1&&i.month.isWildcard&&i.dayOfWeek.isWildcard?n.monthlyAt.replace(`{{day}}`,String(c[0])).replace(`{{time}}`,l):n.customSchedule}catch{return null}}function Ee(e,t,n,r){let i=e.trim();return i?Te(i,t,n,r)||De(r?.nextRun,t)||n.customSchedule:De(r?.nextRun,t)||`—`}function De(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleString(t,{weekday:`short`,hour:`numeric`,minute:`2-digit`})}var Oe=1e3,X=60*Oe,Z=60*X,ke=24*Z,Ae=7*ke,je=new Intl.ListFormat(`en-US`,{type:`conjunction`}),Me=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),Ne={en:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},Pe={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},Fe={minute:X,hour:Z,day:ke,week:Ae};function Ie(e){return e===`zh`?`zh-CN`:`en-US`}function Le(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:Me[String(t)].format(e)}function Re(e,t){return t===`zh`?e.join(` `):je.format(e)}function ze(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(X,Math.round((Number.isFinite(n)&&n>0?n:1)*Fe[t]))}function Be(e,t,n){let r=typeof e==`number`?e:Number.parseFloat(e),i=Number.isFinite(r)&&r>0?r:1;return String(Number.parseFloat((i*Fe[t]/Fe[n]).toFixed(6)))}function Ve(e,t){let n=Math.max(Oe,Math.round(e)),r=n===ke?[{unit:`hour`,ms:Z}]:n>=Ae&&n%Ae===0?[{unit:`week`,ms:Ae}]:n>=ke?[{unit:`day`,ms:ke},{unit:`hour`,ms:Z},{unit:`minute`,ms:X},{unit:`second`,ms:Oe}]:n>=Z?[{unit:`hour`,ms:Z},{unit:`minute`,ms:X},{unit:`second`,ms:Oe}]:n>=X?[{unit:`minute`,ms:X},{unit:`second`,ms:Oe}]:[{unit:`second`,ms:Oe}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(Le(r,e,t)),i%=n)}return Re(a,t)}function He(e,t){let n=Ve(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function Ue(e,t){return Ne[t].format(new Date(e))}function We(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Ge(e,t,n=Date.now()){let r=new Date(e),i=Math.round((We(r)-We(new Date(n)))/ke),a=Pe[t].format(r);return i===0?t===`zh`?`今天 ${a}`:`today at ${a}`:i===1?t===`zh`?`明天 ${a}`:`tomorrow at ${a}`:i===-1?t===`zh`?`昨天 ${a}`:`yesterday at ${a}`:Ue(e,t)}function Ke(e,t){return e.eventType===`task.attention_required.v2`&&e.payloadMatch?.reason===`blocked`?t.trigger.taskBlockedWhen:e.eventType===`note.created`?t.trigger.noteCreatedWhen:e.eventType===`workflow.run.completed`&&e.payloadMatch?.status===`failed`?t.trigger.workflowFailedWhen:e.eventType===`session.transcript.updated`?t.trigger.sessionUpdatedWhen:t.trigger.eventWithType.replace(`{type}`,e.eventType)}function qe(e,t,n,r){if(e.kind===`manual`)return t.trigger.manualWhen;if(e.kind===`webhook`)return t.trigger.webhookWhen;if(e.kind===`event`)return Ke(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Ge(Date.parse(i.at),r)):i.kind===`interval`?He(i.everyMs,r):Ee(i.expr,Ie(r),n.scheduleBadge,{timezone:i.tz})}function Je(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Ge(e.state.nextRunAtMs,n,r):e.trigger.kind===`manual`?t.info.noAutomaticTrigger:e.trigger.kind===`event`||e.trigger.kind===`webhook`?t.info.waitingForTrigger:t.info.noUpcomingRun:t.info.pausedNoAutomaticRuns}function Ye(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Ge(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Xe={name:``,description:``,projectId:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,browserAutomationId:``,browserAutomationInputs:{},safetyMode:`suggest_only`,timeoutSeconds:`1800`,conversationMode:`new_session`,notificationPolicy:`attention`,completionWebhookUrl:``,disableAfterFailures:`3`},Ze=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function Qe(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;if(e.triggerMode===`manual`)o={kind:`manual`};else if(e.triggerMode===`once`)o={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)o={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`taskBlocked`)o={kind:`event`,eventType:`task.attention_required.v2`,source:`tasks`,payloadMatch:{reason:`blocked`}};else if(e.triggerMode===`noteCreated`)o={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`workflowFailed`)o={kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}};else if(e.triggerMode===`sessionUpdated`)o={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;o={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else o=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:ze(e.intervalValue,e.intervalUnit)}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=K(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_automation`?`auto_apply`:e.safetyMode,u;return u=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{}}:e.actionMode===`browser_automation`?{kind:`browser_automation`,automationId:e.browserAutomationId.trim(),inputs:e.browserAutomationInputs}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{}},{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},...e.projectId.trim()?{projectId:e.projectId.trim()}:{},trigger:o,action:u,safety:{mode:l},conversationMode:e.conversationMode,notificationPolicy:e.notificationPolicy,...l===`auto_apply`&&e.completionWebhookUrl.trim()?{completionWebhookUrl:e.completionWebhookUrl.trim()}:{},reliability:{executionTimeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||1800),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function $e(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:Xe.time,weekday:Xe.weekday,cronExpr:e}}function et(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function tt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function nt(e){let t=e.payloadMatch;return e.eventType===`task.attention_required.v2`&&e.source===`tasks`&&t?.reason===`blocked`?{triggerMode:`taskBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`workflow.run.completed`&&e.source===`workflows`&&t?.status===`failed`?{triggerMode:`workflowFailed`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function rt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function it(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function at(e,t=[]){let n={triggerMode:`manual`};if(e.trigger.kind===`webhook`)n={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)n=nt(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=$e(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...et(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:tt(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?rt(r.input):{},o=e.reliability?.executionTimeoutSeconds??r.timeoutSeconds??e.reliability?.timeoutSeconds??(r.kind===`browser_automation`?600:1800);return{...Xe,...n,name:e.name,description:e.description??``,projectId:e.projectId??``,actionMode:r.kind,agentId:r.kind===`browser_automation`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserAutomationId:r.kind===`browser_automation`?r.automationId:``,browserAutomationInputs:r.kind===`browser_automation`?r.inputs??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?me(i.name,a):{},schemaInput:a,concurrency:r.kind===`workflow`&&r.concurrency?String(r.concurrency):``,maxSubagents:r.kind===`workflow`&&r.maxSubagents?String(r.maxSubagents):``},workflowInputValid:!0,safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(o),conversationMode:e.conversationMode??`new_session`,notificationPolicy:e.notificationPolicy??`attention`,completionWebhookUrl:e.completionWebhookUrl??``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function ot(e,t,n){let r=Qe(t,n),i=e.trigger.kind===`schedule`&&r.trigger.kind===`schedule`&&e.trigger.schedule.kind===r.trigger.schedule.kind?{...r.trigger,schedule:{...e.trigger.schedule,...r.trigger.schedule}}:r.trigger,a=r.action;return e.action.kind===`agent`&&r.action.kind===`agent`?a={...e.action,...r.action,agentId:r.action.agentId}:e.action.kind===`workflow`&&r.action.kind===`workflow`?a={...e.action,...r.action,agentId:r.action.agentId,input:r.action.input,goal:r.action.goal,concurrency:r.action.concurrency,maxSubagents:r.action.maxSubagents}:e.action.kind===`browser_automation`&&r.action.kind===`browser_automation`&&(a={...e.action,...r.action}),{...r,description:t.description.trim(),projectId:t.projectId.trim(),completionWebhookUrl:t.completionWebhookUrl.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}function st(e){return[`reminder`,`brief`,`review`,`followUp`].map(t=>{let n=e.scenarios[t];return{...n,requiresProject:t===`followUp`,form:{...Xe,name:n.name,instruction:t===`reminder`?``:n.instruction,triggerMode:t===`reminder`?`once`:t===`review`?`weekly`:`daily`,time:t===`brief`?`08:30`:t===`review`?`17:00`:`09:00`,weekday:`5`,notificationPolicy:`all`}}})}var Q=r(),ct=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-2 focus-visible:outline-accent`;function lt(e){let t=(0,ye.c)(99),{form:n,setForm:r,labels:i,projects:a,projectLocked:c,source:l,requiresProject:u}=e,d;t[0]===r?d=t[1]:(d=e=>r(t=>({...t,...e})),t[0]=r,t[1]=d);let f=d,p;t[2]!==i.experience.source||t[3]!==l?(p=(0,Q.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[i.experience.source,`: `,l]}),t[2]=i.experience.source,t[3]=l,t[4]=p):p=t[4];let m;t[5]===f?m=t[6]:(m=e=>f({name:e.target.value}),t[5]=f,t[6]=m);let h;t[7]!==n.name||t[8]!==m?(h=(0,Q.jsx)(`input`,{className:ct,value:n.name,onChange:m}),t[7]=n.name,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==i.form.name||t[11]!==h?(g=(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.name,h]}),t[10]=i.form.name,t[11]=h,t[12]=g):g=t[12];let _;t[13]===f?_=t[14]:(_=e=>f({instruction:e.target.value}),t[13]=f,t[14]=_);let v;t[15]!==n.instruction||t[16]!==_?(v=(0,Q.jsx)(`textarea`,{className:ct,rows:5,value:n.instruction,onChange:_}),t[15]=n.instruction,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==i.info.task||t[19]!==v?(y=(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.info.task,v]}),t[18]=i.info.task,t[19]=v,t[20]=y):y=t[20];let b;t[21]!==n.projectId||t[22]!==i.form.noProject||t[23]!==i.form.project||t[24]!==c||t[25]!==a||t[26]!==f?(b=!c&&(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.project,(0,Q.jsxs)(o,{className:ct,value:n.projectId,onChange:e=>f({projectId:e.target.value}),children:[(0,Q.jsx)(s,{value:``,children:i.form.noProject}),a.map(ut)]})]}),t[21]=n.projectId,t[22]=i.form.noProject,t[23]=i.form.project,t[24]=c,t[25]=a,t[26]=f,t[27]=b):b=t[27];let x;t[28]!==n.projectId||t[29]!==i.experience.projectRequired||t[30]!==u?(x=u&&!n.projectId?(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:i.experience.projectRequired}):null,t[28]=n.projectId,t[29]=i.experience.projectRequired,t[30]=u,t[31]=x):x=t[31];let S;t[32]===f?S=t[33]:(S=e=>f({triggerMode:e.target.value}),t[32]=f,t[33]=S);let C;t[34]===i.trigger.once?C=t[35]:(C=(0,Q.jsx)(s,{value:`once`,children:i.trigger.once}),t[34]=i.trigger.once,t[35]=C);let w;t[36]===i.trigger.daily?w=t[37]:(w=(0,Q.jsx)(s,{value:`daily`,children:i.trigger.daily}),t[36]=i.trigger.daily,t[37]=w);let T;t[38]===i.trigger.weekly?T=t[39]:(T=(0,Q.jsx)(s,{value:`weekly`,children:i.trigger.weekly}),t[38]=i.trigger.weekly,t[39]=T);let ee;t[40]!==n.triggerMode||t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==T?(ee=(0,Q.jsxs)(o,{className:ct,value:n.triggerMode,onChange:S,children:[C,w,T]}),t[40]=n.triggerMode,t[41]=S,t[42]=C,t[43]=w,t[44]=T,t[45]=ee):ee=t[45];let E;t[46]!==i.form.trigger||t[47]!==ee?(E=(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.trigger,ee]}),t[46]=i.form.trigger,t[47]=ee,t[48]=E):E=t[48];let D;t[49]!==n.onceAt||t[50]!==n.time||t[51]!==n.triggerMode||t[52]!==i.form.onceAt||t[53]!==i.form.time||t[54]!==f?(D=n.triggerMode===`once`?(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.onceAt,(0,Q.jsx)(`input`,{type:`datetime-local`,className:ct,value:n.onceAt,onChange:e=>f({onceAt:e.target.value})})]}):(0,Q.jsxs)(`div`,{className:`grid gap-2 text-sm text-fg`,children:[(0,Q.jsx)(`span`,{children:i.form.time}),(0,Q.jsx)(de,{value:n.time,onChange:e=>f({time:e}),ariaLabel:i.form.time})]}),t[49]=n.onceAt,t[50]=n.time,t[51]=n.triggerMode,t[52]=i.form.onceAt,t[53]=i.form.time,t[54]=f,t[55]=D):D=t[55];let O;t[56]!==n.triggerMode||t[57]!==n.weekday||t[58]!==i.form.day||t[59]!==i.weekdays||t[60]!==f?(O=n.triggerMode===`weekly`&&(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.day,(0,Q.jsx)(o,{className:ct,value:n.weekday,onChange:e=>f({weekday:e.target.value}),children:[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`].map((e,t)=>(0,Q.jsx)(s,{value:String(t),children:i.weekdays[e]},e))})]}),t[56]=n.triggerMode,t[57]=n.weekday,t[58]=i.form.day,t[59]=i.weekdays,t[60]=f,t[61]=O):O=t[61];let k;t[62]!==E||t[63]!==D||t[64]!==O?(k=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[E,D,O]}),t[62]=E,t[63]=D,t[64]=O,t[65]=k):k=t[65];let te;t[66]!==n.onceAt||t[67]!==n.triggerMode||t[68]!==i.experience.futureTime?(te=n.triggerMode===`once`&&n.onceAt&&new Date(n.onceAt).getTime()<=Date.now()?(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-red-700 dark:text-red-300`,children:i.experience.futureTime}):null,t[66]=n.onceAt,t[67]=n.triggerMode,t[68]=i.experience.futureTime,t[69]=te):te=t[69];let ne;t[70]===i.experience.scheduleNote?ne=t[71]:(ne=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.experience.scheduleNote}),t[70]=i.experience.scheduleNote,t[71]=ne);let A;t[72]===f?A=t[73]:(A=e=>f({notificationPolicy:e.target.value}),t[72]=f,t[73]=A);let j;t[74]===i.draft.notifyAll?j=t[75]:(j=(0,Q.jsx)(s,{value:`all`,children:i.draft.notifyAll}),t[74]=i.draft.notifyAll,t[75]=j);let M;t[76]===i.draft.notifyAttention?M=t[77]:(M=(0,Q.jsx)(s,{value:`attention`,children:i.draft.notifyAttention}),t[76]=i.draft.notifyAttention,t[77]=M);let N;t[78]===i.draft.notifyNone?N=t[79]:(N=(0,Q.jsx)(s,{value:`none`,children:i.draft.notifyNone}),t[78]=i.draft.notifyNone,t[79]=N);let P;t[80]!==n.notificationPolicy||t[81]!==A||t[82]!==j||t[83]!==M||t[84]!==N?(P=(0,Q.jsxs)(o,{className:ct,value:n.notificationPolicy,onChange:A,children:[j,M,N]}),t[80]=n.notificationPolicy,t[81]=A,t[82]=j,t[83]=M,t[84]=N,t[85]=P):P=t[85];let F;t[86]!==i.draft.notifications||t[87]!==P?(F=(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.draft.notifications,P]}),t[86]=i.draft.notifications,t[87]=P,t[88]=F):F=t[88];let I;return t[89]!==x||t[90]!==k||t[91]!==p||t[92]!==te||t[93]!==ne||t[94]!==F||t[95]!==g||t[96]!==y||t[97]!==b?(I=(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[p,g,y,b,x,k,te,ne,F]}),t[89]=x,t[90]=k,t[91]=p,t[92]=te,t[93]=ne,t[94]=F,t[95]=g,t[96]=y,t[97]=b,t[98]=I):I=t[98],I}function ut(e){return(0,Q.jsx)(s,{value:e.id,children:e.name},e.id)}function dt(e,t){return t.reduce((t,n)=>n.automationId===e&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0)}function ft(e,t){let n=dt(e.id,t),r=!!(e.state.lastRunAtMs&&(!n||e.state.lastRunAtMs>n.createdAtMs)),i=r?e.state.lastRunStatus:n?.status??e.state.lastRunStatus;return i!==`failed`&&i!==`timeout`?null:`${i}:${(r?e.state.lastRunAtMs:n?.createdAtMs??e.state.lastRunAtMs)??`unknown`}`}function pt(e,t){return ft(e,t)!==null}var mt=`xopc.automations.dismissedExecutionIssues`;function ht(){if(typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(mt)??`{}`);return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return{}}}function gt(e,t,n){return e?Ue(e,n):t.never}function _t(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_automation`?`Browser automation: ${e.automationId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function vt(e){return e.safety?.mode??`auto_apply`}function yt(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`||e===`cancelling`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function bt(e,t){if(e==null)return t.never;if(e<1e3)return`${e}ms`;let n=Math.round(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function xt(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function St(e){return e.status===`failed`||e.status===`timeout`}function Ct(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||_t(e.action,t)}function wt(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function Tt(e){return!!wt(e)}function Et(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function Dt(e){return xt(e)?0:St(e)?1:e.status===`succeeded`?2:3}function Ot(e){return[...e].sort((e,t)=>{let n=Dt(e)-Dt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function kt(){let e=(0,ye.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Q.jsx)(C,{className:`h-4 w-36`}),(0,Q.jsx)(C,{className:`h-3 w-56 max-w-full`})]}),(0,Q.jsx)(C,{className:`h-7 w-20 rounded-full`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[t,(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(At)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(C,{className:`h-4 w-32`}),i=(0,Q.jsx)(C,{className:`mt-4 h-24 rounded-lg`}),e[2]=r,e[3]=i):(r=e[2],i=e[3]);let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:(0,Q.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[n,(0,Q.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[r,i,(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,Q.jsx)(C,{className:`h-12 rounded-lg`}),(0,Q.jsx)(C,{className:`h-12 rounded-lg`}),(0,Q.jsx)(C,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function At(e,t){return(0,Q.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(C,{className:`size-4 rounded-full`}),(0,Q.jsx)(C,{className:`h-4 w-32`}),(0,Q.jsx)(C,{className:`h-5 w-20 rounded-full`})]}),(0,Q.jsx)(C,{className:`mt-3 h-4 w-full`}),(0,Q.jsx)(C,{className:`mt-2 h-4 w-3/5`})]}),(0,Q.jsx)(C,{className:`h-8 w-24 rounded-md`})]})},t)}function jt({projectId:e,embedded:t=!1,title:n,subtitle:r}){let a=p(e=>e.language),c=m(a),l=c.automations,C=c.cron,ee=M(e=>e.setPageHeader),E=M(e=>e.clearPageHeader),[D,O]=i(),k=D.get(`run`)?.trim()??``,A=D.get(`automation`)?.trim()??``,N=D.get(`draft`)?.trim()??``,F=D.get(`action`)?.trim()??``,I=D.get(`projectId`)?.trim()??``,R=e?.trim()||I,z=!!e?.trim(),oe=D.get(`autogenerate`)===`1`,se=(0,J.useRef)(``),ce=D.get(`status`),H=ce===`active`||ce===`paused`||ce===`system`||ce===`attention`?ce:`all`,U=D.get(`q`)??``,W=e=>O(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`status`):n.set(`status`,e),n.delete(`automation`),n}),de=e=>O(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n.delete(`automation`),n},{replace:!0}),[G,fe]=(0,J.useState)(null),[me,K]=(0,J.useState)(!1),[he,q]=(0,J.useState)(`blank`),[ve,ye]=(0,J.useState)(null),[be,xe]=(0,J.useState)(!1),[Y,Se]=(0,J.useState)(Xe),[Ce,we]=(0,J.useState)(null),[Te,Ee]=(0,J.useState)(null),[De,Oe]=(0,J.useState)(!1),[X,Z]=(0,J.useState)(null),[ke,Ae]=(0,J.useState)(``),[je,Me]=(0,J.useState)(null),[Ne,Pe]=(0,J.useState)(!1),[Fe,Ie]=(0,J.useState)(!1),[Le,Re]=(0,J.useState)(R),[ze,Be]=(0,J.useState)(`new_session`),[Ve,He]=(0,J.useState)(`attention`),[Ue,We]=(0,J.useState)(null),[Ge,Ke]=(0,J.useState)(!1),[Je,Ye]=(0,J.useState)(!1),[Ze,$e]=(0,J.useState)(!1),[et,tt]=(0,J.useState)(null),[nt,rt]=(0,J.useState)(ht),ct=x([`automations`,R],()=>V.list(R?{projectId:R}:void 0),{refreshInterval:15e3}),ut=x([`automation-runs`,R],()=>V.runs(50,void 0,R?{projectId:R}:void 0),{refreshInterval:1e4}),gt=x(X?[`automation-history`,X,R]:null,()=>V.runs(50,X,R?{projectId:R}:void 0),{refreshInterval:1e4}),_t=x(Te?`automation-run-events:${Te}`:null,()=>V.runEvents(Te),{refreshInterval:5e3}),vt=x(`automation-workflow-definitions`,ue),yt=x(`automation-browser-automations`,()=>ge.list()),bt=x(`automation-chat-agents`,B),St=x(`automation-projects`,()=>P({sortBy:`name`,sortOrder:`asc`,limit:200})),wt=ct.isLoading&&!ct.data||ut.isLoading&&!ut.data,Dt=ct.data?.automations??[],At=(0,J.useMemo)(()=>Ot(ut.data?.runs??[]),[ut.data?.runs]),jt=(0,J.useMemo)(()=>Dt.filter(e=>!Tt(e)),[Dt]),Pt=(0,J.useMemo)(()=>Dt.filter(Tt),[Dt]),Ft=(0,J.useMemo)(()=>new Set(Pt.map(e=>e.id)),[Pt]),It=(0,J.useMemo)(()=>At.filter(e=>!Ft.has(e.automationId)),[At,Ft]),Rt=(0,J.useMemo)(()=>At.find(e=>e.id===Te)??gt.data?.runs.find(e=>e.id===Te)??null,[At,Te,gt.data]),zt=(0,J.useMemo)(()=>Dt.find(e=>e.id===X)??null,[Dt,X]),Bt=(0,J.useMemo)(()=>Dt.find(e=>e.id===ve)??null,[Dt,ve]),Vt=(0,J.useMemo)(()=>[...gt.data?.runs??At].filter(e=>e.automationId===X).sort((e,t)=>t.createdAtMs-e.createdAtMs),[At,X,gt.data]),Wt=_t.data?.events??[],Gt=(0,J.useMemo)(()=>It.filter(e=>!xt(e)&&e.readAtMs==null),[It]),Kt=U.trim().toLocaleLowerCase(),qt=(0,J.useMemo)(()=>(H===`system`?Pt:jt).filter(e=>H===`attention`&&!pt(e,It)||H===`active`&&!e.enabled||H===`paused`&&e.enabled?!1:Kt?[e.name,Et(e),Ct(e,l),qe(e.trigger,l,C,a)].some(e=>e.toLocaleLowerCase().includes(Kt)):!0),[C,H,l,a,Kt,Pt,jt,It]),Jt=(0,J.useMemo)(()=>vt.data??[],[vt.data]),Yt=(0,J.useMemo)(()=>(yt.data?.automations??[]).filter(e=>e.enabled),[yt.data]),Xt=bt.data?.items??[],$t=St.data?.items??[],en=(0,J.useMemo)(()=>Jt.find(e=>e.id===Y.workflowId.trim())??null,[Y.workflowId,Jt]),tn=(0,J.useMemo)(()=>Yt.find(e=>e.id===Y.browserAutomationId.trim())??null,[Yt,Y.browserAutomationId]),nn=Y.actionMode===`workflow`&&(!Y.workflowId.trim()||Jt.length>0&&!Jt.some(e=>e.id===Y.workflowId)),rn=Y.actionMode===`workflow`&&en?!pe(en,Y.workflowInput,Y.workflowInputValid).valid:!1,an=!!Y.name.trim()&&(Y.triggerMode!==`once`||Number.isFinite(new Date(Y.onceAt).getTime())&&(!!Bt||new Date(Y.onceAt).getTime()>Date.now()))&&(![`daily`,`weekly`].includes(Y.triggerMode)||/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(Y.time))&&(Y.triggerMode!==`event`||!!Y.eventType.trim()&&it(Y.eventPayloadMatch))&&(Y.actionMode===`workflow`?!nn&&!rn:Y.actionMode===`browser_automation`?tn!==null&&_e(tn,Y.browserAutomationInputs):!!Y.instruction.trim()),on=(0,J.useMemo)(()=>st(l),[l]),sn=(0,J.useMemo)(()=>jt.filter(e=>pt(e,It)),[jt,It]),cn=sn.some(e=>{let t=ft(e,It);return t!==null&&nt[e.id]!==t}),ln=(0,J.useCallback)(()=>{rt(e=>{let t={...e};for(let e of sn){let n=ft(e,It);n&&(t[e.id]=n)}try{window.localStorage.setItem(mt,JSON.stringify(t))}catch{}return t})},[sn,It]);(0,J.useEffect)(()=>{if(qt.length===0){Z(null);return}if(A&&qt.some(e=>e.id===A)){Z(A);return}X&&qt.some(e=>e.id===X)||Z(qt[0].id)},[A,qt,X]);let un=(0,J.useCallback)(async()=>{await Promise.all([ct.mutate(),ut.mutate(),gt.mutate(),_t.mutate()])},[ct.mutate,_t.mutate,ut.mutate,gt.mutate]),dn=(0,J.useCallback)(e=>{if(z){Z(null),Ee(null);return}O(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n.delete(`automation`),n.delete(`run`),n}),Z(null),Ee(null)},[z,O]);(0,J.useEffect)(()=>{z&&(Re(R),Se(e=>e.projectId===R?e:{...e,projectId:R}))},[R,z]);let fn=(0,J.useCallback)(e=>{if(ye(null),xe(!1),we(null),q(e),K(!0),e===`blank`){Se({...Xe,projectId:R});return}Ae(``),Me(null),Ie(!1),Re(R),Be(`new_session`),He(`attention`)},[R]),pn=e=>{fe(e),Se({...e.form,projectId:R}),ye(null),xe(!1),we(null),q(`quick`),K(!0)},mn=(0,J.useCallback)(e=>{Se(at(e,Jt)),ye(e.id),xe(!1),Z(null),q(`blank`),K(!0)},[Jt]),hn=(0,J.useCallback)(()=>{je&&(Se({...at(je.automation,Jt),projectId:Le,conversationMode:ze,notificationPolicy:Ve}),ye(null),xe(!0),q(`blank`))},[je,ze,Ve,Le,Jt]),gn=(0,J.useCallback)(async()=>{$e(!0),we(null);try{await un()}catch(e){we(e instanceof Error?e.message:String(e))}finally{$e(!1)}},[l.feedback.actionFailed,un]);(0,J.useEffect)(()=>{let e=Dt.find(e=>e.id===A);!e||!Tt(e)||H===`system`||O(e=>{let t=new URLSearchParams(e);return t.set(`status`,`system`),t},{replace:!0})},[A,Dt,H,O]),(0,J.useEffect)(()=>{F===`create`&&(fn(`blank`),O(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[F,fn,O]),(0,J.useEffect)(()=>{if(!N)return;let e=`${a}:${oe?`auto`:`seed`}:${N}`;se.current!==e&&(se.current=e,Ae(N),Me(null),Ie(!1),Re(R),q(`draft`),K(!0),O(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),oe&&(we(null),Pe(!0),V.draft({prompt:N,language:a}).then(e=>{Me(e.draft),Ie(!1)}).catch(e=>{we(e instanceof Error?e.message:String(e))}).finally(()=>{Pe(!1)})))},[oe,N,a,R,O]);let _n=(0,J.useCallback)(e=>{let t=At.find(t=>t.id===e)??gt.data?.runs.find(t=>t.id===e);if(!t||xt(t)||t.readAtMs!=null)return;let n=Date.now();ut.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),gt.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),V.markRunRead(e).catch(e=>{we(e instanceof Error?e.message:String(e)),ut.mutate(),gt.mutate()})},[At,ut.mutate,gt.data,gt.mutate]),vn=(0,J.useCallback)(e=>{_n(e),Ee(e),Oe(!0),O(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[_n,O]),yn=(0,J.useCallback)(e=>{Z(e);let t=dt(e,At);O(t=>{let n=new URLSearchParams(t);return n.set(`automation`,e),n},{replace:!0}),t&&t.readAtMs==null&&!xt(t)&&_n(t.id)},[_n,At,O]);(0,J.useEffect)(()=>{k&&(_n(k),Ee(k),Oe(!0))},[_n,k]),(0,J.useEffect)(()=>{We(null),Ye(!1)},[Te]);async function bn(){if(we(null),Y.triggerMode===`once`&&!Bt&&new Date(Y.onceAt).getTime()<=Date.now()){we(l.experience.futureTime);return}if(!(!an||et)&&!(he===`quick`&&G?.requiresProject&&!Y.projectId)){if(be&&je){tt(`draft:edit`);try{let e=Qe(Y,en),{simulation:t}=await V.simulate(e);Me({...je,automation:e,simulation:t}),Re(Y.projectId),Be(Y.conversationMode),He(Y.notificationPolicy),Ie(!1),xe(!1),q(`draft`)}catch(e){we(e instanceof Error?e.message:String(e))}finally{tt(null)}return}if(Bt){let e=Bt.id;await xn(`automation:${e}:edit`,()=>V.update(e,ot(Bt,Y,en)))&&(K(!1),ye(null),Z(e));return}tt(`automation:create`);try{let e=Qe(Y,en),{automation:t}=await V.create(e);Se(Xe),K(!1),O(e=>{let n=new URLSearchParams(e);return n.delete(`status`),n.delete(`q`),n.delete(`run`),n.set(`automation`,t.id),z||(t.projectId?n.set(`projectId`,t.projectId):n.delete(`projectId`)),n}),await un(),Z(t.id)}catch(e){we(e instanceof Error?e.message:String(e))}finally{tt(null)}}}async function xn(e,t){we(null),tt(e);try{return await t(),await un(),!0}catch(e){return we(e instanceof Error?e.message:String(e)),!1}finally{tt(null)}}async function Sn(){await xn(`runs:read-all`,()=>V.markAllRunsRead(R||void 0))}async function Cn(){let e=ke.trim();if(e){we(null),Pe(!0);try{Me((await V.draft({prompt:e,language:a})).draft),Ie(!1)}catch(e){we(e instanceof Error?e.message:String(e))}finally{Pe(!1)}}}async function wn(){if(!je)return;let e=``,t=``;await xn(`draft:publish`,async()=>{let{automation:n}=await V.create({...je.automation,...Le?{projectId:Le}:{projectId:void 0},conversationMode:ze,notificationPolicy:Ve});Me(null),Ae(``),Ie(!1),K(!1),W(`all`),de(``),e=n.id,t=n.projectId??``})&&e&&(dn(t),Z(e))}async function Tn(){if(!je)return;let e=``,t=``,n=``;await xn(`draft:test`,async()=>{let{automation:r}=await V.create({...je.automation,...Le?{projectId:Le}:{projectId:void 0},conversationMode:ze,notificationPolicy:Ve,enabled:!1}),{run:i}=await V.runNow(r.id);e=r.id,t=r.projectId??``,n=i.id,Me(null),Ae(``),Ie(!1),K(!1),W(`all`),de(``)})&&e&&n&&(dn(t),Z(e),vn(n))}async function En(e){we(null),Ke(!0),We(null),Ye(!1);try{We((await V.repairDraft(e.id,{language:a})).repair)}catch(e){we(e instanceof Error?e.message:String(e))}finally{Ke(!1)}}async function Dn(e){Ue&&await xn(`run:${e.id}:repair`,async()=>{await V.update(e.automationId,Ue.patch),We(null),Ye(!1)})}let On=(0,J.useMemo)(()=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(le,{className:`size-9 shrink-0 p-0`,loading:Ze,label:l.refresh,onClick:gn}),(0,Q.jsxs)(S,{variant:`primary`,onClick:()=>fn(`draft`),children:[(0,Q.jsx)(u,{className:`size-4`}),l.new]})]}),[l.new,l.refresh,fn,Ze,gn]);return(0,J.useLayoutEffect)(()=>{if(!t)return ee({startExtra:null,main:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:l.title}),end:On}),()=>E()},[E,t,On,l.title,ee]),(0,Q.jsxs)(`div`,{className:f(`flex min-h-0 min-w-0 flex-1 flex-col`,t?`bg-transparent`:`bg-surface-panel`),children:[(0,Q.jsxs)(`div`,{className:f(`flex w-full flex-col gap-4`,t?`py-1`:`mx-auto max-w-[96rem] px-4 py-7 sm:px-6 lg:px-8 lg:py-9`),children:[t?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(L,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n||l.title})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r||l.subtitle})]}),On]}):null,Ce||ct.error||ut.error?(0,Q.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:Ce||l.feedback.actionFailed}):null,!wt&&!ct.error&&jt.length===0&&H!==`system`?(0,Q.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-6`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:l.experience.scenes}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.experience.scenesDescription}),(0,Q.jsx)(Mt,{templates:on,labels:l,onSelect:pn}),(0,Q.jsx)(S,{className:`mt-4`,variant:`ghost`,onClick:()=>fn(`draft`),children:l.experience.custom})]}):null,!wt&&cn&&H!==`system`?(0,Q.jsxs)(`div`,{className:`flex items-center rounded-lg border border-red-500/20 bg-red-500/5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>W(`attention`),className:`flex min-w-0 flex-1 items-center gap-3 rounded-l-lg px-4 py-3 text-left focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Q.jsx)(ne,{className:`size-4 shrink-0 text-red-700 dark:text-red-300`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 text-sm text-fg`,children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[l.experience.executionIssues,` · `,sn.length]}),(0,Q.jsx)(`span`,{className:`ml-2 text-fg-muted`,children:l.experience.issuesDescription})]})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:ln,className:`mr-2 rounded-md p-2 text-fg-muted hover:bg-red-500/10 hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l.close,title:l.close,children:(0,Q.jsx)(d,{className:`size-4`,"aria-hidden":!0})})]}):null,wt?(0,Q.jsx)(kt,{}):jt.length>0||H===`system`?(0,Q.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[minmax(18rem,0.8fr)_minmax(0,1.5fr)]`,children:[(0,Q.jsxs)(`aside`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle p-3`,children:[z?null:(0,Q.jsxs)(o,{"aria-label":l.filters.project,className:$,value:R,onChange:e=>dn(e.target.value),children:[(0,Q.jsx)(s,{value:``,children:l.filters.allProjects}),$t.map(e=>(0,Q.jsx)(s,{value:e.id,children:e.name},e.id))]}),(0,Q.jsxs)(`label`,{className:f(`flex items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg-muted focus-within:border-accent`,!z&&`mt-2`),children:[(0,Q.jsx)(re,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:U,onChange:e=>de(e.target.value),placeholder:l.filters.search,"aria-label":l.filters.search})]}),(0,Q.jsxs)(`nav`,{className:`mt-3 flex flex-wrap items-center gap-1`,"aria-label":l.filters.status,children:[[{id:`all`,label:l.filters.all},{id:`active`,label:l.filters.active},{id:`paused`,label:l.paused},{id:`attention`,label:l.experience.executionIssues}].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:f(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,H===e.id&&`bg-surface-hover text-fg`),onClick:()=>W(e.id),"aria-pressed":H===e.id,children:e.label},e.id)),(0,Q.jsxs)(w,{children:[(0,Q.jsx)(te,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:f(`ml-auto rounded-md p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H===`system`&&`bg-surface-hover text-fg`),"aria-label":l.system.title,children:(0,Q.jsx)(ae,{className:`size-4`})})}),(0,Q.jsx)(ie,{children:(0,Q.jsx)(T,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,Q.jsxs)(j,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>W(`system`),children:[l.system.title,` `,Pt.length]})})})]})]}),Gt.length>0&&H!==`system`?(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 rounded-md bg-accent/8 px-2.5 py-1.5 text-xs text-accent-fg`,children:[(0,Q.jsxs)(`span`,{children:[l.filters.unread,` · `,Gt.length]}),(0,Q.jsx)(`button`,{type:`button`,className:`font-medium hover:underline`,disabled:et===`runs:read-all`,onClick:()=>void Sn(),children:l.filters.markAllRead})]}):null]}),(0,Q.jsx)(Lt,{automations:qt,runs:H===`system`?At:It,labels:l,cronLabels:C,language:a,selectedAutomationId:X,onOpenDetails:yn})]}),zt?(0,Q.jsx)(Ut,{automation:zt,runs:Vt,runsLoading:gt.isLoading,runsError:gt.error?l.feedback.actionFailed:void 0,labels:l,cronLabels:C,language:a,projects:$t,busyAction:et,onEdit:mn,onSelectRun:vn,onAction:xn},zt.id):(0,Q.jsx)(Zt,{icon:(0,Q.jsx)(L,{className:`size-5`}),title:l.empty.filtered})]}):null,!wt&&jt.length>0?(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(S,{variant:`ghost`,onClick:()=>fn(`draft`),children:[(0,Q.jsx)(u,{className:`size-4`,"aria-hidden":!0}),l.experience.discover]})}):null]}),(0,Q.jsx)(b,{open:me,onOpenChange:e=>{K(e),e||(ye(null),xe(!1))},children:(0,Q.jsxs)(_,{children:[(0,Q.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Q.jsxs)(v,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(y,{className:`text-base font-semibold text-fg`,children:he===`draft`?l.draft.title:Bt?l.editTitle:be?l.draft.editTitle:l.createTitle}),(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,"aria-label":l.close,children:(0,Q.jsx)(d,{className:`size-4`})})})]}),Ce?(0,Q.jsx)(`p`,{role:`alert`,className:`px-5 py-2 text-sm text-red-700 dark:text-red-300`,children:Ce}):null,he===`draft`?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Q.jsx)(Nt,{labels:l,prompt:ke,draft:je,loading:Ne,approved:Fe,publishBusy:et===`draft:publish`,testBusy:et===`draft:test`,templates:on,projects:$t,projectId:Le,conversationMode:ze,notificationPolicy:Ve,onPromptChange:Ae,onGenerate:Cn,onEdit:hn,onPublish:wn,onTest:Tn,onProjectChange:Re,onConversationModeChange:Be,onNotificationPolicyChange:He,projectLocked:z,onApprovedChange:Ie,onDiscard:()=>{Me(null),Ie(!1)},onTemplateSelect:e=>{pn(e),Se({...e.form,projectId:Le})},onOpenAdvanced:()=>{Se({...Xe,projectId:Le,conversationMode:ze,notificationPolicy:Ve}),q(`blank`)}})}):(0,Q.jsxs)(Q.Fragment,{children:[he===`quick`&&G?(0,Q.jsx)(lt,{form:Y,setForm:Se,labels:l,projects:$t,projectLocked:z,source:G.source,requiresProject:G.requiresProject}):(0,Q.jsx)(Qt,{form:Y,labels:l,setForm:Se,projects:$t,workflowDefinitions:Jt,selectedWorkflow:en,workflowsLoading:vt.isLoading,browserAutomations:Yt,selectedBrowserAutomation:tn,browserAutomationsLoading:yt.isLoading,agentOptions:Xt,agentsLoading:bt.isLoading,language:a,projectLocked:z}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-edge px-5 py-4`,children:[he===`quick`?(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>q(`blank`),children:l.draft.advancedCreate}):null,be?(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>{xe(!1),q(`draft`)},children:l.cancel}):(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,children:l.cancel})}),(0,Q.jsx)(S,{variant:`primary`,onClick:bn,disabled:!an||!!et||he===`quick`&&!!G?.requiresProject&&!Y.projectId,children:et===`automation:create`||et===`draft:edit`||Bt&&et===`automation:${Bt.id}:edit`?l.feedback.working:Bt||be?l.save:l.experience.createEnabled})]})]})]})]})}),(0,Q.jsx)(b,{open:De&&!!Rt,onOpenChange:e=>{Oe(e),!e&&O(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Q.jsxs)(_,{children:[(0,Q.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Q.jsxs)(v,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-66 flex h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Q.jsx)(y,{className:`truncate text-base font-semibold text-fg`,children:Rt?.automationName??l.dashboard.result}),(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,"aria-label":l.close,children:(0,Q.jsx)(d,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Q.jsx)(Ht,{className:`rounded-none border-0`,run:Rt,events:Wt,labels:l,cronLabels:C,language:a,loading:_t.isLoading,repairDraft:Ue,repairLoading:Ge,repairApproved:Je,busyAction:et,onRepairApprovedChange:Ye,onSuggestRepair:En,onApplyRepair:Dn})})]})]})})]})}function Mt(e){let t=(0,ye.c)(9),{templates:n,labels:r,onSelect:i}=e,a;if(t[0]!==r||t[1]!==i||t[2]!==n){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge-subtle bg-surface-panel p-4 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Q.jsx)(k,{className:`mb-3 size-4 text-accent-fg`,"aria-hidden":!0}),(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.description}),(0,Q.jsxs)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:[r.experience.source,`: `,e.source]})]},e.name),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=i,t[2]=n,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,Q.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:a}),t[7]=a,t[8]=o),o}function Nt(e){let t=(0,ye.c)(110),{labels:n,prompt:r,draft:i,loading:a,approved:c,publishBusy:l,testBusy:u,templates:d,projects:p,projectId:m,conversationMode:h,notificationPolicy:g,onPromptChange:_,onGenerate:v,onEdit:y,onPublish:b,onTest:x,onProjectChange:C,onConversationModeChange:w,onNotificationPolicyChange:T,onApprovedChange:ee,onDiscard:E,onTemplateSelect:O,onOpenAdvanced:k,projectLocked:te}=e,ne=l===void 0?!1:l,A=u===void 0?!1:u,j=te===void 0?!1:te,M=!!(i&&i.simulation.requiredConfirmations.length>0),N;t[0]!==i||t[1]!==n.draft.advancedCreate||t[2]!==n.draft.suggestions||t[3]!==n.draft.suggestionsDescription||t[4]!==n.experience||t[5]!==k||t[6]!==O||t[7]!==d?(N=i?null:(0,Q.jsxs)(`div`,{className:`mb-5 border-b border-edge-subtle pb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.draft.suggestions}),(0,Q.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n.draft.suggestionsDescription})]}),(0,Q.jsx)(S,{variant:`ghost`,onClick:k,children:n.draft.advancedCreate})]}),(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:d.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:`focus-visible:ring-2 focus-visible:ring-accent rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>O(e),children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.experience.source,`: `,e.source]})]},e.name))})]}),t[0]=i,t[1]=n.draft.advancedCreate,t[2]=n.draft.suggestions,t[3]=n.draft.suggestionsDescription,t[4]=n.experience,t[5]=k,t[6]=O,t[7]=d,t[8]=N):N=t[8];let P;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(R,{className:`size-4 text-accent`}),t[9]=P):P=t[9];let I;t[10]===n.draft.title?I=t[11]:(I=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[P,n.draft.title]}),t[10]=n.draft.title,t[11]=I);let L;t[12]===n.draft.subtitle?L=t[13]:(L=(0,Q.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[12]=n.draft.subtitle,t[13]=L);let z;t[14]!==I||t[15]!==L?(z=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[I,L]}),t[14]=I,t[15]=L,t[16]=z):z=t[16];let B;t[17]!==a||t[18]!==r?(B=a||!r.trim(),t[17]=a,t[18]=r,t[19]=B):B=t[19];let re;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(R,{className:`size-4`}),t[20]=re):re=t[20];let ie=a?n.draft.generating:n.draft.generate,V;t[21]!==v||t[22]!==ie||t[23]!==B?(V=(0,Q.jsxs)(S,{variant:`primary`,onClick:v,disabled:B,children:[re,ie]}),t[21]=v,t[22]=ie,t[23]=B,t[24]=V):V=t[24];let ae;t[25]!==V||t[26]!==z?(ae=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[z,V]}),t[25]=V,t[26]=z,t[27]=ae):ae=t[27];let oe;t[28]===_?oe=t[29]:(oe=e=>_(e.target.value),t[28]=_,t[29]=oe);let se;t[30]!==n.draft.placeholder||t[31]!==n.draft.title||t[32]!==r||t[33]!==oe?(se=(0,Q.jsx)(`textarea`,{"aria-label":n.draft.title,className:`mt-4 min-h-20 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:oe,placeholder:n.draft.placeholder}),t[30]=n.draft.placeholder,t[31]=n.draft.title,t[32]=r,t[33]=oe,t[34]=se):se=t[34];let ce=j?`sm:grid-cols-2`:`sm:grid-cols-3`,le;t[35]===ce?le=t[36]:(le=f(`mt-3 grid gap-3`,ce),t[35]=ce,t[36]=le);let ue;t[37]!==n.draft.noProject||t[38]!==n.draft.project||t[39]!==C||t[40]!==m||t[41]!==j||t[42]!==p?(ue=j?null:(0,Q.jsx)(nn,{label:n.draft.project,children:(0,Q.jsxs)(o,{className:$,value:m,onChange:e=>C(e.target.value),children:[(0,Q.jsx)(s,{value:``,children:n.draft.noProject}),p.map(Pt)]})}),t[37]=n.draft.noProject,t[38]=n.draft.project,t[39]=C,t[40]=m,t[41]=j,t[42]=p,t[43]=ue):ue=t[43];let H;t[44]===w?H=t[45]:(H=e=>w(e.target.value),t[44]=w,t[45]=H);let U;t[46]===n.draft.newConversation?U=t[47]:(U=(0,Q.jsx)(s,{value:`new_session`,children:n.draft.newConversation}),t[46]=n.draft.newConversation,t[47]=U);let W;t[48]===n.draft.continuousConversation?W=t[49]:(W=(0,Q.jsx)(s,{value:`continuous`,children:n.draft.continuousConversation}),t[48]=n.draft.continuousConversation,t[49]=W);let de;t[50]!==h||t[51]!==H||t[52]!==U||t[53]!==W?(de=(0,Q.jsxs)(o,{className:$,value:h,onChange:H,children:[U,W]}),t[50]=h,t[51]=H,t[52]=U,t[53]=W,t[54]=de):de=t[54];let G;t[55]!==n.draft.conversation||t[56]!==de?(G=(0,Q.jsx)(nn,{label:n.draft.conversation,children:de}),t[55]=n.draft.conversation,t[56]=de,t[57]=G):G=t[57];let fe;t[58]===T?fe=t[59]:(fe=e=>T(e.target.value),t[58]=T,t[59]=fe);let pe;t[60]===n.draft.notifyAttention?pe=t[61]:(pe=(0,Q.jsx)(s,{value:`attention`,children:n.draft.notifyAttention}),t[60]=n.draft.notifyAttention,t[61]=pe);let me;t[62]===n.draft.notifyAll?me=t[63]:(me=(0,Q.jsx)(s,{value:`all`,children:n.draft.notifyAll}),t[62]=n.draft.notifyAll,t[63]=me);let K;t[64]===n.draft.notifyNone?K=t[65]:(K=(0,Q.jsx)(s,{value:`none`,children:n.draft.notifyNone}),t[64]=n.draft.notifyNone,t[65]=K);let he;t[66]!==g||t[67]!==fe||t[68]!==pe||t[69]!==me||t[70]!==K?(he=(0,Q.jsxs)(o,{className:$,value:g,onChange:fe,children:[pe,me,K]}),t[66]=g,t[67]=fe,t[68]=pe,t[69]=me,t[70]=K,t[71]=he):he=t[71];let ge;t[72]!==n.draft.notifications||t[73]!==he?(ge=(0,Q.jsx)(nn,{label:n.draft.notifications,children:he}),t[72]=n.draft.notifications,t[73]=he,t[74]=ge):ge=t[74];let _e;t[75]!==le||t[76]!==ue||t[77]!==G||t[78]!==ge?(_e=(0,Q.jsxs)(`div`,{className:le,children:[ue,G,ge]}),t[75]=le,t[76]=ue,t[77]=G,t[78]=ge,t[79]=_e):_e=t[79];let q;t[80]!==c||t[81]!==i||t[82]!==n.draft.approval||t[83]!==n.draft.assumptions||t[84]!==n.draft.discard||t[85]!==n.draft.edit||t[86]!==n.draft.publish||t[87]!==n.draft.review||t[88]!==n.draft.risks||t[89]!==n.draft.safety||t[90]!==n.draft.testOnce||t[91]!==n.draft.testing||t[92]!==n.feedback||t[93]!==n.info||t[94]!==n.none||t[95]!==ee||t[96]!==E||t[97]!==y||t[98]!==b||t[99]!==x||t[100]!==ne||t[101]!==M||t[102]!==A?(q=i?(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,Q.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,Q.jsx)(Xt,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Q.jsx)(Xt,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,Q.jsx)(Ft,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Q.jsx)(Ft,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Q.jsx)(Ft,{title:n.draft.risks,items:i.risks,empty:n.none}),M?(0,Q.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:c,onChange:e=>ee(e.target.checked)}),(0,Q.jsx)(`span`,{children:n.draft.approval})]}):null,(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:E,children:n.draft.discard}),(0,Q.jsxs)(S,{variant:`secondary`,onClick:y,children:[(0,Q.jsx)(D,{className:`size-4`}),n.draft.edit]}),(0,Q.jsxs)(S,{variant:`secondary`,onClick:x,disabled:A||ne||M&&!c,children:[(0,Q.jsx)(F,{className:`size-4`}),A?n.draft.testing:n.draft.testOnce]}),(0,Q.jsx)(S,{variant:`primary`,onClick:b,disabled:ne||M&&!c,children:ne?n.feedback.working:n.draft.publish})]})]})]}):null,t[80]=c,t[81]=i,t[82]=n.draft.approval,t[83]=n.draft.assumptions,t[84]=n.draft.discard,t[85]=n.draft.edit,t[86]=n.draft.publish,t[87]=n.draft.review,t[88]=n.draft.risks,t[89]=n.draft.safety,t[90]=n.draft.testOnce,t[91]=n.draft.testing,t[92]=n.feedback,t[93]=n.info,t[94]=n.none,t[95]=ee,t[96]=E,t[97]=y,t[98]=b,t[99]=x,t[100]=ne,t[101]=M,t[102]=A,t[103]=q):q=t[103];let ve;return t[104]!==ae||t[105]!==se||t[106]!==_e||t[107]!==q||t[108]!==N?(ve=(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[N,ae,se,_e,q]}),t[104]=ae,t[105]=se,t[106]=_e,t[107]=q,t[108]=N,t[109]=ve):ve=t[109],ve}function Pt(e){return(0,Q.jsx)(s,{value:e.id,children:e.name},e.id)}function Ft(e){let t=(0,ye.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=r.length>0?r.map(It):(0,Q.jsx)(`li`,{className:`text-fg-muted`,children:i}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===o?s=t[6]:(s=(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm text-fg`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s?(c=(0,Q.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function It(e){return(0,Q.jsxs)(`li`,{children:[`- `,e]},e)}function Lt(e){let t=(0,ye.c)(20),{automations:n,runs:r,labels:i,cronLabels:a,language:o,selectedAutomationId:s,onOpenDetails:c}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(L,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Q.jsx)(Zt,{className:`rounded-none border-0 shadow-none`,icon:e,title:i.empty.filtered}),t[1]=i.empty.filtered,t[2]=n),n}let l;if(t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==r||t[9]!==s){let e;t[11]!==a||t[12]!==i||t[13]!==o||t[14]!==c||t[15]!==r||t[16]!==s?(e=e=>{let t=r.filter(t=>t.automationId===e.id).sort(Rt),n=t.find(xt),l=t[0];return(0,Q.jsxs)(`button`,{type:`button`,className:f(`block w-full p-3 text-left outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,s===e.id&&`bg-surface-hover`),style:{contentVisibility:`auto`,containIntrinsicSize:`auto 130px`},"aria-current":s===e.id?`true`:void 0,onClick:()=>c(e.id),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:f(`size-2 shrink-0 rounded-full`,n?`bg-blue-500`:pt(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.enabled?i.enabled:i.paused}),l&&l.readAtMs==null&&!xt(l)?(0,Q.jsx)(`span`,{className:`ml-auto size-2 shrink-0 rounded-full bg-blue-500`,children:(0,Q.jsx)(`span`,{className:`sr-only`,children:i.filters.unread})}):null]}),(0,Q.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center justify-between gap-2 pl-4 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`span`,{className:f(`line-clamp-2`,l?.error&&`text-red-700 dark:text-red-300`),children:l?l.error||l.summary||i.status[l.status]:e.state.lastError||(e.state.lastRunStatus?i.status[e.state.lastRunStatus]:i.experience.noRuns)}),l?.status?(0,Q.jsx)(`span`,{className:f(`shrink-0 rounded-full px-1.5 py-0.5`,yt(l.status)),children:i.status[l.status]}):null]}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1 pl-4 text-xs text-fg-muted`,children:[l?(0,Q.jsxs)(`div`,{children:[i.last,`: `,gt(l.createdAtMs,i,o)]}):null,(0,Q.jsx)(`div`,{children:e.enabled?`${i.next}: ${Je(e,i,o)}`:i.paused}),(0,Q.jsx)(`div`,{children:qe(e.trigger,i,a,o)})]})]},e.id)},t[11]=a,t[12]=i,t[13]=o,t[14]=c,t[15]=r,t[16]=s,t[17]=e):e=t[17],l=n.map(e),t[3]=n,t[4]=a,t[5]=i,t[6]=o,t[7]=c,t[8]=r,t[9]=s,t[10]=l}else l=t[10];let u;return t[18]===l?u=t[19]:(u=(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:l}),t[18]=l,t[19]=u),u}function Rt(e,t){return t.createdAtMs-e.createdAtMs}function zt(e,t){let n=t.events,r=e.data&&typeof e.data==`object`?e.data:{},i=typeof r.actionKind==`string`?r.actionKind:null,a=typeof r.status==`string`&&r.status in t.status?t.status[r.status]:null;switch(e.type){case`run.queued`:return e.message.toLowerCase().includes(`manual`)?n.manualQueued:e.message.toLowerCase().includes(`scheduled`)?n.scheduledQueued:n.eventQueued;case`run.started`:return n.runStarted;case`action.started`:return i?n.actionStarted.replace(`{kind}`,i):n.actionStartedFallback;case`action.completed`:return i?n.actionCompleted.replace(`{kind}`,i):n.actionCompletedFallback;case`action.failed`:return i?n.actionFailed.replace(`{kind}`,i):n.actionFailedFallback;case`completion_hook.started`:return n.completionHookStarted;case`completion_hook.completed`:return n.completionHookCompleted;case`completion_hook.failed`:return n.completionHookFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function Bt(e){let t=(0,ye.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[o,s]=(0,J.useState)(a===void 0?!1:a),c;t[0]===n?c=t[1]:(c=JSON.stringify(n,null,2),t[0]=n,t[1]=c);let l=c,u;t[2]===l?u=t[3]:(u=l.split(`
2
+ `),t[2]=l,t[3]=u);let d=u.length,p=l.length>720||d>18,m;t[4]!==p||t[5]!==l?(m=p?`${l.split(`
3
+ `).slice(0,10).join(`
4
+ `).trimEnd()}...`:l,t[4]=p,t[5]=l,t[6]=m):m=t[6];let h=m,g;t[7]!==o||t[8]!==p||t[9]!==r||t[10]!==i?(g=p?(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>s(Vt),"aria-expanded":o,children:[(0,Q.jsx)(`span`,{children:i}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[o?r.details.hideDetails:r.details.showDetails,(0,Q.jsx)(ee,{className:f(`size-3.5 transition-transform`,o&&`rotate-180`),"aria-hidden":!0})]})]}):(0,Q.jsx)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-fg-muted`,children:i}),t[7]=o,t[8]=p,t[9]=r,t[10]=i,t[11]=g):g=t[11];let _=o||!p?l:h,v;t[12]===_?v=t[13]:(v=(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-all px-2.5 pb-2 text-xs leading-relaxed text-fg-muted`,children:_}),t[12]=_,t[13]=v);let y;return t[14]!==g||t[15]!==v?(y=(0,Q.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[g,v]}),t[14]=g,t[15]=v,t[16]=y):y=t[16],y}function Vt(e){return!e}function Ht(e){let t=(0,ye.c)(148),{className:n,run:r,events:i,labels:o,cronLabels:s,language:u,loading:d,repairDraft:p,repairLoading:m,repairApproved:h,busyAction:g,onRepairApprovedChange:_,onSuggestRepair:v,onApplyRepair:y}=e;if(!r){let e;t[0]===n?e=t[1]:(e=f(`flex min-h-64 flex-col justify-center rounded-lg border border-edge-subtle bg-surface-base px-4 text-center text-sm text-fg-muted shadow-surface`,n),t[0]=n,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(oe,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let i;t[3]===o.selectRun?i=t[4]:(i=(0,Q.jsx)(`div`,{className:`mt-2`,children:o.selectRun}),t[3]=o.selectRun,t[4]=i);let a;return t[5]!==e||t[6]!==i?(a=(0,Q.jsxs)(`aside`,{className:e,children:[r,i]}),t[5]=e,t[6]=i,t[7]=a):a=t[7],a}let b=r.error||r.summary,x=r.conversationId?`/chat/${encodeURIComponent(r.conversationId)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,w=r.conversationId?o.runDetail.openConversation:o.runDetail.openWorkflow,T=r.conversationId?z:O,E=xt(r)?oe:r.status===`succeeded`?c:ne,D;t[8]===n?D=t[9]:(D=f(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=D);let k;t[10]===r.automationName?k=t[11]:(k=(0,Q.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=k);let te;t[12]===r.id?te=t[13]:(te=r.id.slice(0,8),t[12]=r.id,t[13]=te);let j;t[14]===te?j=t[15]:(j=(0,Q.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:te}),t[14]=te,t[15]=j);let M;t[16]!==k||t[17]!==j?(M=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[k,j]}),t[16]=k,t[17]=j,t[18]=M):M=t[18];let N;t[19]===r.status?N=t[20]:(N=f(`shrink-0 rounded-full px-2 py-0.5 text-xs`,yt(r.status)),t[19]=r.status,t[20]=N);let P=o.status[r.status],F;t[21]!==N||t[22]!==P?(F=(0,Q.jsx)(`span`,{className:N,children:P}),t[21]=N,t[22]=P,t[23]=F):F=t[23];let I;t[24]!==M||t[25]!==F?(I=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[M,F]}),t[24]=M,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==o||t[28]!==u||t[29]!==r.createdAtMs?(L=gt(r.createdAtMs,o,u),t[27]=o,t[28]=u,t[29]=r.createdAtMs,t[30]=L):L=t[30];let B;t[31]===L?B=t[32]:(B=(0,Q.jsx)(`span`,{children:L}),t[31]=L,t[32]=B);let re;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=re):re=t[33];let ie=o.details.duration,V;t[34]!==o||t[35]!==r.durationMs?(V=bt(r.durationMs,o),t[34]=o,t[35]=r.durationMs,t[36]=V):V=t[36];let ae;t[37]!==o.details.duration||t[38]!==V?(ae=(0,Q.jsxs)(`span`,{children:[ie,` `,V]}),t[37]=o.details.duration,t[38]=V,t[39]=ae):ae=t[39];let se;t[40]!==B||t[41]!==ae?(se=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[B,re,ae]}),t[40]=B,t[41]=ae,t[42]=se):se=t[42];let ce;t[43]!==o.repair||t[44]!==v||t[45]!==m||t[46]!==r?(ce=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsxs)(S,{variant:`secondary`,onClick:()=>v(r),disabled:m,children:[(0,Q.jsx)(R,{className:`size-4`}),m?o.repair.generating:o.repair.suggest]})}):null,t[43]=o.repair,t[44]=v,t[45]=m,t[46]=r,t[47]=ce):ce=t[47];let le;t[48]!==se||t[49]!==ce||t[50]!==I?(le=(0,Q.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[I,se,ce]}),t[48]=se,t[49]=ce,t[50]=I,t[51]=le):le=t[51];let ue;t[52]===r?ue=t[53]:(ue=xt(r)?`text-blue-500`:St(r)?`text-red-500`:r.status===`succeeded`?`text-emerald-500`:`text-fg-muted`,t[52]=r,t[53]=ue);let U;t[54]===ue?U=t[55]:(U=f(`size-4`,ue),t[54]=ue,t[55]=U);let W;t[56]!==E||t[57]!==U?(W=(0,Q.jsx)(E,{className:U}),t[56]=E,t[57]=U,t[58]=W):W=t[58];let de;t[59]!==o.runDetail.resultTitle||t[60]!==W?(de=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[W,o.runDetail.resultTitle]}),t[59]=o.runDetail.resultTitle,t[60]=W,t[61]=de):de=t[61];let G;t[62]!==T||t[63]!==w||t[64]!==x?(G=x?(0,Q.jsx)(S,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,Q.jsxs)(a,{to:x,children:[(0,Q.jsx)(T,{className:`size-3.5`}),w,(0,Q.jsx)(A,{className:`size-3.5`})]})}):null,t[62]=T,t[63]=w,t[64]=x,t[65]=G):G=t[65];let fe;t[66]!==de||t[67]!==G?(fe=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[de,G]}),t[66]=de,t[67]=G,t[68]=fe):fe=t[68];let pe=r.error&&`border-red-500/25 bg-red-500/5`,me;t[69]===pe?me=t[70]:(me=f(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,pe),t[69]=pe,t[70]=me);let K;t[71]!==o.runDetail.noResult||t[72]!==o.runDetail.resultPending||t[73]!==b||t[74]!==r?(K=b?r.error?(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:b}):(0,Q.jsx)(l,{content:b,compact:!0,className:`text-sm`}):(0,Q.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:xt(r)?o.runDetail.resultPending:o.runDetail.noResult}),t[71]=o.runDetail.noResult,t[72]=o.runDetail.resultPending,t[73]=b,t[74]=r,t[75]=K):K=t[75];let he;t[76]!==me||t[77]!==K?(he=(0,Q.jsx)(`div`,{className:me,children:K}),t[76]=me,t[77]=K,t[78]=he):he=t[78];let ge;t[79]!==fe||t[80]!==he?(ge=(0,Q.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[fe,he]}),t[79]=fe,t[80]=he,t[81]=ge):ge=t[81];let _e;t[82]===o.runDetail.runInfo?_e=t[83]:(_e=(0,Q.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.runDetail.runInfo}),t[82]=o.runDetail.runInfo,t[83]=_e);let q;t[84]!==s||t[85]!==o||t[86]!==u||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(q=r.manual?o.trigger.manual:qe(r.triggerSnapshot,o,s,u),t[84]=s,t[85]=o,t[86]=u,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=q):q=t[89];let ve;t[90]!==o.explain.whyRan||t[91]!==q?(ve=(0,Q.jsx)(Jt,{label:o.explain.whyRan,value:q}),t[90]=o.explain.whyRan,t[91]=q,t[92]=ve):ve=t[92];let J=o.details.started,be;t[93]!==o||t[94]!==u||t[95]!==r.startedAtMs?(be=gt(r.startedAtMs,o,u),t[93]=o,t[94]=u,t[95]=r.startedAtMs,t[96]=be):be=t[96];let xe;t[97]!==o.details.started||t[98]!==be?(xe=(0,Q.jsx)(Jt,{label:J,value:be}),t[97]=o.details.started,t[98]=be,t[99]=xe):xe=t[99];let Y;t[100]!==o.details.model||t[101]!==r.model?(Y=r.model?(0,Q.jsx)(Jt,{label:o.details.model,value:r.model}):null,t[100]=o.details.model,t[101]=r.model,t[102]=Y):Y=t[102];let Se;t[103]!==ve||t[104]!==xe||t[105]!==Y?(Se=(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[ve,xe,Y]}),t[103]=ve,t[104]=xe,t[105]=Y,t[106]=Se):Se=t[106];let Ce;t[107]!==_e||t[108]!==Se?(Ce=(0,Q.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[_e,Se]}),t[107]=_e,t[108]=Se,t[109]=Ce):Ce=t[109];let we;t[110]!==g||t[111]!==o||t[112]!==y||t[113]!==_||t[114]!==h||t[115]!==p||t[116]!==r?(we=p?(0,Q.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.repair.title}),(0,Q.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:p.explanation}),p.expectedEffect?(0,Q.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:p.expectedEffect}):null,(0,Q.jsx)(Ft,{title:o.repair.risks,items:p.risks,empty:o.none}),(0,Q.jsx)(Bt,{value:p.patch,labels:o,title:o.details.repairPatch}),p.requiresApproval?(0,Q.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:h,onChange:e=>_(e.target.checked)}),(0,Q.jsx)(`span`,{children:o.repair.approval})]}):null,(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsx)(S,{variant:`primary`,onClick:()=>y(r),disabled:g===`run:${r.id}:repair`||p.requiresApproval&&!h,children:g===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[110]=g,t[111]=o,t[112]=y,t[113]=_,t[114]=h,t[115]=p,t[116]=r,t[117]=we):we=t[117];let Te;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,Q.jsx)(H,{className:`size-4 shrink-0`}),t[118]=Te):Te=t[118];let Ee;t[119]===o.runDetail.technicalEvents?Ee=t[120]:(Ee=(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[Te,o.runDetail.technicalEvents]}),t[119]=o.runDetail.technicalEvents,t[120]=Ee);let De;t[121]!==i.length||t[122]!==o.runDetail.eventCount?(De=o.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=o.runDetail.eventCount,t[123]=De):De=t[123];let Oe;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Q.jsx)(ee,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=Oe):Oe=t[124];let X;t[125]===De?X=t[126]:(X=(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[De,Oe]}),t[125]=De,t[126]=X);let Z;t[127]!==Ee||t[128]!==X?(Z=(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 rounded-md outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[Ee,X]}),t[127]=Ee,t[128]=X,t[129]=Z):Z=t[129];let ke;t[130]===o.runDetail.technicalEventsDescription?ke=t[131]:(ke=(0,Q.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:o.runDetail.technicalEventsDescription}),t[130]=o.runDetail.technicalEventsDescription,t[131]=ke);let Ae;t[132]!==i||t[133]!==o||t[134]!==u||t[135]!==d?(Ae=(0,Q.jsx)(`div`,{className:`mt-4`,children:d?(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-label":o.loading,children:[(0,Q.jsx)(C,{className:`h-10 w-full`}),(0,Q.jsx)(C,{className:`h-10 w-4/5`}),(0,Q.jsx)(C,{className:`h-10 w-11/12`})]}):i.length===0?(0,Q.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.empty.events}):(0,Q.jsx)(`ol`,{className:`space-y-3`,children:i.map(e=>(0,Q.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,Q.jsx)(`span`,{className:f(`mt-1 size-2 rounded-full`,Yt(e.type))}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm text-fg`,children:zt(e,o)}),(0,Q.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[gt(e.createdAtMs,o,u),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,Q.jsxs)(`details`,{className:`group/event mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-2.5 py-2 text-xs font-medium text-fg-muted outline-none hover:text-fg`,children:[o.details.eventData,(0,Q.jsx)(ee,{className:`size-3.5 transition-transform group-open/event:rotate-180`})]}),(0,Q.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-all border-t border-edge/70 px-2.5 py-2 text-xs leading-relaxed text-fg-muted`,children:JSON.stringify(e.data,null,2)})]}):null]})]},e.id))})}),t[132]=i,t[133]=o,t[134]=u,t[135]=d,t[136]=Ae):Ae=t[136];let je;t[137]!==Z||t[138]!==ke||t[139]!==Ae?(je=(0,Q.jsxs)(`details`,{className:`group px-4 py-3`,children:[Z,ke,Ae]}),t[137]=Z,t[138]=ke,t[139]=Ae,t[140]=je):je=t[140];let Me;return t[141]!==D||t[142]!==le||t[143]!==ge||t[144]!==Ce||t[145]!==we||t[146]!==je?(Me=(0,Q.jsxs)(`aside`,{className:D,children:[le,ge,Ce,we,je]}),t[141]=D,t[142]=le,t[143]=ge,t[144]=Ce,t[145]=we,t[146]=je,t[147]=Me):Me=t[147],Me}function Ut(e){let t=(0,ye.c)(113),{automation:n,runs:r,runsLoading:i,runsError:a,labels:o,cronLabels:s,language:u,projects:d,busyAction:p,onEdit:m,onSelectRun:h,onAction:g}=e,_=p===`automation:${n.id}:run`,v=p===`automation:${n.id}:toggle`,y=p===`automation:${n.id}:delete`,b;t[0]===n?b=t[1]:(b=Tt(n),t[0]=n,t[1]=b);let x=b,ee;t[2]===n.name?ee=t[3]:(ee=(0,Q.jsx)(`h2`,{className:`truncate text-lg font-semibold text-fg`,children:n.name}),t[2]=n.name,t[3]=ee);let O=n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`,k;t[4]===O?k=t[5]:(k=f(`shrink-0 rounded-full px-2 py-0.5 text-xs`,O),t[4]=O,t[5]=k);let ne=n.enabled?o.enabled:o.paused,A;t[6]!==k||t[7]!==ne?(A=(0,Q.jsx)(`span`,{className:k,children:ne}),t[6]=k,t[7]=ne,t[8]=A):A=t[8];let M;t[9]!==ee||t[10]!==A?(M=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[ee,A]}),t[9]=ee,t[10]=A,t[11]=M):M=t[11];let N;t[12]===n?N=t[13]:(N=Et(n)?(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Et(n)}):null,t[12]=n,t[13]=N);let P;t[14]!==M||t[15]!==N?(P=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[M,N]}),t[14]=M,t[15]=N,t[16]=P):P=t[16];let L;t[17]!==n||t[18]!==p||t[19]!==y||t[20]!==o.dashboard.delete||t[21]!==o.dashboard.deleted||t[22]!==o.dashboard.pause||t[23]!==o.dashboard.resume||t[24]!==o.dashboard.resumed||t[25]!==o.dashboard.runNow||t[26]!==o.details||t[27]!==o.edit||t[28]!==o.experience.deleteConfirm||t[29]!==o.feedback||t[30]!==g||t[31]!==m||t[32]!==x||t[33]!==_||t[34]!==v?(L=x?null:(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsxs)(S,{variant:`secondary`,disabled:p!==null,onClick:()=>void g(`automation:${n.id}:toggle`,()=>n.enabled?V.pause(n.id):V.resume(n.id),n.enabled?o.feedback.paused:o.dashboard.resumed),children:[v?(0,Q.jsx)(E,{className:`size-4 animate-spin`}):n.enabled?(0,Q.jsx)(I,{className:`size-4`}):(0,Q.jsx)(F,{className:`size-4`}),n.enabled?o.dashboard.pause:o.dashboard.resume]}),(0,Q.jsxs)(S,{variant:`primary`,disabled:p!==null,onClick:()=>void g(`automation:${n.id}:run`,()=>V.runNow(n.id),o.feedback.rerunQueued),children:[_?(0,Q.jsx)(E,{className:`size-4 animate-spin`}):(0,Q.jsx)(F,{className:`size-4`}),o.dashboard.runNow]}),(0,Q.jsxs)(w,{children:[(0,Q.jsx)(te,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,className:`size-9 p-0`,"aria-label":o.details.moreActions,children:(0,Q.jsx)(ae,{className:`size-4`})})}),(0,Q.jsx)(ie,{children:(0,Q.jsxs)(T,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Q.jsxs)(j,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>m(n),children:[(0,Q.jsx)(D,{className:`size-4`}),o.edit]}),(0,Q.jsxs)(j,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-red-700 outline-none hover:bg-red-500/10 dark:text-red-300`,disabled:p!==null,onSelect:()=>{window.confirm(o.experience.deleteConfirm)&&g(`automation:${n.id}:delete`,()=>V.remove(n.id),o.dashboard.deleted)},children:[y?(0,Q.jsx)(E,{className:`size-4 animate-spin`}):(0,Q.jsx)(se,{className:`size-4`}),o.dashboard.delete]})]})})]})]}),t[17]=n,t[18]=p,t[19]=y,t[20]=o.dashboard.delete,t[21]=o.dashboard.deleted,t[22]=o.dashboard.pause,t[23]=o.dashboard.resume,t[24]=o.dashboard.resumed,t[25]=o.dashboard.runNow,t[26]=o.details,t[27]=o.edit,t[28]=o.experience.deleteConfirm,t[29]=o.feedback,t[30]=g,t[31]=m,t[32]=x,t[33]=_,t[34]=v,t[35]=L):L=t[35];let R;t[36]!==L||t[37]!==P?(R=(0,Q.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[P,L]}),t[36]=L,t[37]=P,t[38]=R):R=t[38];let z;t[39]===o.dashboard.latestResult?z=t[40]:(z=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.dashboard.latestResult}),t[39]=o.dashboard.latestResult,t[40]=z);let B;t[41]!==o.experience.viewResult||t[42]!==h||t[43]!==r[0]?(B=r[0]?(0,Q.jsx)(S,{variant:`secondary`,onClick:()=>h(r[0].id),children:o.experience.viewResult}):null,t[41]=o.experience.viewResult,t[42]=h,t[43]=r[0],t[44]=B):B=t[44];let re;t[45]!==z||t[46]!==B?(re=(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[z,B]}),t[45]=z,t[46]=B,t[47]=re):re=t[47];let ce;t[48]!==o||t[49]!==u||t[50]!==r[0]||t[51]!==a||t[52]!==i?(ce=a?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-red-700 dark:text-red-300`,children:a}):i?(0,Q.jsx)(C,{className:`h-28 w-full`}):r[0]?(0,Q.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge-subtle bg-surface-base p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{className:f(`rounded-full px-2 py-0.5`,yt(r[0].status)),children:o.status[r[0].status]}),gt(r[0].createdAtMs,o,u)]}),(0,Q.jsx)(l,{content:r[0].error||r[0].summary||(xt(r[0])?o.runDetail.resultPending:o.runDetail.noResult),compact:!0})]}):(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.experience.noRuns}),t[48]=o,t[49]=u,t[50]=r[0],t[51]=a,t[52]=i,t[53]=ce):ce=t[53];let le;t[54]!==n||t[55]!==o||t[56]!==u?(le=n.enabled?`${o.next}: ${Je(n,o,u)}`:o.paused,t[54]=n,t[55]=o,t[56]=u,t[57]=le):le=t[57];let ue;t[58]===le?ue=t[59]:(ue=(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:le}),t[58]=le,t[59]=ue);let H;t[60]!==re||t[61]!==ce||t[62]!==ue?(H=(0,Q.jsxs)(`section`,{children:[re,ce,ue]}),t[60]=re,t[61]=ce,t[62]=ue,t[63]=H):H=t[63];let U;t[64]===o.dashboard.runHistory?U=t[65]:(U=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.dashboard.runHistory}),t[64]=o.dashboard.runHistory,t[65]=U);let W;t[66]===o.dashboard.runHistoryDescription?W=t[67]:(W=(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o.dashboard.runHistoryDescription}),t[66]=o.dashboard.runHistoryDescription,t[67]=W);let de;t[68]!==U||t[69]!==W?(de=(0,Q.jsxs)(`div`,{children:[U,W]}),t[68]=U,t[69]=W,t[70]=de):de=t[70];let G;t[71]===r.length?G=t[72]:(G=(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length}),t[71]=r.length,t[72]=G);let fe;t[73]!==de||t[74]!==G?(fe=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[de,G]}),t[73]=de,t[74]=G,t[75]=fe):fe=t[75];let pe;t[76]!==o||t[77]!==u||t[78]!==h||t[79]!==r||t[80]!==i?(pe=i?(0,Q.jsx)(C,{className:`h-24 w-full`}):r.length===0?(0,Q.jsx)(Zt,{className:`min-h-24 py-6`,icon:(0,Q.jsx)(oe,{className:`size-5`}),title:o.empty.runs}):(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:r.slice(0,8).map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:`block w-full p-3 text-left hover:bg-surface-hover`,onClick:()=>h(e.id),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,Q.jsx)(c,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Q.jsx)(oe,{className:`size-4 shrink-0 text-fg-muted`}),(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:gt(e.createdAtMs,o,u)})]}),(0,Q.jsx)(`span`,{className:f(`shrink-0 rounded-full px-2 py-0.5 text-xs`,yt(e.status)),children:o.status[e.status]})]}),(0,Q.jsx)(`p`,{className:f(`mt-1 line-clamp-2 pl-6 text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||_t(e.actionSnapshot,o)})]},e.id))}),t[76]=o,t[77]=u,t[78]=h,t[79]=r,t[80]=i,t[81]=pe):pe=t[81];let me;t[82]!==fe||t[83]!==pe?(me=(0,Q.jsxs)(`section`,{className:`min-w-0`,children:[fe,pe]}),t[82]=fe,t[83]=pe,t[84]=me):me=t[84];let K;t[85]===o.experience.settings?K=t[86]:(K=(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:o.experience.settings}),t[85]=o.experience.settings,t[86]=K);let he;t[87]!==n||t[88]!==o?(he=Ct(n,o),t[87]=n,t[88]=o,t[89]=he):he=t[89];let ge;t[90]===he?ge=t[91]:(ge=(0,Q.jsx)(l,{content:he,compact:!0}),t[90]=he,t[91]=ge);let _e;t[92]!==n||t[93]!==s||t[94]!==o||t[95]!==u||t[96]!==d?(_e=(0,Q.jsx)(Gt,{automation:n,labels:o,cronLabels:s,language:u,projects:d}),t[92]=n,t[93]=s,t[94]=o,t[95]=u,t[96]=d,t[97]=_e):_e=t[97];let q;t[98]!==ge||t[99]!==_e?(q=(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[ge,_e]}),t[98]=ge,t[99]=_e,t[100]=q):q=t[100];let ve;t[101]!==K||t[102]!==q?(ve=(0,Q.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle p-4`,children:[K,q]}),t[101]=K,t[102]=q,t[103]=ve):ve=t[103];let J;t[104]!==me||t[105]!==ve?(J=(0,Q.jsxs)(`div`,{className:`grid gap-5`,children:[me,ve]}),t[104]=me,t[105]=ve,t[106]=J):J=t[106];let be;t[107]!==H||t[108]!==J?(be=(0,Q.jsxs)(`div`,{className:`grid gap-5 p-5`,children:[H,J]}),t[107]=H,t[108]=J,t[109]=be):be=t[109];let xe;return t[110]!==R||t[111]!==be?(xe=(0,Q.jsxs)(`article`,{className:`min-w-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[R,be]}),t[110]=R,t[111]=be,t[112]=xe):xe=t[112],xe}function Wt(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function Gt(e){let t=(0,ye.c)(146),{automation:n,labels:r,cronLabels:i,language:a,projects:o}=e,s,c,l,u,d,f,p,m,h,g,_;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=vt(n),o;t[15]!==n||t[16]!==r||t[17]!==a?(o=Je(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=o):o=t[18];let v=o,y;t[19]!==n.state.nextRunAtMs||t[20]!==a?(y=n.state.nextRunAtMs?Ue(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=y):y=t[21];let b=y;if(t[22]!==n.trigger.eventType||t[23]!==n.trigger.kind||t[24]!==n.trigger.schedule||t[25]!==n.trigger.secretId||t[26]!==n.trigger.source||t[27]!==r.info.anchor||t[28]!==r.info.calendarSchedule||t[29]!==r.info.eventSource||t[30]!==r.info.eventType||t[31]!==r.info.expression||t[32]!==r.info.fixedInterval||t[33]!==r.info.oneTimeSchedule||t[34]!==r.info.rawInterval||t[35]!==r.info.scheduleType||t[36]!==r.info.timezone||t[37]!==r.info.webhookSecret||t[38]!==a){if(_=[],n.trigger.kind===`schedule`){let e=n.trigger.schedule,i=e.kind===`interval`?r.info.fixedInterval:e.kind===`cron`?r.info.calendarSchedule:r.info.oneTimeSchedule,o;if(t[40]!==r.info.scheduleType||t[41]!==i?(o={label:r.info.scheduleType,value:i},t[40]=r.info.scheduleType,t[41]=i,t[42]=o):o=t[42],_.push(o),e.kind===`interval`){let n=`${e.everyMs} ms`,i;if(t[43]!==r.info.rawInterval||t[44]!==n?(i={label:r.info.rawInterval,value:n},t[43]=r.info.rawInterval,t[44]=n,t[45]=i):i=t[45],_.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=Ue(e.anchorMs,a),t[46]=a,t[47]=e.anchorMs,t[48]=i):i=t[48];let o;t[49]!==r.info.anchor||t[50]!==i?(o={label:n,value:i},t[49]=r.info.anchor,t[50]=i,t[51]=o):o=t[51],_.push(o)}}else if(e.kind===`cron`){let n;if(t[52]!==r.info.expression||t[53]!==e.expr?(n={label:r.info.expression,value:e.expr},t[52]=r.info.expression,t[53]=e.expr,t[54]=n):n=t[54],_.push(n),e.tz){let n;t[55]!==r.info.timezone||t[56]!==e.tz?(n={label:r.info.timezone,value:e.tz},t[55]=r.info.timezone,t[56]=e.tz,t[57]=n):n=t[57],_.push(n)}}else{let n;t[58]!==r.info.oneTimeSchedule||t[59]!==e.at?(n={label:r.info.oneTimeSchedule,value:e.at},t[58]=r.info.oneTimeSchedule,t[59]=e.at,t[60]=n):n=t[60],_.push(n)}}else if(n.trigger.kind===`event`){let e;if(t[61]!==n.trigger.eventType||t[62]!==r.info.eventType?(e={label:r.info.eventType,value:n.trigger.eventType},t[61]=n.trigger.eventType,t[62]=r.info.eventType,t[63]=e):e=t[63],_.push(e),n.trigger.source){let e;t[64]!==n.trigger.source||t[65]!==r.info.eventSource?(e={label:r.info.eventSource,value:n.trigger.source},t[64]=n.trigger.source,t[65]=r.info.eventSource,t[66]=e):e=t[66],_.push(e)}}else if(n.trigger.kind===`webhook`&&n.trigger.secretId){let e;t[67]!==n.trigger.secretId||t[68]!==r.info.webhookSecret?(e={label:r.info.webhookSecret,value:n.trigger.secretId},t[67]=n.trigger.secretId,t[68]=r.info.webhookSecret,t[69]=e):e=t[69],_.push(e)}t[22]=n.trigger.eventType,t[23]=n.trigger.kind,t[24]=n.trigger.schedule,t[25]=n.trigger.secretId,t[26]=n.trigger.source,t[27]=r.info.anchor,t[28]=r.info.calendarSchedule,t[29]=r.info.eventSource,t[30]=r.info.eventType,t[31]=r.info.expression,t[32]=r.info.fixedInterval,t[33]=r.info.oneTimeSchedule,t[34]=r.info.rawInterval,t[35]=r.info.scheduleType,t[36]=r.info.timezone,t[37]=r.info.webhookSecret,t[38]=a,t[39]=_}else _=t[39];h=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?g=t[71]:(g=(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.info.overview})}),t[70]=r.info.overview,t[71]=g),f=`grid gap-4 p-4`;let x;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t[72]=x):x=t[72];let S=r.info.schedule,C;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(C=qe(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=C):C=t[77];let w=n.enabled?`${r.info.nextRun}:${v}`:v;t[78]!==r.info.schedule||t[79]!==b||t[80]!==C||t[81]!==w?(p=(0,Q.jsx)(qt,{icon:x,label:S,value:C,description:w,descriptionTitle:b}),t[78]=r.info.schedule,t[79]=b,t[80]=C,t[81]=w,t[82]=p):p=t[82];let T;t[83]===n.action.kind?T=t[84]:(T=n.action.kind===`workflow`?(0,Q.jsx)(O,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`browser_automation`?(0,Q.jsx)(H,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(L,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=T);let ee=r.info.action,E;t[85]!==n.action||t[86]!==r?(E=_t(n.action,r),t[85]=n.action,t[86]=r,t[87]=E):E=t[87],t[88]!==r.info.action||t[89]!==T||t[90]!==E?(m=(0,Q.jsx)(qt,{icon:T,label:ee,value:E}),t[88]=r.info.action,t[89]=T,t[90]=E,t[91]=m):m=t[91],s=qt,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[92]=c):c=t[92],l=r.info.permission,u=r.safety[e],d=Wt(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_}else s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14];let v;t[93]!==s||t[94]!==c||t[95]!==l||t[96]!==u||t[97]!==d?(v=(0,Q.jsx)(s,{icon:c,label:l,value:u,description:d}),t[93]=s,t[94]=c,t[95]=l,t[96]=u,t[97]=d,t[98]=v):v=t[98];let y;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[99]=y):y=t[99];let b;t[100]!==n.projectId||t[101]!==r.info.noProject||t[102]!==o?(b=o.find(e=>e.id===n.projectId)?.name??r.info.noProject,t[100]=n.projectId,t[101]=r.info.noProject,t[102]=o,t[103]=b):b=t[103];let x;t[104]!==r.info.project||t[105]!==b?(x=(0,Q.jsx)(qt,{icon:y,label:r.info.project,value:b}),t[104]=r.info.project,t[105]=b,t[106]=x):x=t[106];let S;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(z,{className:`size-4`,"aria-hidden":!0}),t[107]=S):S=t[107];let C=n.conversationMode===`continuous`?r.info.continuousConversation:r.info.newConversation,w;t[108]!==r.info.conversation||t[109]!==C?(w=(0,Q.jsx)(qt,{icon:S,label:r.info.conversation,value:C}),t[108]=r.info.conversation,t[109]=C,t[110]=w):w=t[110];let T;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),t[111]=T):T=t[111];let E=n.notificationPolicy===`all`?r.info.notifyAll:n.notificationPolicy===`none`?r.info.notifyNone:r.info.notifyAttention,D;t[112]!==r.info.notifications||t[113]!==E?(D=(0,Q.jsx)(qt,{icon:T,label:r.info.notifications,value:E}),t[112]=r.info.notifications,t[113]=E,t[114]=D):D=t[114];let te;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Q.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[115]=te):te=t[115];let A=r.info.lastRun,j;t[116]!==n||t[117]!==r||t[118]!==a?(j=Ye(n,r,a),t[116]=n,t[117]=r,t[118]=a,t[119]=j):j=t[119];let M=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,P;t[120]!==r.info.lastRun||t[121]!==j||t[122]!==M?(P=(0,Q.jsx)(qt,{icon:te,label:A,value:j,valueTone:M}),t[120]=r.info.lastRun,t[121]=j,t[122]=M,t[123]=P):P=t[123];let F;t[124]!==n.state.consecutiveFailures||t[125]!==n.state.lastError||t[126]!==r.dashboard?(F=n.state.consecutiveFailures?(0,Q.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:[r.dashboard.failures,`:`,n.state.consecutiveFailures,n.state.lastError?(0,Q.jsx)(`p`,{className:`mt-1 break-words text-xs`,children:n.state.lastError}):null]}):n.state.lastError?(0,Q.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null,t[124]=n.state.consecutiveFailures,t[125]=n.state.lastError,t[126]=r.dashboard,t[127]=F):F=t[127];let I;t[128]!==r.info.technicalDetails||t[129]!==_?(I=_.length>0?(0,Q.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-3`,children:[(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Q.jsx)(`span`,{children:r.info.technicalDetails}),(0,Q.jsx)(ee,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:_.map(Kt)})]}):null,t[128]=r.info.technicalDetails,t[129]=_,t[130]=I):I=t[130];let R;t[131]!==v||t[132]!==x||t[133]!==w||t[134]!==D||t[135]!==P||t[136]!==F||t[137]!==I||t[138]!==f||t[139]!==p||t[140]!==m?(R=(0,Q.jsxs)(`div`,{className:f,children:[p,m,v,x,w,D,P,F,I]}),t[131]=v,t[132]=x,t[133]=w,t[134]=D,t[135]=P,t[136]=F,t[137]=I,t[138]=f,t[139]=p,t[140]=m,t[141]=R):R=t[141];let B;return t[142]!==R||t[143]!==h||t[144]!==g?(B=(0,Q.jsxs)(`aside`,{className:h,children:[g,R]}),t[142]=R,t[143]=h,t[144]=g,t[145]=B):B=t[145],B}function Kt(e){return(0,Q.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.label}),(0,Q.jsx)(`span`,{className:`break-all font-mono text-xs text-fg-muted`,children:e.value})]},`${e.label}:${e.value}`)}function qt(e){let t=(0,ye.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:o,valueTone:s}=e,c=s===void 0?`default`:s,l;t[0]===n?l=t[1]:(l=(0,Q.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=l);let u;t[2]===r?u=t[3]:(u=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=u);let d=c===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,p;t[4]===d?p=t[5]:(p=f(`mt-1 text-sm font-medium leading-5`,d),t[4]=d,t[5]=p);let m;t[6]!==p||t[7]!==i?(m=(0,Q.jsx)(`div`,{className:p,children:i}),t[6]=p,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==a||t[10]!==o?(h=a?(0,Q.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,title:o,children:a}):null,t[9]=a,t[10]=o,t[11]=h):h=t[11];let g;t[12]!==u||t[13]!==m||t[14]!==h?(g=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[u,m,h]}),t[12]=u,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==l||t[17]!==g?(_=(0,Q.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[l,g]}),t[16]=l,t[17]=g,t[18]=_):_=t[18],_}function Jt(e){let t=(0,ye.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`grid grid-cols-[5rem_1fr] gap-2`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Yt(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Xt(e){let t=(0,ye.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Q.jsx)(`div`,{className:`mt-1 truncate text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Zt(e){let t=(0,ye.c)(8),{className:n,icon:r,title:i}=e,a;t[0]===n?a=t[1]:(a=f(`flex min-h-48 flex-col items-center justify-center text-fg-muted`,n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=(0,Q.jsx)(`div`,{className:`mt-2 text-sm`,children:i}),t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,Q.jsxs)(`div`,{className:a,children:[r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Qt(e){let t=(0,ye.c)(274),{form:n,labels:r,setForm:i,projects:a,workflowDefinitions:c,selectedWorkflow:l,workflowsLoading:u,browserAutomations:d,selectedBrowserAutomation:p,browserAutomationsLoading:h,agentOptions:g,agentsLoading:_,language:v,projectLocked:y}=e,b=y===void 0?!1:y,x=m(v).agentsSettings,S;t[0]===i?S=t[1]:(S=e=>i(t=>({...t,...e})),t[0]=i,t[1]=S);let C=S,w=ze(n.intervalValue,n.intervalUnit),T=Date.now(),E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=[1,2,3],t[2]=E):E=t[2];let D;t[3]!==w||t[4]!==T||t[5]!==v?(D=E.map(e=>Ge(T+w*e,v,T)),t[3]=w,t[4]=T,t[5]=v,t[6]=D):D=t[6];let O=D,k,te;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==c?(k=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=c[0]?.id;e&&i(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},te=[n.actionMode,n.workflowId,i,c],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=c,t[11]=k,t[12]=te):(k=t[11],te=t[12]),(0,J.useEffect)(k,te);let ne,A;t[13]!==d||t[14]!==n.actionMode||t[15]!==n.browserAutomationId||t[16]!==i?(ne=()=>{if(n.actionMode!==`browser_automation`||n.browserAutomationId.trim())return;let e=d[0];e&&i(t=>({...t,browserAutomationId:e.id,browserAutomationInputs:q(e)}))},A=[d,n.actionMode,n.browserAutomationId,i],t[13]=d,t[14]=n.actionMode,t[15]=n.browserAutomationId,t[16]=i,t[17]=ne,t[18]=A):(ne=t[17],A=t[18]),(0,J.useEffect)(ne,A);let j;t[19]===C?j=t[20]:(j=e=>C({name:e.target.value}),t[19]=C,t[20]=j);let M;t[21]!==n.name||t[22]!==j?(M=(0,Q.jsx)(`input`,{className:$,value:n.name,onChange:j}),t[21]=n.name,t[22]=j,t[23]=M):M=t[23];let N;t[24]!==r.form.name||t[25]!==M?(N=(0,Q.jsx)(nn,{label:r.form.name,children:M}),t[24]=r.form.name,t[25]=M,t[26]=N):N=t[26];let P;t[27]===C?P=t[28]:(P=e=>C({description:e.target.value}),t[27]=C,t[28]=P);let F;t[29]!==n.description||t[30]!==P?(F=(0,Q.jsx)(`input`,{className:$,value:n.description,onChange:P}),t[29]=n.description,t[30]=P,t[31]=F):F=t[31];let I;t[32]!==r.form.description||t[33]!==F?(I=(0,Q.jsx)(nn,{label:r.form.description,children:F}),t[32]=r.form.description,t[33]=F,t[34]=I):I=t[34];let L;t[35]!==n.projectId||t[36]!==r.form.noProject||t[37]!==r.form.project||t[38]!==b||t[39]!==a||t[40]!==C?(L=b?null:(0,Q.jsx)(nn,{label:r.form.project,children:(0,Q.jsxs)(o,{className:$,value:n.projectId,onChange:e=>C({projectId:e.target.value}),children:[(0,Q.jsx)(s,{value:``,children:r.form.noProject}),a.map(tn)]})}),t[35]=n.projectId,t[36]=r.form.noProject,t[37]=r.form.project,t[38]=b,t[39]=a,t[40]=C,t[41]=L):L=t[41];let R;t[42]===r.form.trigger?R=t[43]:(R=(0,Q.jsx)(rn,{title:r.form.trigger}),t[42]=r.form.trigger,t[43]=R);let z;t[44]===C?z=t[45]:(z=e=>C({triggerMode:e.target.value}),t[44]=C,t[45]=z);let B;t[46]===r.trigger.manual?B=t[47]:(B=(0,Q.jsx)(s,{value:`manual`,children:r.trigger.manual}),t[46]=r.trigger.manual,t[47]=B);let re;t[48]===r.trigger.once?re=t[49]:(re=(0,Q.jsx)(s,{value:`once`,children:r.trigger.once}),t[48]=r.trigger.once,t[49]=re);let ie;t[50]===r.trigger.daily?ie=t[51]:(ie=(0,Q.jsx)(s,{value:`daily`,children:r.trigger.daily}),t[50]=r.trigger.daily,t[51]=ie);let V;t[52]===r.trigger.weekly?V=t[53]:(V=(0,Q.jsx)(s,{value:`weekly`,children:r.trigger.weekly}),t[52]=r.trigger.weekly,t[53]=V);let ae;t[54]===r.trigger.interval?ae=t[55]:(ae=(0,Q.jsx)(s,{value:`interval`,children:r.trigger.interval}),t[54]=r.trigger.interval,t[55]=ae);let oe;t[56]===r.trigger.customCron?oe=t[57]:(oe=(0,Q.jsx)(s,{value:`cron`,children:r.trigger.customCron}),t[56]=r.trigger.customCron,t[57]=oe);let se;t[58]===r.trigger.webhook?se=t[59]:(se=(0,Q.jsx)(s,{value:`webhook`,children:r.trigger.webhook}),t[58]=r.trigger.webhook,t[59]=se);let le;t[60]===r.trigger.taskBlocked?le=t[61]:(le=(0,Q.jsx)(s,{value:`taskBlocked`,children:r.trigger.taskBlocked}),t[60]=r.trigger.taskBlocked,t[61]=le);let ue;t[62]===r.trigger.noteCreated?ue=t[63]:(ue=(0,Q.jsx)(s,{value:`noteCreated`,children:r.trigger.noteCreated}),t[62]=r.trigger.noteCreated,t[63]=ue);let H;t[64]===r.trigger.workflowFailed?H=t[65]:(H=(0,Q.jsx)(s,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[64]=r.trigger.workflowFailed,t[65]=H);let U;t[66]===r.trigger.sessionUpdated?U=t[67]:(U=(0,Q.jsx)(s,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[66]=r.trigger.sessionUpdated,t[67]=U);let W;t[68]===r.trigger.customEvent?W=t[69]:(W=(0,Q.jsx)(s,{value:`event`,children:r.trigger.customEvent}),t[68]=r.trigger.customEvent,t[69]=W);let G;t[70]!==n.triggerMode||t[71]!==z||t[72]!==B||t[73]!==re||t[74]!==ie||t[75]!==V||t[76]!==ae||t[77]!==oe||t[78]!==se||t[79]!==le||t[80]!==ue||t[81]!==H||t[82]!==U||t[83]!==W?(G=(0,Q.jsxs)(o,{className:$,value:n.triggerMode,onChange:z,children:[B,re,ie,V,ae,oe,se,le,ue,H,U,W]}),t[70]=n.triggerMode,t[71]=z,t[72]=B,t[73]=re,t[74]=ie,t[75]=V,t[76]=ae,t[77]=oe,t[78]=se,t[79]=le,t[80]=ue,t[81]=H,t[82]=U,t[83]=W,t[84]=G):G=t[84];let pe;t[85]!==n.onceAt||t[86]!==n.triggerMode||t[87]!==r.form.onceAt||t[88]!==C?(pe=n.triggerMode===`once`?(0,Q.jsx)(nn,{label:r.form.onceAt,children:(0,Q.jsx)(`input`,{className:$,type:`datetime-local`,value:n.onceAt,onChange:e=>C({onceAt:e.target.value})})}):null,t[85]=n.onceAt,t[86]=n.triggerMode,t[87]=r.form.onceAt,t[88]=C,t[89]=pe):pe=t[89];let me;t[90]!==n.time||t[91]!==n.triggerMode||t[92]!==n.weekday||t[93]!==r.form.day||t[94]!==r.form.time||t[95]!==r.weekdays||t[96]!==C?(me=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsx)(nn,{label:r.form.time,children:(0,Q.jsx)(de,{value:n.time,onChange:e=>C({time:e}),ariaLabel:r.form.time})}),n.triggerMode===`weekly`?(0,Q.jsx)(nn,{label:r.form.day,children:(0,Q.jsxs)(o,{className:$,value:n.weekday,onChange:e=>C({weekday:e.target.value}),children:[(0,Q.jsx)(s,{value:`1`,children:r.weekdays.monday}),(0,Q.jsx)(s,{value:`2`,children:r.weekdays.tuesday}),(0,Q.jsx)(s,{value:`3`,children:r.weekdays.wednesday}),(0,Q.jsx)(s,{value:`4`,children:r.weekdays.thursday}),(0,Q.jsx)(s,{value:`5`,children:r.weekdays.friday}),(0,Q.jsx)(s,{value:`6`,children:r.weekdays.saturday}),(0,Q.jsx)(s,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[90]=n.time,t[91]=n.triggerMode,t[92]=n.weekday,t[93]=r.form.day,t[94]=r.form.time,t[95]=r.weekdays,t[96]=C,t[97]=me):me=t[97];let K=n.triggerMode===`interval`?(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Q.jsx)(nn,{label:r.form.intervalEvery,children:(0,Q.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Q.jsx)(`input`,{className:$,type:`number`,min:6e4/ze(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>C({intervalValue:e.target.value})}),(0,Q.jsxs)(o,{className:$,value:n.intervalUnit,onChange:e=>{let t=e.target.value;C({intervalValue:Be(n.intervalValue,n.intervalUnit,t),intervalUnit:t})},children:[(0,Q.jsx)(s,{value:`minute`,children:r.form.intervalUnits.minute}),(0,Q.jsx)(s,{value:`hour`,children:r.form.intervalUnits.hour}),(0,Q.jsx)(s,{value:`day`,children:r.form.intervalUnits.day}),(0,Q.jsx)(s,{value:`week`,children:r.form.intervalUnits.week})]})]})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.form.commonIntervals}),(0,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:Ze.map(e=>{let t=ze(e.value,e.unit),n=t===w;return(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":n,className:f(`rounded-full border px-2.5 py-1 text-xs transition-colors`,n?`border-accent bg-accent/10 text-accent`:`border-edge-subtle text-fg-muted hover:border-edge hover:bg-surface-hover hover:text-fg`),onClick:()=>C({intervalValue:e.value,intervalUnit:e.unit}),children:Ve(t,v)},`${e.value}:${e.unit}`)})})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:He(w,v)}),(0,Q.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,O.join(v===`zh`?`、`:`, `)]}),(0,Q.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,ge;t[98]!==n.cronExpr||t[99]!==n.triggerMode||t[100]!==r.form.expression||t[101]!==C?(ge=n.triggerMode===`cron`?(0,Q.jsx)(nn,{label:r.form.expression,children:(0,Q.jsx)(`input`,{className:$,value:n.cronExpr,onChange:e=>C({cronExpr:e.target.value})})}):null,t[98]=n.cronExpr,t[99]=n.triggerMode,t[100]=r.form.expression,t[101]=C,t[102]=ge):ge=t[102];let _e;t[103]!==n.triggerMode||t[104]!==n.webhookSecretId||t[105]!==r.form.secretId||t[106]!==C?(_e=n.triggerMode===`webhook`?(0,Q.jsx)(nn,{label:r.form.secretId,children:(0,Q.jsx)(`input`,{className:$,value:n.webhookSecretId,onChange:e=>C({webhookSecretId:e.target.value})})}):null,t[103]=n.triggerMode,t[104]=n.webhookSecretId,t[105]=r.form.secretId,t[106]=C,t[107]=_e):_e=t[107];let be;t[108]!==n.eventPayloadMatch||t[109]!==n.eventSource||t[110]!==n.eventType||t[111]!==n.triggerMode||t[112]!==r.form.eventPayloadMatch||t[113]!==r.form.eventSource||t[114]!==r.form.eventType||t[115]!==r.form.invalidJsonObject||t[116]!==C?(be=n.triggerMode===`event`?(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsx)(nn,{label:r.form.eventType,children:(0,Q.jsx)(`input`,{className:$,value:n.eventType,onChange:e=>C({eventType:e.target.value})})}),(0,Q.jsx)(nn,{label:r.form.eventSource,children:(0,Q.jsx)(`input`,{className:$,value:n.eventSource,onChange:e=>C({eventSource:e.target.value})})})]}),(0,Q.jsxs)(nn,{label:r.form.eventPayloadMatch,children:[(0,Q.jsx)(`textarea`,{className:f($,`min-h-24 resize-y font-mono text-xs`),value:n.eventPayloadMatch,onChange:e=>C({eventPayloadMatch:e.target.value}),placeholder:`{
5
+ "status": "blocked"
6
+ }`}),it(n.eventPayloadMatch)?null:(0,Q.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-300`,children:r.form.invalidJsonObject})]})]}):null,t[108]=n.eventPayloadMatch,t[109]=n.eventSource,t[110]=n.eventType,t[111]=n.triggerMode,t[112]=r.form.eventPayloadMatch,t[113]=r.form.eventSource,t[114]=r.form.eventType,t[115]=r.form.invalidJsonObject,t[116]=C,t[117]=be):be=t[117];let xe;t[118]===r.form.action?xe=t[119]:(xe=(0,Q.jsx)(rn,{title:r.form.action}),t[118]=r.form.action,t[119]=xe);let Y;t[120]!==n.timeoutSeconds||t[121]!==n.workflowId||t[122]!==C||t[123]!==c?(Y=e=>{let t=e.target.value,r=Number.parseInt(n.timeoutSeconds,10);C({actionMode:t,...r===600||r===1800?{timeoutSeconds:t===`browser_automation`?`600`:`1800`}:{},...t===`browser_automation`?{safetyMode:`auto_apply`}:{},...t===`workflow`&&!n.workflowId.trim()&&c[0]?{workflowId:c[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[120]=n.timeoutSeconds,t[121]=n.workflowId,t[122]=C,t[123]=c,t[124]=Y):Y=t[124];let Se;t[125]===r.action.runAgent?Se=t[126]:(Se=(0,Q.jsx)(s,{value:`agent`,children:r.action.runAgent}),t[125]=r.action.runAgent,t[126]=Se);let Ce;t[127]===r.action.runWorkflow?Ce=t[128]:(Ce=(0,Q.jsx)(s,{value:`workflow`,children:r.action.runWorkflow}),t[127]=r.action.runWorkflow,t[128]=Ce);let we=v===`zh`?`浏览器自动化`:`Browser automation`,Te;t[129]===we?Te=t[130]:(Te=(0,Q.jsx)(s,{value:`browser_automation`,children:we}),t[129]=we,t[130]=Te);let Ee;t[131]!==n.actionMode||t[132]!==Y||t[133]!==Se||t[134]!==Ce||t[135]!==Te?(Ee=(0,Q.jsxs)(o,{className:$,value:n.actionMode,onChange:Y,children:[Se,Ce,Te]}),t[131]=n.actionMode,t[132]=Y,t[133]=Se,t[134]=Ce,t[135]=Te,t[136]=Ee):Ee=t[136];let De=n.actionMode===`browser_automation`?null:(0,Q.jsx)(nn,{label:r.form.agent,children:(0,Q.jsxs)(o,{className:$,value:n.agentId,onChange:e=>C({agentId:e.target.value}),children:[(0,Q.jsx)(s,{value:``,children:_?r.form.loadingAgents:r.form.defaultAgent}),g.map(e=>(0,Q.jsx)(s,{value:e.id,children:ce(e,x)},e.id))]})}),Oe;t[137]!==d||t[138]!==h||t[139]!==n.actionMode||t[140]!==n.agentId||t[141]!==n.browserAutomationId||t[142]!==n.browserAutomationInputs||t[143]!==n.description||t[144]!==n.instruction||t[145]!==n.name||t[146]!==n.triggerMode||t[147]!==n.workflowId||t[148]!==n.workflowInput||t[149]!==r.form.instruction||t[150]!==r.form.loadingWorkflows||t[151]!==r.form.noWorkflows||t[152]!==r.form.triggeredRun||t[153]!==r.form.workflow||t[154]!==v||t[155]!==p||t[156]!==l||t[157]!==C||t[158]!==c||t[159]!==u?(Oe=n.actionMode===`agent`?(0,Q.jsxs)(nn,{label:r.form.instruction,children:[(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(fe,{value:n.instruction,onApply:e=>C({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:v,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,Q.jsx)(`textarea`,{className:f($,`min-h-32 resize-y`),value:n.instruction,onChange:e=>C({instruction:e.target.value})})]}):n.actionMode===`workflow`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(nn,{label:r.form.workflow,children:(0,Q.jsxs)(o,{className:$,value:n.workflowId,onChange:e=>C({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:u||c.length===0,children:[u?(0,Q.jsx)(s,{value:``,children:r.form.loadingWorkflows}):null,!u&&c.length===0?(0,Q.jsx)(s,{value:``,children:r.form.noWorkflows}):null,c.map(en)]})}),l?(0,Q.jsx)(he,{definition:l,language:v,value:n.workflowInput,onChange:e=>C({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>C({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:l.id,workflowTitle:l.title,workflowDescription:l.description}},inputClassName:`rounded-lg`}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(nn,{label:v===`zh`?`浏览器自动化`:`Browser automation`,children:(0,Q.jsxs)(o,{className:$,value:n.browserAutomationId,onChange:e=>{let t=d.find(t=>t.id===e.target.value);C({browserAutomationId:e.target.value,browserAutomationInputs:t?q(t):{}})},disabled:h||d.length===0,children:[d.length===0?(0,Q.jsx)(s,{value:``,children:v===`zh`?`没有已启用的浏览器自动化`:`No enabled browser automations`}):null,d.map($t)]})}),p&&Object.keys(p.inputs).length>0?(0,Q.jsx)(nn,{label:v===`zh`?`运行时填写`:`Run inputs`,children:(0,Q.jsx)(ve,{automation:p,values:n.browserAutomationInputs,language:v,onChange:e=>C({browserAutomationInputs:e})})}):null]}),t[137]=d,t[138]=h,t[139]=n.actionMode,t[140]=n.agentId,t[141]=n.browserAutomationId,t[142]=n.browserAutomationInputs,t[143]=n.description,t[144]=n.instruction,t[145]=n.name,t[146]=n.triggerMode,t[147]=n.workflowId,t[148]=n.workflowInput,t[149]=r.form.instruction,t[150]=r.form.loadingWorkflows,t[151]=r.form.noWorkflows,t[152]=r.form.triggeredRun,t[153]=r.form.workflow,t[154]=v,t[155]=p,t[156]=l,t[157]=C,t[158]=c,t[159]=u,t[160]=Oe):Oe=t[160];let X;t[161]===r.form.advancedDescription?X=t[162]:(X=(0,Q.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:r.form.advancedDescription}),t[161]=r.form.advancedDescription,t[162]=X);let Z;t[163]!==r.form.advanced||t[164]!==X?(Z=(0,Q.jsxs)(`span`,{children:[r.form.advanced,X]}),t[163]=r.form.advanced,t[164]=X,t[165]=Z):Z=t[165];let ke;t[166]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Q.jsx)(ee,{className:`size-4 transition-transform group-open:rotate-180`}),t[166]=ke):ke=t[166];let Ae;t[167]===Z?Ae=t[168]:(Ae=(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[Z,ke]}),t[167]=Z,t[168]=Ae);let je;t[169]!==n.actionMode||t[170]!==n.safetyMode||t[171]!==r.form.safety||t[172]!==r.safety||t[173]!==C?(je=n.actionMode===`browser_automation`?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(rn,{title:r.form.safety}),(0,Q.jsxs)(nn,{label:r.form.safety,children:[(0,Q.jsxs)(o,{className:$,value:n.safetyMode,onChange:e=>{let t=e.target.value;C({safetyMode:t})},children:[(0,Q.jsx)(s,{value:`suggest_only`,children:r.safety.suggest_only}),(0,Q.jsx)(s,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),(0,Q.jsx)(s,{value:`auto_apply`,children:r.safety.auto_apply})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription})]})]}),t[169]=n.actionMode,t[170]=n.safetyMode,t[171]=r.form.safety,t[172]=r.safety,t[173]=C,t[174]=je):je=t[174];let Me;t[175]===r.form.results?Me=t[176]:(Me=(0,Q.jsx)(rn,{title:r.form.results}),t[175]=r.form.results,t[176]=Me);let Ne;t[177]===C?Ne=t[178]:(Ne=e=>C({conversationMode:e.target.value}),t[177]=C,t[178]=Ne);let Pe;t[179]===r.form.newConversation?Pe=t[180]:(Pe=(0,Q.jsx)(s,{value:`new_session`,children:r.form.newConversation}),t[179]=r.form.newConversation,t[180]=Pe);let Fe;t[181]===r.form.continuousConversation?Fe=t[182]:(Fe=(0,Q.jsx)(s,{value:`continuous`,children:r.form.continuousConversation}),t[181]=r.form.continuousConversation,t[182]=Fe);let Ie;t[183]!==n.conversationMode||t[184]!==Ne||t[185]!==Pe||t[186]!==Fe?(Ie=(0,Q.jsxs)(o,{className:$,value:n.conversationMode,onChange:Ne,children:[Pe,Fe]}),t[183]=n.conversationMode,t[184]=Ne,t[185]=Pe,t[186]=Fe,t[187]=Ie):Ie=t[187];let Le;t[188]!==r.form.conversation||t[189]!==Ie?(Le=(0,Q.jsx)(nn,{label:r.form.conversation,children:Ie}),t[188]=r.form.conversation,t[189]=Ie,t[190]=Le):Le=t[190];let Re;t[191]===C?Re=t[192]:(Re=e=>C({notificationPolicy:e.target.value}),t[191]=C,t[192]=Re);let Ue;t[193]===r.form.notifyAttention?Ue=t[194]:(Ue=(0,Q.jsx)(s,{value:`attention`,children:r.form.notifyAttention}),t[193]=r.form.notifyAttention,t[194]=Ue);let We;t[195]===r.form.notifyAll?We=t[196]:(We=(0,Q.jsx)(s,{value:`all`,children:r.form.notifyAll}),t[195]=r.form.notifyAll,t[196]=We);let Ke;t[197]===r.form.notifyNone?Ke=t[198]:(Ke=(0,Q.jsx)(s,{value:`none`,children:r.form.notifyNone}),t[197]=r.form.notifyNone,t[198]=Ke);let qe;t[199]!==n.notificationPolicy||t[200]!==Re||t[201]!==Ue||t[202]!==We||t[203]!==Ke?(qe=(0,Q.jsxs)(o,{className:$,value:n.notificationPolicy,onChange:Re,children:[Ue,We,Ke]}),t[199]=n.notificationPolicy,t[200]=Re,t[201]=Ue,t[202]=We,t[203]=Ke,t[204]=qe):qe=t[204];let Je;t[205]!==r.form.notifications||t[206]!==qe?(Je=(0,Q.jsx)(nn,{label:r.form.notifications,children:qe}),t[205]=r.form.notifications,t[206]=qe,t[207]=Je):Je=t[207];let Ye;t[208]!==n.completionWebhookUrl||t[209]!==n.safetyMode||t[210]!==r.form.completionWebhook||t[211]!==C?(Ye=n.safetyMode===`auto_apply`?(0,Q.jsx)(nn,{label:r.form.completionWebhook,children:(0,Q.jsx)(`input`,{className:$,value:n.completionWebhookUrl,onChange:e=>C({completionWebhookUrl:e.target.value})})}):null,t[208]=n.completionWebhookUrl,t[209]=n.safetyMode,t[210]=r.form.completionWebhook,t[211]=C,t[212]=Ye):Ye=t[212];let Xe;t[213]===r.form.reliability?Xe=t[214]:(Xe=(0,Q.jsx)(rn,{title:r.form.reliability}),t[213]=r.form.reliability,t[214]=Xe);let Qe;t[215]===C?Qe=t[216]:(Qe=e=>C({timeoutSeconds:e.target.value}),t[215]=C,t[216]=Qe);let $e;t[217]!==n.timeoutSeconds||t[218]!==Qe?($e=(0,Q.jsx)(`input`,{className:$,inputMode:`numeric`,value:n.timeoutSeconds,onChange:Qe}),t[217]=n.timeoutSeconds,t[218]=Qe,t[219]=$e):$e=t[219];let et;t[220]!==r.form.timeoutSeconds||t[221]!==$e?(et=(0,Q.jsx)(nn,{label:r.form.timeoutSeconds,children:$e}),t[220]=r.form.timeoutSeconds,t[221]=$e,t[222]=et):et=t[222];let tt;t[223]===C?tt=t[224]:(tt=e=>C({disableAfterFailures:e.target.value}),t[223]=C,t[224]=tt);let nt;t[225]!==n.disableAfterFailures||t[226]!==tt?(nt=(0,Q.jsx)(`input`,{className:$,inputMode:`numeric`,value:n.disableAfterFailures,onChange:tt}),t[225]=n.disableAfterFailures,t[226]=tt,t[227]=nt):nt=t[227];let rt;t[228]!==r.form.disableAfterFailures||t[229]!==nt?(rt=(0,Q.jsx)(nn,{label:r.form.disableAfterFailures,children:nt}),t[228]=r.form.disableAfterFailures,t[229]=nt,t[230]=rt):rt=t[230];let at;t[231]!==et||t[232]!==rt?(at=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[et,rt]}),t[231]=et,t[232]=rt,t[233]=at):at=t[233];let ot;t[234]===r.form.effectivePolicy?ot=t[235]:(ot=(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.form.effectivePolicy}),t[234]=r.form.effectivePolicy,t[235]=ot);let st=n.timeoutSeconds||`—`,ct;t[236]!==r.form.executionDeadline||t[237]!==st?(ct=(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[r.form.executionDeadline,`: `,st,`s`]}),t[236]=r.form.executionDeadline,t[237]=st,t[238]=ct):ct=t[238];let lt;t[239]===r.form.downstreamTimeoutHint?lt=t[240]:(lt=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-fg-subtle`,children:r.form.downstreamTimeoutHint}),t[239]=r.form.downstreamTimeoutHint,t[240]=lt);let ut;t[241]!==ot||t[242]!==ct||t[243]!==lt?(ut=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-muted/40 px-3 py-2.5`,children:[ot,ct,lt]}),t[241]=ot,t[242]=ct,t[243]=lt,t[244]=ut):ut=t[244];let dt;t[245]!==je||t[246]!==Me||t[247]!==Le||t[248]!==Je||t[249]!==Ye||t[250]!==Xe||t[251]!==at||t[252]!==ut?(dt=(0,Q.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[je,Me,Le,Je,Ye,Xe,at,ut]}),t[245]=je,t[246]=Me,t[247]=Le,t[248]=Je,t[249]=Ye,t[250]=Xe,t[251]=at,t[252]=ut,t[253]=dt):dt=t[253];let ft;t[254]!==Ae||t[255]!==dt?(ft=(0,Q.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base`,children:[Ae,dt]}),t[254]=Ae,t[255]=dt,t[256]=ft):ft=t[256];let pt;return t[257]!==N||t[258]!==I||t[259]!==L||t[260]!==R||t[261]!==G||t[262]!==pe||t[263]!==me||t[264]!==K||t[265]!==ge||t[266]!==_e||t[267]!==be||t[268]!==xe||t[269]!==Ee||t[270]!==De||t[271]!==Oe||t[272]!==ft?(pt=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[N,I,L,R,G,pe,me,K,ge,_e,be,xe,Ee,De,Oe,ft]})}),t[257]=N,t[258]=I,t[259]=L,t[260]=R,t[261]=G,t[262]=pe,t[263]=me,t[264]=K,t[265]=ge,t[266]=_e,t[267]=be,t[268]=xe,t[269]=Ee,t[270]=De,t[271]=Oe,t[272]=ft,t[273]=pt):pt=t[273],pt}function $t(e){return(0,Q.jsx)(s,{value:e.id,children:e.name},e.id)}function en(e){return(0,Q.jsx)(s,{value:e.id,children:e.title||e.name},e.id)}function tn(e){return(0,Q.jsx)(s,{value:e.id,children:e.name},e.id)}var $=`min-h-11 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-base sm:min-h-0 sm:text-sm text-fg outline-none focus:border-accent`;function nn(e){let t=(0,ye.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function rn(e){let t=(0,ye.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(O,{className:`size-4 text-fg-muted`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 text-sm font-semibold text-fg`,children:[r,n]}),t[1]=n,t[2]=i),i}export{jt as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-preview-renderer-wzIchDSv.js","assets/preload-helper-zJ_50EbN.js","assets/pdf-runtime-DU_sMPjG.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-D6CRVWtT.js";import{da as o,fa as s}from"./index-B7JCOaCc.js";import{t as c}from"./preview-open-alternatives-B6QLKIZy.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let[c,l]=(0,u.useState)(null),[d,f]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(l(null),f(!1),!t||!n||!o||!r)return;let c=!1,u,d=document.createElement(`div`);d.className=`flex min-h-0 flex-1 flex-col overflow-auto`,o.replaceChildren(d),_(d,g(e,n));let p=e=>{c?e():u=e};return(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-wzIchDSv.js`),__vite__mapDeps([0,1,2]));if(c)return;let o=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(d,t,{loadingText:o.attachmentPreviewPdfRendering,loadMoreHint:o.attachmentPreviewPdfLoadMore,onPageCount:e=>{c||s?.(e)}});p(e)}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(d,t,{truncationNotice:o.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});p(e),c||f(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(d,t);p(e)}}catch(e){c||l(e instanceof Error?e.message:String(e))}})(),()=>{c=!0,u?.(),d.remove()}},[t,n,o,r,e,s]),{error:c,excelTruncated:d}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=s(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,o]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{o({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||o({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(22),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T);let E=f?(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[(0,p.jsx)(y,{props:e,message:b(e)}),(0,p.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600 dark:text-red-400`,children:f})]}):e.kind===`excel`&&m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,D=`${f?`hidden`:`flex`} docx-preview-host min-h-0 flex-1 flex-col overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`,O;t[17]===D?O=t[18]:(O=(0,p.jsx)(`div`,{ref:s,className:D}),t[17]=D,t[18]=O);let k;return t[19]!==O||t[20]!==E?(k=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:[E,O]}),t[19]=O,t[20]=E,t[21]=k):k=t[21],k}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,s=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,o):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==s?(u=s?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=s,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==s?(f=s?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=s,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-C9h8SImu.js";import{da as o,fa as s}from"./index-hlU8MUEz.js";import{t as c}from"./preview-open-alternatives-Dj6LJsuQ.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let[c,l]=(0,u.useState)(null),[d,f]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(l(null),f(!1),!t||!n||!o||!r)return;let c=!1,u,d=document.createElement(`div`);d.className=`flex min-h-0 flex-1 flex-col overflow-auto`,o.replaceChildren(d),_(d,g(e,n));let p=e=>{c?e():u=e};return(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-wzIchDSv.js`),__vite__mapDeps([0,1,2]));if(c)return;let o=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(d,t,{loadingText:o.attachmentPreviewPdfRendering,loadMoreHint:o.attachmentPreviewPdfLoadMore,onPageCount:e=>{c||s?.(e)}});p(e)}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(d,t,{truncationNotice:o.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});p(e),c||f(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(d,t);p(e)}}catch(e){c||l(e instanceof Error?e.message:String(e))}})(),()=>{c=!0,u?.(),d.remove()}},[t,n,o,r,e,s]),{error:c,excelTruncated:d}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=s(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,o]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{o({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||o({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(22),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T);let E=f?(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[(0,p.jsx)(y,{props:e,message:b(e)}),(0,p.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600 dark:text-red-400`,children:f})]}):e.kind===`excel`&&m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,D=`${f?`hidden`:`flex`} docx-preview-host min-h-0 flex-1 flex-col overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`,O;t[17]===D?O=t[18]:(O=(0,p.jsx)(`div`,{ref:s,className:D}),t[17]=D,t[18]=O);let k;return t[19]!==O||t[20]!==E?(k=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:[E,O]}),t[19]=O,t[20]=E,t[21]=k):k=t[21],k}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,s=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,o):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==s?(u=s?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=s,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==s?(f=s?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=s,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,t as o}from"./vendor-react-BOUWij0V.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./external-link-DjqjBmc3.js";import{d as u,h as d,t as f}from"./markdown-view-3YQc6QFV.js";import{t as p}from"./loader-circle-CifKLtgG.js";import{t as m}from"./cn-JdwAhgNB.js";import{n as h}from"./locale-store-CwuCkjo7.js";import{t as g}from"./messages-D6CRVWtT.js";import{t as _}from"./copy-to-clipboard-HOJ79TWv.js";import{s as v}from"./vendor-swr-BIWyz7Rc.js";import{a as y,d as b,i as x,l as S,n as C,o as w,r as T,s as E,t as D,u as O}from"./floating-ui.dom-B7uQOZZW.js";import{Cl as ee,Fl as te,Gl as k,Jc as ne,Kl as A,Ku as re,Lc as ie,Rc as ae,Wc as oe,Wl as se,Xc as ce,_u as le,ar as ue,bl as de,cl as fe,dc as pe,fr as me,ic as he,mr as ge,or as _e,rc as ve,rr as ye,vl as be,xl as xe,zl as Se}from"./index-B7JCOaCc.js";import{C as Ce,S as we}from"./vendor-codemirror-DFxP3B9T.js";import{t as Te}from"./with-selector-aYPsXwdl.js";import{a as Ee}from"./note-detail-panel-CS0W3ESn.js";var j=e(r(),1),De=e(i(),1),M=o(),Oe=v(),ke=Object.defineProperty,Ae=(e,t)=>{let n={};for(var r in e)ke(n,r,{get:e[r],enumerable:!0});return t||ke(n,Symbol.toStringTag,{value:`Module`}),n};function N(e){this.content=e}N.prototype={constructor:N,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new N(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new N(n)},addToStart:function(e,t){return new N([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new N(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new N(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=N.from(e),e.size?new N(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=N.from(e),e.size?new N(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=N.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},N.from=function(e){if(e instanceof N)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new N(t)};function je(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Pe(e.charCodeAt(r-1))&&Ne(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=je(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Me(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Pe(e.charCodeAt(i-1))&&Ne(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Me(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Ne(e){return e>=56320&&e<57344}function Pe(e){return e>=55296&&e<56320}var P=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return je(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Me(this,e,t,n)}findIndex(e){if(e==0)return Ie(0,e);if(e==this.size)return Ie(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Ie(t+1,i):Ie(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};P.empty=new P([],0);var Fe={index:0,offset:0};function Ie(e,t){return Fe.index=e,Fe.offset=t,Fe}function Le(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Le(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Le(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var F=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Le(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};F.none=[];var Re=class extends Error{},I=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Be(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ze(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(P.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};I.empty=new I(P.empty,0,0);function ze(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ze(a.content,t-i-1,n-i-1)))}function Be(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Be(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Ve(e,t,n){if(n.openStart>e.depth)throw new Re(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Re(`Inconsistent open depths`);return He(e,t,n,0)}function He(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=He(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return qe(a,Ye(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return qe(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Xe(n,e);return qe(a,Je(e,i,o,t,r))}}function Ue(e,t){if(!t.type.compatibleContent(e.type))throw new Re(`Cannot join `+t.type.name+` onto `+e.type.name)}function We(e,t,n){let r=e.node(n);return Ue(r,t.node(n)),r}function Ge(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ke(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ge(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Ge(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ge(t.nodeBefore,r)}function qe(e,t){if(!e.type.validContent(t))throw new Re(`Invalid content for node `+e.type.name);return e.copy(t)}function Je(e,t,n,r,i){let a=e.depth>i&&We(e,t,i+1),o=r.depth>i&&We(n,r,i+1),s=[];return Ke(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Ue(a,o),Ge(qe(a,Je(e,t,n,r,i+1)),s)):(a&&Ge(qe(a,Ye(e,t,i+1)),s),Ke(t,n,i,s),o&&Ge(qe(o,Ye(n,r,i+1)),s)),Ke(r,null,i,s),new P(s)}function Ye(e,t,n){let r=[];return Ke(null,e,n,r),e.depth>n&&Ge(qe(We(e,t,n+1),Ye(e,t,n+1)),r),Ke(t,null,n,r),new P(r)}function Xe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(P.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ze=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new tt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=et.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else et.set(t,r=new Qe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%$e,i}},Qe=class{constructor(){this.elts=[],this.i=0}},$e=12,et=new WeakMap,tt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},nt=Object.create(null),rt=class e{constructor(e,t,n,r=F.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||P.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Le(this.attrs,t||e.defaultAttrs||nt)&&F.sameSet(this.marks,n||F.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return I.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new I(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Ve(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ze.resolveCached(this,e)}resolveNoCache(e){return Ze.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),at(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=P.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!F.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=P.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};rt.prototype.text=void 0;var it=class e extends rt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):at(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function at(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var ot=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new st(t,n);if(r.next==null)return e.empty;let i=ct(r);r.next&&r.err(`Unexpected trailing text`);let a=vt(ht(i));return yt(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return P.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
1
+ import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,t as o}from"./vendor-react-BOUWij0V.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./external-link-DjqjBmc3.js";import{d as u,h as d,t as f}from"./markdown-view-B8maDRWh.js";import{t as p}from"./loader-circle-CifKLtgG.js";import{t as m}from"./cn-JdwAhgNB.js";import{n as h}from"./locale-store-DLK05Y1a.js";import{t as g}from"./messages-C9h8SImu.js";import{t as _}from"./copy-to-clipboard-HOJ79TWv.js";import{s as v}from"./vendor-swr-BIWyz7Rc.js";import{a as y,d as b,i as x,l as S,n as C,o as w,r as T,s as E,t as D,u as O}from"./floating-ui.dom-B7uQOZZW.js";import{Cl as ee,Fl as te,Gl as k,Jc as ne,Kl as A,Ku as re,Lc as ie,Rc as ae,Wc as oe,Wl as se,Xc as ce,_u as le,ar as ue,bl as de,cl as fe,dc as pe,fr as me,ic as he,mr as ge,or as _e,rc as ve,rr as ye,vl as be,xl as xe,zl as Se}from"./index-hlU8MUEz.js";import{C as Ce,S as we}from"./vendor-codemirror-DFxP3B9T.js";import{t as Te}from"./with-selector-aYPsXwdl.js";import{a as Ee}from"./note-detail-panel-lcZby9NY.js";var j=e(r(),1),De=e(i(),1),M=o(),Oe=v(),ke=Object.defineProperty,Ae=(e,t)=>{let n={};for(var r in e)ke(n,r,{get:e[r],enumerable:!0});return t||ke(n,Symbol.toStringTag,{value:`Module`}),n};function N(e){this.content=e}N.prototype={constructor:N,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new N(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new N(n)},addToStart:function(e,t){return new N([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new N(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new N(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=N.from(e),e.size?new N(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=N.from(e),e.size?new N(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=N.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},N.from=function(e){if(e instanceof N)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new N(t)};function je(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Pe(e.charCodeAt(r-1))&&Ne(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=je(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Me(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Pe(e.charCodeAt(i-1))&&Ne(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Me(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Ne(e){return e>=56320&&e<57344}function Pe(e){return e>=55296&&e<56320}var P=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return je(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Me(this,e,t,n)}findIndex(e){if(e==0)return Ie(0,e);if(e==this.size)return Ie(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Ie(t+1,i):Ie(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};P.empty=new P([],0);var Fe={index:0,offset:0};function Ie(e,t){return Fe.index=e,Fe.offset=t,Fe}function Le(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Le(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Le(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var F=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Le(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};F.none=[];var Re=class extends Error{},I=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Be(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ze(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(P.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};I.empty=new I(P.empty,0,0);function ze(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ze(a.content,t-i-1,n-i-1)))}function Be(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Be(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Ve(e,t,n){if(n.openStart>e.depth)throw new Re(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Re(`Inconsistent open depths`);return He(e,t,n,0)}function He(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=He(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return qe(a,Ye(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return qe(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Xe(n,e);return qe(a,Je(e,i,o,t,r))}}function Ue(e,t){if(!t.type.compatibleContent(e.type))throw new Re(`Cannot join `+t.type.name+` onto `+e.type.name)}function We(e,t,n){let r=e.node(n);return Ue(r,t.node(n)),r}function Ge(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ke(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ge(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Ge(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ge(t.nodeBefore,r)}function qe(e,t){if(!e.type.validContent(t))throw new Re(`Invalid content for node `+e.type.name);return e.copy(t)}function Je(e,t,n,r,i){let a=e.depth>i&&We(e,t,i+1),o=r.depth>i&&We(n,r,i+1),s=[];return Ke(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Ue(a,o),Ge(qe(a,Je(e,t,n,r,i+1)),s)):(a&&Ge(qe(a,Ye(e,t,i+1)),s),Ke(t,n,i,s),o&&Ge(qe(o,Ye(n,r,i+1)),s)),Ke(r,null,i,s),new P(s)}function Ye(e,t,n){let r=[];return Ke(null,e,n,r),e.depth>n&&Ge(qe(We(e,t,n+1),Ye(e,t,n+1)),r),Ke(t,null,n,r),new P(r)}function Xe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(P.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ze=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new tt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=et.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else et.set(t,r=new Qe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%$e,i}},Qe=class{constructor(){this.elts=[],this.i=0}},$e=12,et=new WeakMap,tt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},nt=Object.create(null),rt=class e{constructor(e,t,n,r=F.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||P.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Le(this.attrs,t||e.defaultAttrs||nt)&&F.sameSet(this.marks,n||F.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return I.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new I(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Ve(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ze.resolveCached(this,e)}resolveNoCache(e){return Ze.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),at(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=P.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!F.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=P.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};rt.prototype.text=void 0;var it=class e extends rt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):at(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function at(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var ot=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new st(t,n);if(r.next==null)return e.empty;let i=ct(r);r.next&&r.err(`Unexpected trailing text`);let a=vt(ht(i));return yt(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return P.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
2
2
  `)}};ot.empty=new ot(!0);var st=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function ct(e){let t=[];do t.push(lt(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function lt(e){let t=[];do t.push(ut(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function ut(e){let t=mt(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=ft(e,t);else break;return t}function dt(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function ft(e,t){let n=dt(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:dt(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function pt(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function mt(e){if(e.eat(`(`)){let t=ct(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=pt(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function ht(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function gt(e,t){return t-e}function _t(e,t){let n=[];return r(t),n.sort(gt);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function vt(e){let t=Object.create(null);return n(_t(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);_t(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new ot(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(gt);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function yt(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function bt(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function xt(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function St(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function Ct(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Et(e,r,t[r]);return n}var wt=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Ct(e,n.attrs),this.defaultAttrs=bt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ot.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:xt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new rt(this,this.computeAttrs(e),P.from(t),F.setFrom(n))}createChecked(e=null,t,n){return t=P.from(t),this.checkContent(t),new rt(this,this.computeAttrs(e),t,F.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=P.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(P.empty,!0);return i?new rt(this,e,t.append(i),F.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){St(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:F.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Tt(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Et=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Tt(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Dt=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Ct(e,r.attrs),this.excluded=null;let i=bt(this.attrs);this.instance=i?new F(this,i):null}create(e=null){return!e&&this.instance?this.instance:new F(this,xt(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){St(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Ot=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=N.from(e.nodes),t.marks=N.from(e.marks||{}),this.nodes=wt.compile(this.spec.nodes,this),this.marks=Dt.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=ot.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?kt(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:kt(this,n.split(` `))}this.nodeFromJSON=e=>rt.fromJSON(this,e),this.markFromJSON=e=>F.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof wt))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new it(n,n.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function kt(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function At(e){return e.tag!=null}function jt(e){return e.style!=null}var Mt=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(At(e))this.tags.push(e);else if(jt(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Vt(this,t,!1);return n.addAll(e,F.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Vt(this,t,!0);return n.addAll(e,F.none,t.from,t.to),I.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Ut(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Wt(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Wt(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Nt={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Pt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ft={ol:!0,ul:!0},It=1,Lt=2,Rt=4;function zt(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?It:0)|(t===`full`?Lt:0)}var Bt=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=F.none,this.match=i||(a&Rt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(P.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&It)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=P.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(P.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Nt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Vt=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=zt(null,t.preserveWhitespace,0)|(n?Rt:0);i=r?new Bt(r.type,r.attrs,F.none,!0,t.topMatch||r.type.contentMatch,a):n?new Bt(null,null,F.none,!0,null,a):new Bt(e.schema.topNodeType,null,F.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Lt?`full`:this.localPreserveWS||(r.options&It)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
3
3
  `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Ft.hasOwnProperty(a)&&this.parser.normalizeLists&&Ht(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:Pt.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Nt.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
4
  `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=F.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Gt(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=zt(e,i,a.options);a.options&Rt&&a.content.length==0&&(o|=Rt);let s=F.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Gt(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new Bt(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=It);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Ht(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Ft.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Ut(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Wt(e){let t={};for(let n in e)t[n]=e[n];return t}function Gt(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var Kt=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=Jt(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Jt(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Qt(Jt(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Qt(Jt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Qt(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=qt(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return qt(e.marks)}};function qt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Jt(e){return e.document||window.document}var Yt=new WeakMap;function Xt(e){let t=Yt.get(e);return t===void 0&&Yt.set(e,t=Zt(e)),t}function Zt(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Qt(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Xt(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=Qt(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var $t=a(),en=65535,tn=2**16;function nn(e,t){return e+t*tn}function rn(e){return e&en}function an(e){return(e-(e&en))/tn}var on=1,sn=2,cn=4,ln=8,un=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&ln)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&cn)>0}},dn=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=rn(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+an(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:nn(o/3,e-s),f=e==s?sn:e==u?on:cn;return(t<0?e!=s:e!=u)&&(f|=ln),new un(a,f,d)}r+=l-c}return n?e+r:new un(e+r,0,null)}touches(e,t){let n=0,r=rn(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};dn.empty=new dn([]);var fn=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new un(e,r,null)}},pn=Object.create(null),mn=class{getMap(){return dn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=pn[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in pn)throw RangeError(`Duplicate use of step JSON ID `+e);return pn[e]=t,t.prototype.jsonID=e,t}},hn=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Re)return e.fail(t.message);throw t}}};function gn(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(gn(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return P.fromArray(r)}var _n=class e extends mn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new I(gn(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return hn.fromReplace(e,this.from,this.to,i)}invert(){return new vn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};mn.jsonID(`addMark`,_n);var vn=class e extends mn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new I(gn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return hn.fromReplace(e,this.from,this.to,n)}invert(){return new _n(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};mn.jsonID(`removeMark`,vn);var yn=class e extends mn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return hn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return hn.fromReplace(e,this.pos,this.pos+1,new I(P.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new bn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};mn.jsonID(`addNodeMark`,yn);var bn=class e extends mn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return hn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return hn.fromReplace(e,this.pos,this.pos+1,new I(P.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new yn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};mn.jsonID(`removeNodeMark`,bn);var xn=class e extends mn{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Cn(e,this.from,this.to)?hn.fail(`Structure replace would overwrite content`):hn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new dn([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?I.empty:new I(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?I.empty:new I(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,I.fromJSON(t,n.slice),!!n.structure)}};xn.MAP_BIAS=1,mn.jsonID(`replace`,xn);var Sn=class e extends mn{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Cn(e,this.from,this.gapFrom)||Cn(e,this.gapTo,this.to)))return hn.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return hn.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?hn.fromReplace(e,this.from,this.to,n):hn.fail(`Content does not fit in gap`)}getMap(){return new dn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,I.fromJSON(t,n.slice),n.insert,!!n.structure)}};mn.jsonID(`replaceAround`,Sn);function Cn(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function wn(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new vn(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new _n(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Tn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Dt){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new vn(t.from,t.to,t.style)))}function En(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new xn(s,l,I.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new vn(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new I(P.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new xn(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(P.empty,!0);e.replace(s,s,new I(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Dn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function On(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Dn(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function kn(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=P.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=P.from(r.node(e).copy(u)),d++):c--;let f=P.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=P.from(i.node(e).copy(f)),p++):l++;e.step(new Sn(c,l,o,s,new I(u.append(f),d,p),u.size-d,!0))}function An(e,t,n=null,r=e){let i=Mn(e,t),a=i&&Nn(r,t);return a?i.map(jn).concat({type:t,attrs:n}).concat(a.map(jn)):null}function jn(e){return{type:e,attrs:null}}function Mn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function Nn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function Pn(e,t,n){let r=P.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=P.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Sn(i,a,i,a,new I(r,0,0),n.length,!0))}function Fn(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Rn(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Ln(e,t,n,a),En(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Sn(c,l,c+1,l-1,new I(P.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&In(e,t,n,a),!1}})}function In(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Ln(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-DldSX8GX.js";import{a as r,r as i}from"./locale-store-CwuCkjo7.js";function a(e){return{id:e.id,name:e.definition.name,description:e.definition.description,enabled:e.status===`enabled`,risk:e.definition.risk,domains:e.definition.allowedDomains,inputs:e.definition.inputs,createdAtMs:e.createdAtMs,updatedAtMs:e.updatedAtMs}}var o={list:async()=>({automations:(await r(i(`/api/browser/automations`))).automations.map(a)}),setEnabled:async(e,t)=>({automation:a((await r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t?`enabled`:`disabled`})})).automation)}),remove:e=>r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(i(`/api/browser/automations/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(i(`/api/browser/automation-runs?automationId=${encodeURIComponent(e)}`)),cancel:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function s(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function c(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}var l=e(),u=t();function d(e){let t=(0,l.c)(53),{name:r,input:i,value:a,yes:o,no:s,onChange:c}=e,d;t[0]!==i.description||t[1]!==r?(d=i.description?.trim()||r,t[0]=i.description,t[1]=r,t[2]=d):d=t[2];let p=d;if(i.choices?.length){let e;t[3]===i.choices?e=t[4]:(e=i.choices.map(f),t[3]=i.choices,t[4]=e);let r=e,o=i.required?` *`:``,s;t[5]!==p||t[6]!==o?(s=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=s):s=t[7];let l;t[8]===a?l=t[9]:(l=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=l);let d;t[10]===c?d=t[11]:(d=e=>c(JSON.parse(e)),t[10]=c,t[11]=d);let m;t[12]!==p||t[13]!==r||t[14]!==l||t[15]!==d?(m=(0,u.jsx)(n,{value:l,options:r,placeholder:p,onChange:d}),t[12]=p,t[13]=r,t[14]=l,t[15]=d,t[16]=m):m=t[16];let h;return t[17]!==s||t[18]!==m?(h=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[s,m]}),t[17]=s,t[18]=m,t[19]=h):h=t[19],h}if(i.type===`boolean`){let e=i.required?` *`:``,r;t[20]!==p||t[21]!==e?(r=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=r):r=t[22];let l=typeof a==`boolean`?String(a):``,d;t[23]===o?d=t[24]:(d={value:`true`,label:o},t[23]=o,t[24]=d);let f;t[25]===s?f=t[26]:(f={value:`false`,label:s},t[25]=s,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===c?h=t[31]:(h=e=>c(e===`true`),t[30]=c,t[31]=h);let g;t[32]!==p||t[33]!==l||t[34]!==m||t[35]!==h?(g=(0,u.jsx)(n,{value:l,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=l,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==r||t[38]!==g?(_=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[r,g]}),t[37]=r,t[38]=g,t[39]=_):_=t[39],_}let m=i.type===`number`,h=i.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=a===void 0?``:String(a),y;t[43]!==m||t[44]!==c?(y=e=>c(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=c,t[45]=y):y=t[45];let b;t[46]!==_||t[47]!==v||t[48]!==y?(b=(0,u.jsx)(`input`,{type:_,value:v,onChange:y,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b):b=t[49];let x;return t[50]!==g||t[51]!==b?(x=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,b]}),t[50]=g,t[51]=b,t[52]=x):x=t[52],x}function f(e){return{value:JSON.stringify(e),label:String(e)}}function p(e){let t=(0,l.c)(7),{automation:n,values:r,language:i,onChange:a}=e,o;t[0]===n.inputs?o=t[1]:(o=Object.entries(n.inputs),t[0]=n.inputs,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,u.jsx)(`div`,{className:`grid gap-4`,children:o.map(e=>{let[t,n]=e;return(0,u.jsx)(d,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}export{o as i,c as n,s as r,p as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-DldSX8GX.js";import{a as r,r as i}from"./locale-store-DLK05Y1a.js";function a(e){return{id:e.id,name:e.definition.name,description:e.definition.description,enabled:e.status===`enabled`,risk:e.definition.risk,domains:e.definition.allowedDomains,inputs:e.definition.inputs,createdAtMs:e.createdAtMs,updatedAtMs:e.updatedAtMs}}var o={list:async()=>({automations:(await r(i(`/api/browser/automations`))).automations.map(a)}),setEnabled:async(e,t)=>({automation:a((await r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t?`enabled`:`disabled`})})).automation)}),remove:e=>r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(i(`/api/browser/automations/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(i(`/api/browser/automation-runs?automationId=${encodeURIComponent(e)}`)),cancel:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function s(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function c(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}var l=e(),u=t();function d(e){let t=(0,l.c)(53),{name:r,input:i,value:a,yes:o,no:s,onChange:c}=e,d;t[0]!==i.description||t[1]!==r?(d=i.description?.trim()||r,t[0]=i.description,t[1]=r,t[2]=d):d=t[2];let p=d;if(i.choices?.length){let e;t[3]===i.choices?e=t[4]:(e=i.choices.map(f),t[3]=i.choices,t[4]=e);let r=e,o=i.required?` *`:``,s;t[5]!==p||t[6]!==o?(s=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=s):s=t[7];let l;t[8]===a?l=t[9]:(l=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=l);let d;t[10]===c?d=t[11]:(d=e=>c(JSON.parse(e)),t[10]=c,t[11]=d);let m;t[12]!==p||t[13]!==r||t[14]!==l||t[15]!==d?(m=(0,u.jsx)(n,{value:l,options:r,placeholder:p,onChange:d}),t[12]=p,t[13]=r,t[14]=l,t[15]=d,t[16]=m):m=t[16];let h;return t[17]!==s||t[18]!==m?(h=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[s,m]}),t[17]=s,t[18]=m,t[19]=h):h=t[19],h}if(i.type===`boolean`){let e=i.required?` *`:``,r;t[20]!==p||t[21]!==e?(r=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=r):r=t[22];let l=typeof a==`boolean`?String(a):``,d;t[23]===o?d=t[24]:(d={value:`true`,label:o},t[23]=o,t[24]=d);let f;t[25]===s?f=t[26]:(f={value:`false`,label:s},t[25]=s,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===c?h=t[31]:(h=e=>c(e===`true`),t[30]=c,t[31]=h);let g;t[32]!==p||t[33]!==l||t[34]!==m||t[35]!==h?(g=(0,u.jsx)(n,{value:l,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=l,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==r||t[38]!==g?(_=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[r,g]}),t[37]=r,t[38]=g,t[39]=_):_=t[39],_}let m=i.type===`number`,h=i.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=a===void 0?``:String(a),y;t[43]!==m||t[44]!==c?(y=e=>c(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=c,t[45]=y):y=t[45];let b;t[46]!==_||t[47]!==v||t[48]!==y?(b=(0,u.jsx)(`input`,{type:_,value:v,onChange:y,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b):b=t[49];let x;return t[50]!==g||t[51]!==b?(x=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,b]}),t[50]=g,t[51]=b,t[52]=x):x=t[52],x}function f(e){return{value:JSON.stringify(e),label:String(e)}}function p(e){let t=(0,l.c)(7),{automation:n,values:r,language:i,onChange:a}=e,o;t[0]===n.inputs?o=t[1]:(o=Object.entries(n.inputs),t[0]=n.inputs,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,u.jsx)(`div`,{className:`grid gap-4`,children:o.map(e=>{let[t,n]=e;return(0,u.jsx)(d,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}export{o as i,c as n,s as r,p as t};