quadwork 1.19.2 → 2.0.0

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 (117) hide show
  1. package/README.md +19 -35
  2. package/bin/quadwork.js +48 -1118
  3. package/out/404.html +1 -1
  4. package/out/__next.__PAGE__.txt +3 -3
  5. package/out/__next._full.txt +14 -14
  6. package/out/__next._head.txt +4 -4
  7. package/out/__next._index.txt +8 -8
  8. package/out/__next._tree.txt +2 -2
  9. package/out/_next/static/chunks/{030cjkhts487t.js → 079wdniva~de1.js} +1 -1
  10. package/out/_next/static/chunks/{0n~dq4kpx9xxx.js → 07lhk_q6pmm3r.js} +1 -1
  11. package/out/_next/static/chunks/0_79hkefw1mo2.js +1 -0
  12. package/out/_next/static/chunks/{153f.fj8jlvle.js → 0_lyyn..t63bc.js} +1 -1
  13. package/out/_next/static/chunks/0oxv9vrvc17to.js +2 -0
  14. package/out/_next/static/chunks/0py7102i226n5.js +1 -0
  15. package/out/_next/static/chunks/{13fv-yi7.v52g.js → 0q4bm04c1jl_3.js} +1 -1
  16. package/out/_next/static/chunks/{0_idxioyl0p7h.js → 0sjhy6oe3mbon.js} +1 -1
  17. package/out/_next/static/chunks/13xk0vgfbrcld.css +2 -0
  18. package/out/_next/static/chunks/14k3bfe537f9_.js +25 -0
  19. package/out/_next/static/chunks/{turbopack-0qm-e3ifrz~2u.js → turbopack-0y2u-q0l2m67w.js} +1 -1
  20. package/out/_not-found/__next._full.txt +13 -13
  21. package/out/_not-found/__next._head.txt +4 -4
  22. package/out/_not-found/__next._index.txt +8 -8
  23. package/out/_not-found/__next._not-found.__PAGE__.txt +2 -2
  24. package/out/_not-found/__next._not-found.txt +3 -3
  25. package/out/_not-found/__next._tree.txt +2 -2
  26. package/out/_not-found.html +1 -1
  27. package/out/_not-found.txt +13 -13
  28. package/out/app-shell/__next._full.txt +13 -13
  29. package/out/app-shell/__next._head.txt +4 -4
  30. package/out/app-shell/__next._index.txt +8 -8
  31. package/out/app-shell/__next._tree.txt +2 -2
  32. package/out/app-shell/__next.app-shell.__PAGE__.txt +2 -2
  33. package/out/app-shell/__next.app-shell.txt +3 -3
  34. package/out/app-shell.html +1 -1
  35. package/out/app-shell.txt +13 -13
  36. package/out/index.html +1 -1
  37. package/out/index.txt +14 -14
  38. package/out/project/_/__next._full.txt +14 -14
  39. package/out/project/_/__next._head.txt +4 -4
  40. package/out/project/_/__next._index.txt +8 -8
  41. package/out/project/_/__next._tree.txt +2 -2
  42. package/out/project/_/__next.project.$d$id.__PAGE__.txt +3 -3
  43. package/out/project/_/__next.project.$d$id.txt +3 -3
  44. package/out/project/_/__next.project.txt +3 -3
  45. package/out/project/_/queue/__next._full.txt +14 -14
  46. package/out/project/_/queue/__next._head.txt +4 -4
  47. package/out/project/_/queue/__next._index.txt +8 -8
  48. package/out/project/_/queue/__next._tree.txt +2 -2
  49. package/out/project/_/queue/__next.project.$d$id.queue.__PAGE__.txt +3 -3
  50. package/out/project/_/queue/__next.project.$d$id.queue.txt +3 -3
  51. package/out/project/_/queue/__next.project.$d$id.txt +3 -3
  52. package/out/project/_/queue/__next.project.txt +3 -3
  53. package/out/project/_/queue.html +1 -1
  54. package/out/project/_/queue.txt +14 -14
  55. package/out/project/_.html +1 -1
  56. package/out/project/_.txt +14 -14
  57. package/out/settings/__next._full.txt +14 -14
  58. package/out/settings/__next._head.txt +4 -4
  59. package/out/settings/__next._index.txt +8 -8
  60. package/out/settings/__next._tree.txt +2 -2
  61. package/out/settings/__next.settings.__PAGE__.txt +3 -3
  62. package/out/settings/__next.settings.txt +3 -3
  63. package/out/settings.html +1 -1
  64. package/out/settings.txt +14 -14
  65. package/out/setup/__next._full.txt +14 -14
  66. package/out/setup/__next._head.txt +4 -4
  67. package/out/setup/__next._index.txt +8 -8
  68. package/out/setup/__next._tree.txt +2 -2
  69. package/out/setup/__next.setup.__PAGE__.txt +3 -3
  70. package/out/setup/__next.setup.txt +3 -3
  71. package/out/setup.html +1 -1
  72. package/out/setup.txt +14 -14
  73. package/package.json +4 -2
  74. package/server/ac-restore.js +128 -0
  75. package/server/bridges/discord.js +183 -0
  76. package/server/bridges/telegram.js +210 -0
  77. package/server/config.js +4 -60
  78. package/server/file-chat.js +318 -0
  79. package/server/index.js +173 -1286
  80. package/server/install-agentchattr.js +3 -284
  81. package/server/mcp-chat-shim.js +171 -0
  82. package/server/migrate-ac.js +158 -0
  83. package/server/pty-dispatcher.js +188 -0
  84. package/server/routes.js +149 -1397
  85. package/templates/CLAUDE.md +2 -2
  86. package/templates/OVERNIGHT-QUEUE.md +1 -1
  87. package/templates/seeds/butler.CLAUDE.md +30 -62
  88. package/templates/seeds/dev.AGENTS.md +10 -1
  89. package/templates/seeds/head.AGENTS.md +3 -3
  90. package/templates/seeds/re1.AGENTS.md +3 -3
  91. package/templates/seeds/re2.AGENTS.md +3 -3
  92. package/bridges/discord/__pycache__/discord_bridge.cpython-314.pyc +0 -0
  93. package/bridges/discord/discord_bridge.py +0 -666
  94. package/bridges/discord/requirements.txt +0 -2
  95. package/out/_next/static/chunks/0_bb~2.5h2ntm.css +0 -2
  96. package/out/_next/static/chunks/0makcdqkwobp6.js +0 -25
  97. package/out/_next/static/chunks/0uz5svjlo9dwl.js +0 -1
  98. package/out/_next/static/chunks/0zahstmgdrpy5.js +0 -1
  99. package/out/_next/static/chunks/0zfotsowwll1x.js +0 -2
  100. package/server/__tests__/bridge-auto-stop-guard.test.js +0 -134
  101. package/server/__tests__/rate-limit-handling.test.js +0 -168
  102. package/server/__tests__/scrub-secrets.test.js +0 -235
  103. package/server/__tests__/v1110-security-qa.test.js +0 -312
  104. package/server/agentchattr-registry.js +0 -188
  105. package/server/install-agentchattr.patchCrashTimeout.test.js +0 -71
  106. package/server/queue-watcher.js +0 -171
  107. package/server/queue-watcher.test.js +0 -64
  108. package/server/routes.batchProgress.test.js +0 -94
  109. package/server/routes.chatWsSend.test.js +0 -161
  110. package/server/routes.discordBridge.test.js +0 -80
  111. package/server/routes.parseActiveBatch.test.js +0 -88
  112. package/server/routes.telegramBridge.test.js +0 -241
  113. package/templates/config.toml +0 -72
  114. package/templates/wrapper.py +0 -70
  115. /package/out/_next/static/{K7A3YZrh4sLaRRP1-Lq7v → 479UD5Kit4YvCmtgO25VT}/_buildManifest.js +0 -0
  116. /package/out/_next/static/{K7A3YZrh4sLaRRP1-Lq7v → 479UD5Kit4YvCmtgO25VT}/_clientMiddlewareManifest.js +0 -0
  117. /package/out/_next/static/{K7A3YZrh4sLaRRP1-Lq7v → 479UD5Kit4YvCmtgO25VT}/_ssgManifest.js +0 -0
@@ -0,0 +1,25 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,26568,(e,t,n)=>{"use strict";var r=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,l=/\n/g,i=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g;function d(e){return e?e.replace(u,""):""}t.exports=function(e,t){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,u=1;function p(e){var t=e.match(l);t&&(n+=t.length);var r=e.lastIndexOf("\n");u=~r?e.length-r:u+e.length}function h(){var e={line:n,column:u};return function(t){return t.position=new f(e),x(i),t}}function f(e){this.start=e,this.end={line:n,column:u},this.source=t.source}function m(r){var l=Error(t.source+":"+n+":"+u+": "+r);if(l.reason=r,l.filename=t.source,l.line=n,l.column=u,l.source=e,t.silent);else throw l}function x(t){var n=t.exec(e);if(n){var r=n[0];return p(r),e=e.slice(r.length),n}}function g(e){var t;for(e=e||[];t=b();)!1!==t&&e.push(t);return e}function b(){var t=h();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;""!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return m("End of comment missing");var r=e.slice(2,n-2);return u+=2,p(r),e=e.slice(n),u+=2,t({type:"comment",comment:r})}}f.prototype.content=e,x(i);var y,v=[];for(g(v);y=function(){var e=h(),t=x(o);if(t){if(b(),!x(a))return m("property missing ':'");var n=x(s),l=e({type:"declaration",property:d(t[0].replace(r,"")),value:n?d(n[0].replace(r,"")):""});return x(c),l}}();)!1!==y&&(v.push(y),g(v));return v}},70454,(e,t,n)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){let n=null;if(!e||"string"!=typeof e)return n;let r=(0,l.default)(e),i="function"==typeof t;return r.forEach(e=>{if("declaration"!==e.type)return;let{property:r,value:l}=e;i?t(r,l,e):l&&((n=n||{})[r]=l)}),n};let l=r(e.r(26568))},65185,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.camelCase=void 0;var r=/^--[a-zA-Z0-9_-]+$/,l=/-([a-z])/g,i=/^[^-]+$/,o=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,s=function(e,t){return t.toUpperCase()},c=function(e,t){return"".concat(t,"-")};n.camelCase=function(e,t){var n;return(void 0===t&&(t={}),!(n=e)||i.test(n)||r.test(n))?e:(e=e.toLowerCase(),(e=t.reactCompat?e.replace(a,c):e.replace(o,c)).replace(l,s))}},15511,(e,t,n)=>{"use strict";var r=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(70454)),l=e.r(65185);function i(e,t){var n={};return e&&"string"==typeof e&&(0,r.default)(e,function(e,r){e&&r&&(n[(0,l.camelCase)(e,t)]=r)}),n}i.default=i,t.exports=i},4100,(e,t,n)=>{"use strict";var r=Object.prototype.hasOwnProperty,l=Object.prototype.toString,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,a=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===l.call(e)},s=function(e){if(!e||"[object Object]"!==l.call(e))return!1;var t,n=r.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&r.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!i)return!1;for(t in e);return void 0===t||r.call(e,t)},c=function(e,t){i&&"__proto__"===t.name?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},u=function(e,t){if("__proto__"===t){if(!r.call(e,t))return;else if(o)return o(e,t).value}return e[t]};t.exports=function e(){var t,n,r,l,i,o,d=arguments[0],p=1,h=arguments.length,f=!1;for("boolean"==typeof d&&(f=d,d=arguments[1]||{},p=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});p<h;++p)if(t=arguments[p],null!=t)for(n in t)r=u(d,n),d!==(l=u(t,n))&&(f&&l&&(s(l)||(i=a(l)))?(i?(i=!1,o=r&&a(r)?r:[]):o=r&&s(r)?r:{},c(d,{name:n,newValue:e(f,o,l)})):void 0!==l&&c(d,{name:n,newValue:l}));return d}},55601,e=>{"use strict";var t=e.i(43476),n=e.i(71645);function r({label:e,status:n,projectId:l,agentId:i,onStatusChange:o,tooltip:a,children:s}){let c="running"===n?"bg-accent":"error"===n?"bg-error":"bg-text-muted",u=e=>{l&&i&&fetch(`/api/agents?project=${encodeURIComponent(l)}&agent=${encodeURIComponent(i)}&action=${e}`,{method:"POST"}).then(e=>e.json()).then(e=>{o&&e.state&&o(e.state)}).catch(()=>{})};return(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 h-7 shrink-0 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,t.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${c}`}),(0,t.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:e}),a]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[s,l&&i&&(0,t.jsxs)(t.Fragment,{children:["running"!==n&&(0,t.jsx)("button",{onClick:()=>u("start"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Start",children:"▶"}),"running"===n&&(0,t.jsx)("button",{onClick:()=>u("stop"),className:"text-[10px] text-text-muted hover:text-error transition-colors px-1",title:"Stop",children:"■"}),(0,t.jsx)("button",{onClick:()=>u("restart"),className:"text-[10px] text-text-muted hover:text-accent transition-colors px-1",title:"Restart",children:"↻"})]})]})]})}var l=e.i(29198),i=e.i(78759),o=e.i(52368);let a={en:{ready:"Ready when you are",tell:"Tell your team what to build. Try something like:",howToWork:"How to Work",examples:["@head start a new feature: <describe>","@head review the latest PR","@head what's our current sprint?"]},ko:{ready:"언제든지 시작하세요",tell:"팀에게 무엇을 만들지 말해보세요. 예를 들어:",howToWork:"사용 방법",examples:["@head 새로운 기능 시작: <설명>","@head 최신 PR 리뷰해줘","@head 현재 스프린트 상황이 어때?"]}};function s({onInsert:e}){let{locale:r}=(0,o.useLocale)(),l=a[r],[c,u]=(0,n.useState)(!1);return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center text-center px-6 py-10 gap-3",children:[(0,t.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none","aria-hidden":!0,className:"text-accent",children:[(0,t.jsx)("path",{d:"M6 8h28a2 2 0 0 1 2 2v17a2 2 0 0 1-2 2H16l-7 6v-6h-3a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2Z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"14",cy:"18",r:"1.4",fill:"currentColor"}),(0,t.jsx)("circle",{cx:"20",cy:"18",r:"1.4",fill:"currentColor"}),(0,t.jsx)("circle",{cx:"26",cy:"18",r:"1.4",fill:"currentColor"})]}),(0,t.jsx)("div",{className:"text-[13px] font-semibold text-text",children:l.ready}),(0,t.jsx)("div",{className:"text-[11px] text-text-muted",children:l.tell}),(0,t.jsx)("div",{className:"flex flex-col gap-1.5 mt-1 w-full max-w-sm",children:l.examples.map(n=>(0,t.jsx)("button",{type:"button",onClick:()=>e(n),className:"text-left px-2 py-1 text-[11px] font-mono text-text-muted border border-border hover:text-accent hover:border-accent transition-colors truncate",children:n},n))}),(0,t.jsx)("button",{type:"button",onClick:()=>u(!0),className:"mt-2 text-[11px] text-text-muted underline underline-offset-2 hover:text-text",children:l.howToWork}),(0,t.jsx)(i.default,{open:c,onClose:()=>u(!1)})]})}let c="qw-chat-presets",u=[{id:"default-1",title:"Queue Check — Trigger",message:`@head @dev @re1 @re2 – Queue check.
2
+ @head: Merge any PR with both approvals, assign next from ~/.quadwork/{{project}}/OVERNIGHT-QUEUE.md.
3
+ @dev: Work on assigned ticket or address review feedback.
4
+ @re1 & @re2: Review open PRs. If @dev pushed fixes, re-review. Post verdict on PR AND notify @dev here.
5
+ ALL: Communicate via this chat by tagging agents. Your terminal is NOT visible.`},{id:"default-2",title:"Suffix Reminder",message:"All agents: ignore numeric suffixes in your identity. dev, dev-1, dev-2 are the same Dev agent. re1, re1-2 are the same RE1. re2, re2-2 are the same RE2. head, head-2 are the same Head. When tagging others, use the base name (@dev, @re1, @re2, @head). When checking for mentions to you, match your base role name regardless of suffix."},{id:"default-3",title:"Check Queue Format",message:"@head Check your OVERNIGHT-QUEUE.md formatting. Each Active Batch item must start with `- #<number>` (dash, space, hash, issue number). Do NOT use `- Issue #598` format — only `- #598 description`. The Current Batch panel won't recognize items in any other format. Fix if needed and confirm."},{id:"default-4",title:"Agent Online Check",message:"@head Are you online? If so, ping @dev, @re1, and @re2 to confirm whether they are online and available."}];function d({projectId:e,onSend:r}){let[l,i]=(0,n.useState)(!1),[o,a]=(0,n.useState)([]),[s,p]=(0,n.useState)(null),[h,f]=(0,n.useState)(""),[m,x]=(0,n.useState)("");(0,n.useEffect)(()=>{a(function(){try{let e=localStorage.getItem(c);if(!e)return localStorage.setItem(c,JSON.stringify(u)),u;return JSON.parse(e)}catch{return u}}())},[]);let g=(0,n.useCallback)(e=>{a(e),localStorage.setItem(c,JSON.stringify(e))},[]);return l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:()=>i(!1),className:"shrink-0 px-1.5 py-2 text-[10px] text-accent transition-colors",title:"Close presets",children:"Preset"}),(0,t.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>{i(!1),p(null)}}),(0,t.jsxs)("div",{className:"absolute bottom-full left-0 right-0 mb-1 z-50 border border-border bg-bg-surface max-h-[60vh] overflow-y-auto",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[11px] text-text font-semibold",children:"Message Presets"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{p({id:"",title:"",message:""}),f(""),x("")},className:"text-[10px] text-accent hover:underline",children:"+ New"}),(0,t.jsx)("button",{type:"button",onClick:()=>{i(!1),p(null)},className:"text-[11px] text-text-muted hover:text-text",children:"✕"})]})]}),s?(0,t.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,t.jsx)("input",{type:"text",value:h,onChange:e=>f(e.target.value),placeholder:"Preset title",className:"w-full bg-transparent border border-border px-2 py-1 text-[11px] text-text outline-none focus:border-accent"}),(0,t.jsx)("textarea",{value:m,onChange:e=>x(e.target.value),placeholder:"Message body",rows:5,className:"w-full bg-transparent border border-border px-2 py-1 text-[11px] text-text outline-none focus:border-accent resize-y font-mono"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{h.trim()&&m.trim()&&(s&&s.id?g(o.map(e=>e.id===s.id?{...e,title:h,message:m}:e)):g([...o,{id:`preset-${Date.now()}`,title:h,message:m}]),p(null))},disabled:!h.trim()||!m.trim(),className:"px-2 py-0.5 text-[10px] text-accent border border-accent/40 hover:bg-accent/10 transition-colors disabled:opacity-30",children:"Save"}),(0,t.jsx)("button",{type:"button",onClick:()=>p(null),className:"px-2 py-0.5 text-[10px] text-text-muted border border-border hover:text-text transition-colors",children:"Cancel"})]})]}):(0,t.jsxs)("div",{className:"divide-y divide-border/30",children:[0===o.length&&(0,t.jsx)("div",{className:"px-3 py-4 text-[11px] text-text-muted text-center",children:'No presets. Click "+ New" to create one.'}),o.map(n=>(0,t.jsx)("div",{className:"px-3 py-2 hover:bg-accent/5 group",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{r(n.message.replace(/\{\{project\}\}/g,e)),i(!1)},className:"text-left flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-[11px] text-text font-medium truncate",children:n.title}),(0,t.jsxs)("div",{className:"text-[10px] text-text-muted truncate mt-0.5",children:[n.message.slice(0,80),n.message.length>80?"…":""]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2 shrink-0",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{p(n),f(n.title),x(n.message)},className:"text-[10px] text-text-muted hover:text-accent",title:"Edit",children:"✎"}),(0,t.jsx)("button",{type:"button",onClick:()=>{var e;return e=n.id,void g(o.filter(t=>t.id!==e))},className:"text-[10px] text-text-muted hover:text-error",title:"Delete",children:"✕"})]})]})},n.id))]})]})]}):(0,t.jsx)("button",{type:"button",onClick:()=>i(!0),className:"shrink-0 px-1.5 py-2 text-[10px] text-text-muted hover:text-accent transition-colors",title:"Message presets",children:"Preset"})}let p={head:"#00ff88",re1:"#4488ff",re2:"#cc44ff",dev:"#ffcc00",user:"#e0e0e0",system:"#737373"},h=["head","re1","re2","dev","user"],f=[/^.+ is online$/,/disconnected \(timeout\)/,/^.+ disconnected$/,/auto-recovered/,/Resuming agent conversation/,/Loop guard:/],m=[{command:"/artchallenge",description:"SVG art challenge — all agents create artwork (optional theme)"},{command:"/hatmaking",description:"All agents design a hat to wear on their avatar"},{command:"/roastreview",description:"Get all agents to review and roast each other's work"},{command:"/poetry haiku",description:"Agents write a haiku about the codebase"},{command:"/poetry limerick",description:"Agents write a limerick about the codebase"},{command:"/poetry sonnet",description:"Agents write a sonnet about the codebase"},{command:"/summary",description:"Summarize recent messages — tag an agent (e.g. /summary @head)"},{command:"/continue",description:"Resume after loop guard pauses"},{command:"/clear",description:"Clear messages in current channel"}];function x(e){return p[e.toLowerCase()]||"#e0e0e0"}let g=/(^|\s)(@(?:head|dev|re1|re2|user))(?![\w-])/gi;function b({projectId:e,filterSystem:n}){return(0,t.jsx)(y,{projectId:e,filterSystem:n})}function y({projectId:e,filterSystem:r=!1}){let l="general",[i,o]=(0,n.useState)([]),[a,c]=(0,n.useState)(!1),[u,p]=(0,n.useState)(""),b=(0,n.useRef)(0),v=(0,n.useRef)(null),[w,k]=(0,n.useState)(!1),[j,N]=(0,n.useState)(""),[S,C]=(0,n.useState)(!1),[E,T]=(0,n.useState)(0),[I,A]=(0,n.useState)(null),[R,O]=(0,n.useState)(null),P=(0,n.useRef)(0),M=(0,n.useRef)(null),F=(0,n.useRef)(null),L=(0,n.useRef)(!1),D=(0,n.useRef)(!0),_=(0,n.useRef)(0);(0,n.useEffect)(()=>{P.current=0,o([]),c(!1),b.current=0,v.current&&(clearTimeout(v.current),v.current=null)},[e]);let $=(0,n.useCallback)(()=>{fetch(`/api/chat?path=/api/messages&channel=${encodeURIComponent(l)}&cursor=${P.current}${e?`&project=${encodeURIComponent(e)}`:""}`).then(e=>{if(403===e.status)throw _.current<3?A(null):A("Chat authentication failed (403). Check project chat configuration in Settings."),Error("auth failed");if(!e.ok)throw Error(`Poll failed: ${e.status}`);return e.json()}).then(e=>{A(null);let t=Array.isArray(e)?e:e.messages||[];if(t.length>0){o(e=>{let n=new Set(e.map(e=>e.id)),r=t.filter(e=>!n.has(e.id));return r.length>0?[...e,...r]:e});let e=Math.max(...t.map(e=>e.id));e>P.current&&(P.current=e)}c(!0)}).catch(()=>{!a&&b.current<3&&(b.current+=1,v.current=setTimeout($,2e3))})},[l,e,a]);(0,n.useEffect)(()=>{$();let e=setInterval($,3e3);return()=>{clearInterval(e),v.current&&(clearTimeout(v.current),v.current=null)}},[$]),(0,n.useEffect)(()=>{D.current&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[i]);let[U,z]=(0,n.useState)(!1),[B,H]=(0,n.useState)(null),[q,V]=(0,n.useState)([]),[W,G]=(0,n.useState)(!1),J=(0,n.useRef)(null),Q=async t=>{if(e){G(!0);try{let n=new FormData;n.append("file",t);let r=await fetch(`/api/upload?project=${encodeURIComponent(e)}`,{method:"POST",body:n});if(!r.ok){let e=await r.json().catch(()=>({error:`${r.status}`}));H(e.error||`Upload failed: ${r.status}`);return}let l=await r.json();V(e=>[...e,{path:l.path,name:l.name}])}catch(e){H(e.message)}finally{G(!1)}}},K=e=>{for(let t of e)t.type.startsWith("image/")&&Q(t)};(0,n.useEffect)(()=>{let e=F.current;e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,120)+"px")},[u]);let Y=()=>{let t=u.trim();if(!t&&0===q.length||U)return;let n=t.startsWith("/")||/^@(head|dev|re1|re2)\b/i.test(t)?t:`@head ${t}`;z(!0),H(null),fetch(`/api/chat${e?`?project=${encodeURIComponent(e)}`:""}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:n,channel:l,sender:"user",...q.length>0?{attachments:q}:{},...R?{reply_to:R.id}:{}})}).then(e=>{if(!e.ok)throw Error(`Send failed: ${e.status}`);p(""),V([]),O(null),setTimeout($,300)}).catch(e=>{H(e.message),console.error(e.message)}).finally(()=>z(!1))},X=(0,n.useCallback)(t=>{if(U)return;let n=t.startsWith("/")||/^@(head|dev|re1|re2)\b/i.test(t)?t:`@head ${t}`;z(!0),H(null),fetch(`/api/chat${e?`?project=${encodeURIComponent(e)}`:""}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:n,channel:l,sender:"user"})}).then(e=>{if(!e.ok)throw Error(`Send failed: ${e.status}`);setTimeout($,300)}).catch(e=>{H(e.message),console.error(e.message)}).finally(()=>z(!1))},[U,e,l,$]),Z=e=>{p(u.replace(/@\w*$/,`@${e} `)),k(!1),F.current?.focus()},ee=e=>{p(e.includes(" ")?e:`${e} `),C(!1),F.current?.focus()},et=h.filter(e=>e.toLowerCase().startsWith(j)),en=m.filter(e=>e.command.toLowerCase().startsWith(u.toLowerCase())),er=r?i.filter(e=>!function(e){if("system"===e.sender||"join"===e.type||"leave"===e.type)return!0;for(let t of f)if(t.test(e.text))return!0;return!1}(e)):i;return(0,t.jsxs)("div",{className:"flex flex-col h-full bg-bg",children:[I&&(0,t.jsx)("div",{className:"px-3 py-2 bg-red-900/30 border-b border-red-700/50 text-[11px] text-red-400",children:I}),(0,t.jsxs)("div",{ref:M,onScroll:()=>{if(!M.current)return;let{scrollTop:e,scrollHeight:t,clientHeight:n}=M.current;D.current=t-e-n<40},className:"flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-0.5",children:[!a&&0===i.length&&(0,t.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,t.jsx)("span",{className:"text-xs text-text-muted",children:"Loading messages..."})}),a&&0===er.length&&(0,t.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,t.jsx)(s,{onInsert:e=>{p(e),F.current?.focus()}})}),er.map(n=>{var r;let l;return(0,t.jsxs)("div",{className:"group flex gap-2 text-[12px] leading-5",children:[(0,t.jsx)("span",{className:"text-text-muted shrink-0 w-12 text-right tabular-nums",children:n.time?.slice(0,5)||""}),(0,t.jsx)("span",{className:"shrink-0 font-semibold w-10 text-right",style:{color:x(n.sender)},children:"re1"===(l=(r=n.sender).toLowerCase())?"RE1":"re2"===l?"RE2":r}),(0,t.jsxs)("span",{className:"text-text break-words min-w-0 whitespace-pre-wrap flex-1",children:[function(e){let n=[],r=0,l=0;for(let i of e.matchAll(g)){let o=i.index??0,a=i[1],s=i[2],c=o+a.length;c>r&&n.push(e.slice(r,c));let u=x(s.slice(1).toLowerCase());n.push((0,t.jsx)("span",{className:"inline-block px-1 py-0 rounded font-mono",style:{backgroundColor:`${u}22`,color:u},children:s},`m${l++}`)),r=c+s.length}return r<e.length&&n.push(e.slice(r)),n.length>0?n:[e]}(n.text),n.attachments&&n.attachments.length>0&&(0,t.jsx)("span",{className:"flex gap-2 mt-1",children:n.attachments.map(n=>(0,t.jsx)("a",{href:`/api/uploads/${encodeURIComponent(e||"")}/${encodeURIComponent(n.name)}`,target:"_blank",rel:"noopener noreferrer",children:(0,t.jsx)("img",{src:`/api/uploads/${encodeURIComponent(e||"")}/${encodeURIComponent(n.name)}`,alt:n.name,className:"max-w-[200px] max-h-[150px] object-cover border border-border rounded hover:border-accent transition-colors"})},n.name))})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{if(O({id:n.id,sender:n.sender}),new Set(["head","dev","re1","re2"]).has(n.sender.toLowerCase())){let e=`@${n.sender} `;p(t=>t.startsWith(e)?t:e)}F.current?.focus()},className:"shrink-0 self-start opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-[10px] text-text-muted hover:text-text px-1 py-0.5 border border-border/50 rounded",title:`Reply to message #${n.id}`,children:"reply"})]},n.id)})]}),(0,t.jsxs)("div",{className:"relative shrink-0 border-t border-border",children:[w&&et.length>0&&(0,t.jsx)("div",{className:"absolute bottom-full left-0 right-0 border border-border bg-bg-surface",children:et.map(e=>(0,t.jsxs)("button",{onClick:()=>Z(e),className:"w-full text-left px-3 py-1 text-[12px] hover:bg-[#1a1a1a] transition-colors",style:{color:x(e)},children:["@",e]},e))}),S&&en.length>0&&(0,t.jsx)("div",{className:"absolute bottom-full left-0 right-0 max-h-60 overflow-y-auto border border-border bg-bg-surface z-10",children:en.map((e,n)=>{let r=n===Math.min(E,en.length-1);return(0,t.jsxs)("button",{onClick:()=>ee(e.command),onMouseEnter:()=>T(n),className:`w-full text-left px-3 py-1 transition-colors flex items-baseline gap-2 ${r?"bg-[#1a1a1a]":"hover:bg-[#1a1a1a]"}`,children:[(0,t.jsx)("span",{className:"text-[12px] text-accent font-mono",children:e.command}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:e.description})]},e.command)})}),B&&(0,t.jsx)("div",{className:"px-3 py-1 text-[11px] text-red-400 bg-red-900/20 border-b border-red-700/40",children:B}),R&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 text-[11px] text-text-muted bg-bg-surface border-b border-border/50",children:[(0,t.jsxs)("span",{children:["Replying to ",(0,t.jsxs)("span",{style:{color:x(R.sender)},children:["@",R.sender]})," #",R.id]}),(0,t.jsx)("button",{type:"button",onClick:()=>O(null),className:"ml-auto hover:text-text",title:"Cancel reply (Esc)",children:"✕"})]}),(0,t.jsxs)("div",{className:"flex items-end gap-1 px-1 relative",children:[(0,t.jsx)("textarea",{ref:F,rows:1,value:u,onChange:e=>(e=>{p(e);let t=e.match(/@(\w*)$/);if(t){k(!0),N(t[1].toLowerCase()),C(!1);return}if(k(!1),e.startsWith("/")){let t=e.slice(1).includes(" "),n=e.startsWith("/poetry");C(!t||n),T(0)}else C(!1)})(e.target.value),onCompositionStart:()=>{L.current=!0},onCompositionEnd:()=>{L.current=!1},onKeyDown:e=>{if("Tab"===e.key&&w&&et.length>0){e.preventDefault(),Z(et[0]);return}if(S&&en.length>0){if("ArrowDown"===e.key){e.preventDefault(),T(e=>(e+1)%en.length);return}if("ArrowUp"===e.key){e.preventDefault(),T(e=>(e-1+en.length)%en.length);return}if("Tab"===e.key||"Enter"===e.key&&!e.shiftKey){e.preventDefault();let t=Math.min(E,en.length-1);ee(en[t].command);return}}"Enter"!==e.key||e.shiftKey||L.current||e.nativeEvent.isComposing||(e.preventDefault(),Y()),"Escape"===e.key&&(k(!1),C(!1),R&&O(null))},onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of Array.from(t))if(e.type.startsWith("image/")){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),K(n))},onDrop:e=>{let t=e.dataTransfer?.files;if(!t)return;let n=Array.from(t).filter(e=>e.type.startsWith("image/"));n.length>0&&(e.preventDefault(),K(n))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},placeholder:`Message #${l}...`,disabled:U,className:"flex-1 bg-transparent px-2 py-2 text-[12px] font-mono text-text placeholder:text-text-muted outline-none focus:ring-1 focus:ring-accent disabled:opacity-50 resize-none overflow-y-auto leading-snug",style:{maxHeight:120}}),(0,t.jsx)("input",{ref:J,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,className:"hidden",onChange:e=>{let t=e.target.files;t&&t.length>0&&K(Array.from(t)),e.target.value=""}}),(0,t.jsx)(d,{projectId:e||"",onSend:X}),(0,t.jsx)("button",{type:"button",onClick:()=>J.current?.click(),disabled:W,className:"shrink-0 px-1.5 py-2 text-[13px] text-text-muted hover:text-accent transition-colors disabled:opacity-30",title:"Attach image",children:"📎"}),(0,t.jsx)("button",{onClick:Y,disabled:U||!u.trim()&&0===q.length,className:"shrink-0 px-2 py-2 text-[11px] font-mono text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Send (Enter)",children:U?"…":"Send"})]}),(q.length>0||W)&&(0,t.jsxs)("div",{className:"flex gap-2 px-2 py-1 flex-wrap",children:[q.map((n,r)=>(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)("img",{src:`/api/uploads/${encodeURIComponent(e||"")}/${encodeURIComponent(n.name)}`,alt:n.name,className:"h-16 max-w-[200px] object-cover border border-border rounded"}),(0,t.jsx)("button",{type:"button",onClick:()=>V(e=>e.filter((e,t)=>t!==r)),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-bg border border-border rounded-full text-[10px] text-text-muted hover:text-error opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",title:"Remove",children:"×"})]},n.name)),W&&(0,t.jsx)("div",{className:"h-16 w-16 border border-border rounded flex items-center justify-center",children:(0,t.jsx)("span",{className:"text-[10px] text-text-muted animate-pulse",children:"..."})})]})]})]})}function v(){}function w(){}let k=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,j=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,N={};function S(e,t){return((t||N).jsx?j:k).test(e)}let C=/[ \t\n\f\r]/g;function E(e){return""===e.replace(C,"")}class T{constructor(e,t){this.attribute=t,this.property=e}}T.prototype.attribute="",T.prototype.booleanish=!1,T.prototype.boolean=!1,T.prototype.commaOrSpaceSeparated=!1,T.prototype.commaSeparated=!1,T.prototype.defined=!1,T.prototype.mustUseProperty=!1,T.prototype.number=!1,T.prototype.overloadedBoolean=!1,T.prototype.property="",T.prototype.spaceSeparated=!1,T.prototype.space=void 0;let I=0,A=D(),R=D(),O=D(),P=D(),M=D(),F=D(),L=D();function D(){return 2**++I}e.s(["boolean",0,A,"booleanish",0,R,"commaOrSpaceSeparated",0,L,"commaSeparated",0,F,"number",0,P,"overloadedBoolean",0,O,"spaceSeparated",0,M],744);var _=e.i(744);let $=Object.keys(_);class U extends T{constructor(e,t,n,r){let l=-1;if(super(e,t),function(e,t,n){n&&(e[t]=n)}(this,"space",r),"number"==typeof n)for(;++l<$.length;){const e=$[l];!function(e,t,n){n&&(e[t]=n)}(this,$[l],(n&_[e])===_[e])}}}function z(e){return e.toLowerCase()}U.prototype.defined=!0;let B=/[A-Z]/g,H=/-[a-z]/g,q=/^data[-\w.:]+$/i;function V(e){return"-"+e.toLowerCase()}function W(e){return e.charAt(1).toUpperCase()}let G={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};class J{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function Q(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new J(n,r,t)}function K(e){let t={},n={};for(let[r,l]of Object.entries(e.properties)){let i=new U(r,e.transform(e.attributes||{},r),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[z(r)]=r,n[z(i.attribute)]=r}return new J(t,n,e.space)}J.prototype.normal={},J.prototype.property={},J.prototype.space=void 0;let Y=K({properties:{ariaActiveDescendant:null,ariaAtomic:R,ariaAutoComplete:null,ariaBusy:R,ariaChecked:R,ariaColCount:P,ariaColIndex:P,ariaColSpan:P,ariaControls:M,ariaCurrent:null,ariaDescribedBy:M,ariaDetails:null,ariaDisabled:R,ariaDropEffect:M,ariaErrorMessage:null,ariaExpanded:R,ariaFlowTo:M,ariaGrabbed:R,ariaHasPopup:null,ariaHidden:R,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:M,ariaLevel:P,ariaLive:null,ariaModal:R,ariaMultiLine:R,ariaMultiSelectable:R,ariaOrientation:null,ariaOwns:M,ariaPlaceholder:null,ariaPosInSet:P,ariaPressed:R,ariaReadOnly:R,ariaRelevant:null,ariaRequired:R,ariaRoleDescription:M,ariaRowCount:P,ariaRowIndex:P,ariaRowSpan:P,ariaSelected:R,ariaSetSize:P,ariaSort:null,ariaValueMax:P,ariaValueMin:P,ariaValueNow:P,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function X(e,t){return t in e?e[t]:t}function Z(e,t){return X(e,t.toLowerCase())}let ee=K({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:F,acceptCharset:M,accessKey:M,action:null,allow:null,allowFullScreen:A,allowPaymentRequest:A,allowUserMedia:A,alt:null,as:null,async:A,autoCapitalize:null,autoComplete:M,autoFocus:A,autoPlay:A,blocking:M,capture:null,charSet:null,checked:A,cite:null,className:M,cols:P,colSpan:null,content:null,contentEditable:R,controls:A,controlsList:M,coords:P|F,crossOrigin:null,data:null,dateTime:null,decoding:null,default:A,defer:A,dir:null,dirName:null,disabled:A,download:O,draggable:R,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:A,formTarget:null,headers:M,height:P,hidden:O,high:P,href:null,hrefLang:null,htmlFor:M,httpEquiv:M,id:null,imageSizes:null,imageSrcSet:null,inert:A,inputMode:null,integrity:null,is:null,isMap:A,itemId:null,itemProp:M,itemRef:M,itemScope:A,itemType:M,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:A,low:P,manifest:null,max:null,maxLength:P,media:null,method:null,min:null,minLength:P,multiple:A,muted:A,name:null,nonce:null,noModule:A,noValidate:A,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:A,optimum:P,pattern:null,ping:M,placeholder:null,playsInline:A,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:A,referrerPolicy:null,rel:M,required:A,reversed:A,rows:P,rowSpan:P,sandbox:M,scope:null,scoped:A,seamless:A,selected:A,shadowRootClonable:A,shadowRootDelegatesFocus:A,shadowRootMode:null,shape:null,size:P,sizes:null,slot:null,span:P,spellCheck:R,src:null,srcDoc:null,srcLang:null,srcSet:null,start:P,step:null,style:null,tabIndex:P,target:null,title:null,translate:null,type:null,typeMustMatch:A,useMap:null,value:R,width:P,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:M,axis:null,background:null,bgColor:null,border:P,borderColor:null,bottomMargin:P,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:A,declare:A,event:null,face:null,frame:null,frameBorder:null,hSpace:P,leftMargin:P,link:null,longDesc:null,lowSrc:null,marginHeight:P,marginWidth:P,noResize:A,noHref:A,noShade:A,noWrap:A,object:null,profile:null,prompt:null,rev:null,rightMargin:P,rules:null,scheme:null,scrolling:R,standby:null,summary:null,text:null,topMargin:P,valueType:null,version:null,vAlign:null,vLink:null,vSpace:P,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:A,disableRemotePlayback:A,prefix:null,property:null,results:P,security:null,unselectable:null},space:"html",transform:Z}),et=K({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:L,accentHeight:P,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:P,amplitude:P,arabicForm:null,ascent:P,attributeName:null,attributeType:null,azimuth:P,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:P,by:null,calcMode:null,capHeight:P,className:M,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:P,diffuseConstant:P,direction:null,display:null,dur:null,divisor:P,dominantBaseline:null,download:A,dx:null,dy:null,edgeMode:null,editable:null,elevation:P,enableBackground:null,end:null,event:null,exponent:P,externalResourcesRequired:null,fill:null,fillOpacity:P,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:F,g2:F,glyphName:F,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:P,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:P,horizOriginX:P,horizOriginY:P,id:null,ideographic:P,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:P,k:P,k1:P,k2:P,k3:P,k4:P,kernelMatrix:L,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:P,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:P,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:P,overlineThickness:P,paintOrder:null,panose1:null,path:null,pathLength:P,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:M,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:P,pointsAtY:P,pointsAtZ:P,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:L,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:L,rev:L,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:L,requiredFeatures:L,requiredFonts:L,requiredFormats:L,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:P,specularExponent:P,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:P,strikethroughThickness:P,string:null,stroke:null,strokeDashArray:L,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:P,strokeOpacity:P,strokeWidth:null,style:null,surfaceScale:P,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:L,tabIndex:P,tableValues:null,target:null,targetX:P,targetY:P,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:L,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:P,underlineThickness:P,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:P,values:null,vAlphabetic:P,vMathematical:P,vectorEffect:null,vHanging:P,vIdeographic:P,version:null,vertAdvY:P,vertOriginX:P,vertOriginY:P,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:P,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:X}),en=K({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),er=K({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Z}),el=K({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),ei=Q([Y,ee,en,er,el],"html"),eo=Q([Y,et,en,er,el],"svg");var ea=e.i(15511);let es=eu("end"),ec=eu("start");function eu(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function ed(e){return e&&"object"==typeof e?"position"in e||"type"in e?eh(e.position):"start"in e||"end"in e?eh(e):"line"in e||"column"in e?ep(e):"":""}function ep(e){return ef(e&&e.line)+":"+ef(e&&e.column)}function eh(e){return ep(e&&e.start)+"-"+ep(e&&e.end)}function ef(e){return e&&"number"==typeof e?e:1}class em extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",l={},i=!1;if(t&&(l="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!l.cause&&e&&(i=!0,r=e.message,l.cause=e),!l.ruleId&&!l.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?l.ruleId=n:(l.source=n.slice(0,e),l.ruleId=n.slice(e+1))}if(!l.place&&l.ancestors&&l.ancestors){const e=l.ancestors[l.ancestors.length-1];e&&(l.place=e.position)}const o=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=o?o.line:void 0,this.name=ed(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=i&&l.cause&&"string"==typeof l.cause.stack?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}em.prototype.file="",em.prototype.name="",em.prototype.reason="",em.prototype.message="",em.prototype.stack="",em.prototype.column=void 0,em.prototype.line=void 0,em.prototype.ancestors=void 0,em.prototype.cause=void 0,em.prototype.fatal=void 0,em.prototype.place=void 0,em.prototype.ruleId=void 0,em.prototype.source=void 0;let ex={}.hasOwnProperty,eg=new Map,eb=/[A-Z]/g,ey=new Set(["table","tbody","thead","tfoot","tr"]),ev=new Set(["td","th"]),ew="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ek(e,t,n){var r,l,i,o,a,s,c,u,d;let p,h,f,m,x,g,b,y,w,k,j;return"element"===t.type?(r=e,l=t,i=n,h=p=r.schema,"svg"===l.tagName.toLowerCase()&&"html"===p.space&&(r.schema=eo),r.ancestors.push(l),f=eC(r,l.tagName,!1),m=function(e,t){let n,r,l={};for(r in t.properties)if("children"!==r&&ex.call(t.properties,r)){let i=function(e,t,n){let r=function(e,t){let n=z(t),r=t,l=T;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&q.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(H,W);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!H.test(e)){let n=e.replace(B,V);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}l=U}return new l(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){var l;let t;if(Array.isArray(n)&&(n=r.commaSeparated?(t={},(""===(l=n)[l.length-1]?[...l,""]:l).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return(0,ea.default)(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let t=new em("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=ew+"#cannot-parse-style-attribute",t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)ex.call(e,t)&&(n[function(e){let t=e.replace(eb,eT);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?G[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(i){let[r,o]=i;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof o&&ev.has(t.tagName)?n=o:l[r]=o}}return n&&((l.style||(l.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),l}(r,l),x=eS(r,l),ey.has(l.tagName)&&(x=x.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&E(e.value):E(e))})),ej(r,m,f,l),eN(m,x),r.ancestors.pop(),r.schema=p,r.create(l,f,m,i)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return v("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}eE(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(o=e,a=t,s=n,b=g=o.schema,"svg"===a.name&&"html"===g.space&&(o.schema=eo),o.ancestors.push(a),y=null===a.name?o.Fragment:eC(o,a.name,!0),w=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];v("ExpressionStatement"===t.type);let l=t.expression;v("ObjectExpression"===l.type);let i=l.properties[0];v("SpreadElement"===i.type),Object.assign(n,e.evaluater.evaluateExpression(i.argument))}else eE(e,t.position);else{let l,i=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];v("ExpressionStatement"===t.type),l=e.evaluater.evaluateExpression(t.expression)}else eE(e,t.position);else l=null===r.value||r.value;n[i]=l}return n}(o,a),k=eS(o,a),ej(o,w,y,a),eN(w,k),o.ancestors.pop(),o.schema=g,o.create(a,y,w,s)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);eE(e,t.position)}(e,t):"root"===t.type?(c=e,u=t,d=n,eN(j={},eS(c,u)),c.create(u,c.Fragment,j,d)):"text"===t.type?t.value:void 0}function ej(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function eN(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function eS(e,t){let n=[],r=-1,l=e.passKeys?new Map:eg;for(;++r<t.children.length;){let i,o=t.children[r];if(e.passKeys){let e="element"===o.type?o.tagName:"mdxJsxFlowElement"===o.type||"mdxJsxTextElement"===o.type?o.name:void 0;if(e){let t=l.get(e)||0;i=e+"-"+t,l.set(e,t+1)}}let a=ek(e,o,i);void 0!==a&&n.push(a)}return n}function eC(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),l=-1;for(;++l<n.length;){let t=S(n[l])?{type:"Identifier",name:n[l]}:{type:"Literal",value:n[l]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(l&&"Literal"===t.type),optional:!1}:t}v(e,"always a result"),r=e}else r=S(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return ex.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);eE(e)}function eE(e,t){let n=new em("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=ew+"#cannot-handle-mdx-estrees-without-createevaluater",n}function eT(e){return"-"+e.toLowerCase()}let eI={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},eA={};function eR(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return eO(e.children,t,n)}return Array.isArray(e)?eO(e,t,n):""}function eO(e,t,n){let r=[],l=-1;for(;++l<e.length;)r[l]=eR(e[l],t,n);return r.join("")}function eP(e,t,n,r){let l,i=e.length,o=0;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)(l=Array.from(r)).unshift(t,n),e.splice(...l);else for(n&&e.splice(t,n);o<r.length;)(l=r.slice(o,o+1e4)).unshift(t,0),e.splice(...l),o+=1e4,t+=1e4}function eM(e,t){return e.length>0?(eP(e,e.length,0,t),e):t}let eF={}.hasOwnProperty,eL=eJ(/[A-Za-z]/),eD=eJ(/[\dA-Za-z]/),e_=eJ(/[#-'*+\--9=?A-Z^-~]/);function e$(e){return null!==e&&(e<32||127===e)}let eU=eJ(/\d/),ez=eJ(/[\dA-Fa-f]/),eB=eJ(/[!-/:-@[-`{-~]/);function eH(e){return null!==e&&e<-2}function eq(e){return null!==e&&(e<0||32===e)}function eV(e){return -2===e||-1===e||32===e}let eW=eJ(/\p{P}|\p{S}/u),eG=eJ(/\s/);function eJ(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function eQ(e,t,n,r){let l=r?r-1:1/0,i=0;return function(r){return eV(r)?(e.enter(n),function r(o){return eV(o)&&i++<l?(e.consume(o),r):(e.exit(n),t(o))}(r)):t(r)}}let eK={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),eQ(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let l=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=l),t=l,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return eH(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},eY={tokenize:function(e){let t,n,r,l=this,i=[],o=0;return a;function a(t){if(o<i.length){let n=i[o];return l.containerState=n[1],e.attempt(n[0].continuation,s,c)(t)}return c(t)}function s(e){if(o++,l.containerState._closeFlow){let n;l.containerState._closeFlow=void 0,t&&g();let r=l.events.length,i=r;for(;i--;)if("exit"===l.events[i][0]&&"chunkFlow"===l.events[i][1].type){n=l.events[i][1].end;break}x(o);let a=r;for(;a<l.events.length;)l.events[a][1].end={...n},a++;return eP(l.events,i+1,0,l.events.slice(r)),l.events.length=a,c(e)}return a(e)}function c(n){if(o===i.length){if(!t)return p(n);if(t.currentConstruct&&t.currentConstruct.concrete)return f(n);l.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return l.containerState={},e.check(eX,u,d)(n)}function u(e){return t&&g(),x(o),p(e)}function d(e){return l.parser.lazy[l.now().line]=o!==i.length,r=l.now().offset,f(e)}function p(t){return l.containerState={},e.attempt(eX,h,f)(t)}function h(e){return o++,i.push([l.currentConstruct,l.containerState]),p(e)}function f(r){if(null===r){t&&g(),x(0),e.consume(r);return}return t=t||l.parser.flow(l.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){m(e.exit("chunkFlow"),!0),x(0),e.consume(n);return}return eH(n)?(e.consume(n),m(e.exit("chunkFlow")),o=0,l.interrupt=void 0,a):(e.consume(n),t)}(r)}function m(e,i){let a=l.sliceStream(e);if(i&&a.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(a),l.parser.lazy[e.start.line]){let e,n,i=t.events.length;for(;i--;)if(t.events[i][1].start.offset<r&&(!t.events[i][1].end||t.events[i][1].end.offset>r))return;let a=l.events.length,s=a;for(;s--;)if("exit"===l.events[s][0]&&"chunkFlow"===l.events[s][1].type){if(e){n=l.events[s][1].end;break}e=!0}for(x(o),i=a;i<l.events.length;)l.events[i][1].end={...n},i++;eP(l.events,s+1,0,l.events.slice(a)),l.events.length=i}}function x(t){let n=i.length;for(;n-- >t;){let t=i[n];l.containerState=t[1],t[0].exit.call(l,e)}i.length=t}function g(){t.write([null]),n=void 0,t=void 0,l.containerState._closeFlow=void 0}}},eX={tokenize:function(e,t,n){return eQ(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},eZ={partial:!0,tokenize:function(e,t,n){return function(t){return eV(t)?eQ(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||eH(e)?t(e):n(e)}}};class e0{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&e1(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),e1(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),e1(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);e1(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);e1(this.left,t.reverse())}}}function e1(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function e2(e){let t,n,r,l,i,o,a,s={},c=-1,u=new e0(e);for(;++c<u.length;){for(;c in s;)c=s[c];if(t=u.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&((r=0)<(o=t[1]._tokenizer.events).length&&"lineEndingBlank"===o[r][1].type&&(r+=2),r<o.length&&"content"===o[r][1].type))for(;++r<o.length&&"content"!==o[r][1].type;)"chunkText"===o[r][1].type&&(o[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(s,function(e,t){let n,r,l=e.get(t)[1],i=e.get(t)[2],o=t-1,a=[],s=l._tokenizer;!s&&(s=i.parser[l.contentType](l.start),l._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let c=s.events,u=[],d={},p=-1,h=l,f=0,m=0,x=[0];for(;h;){for(;e.get(++o)[1]!==h;);a.push(o),!h._tokenizer&&(n=i.sliceStream(h),h.next||n.push(null),r&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(n),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),r=h,h=h.next}for(h=l;++p<c.length;)"exit"===c[p][0]&&"enter"===c[p-1][0]&&c[p][1].type===c[p-1][1].type&&c[p][1].start.line!==c[p][1].end.line&&(m=p+1,x.push(m),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):x.pop(),p=x.length;p--;){let t=c.slice(x[p],x[p+1]),n=a.pop();u.push([n,n+t.length-1]),e.splice(n,2,t)}for(u.reverse(),p=-1;++p<u.length;)d[f+u[p][0]]=f+u[p][1],f+=u[p][1]-u[p][0]-1;return d}(u,c)),c=s[c],a=!0);else if(t[1]._container){for(r=c,n=void 0;r--;)if("lineEnding"===(l=u.get(r))[1].type||"lineEndingBlank"===l[1].type)"enter"===l[0]&&(n&&(u.get(n)[1].type="lineEndingBlank"),l[1].type="lineEnding",n=r);else if("linePrefix"===l[1].type||"listItemIndent"===l[1].type);else break;n&&(t[1].end={...u.get(n)[1].start},(i=u.slice(n,c)).unshift(t),u.splice(n,c-n+1,i))}}return eP(e,0,1/0,u.slice(0)),!a}let e5={resolve:function(e){return e2(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?l(t):eH(t)?e.check(e4,i,l)(t):(e.consume(t),r)}function l(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function i(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},e4={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),eQ(e,l,"linePrefix")};function l(l){if(null===l||eH(l))return n(l);let i=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(l):e.interrupt(r.parser.constructs.flow,n,t)(l)}}},e3={tokenize:function(e){let t=this,n=e.attempt(eZ,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,eQ(e,e.attempt(this.parser.constructs.flow,r,e.attempt(e5,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},e6={resolveAll:te()},e9=e8("string"),e7=e8("text");function e8(e){return{resolveAll:te("text"===e?tt:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],l=t.attempt(r,i,o);return i;function i(e){return s(e)?l(e):o(e)}function o(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),a)}function a(e){return s(e)?(t.exit("data"),l(e)):(t.consume(e),a)}function s(e){if(null===e)return!0;let t=r[e],l=-1;if(t)for(;++l<t.length;){let e=t[l];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function te(e){return function(t,n){let r,l=-1;for(;++l<=t.length;)void 0===r?t[l]&&"data"===t[l][1].type&&(r=l,l++):t[l]&&"data"===t[l][1].type||(l!==r+2&&(t[r][1].end=t[l-1][1].end,t.splice(r+2,l-r-2),l=r+2),r=void 0);return e?e(t,n):t}}function tt(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,l=e[n-1][1],i=t.sliceStream(l),o=i.length,a=-1,s=0;for(;o--;){let e=i[o];if("string"==typeof e){for(a=e.length;32===e.charCodeAt(a-1);)s++,a--;if(a)break;a=-1}else if(-2===e)r=!0,s++;else if(-1===e);else{o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||r||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:l.start._bufferIndex+a,_index:l.start._index+o,line:l.end.line,column:l.end.column-s,offset:l.end.offset-s},end:{...l.end}};l.end={...i.start},l.start.offset===l.end.offset?Object.assign(l,i):(e.splice(n,0,["enter",i,t],["exit",i,t]),n+=2)}n++}return e}function tn(e){return null===e||eq(e)||eG(e)?1:eW(e)?2:void 0}function tr(e,t,n){let r=[],l=-1;for(;++l<e.length;){let i=e[l].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}let tl={name:"attention",resolveAll:function(e,t){let n,r,l,i,o,a,s,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close){for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;a=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;let d={...e[n][1].end},p={...e[u][1].start};ti(d,-a),ti(p,a),i={type:a>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},o={type:a>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:p},l={type:a>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:a>1?"strong":"emphasis",start:{...i.start},end:{...o.end}},e[n][1].end={...i.start},e[u][1].start={...o.end},s=[],e[n][1].end.offset-e[n][1].start.offset&&(s=eM(s,[["enter",e[n][1],t],["exit",e[n][1],t]])),s=eM(s,[["enter",r,t],["enter",i,t],["exit",i,t],["enter",l,t]]),s=eM(s,tr(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),s=eM(s,[["exit",l,t],["enter",o,t],["exit",o,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,s=eM(s,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,eP(e,n-1,u-n+3,s),u=n+s.length-c-2;break}}for(u=-1;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,l=this.previous,i=tn(l);return function(o){return n=o,e.enter("attentionSequence"),function o(a){if(a===n)return e.consume(a),o;let s=e.exit("attentionSequence"),c=tn(a),u=!c||2===c&&i||r.includes(a),d=!i||2===i&&c||r.includes(l);return s._open=!!(42===n?u:u&&(i||!d)),s._close=!!(42===n?d:d&&(c||!u)),t(a)}(o)}}};function ti(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let to={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return eV(t)?eQ(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)};function l(r){return e.attempt(to,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),l}return n(t)};function l(n){return eV(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}},ta={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return eB(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},ts=document.createElement("i");function tc(e){let t="&"+e+";";ts.innerHTML=t;let n=ts.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let tu={name:"characterReference",tokenize:function(e,t,n){let r,l,i=this,o=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),a};function a(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),s):(e.enter("characterReferenceValue"),r=31,l=eD,c(t))}function s(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,l=ez,c):(e.enter("characterReferenceValue"),r=7,l=eU,c(t))}function c(a){if(59===a&&o){let r=e.exit("characterReferenceValue");return l!==eD||tc(i.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(a),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(a)}return l(a)&&o++<r?(e.consume(a),c):n(a)}}},td={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l)};function l(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},tp={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,l=this,i={partial:!0,tokenize:function(e,t,n){let i=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o};function o(t){return e.enter("codeFencedFence"),eV(t)?eQ(e,s,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):s(t)}function s(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(l){return l===r?(i++,e.consume(l),t):i>=a?(e.exit("codeFencedFenceSequence"),eV(l)?eQ(e,c,"whitespace")(l):c(l)):n(l)}(t)):n(t)}function c(r){return null===r||eH(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},o=0,a=0;return function(t){var i;let c;return i=t,o=(c=l.events[l.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,r=i,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(l){return l===r?(a++,e.consume(l),t):a<3?n(l):(e.exit("codeFencedFenceSequence"),eV(l)?eQ(e,s,"whitespace")(l):s(l))}(i)};function s(i){return null===i||eH(i)?(e.exit("codeFencedFence"),l.interrupt?t(i):e.check(td,u,f)(i)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(l){return null===l||eH(l)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),s(l)):eV(l)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),eQ(e,c,"whitespace")(l)):96===l&&l===r?n(l):(e.consume(l),t)}(i))}function c(t){return null===t||eH(t)?s(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(l){return null===l||eH(l)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),s(l)):96===l&&l===r?n(l):(e.consume(l),t)}(t))}function u(t){return e.attempt(i,f,d)(t)}function d(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),p}function p(t){return o>0&&eV(t)?eQ(e,h,"linePrefix",o+1)(t):h(t)}function h(t){return null===t||eH(t)?e.check(td,u,f)(t):(e.enter("codeFlowValue"),function t(n){return null===n||eH(n)?(e.exit("codeFlowValue"),h(n)):(e.consume(n),t)}(t))}function f(n){return e.exit("codeFenced"),t(n)}}},th={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),eQ(e,l,"linePrefix",5)(t)};function l(t){let l=r.events[r.events.length-1];return l&&"linePrefix"===l[1].type&&l[2].sliceSerialize(l[1],!0).length>=4?function t(n){return null===n?i(n):eH(n)?e.attempt(tf,t,i)(n):(e.enter("codeFlowValue"),function n(r){return null===r||eH(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function i(n){return e.exit("codeIndented"),t(n)}}},tf={partial:!0,tokenize:function(e,t,n){let r=this;return l;function l(t){return r.parser.lazy[r.now().line]?n(t):eH(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l):eQ(e,i,"linePrefix",5)(t)}function i(e){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(e):eH(e)?l(e):n(e)}}};function tm(e,t,n,r,l,i,o,a,s){let c=s||1/0,u=0;return function(t){return 60===t?(e.enter(r),e.enter(l),e.enter(i),e.consume(t),e.exit(i),d):null===t||32===t||41===t||e$(t)?n(t):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),f(t))};function d(n){return 62===n?(e.enter(i),e.consume(n),e.exit(i),e.exit(l),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(n))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(a),d(t)):null===t||60===t||eH(t)?n(t):(e.consume(t),92===t?h:p)}function h(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function f(l){return!u&&(null===l||41===l||eq(l))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(l)):u<c&&40===l?(e.consume(l),u++,f):41===l?(e.consume(l),u--,f):null===l||32===l||40===l||e$(l)?n(l):(e.consume(l),92===l?m:f)}function m(t){return 40===t||41===t||92===t?(e.consume(t),f):f(t)}}function tx(e,t,n,r,l,i){let o,a=this,s=0;return function(t){return e.enter(r),e.enter(l),e.consume(t),e.exit(l),e.enter(i),c};function c(d){return s>999||null===d||91===d||93===d&&!o||94===d&&!s&&"_hiddenFootnoteSupport"in a.parser.constructs?n(d):93===d?(e.exit(i),e.enter(l),e.consume(d),e.exit(l),e.exit(r),t):eH(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||eH(t)||s++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!eV(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),s++,u):u(t)}}function tg(e,t,n,r,l,i){let o;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(l),e.consume(t),e.exit(l),o=40===t?41:t,a):n(t)};function a(n){return n===o?(e.enter(l),e.consume(n),e.exit(l),e.exit(r),t):(e.enter(i),s(n))}function s(t){return t===o?(e.exit(i),a(o)):null===t?n(t):eH(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),eQ(e,s,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===o||null===t||eH(t)?(e.exit("chunkString"),s(t)):(e.consume(t),92===t?u:c)}function u(t){return t===o||92===t?(e.consume(t),c):c(t)}}function tb(e,t){let n;return function r(l){return eH(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),n=!0,r):eV(l)?eQ(e,r,n?"linePrefix":"lineSuffix")(l):t(l)}}function ty(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let tv={partial:!0,tokenize:function(e,t,n){return function(t){return eq(t)?tb(e,r)(t):n(t)};function r(t){return tg(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function l(t){return eV(t)?eQ(e,i,"whitespace")(t):i(t)}function i(e){return null===e||eH(e)?t(e):n(e)}}},tw=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],tk=["pre","script","style","textarea"],tj={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(eZ,t,n)}}},tN={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return eH(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l):n(t)};function l(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},tS={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&eP(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,l,i,o=e.length,a=0;for(;o--;)if(n=e[o][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[o][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(l){if("enter"===e[o][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=o,"labelLink"!==n.type)){a=2;break}}else"labelEnd"===n.type&&(l=o);let s={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[l][1].end}},u={type:"labelText",start:{...e[r+a+2][1].end},end:{...e[l-2][1].start}};return i=eM(i=[["enter",s,t],["enter",c,t]],e.slice(r+1,r+a+3)),i=eM(i,[["enter",u,t]]),i=eM(i,tr(t.parser.constructs.insideSpan.null,e.slice(r+a+4,l-3),t)),i=eM(i,[["exit",u,t],e[l-2],e[l-1],["exit",c,t]]),i=eM(i,e.slice(l+1)),i=eM(i,[["exit",s,t]]),eP(e,r,e.length,i),e},tokenize:function(e,t,n){let r,l,i=this,o=i.events.length;for(;o--;)if(("labelImage"===i.events[o][1].type||"labelLink"===i.events[o][1].type)&&!i.events[o][1]._balanced){r=i.events[o][1];break}return function(t){return r?r._inactive?u(t):(l=i.parser.defined.includes(ty(i.sliceSerialize({start:r.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),a):n(t)};function a(t){return 40===t?e.attempt(tC,c,l?c:u)(t):91===t?e.attempt(tE,c,l?s:u)(t):l?c(t):u(t)}function s(t){return e.attempt(tT,c,u)(t)}function c(e){return t(e)}function u(e){return r._balanced=!0,n(e)}}},tC={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return eq(t)?tb(e,l)(t):l(t)}function l(t){return 41===t?c(t):tm(e,i,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function i(t){return eq(t)?tb(e,a)(t):c(t)}function o(e){return n(e)}function a(t){return 34===t||39===t||40===t?tg(e,s,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function s(t){return eq(t)?tb(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},tE={tokenize:function(e,t,n){let r=this;return function(t){return tx.call(r,e,l,i,"reference","referenceMarker","referenceString")(t)};function l(e){return r.parser.defined.includes(ty(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function i(e){return n(e)}}},tT={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},tI={name:"labelStartImage",resolveAll:tS.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),l};function l(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),i):n(t)}function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},tA={name:"labelStartLink",resolveAll:tS.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),l};function l(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},tR={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),eQ(e,t,"linePrefix")}}},tO={name:"thematicBreak",tokenize:function(e,t,n){let r,l=0;return function(i){var o;return e.enter("thematicBreak"),r=o=i,function i(o){return o===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),l++,t):(e.exit("thematicBreakSequence"),eV(n)?eQ(e,i,"whitespace")(n):i(n))}(o)):l>=3&&(null===o||eH(o))?(e.exit("thematicBreak"),t(o)):n(o)}(o)}}},tP={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(eZ,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,eQ(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!eV(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,l(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(tF,t,l)(n))});function l(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,eQ(e,e.attempt(tP,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,l=r.events[r.events.length-1],i=l&&"linePrefix"===l[1].type?l[2].sliceSerialize(l[1],!0).length:0,o=0;return function(t){let l=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===l?!r.containerState.marker||t===r.containerState.marker:eU(t)){if(r.containerState.type||(r.containerState.type=l,e.enter(l,{_container:!0})),"listUnordered"===l)return e.enter("listItemPrefix"),42===t||45===t?e.check(tO,n,a)(t):a(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(l){return eU(l)&&++o<10?(e.consume(l),t):(!r.interrupt||o<2)&&(r.containerState.marker?l===r.containerState.marker:41===l||46===l)?(e.exit("listItemValue"),a(l)):n(l)}(t)}return n(t)};function a(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(eZ,r.interrupt?n:s,e.attempt(tM,u,c))}function s(e){return r.containerState.initialBlankLine=!0,i++,u(e)}function c(t){return eV(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},tM={partial:!0,tokenize:function(e,t,n){let r=this;return eQ(e,function(e){let l=r.events[r.events.length-1];return!eV(e)&&l&&"listItemPrefixWhitespace"===l[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},tF={partial:!0,tokenize:function(e,t,n){let r=this;return eQ(e,function(e){let l=r.events[r.events.length-1];return l&&"listItemIndent"===l[1].type&&l[2].sliceSerialize(l[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},tL={name:"setextUnderline",resolveTo:function(e,t){let n,r,l,i=e.length;for(;i--;)if("enter"===e[i][0]){if("content"===e[i][1].type){n=i;break}"paragraph"===e[i][1].type&&(r=i)}else"content"===e[i][1].type&&e.splice(i,1),l||"definition"!==e[i][1].type||(l=i);let o={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",l?(e.splice(r,0,["enter",o,t]),e.splice(l+1,0,["exit",e[n][1],t]),e[n][1].end={...e[l][1].end}):e[n][1]=o,e.push(["exit",o,t]),e},tokenize:function(e,t,n){let r,l=this;return function(t){var o;let a,s=l.events.length;for(;s--;)if("lineEnding"!==l.events[s][1].type&&"linePrefix"!==l.events[s][1].type&&"content"!==l.events[s][1].type){a="paragraph"===l.events[s][1].type;break}return!l.parser.lazy[l.now().line]&&(l.interrupt||a)?(e.enter("setextHeadingLine"),r=t,o=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),eV(n)?eQ(e,i,"lineSuffix")(n):i(n))}(o)):n(t)};function i(r){return null===r||eH(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let r,l=this;return function(t){var r;return e.enter("definition"),r=t,tx.call(l,e,i,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function i(t){return(r=ty(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o):n(t)}function o(t){return eq(t)?tb(e,a)(t):a(t)}function a(t){return tm(e,s,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function s(t){return e.attempt(tv,c,c)(t)}function c(t){return eV(t)?eQ(e,u,"whitespace")(t):u(t)}function u(i){return null===i||eH(i)?(e.exit("definition"),l.parser.defined.push(r),t(i)):n(i)}}}},"disable",0,{null:[]},"document",0,{42:tP,43:tP,45:tP,48:tP,49:tP,50:tP,51:tP,52:tP,53:tP,54:tP,55:tP,56:tP,57:tP,62:to},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let n,r,l=e.length-2,i=3;return"whitespace"===e[3][1].type&&(i+=2),l-2>i&&"whitespace"===e[l][1].type&&(l-=2),"atxHeadingSequence"===e[l][1].type&&(i===l-1||l-4>i&&"whitespace"===e[l-2][1].type)&&(l-=i+1===l?2:4),l>i&&(n={type:"atxHeadingText",start:e[i][1].start,end:e[l][1].end},r={type:"chunkText",start:e[i][1].start,end:e[l][1].end,contentType:"text"},eP(e,i,l-i+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(l){var i;return e.enter("atxHeading"),i=l,e.enter("atxHeadingSequence"),function l(i){return 35===i&&r++<6?(e.consume(i),l):null===i||eq(i)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||eH(r)?(e.exit("atxHeading"),t(r)):eV(r)?eQ(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||eq(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(i)):n(i)}(i)}}},42:tO,45:[tL,tO],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,l,i,o,a,s=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(o){return 33===o?(e.consume(o),u):47===o?(e.consume(o),l=!0,h):63===o?(e.consume(o),r=3,s.interrupt?t:O):eL(o)?(e.consume(o),i=String.fromCharCode(o),f):n(o)}function u(l){return 45===l?(e.consume(l),r=2,d):91===l?(e.consume(l),r=5,o=0,p):eL(l)?(e.consume(l),r=4,s.interrupt?t:O):n(l)}function d(r){return 45===r?(e.consume(r),s.interrupt?t:O):n(r)}function p(r){let l="CDATA[";return r===l.charCodeAt(o++)?(e.consume(r),o===l.length)?s.interrupt?t:N:p:n(r)}function h(t){return eL(t)?(e.consume(t),i=String.fromCharCode(t),f):n(t)}function f(o){if(null===o||47===o||62===o||eq(o)){let a=47===o,c=i.toLowerCase();return!a&&!l&&tk.includes(c)?(r=1,s.interrupt?t(o):N(o)):tw.includes(i.toLowerCase())?(r=6,a)?(e.consume(o),m):s.interrupt?t(o):N(o):(r=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(o):l?function t(n){return eV(n)?(e.consume(n),t):k(n)}(o):x(o))}return 45===o||eD(o)?(e.consume(o),i+=String.fromCharCode(o),f):n(o)}function m(r){return 62===r?(e.consume(r),s.interrupt?t:N):n(r)}function x(t){return 47===t?(e.consume(t),k):58===t||95===t||eL(t)?(e.consume(t),g):eV(t)?(e.consume(t),x):k(t)}function g(t){return 45===t||46===t||58===t||95===t||eD(t)?(e.consume(t),g):b(t)}function b(t){return 61===t?(e.consume(t),y):eV(t)?(e.consume(t),b):x(t)}function y(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,v):eV(t)?(e.consume(t),y):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||eq(n)?b(n):(e.consume(n),t)}(t)}function v(t){return t===a?(e.consume(t),a=null,w):null===t||eH(t)?n(t):(e.consume(t),v)}function w(e){return 47===e||62===e||eV(e)?x(e):n(e)}function k(t){return 62===t?(e.consume(t),j):n(t)}function j(t){return null===t||eH(t)?N(t):eV(t)?(e.consume(t),j):n(t)}function N(t){return 45===t&&2===r?(e.consume(t),T):60===t&&1===r?(e.consume(t),I):62===t&&4===r?(e.consume(t),P):63===t&&3===r?(e.consume(t),O):93===t&&5===r?(e.consume(t),R):eH(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(tj,M,S)(t)):null===t||eH(t)?(e.exit("htmlFlowData"),S(t)):(e.consume(t),N)}function S(t){return e.check(tN,C,M)(t)}function C(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||eH(t)?S(t):(e.enter("htmlFlowData"),N(t))}function T(t){return 45===t?(e.consume(t),O):N(t)}function I(t){return 47===t?(e.consume(t),i="",A):N(t)}function A(t){if(62===t){let n=i.toLowerCase();return tk.includes(n)?(e.consume(t),P):N(t)}return eL(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),A):N(t)}function R(t){return 93===t?(e.consume(t),O):N(t)}function O(t){return 62===t?(e.consume(t),P):45===t&&2===r?(e.consume(t),O):N(t)}function P(t){return null===t||eH(t)?(e.exit("htmlFlowData"),M(t)):(e.consume(t),P)}function M(n){return e.exit("htmlFlow"),t(n)}}},61:tL,95:tO,96:tp,126:tp},"flowInitial",0,{[-2]:th,[-1]:th,32:th},"insideSpan",0,{null:[tl,e6]},"string",0,{38:tu,92:ta},"text",0,{[-5]:tR,[-4]:tR,[-3]:tR,33:tI,38:tu,42:tl,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l};function l(t){return eL(t)?(e.consume(t),i):64===t?n(t):a(t)}function i(t){return 43===t||45===t||46===t||eD(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,o):(43===n||45===n||46===n||eD(n))&&r++<32?(e.consume(n),t):(r=0,a(n))}(t)):a(t)}function o(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||e$(r)?n(r):(e.consume(r),o)}function a(t){return 64===t?(e.consume(t),s):e_(t)?(e.consume(t),a):n(t)}function s(l){return eD(l)?function l(i){return 46===i?(e.consume(i),r=0,s):62===i?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(i){if((45===i||eD(i))&&r++<63){let n=45===i?t:l;return e.consume(i),n}return n(i)}(i)}(l):n(l)}}},{name:"htmlText",tokenize:function(e,t,n){let r,l,i,o=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),a};function a(t){return 33===t?(e.consume(t),s):47===t?(e.consume(t),v):63===t?(e.consume(t),b):eL(t)?(e.consume(t),k):n(t)}function s(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),l=0,h):eL(t)?(e.consume(t),g):n(t)}function c(t){return 45===t?(e.consume(t),p):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):eH(t)?(i=u,A(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),p):u(t)}function p(e){return 62===e?I(e):45===e?d(e):u(e)}function h(t){let r="CDATA[";return t===r.charCodeAt(l++)?(e.consume(t),l===r.length?f:h):n(t)}function f(t){return null===t?n(t):93===t?(e.consume(t),m):eH(t)?(i=f,A(t)):(e.consume(t),f)}function m(t){return 93===t?(e.consume(t),x):f(t)}function x(t){return 62===t?I(t):93===t?(e.consume(t),x):f(t)}function g(t){return null===t||62===t?I(t):eH(t)?(i=g,A(t)):(e.consume(t),g)}function b(t){return null===t?n(t):63===t?(e.consume(t),y):eH(t)?(i=b,A(t)):(e.consume(t),b)}function y(e){return 62===e?I(e):b(e)}function v(t){return eL(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||eD(t)?(e.consume(t),w):function t(n){return eH(n)?(i=t,A(n)):eV(n)?(e.consume(n),t):I(n)}(t)}function k(t){return 45===t||eD(t)?(e.consume(t),k):47===t||62===t||eq(t)?j(t):n(t)}function j(t){return 47===t?(e.consume(t),I):58===t||95===t||eL(t)?(e.consume(t),N):eH(t)?(i=j,A(t)):eV(t)?(e.consume(t),j):I(t)}function N(t){return 45===t||46===t||58===t||95===t||eD(t)?(e.consume(t),N):function t(n){return 61===n?(e.consume(n),S):eH(n)?(i=t,A(n)):eV(n)?(e.consume(n),t):j(n)}(t)}function S(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,C):eH(t)?(i=S,A(t)):eV(t)?(e.consume(t),S):(e.consume(t),E)}function C(t){return t===r?(e.consume(t),r=void 0,T):null===t?n(t):eH(t)?(i=C,A(t)):(e.consume(t),C)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||eq(t)?j(t):(e.consume(t),E)}function T(e){return 47===e||62===e||eq(e)?j(e):n(e)}function I(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function A(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),R}function R(t){return eV(t)?eQ(e,O,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):O(t)}function O(t){return e.enter("htmlTextData"),i(t)}}}],91:tA,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return eH(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},ta],93:tS,95:tl,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,l=3;if(("lineEnding"===e[3][1].type||"space"===e[l][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=l;++t<r;)if("codeTextData"===e[t][1].type){e[l][1].type="codeTextPadding",e[r][1].type="codeTextPadding",l+=2,r-=2;break}}for(t=l-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,l,i=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),i++,t):(e.exit("codeTextSequence"),o(n))}(t)};function o(s){return null===s?n(s):32===s?(e.enter("space"),e.consume(s),e.exit("space"),o):96===s?(l=e.enter("codeTextSequence"),r=0,function n(o){return 96===o?(e.consume(o),r++,n):r===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(o)):(l.type="codeTextData",a(o))}(s)):eH(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):(e.enter("codeTextData"),a(s))}function a(t){return null===t||32===t||96===t||eH(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),a)}}}}],4127);var tD=e.i(4127);let t_=/[\0\t\n\r]/g;function t$(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let tU=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tz(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return t$(n.slice(t?2:1),t?16:10)}return tc(n)||e}let tB={}.hasOwnProperty;function tH(e){return{line:e.line,column:e.column,offset:e.offset}}function tq(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+ed({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ed({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+ed({start:t.start,end:t.end})+") is still open")}function tV(e){let t=this;t.parser=function(n){var r,l;let i,o,a,s;return"object"==typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(l=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(g),autolinkProtocol:c,autolinkEmail:c,atxHeading:r(f),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:r(h),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:r(h,l),codeText:r(function(){return{type:"inlineCode",value:""}},l),codeTextData:c,data:c,codeFlowValue:c,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(m),hardBreakTrailing:r(m),htmlFlow:r(x,l),htmlFlowData:c,htmlText:r(x,l),htmlTextData:c,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:l,link:r(g),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(b,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(b),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:r(f),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:o(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:o(),autolinkEmail:function(e){u.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){u.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:o(),characterEscapeValue:u,characterReferenceMarkerHexadecimal:p,characterReferenceMarkerNumeric:p,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=t$(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=tc(n);let l=this.stack[this.stack.length-1];l.value+=t},characterReference:function(e){this.stack.pop().position.end=tH(e.end)},codeFenced:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:u,codeIndented:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:u,data:u,definition:o(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=ty(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:o(),hardBreakEscape:o(d),hardBreakTrailing:o(d),htmlFlow:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:u,htmlText:o(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:u,image:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(tU,tz),n.identifier=ty(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=tH(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(c.call(this,e),u.call(this,e))},link:o(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=ty(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:o(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:o(),thematicBreak:o()}};!function e(t,n){let r=-1;for(;++r<n.length;){let l=n[r];Array.isArray(l)?e(t,l):function(e,t){let n;for(n in t)if(tB.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,l)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},o={stack:[r],tokenStack:[],config:t,enter:i,exit:a,buffer:l,resume:s,data:n},c=[],u=-1;for(;++u<e.length;)("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)&&("enter"===e[u][0]?c.push(u):u=function(e,t,n){let r,l,i,o,a=t-1,s=-1,c=!1;for(;++a<=n;){let t=e[a];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?s++:s--,o=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||o||s||i||(i=a),o=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:o=void 0}if(!s&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===s&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let o=a;for(l=void 0;o--;){let t=e[o];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;l&&(e[l][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",l=o}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}i&&(!l||i<l)&&(r._spread=!0),r.end=Object.assign({},l?e[l][1].start:t[1].end),e.splice(l||a,0,["exit",r,t[2]]),a++,n++}if("listItemPrefix"===t[1].type){let l={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=l,e.splice(a,0,["enter",l,t[2]]),a++,n++,i=void 0,o=!0}}}return e[t][1]._spread=c,n}(e,c.pop(),u));for(u=-1;++u<e.length;){let n=t[e[u][0]];tB.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},o),e[u][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||tq).call(o,void 0,e[0])}for(r.position={start:tH(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:tH(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)r=t.transforms[u](r)||r;return r};function r(e,t){return function(n){i.call(this,e(n),n),t&&t.call(this,n)}}function l(){this.stack.push({type:"fragment",children:[]})}function i(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:tH(t.start),end:void 0}}function o(e){return function(t){e&&e.call(this,t),a.call(this,t)}}function a(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||tq).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+ed({start:e.start,end:e.end})+"): it’s not open");n.position.end=tH(e.end)}function s(){var e;return e=this.stack.pop(),eR(e,"boolean"!=typeof eA.includeImageAlt||eA.includeImageAlt,"boolean"!=typeof eA.includeHtml||eA.includeHtml)}function c(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:tH(e.start),end:void 0},t.push(n)),this.stack.push(n)}function u(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=tH(e.end)}function d(){this.data.atHardBreak=!0}function p(e){this.data.characterReferenceType=e.type}function h(){return{type:"code",lang:null,meta:null,value:""}}function f(){return{type:"heading",depth:0,children:[]}}function m(){return{type:"break"}}function x(){return{type:"html",value:""}}function g(){return{type:"link",title:null,url:"",children:[]}}function b(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(l)(function(e){for(;!e2(e););return e}((function(e){let t={constructs:function(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,l=(eF.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];if(i)for(r in i){eF.call(l,r)||(l[r]=[]);let e=i[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);eP(e,0,0,r)}(l[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}([tD,...(e||{}).extensions||[]]),content:n(eK),defined:[],document:n(eY),flow:n(e3),lazy:{},string:n(e9),text:n(e7)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},l={},i=[],o=[],a=[],s={attempt:f(function(e,t){m(e,t.from)}),check:f(h),consume:function(e){eH(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,x()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=p(),c.events.push(["enter",n,c]),a.push(n),n},exit:function(e){let t=a.pop();return t.end=p(),c.events.push(["exit",t,c]),t},interrupt:f(h,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){l[e.line]=e.column,x()},events:[],now:p,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,l=[];for(;++r<e.length;){let i,o=e[r];if("string"==typeof o)i=o;else switch(o){case -5:i="\r";break;case -4:i="\n";break;case -3:i="\r\n";break;case -2:i=t?" ":" ";break;case -1:if(!t&&n)continue;i=" ";break;default:i=String.fromCharCode(o)}n=-2===o,l.push(i)}return l.join("")}(d(e),t)},sliceStream:d,write:function(e){return(o=eM(o,e),function(){let e;for(;r._index<o.length;){let n=o[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),u=u(t)}else u=u(n)}}(),null!==o[o.length-1])?[]:(m(t,0),c.events=tr(i,c.events,c),c.events)}},u=t.tokenize.call(c,s);return t.resolveAll&&i.push(t),c;function d(e){return function(e,t){let n,r=t.start._index,l=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;if(r===i)n=[e[r].slice(l,o)];else{if(n=e.slice(r,i),l>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(l):n.shift()}o>0&&n.push(e[i].slice(0,o))}return n}(o,e)}function p(){let{_bufferIndex:e,_index:t,line:n,column:l,offset:i}=r;return{_bufferIndex:e,_index:t,line:n,column:l,offset:i}}function h(e,t){t.restore()}function f(e,t){return function(n,l,i){var o;let u,d,h,f;return Array.isArray(n)?m(n):"tokenize"in n?m([n]):(o=n,function(e){let t=null!==e&&o[e],n=null!==e&&o.null;return m([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function m(e){return(u=e,d=0,0===e.length)?i:g(e[d])}function g(e){return function(n){let l,i,o,u,d;return(l=p(),i=c.previous,o=c.currentConstruct,u=c.events.length,d=Array.from(a),f={from:u,restore:function(){r=l,c.previous=i,c.currentConstruct=o,c.events.length=u,a=d,x()}},h=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?y(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,s,b,y)(n)}}function b(t){return e(h,f),l}function y(e){return(f.restore(),++d<u.length)?g(u[d]):i}}}function m(e,t){e.resolveAll&&!i.includes(e)&&i.push(e),e.resolve&&eP(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function x(){r.line in l&&r.column<2&&(r.column=l[r.line],r.offset+=l[r.line]-1)}}(t,e,n)}}})(l).document().write((o=1,a="",s=!0,function(e,t,n){let r,l,c,u,d,p=[];for(e=a+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,a="",s&&(65279===e.charCodeAt(0)&&c++,s=void 0);c<e.length;){if(t_.lastIndex=c,u=(r=t_.exec(e))&&void 0!==r.index?r.index:e.length,d=e.charCodeAt(u),!r){a=e.slice(c);break}if(10===d&&c===u&&i)p.push(-3),i=void 0;else switch(i&&(p.push(-5),i=void 0),c<u&&(p.push(e.slice(c,u)),o+=u-c),d){case 0:p.push(65533),o++;break;case 9:for(l=4*Math.ceil(o/4),p.push(-2);o++<l;)p.push(-1);break;case 10:p.push(-4),o=1;break;default:i=!0,o=1}c=u+1}return n&&(i&&p.push(-5),a&&p.push(a),p.push(null)),p})(n,r,!0))))}}let tW="object"==typeof self?self:globalThis,tG=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=l=>{if(t.has(l))return t.get(l);let[i,o]=e[l];switch(i){case 0:case -1:return n(o,l);case 1:{let e=n([],l);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},l);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),l);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),l)}case 5:{let e=n(new Map,l);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,l);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new tW[e](t),l)}case 8:return n(BigInt(o),l);case"BigInt":return n(Object(BigInt(o)),l);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new tW[i](o),l)})(0)},{toString:tJ}={},{keys:tQ}=Object,tK=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=tJ.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},tY=([e,t])=>0===e&&("function"===t||"symbol"===t),tX=(e,{json:t,lossy:n}={})=>{var r,l,i;let o,a,s=[];return(r=!(t||n),l=!!t,i=new Map,o=(e,t)=>{let n=s.push(e)-1;return i.set(t,n),n},a=e=>{if(i.has(e))return i.get(e);let[t,n]=tK(e);switch(t){case 0:{let l=e;switch(n){case"bigint":t=8,l=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);l=null;break;case"undefined":return o([-1],e)}return o([t,l],e)}case 1:{if(n){let t=e;return"DataView"===n?t=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(t=new Uint8Array(e)),o([n,[...t]],e)}let r=[],l=o([t,r],e);for(let t of e)r.push(a(t));return l}case 2:{if(n)switch(n){case"BigInt":return o([n,e.toString()],e);case"Boolean":case"Number":case"String":return o([n,e.valueOf()],e)}if(l&&"toJSON"in e)return a(e.toJSON());let i=[],s=o([t,i],e);for(let t of tQ(e))(r||!tY(tK(e[t])))&&i.push([a(t),a(e[t])]);return s}case 3:return o([t,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return o([t,{source:n,flags:r}],e)}case 5:{let n=[],l=o([t,n],e);for(let[t,l]of e)(r||!(tY(tK(t))||tY(tK(l))))&&n.push([a(t),a(l)]);return l}case 6:{let n=[],l=o([t,n],e);for(let t of e)(r||!tY(tK(t)))&&n.push(a(t));return l}}let{message:s}=e;return o([t,{name:n,message:s}],e)})(e),s},tZ="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?tG(tX(e,t)):structuredClone(e):(e,t)=>tG(tX(e,t));function t0(e){let t=[],n=-1,r=0,l=0;for(;++n<e.length;){let i=e.charCodeAt(n),o="";if(37===i&&eD(e.charCodeAt(n+1))&&eD(e.charCodeAt(n+2)))l=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(o=String.fromCharCode(i));else if(i>55295&&i<57344){let t=e.charCodeAt(n+1);i<56320&&t>56319&&t<57344?(o=String.fromCharCode(i,t),l=1):o="�"}else o=String.fromCharCode(i);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+l+1,o=""),l&&(n+=l,l=0)}return t.join("")+e.slice(r)}function t1(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function t2(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}let t5=function(e){var t,n;if(null==e)return t3;if("function"==typeof e)return t4(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=t5(e[n]);return t4(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,t4(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,t4(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function t4(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function t3(){return!0}let t6=[];function t9(e,t,n,r){var l,i,o;let a,s,c,u,d,p;"function"==typeof t&&"function"!=typeof n?(s=void 0,c=t,a=n):(s=t,c=n,a=r),l=s,i=function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return c(e,r,n)},o=a,"function"==typeof l&&"function"!=typeof i?(o=i,i=l):u=l,d=t5(u),p=o?-1:1,(function e(t,n,r){let a=t&&"object"==typeof t?t:{};if("string"==typeof a.type){let e="string"==typeof a.tagName?a.tagName:"string"==typeof a.name?a.name:void 0;Object.defineProperty(s,"name",{value:"node ("+t.type+(e?"<"+e+">":"")+")"})}return s;function s(){var a;let s,c,u,h=t6;if((!l||d(t,n,r[r.length-1]||void 0))&&!1===(h=Array.isArray(a=i(t,r))?a:"number"==typeof a?[!0,a]:null==a?t6:[a])[0])return h;if("children"in t&&t.children&&t.children&&"skip"!==h[0])for(c=(o?t.children.length:-1)+p,u=r.concat(t);c>-1&&c<t.children.length;){if(!1===(s=e(t.children[c],c,u)())[0])return s;c="number"==typeof s[1]?s[1]:c+p}return h}})(e,void 0,[])()}function t7(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let l=e.all(t),i=l[0];i&&"text"===i.type?i.value="["+i.value:l.unshift({type:"text",value:"["});let o=l[l.length-1];return o&&"text"===o.type?o.value+=r:l.push({type:"text",value:r}),l}function t8(e){let t=e.spread;return null==t?e.children.length>1:t}function ne(e,t,n){let r=0,l=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(l-1);for(;9===t||32===t;)l--,t=e.codePointAt(l-1)}return l>r?e.slice(r,l):""}let nt={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},l=t.lang?t.lang.split(/\s+/):[];l.length>0&&(r.className=["language-"+l[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i={type:"element",tagName:"pre",properties:{},children:[i=e.applyData(t,i)]},e.patch(t,i),i},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",l=String(t.identifier).toUpperCase(),i=t0(l.toLowerCase()),o=e.footnoteOrder.indexOf(l),a=e.footnoteCounts.get(l);void 0===a?(a=0,e.footnoteOrder.push(l),n=e.footnoteOrder.length):n=o+1,a+=1,e.footnoteCounts.set(l,a);let s={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+i,id:r+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,s);let c={type:"element",tagName:"sup",properties:{},children:[s]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return t7(e,t);let l={src:t0(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(l.title=r.title);let i={type:"element",tagName:"img",properties:l,children:[]};return e.patch(t,i),e.applyData(t,i)},image:function(e,t){let n={src:t0(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return t7(e,t);let l={href:t0(r.url||"")};null!==r.title&&void 0!==r.title&&(l.title=r.title);let i={type:"element",tagName:"a",properties:l,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},link:function(e,t){let n={href:t0(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),l=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=t8(n[r])}return t}(n):t8(t),i={},o=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a<r.length;){let e=r[a];(l||0!==a||"element"!==e.type||"p"!==e.tagName)&&o.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||l?o.push(e):o.push(...e.children)}let s=r[r.length-1];s&&(l||"element"!==s.type||"p"!==s.tagName)&&o.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:i,children:o};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},r=e.all(t),l=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++l<r.length;){let e=r[l];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),l=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),l.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},i=ec(t.children[1]),o=es(t.children[t.children.length-1]);i&&o&&(r.position={start:i,end:o}),l.push(r)}let i={type:"element",tagName:"table",properties:{},children:e.wrap(l,!0)};return e.patch(t,i),e.applyData(t,i)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,l=0===(r?r.indexOf(t):1)?"th":"td",i=n&&"table"===n.type?n.align:void 0,o=i?i.length:t.children.length,a=-1,s=[];for(;++a<o;){let n=t.children[a],r={},o=i?i[a]:void 0;o&&(r.align=o);let c={type:"element",tagName:l,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),s.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(s,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),l=0,i=[];for(;r;)i.push(ne(t.slice(l,r.index),l>0,!0),r[0]),l=r.index+r[0].length,r=n.exec(t);return i.push(ne(t.slice(l),l>0,!1)),i.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:nn,yaml:nn,definition:nn,footnoteDefinition:nn};function nn(){}let nr={}.hasOwnProperty,nl={};function ni(e,t){e.position&&(t.position=function(e){let t=ec(e),n=es(e);if(t&&n)return{start:t,end:n}}(e))}function no(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,l=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&l&&Object.assign(n.properties,tZ(l)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function na(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function ns(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function nc(e,t){let n,r,l,i,o=(n=t||nl,r=new Map,l=new Map,i={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let l=i.one(n[r],e);if(l){if(r&&"break"===n[r-1].type&&(Array.isArray(l)||"text"!==l.type||(l.value=ns(l.value)),!Array.isArray(l)&&"element"===l.type)){let e=l.children[0];e&&"text"===e.type&&(e.value=ns(e.value))}Array.isArray(l)?t.push(...l):t.push(l)}}}return t},applyData:no,definitionById:r,footnoteById:l,footnoteCounts:new Map,footnoteOrder:[],handlers:{...nt,...n.handlers},one:function(e,t){let n=e.type,r=i.handlers[n];if(nr.call(i.handlers,n)&&r)return r(i,e,t);if(i.options.passThrough&&i.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=tZ(n);return r.children=i.all(e),r}return tZ(e)}return(i.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(nr.call(n,"hProperties")||nr.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(i,e,t)},options:n,patch:ni,wrap:na},t9(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:l,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),i),a=o.one(e,void 0),s=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||t1,r=e.options.footnoteBackLabel||t2,l=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[],s=-1;for(;++s<e.footnoteOrder.length;){let l=e.footnoteById.get(e.footnoteOrder[s]);if(!l)continue;let i=e.all(l),o=String(l.identifier).toUpperCase(),c=t0(o.toLowerCase()),u=0,d=[],p=e.footnoteCounts.get(o);for(;void 0!==p&&++u<=p;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(s,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(s,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let h=i[i.length-1];if(h&&"element"===h.type&&"p"===h.tagName){let e=h.children[h.children.length-1];e&&"text"===e.type?e.value+=" ":h.children.push({type:"text",value:" "}),h.children.push(...d)}else i.push(...d);let f={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(i,!0)};e.patch(l,f),a.push(f)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...tZ(o),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(o),c=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return s&&(v("children"in c),c.children.push({type:"text",value:"\n"},s)),c}function nu(e,t){return e&&"run"in e?async function(n,r){let l=nc(n,{file:r,...t});await e.run(l,r)}:function(n,r){return nc(n,{file:r,...e||t})}}function nd(e){if(e)throw e}var np=e.i(4100);function nh(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let nf=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');nb(e);let r=0,l=-1,i=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;i--;)if(47===e.codePointAt(i)){if(n){r=i+1;break}}else l<0&&(n=!0,l=i+1);return l<0?"":e.slice(r,l)}if(t===e)return"";let o=-1,a=t.length-1;for(;i--;)if(47===e.codePointAt(i)){if(n){r=i+1;break}}else o<0&&(n=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(l=i):(a=-1,l=o));return r===l?l=o:l<0&&(l=e.length),e.slice(r,l)},nm=function(e){let t;if(nb(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},nx=function(e){let t;nb(e);let n=e.length,r=-1,l=0,i=-1,o=0;for(;n--;){let a=e.codePointAt(n);if(47===a){if(t){l=n+1;break}continue}r<0&&(t=!0,r=n+1),46===a?i<0?i=n:1!==o&&(o=1):i>-1&&(o=-1)}return i<0||r<0||0===o||1===o&&i===r-1&&i===l+1?"":e.slice(i,r)},ng=function(...e){var t;let n,r,l,i=-1;for(;++i<e.length;)nb(e[i]),e[i]&&(l=void 0===l?e[i]:l+"/"+e[i]);return void 0===l?".":(nb(t=l),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,l="",i=0,o=-1,a=0,s=-1;for(;++s<=e.length;){if(s<e.length)n=e.codePointAt(s);else if(47===n)break;else n=47;if(47===n){if(o===s-1||1===a);else if(o!==s-1&&2===a){if(l.length<2||2!==i||46!==l.codePointAt(l.length-1)||46!==l.codePointAt(l.length-2)){if(l.length>2){if((r=l.lastIndexOf("/"))!==l.length-1){r<0?(l="",i=0):i=(l=l.slice(0,r)).length-1-l.lastIndexOf("/"),o=s,a=0;continue}}else if(l.length>0){l="",i=0,o=s,a=0;continue}}t&&(l=l.length>0?l+"/..":"..",i=2)}else l.length>0?l+="/"+e.slice(o+1,s):l=e.slice(o+1,s),i=s-o-1;o=s,a=0}else 46===n&&a>-1?a++:a=-1}return l}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function nb(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function ny(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let nv=["history","path","basename","stem","extname","dirname"];class nw{constructor(e){let t,n;t=e?ny(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<nv.length;){const e=nv[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)nv.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?nf(this.path):void 0}set basename(e){nj(e,"basename"),nk(e,"basename"),this.path=ng(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?nm(this.path):void 0}set dirname(e){nN(this.basename,"dirname"),this.path=ng(e||"",this.basename)}get extname(){return"string"==typeof this.path?nx(this.path):void 0}set extname(e){if(nk(e,"extname"),nN(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=ng(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){ny(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!ny(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),nj(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?nf(this.path,this.extname):void 0}set stem(e){nj(e,"stem"),nk(e,"stem"),this.path=ng(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new em(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function nk(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function nj(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function nN(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let nS=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},nC={}.hasOwnProperty;class nE extends nS{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function l(i,...o){let a=e[++n],s=-1;if(i)return void r(i);for(;++s<t.length;)(null===o[s]||void 0===o[s])&&(o[s]=t[s]);t=o,a?(function(e,t){let n;return function(...t){let i,o=e.length>t.length;o&&t.push(r);try{i=e.apply(this,t)}catch(e){if(o&&n)throw e;return r(e)}o||(i&&i.then&&"function"==typeof i.then?i.then(l,r):i instanceof Error?r(i):l(i))};function r(e,...l){n||(n=!0,t(e,...l))}function l(e){r(null,e)}})(a,l)(...o):r(null,...o)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new nE,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,np.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(nR("data",this.frozen),this.namespace[e]=t,this):nC.call(this.namespace,e)&&this.namespace[e]||void 0:e?(nR("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=nM(e),n=this.parser||this.Parser;return nI("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),nI("process",this.parser||this.Parser),nA("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,l){let i=nM(e),o=n.parse(i);function a(e,n){e||!n?l(e):r?r(n):(v(t,"`done` is defined if `resolve` is not"),t(void 0,n))}n.run(o,i,function(e,t,r){var l,i;if(e||!t||!r)return a(e);let o=n.stringify(t,r);"string"==typeof(l=o)||(i=l)&&"object"==typeof i&&"byteLength"in i&&"byteOffset"in i?r.value=o:r.result=o,a(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),nI("processSync",this.parser||this.Parser),nA("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,nd(e),t=r}),nP("processSync","process",n),v(t,"we either bailed on an error or have a tree"),t}run(e,t,n){nO(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?l(void 0,n):new Promise(l);function l(l,i){v("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let o=nM(t);r.run(e,o,function(t,r,o){let a=r||e;t?i(t):l?l(a):(v(n,"`done` is defined if `resolve` is not"),n(void 0,a,o))})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){nd(e),n=t,r=!0}),nP("runSync","run",r),v(n,"we either bailed on an error or have a tree"),n}stringify(e,t){this.freeze();let n=nM(t),r=this.compiler||this.Compiler;return nA("stringify",r),nO(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(nR("use",this.frozen),null==e);else if("function"==typeof e)o(e,t);else if("object"==typeof e)Array.isArray(e)?i(e):l(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function l(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(e.plugins),e.settings&&(r.settings=(0,np.default)(!0,r.settings,e.settings))}function i(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)o(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;o(t,n)}else l(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function o(e,t){let r=-1,l=-1;for(;++r<n.length;)if(n[r][0]===e){l=r;break}if(-1===l)n.push([e,...t]);else if(t.length>0){let[r,...i]=t,o=n[l][1];nh(o)&&nh(r)&&(r=(0,np.default)(!0,o,r)),n[l]=[e,r,...i]}}}}let nT=new nE().freeze();function nI(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function nA(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function nR(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function nO(e){if(!nh(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function nP(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function nM(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new nw(e)}let nF=[],nL={allowDangerousHtml:!0},nD=/^(https?|ircs?|mailto|xmpp)$/i,n_=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function n$(e){var n;let r,l,i,o,a,s=(r=(n=e).rehypePlugins||nF,l=n.remarkPlugins||nF,i=n.remarkRehypeOptions?{...n.remarkRehypeOptions,...nL}:nL,nT().use(tV).use(l).use(nu,i).use(r)),c=(o=e.children||"",a=new nw,"string"==typeof o?a.value=o:w("Unexpected value `"+o+"` for `children` prop, expected `string`"),a);return function(e,n){let r=n.allowedElements,l=n.allowElement,i=n.components,o=n.disallowedElements,a=n.skipHtml,s=n.unwrapDisallowed,c=n.urlTransform||nU;for(let e of n_)Object.hasOwn(n,e.from)&&w("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return r&&o&&w("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),t9(e,function(e,t,n){if("raw"===e.type&&n&&"number"==typeof t)return a?n.children.splice(t,1):n.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in eI)if(Object.hasOwn(eI,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=eI[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=c(String(n||""),t,e))}}if("element"===e.type){let i=r?!r.includes(e.tagName):!!o&&o.includes(e.tagName);if(!i&&l&&"number"==typeof t&&(i=!l(e,t,n)),i&&n&&"number"==typeof t)return s&&e.children?n.children.splice(t,1,...e.children):n.children.splice(t,1),t}}),function(e,t){var n,r,l,i;let o;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let a=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=a,r=t.jsxDEV,o=function(e,t,l,i){let o=Array.isArray(l.children),a=ec(e);return r(t,l,i,o,{columnNumber:a?a.column-1:void 0,fileName:n,lineNumber:a?a.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");l=t.jsx,i=t.jsxs,o=function(e,t,n,r){let o=Array.isArray(n.children)?i:l;return r?o(t,n,r):o(t,n)}}let s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:o,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?eo:ei,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=ek(s,e,void 0);return c&&"string"!=typeof c?c:s.create(e,s.Fragment,{children:c||void 0},void 0)}(e,{Fragment:t.Fragment,components:i,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0})}(s.runSync(s.parse(c),c),e)}function nU(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),l=e.indexOf("/");return -1===t||-1!==l&&t>l||-1!==n&&t>n||-1!==r&&t>r||nD.test(e.slice(0,t))?e:""}function nz({projectId:e,startInEditMode:r=!1}){let[l,i]=(0,n.useState)(""),[o,a]=(0,n.useState)(null),[s,c]=(0,n.useState)(r),[u,d]=(0,n.useState)(""),[p,h]=(0,n.useState)(!1),[f,m]=(0,n.useState)(null),x=(0,n.useRef)(!1);x.current=s;let g=(0,n.useRef)(r),b=(0,n.useCallback)(async()=>{try{let t=await fetch(`/api/queue?project=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`${t.status}`);let n=await t.json();a(!!n.exists),x.current||i(n.content||""),g.current&&(d(n.content||""),g.current=!1),m(null)}catch(e){m(e.message)}},[e]);(0,n.useEffect)(()=>{b();let e=setInterval(b,1e4);return()=>clearInterval(e)},[b]);let y=async()=>{h(!0),m(null);try{let t=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u})});if(!t.ok)throw Error(`${t.status}`);i(u),c(!1)}catch(e){m(e.message)}finally{h(!1)}},v=async()=>{h(!0);try{let t=await fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"});if(!t.ok)throw Error(`${t.status}`);await b()}catch(e){m(e.message)}finally{h(!1)}};return(0,t.jsxs)("div",{className:"flex flex-col h-full min-h-0 border border-border",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:"OVERNIGHT-QUEUE.md"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[f&&(0,t.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",f]}),!s&&o&&(0,t.jsx)("button",{onClick:()=>{d(l),c(!0)},className:"text-[10px] text-text-muted hover:text-accent uppercase tracking-wider",children:"Edit"}),s&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{onClick:y,disabled:p,className:"text-[10px] text-accent hover:text-accent-dim uppercase tracking-wider disabled:opacity-50",children:p?"Saving…":"Save"}),(0,t.jsx)("button",{onClick:()=>{c(!1),d(""),b()},disabled:p,className:"text-[10px] text-text-muted hover:text-text uppercase tracking-wider disabled:opacity-50",children:"Cancel"})]})]})]}),s&&(0,t.jsx)("div",{className:"shrink-0 px-3 py-1.5 border-b border-border bg-bg-surface text-[10px] text-text-muted leading-snug",children:"⚠️ Editing manually may conflict with the Head agent. Use the chat panel to ask Head to update the queue when possible."}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:!1===o?(0,t.jsxs)("div",{className:"p-3 text-[11px] text-text-muted",children:[(0,t.jsx)("p",{className:"mb-2",children:"No OVERNIGHT-QUEUE.md for this project yet."}),(0,t.jsx)("button",{onClick:v,disabled:p,className:"px-2 py-1 border border-border hover:border-accent hover:text-accent text-[11px] disabled:opacity-50",children:"Create OVERNIGHT-QUEUE.md from template"})]}):s?(0,t.jsx)("textarea",{value:u,onChange:e=>d(e.target.value),spellCheck:!1,className:"w-full h-full p-3 bg-bg text-text text-[11px] font-mono resize-none outline-none"}):(0,t.jsx)("div",{className:"p-3 text-[12px] text-text prose prose-invert prose-sm max-w-none [&_h1]:text-[14px] [&_h1]:font-semibold [&_h1]:mt-3 [&_h1]:mb-2 [&_h2]:text-[13px] [&_h2]:font-semibold [&_h2]:mt-3 [&_h2]:mb-1.5 [&_h3]:text-[12px] [&_h3]:font-semibold [&_h3]:mt-2 [&_h3]:mb-1 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ul]:pl-4 [&_ul]:list-disc [&_ol]:my-1.5 [&_ol]:pl-4 [&_ol]:list-decimal [&_li]:my-0.5 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-2 [&_blockquote]:text-text-muted [&_hr]:my-3 [&_hr]:border-border [&_code]:bg-bg-surface [&_code]:px-1 [&_code]:rounded [&_code]:text-[11px] [&_strong]:text-text [&_a]:text-accent [&_a]:underline",children:(0,t.jsx)(n$,{children:l})})})]})}function nB({open:e,projectId:r,onClose:l}){return((0,n.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,l]),e)?(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:l,role:"dialog","aria-modal":"true","aria-labelledby":"queue-modal-title",children:(0,t.jsxs)("div",{className:"relative mx-4 w-full max-w-3xl h-[80vh] flex flex-col rounded-lg border border-white/10 bg-neutral-950 shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/10",children:[(0,t.jsx)("h2",{id:"queue-modal-title",className:"text-[12px] font-semibold text-white",children:"OVERNIGHT-QUEUE.md"}),(0,t.jsx)("button",{type:"button",onClick:l,"aria-label":"Close",className:"rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,t.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,t.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(nz,{projectId:r,startInEditMode:!0})})]})}):null}let nH={en:{loading:"Loading batch progress…",currentBatchNone:"Current Batch: (none)",noActiveBatch:"No active batch. Ask Head to start one via the chat.",currentBatch:e=>`Current Batch: Batch ${e}`,complete:"✅ COMPLETE",allMerged:e=>`All ${e} items merged. Waiting for the next batch.`,itemsCount:e=>`(${e} items)`,tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Current Batch"}),"— progress tracker for the active batch. Polls GitHub to resolve each issue's status (queued → in review → approved → merged)."]})},ko:{loading:"배치 진행 상황 로딩 중...",currentBatchNone:"현재 배치: (없음)",noActiveBatch:"활성 배치가 없습니다. 채팅에서 Head에게 시작을 요청하세요.",currentBatch:e=>`현재 배치: ${e}번`,complete:"✅ 완료",allMerged:e=>`${e}개 항목 모두 병합됨. 다음 배치를 기다리는 중.`,itemsCount:e=>`(${e}개 항목)`,tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"현재 배치"})," - 활성 배치 진행 상황 추적기입니다. GitHub를 조회해 각 이슈 상태를 대기 → 검토 중 → 승인 → 병합 순으로 추적합니다."]})}};function nq({percent:e}){let n=Math.round(e/100*20);return(0,t.jsxs)("span",{className:"font-mono text-[11px] tabular-nums whitespace-nowrap",children:[(0,t.jsx)("span",{className:"text-accent",children:"█".repeat(n)}),(0,t.jsx)("span",{className:"text-text-muted",children:"░".repeat(20-n)})]})}function nV({projectId:e}){let{locale:r}=(0,o.useLocale)(),i=nH[r],[a,s]=(0,n.useState)(null),c=(0,n.useCallback)(()=>{fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&s(e)}).catch(()=>{})},[e]);return((0,n.useEffect)(()=>{c();let e=setInterval(c,3e4);return()=>clearInterval(e)},[c]),a)?a.items&&0!==a.items.length?a.complete?(0,t.jsxs)("div",{className:"border-t border-border",children:[(0,t.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:i.currentBatch(a.batch_number??"—")}),(0,t.jsx)("span",{className:"text-[10px] text-accent",children:i.complete})]}),(0,t.jsx)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:i.allMerged(a.items.length)})]}):(0,t.jsxs)("div",{className:"border-t border-border",children:[(0,t.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-2 border-b border-border/40",children:[(0,t.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:i.currentBatch(a.batch_number??"—")}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted",children:i.itemsCount(a.items.length)}),(0,t.jsx)(l.default,{children:i.tooltip})]}),(0,t.jsx)("div",{className:"max-h-40 overflow-y-auto",children:a.items.map(e=>{let n=(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 font-mono",children:[(0,t.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0 tabular-nums",children:["#",e.issue_number]}),(0,t.jsx)(nq,{percent:e.progress}),(0,t.jsxs)("span",{className:"text-[11px] text-text-muted tabular-nums shrink-0 w-9 text-right",children:[e.progress,"%"]}),(0,t.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.label})]});return e.url?(0,t.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"block hover:bg-[#1a1a1a] transition-colors border-b border-border/30",children:n},e.issue_number):(0,t.jsx)("div",{children:n},e.issue_number)})}),a.summary&&(0,t.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border/40",children:a.summary})]}):(0,t.jsxs)("div",{className:"border-t border-border",children:[(0,t.jsx)("div",{className:"px-3 py-1.5 flex items-center gap-2",children:(0,t.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:i.currentBatchNone})}),(0,t.jsx)("div",{className:"px-3 pb-2 text-[11px] text-text-muted",children:i.noActiveBatch})]}):(0,t.jsx)("div",{className:"px-3 py-1.5 text-[11px] text-text-muted border-t border-border",children:i.loading})}let nW={en:{rateLimitCritical:e=>`GitHub Rate Limit CRITICAL: 0 remaining. Resets in ${e}m.`,rateLimitLow:(e,t,n)=>`GitHub Rate Limit LOW: ${e}/${t} remaining. Resets in ${n}m.`,issues:e=>`Issues (${e})`,issuesHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Issues"})," — open issues in this repository. Agents will pick these up automatically if they are part of the overnight queue."]}),noIssues:"No open issues.",recentlyClosed:"Recently closed",noneYet:"None yet.",prs:e=>`Pull Requests (${e})`,prsHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Pull Requests"})," — active PRs in this repository. Shows review status from RE1/RE2 and CI status."]}),noPrs:"No active PRs.",recentlyMerged:"Recently merged / closed",overnightQueueHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"OVERNIGHT-QUEUE.md"})," — a list of issue numbers (one per line) for agents to process autonomously. Edit this file to add or remove tasks from the queue."]}),edit:"Edit"},ko:{rateLimitCritical:e=>`GitHub API 제한 위험: 잔여 0개. ${e}분 후 초기화됩니다.`,rateLimitLow:(e,t,n)=>`GitHub API 제한 낮음: ${e}/${t} 남음. ${n}분 후 초기화됩니다.`,issues:e=>`이슈 (${e})`,issuesHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"이슈"})," - 이 저장소의 열려 있는 이슈들입니다. 야간 큐에 포함되면 에이전트가 자동으로 작업을 시작합니다."]}),noIssues:"열린 이슈가 없습니다.",recentlyClosed:"최근 닫힌 이슈",noneYet:"아직 없습니다.",prs:e=>`풀 리퀘스트 (${e})`,prsHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"풀 리퀘스트"})," - 이 저장소의 활성화된 PR들입니다. RE1/RE2의 리뷰 상태와 CI 상태를 보여줍니다."]}),noPrs:"활성 PR이 없습니다.",recentlyMerged:"최근 머지/닫힘",overnightQueueHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"OVERNIGHT-QUEUE.md"})," - 에이전트가 자율적으로 처리할 이슈 번호 목록(한 줄에 하나씩)입니다. 이 파일을 편집하여 큐에 작업을 추가하거나 제거할 수 있습니다."]}),edit:"편집"}};function nG({color:e}){return(0,t.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${e}`})}function nJ({projectId:e}){let{locale:r}=(0,o.useLocale)(),i=nW[r],[a,s]=(0,n.useState)([]),[c,u]=(0,n.useState)([]),[d,p]=(0,n.useState)([]),[h,f]=(0,n.useState)([]),[m,x]=(0,n.useState)(!1),[g,b]=(0,n.useState)(null);(0,n.useEffect)(()=>{let t=!1;return fetch(`/api/queue?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(n=>{if(!t&&n&&!n.exists)return fetch(`/api/queue?project=${encodeURIComponent(e)}`,{method:"POST"})}).catch(()=>{}),()=>{t=!0}},[e]);let y=(0,n.useCallback)(()=>{fetch(`/api/github/issues?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&s(e)}).catch(()=>{}),fetch(`/api/github/prs?project=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`${e.status}`);return e.json()}).then(e=>{Array.isArray(e)&&u(e)}).catch(()=>{}),fetch(`/api/github/closed-issues?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&p(e)}).catch(()=>{}),fetch(`/api/github/merged-prs?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)&&f(e)}).catch(()=>{})},[e]);return(0,n.useEffect)(()=>{let e=()=>{fetch("/api/github/rate-limit").then(e=>e.ok?e.json():null).then(e=>{e&&b(e)}).catch(()=>{})};e();let t=setInterval(e,6e4);return()=>clearInterval(t)},[]),(0,n.useEffect)(()=>{y();let e=setInterval(y,6e4);return()=>clearInterval(e)},[y]),(0,t.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[g&&(g.critical||g.low)&&(0,t.jsx)("div",{className:`px-3 py-1 text-[10px] shrink-0 ${g.critical?"bg-error/20 text-error":"bg-[#ffcc00]/20 text-[#ffcc00]"}`,children:g.critical?i.rateLimitCritical(g.resetInMinutes):i.rateLimitLow(g.remaining,g.limit,g.resetInMinutes)}),(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col lg:flex-row",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col border-b lg:border-b-0 lg:border-r border-border",children:[(0,t.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:i.issues(a.length)}),(0,t.jsx)(l.default,{children:i.issuesHelp})]}),(0,t.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===a.length&&(0,t.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:i.noIssues}),a.map(e=>(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,t.jsx)(nG,{color:"OPEN"===e.state?"bg-accent":"bg-error"}),(0,t.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,t.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,t.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login})]},e.number)),(0,t.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:i.recentlyClosed}),0===d.length&&(0,t.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:i.noneYet}),d.map(e=>(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,t.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,t.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`closed-${e.number}`))]})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,t.jsxs)("div",{className:"px-3 py-1.5 border-b border-border shrink-0 flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:i.prs(c.length)}),(0,t.jsx)(l.default,{children:i.prsHelp})]}),(0,t.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[0===c.length&&(0,t.jsx)("div",{className:"px-3 py-2 text-[11px] text-text-muted",children:i.noPrs}),c.map(e=>{let n=e.reviews||[],r=e.reviewDecision||"REVIEW_REQUIRED",l={};for(let e of n){let t=(e.body||"").trim();/^(?:RE2|Reviewer2|T2b)\b/i.test(t)?l.re2=e.state:(/^(?:RE1|Reviewer1|T2a)\b/i.test(t)||/^##\s*Verdict/i.test(t))&&(l.re1=e.state)}return(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono hover:bg-[#1a1a1a] transition-colors cursor-pointer border-b border-border/50",children:[(0,t.jsx)(nG,{color:"APPROVED"===r?"bg-accent":"CHANGES_REQUESTED"===r?"bg-error":"bg-[#ffcc00]"}),(0,t.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,t.jsx)("span",{className:"text-[11px] text-text truncate flex-1 min-w-0",children:e.title}),e.assignees?.[0]&&(0,t.jsx)("span",{className:"text-[10px] text-text-muted shrink-0",children:e.assignees[0].login}),["re1","re2"].map(e=>{let n=l[e];return(0,t.jsxs)("span",{className:`text-[10px] shrink-0 ${n?"APPROVED"===n?"text-accent":"CHANGES_REQUESTED"===n?"text-error":"text-[#ffcc00]":"text-text-muted"}`,children:[e,":",n?"APPROVED"===n?"ok":"CHANGES_REQUESTED"===n?"chg":"rev":"—"]},e)}),(0,t.jsx)("span",{className:`text-[10px] shrink-0 ${function(e){if(!e||0===e.length)return"text-text-muted";let t=e.map(e=>e.state);return t.every(e=>"SUCCESS"===e)?"text-accent":t.some(e=>"FAILURE"===e||"ERROR"===e)?"text-error":"text-[#ffcc00]"}(e.statusCheckRollup)}`,children:function(e){if(!e||0===e.length)return"—";let t=e.map(e=>e.state);return t.every(e=>"SUCCESS"===e)?"pass":t.some(e=>"FAILURE"===e||"ERROR"===e)?"fail":"run"}(e.statusCheckRollup)})]},e.number)}),(0,t.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] text-text-muted uppercase tracking-wider",children:i.recentlyMerged}),0===h.length&&(0,t.jsx)("div",{className:"px-3 py-1 text-[11px] text-text-muted",children:i.noneYet}),h.map(e=>(0,t.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-1 font-mono opacity-60 hover:opacity-100 hover:bg-[#1a1a1a] transition-all cursor-pointer border-b border-border/30",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:"✓"}),(0,t.jsxs)("span",{className:"text-[11px] text-text-muted w-8 shrink-0",children:["#",e.number]}),(0,t.jsx)("span",{className:"text-[11px] text-text-muted truncate flex-1 min-w-0",children:e.title})]},`merged-${e.number}`))]})]})]}),(0,t.jsx)("div",{className:"shrink-0",children:(0,t.jsx)(nV,{projectId:e})}),(0,t.jsxs)("div",{className:"shrink-0 flex items-center justify-between px-3 py-1.5 border-t border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted font-mono",children:"OVERNIGHT-QUEUE.md"}),(0,t.jsx)(l.default,{position:"above",children:i.overnightQueueHelp})]}),(0,t.jsx)("button",{onClick:()=>x(!0),className:"px-2 py-0.5 text-[10px] text-text-muted hover:text-accent border border-border hover:border-accent transition-colors uppercase tracking-wider",children:i.edit})]}),(0,t.jsx)(nB,{open:m,projectId:e,onClose:()=>x(!1)})]})}var nQ=e.i(67449);let nK={en:{server:{title:"Server",resetAgents:"Reset Agents",failed:"Failed",error:"Error",resetResult:(e,t)=>`Reset — ${e} of ${t} agent${1!==t?"s":""} restarted`,fullReset:"Full Reset",confirmFullReset:"Reset all projects?",fullResetResult:(e,t,n)=>`Full reset — ${e} project${1!==e?"s":""}, ${t} agent${1!==t?"s":""} (${(n/1e3).toFixed(1)}s)`,fullResetFailed:"Full reset failed",interrupt:"Interrupt",interruptAll:"All agents",interrupted:e=>`Interrupted ${e}`,interruptedAll:e=>`Interrupted ${e} agent${1!==e?"s":""}`},system:{keepAwake:"Keep Mac Awake",keepAwakeAbout:"About Keep Mac Awake",keepAwakeHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Keep Mac Awake"})," runs macOS ",(0,t.jsx)("code",{children:"caffeinate"})," to stop the screen, disk, and system idle timers from sleeping your Mac during an overnight run. Make sure the laptop is plugged in — caffeinate blocks sleep but not battery drain."]}),autoAwakeOn:"Auto-awake ON: caffeinate starts/stops with batch lifecycle",autoAwakeOff:"Auto-awake OFF: manual Start/Stop only",awakeFor:e=>`Awake for ${e} more — keep Mac plugged in`,awakeIndefinitely:"Awake indefinitely — keep Mac plugged in",awakeDesc:"Prevents your Mac from sleeping during overnight runs.",awake:"Awake",start:"Start",on:"on",sound:"Notification Sound",soundAbout:"About Notification Sound",soundHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Notification Sound"})," plays a brief chime when an agent posts a new message (not your own sends, not system events). Sound choice picks one of the bundled chimes. Background-only mode suppresses the chime while the tab is focused — ding only when you're looking elsewhere. All prefs persist in localStorage."]}),soundDesc:"Plays a chime when an agent posts a new message.",soundLabel:"Sound",soundBgOnly:"Only when tab is in background",awakeStatusActive:"Batch active — auto-started caffeinate.",awakeStatusComplete:"Batch complete — awake paused.",awakeStatusNew:"New batch detected — auto-started caffeinate.",keepAwakeModalTitle:"Keep Awake",keepAwakeModalAbout:"About Keep Awake",keepAwakeModalHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Keep Awake"})," prevents your Mac from sleeping for the duration you set. Use this when you want agents to keep working overnight.",(0,t.jsx)("br",{}),(0,t.jsx)("br",{}),"Under the hood, this runs macOS's ",(0,t.jsx)("code",{children:"caffeinate"})," command. While it's active your screen, disk, and system idle timers are all paused — make sure your Mac is ",(0,t.jsx)("b",{children:"plugged in"})," to avoid draining the battery."]}),makeSurePluggedIn:"Make sure Mac is plugged in",for:"for",hours:"hours",untilStopped:"Until stopped (no expiry)"}},ko:{server:{title:"서버",resetAgents:"에이전트 초기화",failed:"실패",error:"오류",resetResult:(e,t)=>`초기화 완료 — ${t}개 중 ${e}개 에이전트 재시작됨`,fullReset:"전체 리셋",confirmFullReset:"모든 프로젝트를 리셋할까요?",fullResetResult:(e,t,n)=>`전체 리셋 완료 — ${e}개 프로젝트, ${t}개 에이전트 (${(n/1e3).toFixed(1)}초)`,fullResetFailed:"전체 리셋 실패",interrupt:"중단",interruptAll:"모든 에이전트",interrupted:e=>`${e} 중단됨`,interruptedAll:e=>`${e}개 에이전트 중단됨`},system:{keepAwake:"Mac 절전 방지",keepAwakeAbout:"Mac 절전 방지 정보",keepAwakeHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Mac 절전 방지"}),"는 macOS의 ",(0,t.jsx)("code",{children:"caffeinate"}),"를 실행해 야간 작업 중 Mac이 절전 상태로 들어가는 것을 막습니다. 충전기를 연결해 두세요. caffeinate는 절전은 막지만 배터리 소모를 막아주지는 않습니다."]}),autoAwakeOn:"자동 절전 방지 켬: 배치 상태에 따라 caffeinate 시작/종료",autoAwakeOff:"자동 절전 방지 끔: 수동 시작/종료만 가능",awakeFor:e=>`앞으로 ${e} 동안 절전 방지 — 전원을 연결해 두세요`,awakeIndefinitely:"무기한 절전 방지 중 — 전원을 연결해 두세요",awakeDesc:"야간 작업 중 Mac이 잠들지 않도록 합니다.",awake:"절전 방지 중",start:"시작",on:"켬",sound:"알림음",soundAbout:"알림음 정보",soundHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"알림음"}),"은 에이전트가 새 메시지를 보낼 때 짧은 알림음을 재생합니다. 내 메시지나 시스템 이벤트에는 울리지 않습니다. 사운드 선택으로 내장 알림음 중 하나를 고를 수 있고, 백그라운드 전용 모드는 탭이 포커스된 동안에는 알림음을 막습니다. 모든 설정은 localStorage에 저장됩니다."]}),soundDesc:"에이전트가 새 메시지를 보낼 때 알림음을 재생합니다.",soundLabel:"알림음",soundBgOnly:"탭이 백그라운드에 있을 때만",awakeStatusActive:"배치 실행 중 — caffeinate를 자동으로 시작했습니다.",awakeStatusComplete:"배치 완료 — 절전 방지를 일시 중단했습니다.",awakeStatusNew:"새 배치 감지 — caffeinate를 자동으로 시작했습니다.",keepAwakeModalTitle:"절전 방지",keepAwakeModalAbout:"절전 방지 정보",keepAwakeModalHelp:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"절전 방지"}),"는 설정한 시간 동안 Mac이 절전 상태로 들어가는 것을 막습니다. 에이전트가 밤새 작업하게 하려면 이 기능을 사용하세요.",(0,t.jsx)("br",{}),(0,t.jsx)("br",{}),"내부적으로는 macOS의 ",(0,t.jsx)("code",{children:"caffeinate"})," 명령을 실행합니다. 실행 중에는 화면, 디스크, 시스템 유휴 타이머가 모두 정지됩니다. 배터리 소모를 막으려면 Mac에 ",(0,t.jsx)("b",{children:"전원을 연결"}),"해 두세요."]}),makeSurePluggedIn:"전원을 연결해 두세요",for:"시간:",hours:"시간",untilStopped:"중지할 때까지 (만료 없음)"}}};function nY({projectId:e}){let{locale:r}=(0,o.useLocale)(),l=nK[r].server,[i,a]=(0,n.useState)(null),[s,c]=(0,n.useState)(null),[u,d]=(0,n.useState)(!1),[p,h]=(0,n.useState)(!1),[f,m]=(0,n.useState)({}),x=(0,n.useRef)(null),g=["head","dev","re1","re2"];(0,n.useEffect)(()=>{let t=()=>{fetch("/api/agents").then(e=>e.ok?e.json():{}).then(t=>{let n={};for(let r of g){let l=`${e}/${r}`;n[r]=t[l]?.state||"stopped"}m(n)}).catch(()=>{})};t();let n=setInterval(t,5e3);return()=>clearInterval(n)},[e]),(0,n.useEffect)(()=>{if(!p)return;let e=e=>{x.current&&!x.current.contains(e.target)&&h(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);let b=async t=>{h(!1);let n=t?`/api/agents/${encodeURIComponent(e)}/${encodeURIComponent(t)}/interrupt`:`/api/agents/${encodeURIComponent(e)}/interrupt-all`;a("interrupt");try{let e=await fetch(n,{method:"POST"}),r=await e.json();t?c(r.ok?l.interrupted(t):r.error||l.failed):c(r.ok?l.interruptedAll(r.interrupted):r.error||l.failed)}catch{c(l.error)}a(null),y()},y=()=>{setTimeout(()=>c(null),3e3)};(0,n.useEffect)(()=>{if(!u)return;let e=setTimeout(()=>d(!1),4e3);return()=>clearTimeout(e)},[u]);let v=async()=>{if(!u)return void d(!0);d(!1),a("fullReset");try{let e=await fetch("/api/full-reset",{method:"POST"}),t=await e.json();c(t.ok?l.fullResetResult(t.projects,t.agents,t.duration_ms):t.error||l.fullResetFailed)}catch{c(l.fullResetFailed)}a(null),y()},w=async()=>{a("reset");try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/reset`,{method:"POST"}),n=await t.json();c(n.ok?l.resetResult(n.restarted,n.total):n.error||l.failed)}catch{c(l.error)}a(null),y()};return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:l.title}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("button",{onClick:w,disabled:!!i,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"reset"===i?"...":l.resetAgents}),(0,t.jsx)("button",{onClick:v,disabled:!!i,className:`px-1.5 py-0.5 text-[10px] border transition-colors disabled:opacity-50 ${u?"text-error border-error/60 bg-error/10 hover:bg-error/20":"text-text-muted border-border hover:text-accent hover:border-accent/40"}`,children:"fullReset"===i?"...":u?l.confirmFullReset:l.fullReset}),(0,t.jsxs)("div",{className:"relative",ref:x,children:[(0,t.jsx)("button",{onClick:()=>h(e=>!e),disabled:!!i,className:"px-1.5 py-0.5 text-[10px] text-text-muted border border-border hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-50",children:"interrupt"===i?"...":`${l.interrupt} ▾`}),p&&(0,t.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 p-1 border border-border bg-bg-surface z-20 min-w-[140px] flex flex-col",children:[g.map(e=>(0,t.jsxs)("button",{onClick:()=>b(e),className:"flex items-center gap-1.5 px-2 py-1 text-[10px] text-text-muted hover:text-accent hover:bg-white/5 text-left",children:[(0,t.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${"running"===f[e]?"bg-accent":"bg-text-muted/40"}`}),e.charAt(0).toUpperCase()+e.slice(1)]},e)),(0,t.jsx)("div",{className:"border-t border-border my-0.5"}),(0,t.jsx)("button",{onClick:()=>b(null),className:"px-2 py-1 text-[10px] text-text-muted hover:text-accent hover:bg-white/5 text-left",children:l.interruptAll})]})]})]}),s&&(0,t.jsx)("div",{className:"text-[10px] text-accent",children:s})]})}function nX(e){return Number.isFinite(e)?Math.min(Math.max(e,.1),24):3}function nZ(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return t>0?`${t}h ${n}m`:`${n}m`}function n0({projectId:e}){let{locale:r}=(0,o.useLocale)(),l=nK[r].system,[i,a]=(0,n.useState)(!1),[s,c]=(0,n.useState)(null),[u,d]=(0,n.useState)(""),[p,h]=(0,n.useState)(!1),[f,m]=(0,n.useState)(String(3)),[x,g]=(0,n.useState)(!1),[b,y]=(0,n.useState)(!1),[v,w]=(0,n.useState)(!1),[k,j]=(0,n.useState)(null),N=(0,n.useRef)(!1),S=(0,n.useRef)(null),C=(0,n.useRef)(!1),E=(0,n.useRef)(!1);E.current=i,N.current=v;let[T,I]=(0,n.useState)(!1),[A,R]=(0,n.useState)(!1),[O,P]=(0,n.useState)(!0),[M,F]=(0,n.useState)("soft-chime"),[L,D]=(0,n.useState)(!0);(0,n.useEffect)(()=>{P((0,nQ.getNotificationEnabled)()),F((0,nQ.getNotificationChoice)()),D((0,nQ.getNotificationBackgroundOnly)())},[]);let _=(0,n.useCallback)(()=>{fetch("/api/caffeinate/status").then(e=>e.ok?e.json():null).then(e=>{e&&(a(e.active),c(e.remaining),d(e.platform))}).catch(()=>{})},[]);(0,n.useEffect)(()=>{_();let e=setInterval(_,5e3);return()=>clearInterval(e)},[_]);let $=e=>{fetch("/api/caffeinate/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:e})}).then(e=>e.json()).then(t=>{t.ok&&(a(!0),c(e||null))}).catch(()=>{}),h(!1)};(0,n.useEffect)(()=>{w(!1),j(null),S.current=null,C.current=!1,fetch("/api/config").then(e=>e.ok?e.json():null).then(t=>{if(!t)return;let n=(t.projects||[]).find(t=>t.id===e);n?.awake_auto&&w(!0)}).catch(()=>{})},[e]);let U=(0,n.useCallback)(async()=>{let t=!v;w(t),t||(j(null),S.current=null,C.current=!1);try{let n=await fetch("/api/config");if(!n.ok)return;let r=await n.json(),l=(r.projects||[]).find(t=>t.id===e);l&&(l.awake_auto=t,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}))}catch{}},[v,e]),z=(0,n.useCallback)(()=>{let e=parseFloat(f),t=Math.round(3600*(Number.isFinite(e)?nX(e):8));fetch("/api/caffeinate/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:t})}).then(e=>e.json()).then(e=>{e.ok&&(a(!0),c(t),C.current=!1)}).catch(()=>{})},[f]),B=(0,n.useCallback)(()=>{fetch("/api/caffeinate/stop",{method:"POST"}).then(()=>{a(!1),c(null)}).catch(()=>{})},[]);(0,n.useEffect)(()=>{if(!v)return;let t=async()=>{if(N.current)try{let t=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!t.ok)return;let n=await t.json(),r=n.items.length>0,i=S.current;if(S.current={complete:n.complete,hasItems:r},!i){!r||n.complete||E.current||(z(),j(l.awakeStatusActive)),r&&n.complete&&E.current&&(B(),j(l.awakeStatusComplete));return}r&&n.complete&&!i.complete&&E.current&&(B(),j(l.awakeStatusComplete),C.current=!1),!r||n.complete||!i.complete&&i.hasItems||E.current||C.current||(z(),j(l.awakeStatusNew))}catch{}};t();let n=setInterval(t,3e4);return()=>clearInterval(n)},[v,e,z,B,l]);let H=!u||"darwin"===u;return(0,t.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6 relative",children:[H&&(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,t.jsx)("span",{children:l.keepAwake}),(0,t.jsx)("button",{type:"button","aria-label":l.keepAwakeAbout,onClick:()=>I(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),(0,t.jsxs)("button",{type:"button",onClick:U,title:v?l.autoAwakeOn:l.autoAwakeOff,className:`ml-1 px-1.5 py-0.5 text-[10px] border transition-colors ${v?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",v?"●":"○"]})]}),T&&(0,t.jsx)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:l.keepAwakeHelp}),k&&(0,t.jsx)("div",{className:"text-[10px] text-accent bg-accent/5 border border-border/50 px-1.5 py-0.5 mt-0.5",children:k}),(0,t.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:i&&null!==s&&s>0?l.awakeFor(nZ(s)):i&&null===s?l.awakeIndefinitely:l.awakeDesc}),(0,t.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:(0,t.jsxs)("button",{onClick:()=>i?void(C.current=!0,fetch("/api/caffeinate/stop",{method:"POST"}).then(()=>{a(!1),c(null)}).catch(()=>{})):h(!p),title:"Keep Mac awake (caffeinate)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${i?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[i?l.awake:l.start,i&&null!==s&&s>0&&(0,t.jsx)("span",{className:"ml-1 text-accent/70",children:nZ(s)}),i&&null===s&&(0,t.jsx)("span",{className:"ml-1 text-accent/70",children:l.on})]})})]}),H&&(0,t.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 relative",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-muted uppercase tracking-wider font-semibold",children:[(0,t.jsx)("span",{children:l.sound}),(0,t.jsx)("button",{type:"button","aria-label":l.soundAbout,onClick:()=>R(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),A&&(0,t.jsx)("div",{className:"absolute left-0 top-4 z-30 w-64 p-2 text-[10px] leading-snug text-text bg-bg-surface border border-border rounded shadow-lg",children:l.soundHelp}),(0,t.jsx)("div",{className:"text-[10px] text-text-muted leading-tight",children:l.soundDesc}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap mt-0.5",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{let e=!O;P(e),(0,nQ.setNotificationEnabled)(e)},title:O?"Notification sound on (click to mute)":"Notification sound off (click to unmute)",className:`px-1.5 py-0.5 text-[10px] border transition-colors ${O?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[O?"🔔":"🔕"," ",l.soundLabel]}),O&&(0,t.jsx)("select",{value:M,onChange:e=>(e=>{if(F(e),(0,nQ.setNotificationChoice)(e),O)try{let t=new Audio(`/sounds/${e}.mp3`);t.volume=.6,t.play().catch(()=>{})}catch{}})(e.target.value),title:"Notification sound",className:"bg-transparent border border-border px-1 py-0.5 text-[10px] text-text outline-none focus:border-accent cursor-pointer",children:nQ.NOTIFICATION_SOUND_OPTIONS.map(e=>(0,t.jsx)("option",{value:e.value,className:"bg-bg-surface",children:e.label},e.value))})]}),O&&(0,t.jsxs)("label",{className:"flex items-center gap-1 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,t.jsx)("input",{type:"checkbox",checked:L,onChange:e=>{var t;D(t=e.target.checked),(0,nQ.setNotificationBackgroundOnly)(t)}}),l.soundBgOnly]})]}),p&&!i&&(0,t.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 p-2 border border-border bg-bg-surface z-20 min-w-[220px] flex flex-col gap-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:l.keepAwakeModalTitle}),(0,t.jsx)("button",{type:"button","aria-label":l.keepAwakeModalAbout,onClick:()=>y(e=>!e),className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"})]}),b&&(0,t.jsx)("div",{className:"p-1.5 text-[10px] leading-snug text-text bg-bg border border-border/60 rounded",children:l.keepAwakeModalHelp}),(0,t.jsx)("p",{className:"text-[10px] text-[#ffcc00]",children:l.makeSurePluggedIn}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px]",children:[(0,t.jsx)("span",{className:"text-text-muted",children:l.for}),(0,t.jsx)("input",{type:"number",value:f,onChange:e=>m(e.target.value),onBlur:()=>{let e=parseFloat(f);m(String(Math.round(10*(Number.isFinite(e)?nX(e):3))/10))},disabled:x,min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-text outline-none focus:border-accent text-center disabled:opacity-40"}),(0,t.jsx)("span",{className:"text-text-muted",children:l.hours})]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,t.jsx)("input",{type:"checkbox",checked:x,onChange:e=>g(e.target.checked)}),l.untilStopped]}),(0,t.jsx)("button",{type:"button",onClick:()=>{if(x)return void $(0);let e=parseFloat(f);$(Math.round(3600*(Number.isFinite(e)?nX(e):3)))},className:"self-start px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors",children:l.start})]})]})}function n1({projectId:e}){return(0,t.jsx)("div",{className:"border-t border-border px-3 py-2",children:(0,t.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start gap-2 md:gap-6",children:[(0,t.jsx)(nY,{projectId:e}),(0,t.jsx)("div",{className:"border-t border-border/40 md:border-t-0 md:w-px md:h-auto md:self-stretch md:bg-border"}),(0,t.jsx)(n0,{projectId:e})]})})}var n2=e.i(99894),n5=e.i(93309);function n4({projectId:e,agentId:r,wsUrl:l,onActivity:i}){let o=(0,n.useRef)(null),a=(0,n.useRef)(null),s=(0,n.useRef)(null),c=(0,n.useRef)(null),u=(0,n.useRef)(i);(0,n.useEffect)(()=>{u.current=i},[i]);let d=(0,n.useCallback)(()=>{if(s.current&&a.current&&o.current)try{s.current.fit();let e=c.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:"resize",cols:a.current.cols,rows:a.current.rows}))}catch{}},[]);return(0,n.useEffect)(()=>{if(!o.current)return;let t=new n2.Terminal({scrollback:1e3,fontSize:11,fontFamily:'"Geist Mono", "JetBrains Mono", "Fira Code", "Cascadia Code", monospace',lineHeight:1.2,letterSpacing:.5,cursorBlink:!1,cursorStyle:"block",theme:{background:"#0a0a0a",foreground:"#e0e0e0",cursor:"#00ff88",cursorAccent:"#0a0a0a",selectionBackground:"#00ff8844",black:"#0a0a0a",red:"#ff4444",green:"#00ff88",yellow:"#ffcc00",blue:"#4488ff",magenta:"#cc44ff",cyan:"#44ccff",white:"#e0e0e0",brightBlack:"#737373",brightRed:"#ff6666",brightGreen:"#00ff88",brightYellow:"#ffdd44",brightBlue:"#66aaff",brightMagenta:"#dd66ff",brightCyan:"#66ddff",brightWhite:"#ffffff"},allowTransparency:!1,drawBoldTextInBrightColors:!0}),n=new n5.FitAddon;t.loadAddon(n),t.open(o.current),a.current=t,s.current=n,requestAnimationFrame(()=>d());let i=new ResizeObserver(()=>requestAnimationFrame(()=>d()));i.observe(o.current),t.onData(e=>{let t=c.current;t&&t.readyState===WebSocket.OPEN&&t.send(e)});let p=!1,h=null,f=async()=>{if(h)return h;if(l)return h=l;let e="https:"===window.location.protocol?"wss:":"ws:";try{let t=await fetch("/api/config");if(t.ok){let n=(await t.json()).port||8400,r=parseInt(window.location.port,10);h=r&&r!==n?`${e}//${window.location.hostname}:${n}`:`${e}//${window.location.host}`}else h=`${e}//${window.location.host}`}catch{h=`${e}//${window.location.host}`}return h},m=async()=>{try{let t=await fetch("/api/sessions");if(!t.ok)return!1;let n=await t.json();return Array.isArray(n)&&n.some(t=>t&&t.projectId===e&&t.agentId===r)}catch{return!1}},x=0,g=!1,b=async()=>{let n=await f();if(p)return;let l=new WebSocket(`${n}/ws/terminal?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(r)}`);c.current=l,l.onopen=()=>{x=0,l.send(JSON.stringify({type:"resize",cols:t.cols,rows:t.rows})),l.send(JSON.stringify({type:"replay"}))},l.onmessage=e=>{t.write(e.data),g||(g=!0,requestAnimationFrame(()=>{d(),g=!1}));let n=u.current;n&&n()},l.onclose=async e=>{if(!p){if(x<5){let e=Date.now(),n=!1;for(;Date.now()-e<2e3;){if(await new Promise(e=>setTimeout(e,200)),p)return;if(await m()){n=!0;break}}if(p)return;if(n){x+=1,t.reset(),t.write(`\x1b[38;2;115;115;115m[reattached to new session]\x1b[0m\r
6
+ `),b();return}}t.write(`\r
7
+ \x1b[38;2;115;115;115m[session closed: ${e.reason||e.code}]\x1b[0m\r
8
+ `)}}};return b(),()=>{p=!0,i.disconnect(),c.current?.close(),t.dispose(),a.current=null,s.current=null,c.current=null}},[e,r,l,d]),(0,t.jsx)("div",{ref:o,className:"w-full h-full"})}let n3=[{id:"re1",label:"RE1"},{id:"re2",label:"RE2"},{id:"dev",label:"Dev"}],n6=["border-r border-b border-border","border-b border-border","col-span-2"],n9=["border-r border-b border-border","border-b border-border","border-r border-border",""];function n7({projectId:e,agents:r=n3,agentStates:l={},onStatusChange:i}){let[o,a]=(0,n.useState)(null),s=r.length>=4?n9:n6,c=(0,n.useRef)({}),[u,d]=(0,n.useState)(0),p=(0,n.useCallback)(e=>{c.current[e]=Date.now()},[]),h=(0,n.useRef)({}),f=(0,n.useCallback)((t,n)=>{fetch("/api/activity/log",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e,agent:t,type:n,timestamp:Date.now()})}).catch(()=>{})},[e]);(0,n.useEffect)(()=>{let e=setInterval(()=>{for(let e of(d(e=>e+1),r)){let t=c.current[e.id],n=void 0!==t&&Date.now()-t<5e3,r=!!h.current[e.id];n&&!r?(h.current[e.id]=!0,f(e.id,"start")):!n&&r&&(h.current[e.id]=!1,f(e.id,"end"))}},500);return()=>clearInterval(e)},[r,f]);let m=e=>{let t=c.current[e];return void 0!==t&&Date.now()-t<5e3};return(0,t.jsx)("div",{className:"w-full h-full relative grid grid-rows-2 grid-cols-2",children:r.map((n,r)=>{let c=o===n.id,u=null!==o&&!c;return(0,t.jsxs)("div",{className:`flex flex-col ${c?"absolute inset-0 z-10 bg-bg":`${s[r]||""}`}`,style:u?{visibility:"hidden",overflow:"hidden"}:void 0,children:[(0,t.jsxs)("div",{className:`flex items-center justify-between px-3 shrink-0 border-b border-border ${c?"h-7":"h-6"}`,children:[(0,t.jsxs)("div",{className:`flex items-center gap-1.5 ${!c?"cursor-pointer":""}`,onClick:c?void 0:()=>a(n.id),children:[(0,t.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:["running"===l[n.id]&&m(n.id)&&(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,t.jsx)("span",{className:`relative w-1.5 h-1.5 rounded-full ${"running"===l[n.id]?"bg-accent":"error"===l[n.id]?"bg-error":"bg-text-muted"}`})]}),(0,t.jsx)("span",{className:`text-[11px] uppercase tracking-wider ${"running"===l[n.id]&&m(n.id)?"text-accent animate-name-shimmer":"text-text-muted"}`,children:n.label})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:["running"!==l[n.id]&&(0,t.jsx)("button",{onClick:()=>{fetch(`/api/agents?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(n.id)}&action=start`,{method:"POST"}).then(e=>e.json()).then(e=>{e.state&&i&&i(n.id,e.state)}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-accent transition-colors px-0.5",title:"Start",children:"▶"}),"running"===l[n.id]&&(0,t.jsx)("button",{onClick:()=>{fetch(`/api/agents?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(n.id)}&action=stop`,{method:"POST"}).then(e=>e.json()).then(e=>{e.state&&i&&i(n.id,e.state)}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-error transition-colors px-0.5",title:"Stop",children:"■"}),(0,t.jsx)("button",{onClick:()=>{fetch(`/api/agents?project=${encodeURIComponent(e)}&agent=${encodeURIComponent(n.id)}&action=restart`,{method:"POST"}).then(e=>e.json()).then(e=>{e.state&&i&&i(n.id,e.state)}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-accent transition-colors px-0.5",title:"Restart",children:"↻"}),"running"===l[n.id]&&(0,t.jsx)("button",{onClick:()=>{fetch(`/api/agents/${encodeURIComponent(e)}/${encodeURIComponent(n.id)}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:"/compact\n"})}).catch(()=>{})},className:"text-[10px] text-text-muted hover:text-accent transition-colors px-0.5",title:"Compact — frees context/memory when agent is stuck",children:"/c"}),c&&(0,t.jsx)("button",{onClick:()=>a(null),className:"text-[11px] text-text-muted hover:text-text transition-colors ml-1",children:"esc"})]})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(n4,{projectId:e,agentId:n.id,onActivity:()=>p(n.id)})})]},n.id)})})}let n8="qw-terminals-collapsed",re={en:{title:"Agent Terminals",aboutLabel:"About agent terminals",tooltip:(0,t.jsxs)(t.Fragment,{children:["These show what each agent is doing in their CLI session. ",(0,t.jsx)("b",{children:"Do not type here directly"}),"— use the project chat above instead. Agents won't see messages typed in their terminals."]}),hide:"hide",show:"show"},ko:{title:"에이전트 터미널",aboutLabel:"에이전트 터미널 설명",tooltip:(0,t.jsxs)(t.Fragment,{children:["각 에이전트가 CLI 세션에서 무엇을 하고 있는지 보여주는 읽기 전용 터미널입니다. ",(0,t.jsx)("b",{children:"여기에 직접 입력하지 마세요."})," 위의 프로젝트 채팅을 사용해야 에이전트가 메시지를 볼 수 있습니다."]}),hide:"접기",show:"펼치기"}},rt=[{id:"head",label:"Head"},{id:"dev",label:"Dev"},{id:"re1",label:"RE1"},{id:"re2",label:"RE2"}];function rn({projectId:e,agentStates:r,onStatusChange:l,onCollapsedChange:i}){let{locale:a}=(0,o.useLocale)(),s=re[a],[c,u]=(0,n.useState)(!1),[d,p]=(0,n.useState)(!1),[h,f]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{p("true"===localStorage.getItem(n8)),f(!0)},[]),(0,n.useEffect)(()=>{h&&(localStorage.setItem(n8,String(d)),i?.(d))},[d,h,i]),d)?(0,t.jsx)("div",{className:"flex flex-col h-full min-h-0",children:(0,t.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:s.title}),(0,t.jsxs)("button",{type:"button",onClick:()=>p(!1),className:"text-[10px] text-text-muted hover:text-text transition-colors",children:["▸ ",s.show]})]})}):(0,t.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:s.title}),(0,t.jsxs)("div",{className:"relative inline-flex items-center",onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),children:[(0,t.jsx)("button",{type:"button","aria-label":s.aboutLabel,className:"w-3.5 h-3.5 rounded-full border border-border text-[9px] leading-none text-text-muted hover:text-accent hover:border-accent inline-flex items-center justify-center",children:"?"}),c&&(0,t.jsx)("div",{role:"tooltip",className:"ko-help absolute top-5 left-0 z-20 w-72 max-w-[min(18rem,calc(100vw-2rem))] p-2 text-[11px] leading-snug text-text bg-bg-surface border border-border shadow-lg",children:s.tooltip})]})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>p(!0),className:"text-[10px] text-text-muted hover:text-text transition-colors",children:["▾ ",s.hide]})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(n7,{projectId:e,agents:rt,agentStates:r,onStatusChange:l})})]})}let rr={en:{label:(e,t)=>`Scheduled Trigger${e?t?" (auto)":" (running)":""}`,tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Scheduled Trigger"})," sends a periodic message to all agents on a timer. Use this to keep the autonomous workflow running overnight. First message fires after the configured interval, not immediately."]}),autoTriggerOn:"Auto-trigger ON — trigger follows batch lifecycle",autoTriggerOff:"Auto-trigger OFF — manual start/stop only",auto:"Auto ",message:"Message",sendEvery:"Send every",minFor:"min for",hours:"hours",starting:"Starting…",startTrigger:"Start Trigger",sending:"Sending:",running:"Running",next:"Next: ",stopsIn:"Stops in: ",untilStopped:"(until stopped)",stopping:"Stopping…",stopTrigger:"Stop Trigger",autoStopStatus:"Batch complete — trigger paused. Waiting for next batch."},ko:{label:(e,t)=>`예약 트리거${e?t?" (자동)":" (실행 중)":""}`,tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"예약 트리거"})," - 타이머에 따라 모든 에이전트에게 주기적으로 메시지를 보냅니다. 야간 자율 워크플로우를 계속 돌릴 때 사용하세요. 첫 메시지는 즉시가 아니라 설정한 간격 후에 전송됩니다."]}),autoTriggerOn:"자동 트리거 ON - 배치 생명주기에 따라 트리거가 동작합니다",autoTriggerOff:"자동 트리거 OFF - 수동 시작/중지만 가능합니다",auto:"자동 ",message:"메시지",sendEvery:"전송 간격: ",minFor:"분 마다, ",hours:"시간 동안",starting:"시작 중…",startTrigger:"트리거 시작",sending:"전송 중:",running:"실행 중",next:"다음 전송: ",stopsIn:"종료까지: ",untilStopped:"(중지할 때까지)",stopping:"중지 중…",stopTrigger:"트리거 중지",autoStopStatus:"배치 완료 — 트리거 일시 중지. 다음 배치를 기다리는 중."}};function rl(e){return Number.isFinite(e)?Math.min(Math.max(e,.1),24):3}function ri(e){return!Number.isFinite(e)||e<=0?String(3):(Math.round(e/60*10)/10).toString()}function ro(e){if(e<=0)return"0m 0s";let t=Math.floor(e/36e5),n=Math.floor(e%36e5/6e4),r=Math.floor(e%6e4/1e3);return t>0?`${t}h ${n}m`:`${n}m ${r}s`}function ra({projectId:e}){let{locale:r}=(0,o.useLocale)(),i=rr[r],[a,s]=(0,n.useState)(null),[c,u]=(0,n.useState)(""),[d,p]=(0,n.useState)(15),[h,f]=(0,n.useState)("15"),[m,x]=(0,n.useState)(180),[g,b]=(0,n.useState)(()=>ri(180)),[y,v]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),j=(0,n.useRef)(""),N=(0,n.useRef)(!1),S=(0,n.useRef)(!1);(0,n.useEffect)(()=>{j.current=c},[c]),(0,n.useEffect)(()=>{N.current=y},[y]),(0,n.useEffect)(()=>{S.current=w},[w]);let[C,E]=(0,n.useState)(!1),[T,I]=(0,n.useState)(null),[A,R]=(0,n.useState)(""),[O,P]=(0,n.useState)(""),M=(0,n.useMemo)(()=>{let t;return t=`~/.quadwork/${e}/OVERNIGHT-QUEUE.md`,`@head @dev @re1 @re2 — Queue check.
9
+ @head: Merge any PR with both approvals, assign next from ${t}.
10
+ @dev: Work on assigned ticket or address review feedback.
11
+ @re1 & @re2: Review open PRs. If @dev pushed fixes, re-review. Post verdict on PR AND notify @dev here.
12
+ ALL: Communicate via this chat by tagging agents. Your terminal is NOT visible.`},[e]),[F,L]=(0,n.useState)(!1),[D,_]=(0,n.useState)(!1),[$,U]=(0,n.useState)(null),z=(0,n.useRef)(null),B=(0,n.useRef)(!1);(0,n.useEffect)(()=>{B.current=!1,z.current=null,L(!1),_(!1),U(null)},[e]),(0,n.useEffect)(()=>{B.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(t=>{if(!t)return;let n=(t.projects||[]).find(t=>t.id===e);n?.trigger_auto&&L(!0),B.current=!0}).catch(()=>{})},[e]);let H=(0,n.useCallback)(async()=>{try{let t=await fetch("/api/triggers");if(!t.ok)throw Error(`${t.status}`);let n=(await t.json())[e]||null;if(s(n),n){if(n.message&&!j.current&&(u(n.message),j.current=n.message),!N.current)if(n.enabled&&n.interval){let e=Math.max(1,Math.round(n.interval/6e4));p(e),f(String(e))}else"number"==typeof n.intervalMin&&n.intervalMin>0&&(p(n.intervalMin),f(String(n.intervalMin)));!S.current&&"number"==typeof n.durationMin&&n.durationMin>=0&&(x(n.durationMin),b(ri(n.durationMin)))}I(null)}catch(e){I(e.message)}},[e]);(0,n.useEffect)(()=>{c||u(M)},[M,c]),(0,n.useEffect)(()=>{H();let e=window.setInterval(H,5e3);return()=>window.clearInterval(e)},[H]),(0,n.useEffect)(()=>{if(!a?.enabled){R(""),P("");return}let e=()=>{if(a.nextAt&&R(ro(Math.max(0,a.nextAt-Date.now()))),a.expiresAt){let e=Math.max(0,a.expiresAt-Date.now());P(ro(e)),e<=0&&H()}else P("")};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[a?.enabled,a?.nextAt,a?.expiresAt,H]);let q=async()=>{E(!0),I(null);let t=parseFloat(g),n=Math.round(60*(Number.isFinite(t)?rl(t):3));n!==m&&(x(n),b(ri(n)));let r=parseInt(h,10),l=Number.isFinite(r)?Math.max(1,Math.min(1440,r)):15;l!==d&&(p(l),f(String(l)));try{let t=await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:l,duration:n,message:c})});if(!t.ok)throw Error(`${t.status}`);v(!1),k(!1),await H()}catch(e){I(e.message)}finally{E(!1)}},V=async()=>{E(!0),I(null);try{let t=await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"});if(!t.ok)throw Error(`${t.status}`);_(!1),s({...a||{interval:0,lastSent:null,nextAt:null,expiresAt:null,message:c,intervalMin:d,durationMin:m},enabled:!1}),await H()}catch(e){I(e.message)}finally{E(!1)}},W=(0,n.useCallback)(async()=>{let t=!F;L(t),t||(U(null),z.current=null);try{let n=await fetch("/api/config");if(!n.ok)return;let r=await n.json(),l=(r.projects||[]).find(t=>t.id===e);l&&(l.trigger_auto=t,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}))}catch{}},[F,e]),G=(0,n.useRef)(F),J=(0,n.useRef)(a);(0,n.useEffect)(()=>{G.current=F},[F]),(0,n.useEffect)(()=>{J.current=a},[a]);let Q=(0,n.useCallback)(async()=>{if(G.current)try{let t=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!t.ok)return;let n=await t.json(),r=n.items.length>0,l=z.current;if(z.current={complete:n.complete,hasItems:r},!l){if(r&&!n.complete&&!J.current?.enabled){_(!0),U(null);let t=parseFloat(g),n=Number.isFinite(t)?rl(t):3,r=Math.round(60*n),l=parseInt(h,10),i=Number.isFinite(l)?Math.max(1,Math.min(1440,l)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:i,duration:r,message:j.current||M})}),await H()}r&&n.complete&&J.current?.enabled&&(await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"}),_(!1),U(i.autoStopStatus),await H());return}if(r&&n.complete&&!l.complete&&J.current?.enabled){await fetch(`/api/triggers/${encodeURIComponent(e)}/stop`,{method:"POST"}),_(!1),U(i.autoStopStatus),await H();return}if(r&&!n.complete&&(l.complete||!l.hasItems)&&!J.current?.enabled){_(!0),U(null);let t=parseFloat(g),n=Number.isFinite(t)?rl(t):3,r=Math.round(60*n),l=parseInt(h,10),i=Number.isFinite(l)?Math.max(1,Math.min(1440,l)):15;await fetch(`/api/triggers/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interval:i,duration:r,message:j.current||M})}),await H()}}catch{}},[e,g,h,M,H,i.autoStopStatus]);(0,n.useEffect)(()=>{if(!F)return;Q();let e=window.setInterval(Q,3e4);return()=>window.clearInterval(e)},[F,Q]);let K=!!a?.enabled;return(0,t.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:i.label(K,D)}),(0,t.jsx)(l.default,{children:i.tooltip})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[T&&(0,t.jsxs)("span",{className:"text-[10px] text-error",children:["err: ",T]}),(0,t.jsxs)("button",{type:"button",onClick:W,title:F?i.autoTriggerOn:i.autoTriggerOff,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${F?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:[i.auto,F?"●":"○"]})]})]}),$&&(0,t.jsx)("div",{className:"px-3 py-1 text-[10px] text-accent bg-accent/5 border-b border-border/50",children:$}),K?(0,t.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,t.jsx)("div",{className:"text-[11px] text-text-muted",children:i.sending}),(0,t.jsx)("pre",{className:"text-[11px] font-mono whitespace-pre-wrap text-text bg-bg-surface border border-border p-2 max-h-28 overflow-auto",children:(a?.message||c).slice(0,400)}),(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-wrap text-[11px]",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,t.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,t.jsx)("span",{className:"text-accent",children:i.running})]}),(0,t.jsxs)("span",{className:"tabular-nums text-text",children:[i.next,A]}),O&&(0,t.jsxs)("span",{className:"tabular-nums text-text-muted",children:[i.stopsIn,O]}),!a?.expiresAt&&(0,t.jsx)("span",{className:"text-text-muted",children:i.untilStopped})]}),(0,t.jsx)("button",{onClick:V,disabled:C,className:"self-start px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:C?i.stopping:i.stopTrigger})]}):(0,t.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[(0,t.jsx)("label",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:i.message}),(0,t.jsx)("textarea",{value:c,onChange:e=>u(e.target.value),rows:6,spellCheck:!1,className:"w-full bg-bg text-text text-[11px] font-mono p-2 border border-border outline-none focus:border-accent resize-y"}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-[11px]",children:[(0,t.jsx)("span",{className:"text-text-muted",children:i.sendEvery}),(0,t.jsx)("input",{type:"number",value:h,onChange:e=>{f(e.target.value),v(!0)},onBlur:()=>{let e=parseInt(h,10),t=Number.isFinite(e)?Math.max(1,Math.min(1440,e)):15;p(t),f(String(t))},min:1,max:1440,className:"w-12 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,t.jsx)("span",{className:"text-text-muted",children:i.minFor}),(0,t.jsx)("input",{type:"number",value:g,onChange:e=>{b(e.target.value),k(!0)},onBlur:()=>{let e=parseFloat(g),t=Math.round(60*(Number.isFinite(e)?rl(e):3));x(t),b(ri(t))},min:.1,max:24,step:.1,className:"w-14 bg-transparent border border-border px-1 py-0.5 text-[11px] text-text outline-none focus:border-accent text-center"}),(0,t.jsx)("span",{className:"text-text-muted",children:i.hours})]}),(0,t.jsx)("button",{onClick:q,disabled:C||!c.trim(),className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:C?i.starting:i.startTrigger})]})]})}function rs({open:e,initialChatId:r="",onClose:l,onSave:i}){let[o,a]=(0,n.useState)(""),[s,c]=(0,n.useState)(r),[u,d]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),[f,m]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{e&&c(r)},[e,r]),(0,n.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,l]),!e)return null;let x=async()=>{d(!0),h(null);try{await i(o.trim(),s.trim()),l()}catch(e){h(e.message||"Save failed")}finally{d(!1)}};return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:l,role:"dialog","aria-modal":"true","aria-labelledby":"telegram-setup-title",children:(0,t.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("button",{type:"button",onClick:l,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,t.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,t.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,t.jsx)("h2",{id:"telegram-setup-title",className:"text-base font-semibold text-white",children:"Set up your Telegram Bridge"}),(0,t.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards project chat messages to a Telegram chat, so you can read and reply on your phone."}),(0,t.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Telegram bot"}),(0,t.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,t.jsxs)("li",{children:["Open Telegram and search for ",(0,t.jsx)("b",{children:"@BotFather"}),"."]}),(0,t.jsxs)("li",{children:["Send ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"/newbot"})," and follow the prompts."]}),(0,t.jsxs)("li",{children:["Choose a name and username (must end in ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),")."]}),(0,t.jsxs)("li",{children:["BotFather replies with a ",(0,t.jsx)("b",{children:"bot token"})," that looks like ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"123456:ABC-DEF1234ghIkl…"}),". Copy it."]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Get your chat ID"}),(0,t.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,t.jsxs)("li",{children:["Open Telegram and search for your new bot by its exact ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"@username"}),"."]}),(0,t.jsxs)("li",{children:["Tap ",(0,t.jsx)("b",{children:"Start"})," and send any message (e.g. ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"hello"}),")."," ",(0,t.jsxs)("span",{className:"text-neutral-400",children:["You must send at least one message first — ",(0,t.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," returns ",(0,t.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:'{"ok":true,"result":[]}'})," until Telegram has an inbound message on record."]})]}),(0,t.jsxs)("li",{children:["Open this URL in your browser (replace ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"YOUR_TOKEN"}),"):",(0,t.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://api.telegram.org/botYOUR_TOKEN/getUpdates"})]}),(0,t.jsxs)("li",{children:["Look for ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:'"chat":{"id":<NUMBER>'})," in the JSON. That number is your ",(0,t.jsx)("b",{children:"chat id"}),". Group chat ids are negative (e.g. ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"-1001234567890"}),") — paste the full value ",(0,t.jsx)("b",{children:"including the minus sign"}),"."]})]}),(0,t.jsx)("p",{className:"mt-1 text-neutral-400",children:"Or use one of these terminal one-liners:"}),(0,t.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["With ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (cleanest):"]}),(0,t.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"curl -s \"https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates\" | jq '.result[-1].message.chat.id'"}),(0,t.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-400",children:["Without ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"jq"})," (pure grep):"]}),(0,t.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates" | grep -o \'"chat":{"id":-\\?[0-9]*\' | tail -1'}),(0,t.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["The first message from a brand-new bot sometimes doesn't propagate to ",(0,t.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"getUpdates"})," instantly. If ",(0,t.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"result"})," is empty, send 2-3 more messages and retry."]}),(0,t.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"mt-2 text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Still empty? Troubleshooting ▸"}),f&&(0,t.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{className:"text-white",children:"Webhook conflict."})," Something else may be consuming updates. Check and delete any active webhook:",(0,t.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getWebhookInfo" curl -s "https://api.telegram.org/bot<TOKEN>/deleteWebhook"'})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{className:"text-white",children:"Stale bridge process."}),"A leftover bridge from a previous install will hold the update queue. Two consumers can't share one bot:",(0,t.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"ps aux | grep telegram_bridge | grep -v grep"}),"Kill any PIDs that show up before retrying the curl."]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{className:"text-white",children:"Token / bot mismatch."})," A token that doesn't match the bot you're messaging silently returns empty results. Confirm the token's ",(0,t.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"username"})," matches the ",(0,t.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"@username"}),"you're chatting with:",(0,t.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:'curl -s "https://api.telegram.org/bot<TOKEN>/getMe"'})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Paste credentials below"}),(0,t.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,t.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,t.jsx)("input",{type:"password",value:o,onChange:e=>a(e.target.value),placeholder:"123456:ABC-DEF…",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,t.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Chat id",(0,t.jsx)("input",{type:"text",value:s,onChange:e=>c(e.target.value),placeholder:"123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),p&&(0,t.jsx)("div",{className:"text-[11px] text-error",children:p}),(0,t.jsx)("button",{type:"button",onClick:x,disabled:u||!o.trim()||!s.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:u?"Saving…":"Save and start bridge"})]})]})]})]})})}let rc={en:{title:"Telegram Bridge",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Telegram Bridge"})," forwards project chat messages to a Telegram bot so you can monitor from your phone. Bidirectional — replies from Telegram appear in chat."]}),autoOn:"Auto ON — bridge follows batch lifecycle",autoOff:"Auto OFF — manual start/stop only",notConfigured:"Not configured",setUp:"Set up Telegram Bridge",running:"Running",stopped:"Stopped",stop:"Stop",stopping:"Stopping…",start:"Start",starting:"Starting…",howToSetUp:"How to set up",editCredentials:"Edit credentials",dismiss:"dismiss",batchActive:"Batch active — auto-starting bridge.",batchComplete:"Batch complete — bridge paused. Waiting for next batch.",newBatch:"New batch detected — auto-starting bridge."},ko:{title:"텔레그램 브릿지",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"텔레그램 브릿지"})," - 프로젝트 채팅 메시지를 텔레그램 봇으로 전달해서 휴대폰에서 모니터링할 수 있게 합니다. 양방향이며 텔레그램에서 보낸 답장도 채팅에 나타납니다."]}),autoOn:"자동 모드 켬 — 브릿지가 배치 주기를 따릅니다",autoOff:"자동 모드 끔 — 수동 시작/중지만 가능",notConfigured:"설정되지 않음",setUp:"텔레그램 브릿지 설정",running:"실행 중",stopped:"중지됨",stop:"중지",stopping:"중지 중…",start:"시작",starting:"시작 중…",howToSetUp:"설정 방법",editCredentials:"인증 정보 수정",dismiss:"닫기",batchActive:"배치 실행 중 — 브릿지를 자동 시작합니다.",batchComplete:"배치 완료 — 브릿지를 일시 중단했습니다. 다음 배치를 기다리는 중.",newBatch:"새 배치 감지 — 브릿지를 자동 시작합니다."}};async function ru(e,t){let n=await fetch(`/api/telegram?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json();if(!n.ok||!1===r.ok)throw Error(r.error||`${n.status}`);return r}function rd({projectId:e}){let{locale:r}=(0,o.useLocale)(),i=rc[r],[a,s]=(0,n.useState)(null),[c,u]=(0,n.useState)(!1),[d,p]=(0,n.useState)(null),[h,f]=(0,n.useState)(null),[m,x]=(0,n.useState)(!1),[g,b]=(0,n.useState)(null),[y,v]=(0,n.useState)(!1),[w,k]=(0,n.useState)(null),j=(0,n.useRef)(y),N=(0,n.useRef)(!1);(0,n.useEffect)(()=>{j.current=y},[y]);let S=(0,n.useRef)(!1);(0,n.useEffect)(()=>{S.current=!1,v(!1),k(null)},[e]),(0,n.useEffect)(()=>{S.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(t=>{if(!t)return;let n=(t.projects||[]).find(t=>t.id===e);n?.telegram_auto&&v(!0),S.current=!0}).catch(()=>{})},[e]);let C=(0,n.useCallback)(async()=>{try{let t=await fetch(`/api/telegram?project=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`${t.status}`);let n=await t.json();s(n),f(null)}catch(e){f(e.message)}},[e]);(0,n.useEffect)(()=>{C();let e=window.setInterval(C,5e3);return()=>window.clearInterval(e)},[C]);let E=e=>{let t=Array.isArray(e?.patched_projects)?e.patched_projects:[];t.length>0?b(`Install Bridge patched ${t.length} config(s) (${t.join(", ")}) to declare [agents.tg]. Click Start to begin bridging.`):b(null)},T=async()=>{u(!0),p(null);try{if(a&&!a.bridge_installed){let e=await ru("install",{});E(e)}await ru("start",{project_id:e}),await C()}catch(e){p(e.message)}finally{u(!1)}},I=async()=>{u(!0),p(null);try{await ru("stop",{project_id:e}),await C()}catch(e){p(e.message)}finally{u(!1)}},A=async(t,n)=>{await ru("save-config",{project_id:e,bot_token:t,chat_id:n});try{if(a&&!a.bridge_installed){let e=await ru("install",{});E(e)}await ru("start",{project_id:e})}catch(e){p(e.message)}await C()},R=(0,n.useCallback)(async()=>{let t=!y;v(t),t||(k(null),O.current=null);try{let n=await fetch("/api/config");if(!n.ok)return;let r=await n.json(),l=(r.projects||[]).find(t=>t.id===e);l&&(l.telegram_auto=t,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}))}catch{}},[y,e]),O=(0,n.useRef)(null),P=(0,n.useCallback)(async()=>{if(j.current)try{let t=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!t.ok)return;let n=await t.json(),r=n.items.length>0,l=O.current;if(O.current={complete:n.complete,hasItems:r},!l){!r||n.complete||N.current||(k(i.batchActive),await ru("start",{project_id:e}).catch(()=>{}),await C()),r&&n.complete&&N.current&&(k(i.batchComplete),p(null),await ru("stop",{project_id:e}).catch(()=>{}),await C());return}if(r&&n.complete&&!l.complete&&N.current){k(i.batchComplete),p(null),await ru("stop",{project_id:e}).catch(()=>{}),await C();return}!r||n.complete||!l.complete&&l.hasItems||N.current||(k(i.newBatch),await ru("start",{project_id:e}).catch(()=>{}),await C())}catch{}},[e,C,i]);(0,n.useEffect)(()=>{if(!y)return;P();let e=window.setInterval(P,3e4);return()=>window.clearInterval(e)},[y,P]);let M=!!a?.configured,F=!!a?.running;(0,n.useEffect)(()=>{N.current=F},[F]);let L=!F&&!!w,D=d||h||!F&&!L&&a?.last_error||"";return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:i.title}),(0,t.jsx)(l.default,{children:i.tooltip})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[M&&(0,t.jsxs)("button",{type:"button",onClick:R,title:y?i.autoOn:i.autoOff,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${y?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",y?"●":"○"]}),D&&(0,t.jsx)("span",{className:"text-[10px] text-error",children:"error"})]})]}),(0,t.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[M?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,t.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,t.jsx)("span",{className:"text-accent",children:i.running})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,t.jsx)("span",{className:"text-text-muted",children:i.stopped})]}),a?.bot_username&&(0,t.jsxs)("span",{className:"text-text-muted",children:["· Bot: @",a.bot_username]}),a?.chat_id&&(0,t.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Chat: ",a.chat_id]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[F?(0,t.jsx)("button",{onClick:I,disabled:c,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:c?i.stopping:i.stop}):(0,t.jsx)("button",{onClick:T,disabled:c,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:c?i.starting:i.start}),(0,t.jsx)("button",{onClick:()=>x(!0),disabled:c,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:i.howToSetUp}),(0,t.jsx)("button",{onClick:()=>x(!0),disabled:c,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:i.editCredentials})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,t.jsx)("span",{children:i.notConfigured})]}),(0,t.jsx)("button",{onClick:()=>x(!0),disabled:c,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:i.setUp})]}),g&&(0,t.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[g,(0,t.jsx)("button",{type:"button",onClick:()=>b(null),className:"block mt-1 text-text-muted hover:text-text underline",children:i.dismiss})]}),w&&(0,t.jsx)("div",{className:"mt-1 text-[10px] text-accent",children:w}),D&&(0,t.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[D,d&&(0,t.jsx)("button",{type:"button",onClick:()=>p(null),className:"block mt-1 text-text-muted hover:text-text underline",children:i.dismiss})]})]})]}),(0,t.jsx)(rs,{open:m,initialChatId:a?.chat_id||"",onClose:()=>x(!1),onSave:A})]})}function rp({open:e,initialChannelId:r="",onClose:l,onSave:i}){let[o,a]=(0,n.useState)(""),[s,c]=(0,n.useState)(r),[u,d]=(0,n.useState)(!1),[p,h]=(0,n.useState)(null),[f,m]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{e&&c(r)},[e,r]),(0,n.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,l]),!e)return null;let x=async()=>{d(!0),h(null);try{await i(o.trim(),s.trim()),l()}catch(e){h(e.message||"Save failed")}finally{d(!1)}};return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:l,role:"dialog","aria-modal":"true","aria-labelledby":"discord-setup-title",children:(0,t.jsxs)("div",{className:"relative mx-4 max-w-xl w-full max-h-[90vh] overflow-auto rounded-lg border border-white/10 bg-neutral-950 p-6 shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("button",{type:"button",onClick:l,"aria-label":"Close",className:"absolute right-3 top-3 rounded p-1 text-neutral-400 hover:bg-white/5 hover:text-white",children:(0,t.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:(0,t.jsx)("path",{d:"M4 4l12 12M16 4L4 16",strokeLinecap:"round"})})}),(0,t.jsx)("h2",{id:"discord-setup-title",className:"text-base font-semibold text-white",children:"Set up your Discord Bridge"}),(0,t.jsx)("p",{className:"mt-2 text-[12px] leading-relaxed text-neutral-300",children:"The bridge forwards project chat messages to a Discord channel, so you can read and reply from Discord."}),(0,t.jsxs)("div",{className:"mt-4 text-[12px] text-neutral-300 space-y-3",children:[(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 1 — Create a Discord Application + Bot"}),(0,t.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,t.jsxs)("li",{children:["Go to the ",(0,t.jsx)("a",{href:"https://discord.com/developers/applications",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Discord Developer Portal"}),"."]}),(0,t.jsxs)("li",{children:["Click ",(0,t.jsx)("b",{children:"New Application"}),' → name it (e.g. "QuadWork") → ',(0,t.jsx)("b",{children:"Create"}),"."]}),(0,t.jsxs)("li",{children:["Go to the ",(0,t.jsx)("b",{children:"Bot"})," tab in the left sidebar."]}),(0,t.jsxs)("li",{children:["Click ",(0,t.jsx)("b",{children:"Reset Token"})," → copy the bot token. Save it somewhere safe."]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 2 — Enable MESSAGE_CONTENT intent (critical)"}),(0,t.jsxs)("div",{className:"mt-1.5 rounded border border-amber-500/40 bg-amber-500/5 p-3",children:[(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)("span",{className:"text-amber-400 text-[16px] leading-none shrink-0",children:"⚠"}),(0,t.jsxs)("div",{className:"text-[12px] text-amber-200/90 leading-relaxed",children:[(0,t.jsx)("b",{className:"text-amber-300",children:"This step is required."}),"Without it, the bot connects successfully but receives empty message content — no error, no warning, just silent empty messages. This is the #1 cause of Discord bot setup issues."]})]}),(0,t.jsxs)("ol",{className:"mt-2 pl-6 list-decimal space-y-0.5 text-neutral-300 text-[12px]",children:[(0,t.jsxs)("li",{children:["On the same ",(0,t.jsx)("b",{children:"Bot"})," tab, scroll down to ",(0,t.jsx)("b",{children:"Privileged Gateway Intents"}),"."]}),(0,t.jsxs)("li",{children:["Toggle ",(0,t.jsx)("b",{children:"ON"}),": ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"MESSAGE CONTENT INTENT"}),"."]}),(0,t.jsxs)("li",{children:["Click ",(0,t.jsx)("b",{children:"Save Changes"}),"."]})]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 3 — Invite the bot to your server"}),(0,t.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,t.jsxs)("li",{children:["Go to the ",(0,t.jsx)("b",{children:"OAuth2"})," tab → ",(0,t.jsx)("b",{children:"URL Generator"}),"."]}),(0,t.jsxs)("li",{children:["Under ",(0,t.jsx)("b",{children:"Scopes"}),", check ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"bot"}),"."]}),(0,t.jsxs)("li",{children:["Under ",(0,t.jsx)("b",{children:"Bot Permissions"}),", check:",(0,t.jsxs)("ul",{className:"mt-0.5 pl-4 list-disc text-neutral-400",children:[(0,t.jsx)("li",{children:(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Send Messages"})}),(0,t.jsx)("li",{children:(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"Read Message History"})}),(0,t.jsx)("li",{children:(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"View Channels"})})]})]}),(0,t.jsxs)("li",{children:["Copy the generated URL at the bottom. It will look like:",(0,t.jsx)("pre",{className:"mt-1 p-2 bg-white/5 rounded text-[11px] text-neutral-200 overflow-auto",children:"https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&permissions=66560&scope=bot"})]}),(0,t.jsxs)("li",{children:["Open it in your browser → select your Discord server → ",(0,t.jsx)("b",{children:"Authorize"}),"."]})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 4 — Get your channel ID"}),(0,t.jsxs)("ol",{className:"mt-1 pl-4 list-decimal space-y-0.5 text-neutral-300",children:[(0,t.jsxs)("li",{children:["In Discord, go to ",(0,t.jsx)("b",{children:"User Settings"})," → ",(0,t.jsx)("b",{children:"Advanced"})," → enable ",(0,t.jsx)("b",{children:"Developer Mode"}),"."]}),(0,t.jsxs)("li",{children:["Right-click the channel you want to bridge → ",(0,t.jsx)("b",{children:"Copy Channel ID"}),"."]})]}),(0,t.jsxs)("p",{className:"mt-1 text-[11px] text-neutral-500",children:["Channel IDs are large numbers like ",(0,t.jsx)("code",{className:"bg-white/5 px-1 rounded text-[11px]",children:"1234567890123456789"}),"."]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"text-[13px] font-semibold text-white",children:"Step 5 — Paste credentials below"}),(0,t.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,t.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Bot token",(0,t.jsx)("input",{type:"password",value:o,onChange:e=>a(e.target.value),placeholder:"MTIzNDU2Nzg5MDEyMzQ1Njc4OQ...",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),(0,t.jsxs)("label",{className:"text-[11px] text-neutral-400",children:["Channel ID",(0,t.jsx)("input",{type:"text",value:s,onChange:e=>c(e.target.value),placeholder:"1234567890123456789",className:"mt-0.5 w-full bg-transparent border border-white/10 px-2 py-1 text-[12px] text-white outline-none focus:border-accent font-mono"})]}),p&&(0,t.jsx)("div",{className:"text-[11px] text-error",children:p}),(0,t.jsx)("button",{type:"button",onClick:x,disabled:u||!o.trim()||!s.trim(),className:"mt-1 self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:u?"Saving…":"Save and start bridge"})]})]}),(0,t.jsxs)("section",{children:[(0,t.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"text-[11px] text-accent hover:underline","aria-expanded":f,children:f?"Hide troubleshooting ▾":"Troubleshooting ▸"}),f&&(0,t.jsxs)("div",{className:"mt-2 p-2 border border-white/10 rounded text-[11px] text-neutral-300 space-y-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{className:"text-white",children:"Bot connects but messages are empty."})," ","MESSAGE_CONTENT intent is not enabled. Go back to Step 2 — toggle it on in the Developer Portal under Bot → Privileged Gateway Intents, then restart the bridge."]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{className:"text-white",children:"Bot can't see the channel."})," ","The bot wasn't invited to the server (Step 3) or it lacks the ",(0,t.jsx)("code",{className:"bg-white/5 px-0.5 rounded",children:"View Channels"}),"permission for that specific channel. Check your server's role permissions."]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{className:"text-white",children:'"Disallowed intents" error in logs.'})," ","MESSAGE_CONTENT intent is not toggled in the Developer Portal. This is different from not requesting it in code — the portal toggle is the gatekeeper."]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("b",{className:"text-white",children:"Rate limited."})," ","Normal for high-traffic channels. The Node bridge handles backoff automatically. If persistent, check the bridge logs for repeated 429 responses."]})]})]})]})]})})}let rh={en:{title:"Discord Bridge",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Discord Bridge"})," forwards project chat messages to a Discord channel so you can monitor from Discord. Bidirectional — replies from Discord appear in chat."]}),autoOn:"Auto ON — bridge follows batch lifecycle",autoOff:"Auto OFF — manual start/stop only",notConfigured:"Not configured",setUp:"Set up Discord Bridge",running:"Running",stopped:"Stopped",stop:"Stop",stopping:"Stopping…",start:"Start",starting:"Starting…",howToSetUp:"How to set up",editCredentials:"Edit credentials",dismiss:"dismiss",batchActive:"Batch active — auto-starting bridge.",batchComplete:"Batch complete — bridge paused. Waiting for next batch.",newBatch:"New batch detected — auto-starting bridge."},ko:{title:"디스코드 브릿지",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"디스코드 브릿지"})," - 프로젝트 채팅 메시지를 디스코드 채널로 전달해서 디스코드에서 모니터링할 수 있게 합니다. 양방향이며 디스코드에서 보낸 답장도 채팅에 나타납니다."]}),autoOn:"자동 모드 켬 — 브릿지가 배치 주기를 따릅니다",autoOff:"자동 모드 끔 — 수동 시작/중지만 가능",notConfigured:"설정되지 않음",setUp:"디스코드 브릿지 설정",running:"실행 중",stopped:"중지됨",stop:"중지",stopping:"중지 중…",start:"시작",starting:"시작 중…",howToSetUp:"설정 방법",editCredentials:"인증 정보 수정",dismiss:"닫기",batchActive:"배치 실행 중 — 브릿지를 자동 시작합니다.",batchComplete:"배치 완료 — 브릿지를 일시 중단했습니다. 다음 배치를 기다리는 중.",newBatch:"새 배치 감지 — 브릿지를 자동 시작합니다."}};async function rf(e,t){let n=await fetch(`/api/discord?action=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json();if(!n.ok||!1===r.ok)throw Error(r.error||`${n.status}`);return r}function rm({projectId:e}){let{locale:r}=(0,o.useLocale)(),i=rh[r],[a,s]=(0,n.useState)(null),[c,u]=(0,n.useState)(!1),[d,p]=(0,n.useState)(null),[h,f]=(0,n.useState)(null),[m,x]=(0,n.useState)(!1),[g,b]=(0,n.useState)(null),[y,v]=(0,n.useState)(!1),[w,k]=(0,n.useState)(null),j=(0,n.useRef)(null),N=(0,n.useRef)(y),S=(0,n.useRef)(!1);(0,n.useEffect)(()=>{N.current=y},[y]);let C=(0,n.useRef)(!1);(0,n.useEffect)(()=>{C.current=!1,j.current=null,v(!1),k(null)},[e]),(0,n.useEffect)(()=>{C.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(t=>{if(!t)return;let n=(t.projects||[]).find(t=>t.id===e);n?.discord_auto&&v(!0),C.current=!0}).catch(()=>{})},[e]);let E=(0,n.useCallback)(async()=>{try{let t=await fetch(`/api/discord?project=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`${t.status}`);let n=await t.json();s(n),f(null)}catch(e){f(e.message)}},[e]);(0,n.useEffect)(()=>{E();let e=window.setInterval(E,5e3);return()=>window.clearInterval(e)},[E]);let T=e=>{let t=Array.isArray(e?.patched_projects)?e.patched_projects:[];t.length>0?b(`Install Bridge patched ${t.length} config(s) (${t.join(", ")}) to declare [agents.dc]. Click Start to begin bridging.`):b(null)},I=async()=>{u(!0),p(null);try{if(a&&!a.bridge_installed){let e=await rf("install",{});T(e)}await rf("start",{project_id:e}),await E()}catch(e){p(e.message)}finally{u(!1)}},A=async()=>{u(!0),p(null);try{await rf("stop",{project_id:e}),await E()}catch(e){p(e.message)}finally{u(!1)}},R=async(t,n)=>{await rf("save-config",{project_id:e,bot_token:t,channel_id:n});try{if(a&&!a.bridge_installed){let e=await rf("install",{});T(e)}await rf("start",{project_id:e})}catch(e){p(e.message)}await E()},O=(0,n.useCallback)(async()=>{let t=!y;v(t),t||(k(null),j.current=null);try{let n=await fetch("/api/config");if(!n.ok)return;let r=await n.json(),l=(r.projects||[]).find(t=>t.id===e);l&&(l.discord_auto=t,await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}))}catch{}},[y,e]),P=(0,n.useCallback)(async()=>{if(N.current)try{let t=await fetch(`/api/batch-progress?project=${encodeURIComponent(e)}`);if(!t.ok)return;let n=await t.json(),r=n.items.length>0,l=j.current;if(j.current={complete:n.complete,hasItems:r},!l){!r||n.complete||S.current||(k(i.batchActive),await rf("start",{project_id:e}).catch(()=>{}),await E()),r&&n.complete&&S.current&&(k(i.batchComplete),p(null),await rf("stop",{project_id:e}).catch(()=>{}),await E());return}if(r&&n.complete&&!l.complete&&S.current){k(i.batchComplete),p(null),await rf("stop",{project_id:e}).catch(()=>{}),await E();return}!r||n.complete||!l.complete&&l.hasItems||S.current||(k(i.newBatch),await rf("start",{project_id:e}).catch(()=>{}),await E())}catch{}},[e,E,i]);(0,n.useEffect)(()=>{if(!y)return;P();let e=window.setInterval(P,3e4);return()=>window.clearInterval(e)},[y,P]);let M=!!a?.configured,F=!!a?.running;(0,n.useEffect)(()=>{S.current=F},[F]);let L=!F&&!!w,D=d||h||!F&&!L&&a?.last_error||"";return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col border border-border",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between h-7 px-3 shrink-0 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wider",children:i.title}),(0,t.jsx)(l.default,{children:i.tooltip})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[M&&(0,t.jsxs)("button",{type:"button",onClick:O,title:y?i.autoOn:i.autoOff,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${y?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:["Auto ",y?"●":"○"]}),D&&(0,t.jsx)("span",{className:"text-[10px] text-error",children:"error"})]})]}),(0,t.jsxs)("div",{className:"p-3 flex flex-col gap-2",children:[M?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[11px] flex-wrap",children:[F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"relative inline-flex items-center justify-center w-2 h-2",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-accent opacity-60 animate-ping"}),(0,t.jsx)("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),(0,t.jsx)("span",{className:"text-accent",children:i.running})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,t.jsx)("span",{className:"text-text-muted",children:i.stopped})]}),a?.bot_username&&(0,t.jsxs)("span",{className:"text-text-muted",children:["· Bot: ",a.bot_username]}),a?.channel_id&&(0,t.jsxs)("span",{className:"text-text-muted tabular-nums",children:["· Channel: ",a.channel_id]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[F?(0,t.jsx)("button",{onClick:A,disabled:c,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-error hover:border-error/40 disabled:opacity-50 transition-colors",children:c?i.stopping:i.stop}):(0,t.jsx)("button",{onClick:I,disabled:c,className:"px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:c?i.starting:i.start}),(0,t.jsx)("button",{onClick:()=>x(!0),disabled:c,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:i.howToSetUp}),(0,t.jsx)("button",{onClick:()=>x(!0),disabled:c,className:"px-3 py-1 text-[11px] text-text-muted border border-border hover:text-text disabled:opacity-50 transition-colors",children:i.editCredentials})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted"}),(0,t.jsx)("span",{children:i.notConfigured})]}),(0,t.jsx)("button",{onClick:()=>x(!0),disabled:c,className:"self-start px-3 py-1 text-[11px] font-semibold text-bg bg-accent hover:bg-accent-dim disabled:opacity-50 transition-colors",children:i.setUp})]}),g&&(0,t.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-accent border border-accent/40 bg-accent/5 whitespace-pre-wrap break-words",children:[g,(0,t.jsx)("button",{type:"button",onClick:()=>b(null),className:"block mt-1 text-text-muted hover:text-text underline",children:i.dismiss})]}),w&&(0,t.jsx)("div",{className:"mt-1 text-[10px] text-accent",children:w}),D&&(0,t.jsxs)("div",{className:"mt-1 p-2 text-[10px] text-error border border-error/40 bg-error/5 font-mono whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:[D,d&&(0,t.jsx)("button",{type:"button",onClick:()=>p(null),className:"block mt-1 text-text-muted hover:text-text underline",children:i.dismiss})]})]})]}),(0,t.jsx)(rp,{open:m,initialChannelId:a?.channel_id||"",onClose:()=>x(!1),onSave:R})]})}let rx={en:{title:"Loop Guard",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Loop Guard"})," pauses agent-to-agent message chains after this many hops with no human reply. Higher values let agents work longer overnight; lower values add safety against runaway loops. Accepts ",(0,t.jsx)("b",{children:"4–50"}),"; QuadWork defaults to ",(0,t.jsx)("b",{children:"30"})," (about 5–6 full PR cycles). Posting any chat message yourself resets the counter immediately."]}),pauseAfter:"Pause after",hops:"hops",apply:"Apply",applying:"…",applyTitle:"Apply (saves to project config)",errorInteger:"Must be an integer between 4 and 50.",liveUpdateFailed:"Saved — live update failed; takes effect on next restart.",autoContinue:"Auto-continue after pause",wait:"— wait",secondsBefore:"s before /continue"},ko:{title:"루프 가드",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"루프 가드"})," - 사람의 응답 없이 에이전트끼리 메시지를 주고받는 횟수가 이 값에 도달하면 체인을 멈춥니다. 값을 높이면 야간 작업을 더 길게 돌릴 수 있고, 낮추면 runaway loop에 대한 안전성이 높아집니다. 허용 범위는 ",(0,t.jsx)("b",{children:"4-50"}),"이며 QuadWork 기본값은 ",(0,t.jsx)("b",{children:"30"}),"입니다. 직접 채팅을 한 번 보내면 카운터는 즉시 초기화됩니다."]}),pauseAfter:"다음 횟수 후 일시정지:",hops:"홉",apply:"적용",applying:"…",applyTitle:"적용 (프로젝트 설정에 저장)",errorInteger:"4에서 50 사이의 정수여야 합니다.",liveUpdateFailed:"저장되었습니다. 실시간 업데이트는 실패하여 다음 재시작 때 적용됩니다.",autoContinue:"일시정지 후 자동 재개",wait:"—",secondsBefore:"초 대기 후 /continue"}};function rg({projectId:e}){let{locale:r}=(0,o.useLocale)(),i=rx[r],[a,s]=(0,n.useState)(30),[c,u]=(0,n.useState)("30"),[d,p]=(0,n.useState)(!1),[h,f]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),[g,b]=(0,n.useState)(!1),[y,v]=(0,n.useState)(30),[w,k]=(0,n.useState)("30"),[j,N]=(0,n.useState)(!1);(0,n.useEffect)(()=>{fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&"number"==typeof e.value&&(s(e.value),u(String(e.value)))}).catch(()=>{}),fetch("/api/config").then(e=>e.ok?e.json():null).then(t=>{if(!t||!Array.isArray(t.projects))return;let n=t.projects.find(t=>t.id===e);if(!n)return;b(!!n.auto_continue_loop_guard);let r=Number.isFinite(n.auto_continue_delay_sec)?n.auto_continue_delay_sec:30;v(r),k(String(r))}).catch(()=>{})},[e]);let S=async(t,n)=>{N(!0);try{let r=await fetch("/api/config");if(!r.ok)throw Error(`GET /api/config ${r.status}`);let l=await r.json();if(!l||!Array.isArray(l.projects))throw Error("config shape");let i=l.projects.findIndex(t=>t.id===e);if(i<0)throw Error(`project ${e} not found`);l.projects[i]={...l.projects[i],auto_continue_loop_guard:t,auto_continue_delay_sec:n};let o=await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!o.ok)throw Error(`PUT /api/config ${o.status}`)}finally{N(!1)}};return(0,t.jsxs)("div",{className:"border border-border rounded p-2 text-[11px] font-mono",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,t.jsx)("span",{className:"uppercase tracking-wider text-text-muted",children:i.title}),(0,t.jsx)(l.default,{children:i.tooltip})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-text-muted",children:i.pauseAfter}),(0,t.jsx)("input",{type:"number",min:4,max:50,value:c,onChange:e=>u(e.target.value),disabled:d,className:"w-12 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent"}),(0,t.jsx)("span",{className:"text-text-muted",children:i.hops}),(0,t.jsx)("button",{type:"button",onClick:()=>{let t=parseInt(c,10);!Number.isInteger(t)||t<4||t>50?f(i.errorInteger):(p(!0),f(null),fetch(`/api/loop-guard?project=${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:t})}).then(async e=>{if(!e.ok){let t=await e.text().catch(()=>"");throw Error(`${e.status}: ${t.slice(0,120)}`)}return e.json()}).then(e=>{s(e.value),x(e.live)}).catch(e=>f(e.message||String(e))).finally(()=>p(!1)))},disabled:d||c===String(a),className:"ml-auto px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:i.applyTitle,children:d?i.applying:i.apply})]}),h&&(0,t.jsx)("div",{className:"mt-1 text-[10px] text-red-400",children:h}),!1===m&&!h&&(0,t.jsx)("div",{className:"mt-1 text-[10px] text-text-muted",children:i.liveUpdateFailed}),(0,t.jsxs)("label",{className:"mt-2 flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer select-none",children:[(0,t.jsx)("input",{type:"checkbox",checked:g,disabled:j,onChange:e=>{let t=e.target.checked;b(t),S(t,y).catch(()=>{b(!t)})}}),i.autoContinue,(0,t.jsx)("span",{className:"text-text-muted",children:i.wait}),(0,t.jsx)("input",{type:"number",min:5,max:300,value:w,disabled:j||!g,onChange:e=>k(e.target.value),onBlur:()=>{let e=parseInt(w,10),t=Number.isFinite(e)?Math.max(5,Math.min(300,e)):30;v(t),k(String(t)),t!==y&&S(g,t).catch(()=>{})},className:"w-10 bg-transparent px-1 py-0.5 border border-border rounded text-text outline-none focus:ring-1 focus:ring-accent disabled:opacity-40 text-center"}),(0,t.jsx)("span",{className:"text-text-muted",children:i.secondsBefore})]})]})}let rb={en:{title:"Project History",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Project History"})," — export or import the full chat history for this project. Useful for backup, migration, or resuming after a fresh install."]}),export:e=>`Export ${e} chat`,import:"Import history…",importing:"Importing…",autoSnapshots:"Auto-snapshots (before restart)",restore:"Restore",restoreConfirm:e=>`Restore snapshot ${e}? This will replay every message (tagged by the original sender) and may duplicate history already in the chat. Continue?`,importMismatchConfirm:(e,t)=>`This export is from project '${e}' but you're importing into '${t}'. Continue anyway?`,importReservedConfirm:e=>`This export contains messages attributed to reserved agent/system identities (${e}). Importing will replay them as those agents — only do this for a legitimate disaster-recovery restore. Continue?`,importDuplicateConfirm:e=>`${e}
13
+
14
+ This file looks like it was already imported. Re-import will duplicate every message. Continue anyway?`,importStatus:(e,n,r,l)=>(0,t.jsxs)(t.Fragment,{children:["Imported ",e," / ",n,r>0&&` \xb7 skipped ${r}`,l>0&&` \xb7 ${l} errors`]})},ko:{title:"프로젝트 히스토리",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"프로젝트 히스토리"})," - 이 프로젝트의 전체 채팅 기록을 내보내거나 가져옵니다. 백업, 마이그레이션, 재설치 후 복구에 유용합니다."]}),export:e=>`${e} 채팅 내보내기`,import:"히스토리 가져오기…",importing:"가져오는 중…",autoSnapshots:"자동 스냅샷 (재시작 전)",restore:"복구",restoreConfirm:e=>`스냅샷 ${e}을(를) 복구할까요? 모든 메시지가 재생되며(원본 발신자 표시), 채팅에 이미 있는 내용이 중복될 수 있습니다. 계속하시겠습니까?`,importMismatchConfirm:(e,t)=>`이 내보내기 파일은 '${e}' 프로젝트에서 생성되었지만, 현재 '${t}' 프로젝트로 가져오려 합니다. 계속하시겠습니까?`,importReservedConfirm:e=>`이 파일에는 예약된 에이전트/시스템 식별자(${e})가 발신자로 표시된 메시지가 포함되어 있습니다. 가져오기를 진행하면 해당 에이전트가 말하는 것처럼 메시지가 재생됩니다. 재난 복구 상황에서만 사용하세요. 계속하시겠습니까?`,importDuplicateConfirm:e=>`${e}
15
+
16
+ 이 파일은 이미 가져온 것 같습니다. 다시 가져오면 모든 메시지가 중복됩니다. 계속하시겠습니까?`,importStatus:(e,n,r,l)=>(0,t.jsxs)(t.Fragment,{children:["가져옴: ",e," / ",n,r>0&&` \xb7 건너뜀 ${r}`,l>0&&` \xb7 오류 ${l}`]})}};function ry({projectId:e}){let{locale:r}=(0,o.useLocale)(),i=rb[r],a=(0,n.useRef)(null),[s,c]=(0,n.useState)(null),[u,d]=(0,n.useState)(null),[p,h]=(0,n.useState)(null),[f,m]=(0,n.useState)([]),x=()=>{fetch(`/api/project-history/snapshots?project=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(e=>{e&&Array.isArray(e.snapshots)&&m(e.snapshots)}).catch(()=>{})};(0,n.useEffect)(()=>{x();let e=setInterval(x,15e3);return()=>clearInterval(e)},[e]);let g=async t=>{if(window.confirm(i.restoreConfirm(t))){c("restore"),d(null),h(null);try{let n=await fetch(`/api/project-history/restore?project=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,{method:"POST"}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r&&r.error||`HTTP ${n.status}`);r&&"number"==typeof r.imported&&h(r)}catch(e){d(e.message||String(e))}finally{c(null),x()}}},b=async()=>{c("export"),d(null),h(null);try{let t=await fetch(`/api/project-history?project=${encodeURIComponent(e)}`);if(!t.ok){let e=await t.text().catch(()=>"");throw Error(`HTTP ${t.status}: ${e.slice(0,200)}`)}let n=await t.blob(),r=URL.createObjectURL(n),l=document.createElement("a"),i=new Date().toISOString().slice(0,10);l.href=r,l.download=`${e}-history-${i}.json`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}catch(e){d(e.message||String(e))}finally{c(null)}},y=async t=>{let n;if(t.size>0xa00000)return void d(`File too large (${t.size} bytes; limit 10485760)`);c("import"),d(null),h(null);try{let e=await t.text();n=JSON.parse(e)}catch(e){c(null),d(`Invalid JSON: ${e.message||String(e)}`);return}if(!n||"object"!=typeof n||!Array.isArray(n.messages)){c(null),d("File missing 'messages' array");return}let r=!1;if(n.project_id&&n.project_id!==e){if(!window.confirm(i.importMismatchConfirm(n.project_id,e)))return void c(null);r=!0}let l=new Set(["head","dev","reviewer1","reviewer2","re1","re2","t1","t2a","t2b","t3","system"]),o=!1,s=new Set;for(let e of n.messages)if(e&&"object"==typeof e){let t=e.sender;if("string"==typeof t&&l.has(t.toLowerCase())&&(s.add(t),s.size>=5))break}if(s.size>0){if(!window.confirm(i.importReservedConfirm([...s].join(", "))))return void c(null);o=!0}let u=!1,p=t=>fetch(`/api/project-history?project=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,allow_project_mismatch:r,allow_agent_senders:o,allow_duplicate:u,...t})});try{let e=await p({}),t=await e.json().catch(()=>null);if(409===e.status&&t&&"string"==typeof t.error&&/already imported/i.test(t.error)){if(!window.confirm(i.importDuplicateConfirm(t.error)))return void c(null);u=!0,e=await p({allow_duplicate:!0}),t=await e.json().catch(()=>null)}if(!e.ok)throw Error(t&&t.error||`HTTP ${e.status}`);h(t)}catch(e){d(e.message||String(e))}finally{c(null),a.current&&(a.current.value="")}};return(0,t.jsxs)("div",{className:"border border-border rounded p-2 text-[11px] font-mono",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted uppercase tracking-wider mb-1.5",children:[i.title,(0,t.jsx)(l.default,{children:i.tooltip})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("button",{type:"button",onClick:b,disabled:null!==s,className:"px-2 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Download a JSON snapshot of this project's chat history",children:"export"===s?"…":i.export(e)}),(0,t.jsx)("button",{type:"button",onClick:()=>{d(null),h(null),a.current?.click()},disabled:null!==s,className:"px-2 py-0.5 text-[10px] text-text-muted border border-border rounded hover:text-text hover:border-accent transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:"Restore a previously exported chat history (JSON)",children:"import"===s?i.importing:i.import}),(0,t.jsx)("input",{ref:a,type:"file",accept:"application/json,.json",className:"hidden",onChange:e=>{let t=e.target.files&&e.target.files[0];t&&y(t)}})]}),u&&(0,t.jsx)("div",{className:"mt-1 text-[10px] text-red-400",children:u}),p&&(0,t.jsx)("div",{className:"mt-1 text-[10px] text-text-muted",children:i.importStatus(p.imported,p.total,p.skipped,p.errors.length)}),f.length>0&&(0,t.jsxs)("div",{className:"mt-2 border-t border-border/50 pt-1.5",children:[(0,t.jsx)("div",{className:"text-[9px] text-text-muted uppercase tracking-wider mb-0.5",children:i.autoSnapshots}),f.map(e=>{let n=new Date(e.mtime).toLocaleString();return(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] py-0.5",children:[(0,t.jsx)("span",{className:"text-text-muted tabular-nums flex-1 truncate",title:e.name,children:n}),(0,t.jsxs)("span",{className:"text-text-muted tabular-nums shrink-0",children:[Math.round(e.size/1024),"KB"]}),(0,t.jsx)("button",{type:"button",onClick:()=>g(e.name),disabled:null!==s,className:"px-1.5 py-0.5 text-[10px] text-accent border border-accent/40 rounded hover:bg-accent/10 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:`Restore ${e.name}`,children:"restore"===s?"…":i.restore})]},e.name)})]})]})}var rv=e.i(76234);let rw={en:{label:"Operator Features",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Operator Features"})," — tools for running autonomous overnight batches. Includes the Scheduled Trigger, Telegram Bridge, Discord Bridge, Loop Guard, Project History, and Agent Models."]})},ko:{label:"운영자 기능",tooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"운영자 기능"})," - 야간 자율 배치를 운영할 때 쓰는 도구 모음입니다. Scheduled Trigger, Telegram Bridge, Discord Bridge, Loop Guard, Project History, Agent Models가 포함됩니다."]})}};function rk({projectId:e}){let{locale:n}=(0,o.useLocale)(),i=rw[n];return(0,t.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,t.jsx)(r,{label:i.label,tooltip:(0,t.jsx)(l.default,{children:i.tooltip})}),(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col lg:flex-row gap-2 p-2 overflow-auto lg:overflow-hidden",children:[(0,t.jsx)("div",{className:"lg:flex-1 lg:min-w-[280px] lg:min-h-0",children:(0,t.jsx)(ra,{projectId:e})}),(0,t.jsx)("div",{className:"hidden lg:block w-px self-stretch bg-border"}),(0,t.jsxs)("div",{className:"lg:flex-1 lg:min-h-0 lg:overflow-y-auto flex flex-col gap-2",children:[(0,t.jsx)(rv.default,{projectId:e}),(0,t.jsx)(rd,{projectId:e}),(0,t.jsx)(rm,{projectId:e}),(0,t.jsx)(rg,{projectId:e}),(0,t.jsx)(ry,{projectId:e})]})]})]})}let rj={en:{filterAgentsTitle:"Showing agent messages only — click to show all",filterAllTitle:"Showing all messages — click to hide system/status noise",filterOn:"Filter system log: on",filterOff:"Filter system log: off",chatLabel:"Agent Primary Chat",chatTooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"Primary Chat"})," — live chat between you and the 4 AI agents. Messages you type here trigger agent actions. Use @mentions to address specific agents."]}),githubLabel:"GitHub",githubTooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"GitHub"}),"— open issues and pull requests on this project's repo. Click any item to open it on GitHub. The batch progress panel tracks the active batch's lifecycle from queued to merged."]})},ko:{filterAgentsTitle:"에이전트 메시지만 표시 중 - 클릭하면 전체를 표시합니다",filterAllTitle:"전체 메시지 표시 중 - 클릭하면 시스템/상태 로그를 숨깁니다",filterOn:"시스템 로그 필터: 켜짐",filterOff:"시스템 로그 필터: 꺼짐",chatLabel:"에이전트 메인 채팅",chatTooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"메인 채팅"})," - 당신과 4개의 AI 에이전트가 실시간으로 대화하는 공간입니다. 여기 입력한 메시지가 에이전트 동작을 시작시킵니다. 특정 에이전트를 부를 때는 @멘션을 사용하세요."]}),githubLabel:"GitHub",githubTooltip:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:"GitHub"})," - 이 프로젝트 저장소의 열린 이슈와 PR을 보여줍니다. 항목을 클릭하면 GitHub에서 바로 열립니다. 아래 배치 진행 패널은 현재 배치가 대기에서 병합까지 어떻게 진행되는지 추적합니다."]})}};e.s(["default",0,function({projectId:e}){let{locale:i}=(0,o.useLocale)(),a=rj[i],s=(0,n.useRef)(null),[c,u]=(0,n.useState)(.5),[d,p]=(0,n.useState)(.5),h=(0,n.useRef)(null),[f,m]=(0,n.useState)({}),[x,g]=(0,n.useState)(!1),[y,v]=(0,n.useState)(!1),w=(0,n.useRef)(!1);(0,n.useEffect)(()=>{w.current=!1,v(!1)},[e]),(0,n.useEffect)(()=>{w.current||fetch("/api/config").then(e=>e.ok?e.json():null).then(t=>{if(!t)return;let n=(t.projects||[]).find(t=>t.id===e);n?.bridge_filter_agents_only&&v(!0),w.current=!0}).catch(()=>{})},[e]);let k=(0,n.useCallback)(()=>{v(t=>{let n=!t;return fetch("/api/config").then(e=>e.ok?e.json():null).then(t=>{if(!t)return;let r=(t.projects||[]).find(t=>t.id===e);if(r)return r.bridge_filter_agents_only=n,fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}).catch(()=>{}),n})},[e]),j=(0,n.useMemo)(()=>(0,t.jsx)("button",{type:"button",onClick:k,title:y?a.filterAgentsTitle:a.filterAllTitle,className:`px-1.5 py-0.5 text-[10px] border transition-colors ${y?"border-accent/50 text-accent bg-accent/10 hover:bg-accent/20":"border-border text-text-muted hover:text-text hover:border-accent"}`,children:y?a.filterOn:a.filterOff}),[y,a,k]);(0,n.useEffect)(()=>{let t=()=>{fetch("/api/agents").then(e=>e.ok?e.json():{}).then(t=>{let n={};for(let[r,l]of Object.entries(t))r.startsWith(`${e}/`)&&(n[r.split("/")[1]]=l.state);m(n)}).catch(()=>{})};t();let n=setInterval(t,5e3);return()=>clearInterval(n)},[e]);let N=(0,n.useCallback)((e,t)=>Math.min((t-4-150)/t,Math.max(150/t,e)),[]);(0,n.useEffect)(()=>{let e=e=>{if(!h.current||!s.current)return;let t=s.current.getBoundingClientRect();"col"===h.current?u(N((e.clientX-t.left)/t.width,t.width)):p(N((e.clientY-t.top)/t.height,t.height))},t=()=>{h.current=null,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[N]);let S=e=>{h.current=e,document.body.style.cursor="col"===e?"col-resize":"row-resize",document.body.style.userSelect="none"},C=x?"1fr 4px auto":`${100*c}% 4px 1fr`,E=`${100*d}% 4px 1fr`;return(0,t.jsxs)("div",{ref:s,className:"w-full h-full",children:[(0,t.jsx)("style",{children:`
17
+ @media (min-width: 1024px) {
18
+ .qw-dashboard {
19
+ display: grid !important;
20
+ grid-template-columns: ${C};
21
+ grid-template-rows: ${E};
22
+ overflow: hidden !important;
23
+ }
24
+ }
25
+ `}),(0,t.jsxs)("div",{className:"qw-dashboard flex flex-col w-full h-full overflow-y-auto",children:[(0,t.jsxs)("div",{className:"flex flex-col overflow-hidden border-2 border-accent h-[60vh] shrink-0 lg:h-auto lg:shrink lg:min-h-0",children:[(0,t.jsx)(r,{label:a.chatLabel,tooltip:(0,t.jsx)(l.default,{children:a.chatTooltip}),children:j}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(b,{projectId:e,filterSystem:y})}),(0,t.jsx)(n1,{projectId:e})]}),(0,t.jsx)("div",{className:"hidden lg:block bg-border cursor-col-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>S("col")}),(0,t.jsx)("div",{className:"hidden lg:flex flex-col overflow-hidden",children:(0,t.jsx)(rn,{projectId:e,agentStates:f,onStatusChange:(e,t)=>{m(n=>({...n,[e]:t}))},onCollapsedChange:g})}),(0,t.jsx)("div",{className:"hidden lg:block bg-border cursor-row-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>S("row")}),(0,t.jsx)("div",{className:"hidden lg:block bg-border cursor-move",onMouseDown:()=>S("col")}),(0,t.jsx)("div",{className:"hidden lg:block bg-border cursor-row-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>S("row")}),(0,t.jsxs)("div",{className:"flex flex-col overflow-hidden border-t border-border lg:border-t-0 min-h-[40vh] shrink-0 lg:min-h-0 lg:shrink",children:[(0,t.jsx)(r,{label:a.githubLabel,tooltip:(0,t.jsx)(l.default,{children:a.githubTooltip})}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(nJ,{projectId:e})})]}),(0,t.jsx)("div",{className:"hidden lg:block bg-border cursor-col-resize hover:bg-accent-dim transition-colors",onMouseDown:()=>S("col")}),(0,t.jsx)("div",{className:"border-t border-border lg:border-t-0 flex flex-col overflow-hidden",children:(0,t.jsx)(rk,{projectId:e})})]})]})}],55601)},73766,e=>{e.n(e.i(55601))}]);