agentbox-app 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -16
- package/bin/agentbox.mjs +18 -9
- package/briefs/message-rules.md +15 -4
- package/main/account-tooling.mjs +2 -1
- package/main/acp.mjs +296 -0
- package/main/agent-homes.mjs +158 -0
- package/main/agent-sessions.mjs +57 -20
- package/main/agent-updates.mjs +9 -20
- package/main/analytics.mjs +30 -0
- package/main/approvals.mjs +14 -5
- package/main/claude-bin.mjs +45 -310
- package/main/claude-input.mjs +9 -3
- package/main/claude-launch-env.mjs +54 -0
- package/main/claude-models.mjs +39 -7
- package/main/claude-plan.mjs +14 -2
- package/main/claude-usage.mjs +82 -25
- package/main/codex-bin.mjs +51 -248
- package/main/codex-launch-env.mjs +31 -0
- package/main/codex-session.mjs +38 -3
- package/main/codex-threads.mjs +41 -8
- package/main/codex-watch.mjs +67 -3
- package/main/config.mjs +40 -13
- package/main/corner-tag.mjs +489 -0
- package/main/crash-report.mjs +26 -3
- package/main/demo.mjs +17 -14
- package/main/engine-bin.mjs +595 -0
- package/main/engine-setup.mjs +27 -27
- package/main/feedback.mjs +11 -6
- package/main/fresh-user.mjs +1 -1
- package/main/git-change.mjs +8 -2
- package/main/harnesses/claude-stream.mjs +208 -0
- package/main/harnesses/claude.mjs +84 -0
- package/main/harnesses/codex.mjs +65 -0
- package/main/harnesses/common.mjs +78 -0
- package/main/harnesses/instructions-file.mjs +116 -0
- package/main/harnesses/opencode.mjs +234 -0
- package/main/harnesses.mjs +65 -0
- package/main/importable-threads.mjs +38 -0
- package/main/instruction-settings.mjs +47 -11
- package/main/ipc.mjs +175 -22
- package/main/local-app-frames.mjs +82 -0
- package/main/machine.mjs +1 -1
- package/main/main.mjs +120 -5
- package/main/memory-gate-history.mjs +51 -12
- package/main/memory-gate-server.mjs +67 -11
- package/main/memory-gate.mjs +49 -8
- package/main/memory-log.mjs +124 -0
- package/main/notify.mjs +48 -5
- package/main/opencode-server.mjs +271 -0
- package/main/opencode.mjs +287 -0
- package/main/phone-link.mjs +551 -0
- package/main/refresh-agent-models.mjs +2 -1
- package/main/relay-address.mjs +28 -0
- package/main/relay-client.mjs +246 -0
- package/main/row-label.mjs +8 -7
- package/main/runs-on.mjs +90 -0
- package/main/serve.mjs +124 -10
- package/main/settings.mjs +171 -11
- package/main/shell-path.mjs +86 -0
- package/main/ship-queue.mjs +25 -7
- package/main/sign-in-files.mjs +3 -7
- package/main/source-updater.mjs +27 -1
- package/main/start-hold.mjs +73 -0
- package/main/store/home.mjs +37 -5
- package/main/store/project.mjs +15 -19
- package/main/store.mjs +10 -4
- package/main/supervisor.mjs +1030 -447
- package/main/task-commands.mjs +13 -17
- package/main/task-folders-offthread.mjs +6 -1
- package/main/task-folders.mjs +491 -82
- package/main/task-terminals.mjs +49 -8
- package/main/team/index.mjs +2 -2
- package/main/team/projects.mjs +1 -1
- package/main/updater.mjs +71 -9
- package/main/worktree-include.mjs +494 -0
- package/mcp/core/page.mjs +1 -1
- package/mcp/core/work.mjs +34 -3
- package/mcp/tools.mjs +2 -1
- package/package.json +10 -1
- package/renderer/dist/assets/abnfDiagram-YUKMZFIV-DPPuMWt-.js +1 -0
- package/renderer/dist/assets/arc-HmFfdseH.js +1 -0
- package/renderer/dist/assets/architectureDiagram-47P4ROYG-DxJ3zHrH.js +36 -0
- package/renderer/dist/assets/blockDiagram-E7TT5TSB-CbTXzOqQ.js +140 -0
- package/renderer/dist/assets/c4Diagram-CRA5TL53-X5ItFyLn.js +38 -0
- package/renderer/dist/assets/channel-BlT2g9Sz.js +1 -0
- package/renderer/dist/assets/chunk-2Q5K7J3B-DC12Ho_L.js +1 -0
- package/renderer/dist/assets/chunk-5VM5RSS4-ClVtfPd0.js +15 -0
- package/renderer/dist/assets/chunk-7TKQ45FW-DgcOm0HT.js +1 -0
- package/renderer/dist/assets/chunk-AW2ZBBNX-C01s4yoF.js +88 -0
- package/renderer/dist/assets/chunk-FVRAUYC3-Bj0zxhR4.js +2 -0
- package/renderer/dist/assets/chunk-HTAEGDNF-DWDeEhLU.js +1 -0
- package/renderer/dist/assets/chunk-JWPE2WC7-Dsqwv3eW.js +1 -0
- package/renderer/dist/assets/chunk-KQW6MTUR-CE86ANL2.js +1 -0
- package/renderer/dist/assets/chunk-XXDRQBXY-CoNTASfs.js +1 -0
- package/renderer/dist/assets/classDiagram-v2-K4WV4PDN-2wprLqtw.js +217 -0
- package/renderer/dist/assets/cornerTag-BLrxiDE5.css +1 -0
- package/renderer/dist/assets/cornerTag-BOT6u3Tn.js +1 -0
- package/renderer/dist/assets/cose-bilkent-JH36ORCC-enqMiYbn.js +1 -0
- package/renderer/dist/assets/cynefin-EF2NZ3EQ-DHngLxvQ.js +141 -0
- package/renderer/dist/assets/cynefinDiagram-3GCD6N5R-C0rZZIl3.js +62 -0
- package/renderer/dist/assets/cytoscape.esm-C5JX3QLV.js +331 -0
- package/renderer/dist/assets/dagre-W4DXFKR2-DQnaEWO7.js +4 -0
- package/renderer/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/renderer/dist/assets/diagram-2UJZ2QOL-CS8AlGPx.js +200 -0
- package/renderer/dist/assets/diagram-OVF4WLC6-yiDMHIkY.js +24 -0
- package/renderer/dist/assets/diagram-PFPMY2P6-XbQKzbBA.js +30 -0
- package/renderer/dist/assets/diagram-UMYRVEAY-dhVvlfl_.js +24 -0
- package/renderer/dist/assets/diagram-YEKJPTXX-DZHe8SCf.js +41 -0
- package/renderer/dist/assets/diagram-ZIFT7M5P-B5h6aXVR.js +3 -0
- package/renderer/dist/assets/ebnfDiagram-VR2GEFS7-PR9ScDco.js +1 -0
- package/renderer/dist/assets/elk-IJKZMXRS-Cg-yQXPd.js +27 -0
- package/renderer/dist/assets/erDiagram-O2IAPWRE-omOrJMxu.js +99 -0
- package/renderer/dist/assets/flowDiagram-OXPTDLAJ-aOX2hzvT.js +213 -0
- package/renderer/dist/assets/ganttDiagram-R7TSEDQI-B1H3pWyI.js +292 -0
- package/renderer/dist/assets/gitGraphDiagram-XJZIOB7I-Cvw304HC.js +106 -0
- package/renderer/dist/assets/graph-DGbsTEsI.js +1 -0
- package/renderer/dist/assets/infoDiagram-5W2HQ5XZ-_ZXcNViH.js +2 -0
- package/renderer/dist/assets/init-Gi6I4Gst.js +1 -0
- package/renderer/dist/assets/ishikawaDiagram-K3B6WC7H-C7Mx_qQk.js +70 -0
- package/renderer/dist/assets/journeyDiagram-COXZFDF6-fr62QoAt.js +139 -0
- package/renderer/dist/assets/kanban-definition-P3RFRI5V-J8zsabCe.js +89 -0
- package/renderer/dist/assets/katex-C5jXJg4s.js +257 -0
- package/renderer/dist/assets/linear-BmNdEtIi.js +1 -0
- package/renderer/dist/assets/main-ChNdnUvt.js +1132 -0
- package/renderer/dist/assets/main-nj0QR5kg.css +32 -0
- package/renderer/dist/assets/mermaid.core-CnYzvFkz.js +314 -0
- package/renderer/dist/assets/mindmap-definition-LZFPQGKD-Bfcxc7PM.js +96 -0
- package/renderer/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/renderer/dist/assets/pegDiagram-BGZESJAR-CwUJOq6X.js +1 -0
- package/renderer/dist/assets/pieDiagram-CAPJLFHJ-BrwMmqfC.js +39 -0
- package/renderer/dist/assets/product-name-CTKLYNWY.js +40 -0
- package/renderer/dist/assets/quadrantDiagram-GDMTTRAM-BN4Stoj-.js +7 -0
- package/renderer/dist/assets/railroadDiagram-SM67HX2B-CPZ5bbeR.js +1 -0
- package/renderer/dist/assets/requirementDiagram-X7JNWC4A-CgRnimVe.js +84 -0
- package/renderer/dist/assets/sankeyDiagram-UM26HJRW-Bt2rej__.js +40 -0
- package/renderer/dist/assets/sequenceDiagram-ZO4K6R2Y-Dd5nKe9G.js +169 -0
- package/renderer/dist/assets/sizeCapture-INFHLROL-usyNyXyh.js +1 -0
- package/renderer/dist/assets/stateDiagram-v2-TBUQTH76-CRzUBb0u.js +291 -0
- package/renderer/dist/assets/swimlanes-N4OXWK64-C1GJvMS0.js +1 -0
- package/renderer/dist/assets/swimlanesDiagram-K3J5GTZL-Cy4Av2_p.js +8 -0
- package/renderer/dist/assets/timeline-definition-YOQAKGHF-caeyPlcc.js +120 -0
- package/renderer/dist/assets/usecaseDiagram-VIAY4XPW-BN_SV6PC.js +370 -0
- package/renderer/dist/assets/vennDiagram-BLWOH2XV-BLGuaUX-.js +34 -0
- package/renderer/dist/assets/wardleyDiagram-YMQ3BMBF-Da0cJeNc.js +78 -0
- package/renderer/dist/assets/xychartDiagram-TAQBALBS-cGfUffMk.js +7 -0
- package/renderer/dist/corner-tag.html +13 -0
- package/renderer/dist/emulator/audio-rules.mjs +74 -0
- package/renderer/dist/emulator/data/compression/README.md +11 -0
- package/renderer/dist/emulator/data/compression/extract7z.js +1 -0
- package/renderer/dist/emulator/data/compression/extractzip.js +1 -0
- package/renderer/dist/emulator/data/compression/libunrar.js +519 -0
- package/renderer/dist/emulator/data/compression/libunrar.wasm +0 -0
- package/renderer/dist/emulator/data/cores/README.md +22 -0
- package/renderer/dist/emulator/data/cores/mgba-legacy-wasm.data +0 -0
- package/renderer/dist/emulator/data/cores/mgba-thread-legacy-wasm.data +0 -0
- package/renderer/dist/emulator/data/cores/mgba-thread-wasm.data +0 -0
- package/renderer/dist/emulator/data/cores/mgba-wasm.data +0 -0
- package/renderer/dist/emulator/data/cores/package.json +65 -0
- package/renderer/dist/emulator/data/cores/reports/mgba.json +1 -0
- package/renderer/dist/emulator/data/emulator.css +1614 -0
- package/renderer/dist/emulator/data/loader.js +170 -0
- package/renderer/dist/emulator/data/localization/README.md +63 -0
- package/renderer/dist/emulator/data/localization/af-FR.json +339 -0
- package/renderer/dist/emulator/data/localization/ar-AR.json +301 -0
- package/renderer/dist/emulator/data/localization/ben-BEN.json +301 -0
- package/renderer/dist/emulator/data/localization/de-GER.json +301 -0
- package/renderer/dist/emulator/data/localization/el-GR.json +301 -0
- package/renderer/dist/emulator/data/localization/en-US.json +339 -0
- package/renderer/dist/emulator/data/localization/es-ES.json +310 -0
- package/renderer/dist/emulator/data/localization/fa-AF.json +310 -0
- package/renderer/dist/emulator/data/localization/hi-HI.json +301 -0
- package/renderer/dist/emulator/data/localization/it-IT.json +302 -0
- package/renderer/dist/emulator/data/localization/ja-JA.json +301 -0
- package/renderer/dist/emulator/data/localization/jv-JV.json +301 -0
- package/renderer/dist/emulator/data/localization/ko-KO.json +336 -0
- package/renderer/dist/emulator/data/localization/pt-BR.json +361 -0
- package/renderer/dist/emulator/data/localization/retroarch.json +617 -0
- package/renderer/dist/emulator/data/localization/ro-RO.json +310 -0
- package/renderer/dist/emulator/data/localization/ru-RU.json +301 -0
- package/renderer/dist/emulator/data/localization/tr-TR.json +310 -0
- package/renderer/dist/emulator/data/localization/vi-VN.json +302 -0
- package/renderer/dist/emulator/data/localization/zh-CN.json +351 -0
- package/renderer/dist/emulator/data/src/GameManager.js +464 -0
- package/renderer/dist/emulator/data/src/compression.js +142 -0
- package/renderer/dist/emulator/data/src/emulator.js +6158 -0
- package/renderer/dist/emulator/data/src/gamepad.js +167 -0
- package/renderer/dist/emulator/data/src/nipplejs.js +1 -0
- package/renderer/dist/emulator/data/src/shaders.js +236 -0
- package/renderer/dist/emulator/data/src/socket.io.min.js +7 -0
- package/renderer/dist/emulator/data/src/storage.js +125 -0
- package/renderer/dist/emulator/data/version.json +5 -0
- package/renderer/dist/emulator/host.js +297 -0
- package/renderer/dist/emulator/index.html +28 -0
- package/renderer/dist/emulator/provenance.json +6 -0
- package/renderer/dist/index.html +16 -3
- package/scripts/after-install.mjs +14 -0
- package/scripts/approval-server.sh +31 -7
- package/scripts/before-publish.mjs +12 -10
- package/shared/agent-import.mjs +3 -1
- package/shared/agents.d.mts +1 -0
- package/shared/bridge-map.mjs +19 -0
- package/shared/claude-commands.generated.mjs +8 -6
- package/shared/claude-models.generated.mjs +10 -8
- package/shared/codex-modes.mjs +1 -1
- package/shared/corner-tag.d.mts +14 -0
- package/shared/corner-tag.mjs +141 -0
- package/shared/demo-world.mjs +1 -1
- package/shared/engines.mjs +20 -5
- package/shared/fresh-user-home.mjs +12 -1
- package/shared/harness-definitions.mjs +103 -0
- package/shared/instruction-defaults.json +1 -1
- package/shared/notify-rules.d.mts +25 -0
- package/shared/notify-rules.mjs +19 -0
- package/shared/project-folder-check.mjs +3 -3
- package/shared/provider-commands.mjs +10 -2
- package/shared/rank.d.mts +2 -0
- package/shared/rank.mjs +50 -0
- package/shared/relay-address.mjs +6 -0
- package/shared/relay-crypto.mjs +165 -0
- package/shared/runs-on.d.mts +10 -0
- package/shared/runs-on.mjs +55 -0
- package/shared/shortcuts.mjs +11 -5
- package/shared/spawn-trouble.mjs +58 -7
- package/shared/terminal-input.d.mts +1 -0
- package/shared/terminal-input.mjs +30 -0
- package/shared/terminal-keys.d.mts +1 -0
- package/shared/terminal-keys.mjs +16 -0
- package/shared/terminal-size.d.mts +4 -0
- package/shared/terminal-size.mjs +29 -0
- package/shared/usage.d.mts +3 -0
- package/shared/usage.mjs +7 -0
- package/shared/where-it-runs-from.d.mts +43 -0
- package/shared/where-it-runs-from.mjs +155 -0
- package/shared/work-items.mjs +28 -2
- package/shared/work-lines.mjs +1 -1
- package/shared/xterm-invalid-range.d.mts +2 -0
- package/shared/xterm-invalid-range.mjs +58 -0
- package/renderer/dist/assets/index-B-2Az952.css +0 -32
- package/renderer/dist/assets/index-D6qncgai.js +0 -1168
|
@@ -0,0 +1,1132 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-CnYzvFkz.js","./product-name-CTKLYNWY.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var T$=Object.defineProperty;var M$=(e,t,n)=>t in e?T$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var A0=(e,t,n)=>M$(e,typeof t!="symbol"?t+"":t,n);import{r as g,b as bs,N as Je,d as st,n as QE,W as ZE,j as l,c as R$,a as Mh,g as eA,R as Bn,e as I$,f as D$}from"./product-name-CTKLYNWY.js";function O$(e,t,n){const r=new URLSearchParams(e),s=r.get("focus");if(s==="1")return n[0];if(r.get("fixtures")==="1")return t.find(o=>o.id===s)}const sr=()=>typeof document<"u"&&document.documentElement.dataset.door==="phone",T0="agentbox-thread";function L$(e,t){let n=!1;const r=()=>{n&&(n=!1,t())};return e.addEventListener("popstate",r),{sync(s){var o;s&&!n?(e.history.pushState({[T0]:!0},""),n=!0):!s&&n&&(n=!1,(o=e.history.state)!=null&&o[T0]&&e.history.back())},stop(){e.removeEventListener("popstate",r)}}}function $$(e,t){const n=g.useRef(t);n.current=t;const r=g.useRef(null);g.useEffect(()=>{if(sr())return r.current=L$(window,()=>n.current()),()=>{var s;(s=r.current)==null||s.stop(),r.current=null}},[]),g.useEffect(()=>{var s;(s=r.current)==null||s.sync(e)},[e])}function P$({startX:e,dx:t,dy:n,width:r}){return e>24||t<Math.max(100,r*.28)?!1:Math.abs(n)<t*.6}function z$({innerHeight:e,height:t,offsetTop:n}){return Math.max(0,Math.round(e-t-n))}const M0=e=>{const t=/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+))?\s*\)/.exec(e??"");return t?[Number(t[1]),Number(t[2]),Number(t[3]),t[4]===void 0?1:Number(t[4])]:null},Am=e=>Math.round(e).toString(16).padStart(2,"0");function F$(e,t){const n=M0(e);if(!n)return"#1e1b1a";const r=M0(t),s=r?r[3]:0,o=i=>n[i]*(1-s)+(r?r[i]*s:0);return`#${Am(o(0))}${Am(o(1))}${Am(o(2))}`}const B$=6;function _$(e,t){return e.distance>0?Math.min(B$,Math.max(1,e.scale*(t/e.distance))):e.scale}function W$(e){return e>1.01?1:2.5}function R0(e,t){return Math.max(0,(e*t-e)/2)}function H$(){let e=null,t=1,n=0,r=0,s=null,o=null,i=0;const a=u=>Math.hypot(u[0].clientX-u[1].clientX,u[0].clientY-u[1].clientY),c=()=>{if(!e)return;const u=R0(e.clientWidth,t),d=R0(e.clientHeight,t);n=Math.max(-u,Math.min(u,n)),r=Math.max(-d,Math.min(d,r)),e.style.transform=t===1?"":`translate(${n}px, ${r}px) scale(${t})`};addEventListener("touchstart",u=>{var h,f;const d=(f=(h=u.target)==null?void 0:h.closest)==null?void 0:f.call(h,".doc-picture");if(d){if(d!==e&&(e=d,t=1,n=0,r=0),u.touches.length===2)s={distance:a(u.touches),scale:t},o=null;else if(u.touches.length===1){const p=Date.now();if(p-i<300){t=W$(t),n=0,r=0,c(),i=0,u.preventDefault();return}i=p,o={px:u.touches[0].clientX,py:u.touches[0].clientY,x:n,y:r}}}},{passive:!1}),addEventListener("touchmove",u=>{var d,h;!e||!((h=(d=u.target)==null?void 0:d.closest)!=null&&h.call(d,".doc-picture"))||(s&&u.touches.length===2?(t=_$(s,a(u.touches)),c(),u.preventDefault()):o&&u.touches.length===1&&t>1&&(n=o.x+(u.touches[0].clientX-o.px),r=o.y+(u.touches[0].clientY-o.py),c(),u.preventDefault()))},{passive:!1}),addEventListener("touchend",u=>{u.touches.length<2&&(s=null),u.touches.length===0&&(o=null),t<=1.01&&(t=1,n=0,r=0,c())})}function U$(){const e=document.documentElement,t=window.visualViewport,n=()=>{if(!t)return;e.style.setProperty("--vvh",`${Math.round(t.height)}px`);const u=z$({innerHeight:window.innerHeight,height:t.height,offsetTop:t.offsetTop});e.style.setProperty("--kb",`${u}px`),e.style.setProperty("--vvtop",`${Math.round(t.offsetTop)}px`),u>80?e.dataset.keyboard="up":delete e.dataset.keyboard};n(),t==null||t.addEventListener("resize",n),t==null||t.addEventListener("scroll",n),H$();let r=document.querySelector('meta[name="theme-color"]');r||(r=document.createElement("meta"),r.name="theme-color",document.head.appendChild(r));const s=()=>{const u=document.querySelector(".workspace-layout"),d=getComputedStyle(document.body).backgroundColor,h=u?getComputedStyle(u,"::before").backgroundColor:"";r.content=F$(d,h)};s(),new MutationObserver(s).observe(e,{attributes:!0,attributeFilter:["data-theme","data-skin","class","style"]});const o=new MutationObserver(()=>{document.querySelector(".workspace-layout")&&(o.disconnect(),s())});if(o.observe(document.body,{childList:!0,subtree:!0}),!(navigator.standalone===!0))return;let a=null,c=null;addEventListener("touchstart",u=>{const d=u.touches[0];c=document.querySelector(".focus-pane"),a=d&&d.clientX<=24&&c?{x:d.clientX,y:d.clientY}:null},{passive:!0}),addEventListener("touchmove",u=>{const d=u.touches[0];if(!a||!d||!c)return;const h=Math.max(0,d.clientX-a.x);c.style.transform=`translateX(${h}px)`,c.style.transition="none"},{passive:!0}),addEventListener("touchend",u=>{const d=u.changedTouches[0];if(!a||!d||!c)return;const h=P$({startX:a.x,dx:d.clientX-a.x,dy:d.clientY-a.y,width:innerWidth}),f=c;f.style.transition="transform .18s ease",f.style.transform=h?`translateX(${innerWidth}px)`:"",setTimeout(()=>{h&&history.back(),f.style.transform="",f.style.transition=""},h?170:200),a=null,c=null})}const Tm=e=>!e;function K$(e,t){const n=()=>{e.visibilityState==="hidden"&&t()};return e.addEventListener("visibilitychange",n),()=>e.removeEventListener("visibilitychange",n)}const V$=3e4,q$=2e3,Ta=(e,t)=>t?Math.max(e,V$):e;function Y$(e,t){let n=-1/0,r=null,s=null;const o=i=>{n=Date.now(),t(i)};return i=>{const a=n+e-Date.now();if(a<=0&&!r){o(i);return}s={arg:i},r??(r=setTimeout(()=>{r=null;const c=s;s=null,c&&o(c.arg)},Math.max(a,0)))}}const G$=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","j","k","]","["]);function J$(e,t,n,r=4){if(n>0)return e.find(s=>s>t+r)??null;for(let s=e.length-1;s>=0;s--)if(e[s]<t-r)return e[s];return null}function X$(e){return G$.has(e.length===1?e.toLowerCase():e)}function Q$(e,t,{meta:n=!1}={}){const r=Math.max(0,t.max),s=a=>Math.max(0,Math.min(r,Math.round(a))),o=t.row>0?t.row:19,i=Math.max(o,t.view-o*2);switch(e){case"ArrowDown":return n?r:s(t.top+o);case"ArrowUp":return n?0:s(t.top-o);case"PageDown":return s(t.top+i);case"PageUp":return s(t.top-i);case"Home":return 0;case"End":return r;default:return null}}function Z$(e,t,n){if(n<=0)return null;const r=s=>Math.max(0,Math.min(n-1,s));switch(e){case"ArrowDown":return r(t+1);case"ArrowUp":return r(t-1);case"Home":return 0;case"End":return n-1;default:return null}}function eP(e,t,{shift:n=!1,meta:r=!1}={}){if(n||r)return null;switch(e){case"ArrowUp":return{move:-1,col:t.col};case"ArrowDown":return{move:1,col:t.col};case"ArrowLeft":return t.col===0?{move:-1,col:1/0}:null;case"ArrowRight":return t.col>=t.len?{move:1,col:0}:null;default:return null}}function tP(e,t,n){if(!n.length)return null;const r=Math.max(0,Math.min(n.length-1,t.line)),s=i=>Math.max(0,Math.min(n.length-1,i)),o=(i,a)=>({line:i,col:Math.max(0,Math.min(a,n[i]))});switch(e){case"ArrowDown":return r>=n.length-1?o(r,n[r]):o(s(r+1),t.col);case"ArrowUp":return r<=0?o(r,0):o(s(r-1),t.col);case"ArrowRight":return t.col>=n[r]?r>=n.length-1?null:o(s(r+1),0):o(r,t.col+1);case"ArrowLeft":return t.col<=0?r<=0?null:o(s(r-1),n[s(r-1)]):o(r,t.col-1);case"Home":return o(r,0);case"End":return o(r,n[r]);default:return null}}function nP(e){return e==="ArrowDown"||e==="ArrowUp"||e==="ArrowLeft"||e==="ArrowRight"||e==="Home"||e==="End"}function rP(e,t,n=12){let r=0;for(let s=0;s<e.length;s++)e[s]-t<=n&&(r=s);return r}function sP(e,t={}){return t.meta||t.ctrl||t.alt?!1:e==="Backspace"||e==="Delete"||e==="Enter"?!0:e.length===1}function oP(e){return e.startsWith("insert")||e.startsWith("delete")}function Rh(e){return`runs/${e}/the-change-it-made.change`}function Mm(e){return{name:e,children:new Map,file:null}}function tA(e){const t=Mm("");for(const s of e){const o=String(s.path).split("/").filter(Boolean);let i=t;for(const u of o.slice(0,-1))i.children.has(u)||i.children.set(u,Mm(u)),i=i.children.get(u);const a=o[o.length-1]??s.path,c=Mm(a);c.file=s,i.children.set(a,c)}const n=[],r=(s,o,i)=>{const a=[...s.children.values()],c=a.filter(d=>!d.file).sort((d,h)=>d.name.localeCompare(h.name)),u=a.filter(d=>d.file).sort((d,h)=>d.name.localeCompare(h.name));for(const d of c){let h=d.name,f=d;for(;f.children.size===1;){const m=[...f.children.values()][0];if(m.file)break;h+=`/${m.name}`,f=m}const p=nA(f);n.push({kind:"folder",label:h,depth:o,key:`${i}${h}/`,plus:p.reduce((m,w)=>m+(w.plus??0),0),minus:p.reduce((m,w)=>m+(w.minus??0),0),files:p.length}),r(f,o+1,`${i}${h}/`)}for(const d of u)n.push({kind:"file",label:d.name,depth:o,key:d.file.path,path:d.file.path,plus:d.file.plus??0,minus:d.file.minus??0})};return r(t,0,""),n}function nA(e){return e.file?[e.file]:[...e.children.values()].flatMap(nA)}function iP(e,t){const n=[];let r=null;for(const s of e)r!==null&&s.depth>r||(r=null,n.push(s),s.kind==="folder"&&t.has(s.key)&&(r=s.depth));return n}function aP(e){return e===1?"1 file":`${e} files`}function lP(e){var n;const t=((n=e.files)==null?void 0:n.length)??0;return`${aP(t)} +${e.plus??0} −${e.minus??0}`}function cP(e){const t=e.startedAt??0,n=e.endedAt??0;if(!t||!n||n<=t)return"";const r=Math.round((n-t)/6e4);if(r<1)return"under a minute";if(r===1)return"1 minute";if(r<60)return`${r} minutes`;const s=Math.round(r/60);return s===1?"1 hour":`${s} hours`}const uP=new Set(["const","let","var","function","return","if","else","for","while","of","in","import","from","export","default","class","extends","new","await","async","try","catch","finally","throw","typeof","instanceof","delete","void","type","interface","enum","as","null","undefined","true","false","this","switch","case","break","continue","do","yield","static","public","private","def","elif","lambda","None","True","False","pass","raise","with"]),dP=new Set(["const","let","var"]),hP=new Set(["function","def"]),fP=new Set(["number","string","boolean","bigint","symbol","object","any","unknown","never"]);function pP(e){if(/^\s*(\?\.)?\(/.test(e))return!0;if(e[0]!=="<")return!1;let t=0;for(let n=0;n<Math.min(e.length,120);n+=1){const r=e[n];if(r==="<")t+=1;else if(r===">"){if(t-=1,t===0)return e[n+1]==="("}else{if(r==="("||r===")"||r===";")return!1;if((r==="&"||r==="|")&&e[n+1]===r)return!1}}return!1}function rA(e){const t=[],n=(d,h)=>{h&&t.push({c:d,s:h})};let r=0,s="";const o=()=>{n("",s),s=""};let i=!1,a=!1,c=0;const u=e.match(/^\s*(?=\*(\s|\/|$))/);if(u)return n("",u[0]),n("com",e.slice(u[0].length)),t;for(;r<e.length;){const d=e.slice(r),h=d.slice(0,2);if(h==="//"||h==="/*"||d[0]==="#"&&/^#(!|\s)/.test(d))return o(),n("com",d),t;const f=d[0];if(f==='"'||f==="'"||f==="`"){let b=1;for(;b<d.length;){if(d[b]==="\\"){b+=2;continue}if(d[b]===f){b+=1;break}b+=1}o(),n("str",d.slice(0,b)),r+=b;continue}const p=d.match(/^[A-Za-z_$][\w$]*/);if(p){const b=p[0],x=d.slice(b.length);o(),uP.has(b)?(n("kw",b),i=dP.has(b),a=hP.has(b)):a?(n("fn",b),a=!1):i?(n("def",b),i=!1):c>0?n(/^\s*:/.test(x)?"":"def",b):fP.has(b)?n("typ",b):b.length>1&&/^[A-Z][A-Z0-9_]*$/.test(b)?n("con",b):/^[A-Z]/.test(b)?n("typ",b):pP(x)?n("fn",b):n("",b),r+=b.length;continue}const m=d.match(/^\d[\d_.a-fA-FxX]*/);if(m){o(),n("num",m[0]),r+=m[0].length;continue}if(h==="=>"){o(),n("kw",h),r+=2,i=!1,a=!1;continue}const w=d[0];i&&(w==="["||w==="{")?(i=!1,c=1):c>0&&(w==="["||w==="{")?c+=1:c>0&&(w==="]"||w==="}")?c-=1:/[\s*]/.test(w)||(i=!1,a=!1),s+=d[0],r+=1}return o(),t}function mP(e,t){if(e===t)return null;const n=Math.min(e.length,t.length);let r=0;for(;r<n&&e[r]===t[r];)r+=1;let s=0;for(;s<n-r&&e[e.length-1-s]===t[t.length-1-s];)s+=1;const o=[r,e.length-s],i=[r,t.length-s];return Math.max((o[1]-o[0])/Math.max(1,e.length),(i[1]-i[0])/Math.max(1,t.length))>.6?null:{minus:o,plus:i}}function gP(e){const t=e.map(()=>null);let n=0;for(;n<e.length;){if(e[n][0]!=="-"){n+=1;continue}const r=n;for(;n<e.length&&e[n][0]==="-";)n+=1;const s=n;for(;n<e.length&&e[n][0]==="+";)n+=1;const o=Math.min(s-r,n-s);for(let i=0;i<o;i++){const a=mP(e[r+i][1],e[s+i][1]);a&&(t[r+i]=a.minus,t[s+i]=a.plus)}}return t}function yP(e,t){if(!t||t[0]>=t[1])return e;const n=[];let r=0;for(const s of e){const o=r+s.s.length,i=[r,Math.min(Math.max(t[0],r),o),Math.min(Math.max(t[1],r),o),o];for(let a=0;a<3;a++){const c=s.s.slice(i[a]-r,i[a+1]-r);c&&n.push(a===1?{c:s.c,s:c,hl:!0}:{c:s.c,s:c})}r=o}return n}function wP(e){return{rows:e,hidden:0}}function bP(e){return e.map((t,n)=>n)}const xP=18.6;function I0(e,t){var a,c,u,d,h;const n=(c=e==null?void 0:e.nums)==null?void 0:c[(((a=e.nums)==null?void 0:a.length)??0)-1],r=(u=t==null?void 0:t.nums)==null?void 0:u[0];if(!n||!r)return null;const s=(d=[...(e==null?void 0:e.nums)??[]].reverse().find(f=>f[1]!=null))==null?void 0:d[1],o=(h=((t==null?void 0:t.nums)??[]).find(f=>f[1]!=null))==null?void 0:h[1];if(s==null||o==null)return null;const i=o-s-1;return i>0?i:null}function kP(e,t,n){const r=c=>{var u;for(let d=(((u=c.nums)==null?void 0:u.length)??0)-1;d>=0;d--)if(c.nums[d][1]!=null)return{n:c.nums[d][1],text:c.rows[d][1]};return null},s=c=>{const u=(c.nums??[]).findIndex(d=>d[1]!=null);return u>=0?{n:c.nums[u][1],text:c.rows[u][1]}:null},o=r(t),i=s(n);if(!o||!i)return{ok:!1,error:"This change does not say which lines it skipped."};const a=String(e).split(`
|
|
3
|
+
`);return a[o.n-1]!==o.text||a[i.n-1]!==i.text?{ok:!1,error:"This file has changed since, so the lines in between could not be placed. Open it in your editor to read them."}:{ok:!0,from:o.n+1,lines:a.slice(o.n,Math.max(o.n,i.n-1))}}const D0=48;function vP(e){const t=[];for(let n=0;n<e;n+=D0)t.push([n,Math.min(e,n+D0)]);return t}function sA(e){return Math.round(e*xP)}const SP=2400,oA=150;function jP(e,t,n,r=oA){const s=[n,...Array.from({length:e.length},(a,c)=>c).filter(a=>a>n),...Array.from({length:n},(a,c)=>n-1-c)],o=[];let i=0;for(const a of s){if(a<0||a>=e.length||t.has(a))continue;const c=e[a].hunks.reduce((u,d)=>u+d.rows.length,0);if(o.length&&i+c>r)break;o.push(a),i+=c}return o}function CP(e,t,n=SP){let r=0,s=0;for(;s<e.length;){const o=e[s].hunks.reduce((i,a)=>i+a.rows.length,0);if(s>t&&s>0&&r+o>n)break;r+=o,s+=1}return s}function NP(e){const t=new Map(tA(e).filter(n=>n.kind==="file").map((n,r)=>[n.path,r]));return[...e].sort((n,r)=>(t.get(n.path)??0)-(t.get(r.path)??0))}const O0=new Map;function L0(e,t){const n=`${e}
|
|
4
|
+
${t}`;let r=O0.get(n);return r||(r=new Set,O0.set(n,r)),r}function EP(e,t){const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function AP(e,t,n,r){if(!n.length||e!=="ArrowDown"&&e!=="ArrowUp"&&e!=="Home"&&e!=="End")return null;const s=t?n.indexOf(t):-1;if(s>=0||e==="Home"||e==="End"){const u=Z$(e,Math.max(0,s),n.length);return u==null||u===s?null:n[u]}const o=e==="ArrowDown",i=new Map(r.map((u,d)=>[u,d])),a=t?i.get(t)??-1:-1;return(o?n.find(u=>(i.get(u)??-1)>a):[...n].reverse().find(u=>(i.get(u)??-1)<a))??null}function Sy(e,t){return e&&new URLSearchParams(t).has("reviewLab")}function TP(e,t,n="approve"){const r=n==="feedback"?`Feedback on ${t}:`:`Looks good: ${t}`;return e.split(`
|
|
5
|
+
`).includes(r)?e:e?`${e}
|
|
6
|
+
|
|
7
|
+
${r}`:r}function MP(e){return e.slice(0,6).map(([t,n],r)=>({mark:t,text:n,line:r+1}))}function RP(e){return{visible:e.slice(0,3),remaining:Math.max(0,e.length-3),total:e.length}}const IP=rA;function DP(e){return e>1?"Review all files":e===1?"Review full file":"Open preview"}function OP(e,t){return t===void 0?e.split(/[?#]/)[0].split("/").pop()||e:`Code changes · ${t} file${t===1?"":"s"}`}async function LP({send:e,accepted:t,failed:n}){try{await e()}catch(r){return await n(r),!1}return await t(),!0}function $P({target:e,children:t}){const[n]=g.useState(()=>{const r=document.createElement("div");return r.className="artifact-host",r});return g.useLayoutEffect(()=>{if(e)return e.appendChild(n),()=>{n.remove()}},[e,n]),bs.createPortal(t,n)}function PP(e,t){return e==="beside"&&t<1e3?"focus":e}function zP(e,t){return Math.max(560/t,Math.min(1-400/t,e))}function Ib(e){try{const t=new URL(e);return["http:","https:"].includes(t.protocol)&&["localhost","127.0.0.1","[::1]"].includes(t.hostname)}catch{return!1}}const FP=1800,$0={width:260,height:110};function BP(e){return e.reaching||e.awake}const iA=e=>`${e.product}:${e.id}`;function _P(e,t){const n=Math.min(t,Math.max(0,e.length-1)),r=e[n];return r?{index:n,key:iA(r)}:null}function WP({list:e,selected:t,last:n}){const r=Math.min(t,Math.max(0,e.length-1));if(!n||t!==n.index)return r;const s=e.findIndex(o=>iA(o)===n.key);return s>=0?s:r}const HP=""+new URL("gouache-valley-sm-CdLjT5Ec.webp",import.meta.url).href,UP=""+new URL("gouache-valley-d9qasI6k.webp",import.meta.url).href,P0=Object.fromEntries(Object.entries(Object.assign({"./assets/gouache-valley-sm.webp":HP,"./assets/gouache-valley.webp":UP})).map(([e,t])=>[e.replace("./assets/","").replace(".webp",""),t])),KP={"orbital-glass":"orbit-rings"};function VP(e,t){if(e==="none")return null;const n=KP[e]??e;return P0[t?`${n}-sm`:n]??P0[n]??null}const z0=new Map,qP=700;function jy(e){if(typeof document>"u")return Promise.resolve();const t=document.documentElement.getAttribute("data-skin-detail")==="soft",n=VP(e,t);if(!n)return Promise.resolve();let r=z0.get(n);if(!r){const s=new Image;s.decoding="async",s.src=n,r=s.decode().catch(()=>{}),z0.set(n,r)}return Promise.race([r,new Promise(s=>setTimeout(s,qP))])}function YP(e){const t=document.documentElement,n=()=>{t.setAttribute("data-look-switching",""),e(),requestAnimationFrame(()=>requestAnimationFrame(()=>t.removeAttribute("data-look-switching")))},r=document;typeof r.startViewTransition=="function"?r.startViewTransition(n):n()}const aA={plus:4,minus:2,editCount:1,files:[{path:"renderer/src/components/ProjectStart.tsx",plus:4,minus:2,hunks:[{said:"Keep the first task in the inbox until the user reviews it.",rows:[["=","export function startProject(project: Project) {"],["-",' const task = createTask(project, { status: "running" });'],["-"," return startAgent(task);"],["+"," return createTask(project, {"],["+",' status: "inbox",'],["+",' title: "Ready to set up onboarding?",'],["+"," });"],["=","}"]]}]}]},GP=`# The first task
|
|
8
|
+
|
|
9
|
+
Starting a project should give you one clear next step.
|
|
10
|
+
|
|
11
|
+
## Proposed behavior
|
|
12
|
+
|
|
13
|
+
- Place the proposal in the inbox.
|
|
14
|
+
- Wait for the user to review it.
|
|
15
|
+
- Begin work after their reply.
|
|
16
|
+
|
|
17
|
+
## What stays the same
|
|
18
|
+
|
|
19
|
+
Existing tasks continue to run normally. The change only applies when a new project is created.
|
|
20
|
+
|
|
21
|
+
*Sample document for comparing artifact layouts.*`,JP={plus:10,minus:2,editCount:4,files:[...aA.files,...["renderer/src/project-defaults.ts","tests/project-start.test.ts","docs/project-start.md"].map((e,t)=>({path:e,plus:2,minus:0,hunks:[{said:"Keep new projects waiting for a reply.",rows:[["+",['export const initialStatus = "inbox";','expect(startProject(project).status).toBe("inbox");',"# Starting a project"][t]],["+",["export const autoStart = false;","expect(startAgent).not.toHaveBeenCalled();","New tasks wait for your reply before running."][t]]]}]}))]};function XP(e=!1){let t="available",n=0,r=0;const s=o=>(t==="running"&&Date.now()-n>1800&&(t=e?"failed":"current"),{engine:o,state:t,installed:t==="current"?"2.1.2":"2.1.1",latest:"2.1.2",message:t==="failed"?"Update did not finish. You can retry.":t==="current"?"Updated. Available models refreshed.":void 0});return{action(o,i){return i==="start"&&t!=="running"&&(t="running",n=Date.now(),r++),s(o)},terminal(o){if(o.action==="close")return t="failed",!0;const a=s("claude").state!=="running",c=`$ claude update\r
|
|
22
|
+
Checking for updates…\r
|
|
23
|
+
`+(a?e?`Update failed: could not reach the download server.\r
|
|
24
|
+
`:`Updated to 2.1.2.\r
|
|
25
|
+
`:"");return{token:"update-preview-"+r,cwd:"/preview",data:c.slice(o.offset||0),offset:c.length,truncated:!1,exited:a,exitCode:a?e?1:0:null,process:a?"Exited":"claude"}}}}const lA=e=>{if(e&&typeof e=="object"){for(const t of Object.values(e))lA(t);Object.freeze(e)}return e},cA=lA([{id:"claude",label:"Claude Code",word:"Claude Code",binKey:"claudeBin",homeEnv:"CLAUDE_CONFIG_DIR",accountPrefix:"",package:"@anthropic-ai/claude-code",commandMenu:"claude",commandRoute:"claude",casks:["claude-code","claude-code@latest"],installer:{shell:"/bin/bash",url:"https://claude.ai/install.sh",pipe:"bash"},loginArgs:["auth","login","--claudeai"],statusArgs:["auth","status","--json"],credentialFiles:[".claude.json",".credentials.json"],run:{print:"-p",outputFormat:{flag:"--output-format",value:"stream-json"},stream:["--verbose","--include-partial-messages"],effort:"--effort",system:"--append-system-prompt",resume:"--resume",fork:"--fork-session",input:["--input-format","stream-json","--replay-user-messages"]},scrubPatterns:["^ANTHROPIC_","^CLAUDE_CODE_","^CLAUDECODE$","^CLAUDE_PID$","^CLAUDE_EFFORT$","^CLAUDE_CONFIG_DIR$"],capabilities:{nativeCommands:!0,fork:!0,nativeReview:!1,remoteControl:!0,inlineImages:!1,claudeEffort:!0},imageInstruction:"Open each one with the Read tool, at the absolute path below."},{id:"codex",label:"Codex",word:"Codex",binKey:"codexBin",homeEnv:"CODEX_HOME",accountPrefix:"codex:",package:"@openai/codex",casks:["codex"],commandMenu:"codex",commandRoute:"codex",installer:{shell:"/bin/sh",url:"https://chatgpt.com/codex/install.sh",pipe:"sh"},loginArgs:["login"],statusArgs:["login","status"],credentialFiles:["auth.json"],scrubPatterns:["^ANTHROPIC_","^CLAUDE_CODE_","^CLAUDECODE$","^CLAUDE_PID$","^CLAUDE_EFFORT$","^CLAUDE_CONFIG_DIR$","^OPENAI_","^CODEX_"],capabilities:{nativeCommands:!1,fork:!1,nativeReview:!0,remoteControl:!1,inlineImages:!0,claudeEffort:!1},imageInstruction:"Each one is attached to this message as an image, and is also on disk at the absolute path below."},{id:"opencode",label:"OpenCode",word:"OpenCode",binKey:"opencodeBin",homeEnv:"OPENCODE_CONFIG",accountPrefix:"opencode:",package:"opencode-ai",commandMenu:"opencode",commandRoute:"opencode",casks:["opencode","sst/tap/opencode"],installer:{shell:"/bin/bash",url:"https://opencode.ai/install",pipe:"bash"},loginArgs:["auth","login"],statusArgs:["auth","list"],credentialFiles:["auth.json"],scrubPatterns:["^ANTHROPIC_","^CLAUDE_CODE_","^CLAUDECODE$","^CLAUDE_PID$","^CLAUDE_EFFORT$","^CLAUDE_CONFIG_DIR$","^OPENAI_","^CODEX_","^OPENCODE_","^OPENROUTER_","^GEMINI_","^GOOGLE_","^AWS_","^AZURE_","^GROQ_","^MISTRAL_","^DEEPSEEK_","^XAI_","^CEREBRAS_","^TOGETHER_","^FIREWORKS_","^DEEPINFRA_","^BASETEN_","^NVIDIA_","^GITLAB_TOKEN$","_API_KEY$","_ACCESS_TOKEN$"],capabilities:{nativeCommands:!0,fork:!0,nativeReview:!1,remoteControl:!1,inlineImages:!1,claudeEffort:!1,planLimits:!1},imageInstruction:"Open each one with the read tool, at the absolute path below.",admitted:!1}]);function Ih(e="claude"){return cA.find(t=>t.id===e)??null}const xs=cA.filter(({admitted:e})=>e!==!1).map(({id:e,label:t,word:n})=>({id:e,label:t,word:n})),QP=xs.map(e=>e.id),In="claude";function F0(e){return typeof e=="string"&&QP.includes(e)}function Db(e){var t;return((t=xs.find(n=>n.id===e))==null?void 0:t.label)??xs[0].label}const ZP=[{alias:"opus",id:"claude-opus-5-5",label:"Opus 5.5",defaultLevel:"medium"},{alias:"claude-opus-5",id:"claude-opus-5",label:"Opus 5",defaultLevel:"high"},{alias:"sonnet",id:"claude-sonnet-5-5",label:"Sonnet 5.5",defaultLevel:"medium"},{alias:"claude-sonnet-5",id:"claude-sonnet-5",label:"Sonnet 5",defaultLevel:"high"},{alias:"haiku",id:"claude-haiku-5-5",label:"Haiku 5.5",defaultLevel:"medium"},{alias:"claude-haiku-4-5",id:"claude-haiku-4-5",label:"Haiku 4.5",defaultLevel:null},{alias:"fable",id:"claude-fable-5-1",label:"Fable 5.1",defaultLevel:"high"},{alias:"claude-fable-5",id:"claude-fable-5",label:"Fable 5",defaultLevel:"high"}],uA=ZP.map(e=>({id:e.alias,label:e.label,model:e.id,defaultLevel:e.defaultLevel}));let dA=null;function e2(e){dA=Array.isArray(e)&&e.length?e:null}function Vl(){return dA??uA}const np="opus";function t2(e){const t=e??np,n=Vl();return n.some(s=>s.id===t)?n:[...n,{id:t,label:t}]}const xa="";function Qr(e,t=null){return e!=="codex"?np:t??xa}function Ob(e,t,{codexModels:n=[],codexDefault:r=null}={}){if(e!=="codex")return t2(t);const s=t??Qr(e,r);return s===xa?[...n,{id:xa,label:"Codex's own"}]:n.some(o=>o.id===s)?n:[...n,{id:s,label:s}]}function ql(e,t,n={}){var s;const r=t??Qr(e,n.codexDefault??null);return((s=Ob(e,r,n).find(o=>o.id===r))==null?void 0:s.label)??r}function n2(e,t,n=null){return!!t&&t!==Qr(e,n)}const B0="zero.lastModel";function Cy(e=null){return e==="codex"?`${B0}.codex`:B0}function ih(e=globalThis.localStorage,t=null,n=null){try{const r=e==null?void 0:e.getItem(Cy(t));return!r||r===Qr(t,n)?null:r}catch{return null}}function r2(e,t=globalThis.localStorage,n=null,r=null){try{!e||e===Qr(n,r)?t==null||t.removeItem(Cy(n)):t==null||t.setItem(Cy(n),e)}catch{}}const ua=["read-only","auto","full-access"],Dh="auto",Oh={"read-only":{label:"Read only",sandbox:"read-only",approvalPolicy:"on-request",what:"Reads and searches. Writes nothing and runs nothing that changes anything."},auto:{label:"Auto",sandbox:"workspace-write",approvalPolicy:"on-request",approvalsReviewer:"auto_review",what:"Works inside the project folder. Asks before going outside it or onto the network."},"full-access":{label:"Full access",sandbox:"danger-full-access",approvalPolicy:"never",what:"Anything, anywhere on this computer, without asking."}},Lb={"read-only":"/read-only",auto:"/auto","full-access":"/full-access"},s2={"read-only":"reads and searches, writes nothing",auto:"works in the project folder, asks to leave it","full-access":"anything, anywhere, without asking"};function o2(e,t){if(e===null)return[];const n=ua.filter(s=>Lb[s].slice(1).startsWith(e.toLowerCase())),r=t&&"clear".startsWith(e.toLowerCase())?[null]:[];return[...n,...r]}const i2={"read-only":"read only on",auto:"auto on","full-access":"full access on"};function a2(e){const t=ua.indexOf(e);return ua[(t+1)%ua.length]}function l2(e){return e?ua.find(n=>Lb[n]===`/${e}`)??null:null}const Se=Date.now(),Be=6e4,Nt=36e5,Qo={products:[{slug:"kestrel",dir:"/fixtures/kestrel",name:"Kestrel",oneLiner:"Collectible card games, made beautiful",repoPath:"/Users/you/Desktop/dev/kestrel"},{slug:"onboard",dir:"/fixtures/onboard",name:"Onboard",oneLiner:"Employee onboarding that runs itself",repoPath:null},{slug:"thicket",dir:"/fixtures/thicket",name:"Thicket",oneLiner:"Strength programming for busy people",repoPath:null}],items:[{id:"w-p0",product:"kestrel",productName:"Kestrel",status:"done",kind:"question",title:"The card art is finished and nothing is built. The build menu is the step you named before code.",body:'You said "not yet, we still need to design and plan before building." Design ended when you took the economy, so the menu is the only thing between Kestrel and its first line of code. Approving this gets you one page that says what the build menu makes.',labels:[],priority:2,epoch:4,claim:null,createdAt:Se-40*Be,updatedAt:Se-27*Be},{id:"w-p1",product:"kestrel",productName:"Kestrel",status:"blocked",kind:"task",parent:"w-p0",title:"The build menu has never started, six schedules in. One tap tomorrow may be all it needs.",body:["Every session this product has been given for two days started within fifteen seconds of you pushing the menu's hour, and at that instant the menu is the one row nobody is allowed to touch. So the product gets a drive session instead, and the hour you picked passes with nothing awake to notice it. I recommend a free test: tomorrow after 8am, open the inbox and do anything except push that hour again.","","## Where we were","You have set this row's hour six times, most recently a few minutes ago, for 8am tomorrow. Five drive sessions before this one read that as you picking the hour, which it is, and correctly filed nothing."].join(`
|
|
26
|
+
`),answer:"I think the next step is to settle the art style? We may need an image tool to make the assets, not sure how best to turn our art into something we can build with",labels:[],priority:2,epoch:5,claim:null,wrote:{answer:{ts:Se-4*Be,source:"founder"}},createdAt:Se-17*Be,updatedAt:Se-4*Be,problem:"The build menu has been scheduled six times and never ran. Every start landed on the one minute its row is locked, so each was turned away. You then asked whether the art style should come first.",progress:["Read every session this project was given in the last two days","Each one started within 15 seconds of the menu’s hour","At that moment the menu is the one row nobody may touch, so every start was refused","Moved tomorrow’s run ten minutes off the hour as a test","Wrote up the change the scheduler needs","Asked you about the art style"].join(`
|
|
27
|
+
`)},{id:"w-p2",product:"kestrel",productName:"Kestrel",status:"open",kind:"question",parent:"w-p0",title:"The art needs a house style before any of it is generated.",body:"Three of the five sample cards came back in different lighting, so they cannot sit in one hand together. Fixing that after generation costs more than deciding it now. I recommend one page of style rules, written from the two cards you liked, against [round 3](designs/frame-round-3.html).",labels:[],priority:1,epoch:1,claim:null,createdAt:Se-9*Be,updatedAt:Se-9*Be},{id:"w-p3",product:"kestrel",productName:"Kestrel",status:"open",kind:"task",parent:"w-p0",title:"Name the five card rarities, so the economy page and the art brief stop disagreeing",body:`The economy page calls the top tier "mythic" and the art brief calls it "legendary". Both are written down, both are being built against, and the two names are already in four documents. One pass over all of them, settling on the economy page's words.`,labels:[],priority:2,epoch:1,claim:null,createdAt:Se-8*Be,updatedAt:Se-8*Be},{id:"w-p4",product:"kestrel",productName:"Kestrel",status:"open",kind:"task",parent:"w-p0",title:"Measure how long a hand of twelve takes to deal on the oldest phone we support",body:"The hand animation was designed against a desktop browser. Nothing has run it on a four-year-old phone, and the deal is the first thing anybody sees. One throwaway harness, one number, and a note saying whether the design survives it.",labels:[],priority:1,epoch:1,claim:null,createdAt:Se-7*Be,updatedAt:Se-7*Be},{id:"w-p3",product:"kestrel",productName:"Kestrel",status:"done",kind:"review",title:"The card frames are built, both sizes, and the art is ready. Merging is the only thing left.",body:["Someone who opens a booster now sees the new frame, and I recommend merging it. It is two components and one flag, and anyone who opens nothing sees pixel for pixel what they see today. The three sizes are in `designs/frame-round-3.html`.","","## Options","1. Merge it. It rides the next deploy (recommended)","2. Hold it behind the flag for a week"].join(`
|
|
28
|
+
`),answer:"Rejected. I do not want the frame changing before the art style is settled.",result:`Closed, because the thing this was blocked on came back as a no. You were asked to pick one of three redesigned frames and you refused all three and the idea behind them, so there is nothing here left to build or merge.
|
|
29
|
+
|
|
30
|
+
Your rejection stands fully enacted. Nothing was merged, and the branch is still on no other branch. Checked against main just now, not assumed.`,labels:["app","merge"],priority:5,epoch:3,claim:null,wrote:{answer:{ts:Se-65*Be,source:"founder"},status:{ts:Se-2*Be,source:"agent"}},createdAt:Se-90*Be,updatedAt:Se-2*Be},{id:"w-p4",product:"kestrel",productName:"Kestrel",status:"done",kind:"directive",title:"The booster opening animation is too slow on the second card.",body:"The booster opening animation is too slow on the second card. It feels fine on the first and then it drags, and by the fifth I am waiting on it rather than watching it.",answer:"Yes, try it at 200ms and show me.",result:["**The second card is at 200ms and it is on the branch, ready to merge.**","","All five cards now turn at the same speed, which is what made the second one feel like a stall: it was the only one at 340. A full booster is 1.1 seconds faster end to end, measured on the real build over ten opens, not estimated.","","The one judgement left is the flip on the rare card, which still holds a beat longer on purpose. Merge it as it is, take the beat off the rare card too, or leave it on the branch until you have opened one yourself.","","## Options","1. Merge it (recommended)","2. Take the extra beat off the rare card first","3. Leave it on the branch until I have opened one"].join(`
|
|
31
|
+
`),labels:["founder"],priority:5,epoch:2,claim:null,wrote:{body:{ts:Se-3*Nt,source:"founder"},answer:{ts:Se-70*Be,source:"founder"},result:{ts:Se-3*Be,source:"agent"},status:{ts:Se-3*Be,source:"agent"}},createdAt:Se-3*Nt,updatedAt:Se-3*Be},{id:"w-a1",product:"kestrel",productName:"Kestrel",status:"open",kind:"question",title:"Pricing page: annual toggle default on or off?",body:["## Where we were","You asked for a pricing page draft. I proposed three tiers with annual default. You said annual-default felt presumptuous before we have testimonials.","","## Context","The page is rebuilt with the monthly default. Simulated users (5 personas) now hesitate at the annual toggle: 3 of 5 never noticed it, which costs us the anchor. Screenshot attached shows the toggle placement.","","","","## Options",'1. Monthly default, toggle moved above the fold with a "2 months free" chip (recommended)',"2. Annual default, first testimonial quote placed beside it","3. Ship monthly-only, add annual after the first 10 paying users","","## What happens next","I ship the winner tonight, then re-run the 5-persona panel on the live page. Meanwhile I moved on to the checkout error copy.","","## Cost of being wrong","Low. One-line change to revert, and the panel re-run catches a regression within the hour."].join(`
|
|
32
|
+
`),labels:["pricing"],priority:2,epoch:3,claim:null,createdAt:Se-22*Be,updatedAt:Se-22*Be},{id:"w-b2",product:"onboard",productName:"Onboard",status:"open",kind:"review",title:"Review: welcome-email sequence rewrite (3 emails)",body:["## Where we were",'First draft last week read as AI-generated to you ("delve", exclamation marks). You asked for plain, specific, one idea per email.',"","## Context","Rewritten. Email 1 is 61 words. Diff and rendered previews:","","[View the diff](fixture://diff) · [Preview email 1](http://localhost:4801/emails/1)","","## What happens next","On approve, these go into the drip for new signups only. No existing user is re-mailed.","","## Cost of being wrong","Medium. Real humans receive these; a bad tone lands in inboxes we cannot unsend."].join(`
|
|
33
|
+
`),labels:["marketing","email"],priority:1,epoch:5,claim:null,createdAt:Se-2*Nt,updatedAt:Se-71*Be},{id:"w-c3",product:"thicket",productName:"Thicket",status:"blocked",kind:"task",title:"Stripe account: needs your identity verification to go live",body:["## Context","Test-mode checkout works end to end. Going live requires identity verification that only you can complete (government ID, ~5 minutes at the Stripe dashboard).","","[Open Stripe verification](https://dashboard.stripe.com/settings)","","## What happens next","The moment the account is live I flip the publishable key and re-run the paid-signup journey.","","## Cost of being wrong","None, but every day unverified is a day nothing can be sold."].join(`
|
|
34
|
+
`),labels:["payments"],priority:3,epoch:2,claim:null,createdAt:Se-26*Nt,updatedAt:Se-26*Nt},{id:"w-d4",product:"kestrel",productName:"Kestrel",status:"claimed",kind:"bug",title:"Card zoom flickers on Safari",labels:["frontend"],priority:1,epoch:4,claim:{holder:"zero-worker-9f2",leaseUntil:Se+4*Be},createdAt:Se-48*Be,updatedAt:Se-3*Be,body:"Repro: hover any card in the gallery on Safari 19. The zoom transform re-triggers on every mousemove.",problem:"Cards flicker in Safari when you hover to zoom. You flagged it after the holo effect landed; Chrome is fine.",progress:`Found it: the zoom is applied twice, by the hover style and the tilt code
|
|
35
|
+
Tilt code no longer moves the card; clean on Safari 19 and Chrome`},{id:"w-e5",product:"onboard",productName:"Onboard",status:"claimed",kind:"task",title:"Instrument the new signup flow",labels:["analytics"],priority:0,epoch:1,claim:{holder:"zero-worker-b81",leaseUntil:Se+2*Be},createdAt:Se-31*Be,updatedAt:Se-1*Be},{id:"w-m12",product:"onboard",productName:"Onboard",status:"open",kind:"design",title:"Onboarding: three first run flows are drawn, and one of them is yours to pick",body:`**Pick the walkthrough, already working, or teach as you go.**
|
|
36
|
+
|
|
37
|
+
Three first run flows are drawn, in the lake skin, as screens you can actually look at.`,note:`**Pick the walkthrough, already working, or teach as you go.**
|
|
38
|
+
|
|
39
|
+
Three first run flows are drawn, in the lake skin, as screens you can actually look at. They are in your documents.
|
|
40
|
+
|
|
41
|
+
The walkthrough is six composed screens, one idea each, then the app. It is the closest to onboarding somebody in person and the most beautiful of the three.
|
|
42
|
+
|
|
43
|
+
Nothing is coded until you say which one.`,labels:["design"],priority:5,epoch:2,claim:null,createdAt:Se-40*Be,updatedAt:Se-19*Be},{id:"w-n13",product:"onboard",productName:"Onboard",status:"open",kind:"review",title:"The first row a new project makes is fixed and needs your yes",body:`**Merge the first row change, or pick different words for it.**
|
|
44
|
+
|
|
45
|
+
Making a project used to compose a row the fleet took as work, so an agent started before you had said anything. It asks now, and nothing runs until you reply.
|
|
46
|
+
|
|
47
|
+
The page shows the row before and after:
|
|
48
|
+
|
|
49
|
+
/fixtures/onboard/designs/w-n13/the-first-row.html`,labels:["review"],priority:5,epoch:2,claim:null,createdAt:Se-52*Be,updatedAt:Se-12*Be,problem:"Making a new project used to start an agent straight away, before you had said anything. Now its first row waits for your reply, and the linked page shows that row before and after.",progress:`First row waits for your reply
|
|
50
|
+
Tests pass
|
|
51
|
+
On its branch, ready to merge`},{id:"w-i9",product:"onboard",productName:"Onboard",status:"open",kind:"design",title:"Design the build menu: what resources make, and what unlocks it",answer:"Option 1: One design pass, delivered as an HTML page you read.",labels:["design"],priority:4,epoch:7,claim:null,createdAt:Se-7*Nt,updatedAt:Se-2*Nt},{id:"w-j10",product:"thicket",productName:"Thicket",status:"open",kind:"task",title:"Bring back a list of name alternatives to react to",answer:"Option 1: A page of twenty or so candidates, grouped by what each promises.",labels:[],priority:4,epoch:3,claim:null,createdAt:Se-14*Nt,updatedAt:Se-5*Nt},{id:"w-k11",product:"kestrel",productName:"Kestrel",status:"open",kind:"directive",title:"Your depth signal is built, and the sign up count was wrong",body:["The depth signal you approved is built and verified, waiting on one thing from you.","","A visitor who reads the whole page now leaves marks at 25, 50, 75 and 100 carrying the","campaign that brought them; a visitor who stops at the first screen leaves none. Today","those two people are the same row.","","## What is owed","Whether to merge it. Nothing else waits on this."].join(`
|
|
52
|
+
`),labels:["gtm"],priority:1,epoch:4,claim:null,runAt:Se+9*Nt,wrote:{runAt:{ts:Se-12*Be,source:"agent"}},createdAt:Se-5*Nt,updatedAt:Se-12*Be},{id:"w-h8",product:"kestrel",productName:"Kestrel",status:"done",kind:"directive",title:"can you check our metrics? i want to see if the new pricing page moved signups",result:["Checked, and there is real news: the first stranger off the ad reached checkout tonight.","","On signups themselves the honest answer is that eleven people settle nothing. 1 signup from","13 visitors since the rewrite against 2 from 174 before it, our own rows excluded."].join(`
|
|
53
|
+
`),labels:["founder"],priority:9,epoch:4,claim:null,createdAt:Se-21*Be,updatedAt:Se-4*Be,wrote:{status:{ts:Se-4*Be,source:"agent"}}},{id:"w-h9",product:"onboard",productName:"Onboard",status:"claimed",kind:"directive",title:"Can the welcome email wait until they finish setup?",body:'Can the welcome email wait until they finish setup? Right now it goes out the second someone signs up, so people are getting a "you are all set" email while they are still halfway through the form, and two of them have written back asking what they were supposed to have done. I would rather it went out when they actually finish, and if they never finish then it should be a different email entirely, something that says come back and pick up where you left off.',note:"Found it. The email fires on account creation in signup.ts, not on the setup step, so it cannot see whether anyone finished. Moving the trigger to the completion event now.",labels:["founder"],priority:5,epoch:2,claim:null,createdAt:Se-55*Be,updatedAt:Se-6*Be,wrote:{body:{ts:Se-55*Be,source:"founder"},note:{ts:Se-6*Be,source:"agent"}}},{id:"w-k11",product:"kestrel",productName:"Kestrel",status:"done",kind:"question",title:"The best one is Tripo and it costs twenty cents. The only part I cannot do myself is opening the account it needs.",body:"Every one of these tools wants an account with a card on it before it will answer a single call. I hold your image key and nothing else, so that signup is the only part of this I cannot do.",answer:"status?",result:"Nothing is running, and nothing is waiting on me. It all sits with you.",labels:["v1","pipeline","spend"],priority:7,epoch:9,claim:null,createdAt:Se-6*Nt,updatedAt:Se-34*Be,wrote:{answer:{ts:Se-37*Be,source:"founder"},status:{ts:Se-34*Be,source:"agent"}}},{id:"w-f6",product:"thicket",productName:"Thicket",status:"done",kind:"task",title:"Program builder: deload weeks",result:"Shipped. Deload every 4th week, user-adjustable. Panel re-run: 5/5 completed setup.",labels:[],priority:0,epoch:2,claim:null,createdAt:Se-3*24*Nt,updatedAt:Se-5*Nt},{id:"w-g7",product:"kestrel",productName:"Kestrel",status:"done",kind:"question",title:"Holo effect: CSS or WebGL?",answer:"Option 1. CSS. Revisit only if the panel complains.",result:"Shipped CSS holo. 60fps on the test devices.",labels:["frontend"],priority:0,epoch:6,claim:null,createdAt:Se-2*24*Nt,updatedAt:Se-26*Nt}],supervisor:{paused:!1,capacity:3,productOrder:["onboard","kestrel","thicket"],stalled:["w-i9","w-j10"],running:[{itemId:"w-d4",product:"kestrel",startedAt:Se-3*Be,activity:[{id:"demo-tests",label:"Running npx vitest run",detail:"npx vitest run",startedAt:Se-17e3}],tail:["tool: Read","tool: Grep","Found it: the transform is applied in both the hover class and the JS tilt handler.","tool: Edit"]},{itemId:"w-e5",product:"onboard",startedAt:Se-12*Be,tail:["tool: mcp__agentbox__read_document","Reading the analytics contract before instrumenting.","tool: Edit","tool: Bash"]}]},approvals:[{id:"ap-1",at:Se-4e4,product:"kestrel",item:"w-d4",tool:"Bash",input:{command:"npx vercel deploy --prod --prebuilt",description:"Deploy the pricing page to production"}},{id:"ap-2",at:Se-22e3,product:"onboard",item:"w-e5",tool:"Bash",input:{command:"git push origin main",description:"Push the analytics instrumentation commit"}},{id:"ap-3",at:Se-8e3,product:"kestrel",item:"w-d4",tool:"Write",input:{file_path:"src/components/Pricing.tsx",description:"Rewrite the annual toggle"}}],engines:{choices:[xs[0]],workspace:In,byItem:{}},config:{}},_0=e=>new Date(e).toTimeString().slice(0,8);function Sd(e,t,n,r){const s=`# ${t}
|
|
54
|
+
# fixture · spawned ${new Date(e).toISOString()}
|
|
55
|
+
|
|
56
|
+
`,o=n.map(([a,c])=>`${_0(e+a*1e3)} ${c}`).join(`
|
|
57
|
+
`);if(!r)return`${s}${o}
|
|
58
|
+
`;const i=r.code===0?"success · 27 turns":"success ERROR · 1 turns";return`${s}${o}
|
|
59
|
+
|
|
60
|
+
${_0(r.at)} == RESULT (${i}) ==
|
|
61
|
+
${r.result}
|
|
62
|
+
|
|
63
|
+
# exited (${r.code}) ${new Date(r.at).toISOString()}
|
|
64
|
+
`}const c2={"w-d4":[{startedAt:Se-3*Be,text:Sd(Se-3*Be,"Card zoom flickers on Safari",[[0,"I'll start on the Safari flicker, reading the gallery component first."],[3,"[Read] src/components/Gallery.tsx"],[11,"[Grep] transform:"],[19,"[Read] src/styles/card.css"],[34,"[Read] src/tilt.ts"],[52,"Found it: the transform is applied in both the hover class and the JS tilt handler."],[58,"[Edit] src/styles/card.css"],[71,"[Bash] npx vitest run card"],[96,"The class alone still flickers, so the tilt handler has to stop writing transform at all."],[104,"[Edit] src/tilt.ts"],[119,"[Bash] npx vitest run card"],[142,"Green on Safari 19 and Chrome. Writing the test that would have caught this."],[150,"[Write] tests/card-tilt-owns-one-transform.test.ts"],[163,"[Bash] npx vitest run"]])}],"w-p3":[{startedAt:Se-7*Be,text:Sd(Se-7*Be,"The card frames are built, both sizes, and the art is ready.",[[0,"Took the job. Reading your answer before anything else."],[4,"[mcp__agentbox__claim_work_item] w-p3"],[12,"[mcp__agentbox__read_document] strategy/art-style.md"],[26,"You rejected all three frames and the idea behind them, so there is nothing here to merge."],[33,"[Bash] git log --oneline -5 main"],[39,"[Bash] git branch --contains kestrel/frames"],[48,"Checked rather than assumed: the frame branch is on no other branch, and main has never carried it."],[57,"[Bash] npx vitest run"],[96,"Suite green at 218 tests, so nothing half-merged is sitting in the tree."],[104,"[Edit] docs/decisions.md"],[119,"Recording the rejection where the next session will read it, not just on the row."],[126,"[Edit] docs/decisions.md"],[140,"[mcp__agentbox__update_work_item] w-p3"],[148,"Closed the row with the result above."]],{at:Se-2*Be,code:0,result:"Closed, because the thing this was blocked on came back as a no. You were asked to pick one of three redesigned frames and you refused all three and the idea behind them, so there is nothing here left to build or merge."})}],"w-m12":[{startedAt:Se-40*Be,text:Sd(Se-40*Be,"Onboarding: three first run flows",[[0,"Now the three first run flows, drawn in the lake skin."],[12,"[Read] renderer/src/styles.css"],[40,"[Write] /tmp/compose-flows.mjs"],[96,"[Bash] node /tmp/compose-flows.mjs"],[310,"[mcp__agentbox__write_document] designs/w-78c45faed4/first-run-flows.html"],[318,"They are in your documents."]],{at:Se-19*Be,code:0,result:"Three first run flows drawn."})}],"w-i9":[{startedAt:Se-2*Nt,text:Sd(Se-2*Nt,"Design the build menu: what resources make, and what unlocks it",[[0,"Started on your answer."]],{at:Se-2*Nt+3e3,code:1,result:"API Error: Claude AI usage limit reached. Your weekly limit resets at 4pm."})}]},u2={"w-n13":[{id:"w-n13",ts:Se-52*Be,source:"agent",patch:{title:"The first row a new project makes is fixed and needs your yes",status:"open",kind:"review",priority:5,body:`**Merge the first row change, or pick different words for it.**
|
|
65
|
+
|
|
66
|
+
Making a project used to compose a row the fleet took as work, so an agent started before you had said anything. It asks now, and nothing runs until you reply.
|
|
67
|
+
|
|
68
|
+
The page shows the row before and after:
|
|
69
|
+
|
|
70
|
+
/fixtures/onboard/designs/w-n13/the-first-row.html`}}],"w-p1":[{id:"w-p1",ts:Se-17*Be,source:"agent",patch:{title:"Six schedules, no session: something is eating the build menu's hour",status:"open",kind:"task",priority:2,parent:"w-p0",body:"The menu has been scheduled six times and has never started. I do not know why yet."}},{id:"w-p1",ts:Se-16*Be,source:"agent",epoch:5,claim:{holder:"mcp-40122",leaseUntil:Se-11*Be},patch:{status:"claimed"}},{id:"w-p1",ts:Se-12*Be,source:"agent",epoch:5,patch:{title:"The build menu has never started, six schedules in. One tap tomorrow may be all it needs."}},{id:"w-p1",ts:Se-11*Be,source:"agent",epoch:5,patch:{status:"blocked",note:"Read every session this product has been given for two days. Each one started within fifteen seconds of the menu's hour, and at that instant the menu is the one row nobody may touch."}},{id:"w-p1",ts:Se-4*Be,source:"founder",patch:{answer:"I think the next step is to settle the art style? We may need an image tool to make the assets, not sure how best to turn our art into something we can build with"}}],"w-p0":[{id:"w-p0",ts:Se-40*Be,source:"agent",patch:{title:"The card art is finished and nothing is built. The build menu is the step you named before code.",status:"open",kind:"question",priority:2,body:'You said "not yet, we still need to design and plan before building."'}},{id:"w-p0",ts:Se-31*Be,source:"agent",epoch:4,claim:{holder:"mcp-38801",leaseUntil:Se-26*Be},patch:{status:"claimed"}},{id:"w-p0",ts:Se-27*Be,source:"agent",epoch:4,patch:{status:"done"}}]},W0=[{id:"r-3f9a21bc44",product:"harbour",productName:"Harbour",title:"Every day at 9am, run a synthetic user through Harbour onboarding",body:`From the landing page to the first artifact, as a new user with a fresh email.
|
|
71
|
+
|
|
72
|
+
What I want back:
|
|
73
|
+
- Anything that broke, with the step it broke on.
|
|
74
|
+
- Anything that took longer than ten seconds.
|
|
75
|
+
- Nothing else. If it all worked, say so and stop.
|
|
76
|
+
|
|
77
|
+
Skip:
|
|
78
|
+
- The billing screen, it is not wired yet.
|
|
79
|
+
- The invite flow.`,every:"day",at:"09:00",createdAt:Se-6*24*Nt,served:new Date(Se).toISOString().slice(0,10),misses:0,alerted:0,lastOccurrence:"r-3f9a21bc44-today"},{id:"r-77c1e0aa31",product:"kestrel",productName:"Kestrel",title:"Every morning, check overnight signups against yesterday",every:"day",at:"08:00",createdAt:Se-12*24*Nt,served:new Date(Se).toISOString().slice(0,10),misses:0,alerted:0,lastOccurrence:"r-77c1e0aa31-today"}],Vo=(e,t,n)=>{const r=new Date;return r.setDate(r.getDate()-e),r.setHours(t,n,0,0),r.getTime()},d2=[{id:"r-3f9a21bc44-today",product:"harbour",productName:"Harbour",title:"Every day at 9am, run a synthetic user through Harbour onboarding · today",kind:"directive",status:"done",labels:["founder","repeat:r-3f9a21bc44"],priority:5,epoch:1,claim:null,result:"email verification took 41 seconds to send · filed as its own item",createdAt:Vo(0,9,3),updatedAt:Vo(0,9,14)},{id:"r-3f9a21bc44-yesterday",product:"harbour",productName:"Harbour",title:"Every day at 9am, run a synthetic user through Harbour onboarding · yesterday",kind:"directive",status:"done",labels:["founder","repeat:r-3f9a21bc44","clean"],priority:5,epoch:1,claim:null,createdAt:Vo(1,9,6),updatedAt:Vo(1,9,12)},{id:"r-3f9a21bc44-saturday",product:"harbour",productName:"Harbour",title:"Every day at 9am, run a synthetic user through Harbour onboarding · Sat",kind:"directive",status:"done",labels:["founder","repeat:r-3f9a21bc44","clean"],priority:5,epoch:1,claim:null,createdAt:Vo(2,14,41),updatedAt:Vo(2,14,52)},{id:"r-77c1e0aa31-today",product:"kestrel",productName:"Kestrel",title:"Every morning, check overnight signups against yesterday · today",kind:"directive",status:"done",labels:["founder","repeat:r-77c1e0aa31","clean"],priority:5,epoch:1,claim:null,createdAt:Vo(0,8,2),updatedAt:Vo(0,8,9)}],h2={kestrel:{stage:"prelaunch",headline:{label:"Steps to launch",value:"3"},rows:[{label:"Next milestone",value:"First paying customer"},{label:"Real users",value:"4"},{label:"Revenue",value:"$0"},{label:"Panel verdict",value:"4/5 completed checkout"}],intent:"Ship pricing page, then open the waitlist to the 61 signups."},onboard:{stage:"launched",headline:{label:"Weekly active",value:"12"},rows:[{label:"Next milestone",value:"20 weekly active"},{label:"Signups this week",value:"5"},{label:"Revenue",value:"$147 MRR"},{label:"Churn",value:"unmeasured, needs 30 days of data"}],intent:"Fix the drip sequence, then test the LinkedIn channel."},thicket:{stage:"prelaunch",headline:{label:"Steps to launch",value:"1"},rows:[{label:"Next milestone",value:"Launch"},{label:"Blocker",value:"Stripe identity verification (you)"},{label:"Real users",value:"0"}],intent:"Launch the moment payments go live."}},f2=864e5,qo=(e,t,n)=>{const r=new Date(Date.now()-e*f2);return r.setHours(t,n,0,0),r.getTime()},p2={products:[{slug:"harbour-new",dir:"/fixtures/harbour-new",name:"Harbour (New)",oneLiner:"",repoPath:null}],items:[["m1","The four pages are built. Your signup rate per page is ready.","Built and tested on main. Please review the analytics and copy.",qo(2,16,20)],["m2","The setup cut is on today’s main, tested and green.","Safe to deploy when you say go. Needs your yes to ship.",qo(1,15,10)],["m3","Nobody has read our heaviest user or the only users.","Added a first-time user email and in-app nudges. Needs your yes to ship.",qo(1,14,40)],["m4","Merged and live: the privacy page describes the product.","You asked for clearer language. This is live.",qo(1,13,30)],["m5","Our signup number counts an event that has never occurred.","Fixed the event tracking and backfilled the last 7 days. Needs your yes to ship.",qo(0,10,3)],["m6","Standing deploys: one yes for deploying work.","CI is green and staging is verified. Approve to deploy to production?",qo(0,10,3)],["m7","I want to open a small online shop. First, I have a few…","Blocked by Stripe account verification. Your action is needed.",qo(1,11,5)],["m8","Can you set this up for me and keep it running? If I…","Blocked by missing API key in production secrets. Your action is needed.",qo(1,10,15)]].map(([e,t,n,r])=>({id:e,product:"harbour-new",productName:"Harbour (New)",status:"open",kind:"question",title:t,body:n,labels:[],priority:5,epoch:1,claim:null,createdAt:r,updatedAt:r})),approvals:[],supervisor:{paused:!1,running:[],capacity:3},config:Qo.config},m2={"harbour-new":{stage:"launched",headline:null,rows:[{label:"Next milestone",value:"20 weekly active"},{label:"Signups this week",value:"5"},{label:"Revenue",value:"$147 MRR"},{label:"Churn",value:"unmeasured, needs 30 days of data"}],intent:"Fix the drip sequence, then test the LinkedIn channel."}},g2=[{pid:4102,ppid:1,sessionId:"f-1",name:"kestrel-2c",cwd:"/Users/you/Desktop/dev/kestrel",startedAt:Se-42*Be,status:null,waitingFor:null,lastActiveAt:Se-8e3,lastSaid:"The set is inconsistent. The resumed run reused a stale card back.",product:null,productName:null,startedByZero:!1},{pid:4118,ppid:1,sessionId:"f-2",name:"onboard-c4",cwd:"/Users/you/Desktop/dev/onboard",startedAt:Se-31*Be,status:null,waitingFor:null,lastActiveAt:Se-4e4,lastSaid:"Merged and green. Now filing the one thing her reply raised.",product:null,productName:null,startedByZero:!1},{pid:4133,ppid:1,sessionId:"f-3",name:"kestrel-87",cwd:"/Users/you/Desktop/dev/kestrel",startedAt:Se-3*Nt,status:null,waitingFor:null,lastActiveAt:Se-7e4,about:"Card art pipeline: the second pass on the commons",lastSaid:"The live page renders and matches the commit.",product:"kestrel",productName:"Kestrel",startedByZero:!1},{pid:4140,ppid:1,sessionId:"f-4",name:"thicket-69",cwd:"/Users/you/Desktop/dev/thicket",startedAt:Se-2*Nt,status:null,waitingFor:null,lastActiveAt:Se-4*Be,about:"Deload weeks are landing a session early",lastSaid:"Carrying on. The cut is fixed and verified.",product:null,productName:null,startedByZero:!1},{pid:3901,ppid:1,sessionId:"f-5",name:"onboard-48",cwd:"/Users/you/Desktop/dev/onboard",startedAt:Se-6*Nt,status:"idle",waitingFor:null,lastActiveAt:Se-2*Nt,about:"Open project as electron app",lastSaid:"Done. Anything else?",product:null,productName:null,startedByZero:!1},{pid:3846,ppid:1,sessionId:"f-6",name:"thicket-46",cwd:"/Users/you/Desktop/dev/thicket",startedAt:Se-9*Nt,status:"idle",waitingFor:null,lastActiveAt:Se-3*Nt,about:"Install the commit-message skill",lastSaid:"Installed. It is on the path.",product:null,productName:null,startedByZero:!1},{pid:3102,ppid:1,sessionId:"f-7",name:"kestrel-54",cwd:"/Users/you/Desktop/dev/kestrel",startedAt:Se-50*Nt,status:"idle",waitingFor:null,lastActiveAt:Se-46*Nt,about:"Rename the economy doc",lastSaid:"Renamed.",product:null,productName:null,startedByZero:!1}],hA={ok:!0,workspace:{agentsRunning:!0,sessionsAtOnce:3,memoryGate:{on:!1,slots:null,slotsAuto:2,slotsMax:12,now:null},leftovers:{on:!1,now:"Right now finished agents have left 40 programs running; turning this on stops them, two hours from then."},strayFolders:{count:11,now:`11 copies of Kestrel were made by hand outside the folder ${Je} keeps its own in, and are holding disk until you remove them: ~/Desktop/dev/kestrel-fontsize, ~/Desktop/dev/kestrel-cardart, ~/Desktop/dev/wt-w-34eb858714 and 8 more. ${Je} never removes a folder it did not make.`},capacity:6,running:2,model:"claude-opus-5",permission:"bypassPermissions",outsideAgents:"off",permissionArgs:["--model","claude-opus-5","--allowedTools","mcp__agentbox","Bash(git fetch:*)","Bash(git push:*)","Bash(git merge:*)","--permission-mode","bypassPermissions"],accounts:[{profile:"default",label:"default",dir:null,email:"you@example.com",accountUuid:"acct-personal",live:!0,cooldownUntil:0,running:2,plan:{label:"Max 20x",max:!0}},{profile:"/Users/you/.claude-second",label:".claude-second",dir:"/Users/you/.claude-second",email:"work@example.com",accountUuid:"acct-work",live:!0,cooldownUntil:0,running:0,plan:{label:"Max 20x",max:!0}}],accountsNote:null,storePath:"/Users/you/Zero/accounts/00000000-0000-4000-8000-000000000000",homePath:"/Users/you",claudeBin:"/Users/you/.local/bin/claude",claudeFound:!0,claudeCertain:!0,claudeInstallUrl:"https://code.claude.com/docs/en/setup",engine:In,engineChoices:[xs[0]],codexModels:[],codexModelDefault:null,codexModel:null,claudeModels:uA.map(e=>({id:e.id,label:e.label,model:e.model})),codex:{found:!1,certain:!0,bin:"",url:"https://learn.chatgpt.com/docs/codex/cli",trouble:null},standingLines:20,messageRulesLines:254,projectsWithInstructions:1,projectCount:3},projects:[{slug:"kestrel",name:"Kestrel",dir:"/fixtures/kestrel",repoPath:"/Users/you/Desktop/dev/kestrel",autonomous:!0,permission:"workspace",permissionArgs:null,running:2,instructions:["The card art is the product. Never ship a card that renders wrong,","even to a test account.","","Screens are designs first. Draw it, show me, then build the one I pick."].join(`
|
|
80
|
+
`)},{slug:"onboard",name:"Onboard",dir:"/fixtures/onboard",repoPath:null,autonomous:!1,permission:"workspace",permissionArgs:null,running:0,instructions:""},{slug:"thicket",name:"Thicket",dir:"/fixtures/thicket",repoPath:null,autonomous:!1,permission:"plan",permissionArgs:["--model","claude-opus-5","--allowedTools","mcp__agentbox","--permission-mode","plan"],running:0,instructions:""}]},y2=["missing","claude","codex","nowhere","chosen","signedout"];function w2(e){return y2.includes(e)?e:null}const H0=[{id:"gpt-5.6-sol",label:"GPT-5.6-Sol"},{id:"gpt-5.6-terra",label:"GPT-5.6-Terra"},{id:"gpt-5.6-luna",label:"GPT-5.6-Luna"},{id:"gpt-5.5",label:"GPT-5.5"},{id:"gpt-5.4",label:"GPT-5.4"},{id:"gpt-5.4-mini",label:"GPT-5.4-Mini"}],U0="gpt-5.6-sol",zi="https://learn.chatgpt.com/docs/codex/cli",K0="/Users/you/.local/bin/codex",b2={claude:{"w-e5":"codex","w-b2":"codex"},codex:{"w-d4":In,"w-a1":In}},V0=[{span:"session",qualifier:null,name:"This session",percent:38,resetsText:"6:19pm",resetsOn:null,resetsAt:Se+2*Nt+40*Be,zone:"America/Los_Angeles"},{span:"week",qualifier:"all models",name:"This week",percent:71,resetsText:"4pm",resetsOn:"Sep 8",resetsAt:Se+3*24*Nt,zone:"America/Los_Angeles"}],q0=[{span:"session",qualifier:null,name:"This session",percent:33,resetsText:null,resetsOn:null,resetsAt:Se+4*Nt,zone:null},{span:"week",qualifier:null,name:"This week",percent:63,resetsText:null,resetsOn:null,resetsAt:Se+5*24*Nt,zone:null}];function x2(e){return e?e==="missing"?{codex:{found:!1,certain:!0,bin:"",url:zi,trouble:null}}:e==="signedout"?{claudeFound:!1,claudeCertain:!0,claudeBin:"/Users/you/.local/bin/claude",codexFound:!1,codexCertain:!0,codexInstallUrl:zi,codex:{found:!0,certain:!0,bin:K0,url:zi,trouble:null}}:e==="nowhere"?{claudeFound:!1,claudeCertain:!0,claudeBin:"/Users/you/.local/bin/claude",codexFound:!1,codexCertain:!0,codexInstallUrl:zi,codex:{found:!1,certain:!0,bin:"",url:zi,trouble:null}}:e==="chosen"?{claudeFound:!0,claudeCertain:!0,claudeChosen:!0,claudeBin:"/Volumes/work/tools/claude",engineChoices:xs,codexModels:H0,codexModelDefault:U0,codexModel:null,codexMode:Dh,codex:{found:!0,certain:!0,chosen:!0,bin:"/Volumes/work/tools/codex",url:zi,trouble:null,accounts:[{profile:"default",email:"you@example.com",name:null,plan:"Plus",accountId:null,signedIn:!0,chosen:!1}]}}:{engine:e,engineChoices:xs,codexModels:H0,codexModelDefault:U0,codexModel:null,codexMode:Dh,codex:{found:!0,certain:!0,bin:K0,url:zi,trouble:null,accounts:[{profile:"default",email:"you@example.com",name:null,plan:"Plus",accountId:null,signedIn:!0,chosen:!1}]}}:null}function jd(e,t){if(!t||t==="missing"||t==="nowhere"||t==="chosen"||t==="signedout")return e;const n=b2[t],r=s=>n[s]??t;return{...e,engines:{choices:xs,workspace:t,byItem:{...n}},items:e.items.map(s=>n[s.id]?{...s,engine:n[s.id]}:s),supervisor:{...e.supervisor,running:e.supervisor.running.map(s=>({...s,engine:r(s.itemId)}))},usage:{engine:t,limits:t==="codex"?q0:V0,at:Se-4*Be},usageByEngine:[{engine:"claude",limits:V0,at:Se-4*Be},{engine:"codex",limits:q0,at:Se-4*Be}]}}function k2(){const e=Date.now(),t=6e4;return{ok:!0,name:"harbour-71",total:34,omitted:29,turns:[{at:e-4*1440*t,who:"you",text:"I added a new project in Harbour called Powerup but it is not in the list. I want to see it there so i can give it tasks."},{at:e-4*1440*t+26*t,who:"it",text:"Found it. the app and Harbour read different stores: the composer lists directories under the account root, and the new product was written to the other one."},{at:e-4*1440*t+54*t,who:"you",text:"sounds good. just make sure the login is remembered between sessions now that i am signed in."},{at:e-90*t,who:"it",text:"Auth holds across a restart now, and the sync backlog is drained. One thing left that I need you on."},{at:e-40*t,who:"you",text:"go ahead"}]}}function Y0(){return{user:[{name:"screenshot-reviewer",title:"Screenshot Reviewer",line:"Gives feedback on screenshots passed directly to it, with no browser automation.",scope:"all",path:"/Users/you/.claude/agents/screenshot-reviewer.md"},{name:"new-user-qa",title:"New User QA",line:`QA agent that plays a first-time user being onboarded to ${Je}.`,scope:"all",path:"/Users/you/.claude/agents/new-user-qa.md"},{name:"localhost-qa",title:"Localhost QA",line:"Use this skill after completing any frontend or UI code changes to validate them against the running app.",scope:"all",path:"/Users/you/.claude/agents/localhost-qa.md"},{name:"qa-browser-tester",title:"QA Browser Tester",line:"Playwright-powered browser testing subagent.",scope:"all",path:"/Users/you/.claude/agents/qa-browser-tester.md"}],project:[{name:"cleanup-analyzer",title:"Cleanup Analyzer",line:"Run static analysis tools and get structured cleanup recommendations.",scope:"project",path:"/Users/you/Desktop/dev/recipe-app/.claude/agents/cleanup-analyzer.md"},{name:"docs-reviewer",title:"Docs Reviewer",line:"Review developer documentation for accuracy, consistency with the codebase, and quality.",scope:"project",path:"/Users/you/Desktop/dev/recipe-app/.claude/agents/docs-reviewer.md"},{name:"plan-checker",title:"Plan Checker",line:"Validate implementation plans against documented architecture patterns.",scope:"project",path:"/Users/you/Desktop/dev/recipe-app/.claude/agents/plan-checker.md"},{name:"userguide-reviewer",title:"Userguide Reviewer",line:"Review user guide documentation against actual system features.",scope:"project",path:"/Users/you/Desktop/dev/recipe-app/.claude/agents/userguide-reviewer.md"}],chosen:null}}function v2(){const e=Date.now(),t=3600*1e3,n={folder:"/Users/you/Desktop/dev/zero",folderName:"zero",short:"~/Desktop/dev/zero"},r={folder:"/Users/you/Desktop/dev/harbour",folderName:"harbour",short:"~/Desktop/dev/harbour"};return[["s1","this is a test",1,n],["s2","please run zero (latest version) and also give me a command to do so",30,n],["s3","see the attached screenshots (tell me if they do not load). the list only...",76,n],["s4","Can you please reopen the Powerup application, also known as Zero, using...",76,n],["s5","I'm not sure what changed, but for some reason, after the last update...",77,n],["s6","a popup keeps asking for access to the keychain every time I open...",81,n],["s7","Open the most recent version of this project as an electron app please",98,n],["s8","Please add this commit-message skill to every one of my projects...",142,r],["s9","tried to open zero here but it failed.",142,r]].map(([o,i,a,c])=>({id:o,source:"terminal",title:i,when:e-a*t,path:`/Users/you/.claude/projects/${c.folderName}/${o}.jsonl`,...c}))}const S2={"/Users/you":["Desktop","Documents","dev","Downloads"],"/Users/you/dev":["house","kestrel","orchard"],"/Users/you/dev/house":["src","tests"],"/Users":["you"]};function j2(e){const t=e==="~"||!e.startsWith("/")?"/Users/you":e,n=S2[t]??[];return{at:t,parent:t==="/"?null:t.slice(0,t.lastIndexOf("/"))||"/",home:"/Users/you",folders:n.map(r=>({name:r,path:`${t}/${r}`})),refused:t==="/Users/you"?"That is your whole home folder. Pick the folder your project’s code is in.":null}}const C2=["Desktop","Documents","Downloads","Movies","Music","Pictures","Library","Public"],N2=["/","/Applications","/Library","/System","/Users","/Volumes","/private","/tmp","/var","/etc","/usr","/bin","/sbin","/opt","/net","/cores"];function fA(e){const t=String(e??"").trim();return t?t.length>1?t.replace(/\/+$/,""):t:""}function E2(e,t){const n=fA(t);return n?e===n?"":e.startsWith(`${n}/`)?e.slice(n.length+1):null:null}function A2(e,{home:t=""}={}){const n=fA(e);if(!n)return{ok:!0};const r=n==="~"||n==="~/"?"":n.startsWith("~/")?n.slice(2):E2(n,t);return r===""?{ok:!1,reason:"home",say:"That is your whole home folder. Agents would work across everything on this computer, and the system will ask you about Downloads, Music and every app you have. Pick the folder your project’s code is in."}:r!==null&&C2.includes(r)?{ok:!1,reason:"guarded",say:`${r} holds a lot more than one project, and the system guards it, so choosing it means a run of permission panels. Pick the folder inside it that your project’s code is in.`}:N2.includes(n)?{ok:!1,reason:"system",say:`${n} is part of the system rather than one of your projects. Pick the folder your project’s code is in.`}:/^\/Volumes\/[^/]+$/.test(n)?{ok:!1,reason:"volume",say:`${n} is a whole disk rather than one project. Pick the folder your project’s code is in.`}:{ok:!0}}const Ny="Claude Code didn't report usage for this account. Check that its plan is active at claude.ai.";function T2(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{return null}}const M2={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1};function G0(e,t){if(!t)return null;try{const n=new Intl.DateTimeFormat("en-US",{timeZone:t,...M2}).formatToParts(new Date(e)),r=o=>{var i;return Number((i=n.find(a=>a.type===o))==null?void 0:i.value)},s={year:r("year"),month:r("month"),day:r("day"),hour:r("hour")%24,minute:r("minute"),second:r("second")};return Object.values(s).every(Number.isFinite)?s:null}catch{return null}}function R2(e,t,n){const r=G0(e,n),s=G0(t,n);if(r&&s)return r.year===s.year&&r.month===s.month&&r.day===s.day;const o=new Date(e),i=new Date(t);return o.getFullYear()===i.getFullYear()&&o.getMonth()===i.getMonth()&&o.getDate()===i.getDate()}const pA="any moment";function I2(e){const t=Math.max(0,Math.floor(e/6e4));if(t<1)return pA;if(t<60)return`${t}m`;const n=Math.floor(t/60);if(n>=24){const r=Math.floor(n/24),s=n%24;return s?`${r}d ${s}h`:`${r}d`}return`${n}h ${t%60}m`}function D2(e,t=Date.now()){const n=T2();return(e??[]).map(r=>({key:`${r.span}:${r.qualifier??""}`,name:r.name,used:r.percent,when:O2(r,t,n)}))}function O2(e,t,n){if(e.resetsText)return e.resetsAt&&R2(e.resetsAt,t,e.zone??n)?`Resets ${e.resetsText}`:e.resetsOn?`Resets ${e.resetsOn} at ${e.resetsText}`:`Resets ${e.resetsText}`;if(!e.resetsAt)return null;const r=I2(e.resetsAt-t);return r===pA?`Resets ${r}`:`Resets in ${r}`}const An={cannotUpdateHere:`${st} cannot update itself from where it is.`,button:"Move to Applications",title:"Updates are stuck",where:{"disk-image":`${st} is running from the disk image it was downloaded in.`,translocated:`${st} is running from a read-only copy macOS made of it.`},shortWhere:{"disk-image":`${st} can’t update itself from the disk image.`,translocated:`${st} can’t update itself from the copy macOS made.`},fix:"Moving it to your Applications folder takes a few seconds and gets updates working again.",retry:"Pressing it again tries again."};function mA(e,{short:t=!1}={}){return(t?An.shortWhere:An.where)[e]??null}const L2={terminal:"zero:terminal",agentUpdate:"zero:agent-update",snapshot:"zero:snapshot",refreshUsage:"zero:refresh-usage",assistiveTech:"zero:assistiveTech",olderItems:"zero:older-items",dashboard:"zero:dashboard",commandCatalog:"zero:command-catalog",remoteControl:"zero:remote-control",command:"zero:command",compact:"zero:compact",compactionStatus:"zero:compaction-status",answer:"zero:answer",sendNow:"zero:send-now",compose:"zero:compose",schedule:"zero:schedule",snooze:"zero:snooze",sendFeedback:"zero:send-feedback",teamSignIn:"zero:team-sign-in",teamSignInCancel:"zero:team-sign-in-cancel",teamSignInReopen:"zero:team-sign-in-reopen",teamSignOut:"zero:team-sign-out",teamSignInEmail:"zero:team-sign-in-email",teamSignUp:"zero:team-sign-up",teamCreate:"zero:team-create",teamInvite:"zero:team-invite",teamRename:"zero:team-rename",teamRemoveMember:"zero:team-remove-member",teamLeave:"zero:team-leave",teamCancelInvite:"zero:team-cancel-invite",teamAcceptInvite:"zero:team-accept-invite",teamStatus:"zero:team-status",teamShare:"zero:team-share",teamSync:"zero:team-sync",teamRoute:"zero:team-route",teamReact:"zero:team-react",teamMessage:"zero:team-message",threadEdit:"zero:thread-edit",repeats:"zero:repeats",composeRepeat:"zero:compose-repeat",setRepeat:"zero:set-repeat",endRepeat:"zero:end-repeat",pauseSupervisor:"zero:supervisor-pause",createProduct:"zero:create-product",firstRunAnswer:"zero:first-run-answer",firstRunExamples:"zero:first-run-examples",firstRunPractice:"zero:first-run-practice",firstRunPracticeEnd:"zero:first-run-practice-end",firstRunWalking:"zero:first-run-walking",openFreshUser:"zero:open-fresh-user",openDemo:"zero:open-demo",chooseFolder:"zero:choose-folder",listFolders:"zero:list-folders",folderExists:"zero:folder-exists",agentFiles:"zero:agent-files",agentFolders:"zero:agent-folders",importAgents:"zero:import-agents",agentThreads:"zero:agent-threads",importThreads:"zero:import-threads",badge:"zero:badge",cornerTag:"zero:corner-tag",bootInfo:"zero:boot-info",updateCheck:"zero:update-check",updateInstall:"zero:update-install",updateMove:"zero:update-move",notify:"zero:notify",stopSession:"zero:stop-session",runNow:"zero:run-now",reopen:"zero:reopen",instructionRead:"zero:instruction-read",instructionWrite:"zero:instruction-write",instructionHistory:"zero:instruction-history",instructionVersion:"zero:instruction-version",standingRead:"zero:standing-read",standingWrite:"zero:standing-write",messageRulesRead:"zero:message-rules-read",messageRulesWrite:"zero:message-rules-write",settingsRead:"zero:settings-read",claudeRecheck:"zero:claude-recheck",codexRecheck:"zero:codex-recheck",engineBin:"zero:engine-bin",engineSetup:"zero:engine-setup",codexAddAccount:"zero:codex-add-account",claudeAddAccount:"zero:claude-add-account",setProjectSetting:"zero:settings-set-project",setWorkspaceSetting:"zero:settings-set-workspace",projectRename:"zero:project-rename",projectArchive:"zero:project-archive",projectSeenBy:"zero:project-seen-by",projectIcon:"zero:project-icon",projectIconClear:"zero:project-icon-clear",projectInstructionsRead:"zero:project-instructions-read",projectInstructionsWrite:"zero:project-instructions-write",saveAttachments:"zero:save-attachments",stageAttachment:"zero:stage-attachment",crash:"zero:crash",track:"zero:track",sessionTrace:"zero:session-trace",itemHistory:"zero:item-history",openArtifact:"zero:open-artifact",folderPictures:"zero:folder-pictures",readDoc:"zero:read-doc",codeChange:"zero:code-change",codeFile:"zero:code-file",saveCodeFile:"zero:save-code-file",writeDoc:"zero:write-doc",railNote:"zero:rail-note",saveRailNote:"zero:save-rail-note",agentReply:"zero:agent-reply",agentReveal:"zero:agent-reveal",agentConversation:"zero:agent-conversation",scheduleAgent:"zero:schedule-agent",closeAgent:"zero:close-agent",unreplyAgent:"zero:unreply-agent",resumeAgents:"zero:resume-agents",resumeItems:"zero:resume-items",redeliver:"zero:redeliver",setProductOrder:"zero:set-product-order",setThreadPlaces:"zero:set-thread-places",setThreadPins:"zero:set-thread-pins",setProductHidden:"zero:set-product-hidden",approve:"zero:approve",phoneLink:"zero:phone-link"},Cd={onApprovalAnswered:"zero:approval-answered",onChanged:"zero:changed",onFind:"zero:find",onZoomPercent:"zero:zoom-percent",onRecovered:"zero:recovered",onOpenItem:"zero:open-item",onOpenSettings:"zero:open-settings",onScreenDetail:"zero:screen-detail",onEscapeBrowser:"zero:escape-browser",onKeyInTheFile:"zero:key-in-the-file",onPhoneChanged:"zero:phone-changed"},$2={notify:["arrivals"],track:["name"],instructionWrite:["id","text"],instructionVersion:["id","at"]},P2=["pathForFile","onWriteHeld"];let Oc=null,mc=null;const z2=()=>/iPhone|iPad/.test(navigator.userAgent),F2=()=>navigator.standalone===!0,gA=()=>"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;async function ou(e,t={}){if(!Oc)throw new Error("Not on the phone door.");const n=await fetch("/phone/alerts",{method:"POST",headers:{"content-type":"application/json","x-agentbox-token":Oc.token,"x-agentbox-device":Oc.device},body:JSON.stringify({action:e,...t})}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error??`${st} could not answer.`);return r}const B2="/relay-sw.js",yA=async()=>{var t;const e=await navigator.serviceWorker.getRegistration("/");return(t=e==null?void 0:e.active)!=null&&t.scriptURL&&new URL(e.active.scriptURL).pathname===B2?e:navigator.serviceWorker.register("/phone-sw.js",{scope:"/"})};async function $b(){if(!Oc)return"unsupported";if(!isSecureContext)return"needs-secure";if(!gA())return z2()&&!F2()?"needs-home-screen":"unsupported";if(Notification.permission==="denied")return"blocked";try{return(await ou("state")).on&&Notification.permission==="granted"?"on":"off"}catch{return"off"}}async function wA(){const e=await $b();if(e!=="off")return e;const t=await Notification.requestPermission();if(t!=="granted")return t==="denied"?"blocked":"off";const{publicKey:n}=await ou("key"),r=await yA();await navigator.serviceWorker.ready;const o=await r.pushManager.getSubscription()??await r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:V2(n)});return await ou("subscribe",{subscription:o.toJSON()}),"on"}async function _2(){var e;try{const t=await navigator.serviceWorker.getRegistration("/");await((e=await(t==null?void 0:t.pushManager.getSubscription()))==null?void 0:e.unsubscribe())}catch{}return await ou("unsubscribe"),"off"}async function W2(){return!!(await ou("test")).sent}const Ey={on:"Alerts are on. This phone hears when an agent needs you, and the icon shows how many threads are waiting.",off:"Get an alert when an agent needs you, and a count on the icon.",blocked:"Alerts are blocked for this app. Turn them on in the phone's Settings, under Notifications.","needs-home-screen":"To get alerts, add this page to your home screen (Share, then Add to Home Screen) and open it from there.","needs-secure":"Alerts need a secure connection. On the computer, open Settings, then Phone, pick Anywhere, and scan the new code.",unsupported:"This browser cannot show alerts from a web app."};function H2(e){var n,r,s,o,i,a;const t=navigator;try{e>0?(s=(r=(n=t.setAppBadge)==null?void 0:n.call(t,e))==null?void 0:r.catch)==null||s.call(r,()=>{}):(a=(i=(o=t.clearAppBadge)==null?void 0:o.call(t))==null?void 0:i.catch)==null||a.call(i,()=>{})}catch{}}function U2(e,t){Oc=e,mc=r=>{let s=0;const o=()=>{!t(r)&&++s<40&&setTimeout(o,250)};o()},gA()&&isSecureContext&&(yA().catch(()=>{}),navigator.serviceWorker.addEventListener("message",r=>{var s;((s=r.data)==null?void 0:s.agentbox)==="open-item"&&typeof r.data.id=="string"&&(mc==null||mc(r.data.id))}));const n=location.hash.match(/^#open=(.+)$/);n&&(history.replaceState(null,"",location.pathname+location.search),mc(decodeURIComponent(n[1]))),K2()}const J0="agentbox-alerts-not-now";async function K2(){const e=await $b();if(e!=="off"&&e!=="needs-home-screen")return;try{if(localStorage.getItem(J0)===e)return}catch{}if(document.getElementById("phone-alerts-ask"))return;const t=document.createElement("div");t.id="phone-alerts-ask",t.setAttribute("role","region"),t.setAttribute("aria-label","Alerts");const n=document.createElement("span");n.textContent=e==="off"?"Get an alert when an agent needs you?":Ey["needs-home-screen"],t.appendChild(n);const r=()=>t.remove();if(e==="off"){const o=document.createElement("button");o.type="button",o.textContent="Turn on",o.onclick=async()=>{o.disabled=!0;try{const i=await wA();if(i==="on")return r();n.textContent=Ey[i],i==="off"?o.disabled=!1:o.remove()}catch(i){n.textContent=`Alerts could not be turned on: ${i.message??i}`,o.disabled=!1}},t.appendChild(o)}const s=document.createElement("button");s.type="button",s.className="quiet",s.textContent="Not now",s.onclick=()=>{try{localStorage.setItem(J0,e)}catch{}r()},t.appendChild(s),document.body.appendChild(t)}function V2(e){const t=atob(e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4)),n=new Uint8Array(new ArrayBuffer(t.length));for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}const bA=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),q2=`${QE}-doc`,xA=`${QE}-img`,kA=Object.freeze([q2,...ZE.map(e=>`${bA(e)}-doc`)]),vA=Object.freeze([xA,...ZE.map(e=>`${bA(e)}-img`)]),Y2=Object.freeze([...kA,...vA]),G2=[[kA,"doc"],[vA,"img"]];function J2(e,t){if(!e)return e;for(const[n,r]of G2)for(const s of n){const o=`${s}://file/`;if(e.startsWith(o))return`/f/${t}/${r}/${e.slice(o.length)}`}return e}const Rm=["src","poster"],Im="data-phone-img",X0=new WeakSet;function Dm(e){e.setAttribute(Im,e.complete?e.naturalWidth>0?"ready":"failed":"loading"),!X0.has(e)&&(X0.add(e),e.addEventListener("load",()=>e.setAttribute(Im,"ready")),e.addEventListener("error",()=>e.setAttribute(Im,"failed")))}function X2(e=document){const t=n=>{if(n instanceof Element){n instanceof HTMLImageElement&&Dm(n);for(const r of n.querySelectorAll("img"))Dm(r)}};t(e instanceof Document?e.documentElement:e),new MutationObserver(n=>{for(const r of n)if(r.type==="attributes")r.target instanceof HTMLImageElement&&Dm(r.target);else for(const s of r.addedNodes)t(s)}).observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["src"]})}function Q2(e,t=document){const n=o=>{for(const i of Rm){const a=o.getAttribute(i);if(!a)continue;const c=J2(a,e);c!==a&&o.setAttribute(i,c)}},r=o=>{if(o instanceof Element){n(o);for(const i of o.querySelectorAll(Rm.map(a=>`[${a}*="://file/"]`).join(",")))n(i)}};r(t instanceof Document?t.documentElement:t);const s=new MutationObserver(o=>{for(const i of o)if(i.type==="attributes")n(i.target);else for(const a of i.addedNodes)r(a)});return s.observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:Rm}),()=>s.disconnect()}const Q0="x-agentbox-token",Nd="agentbox-token",Z2=/^(127\.\d+\.\d+\.\d+|localhost|\[::1\])$/,ah=(e=location.hostname)=>!Z2.test(e);function ez(){const e="agentbox-device";try{const t=localStorage.getItem(e);if(t)return t;const n=Array.from(crypto.getRandomValues(new Uint8Array(9)),r=>r.toString(16).padStart(2,"0")).join("");return localStorage.setItem(e,n),n}catch{return"private-tab"}}function Z0(){if(document.getElementById("phone-locked-out"))return;const e=document.createElement("div");e.id="phone-locked-out",e.setAttribute("role","alert"),e.innerHTML=`<div><strong>This phone is disconnected.</strong><p>The key was reset on the computer. Open ${st} there, go to Settings, then Phone, and scan the new code.</p></div>`,document.body.appendChild(e)}function tz(){var r;const e=new URL(location.href),t=ah()?((r=/(?:^#|&)k=([A-Za-z0-9_-]{24,})/.exec(e.hash))==null?void 0:r[1])??null:null,n=e.searchParams.get("token")??t;if(n&&ah()){try{localStorage.setItem(Nd,n)}catch{}return n}if(!n&&ah())try{const s=localStorage.getItem(Nd);if(s)return s}catch{}if(n){e.searchParams.delete("token"),history.replaceState(null,"",e.toString());try{sessionStorage.setItem(Nd,n)}catch{}return n}try{return sessionStorage.getItem(Nd)}catch{return null}}function nz(){if(typeof window>"u"||window.zero)return!1;const e=tz();if(!e)return!1;const t=ez(),n=ah();if(n){const u=document.createElement("link");u.rel="manifest",u.href=`/manifest.webmanifest?token=${encodeURIComponent(e)}`,document.head.appendChild(u),document.documentElement.dataset.door="phone";const d=()=>requestAnimationFrame(()=>{(scrollX||scrollY)&&scrollTo(0,0)});addEventListener("orientationchange",()=>{d(),setTimeout(d,350)}),addEventListener("resize",d),visualViewport==null||visualViewport.addEventListener("resize",d),U$(),X2(),fetch("/file-key",{headers:{[Q0]:e}}).then(h=>h.ok?h.json():null).then(h=>{h!=null&&h.key&&Q2(h.key)}).catch(()=>{})}const r=async(u,d)=>{const h=await fetch(`/api/${encodeURIComponent(u)}`,{method:"POST",headers:{"content-type":"application/json",[Q0]:e,"x-agentbox-device":t},body:JSON.stringify(d??null)});if(h.status===403&&n&&Z0(),!h.ok){const f=await h.json().catch(()=>({}));throw new Error(f.error??`${st} could not answer ${u}.`)}return h.json()},s={};for(const[u,d]of Object.entries(L2)){const h=$2[u];s[u]=h?(...f)=>r(d,Object.fromEntries(h.map((p,m)=>[p,f[m]]))):f=>r(d,f)}for(const u of P2)s[u]=()=>null;n&&(s.badge=u=>(H2(Number(u)||0),Promise.resolve(null)));const o=new Map;for(const[u,d]of Object.entries(Cd))s[u]=h=>{const f=o.get(d)??new Set;return o.set(d,f),f.add(h),()=>f.delete(h)};const i=new EventSource(`/events?token=${encodeURIComponent(e)}&device=${encodeURIComponent(t)}`);i.onerror=()=>{n&&i.readyState===EventSource.CLOSED&&Z0()};const a=(u,d)=>{for(const h of o.get(u)??[])try{h(d)}catch{}},c=Y$(q$,u=>a(Cd.onChanged,u));return i.onmessage=u=>{var h,f;let d;try{d=JSON.parse(u.data)}catch{return}if(d.channel){if(n&&d.channel===Cd.onChanged){c((h=d.args)==null?void 0:h[0]);return}a(d.channel,(f=d.args)==null?void 0:f[0])}},window.zero=s,n&&U2({token:e,device:t},u=>{const d=o.get(Cd.onOpenItem);if(!(d!=null&&d.size))return!1;for(const h of d)try{h({id:u})}catch{}return!0}),typeof document<"u"&&(document.documentElement.dataset.shell="tab"),!0}nz();async function hn(e){var t;if(!((t=window.zero)!=null&&t.teamSignIn))return{ok:!1,error:"This build has no team cloud set up."};try{return await e()}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)??n)}}}const rz=typeof location>"u"?"":location.search,$t=new URLSearchParams(rz),e1=XP($t.get("modelUpdates")==="fail"),$e=$t.has("fixtures")||typeof window>"u"||!window.zero,gc=$t.get("fixtures")==="empty",t1=Math.max(0,Math.min(99,Number($t.get("working")??0)||0)),sz=$t.get("fixtures")==="crowded",n1=$t.get("fixtures")==="mock",Ki=w2($t.get("engines")),r1=["Crown","Meadow","Delete","Cascade","Orchard","Kestrel","Kestrel (2)","Harbour","Harbour (2)","Harbour (3)","Harbour (empty duplicate)","Harbour (empty duplicate 2)","Harbour (New)","Lantern","Personal","Repro Product","Repro Product (2)","Repro Product (3)","Test","Test (2)","The Frontier","Untitled"],Nn=`quit and reopen ${Je} to change settings`,Vr={ok:!0,workspace:{agentsRunning:!0,sessionsAtOnce:0,capacity:0,running:0,model:null,permission:"custom",codexMode:"auto",permissionArgs:[],outsideAgents:"off",accounts:[],accountsNote:null,diagnostics:!0,diagnosticsDestination:!1,adhdMode:!1,cornerTag:!0,storePath:"",homePath:"",claudeBin:"",claudeFound:!1,claudeCertain:!1,claudeInstallUrl:"",standingLines:0,messageRulesLines:0,projectsWithInstructions:0,projectCount:0},projects:[]},Tn=structuredClone(hA),s1=x2(Ki);s1&&Object.assign(Tn.workspace,structuredClone(s1));if($t.get("memory")){const e=$t.get("memory")==="held";Object.assign(Tn.workspace,{running:6,capacity:6,agentsTotal:6,agentsAuto:!0}),Tn.workspace.memoryGate={...Tn.workspace.memoryGate,on:!0,reading:{heavy:e?0:1,waiting:e?3:0,pressure:e?"tight":"normal",usedPct:e?74:48,asked:488,waited:36,refused:0,holding:e}}}const o1={"org-blocked":"Signed in, but its organization has turned Claude Code off. Only an admin of that workspace can turn it back on.","subscription-ended":"Signed in, but its Claude subscription has ended. Renew it at claude.ai to use this account again."},ul=$t.get("account")??"";if(ul==="unreadable"){const[e,t]=Tn.workspace.accounts;e&&(e.chosen=!1),t&&(t.chosen=!0)}if(o1[ul]){const[e,t]=Tn.workspace.accounts;e&&(e.chosen=!1),t&&Object.assign(t,{chosen:!0,live:!1,state:ul,trouble:{cause:ul,since:Date.now(),note:o1[ul]},...ul==="subscription-ended"?{plan:{label:"Subscription ended",max:!1}}:{}})}function Om(e,t){var r,s,o;const n=Tn.workspace;if(e==="workspace")if(t.key==="sessionsAtOnce")n.sessionsAtOnce=Math.max(1,Math.min(n.slotsMax??12,Number(t.value)||1)),n.capacity=n.sessionsAtOnce,n.agentsAuto=!1;else if(t.key==="memoryGate"&&n.memoryGate)n.memoryGate={...n.memoryGate,on:!!t.value,now:t.value?"Memory is fine. Nothing heavy running.":null};else if(t.key==="cleanupLeftovers"&&n.leftovers)n.leftovers={on:!!t.value,now:t.value?"Finished agents have left 6 programs running. 4 stop in 1 h 40 m; 2 are kept.":null};else if(t.key==="memoryGateSlots"&&n.memoryGate)n.memoryGate={...n.memoryGate,slots:t.value===null?null:Math.max(1,Math.min(n.memoryGate.slotsMax,Number(t.value)||1))};else if(t.key==="activeAccount"){const i=((r=t.value)==null?void 0:r.engine)==="codex"?((s=n.codex)==null?void 0:s.accounts)??[]:n.accounts;for(const a of i)a.chosen=a.profile===((o=t.value)==null?void 0:o.profile)}else n[t.key]=t.value;else{const i=Tn.projects.find(a=>a.slug===t.product);i&&(i[t.key]=t.value)}return Tn.workspace.projectsWithInstructions=Tn.projects.filter(i=>i.instructions.trim()).length,structuredClone(Tn)}function Ay(e){const t={ready:{phase:"ready",newVersion:"0.2.0",percent:100,ready:!0,readyAt:Date.now()-372e4},downloading:{phase:"downloading",newVersion:"0.2.0",percent:47},source:{phase:"ready",ready:!0,source:!0,currentVersion:"5c6afa7",newVersion:"9e1b204",changes:["Teammates get a restart prompt when main moves","The Team page loads faster","Sign-in retries once on a slow network"],behind:4,percent:null,readyAt:Date.now()-72e4},installing:{phase:"installing",ready:!1,installing:!0,source:!0,currentVersion:"5c6afa7",newVersion:"9e1b204",changes:["Teammates get a restart prompt when main moves"],behind:1,readyAt:Date.now()-72e4},current:{phase:"current"},error:{phase:"error",error:"Could not reach the internet."},"disk-image":{phase:"error",error:An.cannotUpdateHere,canMove:!0,place:"disk-image"},translocated:{phase:"error",error:An.cannotUpdateHere,canMove:!0,place:"translocated"},"move-failed":{phase:"error",error:An.cannotUpdateHere,canMove:!0,place:"disk-image",moveError:"The move did not work."},unsupported:{phase:"unsupported",source:!0,currentVersion:"5c6afa7",error:"This folder has changes of your own in it, so it does not update itself."}};return{phase:"idle",currentVersion:"0.1.0",newVersion:null,percent:null,error:null,checkedAt:Date.now()-4*6e4,readyAt:null,ready:!1,...t[e]??{}}}const q={isFixtures:$e,async assistiveTech(){var e,t;if($e)return!1;try{return!!await((t=(e=window.zero)==null?void 0:e.assistiveTech)==null?void 0:t.call(e))}catch{return!1}},async snapshot(){if(gc){const e={...structuredClone(Qo),items:[],approvals:[],supervisor:{paused:!1,running:[],capacity:3}};return t1&&(e.supervisor.running=Array.from({length:t1},(t,n)=>({itemId:`w-working-${n+1}`,product:"kestrel",startedAt:Date.now()-(n+1)*6e4,tail:["tool: Read"]}))),jd(e,Ki)}if(n1)return jd(structuredClone(p2),Ki);if(sz){const e=structuredClone(Qo);return e.products=r1.map(t=>({slug:t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),dir:`/fixtures/${t}`,name:t,oneLiner:"",repoPath:null})),e.supervisor.productOrder=e.products.map(t=>t.slug),e.supervisor.hiddenProducts=($t.get("hidden")??"").split(",").filter(Boolean),$t.has("approvals")||(e.approvals=[]),jd(e,Ki)}if($e){const e=structuredClone(Qo);e.items=[...e.items,...structuredClone(d2)],e.agents=structuredClone(g2),$t.has("stale")&&(e.restartNeeded={files:["main/supervisor.mjs","main/ipc.mjs","preload.cjs","shared/rank.mjs"],since:Date.now()-2.9*24*36e5});const t=$t.get("update");return t&&(e.update=Ay(t)),$t.has("approvals")||(e.approvals=[]),jd(e,Ki)}return window.zero.snapshot()},async refreshUsage(){var e,t,n;if($e){if($t.get("account")==="unreadable")return{ok:!1,error:Ny};const r=((e=Qo.usageByEngine)==null?void 0:e.find(s=>s.engine==="claude"))??(((t=Qo.usage)==null?void 0:t.engine)==="claude"?Qo.usage:null);return r?{ok:!0,reading:{...structuredClone(r),profile:"default",at:Date.now()}}:{ok:!1,error:"No usage reading yet."}}if(!((n=window.zero)!=null&&n.refreshUsage))return{ok:!1,error:Nn};try{return await window.zero.refreshUsage()}catch{return{ok:!1,error:Ny}}},async olderItems(e,t=50){var n;return $e||!((n=window.zero)!=null&&n.olderItems)?{items:[],more:!1}:window.zero.olderItems({offset:e,limit:t})},async updateCheck(){return $e?Ay($t.get("update")||"ready"):window.zero.updateCheck()},async updateInstall(){return $e?{started:!0}:window.zero.updateInstall()},async updateMove(){return $e?$t.get("update")==="move-failed"?{moved:!1,error:"The move did not work."}:{moved:!0,error:null}:window.zero.updateMove()},async agentReply(e){var t,n;return $e?$t.has("agentUnsure")?{ok:!1,reason:"That agent is not listening any more."}:{ok:!0,delivered:!0,working:!0}:((n=(t=window.zero)==null?void 0:t.agentReply)==null?void 0:n.call(t,e))??{ok:!1,reason:"The message could not be handed over."}},async agentReveal(e){var t,n;return $e?{ok:!0,name:"CNVS"}:((n=(t=window.zero)==null?void 0:t.agentReveal)==null?void 0:n.call(t,e))??{ok:!1,reason:`${st} cannot tell which window it is running in.`}},async agentConversation(e){var t,n;return $e?k2():((n=(t=window.zero)==null?void 0:t.agentConversation)==null?void 0:n.call(t,e))??{ok:!1,reason:"That conversation could not be read."}},async sessionTrace(e){var t,n;return $e?{sessions:c2[e.id]??[]}:((n=(t=window.zero)==null?void 0:t.sessionTrace)==null?void 0:n.call(t,e))??{sessions:[]}},async resolveDoc(e){if($e&&["artifact-layout-sample.change","review-bundle.change"].includes(e.src))return{ok:!0,opened:e.src};if($e&&e.src==="artifact-layout-sample.md")return{ok:!0,opened:e.src};if($e&&e.product==="onboard"&&["designs/w-n13/the-first-row.html","/fixtures/onboard/designs/w-n13/the-first-row.html"].includes(e.src))return{ok:!0,opened:e.src,url:"/fixtures/onboard/designs/w-n13/the-first-row.html"};const t=window.zero;return t!=null&&t.openArtifact?t.openArtifact({...e,mode:"resolve"}):{ok:!1,error:`quit and reopen ${Je} to open documents here`}},async readDoc(e){if($e&&e.src==="artifact-layout-sample.md")return{ok:!0,text:GP,mtime:0};const t=window.zero;return t!=null&&t.readDoc?t.readDoc(e):{ok:!1,error:`quit and reopen ${Je} to open documents here`}},async codeChange(e){if($e&&e.src==="review-bundle.change")return{ok:!0,change:JP};if($e&&e.src==="artifact-layout-sample.change")return{ok:!0,change:aA};const t=window.zero;return t!=null&&t.codeChange?t.codeChange(e):{ok:!1,error:`quit and reopen ${Je} to open changes here`}},async codeFile(e){const t=window.zero;return t!=null&&t.codeFile?t.codeFile(e):{ok:!1,error:`quit and reopen ${Je} to edit files here`}},async saveCodeFile(e){const t=window.zero;return t!=null&&t.saveCodeFile?t.saveCodeFile(e):{ok:!1,error:`quit and reopen ${Je} to save this file`}},async writeDoc(e){const t=window.zero;return t!=null&&t.writeDoc?t.writeDoc(e):{ok:!1,error:`quit and reopen ${Je} to save this file`}},async railNote(e){const t=window.zero;return t!=null&&t.railNote?t.railNote({product:e}):{ok:!1,error:`quit and reopen ${Je} to keep a note here`}},async saveRailNote(e){const t=window.zero;return t!=null&&t.saveRailNote?t.saveRailNote(e):{ok:!1,error:`quit and reopen ${Je} to save this note`}},async openArtifactExternally(e){const t=window.zero;return t!=null&&t.openArtifact?t.openArtifact(e):(window.open(e.src,"_blank"),{ok:!0})},async itemHistory(e){if($e)return{ok:!0,lines:u2[e.id]??[]};const t=window.zero;return t!=null&&t.itemHistory?t.itemHistory(e):{ok:!1,lines:[],error:`quit and reopen ${Je} to see this`}},async dashboard(e){return n1?m2[e]??null:$e?h2[e]??null:window.zero.dashboard(e)},async agentUpdate(e,t){var n;return $e?$t.has("modelUpdates")?e1.action(e,t):{engine:e,state:"current"}:(n=window.zero)!=null&&n.agentUpdate?window.zero.agentUpdate({engine:e,action:t}):{engine:e,state:"unknown"}},async terminal(e){var t;if($e&&e.product==="@agent-update"&&$t.has("modelUpdates"))return e1.terminal(e);if($e)throw new Error("Terminal requires the desktop app and a real task.");if(!((t=window.zero)!=null&&t.terminal))throw new Error(`Restart ${Je} to use the terminal.`);return window.zero.terminal(e)},async commandCatalog(e){return $e?["code-review","loop","simplify","verify"]:window.zero.commandCatalog(e)},async command(e){return $e?{state:"done",at:Date.now(),text:"Command completed.",name:e.text}:window.zero.command(e)},async compact(e){return $e?{state:"done",at:Date.now()}:window.zero.compact(e)},async remoteControl(e){return $e?null:window.zero.remoteControl(e)},async compactionStatus(e){if($e){const t=$t.get("command-state");return t&&t!=="menu"?{state:t,at:Date.now()}:null}return window.zero.compactionStatus(e)},async answer(e){return $e?null:window.zero.answer(e)},async sendNow(e){return $e?{ok:!0,interrupted:!0}:window.zero.sendNow(e)},async sendFeedback(e){var t;return $e?{ok:!0}:(t=window.zero)!=null&&t.sendFeedback?window.zero.sendFeedback(e):{ok:!1,error:`Restart ${st} to send feedback.`}},async teamSignIn(){return hn(()=>window.zero.teamSignIn())},async teamSignInCancel(){return hn(()=>window.zero.teamSignInCancel())},async teamSignInReopen(){return hn(()=>window.zero.teamSignInReopen())},async teamSignOut(){return hn(()=>window.zero.teamSignOut())},async teamSignInEmail(e,t){return hn(()=>window.zero.teamSignInEmail({email:e,password:t}))},async teamSignUp(e,t,n){return hn(()=>window.zero.teamSignUp({name:e,email:t,password:n}))},async teamCreate(e){return hn(()=>window.zero.teamCreate({name:e}))},async teamAcceptInvite(e){return hn(()=>window.zero.teamAcceptInvite({teamId:e}))},async teamInvite(e){return hn(()=>window.zero.teamInvite({email:e}))},async teamRename(e){return hn(()=>window.zero.teamRename({name:e}))},async teamRemoveMember(e){return hn(()=>window.zero.teamRemoveMember({personId:e}))},async teamLeave(){return hn(()=>window.zero.teamLeave())},async teamCancelInvite(e){return hn(()=>window.zero.teamCancelInvite({email:e}))},async teamStatus(e){return hn(()=>window.zero.teamStatus(e))},async teamShare(e){return hn(()=>window.zero.teamShare(e))},async teamSync(){return hn(()=>window.zero.teamSync())},async teamRoute(e){return hn(()=>window.zero.teamRoute(e))},async teamReact(e){return hn(()=>window.zero.teamReact(e))},async teamMessage(e,t,n){return hn(()=>window.zero.teamMessage({to:e,body:t,priority:n}))},async threadEdit(e,t,n){var r;if($e||!((r=window.zero)!=null&&r.threadEdit))return{ok:!0};try{return await window.zero.threadEdit({product:e,id:t,patch:n})}catch(s){return{ok:!1,error:String((s==null?void 0:s.message)??s)}}},async setThreadPlaces(e){var t;$e||!((t=window.zero)!=null&&t.setThreadPlaces)||await window.zero.setThreadPlaces({places:e})},async setThreadPins(e){var t;$e||!((t=window.zero)!=null&&t.setThreadPins)||await window.zero.setThreadPins({pins:e})},async compose(e){var t;if($e){const n=Date.now();return{id:`w-fixture${n.toString(36)}`,product:e.product,productName:((t=Qo.products.find(r=>r.slug===e.product))==null?void 0:t.name)??e.product,status:"open",title:e.title,body:e.body,kind:e.kind??"directive",labels:["founder"],priority:e.priority??5,epoch:1,claim:null,...e.runAt?{runAt:e.runAt}:{},...e.model?{model:e.model}:{},...e.engine?{engine:e.engine}:{},createdAt:n,updatedAt:n}}return window.zero.compose(e)},async firstRunAnswer(e){if($e)return{line:"A fixture project, with no folder under it to read.",found:!1};const t=window.zero;return t!=null&&t.firstRunAnswer?t.firstRunAnswer(e):null},async firstRunExamples(e){if($e)return null;const t=window.zero;return t!=null&&t.firstRunExamples?t.firstRunExamples(e):null},async firstRunPractice(){if($e)return null;const e=window.zero;return e!=null&&e.firstRunPractice?e.firstRunPractice():null},async firstRunPracticeEnd(){var t;if($e)return;const e=window.zero;try{await((t=e==null?void 0:e.firstRunPracticeEnd)==null?void 0:t.call(e))}catch{}},async firstRunWalking(e){if($e)return;const t=window.zero;if(t!=null&&t.firstRunWalking)try{await t.firstRunWalking({walking:e})}catch{}},async openFreshUser(e=!0,t=!0){if($e)return{ok:!1,error:"Not in this preview."};const n=window.zero;if(!(n!=null&&n.openFreshUser))return{ok:!1,error:`This window is running an older ${Je}. Quit it and open it again.`};try{return await n.openFreshUser({withAgents:e,withTools:t})}catch(r){return{ok:!1,error:(r==null?void 0:r.message)??"It could not be opened."}}},async openDemo(){if($e)return{ok:!1,error:"Not in this preview."};const e=window.zero;if(!(e!=null&&e.openDemo))return{ok:!1,error:`This window is running an older ${Je}. Quit it and open it again.`};try{return await e.openDemo()}catch(t){return{ok:!1,error:(t==null?void 0:t.message)??"It could not be opened."}}},async schedule(e){return $e?null:window.zero.schedule(e)},async snooze(e){var t;if($e)return null;if(!((t=window.zero)!=null&&t.snooze))throw new Error("Restart the app to use Later");return window.zero.snooze(e)},async scheduleAgent(e){var n,r;if($e)return{ok:!0,runAt:e.runAt};const t=await((r=(n=window.zero)==null?void 0:n.scheduleAgent)==null?void 0:r.call(n,e));if(!(t!=null&&t.ok))throw new Error("the app could not keep that moment");return t},async unreplyAgent(e){var n,r;return $e?{ok:!0,repliedAt:0}:await((r=(n=window.zero)==null?void 0:n.unreplyAgent)==null?void 0:r.call(n,e))??{ok:!1,repliedAt:0}},async closeAgent(e){var n,r;if($e)return{ok:!0,doneThrough:e.through};const t=await((r=(n=window.zero)==null?void 0:n.closeAgent)==null?void 0:r.call(n,e));if(!(t!=null&&t.ok))throw new Error("the app could not close that row");return t},async repeats(){return gc?[]:$e?W0:window.zero.repeats()},async composeRepeat(e){return $e?null:window.zero.composeRepeat(e)},async setRepeat(e){if($e){const t=W0.find(n=>n.id===e.id);return t?(Object.assign(t,e.rule),t):null}return window.zero.setRepeat(e)},async endRepeat(e){return $e?null:window.zero.endRepeat(e)},async settings(){if($e)return structuredClone(Tn);const e=window.zero;return e!=null&&e.settingsRead?e.settingsRead():{...Vr,ok:!1,error:Nn}},async recheckClaude(){var n,r,s;const e="https://code.claude.com/docs/en/setup";if($e){const o=Tn.workspace;return{found:!!o.claudeFound,certain:!!o.claudeCertain,url:o.claudeInstallUrl||e}}const t=window.zero;if(!(t!=null&&t.claudeRecheck))return{found:!1,certain:!1,url:e};try{const o=await t.claudeRecheck();return o!=null&&o.ok?{found:!!((n=o.workspace)!=null&&n.claudeFound),certain:((r=o.workspace)==null?void 0:r.claudeCertain)===!0,url:((s=o.workspace)==null?void 0:s.claudeInstallUrl)||e}:{found:!1,certain:!1,url:e}}catch{return{found:!1,certain:!1,url:e}}},async addCodexAccount(){if($e)return{ok:!0,command:"CODEX_HOME=/tmp/.codex-2 codex login",home:"/tmp/.codex-2"};const e=window.zero;if(!(e!=null&&e.codexAddAccount))return{ok:!1,error:Nn};try{return await e.codexAddAccount()??{ok:!1,error:"could not add an account"}}catch(t){return{ok:!1,error:String((t==null?void 0:t.message)??t)}}},async addClaudeAccount(){if($e)return{ok:!0,command:"CLAUDE_CONFIG_DIR=/tmp/.claude-2 claude auth login",home:"/tmp/.claude-2"};const e=window.zero;if(!(e!=null&&e.claudeAddAccount))return{ok:!1,error:Nn};try{return await e.claudeAddAccount()??{ok:!1,error:"could not add an account"}}catch(t){return{ok:!1,error:String((t==null?void 0:t.message)??t)}}},async recheckCodex(){var t,n;if($e){const r=Tn.workspace.codex;return{found:!!(r!=null&&r.found),certain:!!(r!=null&&r.certain)}}const e=window.zero;if(!(e!=null&&e.codexRecheck))return{found:!1,certain:!1};try{const r=await e.codexRecheck();return r!=null&&r.ok?{found:!!((t=r.workspace)!=null&&t.found),certain:((n=r.workspace)==null?void 0:n.certain)===!0}:{found:!1,certain:!1}}catch{return{found:!1,certain:!1}}},async engineBin(e,t){if($e)return{...Vr,ok:!0,canceled:!0};const n=window.zero;if(!(n!=null&&n.engineBin))return{...Vr,ok:!1,error:Nn};try{return await n.engineBin({engine:e,...t?{action:t}:{}})}catch(r){return{...Vr,ok:!1,error:String((r==null?void 0:r.message)??r)}}},async engineSetup(e,t){const n={engine:t,phase:"ready",error:null,log:"",found:!0,signedIn:!0};if($e&&Ki==="nowhere")return{engine:t,phase:"idle",error:null,log:"",found:!1,signedIn:!1};if($e&&Ki==="signedout")return{engine:t,phase:"idle",error:null,log:"",found:t==="codex",signedIn:!1};const r=window.zero;if(!(r!=null&&r.engineSetup))return n;try{const s=await r.engineSetup({action:e,engine:t});return s!=null&&s.ok?{engine:t,phase:s.phase??"idle",error:s.error??null,log:s.log??"",found:!!s.found,signedIn:!!s.signedIn}:{...n,phase:"failed",found:!1,signedIn:!1,error:(s==null?void 0:s.error)??"Setup could not start."}}catch(s){return{...n,phase:"failed",found:!1,signedIn:!1,error:String((s==null?void 0:s.message)??s)}}},async setProjectSetting(e){if($e)return Om("project",e);const t=window.zero;return t!=null&&t.setProjectSetting?t.setProjectSetting(e):{...Vr,ok:!1,error:Nn}},async renameProject(e){if($e)return Om("project",{product:e.product,key:"name",value:e.name});const t=window.zero;return t!=null&&t.projectRename?t.projectRename(e):{...Vr,ok:!1,error:Nn}},async pickProjectIcon(e){if($e)return{...Vr,ok:!0,canceled:!0};const t=window.zero;return t!=null&&t.projectIcon?t.projectIcon(e):{...Vr,ok:!1,error:Nn}},async clearProjectIcon(e){if($e)return{...Vr,ok:!0};const t=window.zero;return t!=null&&t.projectIconClear?t.projectIconClear(e):{...Vr,ok:!1,error:Nn}},async setProjectSeenBy(e){const t=window.zero;return t!=null&&t.projectSeenBy?t.projectSeenBy(e):{ok:!1,error:Nn}},async archiveProject(e){if($e){const n=Tn;if(n.archivedProjects??(n.archivedProjects=[]),e.archived){const r=r1.map(o=>({slug:o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),name:o,dir:`/fixtures/${o}`})).find(o=>o.slug===e.product),s=n.projects.find(o=>o.slug===e.product)??r;s&&!n.archivedProjects.some(o=>o.slug===e.product)&&(n.projects=n.projects.filter(o=>o.slug!==e.product),n.archivedProjects.push({slug:s.slug,name:s.name,dir:s.dir}))}else{const r=n.archivedProjects.find(o=>o.slug===e.product),s=hA.projects.find(o=>o.slug===e.product);n.archivedProjects=n.archivedProjects.filter(o=>o!==r),r&&s&&n.projects.push(structuredClone(s))}return structuredClone(n)}const t=window.zero;return t!=null&&t.projectArchive?t.projectArchive(e):{...Vr,ok:!1,error:Nn}},async importAgents(e){if($e)return{added:e.agents.length,already:0};const t=window.zero;if(!(t!=null&&t.importAgents)){if(t!=null&&t.setProjectSetting)try{await t.setProjectSetting({product:e.product,key:"agents",value:e.agents})}catch{}return{added:0,already:0}}try{const n=await t.importAgents(e);return{added:Number((n==null?void 0:n.added)??0),already:Number((n==null?void 0:n.already)??0)}}catch{return{added:0,already:0}}},async setWorkspaceSetting(e){if($e)return Om("workspace",e);const t=window.zero;return t!=null&&t.setWorkspaceSetting?t.setWorkspaceSetting(e):{...Vr,ok:!1,error:Nn}},async projectInstructions(e){if($e){const n=Tn.projects.find(r=>r.slug===e);return{ok:!0,text:(n==null?void 0:n.instructions)??""}}const t=window.zero;return t!=null&&t.projectInstructionsRead?t.projectInstructionsRead({product:e}):{ok:!1,text:"",error:Nn}},async writeProjectInstructions(e,t){if($e){const r=Tn.projects.find(s=>s.slug===e);return r&&(r.instructions=t),{ok:!1,error:"fixtures have nowhere to save this"}}const n=window.zero;return n!=null&&n.projectInstructionsWrite?n.projectInstructionsWrite({product:e,text:t}):{ok:!1,error:Nn}},async createProduct(e){return $e?null:window.zero.createProduct(e)},async chooseFolder(e){if($e){if($t.has("refusedFolder")){const r=A2("~");return{path:null,refused:r.ok?void 0:r.say}}return{path:"/Users/you/Desktop/dev/house"}}const t=window.zero;if(!(t!=null&&t.chooseFolder))return{path:null};const n=await t.chooseFolder({startIn:e});return{path:(n==null?void 0:n.path)??null,refused:(n==null?void 0:n.refused)??void 0,browse:(n==null?void 0:n.browse)===!0}},async listFolders(e,t=!1){if($e)return j2(e??"~");const n=window.zero;if(!(n!=null&&n.listFolders))return{at:e??"~",parent:null,home:"~",folders:[],unreadable:Nn};const r=await n.listFolders({at:e,showHidden:t});return{at:(r==null?void 0:r.at)??e??"~",parent:(r==null?void 0:r.parent)??null,home:(r==null?void 0:r.home)??"~",folders:Array.isArray(r==null?void 0:r.folders)?r.folders:[],refused:(r==null?void 0:r.refused)??null,unreadable:(r==null?void 0:r.unreadable)??void 0}},async folderExists(e){if($e)return!1;const t=window.zero;if(!(t!=null&&t.folderExists))return!0;const n=await t.folderExists({path:e});return!!(n!=null&&n.exists)},async agentFiles(e){if($e){const n=Y0();return gc?{user:[],project:[],chosen:null}:$t.has("noProjectAgents")?{...n,project:[]}:n}const t=window.zero;if(!(t!=null&&t.agentFiles))return{user:[],project:[],chosen:null};try{const n=await t.agentFiles(e);return{user:(n==null?void 0:n.user)??[],project:(n==null?void 0:n.project)??[],chosen:(n==null?void 0:n.chosen)??null}}catch{return{user:[],project:[],chosen:null}}},async agentFolders(){if($e)return gc||$t.has("noOtherFolders")?[]:[{folder:"/home/dev/sidecar-desktop",short:"~/Desktop/dev/sidecar-desktop",name:"sidecar-desktop",count:4,agents:Y0().project.map(t=>({...t,path:`/home/dev/sidecar-desktop/.claude/agents/${t.name}.md`}))}];const e=window.zero;if(!(e!=null&&e.agentFolders))return[];try{const t=await e.agentFolders();return Array.isArray(t==null?void 0:t.folders)?t.folders:[]}catch{return[]}},async agentThreads(){if($e)return gc||$t.has("noThreads")?[]:v2();const e=window.zero;if(!(e!=null&&e.agentThreads))return[];try{const t=await e.agentThreads();return Array.isArray(t==null?void 0:t.threads)?t.threads:[]}catch{return[]}},async importThreads(e){if($e)return{added:e.threads.length,already:0};const t=window.zero;if(!(t!=null&&t.importThreads))return{added:0,already:0};try{const n=await t.importThreads(e);return{added:Number((n==null?void 0:n.added)??0),already:Number((n==null?void 0:n.already)??0)}}catch{return{added:0,already:0}}},async pauseSupervisor(e){if(!$e)return window.zero.pauseSupervisor(e)},onChanged(e){return $e?()=>{}:window.zero.onChanged(e)},async phoneLink(e){if($e)return null;const t=window.zero;if(!(t!=null&&t.phoneLink))return null;try{return await t.phoneLink(e)}catch{return null}},onPhoneChanged(e){const t=window.zero;return $e||!(t!=null&&t.onPhoneChanged)?()=>{}:t.onPhoneChanged(e)}},Ji=Object.freeze(Object.defineProperty({__proto__:null,RESTART_NOTE:Nn,api:q,updateShape:Ay},Symbol.toStringTag,{value:"Module"}));function oz(e){return e.fromTask&&e.index>=0?{index:e.index,excludeId:e.id}:null}function iz(e){return e.onBoard||e.view==="inbox"}function az(e,t){if(!t)return null;const n=e.filter(o=>o.id!==t.excludeId),r=Math.min(t.index,n.length-1),s=n[r];return s?{item:s,index:r}:null}const Ty=[{name:"model",description:"Set the AI model for Claude Code",menuDescription:null,whole:!0,argumentHint:"<model>",aliases:[]},{name:"effort",description:"Set effort level for model usage",menuDescription:null,whole:!0,argumentHint:null,aliases:[]},{name:"fast",description:"Toggle fast mode",menuDescription:null,whole:!1,argumentHint:"[on|off]",aliases:[]},{name:"goal",description:"Set a goal — keep working until the condition is met",menuDescription:null,whole:!0,argumentHint:null,aliases:[]},{name:"context",description:"Show current context usage",menuDescription:null,whole:!0,argumentHint:null,aliases:[]},{name:"usage",description:"Show session cost, plan usage, and what's contributing to your limits",menuDescription:"Show session cost and plan usage",whole:!0,argumentHint:null,aliases:["cost","stats"]},{name:"mcp",description:"Manage MCP servers",menuDescription:null,whole:!0,argumentHint:"[reconnect|enable|disable [<server>|all]]",aliases:[]},{name:"compact",description:"Free up context by summarizing the conversation so far",menuDescription:null,whole:!0,argumentHint:"<optional custom summarization instructions>",aliases:[]},{name:"advisor",description:"Let Claude consult a stronger model at key moments",menuDescription:null,whole:!0,argumentHint:null,aliases:[]},{name:"autocompact",description:"Configure the auto-compact window size",menuDescription:null,whole:!0,argumentHint:"[auto|<tokens>]",aliases:[]},{name:"output-style",description:"List output styles or switch to one",menuDescription:null,whole:!0,argumentHint:"[style]",aliases:[]},{name:"recap",description:"Generate a one-line session recap now",menuDescription:null,whole:!0,argumentHint:null,aliases:[]},{name:"reload-skills",description:"Pick up skills added or changed on disk during this session",menuDescription:null,whole:!0,argumentHint:null,aliases:[]},{name:"list-agents",description:"List subagents, teammates, and other Claude sessions you can message",menuDescription:null,whole:!0,argumentHint:null,aliases:["peers"]},{name:"focus",description:"Toggle focus view: just your prompt, summary, and response",menuDescription:null,whole:!0,argumentHint:"[on|off]",aliases:[]},{name:"reload-plugins",description:"Activate pending plugin changes in the current session",menuDescription:null,whole:!0,argumentHint:"[--force]",aliases:[]}];function SA(e){return[e.name,...e.aliases??[]]}function lz(e){return(e.menuDescription||e.description).replace(/\s*—\s*/g,", ")}function cz(e){return`/${e.name} `}function jA(e,t=[]){if(typeof e!="string"||!e.startsWith("/"))return null;const n=e.match(/^\/([a-z][a-z0-9:_-]*)(?:(\s[\s\S]*))?$/i);if(!n)return null;const r=n[1].toLowerCase(),s=r==="review"&&t.includes("code-review")?"code-review":r,o=Ty.find(a=>SA(a).includes(s))??(t.includes(s)?{name:s}:null);if(!o)return null;const i=(n[2]??"").trim();return i?`/${o.name} ${i}`:`/${o.name}`}function uz(e,t,n){return!e||e.agent||(n??In)!==In?!1:jA(t)!==null}function dz(e,t){return e?t?t.product===e.product&&t.id===e.id?e:null:e:null}function hz(e,t){return!t&&e?"inbox":"stay"}function fz(e,t,n){if(!t)return null;const r=e.find(s=>s.id===t.id&&s.product===t.product);return!r||r===t?null:n||(r.updatedAt??0)!==(t.updatedAt??0)?r:null}const pz="clean",i1="repeat:";function rp(e){const t=((e==null?void 0:e.labels)??[]).find(n=>typeof n=="string"&&n.startsWith(i1));return t?t.slice(i1.length):null}function sp(e){return!!rp(e)&&((e==null?void 0:e.labels)??[]).includes(pz)}const mz=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Pb(e){return!e||typeof e.at!="string"||!/^([01]\d|2[0-3]):[0-5]\d$/.test(e.at)?!1:e.every==="day"||e.every==="weekday"?!0:e.every==="week"?Number.isInteger(e.on)&&e.on>=0&&e.on<=6:!1}function To(e){if(!Pb(e))return"Once";const t=CA(e.at);return e.every==="day"?`daily at ${t}`:e.every==="weekday"?`weekdays at ${t}`:`${mz[e.on]}s at ${t}`}function CA(e){const[t,n]=e.split(":").map(Number),r=new Date;return r.setHours(t,n,0,0),r.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}).toLowerCase().replace(/\s/g,"")}function NA(e,t){return e.every==="day"?!0:e.every==="weekday"?t.getDay()>=1&&t.getDay()<=5:t.getDay()===e.on}function gz(e=Date.now()){const t=new Date(e),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${n}-${r}`}function yz(e,t=Date.now()){if(!Pb(e))return null;const[n,r]=e.at.split(":").map(Number),s=new Date(t),o=new Date(s.getFullYear(),s.getMonth(),s.getDate(),n,r,0,0);o.getTime()>t&&o.setDate(o.getDate()-1);for(let i=0;i<8;i++){if(NA(e,o))return gz(o.getTime());o.setDate(o.getDate()-1)}return null}function zb(e,t=Date.now()){if(!Pb(e)||e.endedAt)return null;const[n,r]=e.at.split(":").map(Number),s=new Date(t),o=new Date(s.getFullYear(),s.getMonth(),s.getDate(),n,r,0,0);o.getTime()<=t&&o.setDate(o.getDate()+1);for(let i=0;i<8;i++){if(NA(e,o))return o.getTime();o.setDate(o.getDate()+1)}return null}function a1(e,t){return!e||!t?e===t:e.every===t.every&&e.at===t.at&&(e.on??null)===(t.on??null)}const wz={morning:8,afternoon:14,evening:18,night:20},bz=new Set(["at","on","by","around","about","for","until","till","til","the","of","and"]),xz=new Set(["tomorrow","tmrw","tmr","tom","tmw","tomorow","tommorow","tommorrow"]),l1=/^(?:(sun)(?:day)?|(mon)(?:day)?|(tue)(?:s|sday)?|(wed)(?:s|nesday)?|(thu)(?:r|rs|rsday)?|(fri)(?:day)?|(sat)(?:urday)?)$/,c1=/^(?:(jan)(?:uary)?|(feb)(?:ruary)?|(mar)(?:ch)?|(apr)(?:il)?|(may)|(jun)e?|(jul)y?|(aug)(?:ust)?|(sep)(?:t|tember)?|(oct)(?:ober)?|(nov)(?:ember)?|(dec)(?:ember)?)$/,Ed={m:"min",min:"min",mins:"min",minute:"min",minutes:"min",h:"hour",hr:"hour",hrs:"hour",hour:"hour",hours:"hour",d:"day",day:"day",days:"day",w:"week",wk:"week",wks:"week",week:"week",weeks:"week",mo:"month",mos:"month",month:"month",months:"month",y:"year",yr:"year",yrs:"year",year:"year",years:"year"},Lh=["one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],EA=["twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],AA=["first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth"],kz=new RegExp(`\\b(?:(${EA.join("|")})(?:[\\s-](${Lh.slice(0,9).join("|")}))?|(${Lh.join("|")}))\\b`,"g"),vz=new RegExp(`\\b(?:(twenty|thirty)[\\s-])?(${AA.join("|")})\\b|\\b(twentieth|thirtieth)\\b`,"g");function Sz(e){let t=(e??"").toLowerCase().trim().replace(/[.!?]+$/,"").replace(/,/g," ").replace(/@/g," at ").replace(/\s+/g," ");return t=t.replace(/\b(?:half an? (?:hour|hr)|an? half (?:hour|hr)|half (?:hour|hr))\b/g,"30 minutes").replace(/\b(?:the )?day after (?:tomorrow|tmrw)\b/g,"overmorrow").replace(/\b(?:end of (?:the )?(?:day|today)|end of business|close of business|eod|eob|cob)\b/g,"eod").replace(/\b(?:end of (?:the )?week|eow)\b/g,"eow").replace(/\bfirst thing(?: in the morning)?\b/g,"morning").replace(/\bin the (morning|afternoon|evening)\b/g,"$1").replace(/\bat night\b/g,"night").replace(/\s*o'?clock\b/g,"").replace(/\bfrom now\b/g,"").replace(/\b(?:a )?couple(?: of)?\b/g,"2").replace(/\b(?:a )?few\b/g,"3").replace(/\b(?:midday|lunch ?time|lunch)\b/g,"noon").replace(/^(in )?(min|minute|hr|hour|day|wk|week|month|yr|year)$/,"$11 $2"),t=t.replace(vz,(n,r,s,o)=>o?o==="twentieth"?"20th":"30th":`${(r==="twenty"?20:r==="thirty"?30:0)+AA.indexOf(s)+1}th`),t=t.replace(kz,(n,r,s,o)=>String(o?Lh.indexOf(o)+1:(EA.indexOf(r)+2)*10+(s?Lh.indexOf(s)+1:0))),t=t.replace(/\b(\d+|an?) ([a-z]+) and a half\b/g,(n,r,s)=>`${/^\d/.test(r)?r:1}.5 ${s}`).replace(/\b(\d+) and a half\b/g,"$1.5"),t=t.replace(/(\d)\s*([ap])\.?(?:\s?m\.?)?(?=\s|$)/g,"$1$2m"),t=t.replace(/\bhalf past (\d{1,2})(am|pm)?\b/g,"$1:30$2").replace(/\bquarter past (\d{1,2})(am|pm)?\b/g,"$1:15$2").replace(/\bquarter to (\d{1,2})(am|pm)?\b/g,(n,r,s)=>`${Number(r)-1||12}:45${s??""}`).replace(/\b(\d{1,2}) ([0-5]\d)(am|pm)\b/g,"$1:$2$3").replace(/\bat (\d{1,2}) ([0-5]\d)\b/g,"at $1:$2"),t.split(" ").filter(Boolean)}function Dr(e,t=0){const n=new Date(e);return n.setHours(0,0,0,0),n.setDate(n.getDate()+t),n}function yc(e,t){const n=new Date(e).getDay();return Dr(e,(t-n+7)%7||7)}function u1(e,t){const n=new Date(e),r=n.getDate();n.setDate(1),n.setMonth(n.getMonth()+t);const s=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return n.setDate(Math.min(r,s)),n}function yl(e,t,n){const r=new Date(e,t,n);return r.getMonth()===t&&r.getDate()===n?r:null}const $h=e=>e.slice(1).findIndex(Boolean);function zn(e,t,n=0){return!t||e.date?!1:(e.date=t,e.roll=n,!0)}function Lm(e,t){return!t||e.clock||e.fallback!==void 0?!1:(e.clock=t,!0)}function jz(e){const t=e.match(/^(\d{1,2})(?:[:.](\d{2}))?(am|pm)?$/);if(!t)return null;const n=Number(t[1]),r=Number(t[2]??0),s=t[3];if(r>59)return null;if(s)return n>=1&&n<=12?{h:n,m:r,mer:s,sure:!0}:null;if(n>23)return null;const o=n===0||n>=13||t[1].length===2&&t[1].startsWith("0");return{h:n,m:r,sure:o}}function Cz(e,t){let n=0,r=0,s=0,o=0,i=!1,a=!1;for(;;){let c=t+n;i&&e[c]==="and"&&(c+=1);const u=Nz(e,c);if(!u)break;const{n:d,unit:h}=u;if(!Number.isInteger(d)&&h!=="min"&&h!=="hour")return null;(h==="min"||h==="hour")&&(a=!0),h==="min"?r+=d*6e4:h==="hour"?r+=d*36e5:h==="day"?s+=d:h==="week"?s+=d*7:h==="month"?o+=d:o+=d*12,n=c-t+u.used,i=!0}return i?{used:n,ms:r,days:s,months:o,clocked:a}:null}function Nz(e,t){const n=e[t];if(!n)return null;const r=n.match(/^(\d+)h(\d{1,2})m?$/);if(r)return{n:Number(r[1])+Number(r[2])/60,unit:"hour",used:1};const s=n.match(/^(\d+(?:\.\d+)?)([a-z]+)$/);if(s&&Ed[s[2]])return{n:Number(s[1]),unit:Ed[s[2]],used:1};const o=/^\d+(?:\.\d+)?$/.test(n)?Number(n):n==="a"||n==="an"?1:null;return o!==null&&e[t+1]&&Ed[e[t+1]]?{n:o,unit:Ed[e[t+1]],used:2}:null}function Ez(e,t,n){var f;const r=p=>{var m;return(m=p==null?void 0:p.match(/^(\d{1,2})(?:st|nd|rd|th)?$/))==null?void 0:m[1]},s=p=>p&&/^\d{4}$/.test(p)?Number(p):null;let o=-1,i,a=0;const c=e[t].match(c1);if(c&&r(e[t+1]))o=$h(c),i=r(e[t+1]),a=2;else if(r(e[t])){const p=e[t+1]==="of"?1:0,m=(f=e[t+1+p])==null?void 0:f.match(c1);if(!m)return null;o=$h(m),i=r(e[t]),a=2+p}else return null;const u=s(e[t+a]);u!==null&&(a+=1);const d=Dr(n);let h=yl(u??d.getFullYear(),o,Number(i));return h&&u===null&&h<d&&(h=yl(d.getFullYear()+1,o,Number(i))),{used:a,date:h}}function Az(e,t,n,r){const s=e[t],o=e[t+1];if(s==="in")return n.needDuration=!0,1;if(s==="this"||s==="coming")return n.thisDay=!0,1;if(bz.has(s))return 1;const i=Cz(e,t);if(i)return n.needDuration=!1,n.any=!0,i.clocked?n.exact!==void 0||i.months?0:(n.exact=i.ms+i.days*864e5,i.used):zn(n,u1(Dr(r,i.days),i.months))?i.used:0;if(n.needDuration)return 0;if(n.any=!0,s==="today")return zn(n,Dr(r))?1:0;if(xz.has(s))return zn(n,Dr(r,1))?1:0;if(s==="overmorrow")return zn(n,Dr(r,2))?1:0;if(s==="tonight")return n.period?0:(n.period="evening",1);if(s==="morning"||s==="afternoon"||s==="evening"||s==="night")return n.period?0:(n.period=s,1);if(s==="next"){const f=o==null?void 0:o.match(l1);if(f)return zn(n,yc(r,$h(f)))?2:0;if(o==="week")return zn(n,yc(r,1))?2:0;if(o==="weekend")return zn(n,yc(r,6))?2:0;if(o==="month"){const p=Dr(r);return p.setDate(1),zn(n,u1(p,1))?2:0}return 0}const a=s.match(l1);if(a){const f=$h(a);return n.thisDay&&f===new Date(r).getDay()?zn(n,Dr(r),7)?1:0:zn(n,yc(r,f))?1:0}if(s==="weekend"){const f=new Date(r).getDay()===6;return zn(n,f?Dr(r,1):yc(r,6))?1:0}if(s==="eow")return n.fallback!==void 0||n.clock?0:(n.fallback=17,zn(n,Dr(r,(5-new Date(r).getDay()+7)%7),7)?1:0);if(s==="eod")return n.fallback!==void 0||n.clock?0:(n.fallback=17,1);if(s==="noon")return Lm(n,{h:12,m:0,mer:"pm",sure:!0})?1:0;if(s==="midnight")return n.midnight=!0,Lm(n,{h:0,m:0,sure:!0})?1:0;const c=Ez(e,t,r);if(c)return zn(n,c.date)?c.used:0;const u=s.match(/^(\d{1,2})(?:st|nd|rd|th)$/);if(u){const f=Dr(r),p=Number(u[1]),m=p<f.getDate()?f.getMonth()+1:f.getMonth();return zn(n,yl(f.getFullYear(),m,p))?1:0}const d=s.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);if(d)return zn(n,yl(Number(d[1]),Number(d[2])-1,Number(d[3])))?1:0;const h=s.match(/^(\d{1,2})\/(\d{1,2})(?:\/(\d{2}|\d{4}))?$/);if(h){const f=Dr(r),p=h[3]?Number(h[3].length===2?`20${h[3]}`:h[3]):f.getFullYear();let m=yl(p,Number(h[1])-1,Number(h[2]));return m&&!h[3]&&m<f&&(m=yl(p+1,Number(h[1])-1,Number(h[2]))),zn(n,m)?1:0}return Lm(n,jz(s))?1:0}function Tz(e,t,n){if(e.sure)return e.mer==="pm"?e.h%12+12:e.mer==="am"?e.h%12:e.h;if(e.h===12)return 12;if(t.period)return t.period==="morning"?e.h:e.h+12;if(e.h<=6)return e.h+12;if(t.date)return e.h;const r=new Date(n);return r.setHours(e.h,e.m,0,0),r.getTime()>n?e.h:e.h+12}function Mz(e,t=Date.now()){const n=Sz(e);if(!n.length)return null;const r={any:!1,roll:1};for(let i=0;i<n.length;){const a=Az(n,i,r,t);if(!a)return null;i+=a}if(!r.any||r.needDuration)return null;if(r.exact!==void 0){if(r.date||r.clock||r.period||r.fallback!==void 0)return null;const i=t+r.exact;return i>t?i:null}const s=new Date(r.date??Dr(t)),o=r.date?r.roll:1;return r.clock?s.setHours(Tz(r.clock,r,t),r.clock.m,0,0):r.period?s.setHours(wz[r.period],0,0,0):s.setHours(r.fallback??8,0,0,0),r.midnight&&r.date&&s.setDate(s.getDate()+1),s.getTime()<=t&&o&&s.setDate(s.getDate()+o),s.getTime()>t?s.getTime():null}function Bs(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n}s`;const r=Math.floor(n/60);if(r<60)return`${r}m`;const s=Math.floor(r/60);if(s<24)return`${s}h`;const o=Math.floor(s/24);return o<7?`${o}d`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function iu(e,t=Date.now()){const n=new Date(e);return Math.floor((au(t)-au(e))/864e5)===0?n.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"short",day:"numeric"}).toUpperCase()}function op(e,t=Date.now()){const n=Math.floor((au(t)-au(e))/864e5);return n===0?"Today":n===-1?"Tomorrow":n<0?new Date(e).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"}):n===1?"Yesterday":n<7?"Last 7 days":"Earlier"}function au(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function My(e){if(!e)return[];const t=e.split(`
|
|
81
|
+
`);let n=!1;const r=[];for(const s of t){if(/^#{1,4}\s/.test(s)){n=/option/i.test(s);continue}if(!n)continue;const o=s.match(/^\s*(\d+)[.)]\s+(.*)$/);o&&r.push({n:Number(o[1]),text:o[2].trim(),recommended:/\(recommended\)/i.test(o[2])})}return r}const Ph=(e,t)=>{var n,r;return((r=(n=e.wrote)==null?void 0:n[t])==null?void 0:r.ts)??0};function ip(e){const t=My(e.result).length>0,n=My(e.note).length>0;return t&&n?Ph(e,"note")>Ph(e,"result")?"note":"result":t?"result":n?"note":"body"}function wl(e){return My(e[ip(e)])}function Fb(e){var o,i;if(!wl(e).length)return!1;const t=ip(e),n=Ph(e,t);if((t==="body"?["result"]:["result","note"]).some(a=>a!==t&&Ph(e,a)>n))return!1;if(!e.answer||e.answer==="(withdrawn)")return!0;const s=((i=(o=e.wrote)==null?void 0:o.answer)==null?void 0:i.ts)??0;return n>s}function Rz(e){const t=e.replace(/\s*\(recommended\)\s*/i,"").trim().replace(/[.!]+$/,"");return/^close (this|the) (task|thread)$/i.test(t)}function Iz(e,t){return e.trim()?t?"typed":"refuse":"selected"}function ap(e,t=Date.now()){const n=Mz(e??"",t);return n===null?null:Fz(n,t)}const Dz=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Oz=String.raw`(?:sun|sunday|sundays|mon|monday|mondays|tue|tues|tuesday|tuesdays|wed|weds|wednesday|wednesdays|thu|thur|thurs|thursday|thursdays|fri|friday|fridays|sat|saturday|saturdays)`,Lz=String.raw`(?:sundays|mondays|tuesdays|wednesdays|thursdays|fridays|saturdays)`,TA=String.raw`(?:(?:every|each)\s+(?:other\s+day|weekday|weekdays|day|morning|night|evening|${Oz})|daily|weekdays?|${Lz})`,$z=new RegExp(`^${TA}\\b`,"i"),Pz=new RegExp(`\\b(${TA})\\s+(?:at\\s+)?([0-9][^,.]*)`,"i"),d1=/other day|night|evening/i;function Ry(e){const t=(e??"").split(`
|
|
82
|
+
`)[0].trim().toLowerCase().replace(/\s+/g," ");if(!t)return null;for(const r of t.split(",")){const s=r.trim().match($z);if(!s)continue;if(d1.test(s[0]))return{unreadable:!0};const i=r.trim().slice(s[0].length).trim().match(/^at\s+(.+)$/);return i?$m(s[0],i[1]):$m(s[0],"")}const n=t.match(Pz);return n?d1.test(n[1])?{unreadable:!0}:$m(n[1],n[2]):null}function MA(e){const t=(e??"").trim().replace(/\s+/g," ");if(!t)return null;const n=t.match(/^(.+?) (?:at )?(\d{1,2}(?::\d{2})? ?(?:am|pm)?)$/i);return n&&Ry(`${n[1]} at ${n[2]}`)||Ry(t)}function $m(e,t){const n=t?zz(t):"08:00";if(!n)return{unreadable:!0};const r=e.toLowerCase();if(/weekday/.test(r))return Pm({every:"weekday",at:n});const s=Dz.findIndex(o=>new RegExp(`\\b${o.slice(0,3)}`).test(r));return s>=0&&!/every day|each day|daily|morning/.test(r)?Pm({every:"week",on:s,at:n}):Pm({every:"day",at:n})}function zz(e){const t=e.trim().match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\b/);if(!t)return null;let n=Number(t[1]);const r=Number(t[2]??0),s=t[3];return r>59||n>23?null:(s==="pm"&&n<12&&(n+=12),s==="am"&&n===12&&(n=0),`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`)}function Pm(e){return{rule:e,label:To(e)}}function Fz(e,t){const n=new Date(e),r=Math.floor((e-au(t))/864e5),s=n.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),o=r===0?"today":r===1?"tomorrow":n.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"});return{ts:e,label:`${o}, ${s}`}}function RA(e,t){return e.replace(/^#{1,4}\s.*$/gm,n=>t==="keep"?n.replace(/^#{1,4}\s*/,""):"").replace(/!\[[^\]]*\]\([^)]*\)/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/[*_`>#]/g,"").split(`
|
|
83
|
+
`).map(n=>n.trim()).filter(Boolean).join(" ")}function IA(e){return e?RA(e,"drop"):""}function Cc(e){return e?RA(e,"keep"):""}function DA(e){return IA(e).slice(0,200)}const Bz=32;function Iy(e){const t=(e??"").split(`
|
|
84
|
+
`).map(r=>IA(r)).filter(Boolean);return t.find(r=>!(r.length<=Bz&&r.endsWith(":")))??t[0]??""}const _z=["result","title","body"];function Wz(e,t){return _z.some(n=>{var s;const r=(s=e==null?void 0:e.wrote)==null?void 0:s[n];return!!r&&r.source==="agent"&&(r.ts??0)>t})}function OA(e){var r,s;const t=e==null?void 0:e.answer;if(!t||t==="(withdrawn)")return!1;const n=((s=(r=e==null?void 0:e.wrote)==null?void 0:r.answer)==null?void 0:s.ts)??0;return n>0&&((e==null?void 0:e.answeredThrough)??0)>=n?Wz(e,n):!1}const Hz=[/organi[sz]ation has disabled/i,/disabled for (your|this) organi[sz]ation/i,/ask your admin/i],Uz=[/oauth/i,/session expired/i,/could not be refreshed/i,/failed to authenticate/i,/not logged in/i,/please run\s*\/?login/i,/invalid api key/i,/unauthoriz/i,/subscription access/i],Kz=[/usage limit/i,/rate limit/i,/quota/i,/out of credit/i,/insufficient credit/i,/hit your [a-z]{0,12} ?limit/i,/session limit/i,/weekly limit/i,/\busageLimitExceeded\b/],Vz=[/went to sleep/i,/connection (closed|lost|dropped)/i,/response stopped arriving/i,/may be incomplete/i,/econnreset|enotfound|etimedout|econnrefused|enetunreach|ehostunreach|eai_again/i,/error sending request for url/i,/failed to send websocket request/i,/unable to connect/i,/can.{0,3}t reach the api/i,/timed out/i,/\b(429|500|502|503|529)\b/,/overloaded/i],qz=[/untrusted/i,/trust this folder/i,/not a git repos/i,/not inside a trusted directory/i,/skip-git-repo-check/i],Yz=[/model is not supported when using codex with a chatgpt account/i,/not a model the plan of the codex account/i];function Gz(e){const t=String(e??"");return t.trim()?Hz.some(n=>n.test(t))?"org-blocked":Yz.some(n=>n.test(t))?"model-not-on-plan":Uz.some(n=>n.test(t))?"signed-out":Kz.some(n=>n.test(t))?"at-limit":qz.some(n=>n.test(t))?"workspace":Vz.some(n=>n.test(t))?"interrupted":"unknown":"unknown"}function Jz(e){const t=Math.max(0,Math.trunc(e??0)),n=t!==1;return`${t} task${n?"s":""} ${n?"have":"has"} not been able to run`}const h1={"signed-out":"This run stopped because the account was signed out.","org-blocked":"This run stopped because Claude Code will not run on that account.","at-limit":"This run stopped because the account hit its usage limit.",workspace:"This run stopped because it would not start in this project's folder.",interrupted:"This run was cut off in the middle.","model-not-on-plan":"This run stopped because that account's plan does not include the model.",unknown:"This run stopped before it finished."};function Xz(e){return h1[Gz(e)]??h1.unknown}const lp="trouble";function pn(e){return!!e&&e.id===lp}function Qz(e){if(e.cause==="at-limit"){const t=/at (\d[^.]*)\./.exec(e.next);return t?`back at ${t[1]}`:"back when the limit resets"}return e.cause==="signed-out"?"need a login":e.cause==="org-blocked"?"need an admin":e.cause==="subscription-ended"?"need a renewed subscription":e.cause==="workspace"?"need the folder trusted":e.cause==="interrupted"?"retrying on their own":e.cause==="model-not-on-plan"?"need another model":"stopped, still trying"}function zh(e){var t;return(t=e.byCause)!=null&&t.length?e.byCause:[{cause:e.cause==="mixed"?"unknown":e.cause,count:e.count??1,what:e.message,next:e.remedy,act:null,hers:!1}]}function Zz(e){return e.count??zh(e).reduce((t,n)=>t+n.count,0)}function eF(e){return Jz(Zz(e))}function tF(e){return zh(e).map(t=>`${t.count} ${Qz(t)}`).join(" · ")}function nF(e,t=[]){const n=new Map(t.map(a=>[a.id,a])),r=e.stopped??(e.ids??[]).map(a=>({id:a,cause:"unknown"})),s=[tF(e)];for(const a of zh(e)){const c=r.filter(u=>u.cause===a.cause);s.push(`**${a.what}.** ${a.next}`),c.length&&s.push(c.map(u=>{const d=n.get(u.id);return`- ${d?d.title:"A task that is no longer in your inbox"}${d!=null&&d.productName?` (${d.productName})`:""}`}).join(`
|
|
85
|
+
`))}const o=new Set(zh(e).map(a=>a.cause)),i=r.filter(a=>!o.has(a.cause));return i.length&&(s.push(`**${i.length} more.** ${st} keeps trying on its own.`),s.push(i.map(a=>{var c;return`- ${((c=n.get(a.id))==null?void 0:c.title)??"A task that is no longer in your inbox"}`}).join(`
|
|
86
|
+
`))),s.join(`
|
|
87
|
+
|
|
88
|
+
`)}function rF(e,t=[]){return{id:lp,product:"",productName:"",status:"open",title:eF(e),body:nF(e,t),kind:"trouble",labels:[],priority:5,epoch:0,claim:null,createdAt:e.since,updatedAt:e.since}}const lu={verb:"Done",short:"Done"},bo=e=>(e==null?void 0:e.start)==="later",cu=e=>(e.labels??[]).includes("founder"),na=e=>e.answer&&e.answer!=="(withdrawn)"?e.answer:void 0,sF=["title","body","answer"];function oF(e){var n;let t=0;for(const r of sF){const s=(n=e.wrote)==null?void 0:n[r];(s==null?void 0:s.source)==="founder"&&(t=Math.max(t,s.ts??0))}return t}function LA(e){var n;if(e.status!=="open"||!cu(e)||na(e)||!e.result)return!1;const t=(n=e.wrote)==null?void 0:n.result;return!!t&&t.source==="agent"&&(t.ts??0)>oF(e)}function lh(e,t=Date.now()){var n,r;return e.status==="done"?!1:(e.runAt??0)>t&&((r=(n=e.wrote)==null?void 0:n.runAt)==null?void 0:r.source)!=="founder"}function iF(e,t=0){var s,o,i,a;const n=((o=(s=e.wrote)==null?void 0:s.runAt)==null?void 0:o.source)==="founder"?e.runAt??0:0,r=((a=(i=e.wrote)==null?void 0:i.snoozedUntil)==null?void 0:a.source)==="founder"?e.snoozedUntil??0:0;return Math.max(n,r,t)}function $A(e,{deliveredThrough:t=0,hiddenUntil:n=0,now:r=Date.now(),live:s=!1,shipping:o=!1,waitingOn:i=[]}={}){var a,c,u,d;return bo(e)||s||o||n>r||sp(e)||Lc(e,i)?!1:lh(e,r)||e.status!=="done"&&e.status!=="claimed"&&OA(e)||LA(e)?!0:e.status==="done"?!cu(e)&&!na(e)||((c=(a=e.wrote)==null?void 0:a.status)==null?void 0:c.source)==="founder"?!1:(((d=(u=e.wrote)==null?void 0:u.status)==null?void 0:d.ts)??e.updatedAt??0)>t:e.status==="blocked"?!0:e.kind==="question"||e.kind==="review"?!na(e):Fh(e)?!1:e.status==="open"&&!cu(e)?!na(e):!1}function Fh(e){return e.status!=="open"||cu(e)||na(e)||e.kind==="question"||e.kind==="review"?!1:!!e.parent}function Lc(e,t){var n,r;return t.length>0&&e.status==="blocked"&&((r=(n=e.wrote)==null?void 0:n.status)==null?void 0:r.source)!=="founder"}function PA(e,t,n=new Set([e.id])){const r=s=>(Array.isArray(s.blockedBy)?s.blockedBy:[]).filter(o=>o&&o!==s.id&&t.has(o)&&t.get(o).status!=="done");return r(e).filter(s=>{if(n.has(s))return!1;const o=t.get(s);return r(o).length?PA(o,t,new Set(n).add(s)).length>0:!0})}const aF=24*36e5;function lF(e,t=Date.now()){var s,o;const n=new Map(e.map(i=>[i.id,i])),r=new Set;for(const i of e){if(!Fh(i)||t-(i.createdAt??0)<=aF)continue;const a=i.parent?n.get(i.parent):void 0;a&&(a.status==="done"&&((o=(s=a.wrote)==null?void 0:s.status)==null?void 0:o.source)==="founder"||r.add(a.id))}return r}function $c(e,{deferredUntil:t=0,now:n=Date.now(),live:r=!1,shipping:s=!1}={}){return bo(e)?!1:r||s?!0:t>n?!1:e.status==="claimed"?!0:OA(e)||LA(e)?!1:e.status==="open"&&na(e)?!0:e.status==="open"&&e.kind!=="question"&&e.kind!=="review"&&cu(e)}function cF(e,{deferredUntil:t=0,now:n=Date.now(),live:r=!1}={}){return $c(e,{deferredUntil:t,now:n,live:r})}function uF(e,{deliveredThrough:t=0,hiddenUntil:n=0,deferredUntil:r=0,now:s=Date.now(),live:o=!1,shipping:i=!1,waitingOn:a=[]}={}){return $c(e,{deferredUntil:r,now:s,live:o,shipping:i})||n>s&&e.status!=="done"||Lc(e,a)?!0:$A(e,{deliveredThrough:t,hiddenUntil:n,now:s})}function f1(e){return e==="blocked"||e==="done"?"open":void 0}function p1(e){return{answer:"(withdrawn)",status:e}}function dF(e,t=Date.now()){return Math.max(e.runAt??0,e.snoozedUntil??0)>t}function m1(e,t={}){return t.shift?"range":e==="box"||t.meta||t.ctrl?"toggle":"open"}function zA(e,t){var i,a,c,u,d,h,f,p,m;if(e.id===lp)return zs((e.body??"").split(`
|
|
89
|
+
`)[0].trim());const n=(i=e.wrote)==null?void 0:i.answer;if(e.answer&&(n!=null&&n.by)&&n.ts>=Math.max(((c=(a=e.wrote)==null?void 0:a.body)==null?void 0:c.ts)??0,((d=(u=e.wrote)==null?void 0:u.result)==null?void 0:d.ts)??0))return zs(Iy(e.answer));const r=t==="done"||e.status==="done",s=(((f=(h=e.wrote)==null?void 0:h.result)==null?void 0:f.ts)??0)>(((m=(p=e.wrote)==null?void 0:p.body)==null?void 0:m.ts)??0),o=!!e.result&&(r||s);return zs(DA(o?e.result:fF(e)))}function Co(e){var o,i;const t=(e.label??"").trim();if(!t)return e.title??"";const n=(o=e.wrote)==null?void 0:o.title,r=(i=e.wrote)==null?void 0:i.label;return!!n&&!!r&&n.source==="founder"&&n.ts>r.ts&&(e.title??"").trim()||t}function hF(e,t=1){return t>1?`${t} items`:Co(e)}function fF(e){const t=e.body??"",n=(e.title??"").replace(/…$/,"").trim();return n&&t.startsWith(n)?t.slice(n.length).trim():t}const Bh=112;function zs(e,t=Bh){if(e.length<=t)return e;const n=e.slice(0,t+1),r=Math.max(n.lastIndexOf(". "),n.lastIndexOf("? "),n.lastIndexOf("! "));if(r>40)return e.slice(0,r+1);const s=n.lastIndexOf(" ");return`${e.slice(0,s>40?s:t).trimEnd()}…`}function g1(e){return(t,n)=>e(n)-e(t)||n.updatedAt-t.updatedAt}const pF="Urgent",mF="Everything else";function gF(e,t=!1){return t?[]:e==="inbox"?[{key:"R",word:"Reply"},{key:"E",word:lu.short},{key:"L",word:"Later"}]:e==="snoozed"?[{key:"E",word:"Back to inbox"},{key:"L",word:"Later"}]:[{key:"⏎",word:"Open"}]}function yF(e,t,n){if(!t)return e;const r=t.key;return r?t.rows.includes(n)?e.filter(s=>s.key.toUpperCase()===r.toUpperCase()):[]:[]}const FA=100;function wF(e){if(!Array.isArray(e))return[];const t=new Set,n=[];for(const r of e)typeof r!="string"||!r||t.has(r)||(t.add(r),n.push(r));return n}function bF(e,t){const n=e.indexOf(t);return n===-1?0:(e.length-n)*FA}function BA(e,t,n){return n!=null&&n.has(t)?e.length*FA:bF(e,t)}const zm=5;function _A(e){var n,r;if(!e||((r=(n=e.wrote)==null?void 0:n.priority)==null?void 0:r.source)==="agent")return zm;const t=e.priority;return Number.isFinite(t)&&t>0?t:zm}const xF=9;function WA(e,t){return Number.isFinite(e)?e:t}function kF(e,t,n){var p;if(!Array.isArray(e)||t<0||t>=e.length)return null;const r=e.filter((m,w)=>w!==t),s=Math.max(0,Math.min(r.length,n>t?n-1:n));if(s===t||!r.length)return null;const o=(m,w)=>Math.abs(m-w)<1e-6,a=((p=r[s])==null?void 0:p.score)??r[s-1].score-2;let c=s;for(;c>0&&o(r[c-1].score,a);)c-=1;const u=c>0?r[c-1].score:a+2,d=r.slice(c,s),h=(u-a)/(d.length+2),f={};return d.forEach((m,w)=>{f[m.id]=a+(d.length+1-w)*h}),f[e[t].id]=a+h,f}function Bb(e,t,n){const r=wF(e).filter(o=>o!==t),s=Math.max(0,Math.min(r.length,Math.trunc(n)));return r.splice(s,0,t),r}function da(e){return!!e&&_A(e)>=xF}function vF(e){if(!e.reading||e.typing||da(e.reading))return null;for(const t of e.inbox)if(t.id!==e.reading.id&&da(t)&&!e.known.has(t.id)&&!e.spent.has(t.id))return t;return null}function SF(e,t){if(!e)return null;const n=t.find(r=>r.id===e.id&&r.product===e.product);return!n||n.status==="done"?null:n}const jF=/^(\d\d):(\d\d):(\d\d) {2}(.*)$/,CF=/^# exited \((-?\d+)\)(?:\s+(\S+))?/;function NF(e,t){const n=e<12?"am":"pm";return`${e%12===0?12:e%12}:${String(t).padStart(2,"0")}${n}`}function _h(e,t,n,r){const s=new Date(e),o=Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate(),t,n,r);return o<Math.floor(e/1e3)*1e3?o+864e5:o}function y1(e){const t=new Date(e);return NF(t.getHours(),t.getMinutes())}function EF(e){const t=e.split(/\n\s*\n/)[0].trim();if(t.length<=300)return t;const n=t.slice(0,300),r=Math.max(n.lastIndexOf(". "),n.lastIndexOf("? "),n.lastIndexOf("! "));return`${(r>120?n.slice(0,r+1):n).trim()}…`}function AF(e,t){const n=i=>i.replace(/[\s*_`#]+/g," ").trim().toLowerCase(),[r,s]=[n(e),n(t)],o=Math.min(r.length,s.length,60);return o<25?!1:r.slice(0,o)===s.slice(0,o)}function TF(e){var n;const t=e.trim();if(!t)return"The run stopped without saying why.";if(/usage limit|rate.?limit|quota/i.test(t)){const r=(n=t.match(/resets? at ([^.\n]+)/i))==null?void 0:n[1];return`Claude turned the session away: the usage limit is used up${r?`, and resets at ${r.trim()}`:""}.`}return/went to sleep mid-response/i.test(t)?"Your computer went to sleep mid-response, so the agent was cut off part-way.":/credit balance|insufficient/i.test(t)?"Claude refused the session: the account is out of credit.":t.replace(/^API Error:\s*/i,"").split(`
|
|
90
|
+
`)[0].slice(0,300)}function MF(e){var m;const t=[],n=new Set;let r=0,s=0,o=null,i=!1,a="",c=!1,u=null,d=null,h=null;for(const w of e.text.split(`
|
|
91
|
+
`)){const b=jF.exec(w);if(!b){const v=CF.exec(w);if(v){u=Number(v[1]);const S=Date.parse(v[2]??"");Number.isNaN(S)||(d=S),o=null;continue}if(w.startsWith("#"))continue;if(i){a+=`${w}
|
|
92
|
+
`;continue}o&&w.trim()&&(o.text+=`
|
|
93
|
+
${w}`);continue}const x=b[4];if(x.startsWith("== RESULT")){i=!0,h=_h(e.startedAt,Number(b[1]),Number(b[2]),Number(b[3])),c=/ERROR/.test(x)||/error/i.test(((m=x.match(/\(([^)]*)\)/))==null?void 0:m[1])??""),o=null;continue}if(i=!1,x.startsWith("[")){const v=x.indexOf("]"),S=v>0?x.slice(1,v):"",C=v>0?x.slice(v+1).trim():"";r+=1,o&&(o.actions+=1),/^(Write|Edit|NotebookEdit)$/.test(S)&&C&&n.add(C),/create_work_item/.test(S)&&(s+=1);continue}x.startsWith("stderr:")||x.trim()&&(o={time:y1(_h(e.startedAt,Number(b[1]),Number(b[2]),Number(b[3]))),text:x,actions:0},t.push(o))}const f=t[t.length-1];f&&a&&AF(f.text,a)&&t.pop();for(const w of t)w.text=EF(w.text);d===null&&h!==null&&(d=h);const p=c||u!==null&&u!==0;if(p){const w=TF(a);t.push({time:d?y1(d):"",text:w,actions:0,failed:!0})}return{steps:t,actions:r,files:n,filed:s,failed:p,endedAt:d,exitCode:u}}function RF(e){var h;const t=[...e].filter(f=>f&&f.text).sort((f,p)=>f.startedAt-p.startedAt);if(!t.length)return null;const n=[],r=new Set;let s=0,o=0,i=!1,a=null,c=null,u=0,d=null;for(const f of t){const p=MF(f);n.push(...p.steps),p.files.forEach(m=>r.add(m)),s+=p.actions,o+=p.filed,i=p.failed,a=p.failed?((h=p.steps[p.steps.length-1])==null?void 0:h.text)??null:null,c=p.endedAt,p.endedAt?(u+=Math.max(0,p.endedAt-f.startedAt),d=null):d=f.startedAt}return{steps:n,actions:s,files:r.size,filed:o,startedAt:t[0].startedAt,endedAt:c,worked:u,openSince:d,failed:i,failure:a,sessions:t.length,raw:t.map(f=>f.text).join(`
|
|
94
|
+
`)}}function Fm(e){const t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t} second${t===1?"":"s"}`;const n=Math.floor(t/60);return n<60?`${n} minute${n===1?"":"s"}`:`${Math.floor(n/60)}h ${n%60}m`}function HA(e,t=0){return e==="working"&&t>0?t===1?"1 Subagent Working":`${t} Subagents Working`:e==="working"?"Working":e==="shipping"?"Shipping":e==="next"?"Up next":e==="queued"?"Queued":e==="signin"?"Signed out":e==="limit"?"At its limit":e==="paused"?"Paused":e==="silent"?"Nothing came back":"Nothing running"}function Dy(e){const t=Math.max(0,Math.floor(e/1e3));if(t<60)return"just now";const n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function w1(e){const t=typeof e=="string"?e.trim():"";return!!t&&t!=="(withdrawn)"}function UA(e,t){return!!t&&!w1(e.result)&&!w1(e.note)}function KA(e,t={}){const{session:n=null,queued:r=[],runNow:s=[],stalled:o=!1,paused:i=!1,silent:a=null,signInNeeded:c={},atLimit:u={},inProgress:d=!1,scheduledUntil:h=0,now:f=Date.now(),shipping:p=!1}=t;if(e.agent||e.status==="done")return null;if(n){const b=Math.max(0,f-n.startedAt),x=n.helpers??0;if(x>0){const v=x===1?"one subagent":`${x} subagents`;return{state:"working",line:b<6e4?`The agent just started on this, with ${v} out.`:`The agent is working with ${v}, ${Fm(b)} in.`}}return{state:"working",line:b<6e4?"The agent just started on this.":`The agent is working, ${Fm(b)} in.`}}if(o||h>f)return null;if(UA(e,a)){const b=Math.max(0,f-(a.endedAt||f));return{state:"silent",line:b<6e4?"The last agent finished without saying anything. Send it a message to find out what happened.":`The last agent finished without saying anything, ${Fm(b)} ago. Send it a message to find out what happened.`}}if(!d)return null;if(p)return{state:"shipping",line:`${st} is shipping this. It comes back to you once it is live, or goes back to its agent if it fails.`};const m=c[e.id];if(m)return{state:"signin",line:m==="Codex"?"Codex is signed out. Open a terminal and run codex login, and this starts on its own.":`${m} is signed out. Open a terminal, run claude, and type /login, and this starts on its own.`};const w=u[e.id];if(w){const b=w.until>f?new Date(w.until).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}).replace(/\s/g,"").toLowerCase():null;return{state:"limit",line:`${w.tool} is at its usage limit, so this starts on its own when it resets${b?` at ${b}`:""}.`}}return r.includes(e.id)&&s.includes(e.id)?{state:"next",line:"Up next. It starts as soon as an agent is free, and if every agent is busy the least important one is paused to make room."}:r.includes(e.id)?{state:"queued",line:"Queued. An agent starts on it as soon as one is free."}:i?{state:"paused",line:"Agents are paused, so nothing will start on this."}:{state:"idle",line:"No agent is on this, and none is waiting to start."}}function IF(e,t={}){const{inProgress:n=!1,scheduledUntil:r=0,now:s=Date.now()}=t;return e.status==="done"?"closed":e.status==="blocked"?"blocked":r>s?"scheduled":n?"progress":"inbox"}const DF={progress:"In progress",inbox:"In your inbox",scheduled:"Scheduled",closed:"Closed",blocked:"Blocked"},Vi={progress:"This is in progress.",inbox:"This is in your inbox, waiting for you.",scheduled:"This is scheduled and is not running yet.",closed:"This is closed.",blocked:"This is blocked and is waiting for you."};function OF(e){let t=0;for(const n of Object.values(e.wrote??{}))n&&n.ts>t&&(t=n.ts);return t||e.updatedAt||0}function VA(e={}){return e.engineChoice?Db(e.engine??null):null}function Oy(e={}){var t;return VA({...e,engine:((t=e.session)==null?void 0:t.engine)??e.engine??null})}function LF(e,t={}){var d,h;const n=t.now??Date.now(),r=IF(e,t),s=KA(e,{...t,now:n}),i=(e.labels??[]).some(f=>f==="codex"||f==="codex-import"||f==="not-imported")?Db("codex"):Oy(t),a=t.session?Dy(Math.max(0,n-t.session.startedAt)):null,c=s?HA(s.state,((d=t.session)==null?void 0:d.helpers)??0):null,u=((h=e.productName)==null?void 0:h.trim())||null;return{project:u,where:r,whereWord:DF[r],state:(s==null?void 0:s.state)??null,stateWord:c,span:a,engineWord:i,age:a?null:Bs(OF(e),n),line:(u?`${u}. `:"")+zF({where:r,live:(s==null?void 0:s.line)??null,engineWord:i,span:a})}}function $F(e){return e.state==="working"?e.stateWord&&e.stateWord!=="Working"?e.stateWord.replace(/ Working$/,""):null:e.state==="idle"?null:e.stateWord}function PF(e,t){return[e.project,e.where==="blocked"?e.whereWord:null,$F(e),e.engineWord,t]}function zF({where:e,live:t,engineWord:n,span:r}){if(e==="closed")return Vi[e];const s=n??"The agent";return r?`${Vi[e]} ${s} has been working on this for ${r}.`:t&&!n?`${Vi[e]} ${t}`:t?`${Vi[e]} ${t} It will run on ${n}.`:n?`${Vi[e]} It will run on ${n}.`:Vi[e]}const qA="update";function nr(e){return!!e&&e.id===qA}function b1(e,t){return t.walking||!(e!=null&&e.ready)&&!(e!=null&&e.installing)?!1:!(t.closed&&t.closed===(e.newVersion??""))}function x1(e,t){return t.walking||!(e!=null&&e.canMove)||e.installing?!1:!(t.closed&&t.closed===(e.place??""))}const YA="zero.moveClosed",Xi={restart:"Restart to update",installing:`Updating. ${Je} restarts by itself in about a minute.`},_s={check:"Check for updates",checking:"Checking",downloading:"Downloading",updating:"Updating",looking:"Looking for a new version.",idle:`${st} looks for a new version on its own.`,current:`${st} is up to date.`,unknown:"Could not check for updates."};function GA(e,{checking:t=!1}={}){const n=!!(e!=null&&e.installing),r=t&&!n?"checking":(e==null?void 0:e.phase)??"idle",s=r==="ready",o=!!(e!=null&&e.source),i=r==="checking"||r==="downloading"||n,a=!!(e!=null&&e.canMove)&&!s&&!i,c=a?An.button:s?Xi.restart:n?_s.updating:r==="checking"?_s.checking:r==="downloading"?_s.downloading:_s.check;return{sentence:a?FF(e):BF(r,e,o),button:c,restart:s,move:a,busy:i}}function FF(e){return e!=null&&e.moveError?`${e.moveError.replace(/\.?$/,".")} ${An.retry}`:[mA((e==null?void 0:e.place)??null)??An.cannotUpdateHere,An.fix].join(" ")}function BF(e,t,n){if(t!=null&&t.installing)return Xi.installing;if(e==="ready"){if(t!=null&&t.error)return`${t.error.replace(/\.?$/,".")} Pressing it again tries again.`;const r=n?"Restarting takes about a minute.":"Restarting takes a few seconds.";return`${n?typeof(t==null?void 0:t.behind)=="number"&&t.behind>0?`${t.behind} new ${t.behind===1?"change":"changes"}.`:"A new version is ready.":t!=null&&t.newVersion?`Version ${t.newVersion} has downloaded.`:"A new version has downloaded."} ${r}`}return e==="downloading"?typeof(t==null?void 0:t.percent)=="number"?`Downloading the new version, ${t.percent}%.`:"Downloading the new version.":e==="checking"?_s.looking:e==="current"?_s.current:e==="error"||e==="unsupported"?(t==null?void 0:t.error)||_s.unknown:_s.idle}function _F(e){const t=(e==null?void 0:e.changes)??[];if(!t.length)return[];const n=((e==null?void 0:e.behind)??t.length)-t.length;return n>0?[...t,`and ${n} more`]:[...t]}const JA="zero.updateClosed",XA=()=>typeof localStorage>"u"?void 0:localStorage;function WF(e=XA()){try{return(e==null?void 0:e.getItem(JA))||null}catch{return null}}function HF(e=XA()){try{return(e==null?void 0:e.getItem(YA))||null}catch{return null}}function UF(e,t){if(t)try{e==null||e.setItem(YA,t)}catch{}}function KF(e,t){if(t)try{e==null||e.setItem(JA,t)}catch{}}function VF(e,t){return!e.installing&&t!==null&&t===(e.version??"")}const qF="codex-import",YF="codex",GF="not-imported";function JF(e){for(const t of(e==null?void 0:e.labels)??[])if(typeof t=="string"&&t.startsWith("codex:"))return t.slice(6);return null}const _b=(e,t)=>((e==null?void 0:e.labels)??[]).includes(t),Qi=e=>!!e&&_b(e,qF)&&e.status!=="done",Ly=e=>!!e&&_b(e,GF)&&e.status==="done",XF=e=>!!e&&_b(e,YF)&&!!JF(e),Pc=(e,t)=>XF(e)&&e.status!=="done"&&!t.has(e.id),QF="just imported",ZF=[{key:"1",word:"Yes"},{key:"2",word:"No"}],eB=[{key:"I",word:"Import"}],tB=e=>e==="yes"?"Yes":"Not now",nB="Not imported",rB=/^(?:agentbox\/)?(w-[a-f0-9]{10})(?:-[a-z0-9-]+)?$/i,sB=new RegExp("(?<![\\w/.:@-])(?:agentbox\\/)?w-[a-f0-9]{10}(?:-[a-z0-9]+(?:-[a-z0-9]+)*)?(?![\\w/-]|\\.[a-z0-9])","gi"),uu="#ticket/";function zc(e){var t;return((t=e.trim().match(rB))==null?void 0:t[1].toLowerCase())??null}function Wb(e){const t=e.trim().match(/^(?:agentbox\/)?(w-[a-f0-9]{1,10})(-[a-z0-9]+(?:-[a-z0-9]+)*)?$/i);return!t||t[2]&&t[1].length!==12?null:t[1].toLowerCase()}function k1(e,t,n){return e.find(r=>r.id===t&&r.product===n)??e.find(r=>r.id===t)??null}function QA(e){const t=[];let n=0;for(const r of e.matchAll(sB))r.index>n&&t.push({text:e.slice(n,r.index)}),t.push({text:r[0],id:zc(r[0])}),n=r.index+r[0].length;return n<e.length&&t.push({text:e.slice(n)}),t}const oB=new Set(["link","linkReference","image","imageReference","definition","code","html"]);function ZA(e){e.children&&(e.children=e.children.flatMap(t=>{if(t.type==="text"&&t.value)return QA(t.value).map(n=>n.id?{type:"link",url:uu+n.id,children:[{type:"text",value:n.text}]}:{type:"text",value:n.text});if(t.type==="inlineCode"&&t.value){const n=zc(t.value);if(n)return[{type:"link",url:uu+n,children:[t]}]}return oB.has(t.type)||ZA(t),[t]}))}function iB(){return e=>ZA(e)}const aB={"‘":"'","’":"'",ʼ:"'","“":'"',"”":'"',"–":"-","—":"-"};function Hs(e){return e.toLowerCase().replace(/[‘’ʼ“”–—]/g,t=>aB[t])}function cp(e){const t=Hs(e).trim(),n=t.length>2&&t.startsWith('"')&&t.endsWith('"'),r=(n?t.slice(1,-1):t).trim(),s=Hb((Wb(r)??r).replace(/"/g," ").split(/\s+/)),o=s.length>1?s.join(" "):"";return{terms:s,phrase:o,quoted:n&&s.length>0}}function Hb(e){return e.map(t=>Hs(t)).filter(Boolean)}function $y(e){return e.replace(/\s+/g," ")}function Nc(e){return cB(e).map(t=>({raw:t,folded:$y(Hs(t))}))}const v1=new WeakMap;function eT(e){const t=v1.get(e);if(t)return t;const n=$y(Hs([e.label,e.title].filter(Boolean).join(" . "))),r=Cc(e.body),s=Cc(e.result),o=Cc(e.note),i=Cc(e.answer),a=[r,s,o,i].filter(Boolean).join(" . "),c=`${Hs(e.id)} . ${n} . ${$y(Hs(a))}`,u={title:n,all:c,body:Nc(r),result:Nc(s),note:Nc(o),answer:Nc(i)};return v1.set(e,u),u}function S1(e){return e>="a"&&e<="z"||e>="0"&&e<="9"}function du(e,t,n=0,r=!1){if(!t)return-1;let s=e.indexOf(t,n);for(;s>=0;){const o=s===0||!S1(e[s-1]),i=!r||!S1(e[s+t.length]??"");if(o&&i)return s;s=e.indexOf(t,s+1)}return-1}function Ub(e,t,n,r=0){return du(e,t[n],r,n<t.length-1)}function j1(e,t){return t.every((n,r)=>Ub(e,t,r)>=0)}function tT(e,t){if(t.terms.length===0)return 0;const n=t.terms.length===1?Wb(t.terms[0]):null;if(n&&Hs(e.id).startsWith(n))return Hs(e.id)===n?6:5;const r=eT(e);if(t.phrase){if(du(r.title,t.phrase)>=0)return 4;if(du(r.all,t.phrase)>=0)return 3;if(t.quoted)return 0}return j1(r.title,t.terms)?2:j1(r.all,t.terms)?1:0}function C1(e,t){return tT(e,cp(t))}function lB(e,t){const n=cp(t);return n.terms.length===0?[...e].sort((r,s)=>(s.updatedAt??0)-(r.updatedAt??0)).map(r=>({item:r,summary:N1(r,[])})):e.map(r=>({item:r,n:tT(r,n)})).filter(r=>r.n>0).sort((r,s)=>s.n-r.n||(s.item.updatedAt??0)-(r.item.updatedAt??0)).map(({item:r})=>({item:r,summary:N1(r,n.terms,n.phrase)}))}function N1(e,t,n=""){const r=t.length===1?Wb(t[0]):null;if(r&&Hs(e.id).startsWith(r))return e.id;const s=e.status==="done",{body:o,result:i,note:a,answer:c}=eT(e),u=s?[i,o,a]:[o,i,a];for(const d of n?["phrase","words"]:["words"]){const h=d==="phrase";for(const p of u){const m=Py(p,t,n,Bh,h);if(m)return m}const f=Py(c,t,n,Bh,h);if(f)return f}return zA(e,s?"done":"inbox")}function E1(e,t,n="",r=Bh){return e?Py(Nc(e),t,n,r):""}function Py(e,t,n,r,s=!1){const o=Hb(t);if(!n&&o.length===0)return"";if(n){for(const i of e)if(!(du(i.folded,n)<0))return T1(i.raw,Math.max(0,A1(i,o)),r)}if(s)return"";for(const i of e){const a=A1(i,o);if(a>=0)return T1(i.raw,a,r)}return""}function cB(e){return e.split(new RegExp("(?<=[.!?])\\s+")).map(t=>t.trim()).filter(Boolean)}function A1(e,t){const n=t.map((r,s)=>s).sort((r,s)=>t[s].length-t[r].length);for(const r of n){const s=Ub(e.folded,t,r);if(s>=0)return s}return-1}function T1(e,t,n){if(e.length<=n)return e;let s=Math.max(0,t-24);if(s>0){const i=e.indexOf(" ",s);s=i>=0&&i<t?i+1:s}let o=Math.min(e.length,s+n);if(o<e.length){const i=e.lastIndexOf(" ",o);i>t&&(o=i)}return`${s>0?"…":""}${e.slice(s,o).trim()}${o<e.length?"…":""}`}function uB(e,t,n=""){if(!e)return[];const r=Hb(t);if(r.length===0)return[{text:e,hit:!1}];const s=Hs(e),o=[],i=(d,h)=>{let f=h(0);for(;f>=0;)o.push([f,f+d.length]),f=h(f+1)};if(r.forEach((d,h)=>i(d,f=>Ub(s,r,h,f))),n&&i(n,d=>du(s,n,d)),o.length===0)return[{text:e,hit:!1}];o.sort((d,h)=>d[0]-h[0]||d[1]-h[1]);const a=[];for(const[d,h]of o){const f=a[a.length-1];f&&d<=f[1]?f[1]=Math.max(f[1],h):a.push([d,h])}const c=[];let u=0;for(const[d,h]of a)d>u&&c.push({text:e.slice(u,d),hit:!1}),c.push({text:e.slice(d,h),hit:!0}),u=h;return u<e.length&&c.push({text:e.slice(u),hit:!1}),c}function up(e,t=Date.now()){return e.status==="done"?"done":e.start==="later"||Number.isFinite(e.runAt)&&e.runAt>t?"scheduled":e.status==="claimed"&&e.claim&&!e.claimExpired||(e.labels??[]).includes("founder")&&!e.result&&!e.note&&e.kind!=="question"&&e.kind!=="review"&&!dB(e)?"running":"waiting"}const dB=e=>typeof e.assignee=="string"&&e.assignee!=="agent",hB=[[/\*\*(\w[^*\n]*?)\*\*/g,"$1"],[new RegExp("(?<!\\w)__(\\w[^_\\n]*?)__(?!\\w)","g"),"$1"],[/\*(\w[^*\n]*?)\*/g,"$1"],[new RegExp("(?<!\\w)_(\\w[^_\\n]*?)_(?!\\w)","g"),"$1"],[/`([^`\n]+)`/g,"$1"]],fB=/^(.+?\w[.!?]["'”’)\]]?)(?=\s+["“'(\[]?[A-Z]|\s*$)/;function Bm(e,t=240){if(typeof e!="string")return"";let n=e.replace(/^#+\s.*$/gm,"").replace(/^##\s*Options[\s\S]*$/m,"").replace(/^\s*>\s?/gm,"");for(const[o,i]of hB)n=n.replace(o,i);n=n.replace(/\s+/g," ").trim();const r=n.match(fB),s=(r?r[1]:n).trim();return s.length>t?`${s.slice(0,t-1).trimEnd()}…`:s}function zy(e){return typeof e!="string"?[]:e.split(`
|
|
95
|
+
`).map(t=>t.trim().replace(/^(?:[-*•✓✔]\s*)+/,"").trim()).filter(Boolean)}function pB(e){const t=s=>typeof e[s]=="string",n=Bm(e.result||""),r=n.endsWith("?");return{problem:t("problem")?e.problem:Bm(e.body||e.title),progress:t("progress")?e.progress:r?n:Bm(e.result?"":e.note||""),solution:t("solution")?e.solution:r?"":n,written:t("problem")||t("progress")||t("solution")}}function Kb(e,t=null,n=null){const r=Vb(e);return r==="team"?!0:r==="people"?$u(e,n).length>0:r==="private"||t&&((e==null?void 0:e.createdAt)??0)<t?!1:Mo(n).who!=="private"}const Vb=e=>{const t=e==null?void 0:e.visibility;return t==="team"||t==="people"||t==="private"?t:void 0},nT=e=>[...new Set((Array.isArray(e)?e:[]).filter(t=>typeof t=="string"&&t))];function Mo(e){if((e==null?void 0:e.personal)===!0||(e==null?void 0:e.seenBy)==="private")return{who:"private",people:[]};if((e==null?void 0:e.seenBy)==="people"){const t=nT(e.seenByPeople);return t.length?{who:"people",people:t}:{who:"private",people:[]}}return{who:"team",people:[]}}function rT(e,t=null){const n=Vb(e);if(n)return n;const{who:r}=Mo(t);return r==="team"?void 0:r}function $u(e,t=null){const n=Vb(e);if(n==="people")return nT(e.visibleTo);if(n)return[];const r=Mo(t);return r.who==="people"?r.people:[]}new TextEncoder;const Sl=e=>{var t;return!!((t=e==null?void 0:e.team)!=null&&t.projectId)};function qb(e,t){var n;return(e==null?void 0:e.runner)||(e==null?void 0:e.createdBy)||((n=t==null?void 0:t.team)==null?void 0:n.sharedBy)||null}const hi=e=>!!(e!=null&&e.assignee)&&e.assignee!=="agent";function sT(e){var s,o;const t=(s=e==null?void 0:e.wrote)==null?void 0:s.answer,n=(o=e==null?void 0:e.wrote)==null?void 0:o.body,r=t&&(!n||(t.ts??0)>=(n.ts??0))?t:n;return(r==null?void 0:r.by)??(e==null?void 0:e.createdBy)??null}function dp(e,t){const n=e==null?void 0:e.talk;if(!n||!t)return null;const r=o=>{let i=0;for(let a=o.length-1;a>=0&&o[a].by!==t;a-=1)i+=1;return i},s=[];for(const[o,i]of Object.entries(n.threads??{})){const a=i.replies??[];if(i.by!==t&&!a.some(d=>d.by===t))continue;const c=r(a);if(!c)continue;const u=a.slice(-c);s.push({uid:o,mine:i.by===t,fresh:c,people:[...new Set(u.map(d=>d.by))],text:i.text,last:u[u.length-1].text,lastBy:u[u.length-1].by,at:u[u.length-1].ts})}return s.sort((o,i)=>i.at-o.at),{chat:r(n.chat??[]),threads:s.map(({at:o,...i})=>i)}}function mB(e,t,n){var r;if(!Sl(t)||!n)return!0;if((r=t==null?void 0:t.team)!=null&&r.direct){if(e.status==="done")return!1;const s=dp(e,n);if(s)return s.chat>0||s.threads.length>0;const o=sT(e);return o?o!==n:e.assignee===n}return hi(e)?e.assignee===n&&e.status!=="done":qb(e,t)===n}function gB(e,t,n){var s;if(!n||!((s=t==null?void 0:t.team)!=null&&s.direct)||(e==null?void 0:e.status)==="done")return!1;const r=dp(e,n);return r?r.chat===0&&r.threads.length===0:sT(e)===n}const bn=e=>((e==null?void 0:e.name)||(e==null?void 0:e.email)||"Someone").split(/\s+/)[0];function oT(e,t=new Date){if(!e||e==="none")return null;const[n,r,s]=e.split("-").map(Number),o=new Date(n,r-1,s),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=Math.round((o.getTime()-i.getTime())/864e5);return a===0?"Due today":a===1?"Due tomorrow":a>1&&a<7?`Due ${o.toLocaleDateString(void 0,{weekday:"short"})}`:a<0?`Overdue ${o.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`:`Due ${o.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`}function yB(e,t,n){if(!n||!Sl(t))return null;const r=hi(e)?(e.people??[]).find(s=>s!==n)??e.createdBy:qb(e,t);return!r||r===n?null:{from:r,agent:!hi(e)}}const Xt=g.createContext(null);function M1(e,t){return!(e!=null&&e.signedIn)||!e.me?null:{state:e,me:e.me.id,byId:new Map(e.people.map(n=>[n.id,n])),products:new Map(t.map(n=>[n.slug,n]))}}const wB=e=>bn(e).slice(0,2);function Rt({person:e,me:t,agent:n,size:r}){const s=`tm-av${t?" you":""}${n?" bot":""}${r?` ${r}`:""}`;return e!=null&&e.avatarUrl&&!n?l.jsx("img",{className:`${s} tm-ph`,src:e.avatarUrl,alt:"",referrerPolicy:"no-referrer"}):l.jsx("span",{className:s,"aria-hidden":"true",children:wB(e)})}function bB({item:e,team:t}){const n=t==null?void 0:t.products.get(e.product),r=t?yB(e,n,t.me):null,s=r?t.byId.get(r.from):void 0,o=e.assignee===(t==null?void 0:t.me)?oT(e.due):null,i=!!t&&rT(e,n)==="private";return l.jsxs(l.Fragment,{children:[r?l.jsxs("span",{className:"tm-who",children:[l.jsx(Rt,{person:s,agent:r.agent}),r.agent?`${bn(s)}’s agent`:bn(s)]}):l.jsxs("span",{className:`product${i?" tm-lock":""}`,children:[i&&l.jsx(Wh,{}),e.productName]}),o&&l.jsx("span",{className:"tm-due",children:o})]})}function Wh(){return l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-label":"Private",children:[l.jsx("rect",{x:"2.5",y:"5.5",width:"7",height:"5"}),l.jsx("path",{d:"M4 5.5V4a2 2 0 0 1 4 0v1.5"})]})}const xB=e=>{var t;return((t=e.team)==null?void 0:t.direct)===!0};function kB(e){return e.filter(t=>!t.practice&&!xB(t))}function R1(e,t,n){if(n===t)return null;const r=e.filter(i=>i!==t),s=n?r.indexOf(n):r.length,o=Bb(r,t,s<0?r.length:s);return o.join(`
|
|
96
|
+
`)===e.join(`
|
|
97
|
+
`)?null:o}function _m(e,t,n,r){const s=t.indexOf(n),o=s+r;if(s<0||o<0||o>=t.length)return null;const i=e.filter(c=>c!==n),a=i.indexOf(t[o]);return a<0?null:Bb(i,n,r<0?a:a+1)}function iT(e,t){for(let n=0;n<e.length;n+=1)if(t<(e[n].top+e[n].bottom)/2)return n;return e.length}const Ad={duration:200,easing:"cubic-bezier(.2,.8,.2,1)"},ol=56,I1=14;function vB(e,t,n,r){return t<e&&e<n?-r:n<=e&&e<t?r:0}const aT=(e,t)=>t===e||t===e+1;function SB(e,t,n){return e<t+ol?-Math.ceil(I1*Math.min(1,(t+ol-e)/ol)):e>n-ol?Math.ceil(I1*Math.min(1,(e-(n-ol))/ol)):0}let Fy=0;const jB=()=>Fy>0;function CB(e,t,n){return aT(t,n)?0:n>t?e[n-1].bottom-e[t].bottom:e[n].top-e[t].top}const NB=16,EB=32,AB=29;function D1(e,t){return{left:e.left+EB-NB,top:e.top+AB-t/2}}function O1(e,t,n=16){return Math.max(n,Math.min(t-n,e))}function TB(e){var s,o,i,a;const t=document.createElement("div");t.className="drag-preview drag-chip";const n=document.createElement("span");n.className="t",n.textContent=((o=(s=e.querySelector(".th-cell-title .th-msg-text, .th-cell-title"))==null?void 0:s.textContent)==null?void 0:o.trim())??"";const r=document.createElement("span");return r.className="p",r.textContent=((a=(i=e.querySelector(".th-cell-proj"))==null?void 0:i.textContent)==null?void 0:a.trim())??"",t.append(n,r),t}function MB(e){const t=e.cloneNode(!0);for(const n of["data-drag-id","data-lifted","data-settling"])t.removeAttribute(n);return t.classList.remove("selected"),t.classList.add("drag-preview"),t.style.width=`${e.getBoundingClientRect().width}px`,t}const RB=e=>{for(let t=(e==null?void 0:e.parentElement)??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t}return null};function lT(e,t="chip"){const n=g.useRef(null),r=g.useRef(null),s=g.useRef(!1),o=g.useRef(e);o.current=e;const i=m=>m.scroller?m.scroller.scrollTop-m.scroll0:0,a=m=>{const w=i(m);m.to=iT(m.rows,m.y+w),m.preview&&(m.preview.style.transform=`translate(${m.x-m.gx}px, ${m.y-m.gy}px)`),m.el.style.transform=`translateY(${CB(m.rows,m.from,m.to)}px)`,m.rows.forEach((b,x)=>{x!==m.from&&(b.el.style.transform=`translateY(${vB(x,m.from,m.to,c(m))}px)`)})},c=m=>{const w=m.rows[m.from],b=m.rows[m.from+1],x=m.rows[m.from-1];return b?b.top-w.top:x?w.bottom-x.bottom:w.bottom-w.top},u=()=>{const m=r.current;if(!(m!=null&&m.started))return;let w=!1;if(m.scroller){const v=m.scroller.getBoundingClientRect(),S=SB(m.y,v.top,v.bottom);S&&(m.scroller.scrollTop+=S,w=!0)}const b=m.gxEnd-m.gx,x=m.gyEnd-m.gy;(Math.abs(b)>.5||Math.abs(x)>.5)&&(m.gx+=Math.abs(b)>.5?b*.2:b,m.gy+=Math.abs(x)>.5?x*.2:x,w=!0),w&&a(m),m.frame=requestAnimationFrame(u)},d=m=>{var _,Y;const w=r.current;if(r.current=null,!(w!=null&&w.started))return;Fy-=1,cancelAnimationFrame(w.frame),s.current=!0;const b=new Map(w.rows.map(se=>{const re=se.el.getBoundingClientRect();return[se.id,{top:re.top,left:re.left}]}));if(m&&!aT(w.from,w.to)){const se=((_=w.rows[w.to])==null?void 0:_.id)??null,re=w.rows.map(T=>T.id);bs.flushSync(()=>{var T;return(T=o.current)==null?void 0:T.call(o,w.id,se,re)})}const x=w.scope;x&&(x.dataset.sorting="settle",setTimeout(()=>{x.dataset.sorting==="settle"&&delete x.dataset.sorting},Ad.duration+20)),delete document.body.dataset.dragging;const v=[...((Y=w.scope)==null?void 0:Y.querySelectorAll("[data-drag-id]"))??[]];for(const se of v)se.style.transform="";for(const se of v){const re=b.get(se.dataset.dragId);if(re===void 0||!se.animate)continue;const T=se.getBoundingClientRect(),W=re.top-T.top;Math.abs(W)<.5||se.animate([{transform:`translateY(${W}px)`},{transform:"none"}],Ad)}const S=w.el.isConnected?w.el:v.find(se=>se.dataset.dragId===w.id)??null,C=w.preview;if(S&&(delete S.dataset.lifted,S.dataset.settling=""),!C){S&&delete S.dataset.settling;return}const O=C.getBoundingClientRect(),N=S==null?void 0:S.getBoundingClientRect(),P=N?t==="chip"?D1(N,O.height):{left:N.left,top:N.top}:{left:O.left,top:O.top},M=P.left,R=P.top,L=()=>{C.remove(),S&&delete S.dataset.settling};if(!C.animate){L();return}const H=C.animate([{transform:`translate(${O.left}px, ${O.top}px)`,opacity:1},{transform:`translate(${M}px, ${R}px)`,opacity:1,offset:.7},{transform:`translate(${M}px, ${R}px)`,opacity:0}],{duration:240,easing:Ad.easing,fill:"forwards"});H.onfinish=H.oncancel=L},h=(m,w)=>{var x,v,S,C,O;const b=r.current;if(b){if(b.x=m,b.y=w,!b.started){if(Math.hypot(m-b.startX,w-b.startY)<4)return;const N=[...((x=b.scope)==null?void 0:x.querySelectorAll("[data-drag-id]"))??[]];for(const R of N)(v=R.getAnimations)==null||v.call(R).forEach(L=>L.finish()),delete R.dataset.settling;if(b.rows=N.map(R=>{const L=R.getBoundingClientRect();return{id:R.dataset.dragId,el:R,top:L.top,bottom:L.bottom}}),b.from=b.rows.findIndex(R=>R.id===b.id),b.from<0){r.current=null;return}b.started=!0,Fy+=1,b.scroller=RB(b.scope),b.scroll0=((S=b.scroller)==null?void 0:S.scrollTop)??0,(C=window.getSelection())==null||C.removeAllRanges(),b.scope&&(b.scope.dataset.sorting="carry"),document.body.dataset.dragging="";const P=b.el.getBoundingClientRect(),M=t==="copy"?MB(b.el):TB(b.el);if(document.body.appendChild(M),b.preview=M,t==="copy")b.gx=b.gxEnd=b.startX-P.left,b.gy=b.gyEnd=b.startY-P.top;else{const R=M.getBoundingClientRect(),L=D1(P,R.height);b.gx=b.startX-L.left,b.gy=b.startY-L.top,b.gxEnd=O1(b.gx,R.width),b.gyEnd=O1(b.gy,R.height,R.height/2)}(O=M.animate)==null||O.call(M,[{opacity:0,scale:"0.97"},{opacity:1,scale:"1"}],{duration:140,easing:Ad.easing}),b.el.dataset.lifted="",b.frame=requestAnimationFrame(u)}a(b)}},f=g.useRef(null);return g.useEffect(()=>{const m=b=>{var x;(x=r.current)!=null&&x.started&&(b.preventDefault(),b.stopPropagation(),b.key==="Escape"&&d(!1))},w=()=>{var b;r.current&&(d(!1),(b=f.current)==null||b.call(f),s.current=!1)};return window.addEventListener("keydown",m,!0),window.addEventListener("blur",w),()=>{window.removeEventListener("keydown",m,!0),window.removeEventListener("blur",w)}},[]),{listRef:n,onPointerDown:(m,w)=>{if(w.pointerType==="touch"||!o.current||w.button!==0||w.shiftKey||w.metaKey||w.ctrlKey)return;const b=w.target.closest("button, a, input, textarea");if(b&&b!==w.currentTarget)return;const x=w.currentTarget,v=x.closest("[data-drag-scope]")??n.current;r.current={id:m,el:x,scope:v,scroller:null,startX:w.clientX,startY:w.clientY,scroll0:0,x:w.clientX,y:w.clientY,started:!1,rows:[],from:-1,to:-1,frame:0,preview:null,gx:0,gy:0,gxEnd:0,gyEnd:0};const S=M=>h(M.clientX,M.clientY),C=()=>{const M=r.current;M!=null&&M.started&&a(M)},O=()=>{f.current=null,window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",N),window.removeEventListener("pointercancel",P),window.removeEventListener("scroll",C,!0),setTimeout(()=>{s.current=!1},0)},N=()=>{d(!0),O()},P=()=>{d(!1),O()};f.current=O,window.addEventListener("pointermove",S),window.addEventListener("pointerup",N),window.addEventListener("pointercancel",P),window.addEventListener("scroll",C,!0)},swallowsClick:()=>s.current,carrying:()=>{var m;return!!((m=r.current)!=null&&m.started)}}}const wr=[{id:"urgent",label:"Urgent",value:9},{id:"high",label:"High",value:7},{id:"medium",label:"Medium",value:5},{id:"low",label:"Low",value:2}];function kr(e){const t=e??5;return t>=9?"urgent":t>=7?"high":t<=2?"low":"medium"}function hu(e){return wr.find(t=>t.id===e).value}function Ma(e){return wr.find(t=>t.id===e).label}function L1(e){if(!e.length)return[];const t=new Set(e.map(s=>kr(s.priority))),n=t.size===1?[...t][0]:null,r=e.length>1?` (${e.length} selected)`:"";return wr.map(s=>({id:`priority-${s.id}`,label:`Priority: ${s.label}${r}${s.id===n?" (current)":""}`,value:s.value,current:s.id===n}))}function IB(e){return wr.some(t=>t.id===e)?e:null}const qi=8,Td=8,$1=44+qi;function DB(e){let t=0,n=window.innerWidth;for(let r=e;r&&r!==document.body;r=r.parentElement){if(getComputedStyle(r).overflowX==="visible")continue;const s=r.getBoundingClientRect();t=Math.max(t,s.left),n=Math.min(n,s.right)}return{left:t,right:n}}function By(e,t=window.innerHeight,n){var f;const r=e.style;r.top=r.bottom=r.maxHeight=r.overflowY=r.left=r.right="";const s=e.getBoundingClientRect(),o=(f=e.parentElement)==null?void 0:f.getBoundingClientRect();if(!o)return;const i=DB(e.parentElement);if(s.left<i.left+qi||s.right>i.right-qi){const p=Math.max(i.left+qi,Math.min(s.left,i.right-qi-s.width));r.left=`${Math.round(p-o.left)}px`,r.right="auto"}if(s.top>=$1&&s.bottom<=t-qi)return;const a=t-o.bottom-Td-qi,c=o.top-Td-$1,u=s.height,d=a>=u||c<u&&a>=c;d?(r.top=`calc(100% + ${Td}px)`,r.bottom="auto"):(r.top="auto",r.bottom=`calc(100% + ${Td}px)`);const h=Math.floor(d?a:c);u>h&&(r.maxHeight=`${Math.max(h,96)}px`,r.overflowY="auto")}function hp(e,t,n=[]){g.useLayoutEffect(()=>{var o;if(!t)return;const r=(o=e.current)==null?void 0:o.querySelector(":scope > .prio-menu, :scope > .when-menu");if(!r)return;const s=()=>By(r);return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[t,...n])}function xi({id:e}){if(e==="urgent")return l.jsxs("span",{className:"prio-bars p4",children:[l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{})]});const t=e==="low"?1:e==="medium"?2:3;return l.jsxs("span",{className:`prio-bars p${t}`,children:[l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{})]})}function OB({value:e,set:t=!1,onChange:n,title:r,variant:s="tag",onOpenChange:o}){const[i,a]=g.useState(!1);g.useEffect(()=>{o==null||o(i)},[i]);const[c,u]=g.useState(0),d=g.useRef(null);hp(d,i),g.useEffect(()=>{if(!i)return;u(Math.max(0,wr.findIndex(m=>m.id===e)));const p=m=>{var w;(w=d.current)!=null&&w.contains(m.target)||a(!1)};return document.addEventListener("pointerdown",p),()=>document.removeEventListener("pointerdown",p)},[i,e]);const h=p=>{n(p),a(!1)},f=s==="word";return l.jsxs("span",{className:f?"compose-word-wrap":"prio-wrap",ref:d,children:[i&&l.jsx("span",{className:"prio-menu",role:"listbox","aria-label":"Priority",children:wr.map((p,m)=>l.jsxs("button",{role:"option","aria-selected":p.id===e,className:`prio-menu-row ${m===c?"cursor":""} ${p.id===e?"on":""}`,onPointerEnter:()=>u(m),onClick:()=>h(p.id),children:[l.jsx(xi,{id:p.id}),l.jsx("span",{className:"prio-menu-label",children:p.label})]},p.id))}),l.jsxs("button",{type:"button",className:[f?"compose-word":"prio-tag",e==="urgent"?"urgent":"",t?"set":"",i?"open":""].filter(Boolean).join(" "),title:r??"Priority","aria-haspopup":"listbox","aria-expanded":i,onClick:()=>a(p=>!p),onKeyDown:p=>{if(!i){(p.key==="ArrowUp"||p.key==="ArrowDown"||p.key==="Enter"||p.key===" ")&&(p.preventDefault(),a(!0));return}p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),a(!1)),p.key==="ArrowDown"&&(p.preventDefault(),u(m=>(m+1)%wr.length)),p.key==="ArrowUp"&&(p.preventDefault(),u(m=>(m-1+wr.length)%wr.length)),p.key==="Enter"&&(p.preventDefault(),h(wr[c].id))},children:[!f&&l.jsx(xi,{id:e}),Ma(e)]})]})}function Wm(e,t){return e.filter(n=>n.parent===t.id&&n.product===t.product).sort((n,r)=>(n.createdAt??0)-(r.createdAt??0))}const LB={waiting:"Needs you",running:"In progress",scheduled:"Later",done:"Done"},$B=e=>e?LB[e]:"";function PB(e,t){const n=new Map;for(const r of e){if(!r.parent||!_y(r,t(r)))continue;const s=`${r.product}/${r.parent}`;n.set(s,(n.get(s)??0)+1)}return n}const cT=e=>e?`${e} task${e===1?"":"s"} to approve`:"";function _y(e,t){return t!=="waiting"&&t!=="scheduled"||e.status!=="open"||e.kind==="question"||e.kind==="review"||(e.labels??[]).includes("founder")||bo(e)?!1:!(e.answer&&e.answer!=="(withdrawn)")}const uT=xs.map(e=>({engine:e.id,label:e.label})),Yb="agentbox-agent:",P1=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function zB(e,t){const n=/(^|[\s(])@([^\s@]{0,30})$/.exec(e.slice(0,t));return n?{start:t-n[2].length-1,query:n[2]}:null}const z1=(e,t)=>!t||e.toLowerCase().split(/\s+/).some(n=>n.startsWith(t.toLowerCase()))||e.toLowerCase().startsWith(t.toLowerCase());function F1(e,t){const n=uT.slice().sort((a,c)=>c.label.length-a.label.length),r=t.slice().sort((a,c)=>c.name.length-a.name.length),s=r.length?`(?: in (${r.map(a=>P1(a.name)).join("|")}))?`:"",o=new RegExp(`(^|[^\\w\\[])@(${n.map(a=>P1(a.label)).join("|")})${s}(?![\\w])`,"g"),i=[];for(let a=o.exec(e);a;a=o.exec(e)){const c=a.index+a[1].length,u=n.find(h=>h.label===a[2]),d=a[3]?r.find(h=>h.name===a[3])??null:null;i.push({start:c,end:a.index+a[0].length,engine:u.engine,label:u.label,project:d})}return i}function FB(e){const t=e.find(n=>!n.project);return t?`Pick a project for @${t.label}: click it to choose.`:null}const Gb=(e,t)=>`@${e}${t?` in ${t.name}`:""}`;function BB(e,t,n){return e.slice(0,t.start)+Gb(t.label,n)+e.slice(t.end)}const _B=(e,t)=>{const n=new URLSearchParams;return e.project&&n.set("project",e.project.slug),t!=null&&t.model&&n.set("model",t.model),t!=null&&t.effort&&n.set("effort",t.effort),`[${Gb(e.label,e.project)}](${Yb}${e.engine}?${n.toString()})`};function WB(e,t,n=[]){let r=e;return t.map((s,o)=>({m:s,pick:n[o]})).sort((s,o)=>o.m.start-s.m.start).forEach(({m:s,pick:o})=>{r=r.slice(0,s.start)+_B(s,o)+r.slice(s.end)}),r}const Jb=/\[(@[^\]]+)\]\((agentbox-agent:[^)\s]+)\)/g;function dT(e){const t=[];for(const n of String(e??"").matchAll(Jb)){const r=n[2],[s,o=""]=r.slice(Yb.length).split("?"),i=new URLSearchParams(o);t.push({raw:n[0],engine:s,label:n[1].replace(/^@/,"").replace(/ in .*$/,""),project:i.get("project"),model:i.get("model"),effort:i.get("effort"),task:i.get("task")})}return t}function HB(e,t,n){const[r,s]=[t.raw.slice(0,t.raw.indexOf("](")+2),t.raw.slice(t.raw.indexOf("](")+2,-1)];return e.replace(t.raw,`${r}${s}${s.includes("?")?"&":"?"}task=${encodeURIComponent(n)})`)}const Hh=e=>String(e??"").replace(Jb,"$1");function UB(e,t=[],n=[]){const r=s=>{const o=t.indexOf(s);return o<0?1/0:o};return e.filter(s=>{var o;return!((o=s.team)!=null&&o.direct)&&!s.practice&&!n.includes(s.slug)}).sort((s,o)=>r(s.slug)-r(o.slug)||s.name.localeCompare(o.name)).map(s=>({slug:s.slug,name:s.name}))}function KB(e,t){var r,s;const n=[];for(const o of e.slice().sort((i,a)=>i.ts-a.ts)){const i=((r=o.patch)==null?void 0:r.answer)??((s=o.patch)==null?void 0:s.body);typeof i!="string"||!i.trim()||i==="(withdrawn)"||n.push({who:t(o.by),text:i})}return n}const B1=1500,VB=7e3;function qB({sent:e,asker:t,others:n,transcript:r}){const s=[];let o=VB;for(const a of r.slice(-12).reverse()){const c=Hh(a.text).trim(),u=c.length>B1?`${c.slice(0,B1)}…`:c,d=`**${a.who}:** ${u}`;if(d.length>o)break;o-=d.length,s.unshift(d)}const i=n.length?` in a conversation with ${n.join(", ")}`:" in a conversation";return[Hh(e).trim(),"---",`Asked by ${t}${i}. Your answer is shown in that conversation, so write it for everyone in it.`,...s.length?["The conversation so far, newest last:",...s]:[]].join(`
|
|
98
|
+
|
|
99
|
+
`)}function YB(e,t){if(Mo(e).who==="private")return{};const n=[...new Set(t.filter(Boolean))];return n.length?{visibility:"people",visibleTo:n}:{visibility:"private"}}function GB(e){const n=(String(e??"").replace(Jb," ").split(`
|
|
100
|
+
`).map(s=>s.trim()).find(Boolean)??"").replace(/\s+/g," ").replace(/^[,.:;\s-]+/,"").trim(),r=n.length>80?`${n.slice(0,80).replace(/\s+\S*$/,"")}…`:n;return r?r[0].toUpperCase()+r.slice(1):"Asked in a conversation"}const Ec={inbox:{view:"list",sort:"priority",priorities:[],projects:[],updated:"any",privacy:"any"},team:{view:"board",sort:"priority",priorities:[],projects:[],updated:"any",privacy:"any"}};function hT(e,t){return t==="shared"?e!=="private":t==="private"?e==="private":!0}const JB=(e,t)=>e===t?"any":t,fT="threads.privacy";function XB(e=typeof localStorage>"u"?null:localStorage){try{const t=JSON.parse((e==null?void 0:e.getItem(fT))??"null");return t==="shared"||t==="private"?t:"any"}catch{return"any"}}function QB(e,t=typeof localStorage>"u"?null:localStorage){try{t==null||t.setItem(fT,JSON.stringify(e))}catch{}}const ZB=(e,t,n)=>({...e,privacy:n?t:"any"}),Hm=e=>({...e,view:e.view==="board"?"list":"board"}),pT=2,e4=e=>e?"team":"inbox",mT=e=>`threads.display.${e}`;function _1(e,t=typeof localStorage>"u"?null:localStorage){try{const n=t==null?void 0:t.getItem(mT(e));if(!n)return Ec[e];const r=JSON.parse(n);return{view:r.view==="board"||r.view==="list"?r.view:Ec[e].view,sort:e==="team"&&r.sort==="updated"&&r.v!==pT?"priority":r.sort==="updated"||r.sort==="priority"?r.sort:Ec[e].sort,priorities:Array.isArray(r.priorities)?r.priorities.filter(s=>["urgent","high","medium","low"].includes(s)):[],projects:Array.isArray(r.projects)?r.projects.filter(s=>typeof s=="string"):[],updated:r.updated==="today"||r.updated==="week"?r.updated:"any"}}catch{return Ec[e]}}function t4(e,t,n=typeof localStorage>"u"?null:localStorage){try{n==null||n.setItem(mT(e),JSON.stringify({...t,v:pT}))}catch{}}const gT=e=>e.priorities.length>0||e.projects.length>0||e.updated!=="any"||e.privacy==="shared"||e.privacy==="private",fu=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()};function Um(e,t,n,r,s){return!(!hT(r,t.privacy)||t.priorities.length&&!t.priorities.includes(kr(e.priority))||t.projects.length&&e.product&&!t.projects.includes(e.product)&&!(s!=null&&s.has(e.product))||t.updated==="today"&&!(e.updatedAt>=fu(n))||t.updated==="week"&&!(e.updatedAt>=n-7*864e5))}const Uh=(e,t=[],n)=>WA(e.place,BA(t,e.product??"",n)+hu(kr(e.priority))),n4=(e=[],t)=>(n,r)=>Uh(r,e,t)-Uh(n,e,t)||r.updatedAt-n.updatedAt,r4=(e,t)=>t.updatedAt-e.updatedAt,Wy=e=>{var t,n;return e.status==="done"&&((n=(t=e.wrote)==null?void 0:t.status)==null?void 0:n.ts)||e.updatedAt},yT=(e,t)=>Wy(t)-Wy(e),Km=e=>e.status==="done"?1:0,s4=e=>(t,n)=>Km(t)-Km(n)||(Km(t)?yT(t,n):e(t,n)),W1=e=>e.pinned&&e.status!=="done"?1:0,o4=e=>(t,n)=>W1(n)-W1(t)||e(t,n),Kh=(e,t,n=[],r)=>{if(t==="done")return yT;const s=o4(e.sort==="updated"?r4:n4(n,r));return t==="all"?s4(s):s},i4=e=>e==="done"?"Done":"Updated";function H1(e,t,n,r=[],s){const o=Kh(t,n,r,s),i=e.filter(a=>a.product!=="");return i.length===e.length?e.slice().sort(o):[...e.filter(a=>a.product===""),...i.sort(o)]}const Hy=e=>({...e,product:e.projectSlug,...e.item?{status:e.item.status,wrote:e.item.wrote,place:e.item.place,pinned:e.item.pinned}:{}});function a4(e,t,n,r=[],s){const o=Kh(t,n,r,s);return e.slice().sort((i,a)=>o(Hy(i),Hy(a)))}const l4=(e,t=[],n)=>Uh(Hy(e),t,n),wT=15e3;function c4(e,t,n=Date.now()){const r=Object.keys(t);if(!r.length)return e;const s=new Map(e.map(o=>[o.id,o]));for(const o of r){const i=s.get(o);(!i||i.place===t[o].place||n-t[o].at>wT)&&delete t[o]}return e.map(o=>o.id in t?{...o,place:t[o.id].place}:o)}function u4(e,t,n=Date.now()){const r=Object.keys(t);if(!r.length)return e;const s=new Map(e.map(o=>[o.id,o]));for(const o of r){const i=s.get(o);(!i||!!i.pinned===t[o].pinned||n-t[o].at>wT)&&delete t[o]}return e.map(o=>o.id in t?{...o,pinned:t[o.id].pinned}:o)}function d4(e,t,n){const r=e.findIndex(o=>o.id===t),s=n?e.findIndex(o=>o.id===n):-1;return kF(e,r,s<0?e.length:s)}function bT(e,t,n){const r=d4(e,t,n),s=e.find(h=>h.id===t);if(!s||!r)return{places:r,pin:null};const o=e.filter(h=>h.id!==t),i=n?o.findIndex(h=>h.id===n):-1,a=i<0?void 0:o[i],c=i<0?o[o.length-1]:o[i-1],d=!!(c!=null&&c.pinned)&&!!a&&!a.pinned?!!s.pinned:!!(a??c??s).pinned;return{places:r,pin:d===!!s.pinned?null:d}}function h4(e,t,n=!1){if(!e.length)return"inbox";const r=e.indexOf(t);return r<0?e[0]:e[(r+(n?-1:1)+e.length)%e.length]}function f4(e,t){const n={progress:"Nothing in your filter is running",snoozed:"Nothing in your filter is in Later",done:"Nothing in your filter is closed",all:"No threads match your filter"}[e]??"Nothing in your filter needs you",r=t===1?"One more thread is behind your filters.":`${t} more threads are behind your filters.`;return{head:n,line:r}}function p4(e,t,{picked:n=[],limit:r=8}={}){const s=new Map;for(const d of t){if(d.agent)continue;const h=s.get(d.product)??0;d.updatedAt>h&&s.set(d.product,d.updatedAt)}const o=e.filter(d=>!Us(d)&&!d.practice).sort((d,h)=>(s.get(h.slug)??0)-(s.get(d.slug)??0)||d.name.localeCompare(h.name)),i=o.filter(d=>n.includes(d.slug)),a=o.filter(d=>!n.includes(d.slug)),c=[...i,...a],u=Math.max(r,i.length);return{shown:c.slice(0,u),rest:c.slice(u)}}function m4(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<1)return"just now";if(n<60)return`${n} min ago`;const r=Math.floor(n/60);return e>=fu(t)?`${r} hour${r===1?"":"s"} ago`:e>=fu(t)-864e5?"Yesterday":new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}const Us=e=>{var t;return!!((t=e==null?void 0:e.team)!=null&&t.direct)},fp=(e=[])=>new Set(e.filter(Us).map(t=>t.slug));function g4(e,t,n=[]){if(!Us(e)||!t)return null;const r=e.team,s=new Set([...r.people??[],...r.sharedBy?[r.sharedBy]:[]]),o=[...s].filter(i=>i&&i!==t);return!o.length||!n.some(i=>i.id!==t&&!s.has(i.id))?null:{to:o[0],also:o.slice(1)}}function pp(e,t,n){return!n||!t||Us(t)||e.agent||e.createdBy&&e.createdBy!==n.me?null:Kb(e,n.since??null,t)?$u(e,t).length?"people":"team":"private"}function Xb(e,t,n,r=()=>"Someone"){var h,f,p,m;if(!Us(t))return null;const s=t.team,o=[...(s==null?void 0:s.people)??[],...s!=null&&s.sharedBy?[s.sharedBy]:[],...e.people??[]];let i=[...new Set(o)].filter(w=>w&&w!==n);!i.length&&e.createdBy&&e.createdBy!==n&&(i=[e.createdBy]);const a=dp(e,n);if(a&&e.talk){const w=v=>Iy(Hh(v)),b=a.threads[0];if(b){const v=b.mine?"your thread":"a thread";return{people:i,fromMe:!1,text:`${r(b.lastBy)} in ${v}: ${w(b.last)}`}}const x=e.talk.chat[e.talk.chat.length-1];if(x)return{people:i,fromMe:!!n&&x.by===n,text:w(x.text)}}const c=!!e.answer&&e.answer!=="(withdrawn)",u=Iy(Hh(String((c?e.answer:e.body)||e.title||""))),d=(c?(f=(h=e.wrote)==null?void 0:h.answer)==null?void 0:f.by:(m=(p=e.wrote)==null?void 0:p.body)==null?void 0:m.by)??e.createdBy??null;return{people:i,fromMe:!!n&&d===n,text:u}}function xT(e){var n;const t=(n=e.wrote)==null?void 0:n.priority;return t&&t.source!=="system"?e.priority??null:null}const y4=e=>({visibility:e==="private"?"team":"private"});function w4({items:e,products:t,cards:n,me:r,now:s,since:o=null,stateOf:i,live:a,allMine:c=!1,nameOf:u}){const d=new Map(t.map(m=>[m.slug,m])),h=fu(s),f=[];for(const m of e){if(m.agent)continue;const w=d.get(m.product);if(!w)continue;if(Us(w)){const x=c?Xb(m,w,r,u):null,v=x&&(i==null?void 0:i(m));if(!x||!v||v==="done"&&!(m.updatedAt>=h))continue;f.push({key:`mine/${m.product}/${m.id}`,ownerId:r,state:v,title:x.text,project:"Message",projectSlug:w.slug,priority:xT(m),updatedAt:m.updatedAt,item:m,card:null,message:{people:x.people,fromMe:x.fromMe}});continue}if(r&&m.createdBy&&m.createdBy!==r||!c&&rT(m,w)!=="private"&&!Kb(m,o,w))continue;const b=(i==null?void 0:i(m))??up(m,s);b==="done"&&!(m.updatedAt>=h)||f.push({key:`mine/${m.product}/${m.id}`,ownerId:r,state:b,title:m.label||m.title,project:w.name,projectSlug:w.slug,priority:m.priority??null,updatedAt:m.updatedAt,item:m,card:null,live:!!(a!=null&&a.has(m.id))})}const p=new Map(t.map(m=>[m.name,m.slug]));for(const m of n)m.personId!==r&&m.visible&&(m.state==="done"&&!(m.updatedAt>=h)||f.push({key:`card/${m.personId}/${m.threadId}`,ownerId:m.personId,state:m.state,title:m.visible?m.title:null,project:m.visible?m.project:null,projectSlug:m.visible&&p.get(m.project??"")||null,priority:m.priority,updatedAt:m.updatedAt,item:null,card:m}));return f.sort((m,w)=>w.updatedAt-m.updatedAt)}const kT=[{state:"waiting",label:"Waiting"},{state:"running",label:"In progress"},{state:"scheduled",label:"Later"},{state:"done",label:"Done today"}],bl=kT.map(e=>e.state),vT="threads.board.columns";function b4(e=typeof localStorage>"u"?null:localStorage){try{const t=JSON.parse((e==null?void 0:e.getItem(vT))??"null");if(!Array.isArray(t))return bl;const n=[...new Set(t.filter(r=>bl.includes(r)))];return[...n,...bl.filter(r=>!n.includes(r))]}catch{return bl}}function x4(e,t=typeof localStorage>"u"?null:localStorage){try{t==null||t.setItem(vT,JSON.stringify(e))}catch{}}function k4(e,t){let n=-1;for(let r=0;r<e.length;r++)(n<0||Math.abs(e[r]-t)<Math.abs(e[n]-t))&&(n=r);return n}function v4(e,t,n){if(n<0||n>=e.length||!e.includes(t))return e.slice();const r=e.filter(s=>s!==t);return r.splice(n,0,t),r}function S4(e,{person:t,projectName:n},r,s){return!(r.priorities.length&&!r.priorities.includes(kr(e.priority))||r.updated==="today"&&!(e.updatedAt>=fu(s))||r.updated==="week"&&!(e.updatedAt>=s-7*864e5))}function Uy({items:e,products:t,display:n,now:r,stateOf:s,cards:o=[],picked:i,me:a,since:c=null,live:u,order:d=bl,projectOrder:h=[],nameOf:f}){const p=i??(a?[a]:[]),m=b=>b.item?pp(b.item,t.find(x=>x.slug===b.item.product),a?{me:a,since:c}:null):"team",w=w4({items:a&&!p.includes(a)?[]:e,products:t,cards:o.filter(b=>p.includes(b.personId)),me:a,now:r,since:c,stateOf:s,live:u,allMine:!0,nameOf:f}).filter(b=>!b.item||b.message||n.projects.length===0||n.projects.includes(b.item.product)).filter(b=>hT(m(b),n.privacy)).filter(b=>S4(b,{person:null,projectName:null},n,r));return d.flatMap(b=>kT.filter(x=>x.state===b)).map(b=>({...b,rows:a4(w.filter(x=>x.state===b.state),n,b.state,h,fp(t))}))}function U1(e){return e.flatMap(t=>t.rows).flatMap(t=>t.item?[t.item]:[])}function j4(e,t,n){const r=e.map(o=>o.rows.flatMap(i=>i.item?[i.item]:[]));let s=0;for(let o=0;o<r.length;o++){const i=t-s;if(i>=0&&i<r[o].length){for(let a=o+n;a>=0&&a<r.length;a+=n){if(!r[a].length)continue;return r.slice(0,a).reduce((u,d)=>u+d.length,0)+Math.min(i,r[a].length-1)}return t}s+=r[o].length}return t}function Ky(e,{products:t,items:n,me:r}){const s=new Set([...[].concat(e),...r?[r]:[]]),o=c=>[...new Set([...c.people,...c.sharedBy?[c.sharedBy]:[]])],i=c=>o(c).length===s.size&&o(c).every(u=>s.has(u)),a=t.filter(c=>{var u;return((u=c.team)==null?void 0:u.direct)&&i(c.team)}).sort((c,u)=>String(c.team.projectId).localeCompare(String(u.team.projectId)))[0];return a?n.filter(c=>c.product===a.slug&&!c.agent).sort((c,u)=>(u.updatedAt??0)-(c.updatedAt??0))[0]??null:null}const ST="threads.people";function C4(e=typeof localStorage>"u"?null:localStorage){try{const t=e==null?void 0:e.getItem(ST);if(!t)return null;const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>typeof r=="string"):null}catch{return null}}function N4(e,t=typeof localStorage>"u"?null:localStorage){try{t==null||t.setItem(ST,JSON.stringify(e))}catch{}}function E4(e,t,n){const r=(e??[]).filter(s=>n.includes(s));return r.length?r:t?[t]:[]}function A4(e,t,n){if(!e.includes(t))return[...e,t];const r=e.filter(s=>s!==t);return r.length?r:e}const jT=(e,t)=>e.some(n=>n!==t),K1=(e,t)=>jT(e,t)?"Waiting":"Needs you";function T4(e,t,n){const r=a=>(a.name||a.email||"Someone").split(/[\s@]/)[0],s=e.filter(a=>t.includes(a.id));if(e.length>1&&s.length===e.length)return"Everyone";const o=s.filter(a=>a.id!==n);if(!o.length)return"Just you";const i=n!==null&&t.includes(n);return o.length===1?i?`You and ${r(o[0])}`:r(o[0]):i?`You and ${o.length} others`:`${o.length} people`}function M4(e,t,n,r=3){if(!e.some(a=>a.id!==n))return null;const s=a=>a.name||a.email||"",o=e.filter(a=>t.includes(a.id)),i=[...o.filter(a=>a.id===n),...o.filter(a=>a.id!==n).sort((a,c)=>s(a).localeCompare(s(c)))];return{faces:i.slice(0,r),more:Math.max(0,i.length-r)}}function R4(e,t,n){if(!e.some(s=>s.id!==n))return!1;const r=e.filter(s=>t.includes(s.id));return r.length===e.length?!1:!(r.length===1&&r[0].id===n)}const I4={inbox:e=>e==="waiting",progress:e=>e==="running",snoozed:e=>e==="scheduled",done:e=>e==="done",all:()=>!0},D4=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()};function Vm(e,{tab:t,picked:n,me:r,display:s,products:o,now:i}){const a=I4[t];if(!a)return[];const c=new Map(o.map(u=>[u.name,u.slug]));return e.filter(u=>!(u.personId===r||!n.includes(u.personId)||!u.visible||!a(u.state)||s.privacy==="private"||s.priorities.length&&!s.priorities.includes(kr(u.priority))||s.projects.length&&!s.projects.includes(c.get(u.project??"")??"")||s.updated==="today"&&!(u.updatedAt>=D4(i))||s.updated==="week"&&!(u.updatedAt>=i-7*864e5)))}function O4(e,t,n,r={order:[],products:[]},s){const o=new Map(r.products.map(f=>[f.name,f.slug])),i=f=>({priority:f.priority,updatedAt:f.updatedAt,product:o.get(f.project??"")??null,status:f.state==="done"?"done":void 0}),a=n==="done"?Kh({sort:"updated"},"done"):Kh({sort:n},s,r.order,fp(r.products)),c=t.slice().sort((f,p)=>a(i(f),i(p))),u=(f,p)=>a(i(f),p)<0,d=[];let h=0;for(const f of e){for(;h<c.length&&u(c[h],f);)d.push({card:c[h++]});d.push({item:f})}for(;h<c.length;)d.push({card:c[h++]});return d}const ra=e=>e.item?`item/${e.item.product}/${e.item.id}`:`card/${e.card.personId}/${e.card.threadId}`;function V1(e,t){if(!t)return e.map(r=>({item:r}));const n=new Set(e.map(r=>r.id));return t.filter(r=>r.card?!0:n.has(r.item.id))}function L4(e){return e.flatMap(t=>t.rows).flatMap(t=>t.item?[{item:t.item}]:t.card?[{card:t.card}]:[])}function qm(e,t,n,r=-1){const s=t?ra(t):null,o=s?e.findIndex(a=>ra(a)===s):-1,i=(o>=0?o:r)+n;return i>=0&&i<e.length?e[i]:null}function $4({change:e,terminal:t,finish:n,runNow:r=!1,pin:s=null}){const o=[];return r&&o.push({id:"run",label:"Run now",key:null}),e&&o.push({id:"code",label:"View code changes",key:null}),t&&o.push({id:"terminal",label:t==="open"?"Hide terminal":"Open terminal",key:"⌘J"}),s&&o.push({id:"pin",label:s==="pinned"?"Unpin thread":"Pin thread",key:null}),n&&o.push({id:"done",label:"Mark done",key:"E"}),o}const Pu={viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};function P4(){return l.jsxs("svg",{...Pu,children:[l.jsx("path",{d:"m8.5 7-5 5 5 5"}),l.jsx("path",{d:"m15.5 7 5 5-5 5"})]})}function z4(){return l.jsxs("svg",{...Pu,children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"16"}),l.jsx("path",{d:"m7 9 3 3-3 3m6 0h4"})]})}function F4(){return l.jsxs("svg",{...Pu,children:[l.jsx("path",{d:"m3 13 3.6 3.6L13.4 9"}),l.jsx("path",{d:"m10.6 13 3.6 3.6L21 9"})]})}function B4(){return l.jsxs("svg",{...Pu,children:[l.jsx("path",{d:"M5 5v14"}),l.jsx("path",{d:"m9 5 10 7-10 7z"})]})}function CT({size:e=16,className:t}){return l.jsxs("svg",{...Pu,width:e,height:e,className:t,children:[l.jsx("path",{d:"M8 3h8l-1.5 6 3.5 3.5H6L9.5 9z"}),l.jsx("path",{d:"M12 12.5V21"})]})}const _4={run:B4,code:P4,terminal:z4,pin:()=>l.jsx(CT,{}),done:F4};function W4(){return l.jsxs("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor","aria-hidden":"true",children:[l.jsx("rect",{x:"2.5",y:"7",width:"2",height:"2"}),l.jsx("rect",{x:"7",y:"7",width:"2",height:"2"}),l.jsx("rect",{x:"11.5",y:"7",width:"2",height:"2"})]})}function H4({rows:e,change:t,onPick:n}){return l.jsx("div",{className:"th-menu ts-more-menu",role:"menu","aria-label":"Thread actions",children:e.map(r=>{const s=_4[r.id];return l.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:"row-i ts-more-row",onClick:()=>n(r.id),children:[l.jsx("span",{className:"ico",children:l.jsx(s,{})}),l.jsx("span",{className:"ts-more-label",children:r.label}),r.id==="code"?t:r.key&&l.jsx("kbd",{children:r.key})]},r.id)})})}function U4({change:e=null,onViewChange:t,terminal:n=null,onToggleTerminal:r,onFinish:s=null,onRunNow:o=null,pinned:i=null,onPin:a}){const c=$4({change:!!e,terminal:n,finish:!!s,runNow:!!o,pin:i===null||!a?null:i?"pinned":"unpinned"}),[u,d]=g.useState(!1),h=g.useRef(null),f=g.useRef(null),p=g.useCallback(b=>{var x;d(!1),b&&((x=f.current)==null||x.focus())},[]);g.useEffect(()=>{if(!u)return;const b=v=>{var S;(S=h.current)!=null&&S.contains(v.target)||p(!1)},x=v=>{var C,O;if(v.key==="Escape"){v.preventDefault(),v.stopImmediatePropagation(),p(!0);return}const S=[...((C=h.current)==null?void 0:C.querySelectorAll('[role="menuitem"]'))??[]];if(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Home"||v.key==="End"){if(v.preventDefault(),v.stopImmediatePropagation(),!S.length)return;const N=S.indexOf(document.activeElement),P=v.key==="Home"?0:v.key==="End"?S.length-1:v.key==="ArrowDown"?(N+1)%S.length:N<=0?S.length-1:N-1;S[P].focus();return}if((v.key==="Enter"||v.key===" ")&&((O=h.current)!=null&&O.contains(document.activeElement))){v.stopImmediatePropagation();return}v.key==="Tab"&&p(!1)};return document.addEventListener("pointerdown",b),window.addEventListener("keydown",x,!0),()=>{document.removeEventListener("pointerdown",b),window.removeEventListener("keydown",x,!0)}},[u,p]),g.useEffect(()=>{var b,x;u&&((x=(b=h.current)==null?void 0:b.querySelector('[role="menuitem"]'))==null||x.focus())},[u]);const m=b=>{b.key!=="Enter"&&b.key!==" "&&b.key!=="ArrowDown"||(b.preventDefault(),b.stopPropagation(),d(!0))},w=b=>{p(b==="terminal"),b==="run"?o==null||o():b==="code"?t==null||t():b==="terminal"?r==null||r():b==="pin"?a==null||a(!i):s==null||s()};return c.length?l.jsxs("span",{className:"ts-more-wrap",ref:h,children:[l.jsx("button",{ref:f,type:"button",className:"ts-more","aria-label":"More actions",title:"More","aria-haspopup":"menu","aria-expanded":u,onClick:()=>d(b=>!b),onKeyDown:m,children:l.jsx(W4,{})}),u&&l.jsx(H4,{rows:c,change:e,onPick:w})]}):null}function K4(e){return e.shift||e.meta||e.ctrl?"toggle":"open"}function V4(e,t){const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function q4(e,t,n){return e.size?V4(e,t):new Set(n?[n,t]:[t])}function Y4(e,t){return{left:Math.min(e.x,t.x),top:Math.min(e.y,t.y),right:Math.max(e.x,t.x),bottom:Math.max(e.y,t.y)}}function G4(e,t){return t.filter(({box:n})=>e.left<n.right&&e.right>n.left&&e.top<n.bottom&&e.bottom>n.top).map(n=>n.id)}function J4(e,t,n){return new Set(n?[...e,...t]:t)}const q1=typeof window>"u"?g.useEffect:g.useLayoutEffect,Y1={duration:180,easing:"cubic-bezier(.2,.8,.2,1)"},X4=()=>l.jsxs("svg",{className:"th-col-grip",viewBox:"0 0 10 16",width:"8",height:"13",fill:"currentColor","aria-hidden":"true",children:[l.jsx("circle",{cx:"2.5",cy:"3",r:"1.4"}),l.jsx("circle",{cx:"7.5",cy:"3",r:"1.4"}),l.jsx("circle",{cx:"2.5",cy:"8",r:"1.4"}),l.jsx("circle",{cx:"7.5",cy:"8",r:"1.4"}),l.jsx("circle",{cx:"2.5",cy:"13",r:"1.4"}),l.jsx("circle",{cx:"7.5",cy:"13",r:"1.4"})]}),NT=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[l.jsx("path",{d:"M12 20h8"}),l.jsx("path",{d:"m4 20 1-4.5L15.5 5a2.1 2.1 0 0 1 3 3L8 18.5 4 20Z"})]}),Q4=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[l.jsx("circle",{cx:"11",cy:"11",r:"6"}),l.jsx("path",{d:"m20 20-4.5-4.5"})]}),Z4=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[l.jsx("path",{d:"M4 7h10M18 7h2M4 17h4M12 17h8"}),l.jsx("circle",{cx:"16",cy:"7",r:"2"}),l.jsx("circle",{cx:"10",cy:"17",r:"2"})]}),e_=()=>l.jsx("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:l.jsx("path",{d:"M4 6h16M4 12h16M4 18h16"})}),t_=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[l.jsx("rect",{x:"3.5",y:"4",width:"5",height:"16",rx:"1"}),l.jsx("rect",{x:"10.5",y:"4",width:"5",height:"11",rx:"1"}),l.jsx("rect",{x:"17.5",y:"4",width:"3",height:"7",rx:"1"})]}),ET=()=>l.jsxs("svg",{className:"th-lock",width:"11",height:"12",viewBox:"0 0 11 12",fill:"none",stroke:"currentColor",strokeWidth:"1.2","aria-label":"Private",children:[l.jsx("rect",{x:"1.5",y:"5.5",width:"8",height:"6",rx:"1"}),l.jsx("path",{d:"M3.5 5.5V3.8a2 2 0 0 1 4 0v1.7"})]}),n_=16;function r_({title:e,mark:t}){if(!t)return l.jsx(l.Fragment,{children:e});const n=e.trimEnd(),r=Math.max(0,n.search(/\S+$/)),s=n.length-r>n_?n.length-3:r;return l.jsxs(l.Fragment,{children:[n.slice(0,s),l.jsxs("span",{className:"th-keep",children:[n.slice(s),t]})]})}function Rl({className:e="th-shared",label:t}){return l.jsxs("svg",{className:e,width:"14",height:"12",viewBox:"2 4 20 17",fill:"none",stroke:"currentColor",strokeWidth:"1.7",...t?{role:"img","aria-label":t}:{"aria-hidden":!0},children:[l.jsx("circle",{cx:"9",cy:"9",r:"3.2"}),l.jsx("path",{d:"M3 19.5c.6-3.2 3-5 6-5s5.4 1.8 6 5"}),l.jsx("path",{d:"M15.5 6.2a3 3 0 0 1 0 5.6M17.5 14.8c1.8.6 3 2.1 3.4 4.7"})]})}function Vy({state:e,live:t=!1}){return l.jsx("span",{className:`th-st s-${e}${t?" live":""}`,"aria-hidden":"true",title:t?"An agent is on it now":void 0})}const Qb=g.createContext(new Set),Zb=g.createContext(new Map);function ex({id:e}){return l.jsx("span",{className:"th-prio-mark",children:l.jsx(xi,{id:e})})}function s_(e,t){const n=g.useRef(null);return g.useEffect(()=>{if(!e)return;const r=o=>{n.current&&!n.current.contains(o.target)&&t()},s=o=>{o.key==="Escape"&&(o.stopPropagation(),t())};return document.addEventListener("mousedown",r),document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",s,!0)}},[e,t]),n}function o_({page:e,display:t,onDisplay:n,products:r,items:s,onSearch:o,onCompose:i,shown:a,total:c,tab:u,people:d}){const[h,f]=g.useState(!1),p=s_(h,()=>f(!1)),m=d?M4(d.everyone,d.picked,d.me):null,w=m&&d?T4(d.everyone,d.picked,d.me):null,x=!(!!m&&!!(d!=null&&d.me)&&d.picked.length===1&&d.picked[0]===d.me)&&(gT(t)||!!d&&R4(d.everyone,d.picked,d.me));return l.jsxs("div",{className:"th-right",children:[l.jsxs("button",{type:"button",className:"th-search","data-hint":"search","data-hint-text":"span",onClick:o,title:"Search threads (/)","aria-label":"Search threads",children:[l.jsx(Q4,{}),l.jsx("span",{children:"Search"})]}),l.jsxs("button",{type:"button",className:"th-new","data-hint":"new-task",onClick:i,title:"New thread (N)",children:[l.jsx(NT,{}),"New thread"]}),l.jsxs("span",{ref:v=>{p.current=v},style:{position:"relative",display:"inline-flex"},children:[l.jsxs("button",{type:"button",className:`th-disp${m?" faces":""}${h?" open":""}`,"aria-label":w?`View and filters, showing ${w}`:"View and filters",title:w?`${w} · View and filters`:"View and filters",onClick:()=>f(v=>!v),children:[m&&l.jsxs("span",{className:"th-faces",children:[m.faces.map(v=>l.jsx(Rt,{person:v,me:v.id===d.me},v.id)),m.more>0&&l.jsxs("span",{className:"th-faces-more",children:["+",m.more]})]}),l.jsx(Z4,{}),x&&l.jsx("i",{})]}),h&&l.jsx(i_,{page:e,display:t,onDisplay:n,products:r,items:s,shown:a,total:c,tab:u,people:d})]})]})}const G1=(e,t)=>e.includes(t)?e.filter(n=>n!==t):[...e,t];function i_({page:e,display:t,onDisplay:n,products:r,items:s=[],shown:o,total:i,tab:a,people:c}){const[u,d]=g.useState(!1),{shown:h,rest:f}=p4(r,s,{picked:t.projects}),p=u?[...h,...f]:h,m=v=>n({...t,...v}),w=[["today","Today"],["week","This week"],["any","Any time"]],b=[["private","Private"],["shared","Shared"]],x=t.privacy??"any";return l.jsxs("div",{className:"th-pop",role:"dialog","aria-label":e==="inbox"?"Inbox view and filters":"Team view and filters",children:[c&&l.jsx(c_,{...c}),l.jsxs("div",{className:"line",children:[l.jsx("span",{className:"lab",children:"View"}),l.jsxs("span",{className:"opts",children:[l.jsxs("button",{type:"button",className:t.view==="list"?"on":"",title:"List (B)",onClick:()=>m({view:"list"}),children:[l.jsx(e_,{}),"List"]}),l.jsxs("button",{type:"button",className:t.view==="board"?"on":"",title:"Board (B)",onClick:()=>m({view:"board"}),children:[l.jsx(t_,{}),"Board"]})]})]}),l.jsxs("div",{className:"line",children:[l.jsx("span",{className:"lab",children:"Sort by"}),l.jsxs("span",{className:"opts",children:[l.jsx("button",{type:"button",className:t.sort==="priority"?"on":"",onClick:()=>m({sort:"priority"}),children:"Priority"}),l.jsx("button",{type:"button",className:t.sort==="updated"?"on":"",onClick:()=>m({sort:"updated"}),children:"Updated"}),a==="done"&&l.jsx("span",{className:"th-pop-note",children:"Done runs newest first"})]})]}),l.jsx("div",{className:"rule"}),l.jsxs("div",{className:"line",children:[l.jsx("span",{className:"lab",children:"Priority"}),l.jsx("span",{className:"opts",children:wr.map(v=>l.jsxs("button",{type:"button",className:t.priorities.includes(v.id)?"on":"",onClick:()=>m({priorities:G1(t.priorities,v.id)}),children:[l.jsx(ex,{id:v.id}),v.label]},v.id))})]}),e==="inbox"&&h.length+f.length>1&&l.jsxs("div",{className:"line",children:[l.jsx("span",{className:"lab",children:"Project"}),l.jsxs("span",{className:"opts",children:[l.jsx("button",{type:"button",className:t.projects.length===0?"on":"",onClick:()=>m({projects:[]}),children:"All projects"}),p.map(v=>l.jsx("button",{type:"button",className:t.projects.includes(v.slug)?"on":"",onClick:()=>m({projects:G1(t.projects,v.slug)}),children:v.name},v.slug)),f.length>0&&l.jsx("button",{type:"button",className:"th-pop-more",onClick:()=>d(!u),children:u?"Show fewer":`Show all ${h.length+f.length}`})]})]}),c&&l.jsxs("div",{className:"line",children:[l.jsx("span",{className:"lab",children:"Privacy"}),l.jsx("span",{className:"opts",children:b.map(([v,S])=>l.jsx("button",{type:"button",className:x===v?"on":"",onClick:()=>m({privacy:JB(x,v)}),children:S},v))})]}),l.jsxs("div",{className:"line",children:[l.jsx("span",{className:"lab",children:"Updated"}),l.jsx("span",{className:"opts",children:w.map(([v,S])=>l.jsx("button",{type:"button",className:t.updated===v?"on":"",onClick:()=>m({updated:v}),children:S},v))})]}),l.jsx("div",{className:"rule"}),l.jsxs("div",{className:"foot",children:[l.jsx("span",{children:o!==void 0&&i!==void 0?`Showing ${o} of ${i}`:""}),gT(t)&&l.jsx("button",{type:"button",onClick:()=>m({priorities:[],projects:[],updated:"any",privacy:"any"}),children:"Clear filters"})]})]})}const qy=[{view:"inbox",label:"Needs you"},{view:"progress",label:"In progress"},{view:"snoozed",label:"Later"},{view:"done",label:lu.short},{view:"all",label:"All"}],a_=["inbox","progress","snoozed"];function l_({view:e,counts:t,onView:n,needs:r}){return l.jsx("div",{className:"th-bar",children:l.jsx("div",{className:"tm-tabs",children:qy.map(s=>l.jsxs("button",{type:"button","data-hint":"state-tab",className:`tm-tab${e===s.view?" on":""}`,onClick:()=>n(s.view),children:[s.view==="inbox"&&r?r:s.label,a_.includes(s.view)&&!!t[s.view]&&l.jsx("b",{children:t[s.view]})]},s.view))})})}function c_({everyone:e,picked:t,me:n,onPick:r}){if(!e.some(c=>c.id!==n))return null;const s=c=>c.id===n?"You":c.name||c.email||"Someone",o=[...e.filter(c=>c.id===n),...e.filter(c=>c.id!==n).sort((c,u)=>s(c).localeCompare(s(u)))],i=o.every(c=>t.includes(c.id)),a=!!n&&t.length===1&&t[0]===n;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"line",children:[l.jsx("span",{className:"lab",children:"People"}),l.jsxs("span",{className:"opts",children:[l.jsx("button",{type:"button",className:i?"on":"",onClick:()=>r(o.map(c=>c.id)),children:"Everyone"}),n&&l.jsx("button",{type:"button",className:a?"on":"",onClick:()=>r([n]),children:"Just you"}),o.map(c=>l.jsxs("button",{type:"button","aria-pressed":t.includes(c.id),className:t.includes(c.id)?"on":"",onClick:()=>r(A4(t,c.id)),children:[l.jsx(Rt,{person:c,me:c.id===n}),s(c)]},c.id))]})]}),l.jsx("div",{className:"rule"})]})}function u_({running:e,scheduled:t,onView:n,onCompose:r,team:s=!1}){const o=(i,a,c)=>`${i} ${i===1?a:c}`;return l.jsxs("div",{className:"th-clear",children:[l.jsx("h2",{children:"Nothing needs you"}),l.jsx("p",{children:e>0?l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"th-clear-link",onClick:()=>n("progress"),children:o(e,"thread is running","threads are running")}),". Each one lands here when it needs you."]}):t>0?l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"th-clear-link",onClick:()=>n("snoozed"),children:o(t,"thread is scheduled","threads are scheduled")}),". Nothing else is open."]}):s?"Start a thread and an agent picks it up, or message a teammate.":"Start a thread and an agent picks it up."}),l.jsxs("div",{className:"th-clear-acts",children:[l.jsxs("button",{type:"button",className:"th-new",onClick:r,children:[l.jsx(NT,{}),"New thread"]}),l.jsxs("span",{className:"th-clear-key",children:["or press ",l.jsx("kbd",{children:"N"})]})]})]})}function d_({view:e,hidden:t,onClear:n}){const{head:r,line:s}=f4(e,t);return l.jsxs("div",{className:"th-clear th-clear-filtered",children:[l.jsx(h_,{}),l.jsx("h2",{children:r}),l.jsx("p",{children:s}),l.jsx("div",{className:"th-clear-acts",children:l.jsx("button",{type:"button",className:"th-new",onClick:n,children:"Clear filters"})})]})}const h_=()=>l.jsx("svg",{className:"th-clear-mark",width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"square","aria-hidden":"true",children:l.jsx("path",{d:"m4 12.5 5 5L20 6.5"})});function f_({view:e}){const t={progress:"Nothing is running.",snoozed:'Nothing is waiting for later. "Add it to Later" on a new thread writes one down without starting it.',done:"Nothing closed yet. A finished thread waits in Needs you until you close it.",all:"No threads yet."};return l.jsx("div",{className:"th-empty",children:t[e]??"Nothing here."})}function p_({person:e=!1,tab:t}){return l.jsxs("div",{className:"row th-head",children:[l.jsx("span",{className:"mark","aria-hidden":"true"}),l.jsxs("div",{className:`row-main th-grid${e?" with-person":""}`,children:[l.jsx("div",{children:"Thread"}),l.jsx("div",{children:"Project"}),e&&l.jsx("div",{children:"Person"}),l.jsx("div",{children:"Priority"}),l.jsx("div",{className:"num",children:i4(t)})]})]})}const m_=()=>l.jsxs("svg",{className:"th-repeat",width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-label":"Repeats",children:[l.jsx("path",{d:"M13 6.5A5.5 5.5 0 0 0 3.2 4.8M3 2.5v2.6h2.6"}),l.jsx("path",{d:"M3 9.5a5.5 5.5 0 0 0 9.8 1.7M13 13.5v-2.6h-2.6"})]});function Vh({live:e=!1,lead:t,title:n,hidden:r=!1,lock:s=!1,shared:o=!1,chosen:i=0,held:a=!1,pinned:c=!1,aside:u,where:d,person:h,priority:f,updatedAt:p,when:m,now:w,action:b}){const x=f===null?null:kr(f);return l.jsxs("div",{className:`row-main th-grid${h!==void 0?" with-person":""}`,children:[l.jsxs("div",{className:`th-cell-title subject${r?" hidden":""}`,children:[e?l.jsx(Vy,{state:"running",live:!0}):t,n,u&&l.jsx("span",{className:"th-aside",children:u}),a&&l.jsx("span",{className:"th-aside",children:"not started"}),o&&l.jsx(Rl,{label:i?`Visible to ${i} ${i===1?"person":"people"}`:"Visible to the team"}),i>0&&l.jsx("span",{className:"th-shared-n","aria-hidden":"true",children:i}),s&&l.jsx(ET,{}),c&&l.jsx(CT,{size:13,className:"th-pin"})]}),l.jsx("div",{className:"th-cell-proj",children:d}),h!==void 0&&l.jsx("div",{className:"th-cell-person",children:h}),l.jsx("div",{className:`th-cell-prio${x==="urgent"?" urgent":""}`,children:x&&l.jsxs(l.Fragment,{children:[l.jsx(ex,{id:x}),Ma(x)]})}),l.jsxs("div",{className:`th-cell-when num${b?" has-act":""}`,children:[l.jsx("span",{className:"th-when",children:m??m4(p,w)}),b]})]})}function AT({people:e,fromMe:t,text:n}){const r=g.useContext(Xt),s=e.length?(r==null?void 0:r.byId.get(e[0]))??null:null,o=e.map(i=>{var a;return e.length>1?bn((r==null?void 0:r.byId.get(i))??null):((a=r==null?void 0:r.byId.get(i))==null?void 0:a.name)||bn((r==null?void 0:r.byId.get(i))??null)}).join(", ");return l.jsxs("span",{className:"th-msg",children:[l.jsx(Rt,{person:s}),l.jsx("b",{className:"th-msg-who",children:o}),l.jsx("span",{className:"th-msg-text",children:t?`You: ${n}`:n})]})}function g_({item:e,product:t,now:n,person:r,tab:s}){const o=s==="done"?Wy(e):e.updatedAt,i=g.useContext(Qb),a=g.useContext(Zb),c=g.useContext(Xt),u=pp(e,t,c?{me:c.me,since:c.state.since??null}:null),[d,h]=g.useState(null);g.useEffect(()=>{h(null)},[e.visibility,e.visibleTo]);const f=u&&(d??u),p=f==="people"?$u(e,t).length:0,m=async()=>{if(!f)return;const v=y4(f);h(v.visibility),(await q.threadEdit(e.product,e.id,v)).ok||h(null)},w=f?l.jsxs("button",{type:"button",className:"th-row-act",onClick:v=>{v.stopPropagation(),m()},title:f==="private"?"Show this thread to the team":"Stop showing this thread",children:[l.jsx(Rl,{className:"th-row-act-mark"}),f==="private"?"Share":"Unshare"]}):void 0,b=Xb(e,t,(c==null?void 0:c.me)??null,v=>bn((c==null?void 0:c.byId.get(v))??null));if(b)return l.jsx(Vh,{live:i.has(e.id),title:l.jsx(AT,{people:b.people,fromMe:b.fromMe,text:b.text}),pinned:!!e.pinned&&e.status!=="done",where:"Message",person:r,priority:xT(e),updatedAt:o,now:n,action:w});const x=f==="private";return l.jsx(Vh,{live:i.has(e.id),title:Co(e),aside:cT(a.get(`${e.product}/${e.id}`)),shared:f==="people",chosen:p,lock:x,held:bo(e),pinned:!!e.pinned&&e.status!=="done",where:(t==null?void 0:t.name)??"",person:r,priority:e.priority??0,updatedAt:o,now:n,action:w})}function y_({items:e,products:t,display:n,now:r,onOpenItem:s,stateOf:o,cards:i=[],picked:a,onOpenCard:c,selected:u,selectedCard:d=null,columnOrder:h=bl,onReorderColumns:f,projectOrder:p,onPlaces:m,marked:w,onMark:b}){const x=g.useContext(Qb),v=g.useContext(Xt),S=(v==null?void 0:v.me)??null,O=(a??(S?[S]:[])).some(Z=>Z!==S),N=(v==null?void 0:v.state.since)??null,[P,M]=g.useState(null),[R,L]=g.useState(null),H=R??h,_=g.useMemo(()=>Uy({items:e,products:t,display:n,now:r,stateOf:o,cards:i,picked:a,me:S,since:N,live:x,order:H,projectOrder:p,nameOf:Z=>bn((v==null?void 0:v.byId.get(Z))??null)}),[e,t,n,r,o,i,a,S,N,x,H,p,v]),Y=g.useRef(new Map),se=g.useRef(H),re=g.useRef(H);re.current=H;const T=g.useRef(null),W=()=>{const Z=T.current;if(!(Z!=null&&Z.started))return;const Ce=Z.el,Ee=Z.x-Z.startX-(re.current.indexOf(Z.state)-Z.startIndex)*Z.pitch,oe=Math.max(-6,Z.y-Z.startY);Ce.style.transform=`translate(${Ee}px, ${oe}px) scale(1.02)`};q1(()=>{const Z=se.current;if(se.current=H,W(),Z===H)return;const Ce=H.map(oe=>{var ne;return((ne=Y.current.get(oe))==null?void 0:ne.offsetLeft)??0}),Ee=Ce.length>1?Ce[1]-Ce[0]:0;H.forEach((oe,ne)=>{if(oe===P)return;const Ie=Z.indexOf(oe),Q=Y.current.get(oe);Ie<0||Ie===ne||!(Q!=null&&Q.animate)||Q.animate([{transform:`translateX(${(Ie-ne)*Ee}px)`},{transform:"translateX(0)"}],Y1)})},[H]);const le=Z=>{const Ce=T.current;if(T.current=null,!(Ce!=null&&Ce.started))return;Z&&(f==null||f(re.current));const Ee=Ce.el.style.transform;Ce.el.style.transform="",Ee&&Ce.el.animate&&Ce.el.animate([{transform:Ee},{transform:"none"}],Y1),M(null),L(null)},ge=g.useRef(le);ge.current=le;const j=(Z,Ce)=>{const Ee=T.current;if(!Ee)return;if(Ee.x=Z,Ee.y=Ce,!Ee.started){if(Math.hypot(Ee.x-Ee.startX,Ee.y-Ee.startY)<4)return;const ne=re.current;Ee.slots=ne.map(Ie=>{var he;const Q=(he=Y.current.get(Ie))==null?void 0:he.getBoundingClientRect();return Q?Q.left+Q.width/2:0}),Ee.pitch=Ee.slots.length>1?Ee.slots[1]-Ee.slots[0]:0,Ee.startIndex=ne.indexOf(Ee.state),Ee.started=!0,M(Ee.state)}const oe=k4(Ee.slots,Ee.slots[Ee.startIndex]+(Ee.x-Ee.startX));oe>=0&&oe!==re.current.indexOf(Ee.state)&&L(v4(re.current,Ee.state,oe)),W()};g.useEffect(()=>{if(!P)return;const Z=Ce=>{Ce.key==="Escape"&&(Ce.preventDefault(),Ce.stopPropagation(),le(!1))};return window.addEventListener("keydown",Z,!0),()=>window.removeEventListener("keydown",Z,!0)});const ae=g.useMemo(()=>fp(t),[t]),me=lT(m?(Z,Ce,Ee)=>{const oe=_.find(te=>te.rows.some(ee=>{var U;return((U=ee.item)==null?void 0:U.id)===Z}));if(!oe)return;const ne=new Map(oe.rows.filter(te=>te.item).map(te=>[te.item.id,te])),Ie=Ee.flatMap(te=>{var U;const ee=ne.get(te);return ee?[{id:te,score:l4(ee,p,ae),pinned:!!((U=ee.item)!=null&&U.pinned)}]:[]}),{places:Q,pin:he}=bT(Ie,Z,Ce);Q&&m(Q,Z,he)}:void 0,"copy"),E=Z=>pp(Z,t.find(Ce=>Ce.slug===Z.product),v?{me:S,since:N}:null),K=Z=>Z.card?d===ra({card:Z.card}):!d&&!!Z.item&&!!u&&Z.item.id===u.id&&Z.item.product===u.product,z=!d&&u&&_.some(Z=>Z.rows.some(Ce=>!!Ce.item&&K(Ce)))?u.id:null,xe=g.useRef(null);q1(()=>{var oe,ne,Ie,Q;if((oe=T.current)!=null&&oe.started)return;const Z=(ne=xe.current)==null?void 0:ne.querySelector(".th-card.selected");if(!Z)return;const Ce=Z.parentElement;(Q=(Ie=(Ce==null?void 0:Ce.querySelector(".th-card"))===Z?(Ce==null?void 0:Ce.querySelector(".th-col-h"))??Z:Z).scrollIntoView)==null||Q.call(Ie,{block:"nearest",inline:"nearest"})},[u==null?void 0:u.id,u==null?void 0:u.product,d]);const Oe=g.useRef(null),[F,J]=g.useState(null),ze=g.useRef(b);ze.current=b;const ye=Z=>{if(Z.pointerType==="touch"||!b||Z.button!==0||Z.target.closest(".th-card, .th-col-h, button, a, input, textarea"))return;const Ce=Oe.current;if(!Ce)return;Z.preventDefault();const Ee=U=>{const I=Ce.getBoundingClientRect();return{x:U.clientX-I.left,y:U.clientY-I.top}},oe=Ee(Z),ne=new Set(w??[]),Ie=Z.shiftKey||Z.metaKey||Z.ctrlKey;let Q=!1;const he=U=>{var ie;const I=Ee(U);if(!Q&&Math.hypot(I.x-oe.x,I.y-oe.y)<4)return;Q=!0;const V=Y4(oe,I);J(V);const ue=Ce.getBoundingClientRect(),G=[...Ce.querySelectorAll("[data-board-id]")].map(we=>{const ve=we.getBoundingClientRect();return{id:we.dataset.boardId??"",box:{left:ve.left-ue.left,top:ve.top-ue.top,right:ve.right-ue.left,bottom:ve.bottom-ue.top}}});(ie=ze.current)==null||ie.call(ze,J4(ne,G4(V,G),Ie))},te=()=>{window.removeEventListener("pointermove",he),window.removeEventListener("pointerup",ee),window.removeEventListener("pointercancel",te),J(null)},ee=()=>{var U;te(),!Q&&!Ie&&ne.size&&((U=ze.current)==null||U.call(ze,new Set))};window.addEventListener("pointermove",he),window.addEventListener("pointerup",ee),window.addEventListener("pointercancel",te)};return l.jsxs("div",{className:`list hm-me th-board-wrap${F?" banding":""}`,ref:Oe,onPointerDown:ye,children:[F&&l.jsx("div",{className:"th-band","aria-hidden":"true",style:{left:F.left,top:F.top,width:F.right-F.left,height:F.bottom-F.top}}),l.jsx("div",{className:`th-board${P?" dragging":""}`,ref:xe,children:_.map(Z=>{const Ce=Z.rows,Ee=!!m&&Z.state!=="done"&&n.sort==="priority";return l.jsxs("div",{className:`th-col${P===Z.state?" lifted":""}`,"data-drag-scope":"",ref:oe=>{oe?Y.current.set(Z.state,oe):Y.current.delete(Z.state)},children:[l.jsxs("div",{className:`th-col-h${f?" movable":""}`,onPointerDown:oe=>{if(!f||oe.button!==0)return;const ne=Y.current.get(Z.state);if(!ne)return;oe.preventDefault(),T.current={state:Z.state,el:ne,startX:oe.clientX,startY:oe.clientY,x:oe.clientX,y:oe.clientY,started:!1,startIndex:0,slots:[],pitch:0};const Ie=ee=>j(ee.clientX,ee.clientY),Q=()=>{window.removeEventListener("pointermove",Ie),window.removeEventListener("pointerup",he),window.removeEventListener("pointercancel",te)},he=()=>{Q(),ge.current(!0)},te=()=>{Q(),ge.current(!1)};window.addEventListener("pointermove",Ie),window.addEventListener("pointerup",he),window.addEventListener("pointercancel",te)},children:[l.jsx(Vy,{state:Z.state}),Z.state==="waiting"&&!O?"Needs you":Z.label,l.jsx("b",{children:Ce.length}),f&&l.jsx(X4,{})]}),Ce.length===0&&l.jsx("div",{className:"th-col-empty",children:"Nothing here."}),Ce.map(oe=>{const ne=!!oe.item&&!!b,Ie=ne&&!!(w!=null&&w.has(oe.item.id)),Q=K(oe)&&!(w!=null&&w.size);return l.jsxs("button",{type:"button",className:`th-card${Q?" selected":""}${Ie?" picked":""}`,...ne?{"data-board-id":oe.item.id,"aria-pressed":Ie}:{},...Ee&&oe.item?{"data-drag-id":oe.item.id,onPointerDown:he=>me.onPointerDown(oe.item.id,he)}:{},onClick:he=>{if(!me.swallowsClick()){if(ne&&K4({shift:he.shiftKey,meta:he.metaKey,ctrl:he.ctrlKey})==="toggle"){b(q4(w??new Set,oe.item.id,z));return}oe.item?s(oe.item):oe.card&&(c==null||c(oe.card))}},children:[l.jsx("div",{className:"t",children:oe.message?l.jsx(AT,{people:oe.message.people,fromMe:oe.message.fromMe,text:oe.title??""}):l.jsx(r_,{title:oe.title??"",mark:oe.item&&E(oe.item)==="people"?l.jsx(Rl,{label:"Visible to the people on it"}):oe.item&&E(oe.item)==="private"?l.jsx(ET,{}):null})}),l.jsxs("div",{className:"m",children:[oe.live&&l.jsx(Vy,{state:"running",live:!0}),oe.priority!==null&&l.jsx(ex,{id:kr(oe.priority)}),l.jsx("span",{className:"p",children:oe.project}),O&&l.jsx(Rt,{person:oe.ownerId?(v==null?void 0:v.byId.get(oe.ownerId))??null:null,me:oe.ownerId===S})]})]},oe.key)})]},Z.state)})})]})}function J1({engineChoice:e,engines:t,item:n}){var o;if(!e||!t||hi(n))return null;const s=(n.labels??[]).some(i=>i==="codex"||i==="codex-import"||i==="not-imported")?"codex":((o=t.byItem)==null?void 0:o[n.id])??t.workspace??In;return VA({engineChoice:e,engine:s})}function X1({text:e,terms:t,phrase:n}){return t!=null&&t.length?l.jsx(l.Fragment,{children:uB(e,t,n).map((r,s)=>r.hit?l.jsx("b",{className:"hit",children:r.text},s):l.jsx("span",{children:r.text},s))}):l.jsx(l.Fragment,{children:e})}function Q1(e,t,n=Date.now()){const r=zb(e,n),s=r?`${new Date(r).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})} ${op(r,n).toLowerCase()}`:"not scheduled";return t?t.status==="open"||t.status==="claimed"?{when:s,last:`running, started ${Bs(t.createdAt,n)}`}:sp(t)?{when:s,last:`last run ${iu(t.updatedAt,n)}, clean`}:{when:s,last:`last run ${iu(t.updatedAt,n)}, ${DA(t.result)||"needs a look"}`}:{when:s,last:"not run yet"}}function Z1(e){return`${e.every==="weekday"?"weekdays":e.every==="week"?`every ${new Date(2026,0,4+(e.on??0)).toLocaleDateString(void 0,{weekday:"long"})}`:"every day"} at ${CA(e.at).replace(":00","")}`}function w_(e,t=Date.now()){const n=zb(e,t);if(!n)return"Not scheduled";const r=i=>new Date(i).setHours(0,0,0,0),s=Math.round((r(n)-r(t))/864e5),o=new Date(n);return s===0?"Today":s===1?"Tomorrow":s<7?o.toLocaleDateString(void 0,{weekday:"long"}):o.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function b_(e,t){const n=[];return e.forEach((r,s)=>{const o=t(r,s),i=n[n.length-1];(!i||i.label!==o)&&n.push({key:r.id,label:o,items:[]}),n[n.length-1].items.push({item:r,index:s})}),n}function x_({items:e,view:t,keyView:n,hoveredId:r,selected:s,seen:o,running:i,engineChoice:a,engines:c,stalled:u,queued:d,signInNeeded:h,atLimit:f,shipping:p,silent:m,paused:w,multiSel:b,snoozes:x,repeats:v,allItems:S,terms:C,phrase:O,summaries:N,searchDetails:P,ranked:M,emptyText:R,walk:L,onSelect:H,onOpen:_,onOpenRepeat:Y,onToggle:se,onRange:re,onHover:T,onAnswerImport:W,team:le=null,table:ge=!1,products:j=[],mixed:ae=null,personCell:me,onOpenCard:E,selectedCard:K=null,onEnd:z,onReorder:xe}){const Oe=g.useContext(Zb),F=lT(ge?xe:void 0),J=ee=>{F.carrying()||T==null||T(ee)},ze=t==="snoozed"?v??[]:[],ye=gF(n??t,b.size>0),Z=ee=>Qi(e.find(U=>U.id===ee))?[]:yF(ee===lp||ee===qA?ye.filter(U=>U.key!=="R"):ye,L??null,ee);if(e.length===0&&ze.length===0&&!(ae!=null&&ae.length))return R?l.jsx("div",{className:"empty",children:R}):null;const Ce=ee=>Math.max(ee.runAt??0,ee.snoozedUntil??0,(x==null?void 0:x[ee.id])??0),Ee=ee=>Ce(ee)||ee.updatedAt,oe=ee=>new Date(ee).toLocaleString(void 0,{weekday:"short",hour:"numeric",minute:"2-digit"}),ne=t==="inbox"&&!M?e.findIndex(da):-1,Ie=b_(e,(ee,U)=>ge?"":t==="done"&&Ly(ee)?nB:t==="snoozed"&&!pn(ee)&&!M?`Returns ${op(Ee(ee))}`:ne>=0&&U>=ne?da(ee)?pF:mF:""),Q=new Map(e.map((ee,U)=>[ee.id,U])),he=ge&&ae?[{key:"mixed",label:"",items:ae.flatMap(ee=>ee.card?[{card:ee.card}]:Q.has(ee.item.id)?[{item:ee.item,index:Q.get(ee.item.id)}]:[])}]:Ie,te=ge&&!!ae;return l.jsxs("div",{className:`list${ge?" th-table":""}`,ref:F.listRef,children:[ge&&l.jsx(p_,{person:te,tab:t}),ge&&ze.map(ee=>{const U=S??e,I=ee.lastOccurrence?U.find(ue=>ue.id===ee.lastOccurrence)??null:null,V=!!I&&(I.status==="open"||I.status==="claimed");return l.jsxs("div",{"data-repeat-id":ee.id,className:"row",title:Q1(ee,I).last,onClick:()=>Y==null?void 0:Y(ee),children:[l.jsx("span",{className:"mark","aria-hidden":"true"}),l.jsx(Vh,{live:V,lead:l.jsx(m_,{}),title:ee.title,aside:Z1(ee),where:ee.productName,person:te?me==null?void 0:me((le==null?void 0:le.me)??null):void 0,priority:ee.priority??5,updatedAt:ee.updatedAt??ee.createdAt,when:w_(ee),now:Date.now()})]},ee.id)}),!ge&&ze.length>0&&l.jsxs("div",{children:[l.jsx("div",{className:"day-label",children:"Repeating"}),ze.map(ee=>{const U=S??e,I=ee.lastOccurrence?U.find(ue=>ue.id===ee.lastOccurrence)??null:null,V=Q1(ee,I);return l.jsxs("div",{"data-repeat-id":ee.id,className:"row",onClick:()=>Y==null?void 0:Y(ee),children:[l.jsx("span",{className:"mark"}),l.jsxs("div",{className:"row-main",children:[l.jsx("div",{className:"subject",children:ee.title}),l.jsx("div",{className:"preview",children:V.last})]}),l.jsxs("div",{className:"row-end",children:[l.jsx("span",{className:"chip",children:Z1(ee)}),l.jsx("span",{className:"product",children:ee.productName}),l.jsx("span",{className:"time",children:V.when})]})]},ee.id)})]}),he.map(ee=>l.jsxs("div",{children:[ee.label&&!ge&&l.jsx("div",{className:"day-label",children:ee.label}),ee.items.map(U=>{if(U.card){const de=U.card,be=`card/${de.personId}/${de.threadId}`;return l.jsxs("div",{className:`row th-their-row${K===be?" selected":""}`,onClick:()=>E==null?void 0:E(de),children:[l.jsx("span",{className:"mark","aria-hidden":"true"}),l.jsx(Vh,{title:de.title??"Private thread",where:de.project??"",person:me==null?void 0:me(de.personId),priority:de.priority,updatedAt:de.updatedAt,now:Date.now()})]},be)}const{item:I,index:V}=U,ue=i.find(de=>de.itemId===I.id),G=b.has(I.id),ie=pn(I)||nr(I),we=ge&&!!xe&&!ie&&!Qi(I),ve=P==null?void 0:P.get(I.id);return l.jsxs("div",{...we?{"data-drag-id":I.id,onPointerDown:de=>F.onPointerDown(I.id,de)}:{},"data-item-id":I.id,...t==="inbox"&&!Qi(I)?{"data-hint":"row","data-hint-text":".subject"}:{},className:`row ${ie?"trouble-row ":""}${V===s&&!K?"selected":""} ${G?"checked":""}`,onMouseMove:()=>{r!==I.id&&(J==null||J(I.id))},onMouseLeave:()=>{r===I.id&&(J==null||J(null))},onClick:de=>{if(F.swallowsClick())return;const be=m1("row",{shift:de.shiftKey,meta:de.metaKey,ctrl:de.ctrlKey});if(be==="range"){re(V);return}if(be==="toggle"){se(V);return}H(V),_(I)},children:[ie?l.jsx("span",{className:"trouble-rule","aria-hidden":"true"}):l.jsx("button",{type:"button",className:`mark${G?" on":""}`,role:"checkbox","aria-checked":G,"aria-label":`${G?"Deselect":"Select"} ${(ve==null?void 0:ve.title)??Co(I)}`,onClick:de=>{de.stopPropagation(),m1("box",{shift:de.shiftKey})==="range"?re(V):se(V)},children:l.jsx("span",{className:"box","aria-hidden":"true"})}),ge&&!(L&&Z(I.id).length)&&!Qi(I)?l.jsx(g_,{item:I,product:j.find(de=>de.slug===I.product),now:Date.now(),tab:t,person:te?me==null?void 0:me((le==null?void 0:le.me)??null):void 0}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"row-main",children:[l.jsxs("div",{className:"subject",children:[(ve==null?void 0:ve.kind)==="chat"&&l.jsxs("span",{className:"th-faces search-faces",children:[ve.people.slice(0,3).map(de=>l.jsx(Rt,{person:le==null?void 0:le.byId.get(de)},de)),ve.people.length>3&&l.jsxs("span",{className:"th-faces-more",children:["+",ve.people.length-3]})]}),l.jsx(X1,{text:(ve==null?void 0:ve.title)??Co(I),terms:C,phrase:O}),Oe.get(`${I.product}/${I.id}`)?l.jsx("span",{className:"th-aside",children:cT(Oe.get(`${I.product}/${I.id}`))}):null]}),l.jsx("div",{className:"preview",children:l.jsx(X1,{text:(N==null?void 0:N.get(I.id))??zA(I,t),terms:C,phrase:O})})]}),l.jsx("div",{className:"row-end",children:(ve==null?void 0:ve.kind)==="chat"?l.jsx(l.Fragment,{children:l.jsx("span",{className:"time",children:iu(I.updatedAt)})}):l.jsx(l.Fragment,{children:L&&Z(I.id).length?l.jsx("span",{className:"row-keys",children:Z(I.id).map(de=>l.jsxs("span",{className:"row-key",children:[l.jsx("kbd",{children:de.key}),l.jsx("span",{className:"row-key-word",children:de.word})]},de.key))}):Qi(I)?l.jsx("span",{className:"row-keys import-keys",children:ZF.map(de=>l.jsxs("button",{type:"button",className:"row-key",title:de.word,onClick:be=>{be.stopPropagation(),W==null||W(I,de.key==="1"?"yes":"no")},children:[l.jsx("kbd",{children:de.key}),l.jsx("span",{className:"row-key-word",children:de.word})]},de.key))}):l.jsxs(l.Fragment,{children:[t==="done"&&Ly(I)?l.jsx("span",{className:"row-keys import-keys import-key",children:eB.map(de=>l.jsxs("button",{type:"button",className:"row-key",title:de.word,onClick:be=>{be.stopPropagation(),W==null||W(I,"yes")},children:[l.jsx("kbd",{children:de.key}),l.jsx("span",{className:"row-key-word",children:de.word})]},de.key))}):null,da(I)||I.agent?null:(I.priority??5)>=7?l.jsxs("span",{className:"prio-bars p3",title:"high priority",children:[l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{})]}):(I.priority??5)<=2?l.jsxs("span",{className:"prio-bars p1 low",title:"low priority",children:[l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{})]}):null,le?l.jsx(bB,{item:I,team:le}):l.jsx("span",{className:"product",children:I.productName}),!Pc(I,o)&&!ue&&J1({engineChoice:a,engines:c,item:I})&&l.jsx("span",{className:"time agent",children:J1({engineChoice:a,engines:c,item:I})}),!Pc(I,o)&&ue&&Oy({engineChoice:a,session:ue})&&l.jsx("span",{className:"time agent",children:Oy({engineChoice:a,session:ue})}),Pc(I,o)?l.jsx("span",{className:"time imported",children:QF}):ue?l.jsxs("span",{className:"time working",children:["working · ",Bs(ue.startedAt)]}):u!=null&&u.includes(I.id)?l.jsxs("span",{className:"time stalled",children:["stopped · ",Bs(I.updatedAt)]}):UA(I,m==null?void 0:m[I.id])?l.jsxs("span",{className:"time quiet",title:"An agent ran on this and finished without writing anything back. Send it a message to find out what happened.",children:["nothing came back · ",Bs(m[I.id].endedAt||I.updatedAt)]}):h!=null&&h[I.id]?l.jsx("span",{className:"time",title:`${h[I.id]} is signed out, so nothing can start. Sign in again and this starts on its own.`,children:"signed out"}):f!=null&&f[I.id]?l.jsx("span",{className:"time",title:`${f[I.id].tool} is at its usage limit, so this starts on its own when it resets.`,children:"at its limit"}):p!=null&&p.includes(I.id)?l.jsx("span",{className:"time",title:"The app is shipping this. It comes back to you once it is live, or goes back to its agent if it fails.",children:"shipping"}):d!=null&&d.includes(I.id)?l.jsx("span",{className:"time",children:"queued"}):w&&t==="progress"?l.jsx("span",{className:"time",children:"paused"}):l.jsx("span",{className:"time",children:t==="snoozed"?oe(Ee(I)):t==="inbox"?iu(I.updatedAt):Bs(I.updatedAt)})]})})})]})]},I.id)})]},ee.key)),z&&l.jsx(k_,{onEnd:z})]})}function k_({onEnd:e}){const t=g.useRef(null);return g.useEffect(()=>{const n=t.current;if(!n||typeof IntersectionObserver>"u")return;const r=new IntersectionObserver(s=>{s.some(o=>o.isIntersecting)&&e()},{rootMargin:"0px 0px 800px 0px"});return r.observe(n),()=>r.disconnect()},[e]),l.jsx("div",{ref:t,className:"list-foot","aria-hidden":!0})}function v_({product:e,id:t}){const[n,r]=g.useState(null),[s,o]=g.useState(!1),i={product:e,id:t};g.useEffect(()=>{let d=!1;const h=()=>q.remoteControl({product:e,id:t,action:"status"}).then(m=>{d||r(m)}).catch(()=>{});h();const f=setInterval(h,Ta(1e3,sr())),p=()=>{q.remoteControl({product:e,id:t,action:"toggle"}).then(m=>{d||r(m)}).catch(m=>{d||r({state:"failed",at:Date.now(),text:m.message})})};return window.addEventListener("task-remote-control-open",p),()=>{d=!0,clearInterval(f),window.removeEventListener("task-remote-control-open",p)}},[e,t]);const a=async d=>{o(!0);try{r(await q.remoteControl({...i,action:d}))}catch(h){r({state:"failed",at:Date.now(),text:h instanceof Error?h.message:"The operation failed."})}finally{o(!1)}};if(!n||n.state==="off")return null;const c=["ready","connected"].includes(n.state),u=["connecting","disconnecting","reconnecting"].includes(n.state);return l.jsxs("section",{className:"thread remote-control",onMouseDown:d=>d.stopPropagation(),"aria-label":"Remote control",children:[l.jsx("div",{className:"remote-command",children:"/remote-control"}),l.jsxs("div",{className:"remote-card",children:[l.jsxs("div",{className:"remote-main",children:[l.jsxs("svg",{className:"remote-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"3",y:"4",width:"12",height:"10",rx:"2"}),l.jsx("path",{d:"M7 18h4M9 14v4"}),l.jsx("rect",{x:"16",y:"9",width:"5",height:"11",rx:"1.5"})]}),l.jsxs("div",{className:"remote-copy",children:[l.jsx("div",{className:"remote-eyebrow",role:"status",children:c?"Remote control is on":u?n.state==="connecting"?"Connecting…":n.state==="disconnecting"?"Turning off…":"Reconnecting…":"Remote control"}),l.jsx("h3",{children:c?"Your conversation goes with you":n.state==="failed"?"Couldn’t connect":"Pick up on another device"}),l.jsx("p",{children:n.text||(c?"Open this chat in Claude on your phone or browser.":"Continue this chat in Claude on your phone or browser.")})]})]}),l.jsxs("div",{className:"remote-footer",children:[l.jsx("p",{className:"remote-permission",children:c||u?`Keep ${st} running on this computer.`:"Anthropic syncs this conversation. Remote messages use this task’s tools and permissions."}),l.jsxs("div",{className:"remote-actions",children:[c&&n.url?l.jsxs("a",{className:"remote-primary",href:n.url,target:"_blank",rel:"noreferrer",children:["Open in Claude ",l.jsx("span",{"aria-hidden":"true",children:"↗"})]}):!u&&!n.mayBeActive?l.jsxs("button",{className:"remote-primary",disabled:s,onClick:()=>void a("enable"),children:[n.state==="failed"?"Try again":"Enable Remote Control"," ",l.jsx("span",{"aria-hidden":"true",children:"→"})]}):null,l.jsx("button",{className:"remote-secondary",disabled:s||n.state==="connecting"||n.state==="disconnecting",onClick:()=>void a(n.mayBeActive||c||u?"disable":"dismiss"),children:n.mayBeActive||c||u?"Turn off":"Not now"})]})]})]})]})}function ka(e){if(!e)return null;const t=String(e).split(/[?#]/)[0];return/\.html?$/i.test(t)?"html":/\.(md|markdown)$/i.test(t)?"markdown":/\.change$/i.test(t)?"code":/\.(png|jpe?g|gif|webp|svg)$/i.test(t)?"image":null}function S_(e){return ka(e)!==null}function TT(e,t=[]){const n=String(e??"").replace(/^file:\/\//,"").replace(/\/+$/,"");if(!n)return[];let r="";for(const o of t){if(!o)continue;const i=o.replace(/\/+$/,"");(n===i||n.startsWith(`${i}/`))&&i.length>r.length&&(r=i)}if(r){const o=r.split("/").filter(Boolean).slice(-1),i=n.slice(r.length+1).split("/").filter(Boolean);return[...o,...i]}return n.split("/").filter(Boolean).slice(-3)}function j_(e){const t=TT(e);return t[t.length-1]??""}const C_=.25,N_=.75,MT=.5,ch=.72;function tx(e){return Number.isFinite(e)?Math.min(N_,Math.max(C_,e)):MT}function eS(e,t){return t?tx((t-e)/t):MT}const RT="zero.docPane.split.v1";function E_(e){try{const t=e==null?void 0:e.getItem(RT);if(!t)return ch;const n=Number.parseFloat(t);return Number.isFinite(n)?tx(n):ch}catch{return ch}}function A_(e,t){try{e==null||e.setItem(RT,String(tx(t)))}catch{}}function T_(e){return!!e&&!e.auto}function M_(e){return!!e}const R_="doc-view";function I_(e){var t;return!e||String(e.tagName??"").toUpperCase()!=="IFRAME"?!1:!!((t=e.classList)!=null&&t.contains(R_))}function si({ready:e=!1,delayed:t=!1}){const[n,r]=g.useState(!t);return g.useEffect(()=>{if(r(!t),!t||e)return;const s=setTimeout(()=>r(!0),500);return()=>clearTimeout(s)},[t,e]),l.jsx("div",{className:"preview-loading",role:"status","aria-label":"Loading preview","aria-hidden":e||!n,"data-ready":e,"data-delayed":t&&!n,children:l.jsxs("div",{className:"preview-skeleton","aria-hidden":"true",children:[l.jsx("div",{className:"preview-skeleton-title"}),l.jsx("div",{className:"preview-skeleton-line"}),l.jsx("div",{className:"preview-skeleton-line preview-skeleton-short"}),l.jsx("div",{className:"preview-skeleton-block"}),l.jsx("div",{className:"preview-skeleton-line"}),l.jsx("div",{className:"preview-skeleton-line preview-skeleton-short"})]})})}function D_(e){let t=!1,n=requestAnimationFrame(()=>{t||(n=requestAnimationFrame(()=>{t||e()}))});return()=>{t=!0,cancelAnimationFrame(n)}}function IT(e){const[t,n]=g.useState(null),r=g.useRef(null);g.useEffect(()=>(n(null),()=>{var o;(o=r.current)==null||o.call(r)}),[e]);const s=g.useCallback(()=>{var o;(o=r.current)==null||o.call(r),r.current=D_(()=>n(e))},[e]);return[e!==null&&t===e,s]}class O_{constructor(t=12){A0(this,"entries",new Map);this.limit=t}acquire(t,n){let r=this.entries.get(t);return r||(r={value:n(),users:0}),r.users++,this.entries.delete(t),this.entries.set(t,r),this.trim(),r.value}release(t){const n=this.entries.get(t);n&&(n.users=Math.max(0,n.users-1)),this.trim()}trim(){for(const[t,n]of this.entries){if(this.entries.size<=this.limit)break;n.users||(this.entries.delete(t),n.value.dispose())}}}function tS({product:e,path:t}){const n=ka(t)??"html",[r,s]=g.useState(null),o=g.useRef(null),[i,a]=g.useState(0),[c,u]=g.useState(null),[d,h]=IT(c),[f,p]=g.useState(!1);return g.useEffect(()=>{let m=!0;return u(null),p(!1),s(null),n==="code"||n==="markdown"?((n==="code"?q.codeChange({product:e,src:t}).then(b=>{if(!b.ok||!b.change)throw new Error("Unavailable");return b.change.files.flatMap(v=>[v.path,...v.hunks.flatMap(S=>S.rows.map(([C,O])=>`${C==="="?" ":C} ${O}`))]).slice(0,5).join(`
|
|
101
|
+
`)}):q.readDoc({product:e,src:t}).then(b=>{if(!b.ok)throw new Error("Unavailable");return(b.text??"").split(`
|
|
102
|
+
`).filter(x=>x.trim()).slice(0,5).join(`
|
|
103
|
+
`)})).then(b=>{m&&s(b||"Empty document")}).catch(()=>{m&&p(!0)}),()=>{m=!1}):(q.resolveDoc({product:e,src:t}).then(w=>{m&&(w.ok&&w.url?u(w.url):p(!0))}).catch(()=>{m&&p(!0)}),()=>{m=!1})},[e,t,n]),g.useEffect(()=>{if(!o.current)return;const m=new ResizeObserver(([w])=>{w.contentRect.width>0&&a(w.contentRect.width)});return m.observe(o.current),()=>m.disconnect()},[]),l.jsxs("div",{ref:o,className:"artifact-thumbnail","data-kind":n,"aria-label":"Artifact preview",children:[r!==null?l.jsx("pre",{children:r}):c&&!f?l.jsx("iframe",{src:c,title:`Preview of ${t.split("/").pop()}`,sandbox:"allow-same-origin",scrolling:"no",tabIndex:-1,loading:"lazy",onError:()=>p(!0),onLoad:h,style:{opacity:d?.55:0,transform:`scale(${i/1200})`}}):f?l.jsx("span",{children:"Preview unavailable"}):l.jsx(si,{delayed:!0}),c&&!f&&l.jsx(si,{ready:d,delayed:!0})]})}const nS=new O_(12);let il=null;function rS(){return il||(il=document.createElement("div"),il.hidden=!0,il.inert=!0,document.body.appendChild(il)),il}function sS(e,t){e.moveBefore(t,null)}function DT({product:e,path:t,revision:n=0}){const r=g.useRef(null),s=typeof Element<"u"&&"moveBefore"in Element.prototype;return g.useLayoutEffect(()=>{if(!s||!r.current)return;const o=JSON.stringify([e,t,n]),i=nS.acquire(o,()=>{const a=document.createElement("div");a.style.display="contents",rS().appendChild(a);const c=R$(a);return c.render(l.jsx(tS,{product:e,path:t})),{host:a,dispose:()=>{queueMicrotask(()=>{c.unmount(),a.remove()})}}});return sS(r.current,i.host),()=>{sS(rS(),i.host),nS.release(o)}},[e,t,n,s]),s?l.jsx("div",{ref:r,className:"retained-preview"}):l.jsx(tS,{product:e,path:t})}function L_({product:e,path:t,revision:n,open:r=!1,onOpen:s,onAddContext:o}){var m;const[i,a]=g.useState(null),[c,u]=g.useState(!1),d=ka(t)==="code";g.useEffect(()=>{let w=!0;return a(null),u(!1),d&&q.codeChange({product:e,src:t}).then(b=>{w&&(b.ok&&b.change?a(b.change):u(!0))}).catch(()=>{w&&u(!0)}),()=>{w=!1}},[e,t,n,d]);const h=d?"Code changes":ka(t)==="markdown"?"Document":"Design",f=RP((i==null?void 0:i.files)??[]),p=DP(i?f.total:0);return l.jsxs("section",{className:"direct-review","aria-label":`${h} review`,children:[l.jsx("button",{type:"button",className:"review-card-hit","aria-expanded":r,"aria-label":i?`Open all ${f.total} changed files`:`Open ${h.toLowerCase()} preview`,onClick:s}),l.jsxs("header",{children:[l.jsx("span",{className:"review-title",children:OP(t,i?f.total:void 0)}),l.jsxs("span",{className:"review-status",children:[l.jsx("i",{}),"Ready for review"]})]}),l.jsx("div",{className:"review-inset",children:i?l.jsxs("div",{className:"review-bundle",children:[l.jsxs("div",{className:"review-files",children:[f.visible.map(w=>l.jsxs("div",{children:[l.jsx("span",{children:w.path.split("/").pop()}),l.jsxs("small",{children:["+",w.plus," −",w.minus]})]},w.path)),f.remaining>0&&l.jsxs("p",{children:["+",f.remaining," more file",f.remaining===1?"":"s"]})]}),l.jsx("div",{className:"review-code","aria-label":"Code excerpt",children:MP(((m=i.files[0])==null?void 0:m.hunks.flatMap(w=>w.rows))??[]).map(w=>l.jsxs("div",{className:"review-code-line","data-mark":w.mark,children:[l.jsx("span",{className:"review-line-number","aria-hidden":"true",children:w.line}),l.jsxs("code",{children:[l.jsx("span",{className:"review-mark",children:w.mark==="="?" ":w.mark}),IP(w.text).map((b,x)=>l.jsx("span",{className:b.c?`t-${b.c}`:void 0,children:b.s},x))]})]},w.line))})]}):d?l.jsx("div",{className:"review-code-placeholder",children:c?l.jsx("span",{children:"Preview unavailable"}):l.jsx(si,{delayed:!0})}):l.jsx(DT,{product:e,path:t,revision:n})}),l.jsxs("footer",{className:"review-controls",children:[l.jsxs("button",{type:"button",className:"review-open","aria-expanded":r,"aria-label":p,title:`${p} beside the conversation`,onClick:s,children:[l.jsx(Ym,{kind:"expand"}),l.jsx("span",{children:p})]}),o&&l.jsxs("div",{className:"review-responses",children:[l.jsxs("button",{type:"button",className:"review-feedback","aria-label":"Feedback / changes",title:"Add feedback context to your reply draft",onClick:()=>o("feedback"),children:[l.jsx(Ym,{kind:"feedback"}),l.jsx("span",{children:"Feedback"})]}),l.jsxs("button",{type:"button",className:"review-accept",title:"Add Looks good to your reply draft","aria-label":"Looks good",onClick:()=>o("approve"),children:[l.jsx(Ym,{kind:"approve"}),l.jsx("span",{children:"Looks good"})]})]})]})]})}function Ym({kind:e}){return l.jsx("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="expand"?l.jsx("path",{d:"M12 3.5h4.5V8M16.5 3.5l-5 5M8 16.5H3.5V12M3.5 16.5l5-5"}):e==="approve"?l.jsx("path",{d:"m4.5 10 3.5 3.5 7.5-7.5"}):l.jsx("path",{d:"M5 4h10a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H9l-4.5 3v-3H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z"})})}async function $_(e,t,n){const r=P_(n);try{if(r==="markdown"||r==="html"){const o=await e.readDoc({product:t,src:n});return o.ok?z_(o.text??"",r):null}if(r==="code"){const o=await e.codeChange({product:t,src:n});return o.ok&&o.change?{title:"Code changes",line:null,blocks:[]}:null}return(await e.resolveDoc({product:t,src:n})).ok?{title:null,line:null,blocks:[]}:null}catch{return null}}function P_(e){const t=e.split(/[?#]/)[0]??"";return/\.html?$/i.test(t)?"html":/\.(md|markdown)$/i.test(t)?"markdown":/\.change$/i.test(t)?"code":"other"}function z_(e,t="markdown"){return t==="html"?B_(e):F_(e)}function F_(e){let t=null,n=null,r=!1;const s=[];for(const o of e.split(`
|
|
104
|
+
`)){if(/^\s*(```|~~~)/.test(o)){r=!r;continue}if(r)continue;const i=o.match(/^\s{0,3}#{1,6}\s+(.*?)\s*#*\s*$/);if(i){const c=oS(i[1]??"");if(!c)continue;t?s.length<6&&s.push({heading:!0,text:c}):t=c;continue}if(/^\s*(---+|\*\*\*+|___+)\s*$/.test(o)||/^\s*\|/.test(o)||/^\s*<!--/.test(o))continue;const a=oS(o.replace(/^\s*(?:[-*+]|\d+[.)]|>)\s+/,""));a&&(n||(n=a),s.length<6&&s.push({heading:!1,text:a}))}return{title:t,line:n,blocks:s}}function B_(e){const t=e.replace(/<(script|style|svg)[\s\S]*?<\/\1>/gi,""),n=o=>{const i=t.match(o);return i&&__(i[1].replace(/<[^>]+>/g," ")).replace(/\s+/g," ").trim()||null},r=n(/<title[^>]*>([\s\S]*?)<\/title>/i)??n(/<h1[^>]*>([\s\S]*?)<\/h1>/i)??n(/<h2[^>]*>([\s\S]*?)<\/h2>/i),s=n(/<p[^>]*>([\s\S]*?)<\/p>/i);return{title:r,line:s,blocks:[]}}function __(e){return e.replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'|'/g,"'")}function oS(e){return e.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/(\*\*|__|\*|_|`)(.+?)\1/g,"$2").replace(/\s+/g," ").trim()}const W_={html:"Design",image:"Picture",markdown:"Document",code:"Code"};function H_({product:e,paths:t,revision:n,openDoc:r,onOpen:s}){return t.length?l.jsx("div",{className:"message-files","aria-label":"Files",children:t.map(o=>l.jsx(U_,{product:e,path:o,revision:n,open:r===o,onOpen:()=>s(o)},o))}):null}function U_({product:e,path:t,revision:n,open:r,onOpen:s}){const[o,i]=g.useState(null);if(g.useEffect(()=>{let d=!0;return i(null),$_(q,e,t).then(h=>{d&&i(h)}),()=>{d=!1}},[e,t,n]),!o)return null;const a=t.split("/").pop()??t,c=ka(t),u=c==="html"||c==="image";return l.jsxs("button",{type:"button",className:"message-file","aria-pressed":r,title:`Open ${a}`,onClick:s,children:[l.jsxs("span",{className:"message-file-face",children:[u?l.jsx(DT,{product:e,path:t,revision:n}):l.jsx(K_,{title:o.title||a,blocks:o.blocks}),l.jsx("i",{className:"tick tl"}),l.jsx("i",{className:"tick tr"}),l.jsx("i",{className:"tick bl"}),l.jsx("i",{className:"tick br"})]}),l.jsxs("span",{className:"message-file-foot",children:[l.jsx("span",{className:"message-file-name",children:a}),l.jsx("span",{className:"message-file-kind",children:c?W_[c]:"File"})]})]})}function K_({title:e,blocks:t}){return l.jsxs("span",{className:"message-file-page","aria-hidden":"true",children:[l.jsx("b",{children:e}),t.map((n,r)=>n.heading?l.jsx("em",{children:n.text},r):l.jsx("span",{children:n.text},r))]})}function qh(e){if(typeof e!="string"||/[\r\n]/.test(e))return null;const t=e.trim().match(/^((?:\/|\.\/)?[\w@.-]+(?:\/[\w@.-]+)*\.(?:[cm]?jsx?|tsx?|py|go|rs|rb|java|kt|swift|[ch](?:pp)?|cs|css|scss|vue|svelte|sql|sh|json|ya?ml|toml))(?::[1-9]\d*(?:-[1-9]\d*)?|#L[1-9]\d*)?$/i);return!t||t[1].split("/").includes("..")?null:t[1]}const V_={thread:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M5 3v14a3 3 0 0 0 3 3h3M5 7h6"}),l.jsx("rect",{x:"11",y:"3",width:"10",height:"7",rx:"2"}),l.jsx("rect",{x:"11",y:"16",width:"10",height:"6",rx:"2"})]}),folder:l.jsx("path",{d:"M3 7.5A2.5 2.5 0 0 1 5.5 5H9l2 2.2h7.5A2.5 2.5 0 0 1 21 9.7v7.8a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 17.5z"}),page:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),l.jsx("path",{d:"M3 9h18M6.5 6.6h.01M9.3 6.6h.01"})]}),doc:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M14 3H7.5A2.5 2.5 0 0 0 5 5.5v13A2.5 2.5 0 0 0 7.5 21h9a2.5 2.5 0 0 0 2.5-2.5V8z"}),l.jsx("path",{d:"M14 3v5h5M9 13h6M9 16.5h4"})]}),image:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),l.jsx("circle",{cx:"9",cy:"10",r:"1.7"}),l.jsx("path",{d:"m21 15.5-4.5-4.5L7 20.5"})]}),code:l.jsx("path",{d:"m8 8-4 4 4 4M16 8l4 4-4 4M13.5 5l-3 14"}),media:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2.5"}),l.jsx("path",{d:"m10 9.5 4.5 2.5-4.5 2.5z"})]}),link:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1"}),l.jsx("path",{d:"M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1"})]}),file:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M14 3H7.5A2.5 2.5 0 0 0 5 5.5v13A2.5 2.5 0 0 0 7.5 21h9a2.5 2.5 0 0 0 2.5-2.5V8z"}),l.jsx("path",{d:"M14 3v5h5"})]})};function Yh({kind:e}){return l.jsx("svg",{className:"mention-icon",viewBox:"0 0 24 24","aria-hidden":"true",strokeLinecap:"round",strokeLinejoin:"round",children:V_[e]})}function Yy({kind:e,href:t,title:n,label:r,className:s,onClick:o,onKeyDown:i,children:a}){const c=`mention mention-${e}${s?` ${s}`:""}`;return!t&&!o?l.jsxs("span",{className:`${c} mention-unavailable`,title:n,children:[l.jsx(Yh,{kind:e}),l.jsx("span",{className:"mention-name",children:a})]}):l.jsxs("a",{className:c,href:t,title:n,"aria-label":r,rel:"noreferrer",onClick:o,onKeyDown:i,children:[l.jsx(Yh,{kind:e}),l.jsx("span",{className:"mention-name",children:a})]})}const OT=g.createContext([]),nx=g.createContext(null);function LT({id:e,children:t}){const n=g.useContext(nx);if(!n)return l.jsx(l.Fragment,{children:t});const r=n.name(e);return r?l.jsx(Yy,{kind:"thread",href:uu+e,title:r,label:`Open thread: ${r}`,onClick:s=>{s.preventDefault(),s.stopPropagation(),n.open(e)},onKeyDown:s=>s.stopPropagation(),children:r}):l.jsx(Yy,{kind:"thread",title:"This thread is not available.",children:"Unavailable thread"})}function $T({text:e}){return l.jsx(l.Fragment,{children:QA(e).map((t,n)=>t.id?l.jsx(LT,{id:t.id,children:t.text},n):t.text)})}function q_(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Y_=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,G_=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,J_={};function iS(e,t){return(J_.jsx?G_:Y_).test(e)}const X_=/[ \t\n\f\r]/g;function Q_(e){return typeof e=="object"?e.type==="text"?aS(e.value):!1:aS(e)}function aS(e){return e.replace(X_,"")===""}let zu=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};zu.prototype.normal={};zu.prototype.property={};zu.prototype.space=void 0;function PT(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new zu(n,r,t)}function Gy(e){return e.toLowerCase()}class vr{constructor(t,n){this.attribute=n,this.property=t}}vr.prototype.attribute="";vr.prototype.booleanish=!1;vr.prototype.boolean=!1;vr.prototype.commaOrSpaceSeparated=!1;vr.prototype.commaSeparated=!1;vr.prototype.defined=!1;vr.prototype.mustUseProperty=!1;vr.prototype.number=!1;vr.prototype.overloadedBoolean=!1;vr.prototype.property="";vr.prototype.spaceSeparated=!1;vr.prototype.space=void 0;let Z_=0;const ct=Ra(),rn=Ra(),Jy=Ra(),Te=Ra(),Tt=Ra(),ha=Ra(),Ir=Ra();function Ra(){return 2**++Z_}const Xy=Object.freeze(Object.defineProperty({__proto__:null,boolean:ct,booleanish:rn,commaOrSpaceSeparated:Ir,commaSeparated:ha,number:Te,overloadedBoolean:Jy,spaceSeparated:Tt},Symbol.toStringTag,{value:"Module"})),Gm=Object.keys(Xy);class rx extends vr{constructor(t,n,r,s){let o=-1;if(super(t,n),lS(this,"space",s),typeof r=="number")for(;++o<Gm.length;){const i=Gm[o];lS(this,Gm[o],(r&Xy[i])===Xy[i])}}}rx.prototype.defined=!0;function lS(e,t,n){n&&(e[t]=n)}function Yl(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new rx(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Gy(r)]=r,n[Gy(o.attribute)]=r}return new zu(t,n,e.space)}const zT=Yl({properties:{ariaActiveDescendant:null,ariaAtomic:rn,ariaAutoComplete:null,ariaBusy:rn,ariaChecked:rn,ariaColCount:Te,ariaColIndex:Te,ariaColSpan:Te,ariaControls:Tt,ariaCurrent:null,ariaDescribedBy:Tt,ariaDetails:null,ariaDisabled:rn,ariaDropEffect:Tt,ariaErrorMessage:null,ariaExpanded:rn,ariaFlowTo:Tt,ariaGrabbed:rn,ariaHasPopup:null,ariaHidden:rn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Tt,ariaLevel:Te,ariaLive:null,ariaModal:rn,ariaMultiLine:rn,ariaMultiSelectable:rn,ariaOrientation:null,ariaOwns:Tt,ariaPlaceholder:null,ariaPosInSet:Te,ariaPressed:rn,ariaReadOnly:rn,ariaRelevant:null,ariaRequired:rn,ariaRoleDescription:Tt,ariaRowCount:Te,ariaRowIndex:Te,ariaRowSpan:Te,ariaSelected:rn,ariaSetSize:Te,ariaSort:null,ariaValueMax:Te,ariaValueMin:Te,ariaValueNow:Te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function FT(e,t){return t in e?e[t]:t}function BT(e,t){return FT(e,t.toLowerCase())}const e5=Yl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ha,acceptCharset:Tt,accessKey:Tt,action:null,allow:null,allowFullScreen:ct,allowPaymentRequest:ct,allowUserMedia:ct,alpha:ct,alt:null,as:null,async:ct,autoCapitalize:null,autoComplete:Tt,autoFocus:ct,autoPlay:ct,blocking:Tt,capture:null,charSet:null,checked:ct,cite:null,className:Tt,closedBy:null,colorSpace:null,cols:Te,colSpan:Te,command:null,commandFor:null,content:null,contentEditable:rn,controls:ct,controlsList:Tt,coords:Te|ha,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ct,defer:ct,dir:null,dirName:null,disabled:ct,download:Jy,draggable:rn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ct,formTarget:null,headers:Tt,height:Te,hidden:Jy,high:Te,href:null,hrefLang:null,htmlFor:Tt,httpEquiv:Tt,id:null,imageSizes:null,imageSrcSet:null,inert:ct,inputMode:null,integrity:null,is:null,isMap:ct,itemId:null,itemProp:Tt,itemRef:Tt,itemScope:ct,itemType:Tt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ct,low:Te,manifest:null,max:null,maxLength:Te,media:null,method:null,min:null,minLength:Te,multiple:ct,muted:ct,name:null,nonce:null,noModule:ct,noValidate:ct,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:ct,optimum:Te,pattern:null,ping:Tt,placeholder:null,playsInline:ct,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ct,referrerPolicy:null,rel:Tt,required:ct,reversed:ct,rows:Te,rowSpan:Te,sandbox:Tt,scope:null,scoped:ct,seamless:ct,selected:ct,shadowRootClonable:ct,shadowRootCustomElementRegistry:ct,shadowRootDelegatesFocus:ct,shadowRootMode:null,shadowRootSerializable:ct,shape:null,size:Te,sizes:null,slot:null,span:Te,spellCheck:rn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Te,step:null,style:null,tabIndex:Te,target:null,title:null,translate:null,type:null,typeMustMatch:ct,useMap:null,value:rn,width:Te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Tt,axis:null,background:null,bgColor:null,border:Te,borderColor:null,bottomMargin:Te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ct,declare:ct,event:null,face:null,frame:null,frameBorder:null,hSpace:Te,leftMargin:Te,link:null,longDesc:null,lowSrc:null,marginHeight:Te,marginWidth:Te,noResize:ct,noHref:ct,noShade:ct,noWrap:ct,object:null,profile:null,prompt:null,rev:null,rightMargin:Te,rules:null,scheme:null,scrolling:rn,standby:null,summary:null,text:null,topMargin:Te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Te,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ct,disablePictureInPicture:ct,disableRemotePlayback:ct,exportParts:ha,part:Tt,prefix:null,property:null,results:Te,security:null,unselectable:null},space:"html",transform:BT}),t5=Yl({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",maskType:"mask-type",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:Ir,accentHeight:Te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Te,amplitude:Te,arabicForm:null,ascent:Te,attributeName:null,attributeType:null,azimuth:Te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Te,by:null,calcMode:null,capHeight:Te,className:Tt,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:Te,diffuseConstant:Te,direction:null,display:null,dur:null,divisor:Te,dominantBaseline:null,download:ct,dx:null,dy:null,edgeMode:null,editable:null,elevation:Te,enableBackground:null,end:null,event:null,exponent:Te,externalResourcesRequired:null,fill:null,fillOpacity:Te,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:ha,g2:ha,glyphName:ha,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Te,horizOriginX:Te,horizOriginY:Te,id:null,ideographic:Te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Te,k:Te,k1:Te,k2:Te,k3:Te,k4:Te,kernelMatrix:Ir,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Te,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Te,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:Te,overlineThickness:Te,paintOrder:null,panose1:null,path:null,pathLength:Te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Tt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Te,pointsAtY:Te,pointsAtZ:Te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ir,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ir,rev:Ir,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ir,requiredFeatures:Ir,requiredFonts:Ir,requiredFormats:Ir,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:Te,specularExponent:Te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Te,strikethroughThickness:Te,string:null,stroke:null,strokeDashArray:Ir,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Te,strokeOpacity:Te,strokeWidth:null,style:null,surfaceScale:Te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ir,tabIndex:Te,tableValues:null,target:null,targetX:Te,targetY:Te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ir,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Te,underlineThickness:Te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Te,values:null,vAlphabetic:Te,vMathematical:Te,vectorEffect:null,vHanging:Te,vIdeographic:Te,version:null,vertAdvY:Te,vertOriginX:Te,vertOriginY:Te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:FT}),_T=Yl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),WT=Yl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:BT}),HT=Yl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),n5={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"},r5=/[A-Z]/g,cS=/-[a-z]/g,s5=/^data[-\w.:]+$/i;function o5(e,t){const n=Gy(t);let r=t,s=vr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&s5.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(cS,a5);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!cS.test(o)){let i=o.replace(r5,i5);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}s=rx}return new s(r,t)}function i5(e){return"-"+e.toLowerCase()}function a5(e){return e.charAt(1).toUpperCase()}const l5=PT([zT,e5,_T,WT,HT],"html"),sx=PT([zT,t5,_T,WT,HT],"svg");function c5(e){return e.join(" ").trim()}var ox={},uS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,u5=/\n/g,d5=/^\s*/,h5=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,f5=/^:\s*/,p5=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,m5=/^[;\s]*/,g5=/^\s+|\s+$/g,y5=`
|
|
105
|
+
`,dS="/",hS="*",Zi="",w5="comment",b5="declaration";function x5(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(m){var w=m.match(u5);w&&(n+=w.length);var b=m.lastIndexOf(y5);r=~b?m.length-b:r+m.length}function o(){var m={line:n,column:r};return function(w){return w.position=new i(m),u(),w}}function i(m){this.start=m,this.end={line:n,column:r},this.source=t.source}i.prototype.content=e;function a(m){var w=new Error(t.source+":"+n+":"+r+": "+m);if(w.reason=m,w.filename=t.source,w.line=n,w.column=r,w.source=e,!t.silent)throw w}function c(m){var w=m.exec(e);if(w){var b=w[0];return s(b),e=e.slice(b.length),w}}function u(){c(d5)}function d(m){var w;for(m=m||[];w=h();)w!==!1&&m.push(w);return m}function h(){var m=o();if(!(dS!=e.charAt(0)||hS!=e.charAt(1))){for(var w=2;Zi!=e.charAt(w)&&(hS!=e.charAt(w)||dS!=e.charAt(w+1));)++w;if(w+=2,Zi===e.charAt(w-1))return a("End of comment missing");var b=e.slice(2,w-2);return r+=2,s(b),e=e.slice(w),r+=2,m({type:w5,comment:b})}}function f(){var m=o(),w=c(h5);if(w){if(h(),!c(f5))return a("property missing ':'");var b=c(p5),x=m({type:b5,property:fS(w[0].replace(uS,Zi)),value:b?fS(b[0].replace(uS,Zi)):Zi});return c(m5),x}}function p(){var m=[];d(m);for(var w;w=f();)w!==!1&&(m.push(w),d(m));return m}return u(),p()}function fS(e){return e?e.replace(g5,Zi):Zi}var k5=x5,v5=Mh&&Mh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ox,"__esModule",{value:!0});ox.default=j5;const S5=v5(k5);function j5(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,S5.default)(e),s=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:i,value:a}=o;s?t(i,a,o):a&&(n=n||{},n[i]=a)}),n}var mp={};Object.defineProperty(mp,"__esModule",{value:!0});mp.camelCase=void 0;var C5=/^--[a-zA-Z0-9_-]+$/,N5=/-([a-z])/g,E5=/^[^-]+$/,A5=/^-(webkit|moz|ms|o|khtml)-/,T5=/^-(ms)-/,M5=function(e){return!e||E5.test(e)||C5.test(e)},R5=function(e,t){return t.toUpperCase()},pS=function(e,t){return"".concat(t,"-")},I5=function(e,t){return t===void 0&&(t={}),M5(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(T5,pS):e=e.replace(A5,pS),e.replace(N5,R5))};mp.camelCase=I5;var D5=Mh&&Mh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},O5=D5(ox),L5=mp;function Qy(e,t){var n={};return!e||typeof e!="string"||(0,O5.default)(e,function(r,s){r&&s&&(n[(0,L5.camelCase)(r,t)]=s)}),n}Qy.default=Qy;var $5=Qy;const P5=eA($5),UT=KT("end"),ix=KT("start");function KT(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function z5(e){const t=ix(e),n=UT(e);if(t&&n)return{start:t,end:n}}function Fc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?mS(e.position):"start"in e||"end"in e?mS(e):"line"in e||"column"in e?Zy(e):""}function Zy(e){return gS(e&&e.line)+":"+gS(e&&e.column)}function mS(e){return Zy(e&&e.start)+"-"+Zy(e&&e.end)}function gS(e){return e&&typeof e=="number"?e:1}class Kn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",o={},i=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?s=t:!o.cause&&t&&(i=!0,s=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?o.ruleId=r:(o.source=r.slice(0,c),o.ruleId=r.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=a?a.line:void 0,this.name=Fc(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=i&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Kn.prototype.file="";Kn.prototype.name="";Kn.prototype.reason="";Kn.prototype.message="";Kn.prototype.stack="";Kn.prototype.column=void 0;Kn.prototype.line=void 0;Kn.prototype.ancestors=void 0;Kn.prototype.cause=void 0;Kn.prototype.fatal=void 0;Kn.prototype.place=void 0;Kn.prototype.ruleId=void 0;Kn.prototype.source=void 0;const ax={}.hasOwnProperty,F5=new Map,B5=/[A-Z]/g,_5=new Set(["table","tbody","thead","tfoot","tr"]),W5=new Set(["td","th"]),VT="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function H5(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=X5(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=J5(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?sx:l5,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=qT(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function qT(e,t,n){if(t.type==="element")return U5(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return K5(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return q5(e,t,n);if(t.type==="mdxjsEsm")return V5(e,t);if(t.type==="root")return Y5(e,t,n);if(t.type==="text")return G5(e,t)}function U5(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=sx,e.schema=s),e.ancestors.push(t);const o=GT(e,t.tagName,!1),i=Q5(e,t);let a=cx(e,t);return _5.has(t.tagName)&&(a=a.filter(function(c){return typeof c=="string"?!Q_(c):!0})),YT(e,i,o,t),lx(i,a),e.ancestors.pop(),e.schema=r,e.create(t,o,i,n)}function K5(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}pu(e,t.position)}function V5(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);pu(e,t.position)}function q5(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=sx,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:GT(e,t.name,!0),i=Z5(e,t),a=cx(e,t);return YT(e,i,o,t),lx(i,a),e.ancestors.pop(),e.schema=r,e.create(t,o,i,n)}function Y5(e,t,n){const r={};return lx(r,cx(e,t)),e.create(t,e.Fragment,r,n)}function G5(e,t){return t.value}function YT(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function lx(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function J5(e,t,n){return r;function r(s,o,i,a){const u=Array.isArray(i.children)?n:t;return a?u(o,i,a):u(o,i)}}function X5(e,t){return n;function n(r,s,o,i){const a=Array.isArray(o.children),c=ix(r);return t(s,o,i,a,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Q5(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&ax.call(t.properties,s)){const o=e3(e,s,t.properties[s]);if(o){const[i,a]=o;e.tableCellAlignToStyle&&i==="align"&&typeof a=="string"&&W5.has(t.tagName)?r=a:n[i]=a}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Z5(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const i=o.expression;i.type;const a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else pu(e,t.position);else{const s=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,o=e.evaluater.evaluateExpression(a.expression)}else pu(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function cx(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:F5;for(;++r<t.children.length;){const o=t.children[r];let i;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const u=s.get(c)||0;i=c+"-"+u,s.set(c,u+1)}}const a=qT(e,o,i);a!==void 0&&n.push(a)}return n}function e3(e,t,n){const r=o5(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?q_(n):c5(n)),r.property==="style"){let s=typeof n=="object"?n:t3(e,String(n));return e.stylePropertyNameCase==="css"&&(s=n3(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?n5[r.property]||r.property:r.attribute,n]}}function t3(e,t){try{return P5(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Kn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=VT+"#cannot-parse-style-attribute",s}}function GT(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let o=-1,i;for(;++o<s.length;){const a=iS(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};i=i?{type:"MemberExpression",object:i,property:a,computed:!!(o&&a.type==="Literal"),optional:!1}:a}r=i}else r=iS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return ax.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);pu(e)}function pu(e,t){const n=new Kn("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=VT+"#cannot-handle-mdx-estrees-without-createevaluater",n}function n3(e){const t={};let n;for(n in e)ax.call(e,n)&&(t[r3(n)]=e[n]);return t}function r3(e){let t=e.replace(B5,s3);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function s3(e){return"-"+e.toLowerCase()}const Jm={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"]},o3={};function ux(e,t){const n=o3,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return JT(e,r,s)}function JT(e,t,n){if(i3(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return yS(e.children,t,n)}return Array.isArray(e)?yS(e,t,n):""}function yS(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=JT(e[s],t,n);return r.join("")}function i3(e){return!!(e&&typeof e=="object")}const wS=document.createElement("i");function dx(e){const t="&"+e+";";wS.innerHTML=t;const n=wS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function $r(e,t,n,r){const s=e.length;let o=0,i;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)i=Array.from(r),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<r.length;)i=r.slice(o,o+1e4),i.unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}function Jr(e,t){return e.length>0?($r(e,e.length,0,t),e):t}const bS={}.hasOwnProperty;function XT(e){const t={};let n=-1;for(;++n<e.length;)a3(t,e[n]);return t}function a3(e,t){let n;for(n in t){const s=(bS.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let i;if(o)for(i in o){bS.call(s,i)||(s[i]=[]);const a=o[i];l3(s[i],Array.isArray(a)?a:a?[a]:[])}}}function l3(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);$r(e,0,0,r)}function QT(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function ys(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const or=Si(/[A-Za-z]/),_n=Si(/[\dA-Za-z]/),c3=Si(/[#-'*+\--9=?A-Z^-~]/);function Gh(e){return e!==null&&(e<32||e===127)}const ew=Si(/\d/),u3=Si(/[\dA-Fa-f]/),d3=Si(/[!-/:-@[-`{-~]/);function nt(e){return e!==null&&e<-2}function It(e){return e!==null&&(e<0||e===32)}function yt(e){return e===-2||e===-1||e===32}const gp=Si(new RegExp("\\p{P}|\\p{S}","u")),va=Si(/\s/);function Si(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gl(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let i="";if(o===37&&_n(e.charCodeAt(n+1))&&_n(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(i=String.fromCharCode(o));else if(o>55295&&o<57344){const a=e.charCodeAt(n+1);o<56320&&a>56319&&a<57344?(i=String.fromCharCode(o,a),s=1):i="�"}else i=String.fromCharCode(o);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+s+1,i=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function kt(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return i;function i(c){return yt(c)?(e.enter(n),a(c)):t(c)}function a(c){return yt(c)&&o++<s?(e.consume(c),a):(e.exit(n),t(c))}}const h3={tokenize:f3};function f3(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),kt(e,t,"linePrefix")}function s(a){return e.enter("paragraph"),o(a)}function o(a){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,i(a)}function i(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return nt(a)?(e.consume(a),e.exit("chunkText"),o):(e.consume(a),i)}}const p3={tokenize:m3},xS={tokenize:g3};function m3(e){const t=this,n=[];let r=0,s,o,i;return a;function a(S){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,c,u)(S)}return u(S)}function c(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&v();const C=t.events.length;let O=C,N;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){N=t.events[O][1].end;break}x(r);let P=C;for(;P<t.events.length;)t.events[P][1].end={...N},P++;return $r(t.events,O+1,0,t.events.slice(C)),t.events.length=P,u(S)}return a(S)}function u(S){if(r===n.length){if(!s)return f(S);if(s.currentConstruct&&s.currentConstruct.concrete)return m(S);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(xS,d,h)(S)}function d(S){return s&&v(),x(r),f(S)}function h(S){return t.parser.lazy[t.now().line]=r!==n.length,i=t.now().offset,m(S)}function f(S){return t.containerState={},e.attempt(xS,p,m)(S)}function p(S){return r++,n.push([t.currentConstruct,t.containerState]),f(S)}function m(S){if(S===null){s&&v(),x(0),e.consume(S);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),w(S)}function w(S){if(S===null){b(e.exit("chunkFlow"),!0),x(0),e.consume(S);return}return nt(S)?(e.consume(S),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(S),w)}function b(S,C){const O=t.sliceStream(S);if(C&&O.push(null),S.previous=o,o&&(o.next=S),o=S,s.defineSkip(S.start),s.write(O),t.parser.lazy[S.start.line]){let N=s.events.length;for(;N--;)if(s.events[N][1].start.offset<i&&(!s.events[N][1].end||s.events[N][1].end.offset>i))return;const P=t.events.length;let M=P,R,L;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){if(R){L=t.events[M][1].end;break}R=!0}for(x(r),N=P;N<t.events.length;)t.events[N][1].end={...L},N++;$r(t.events,M+1,0,t.events.slice(P)),t.events.length=N}}function x(S){let C=n.length;for(;C-- >S;){const O=n[C];t.containerState=O[1],O[0].exit.call(t,e)}n.length=S}function v(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function g3(e,t,n){return kt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Il(e){if(e===null||It(e)||va(e))return 1;if(gp(e))return 2}function yp(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const tw={name:"attention",resolveAll:y3,tokenize:w3};function y3(e,t){let n=-1,r,s,o,i,a,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[r][1].end},f={...e[n][1].start};kS(h,-c),kS(f,c),i={type:c>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},a={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},o={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...i.start},end:{...a.end}},e[r][1].end={...i.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Jr(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Jr(u,[["enter",s,t],["enter",i,t],["exit",i,t],["enter",o,t]]),u=Jr(u,yp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Jr(u,[["exit",o,t],["enter",a,t],["exit",a,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Jr(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,$r(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function w3(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=Il(r);let o;return i;function i(c){return o=c,e.enter("attentionSequence"),a(c)}function a(c){if(c===o)return e.consume(c),a;const u=e.exit("attentionSequence"),d=Il(c),h=!d||d===2&&s||n.includes(c),f=!s||s===2&&d||n.includes(r);return u._open=!!(o===42?h:h&&(s||!f)),u._close=!!(o===42?f:f&&(d||!h)),t(c)}}function kS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const b3={name:"autolink",tokenize:x3};function x3(e,t,n){let r=0;return s;function s(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(p){return or(p)?(e.consume(p),i):p===64?n(p):u(p)}function i(p){return p===43||p===45||p===46||_n(p)?(r=1,a(p)):u(p)}function a(p){return p===58?(e.consume(p),r=0,c):(p===43||p===45||p===46||_n(p))&&r++<32?(e.consume(p),a):(r=0,u(p))}function c(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||Gh(p)?n(p):(e.consume(p),c)}function u(p){return p===64?(e.consume(p),d):c3(p)?(e.consume(p),u):n(p)}function d(p){return _n(p)?h(p):n(p)}function h(p){return p===46?(e.consume(p),r=0,d):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||_n(p))&&r++<63){const m=p===45?f:h;return e.consume(p),m}return n(p)}}const Fu={partial:!0,tokenize:k3};function k3(e,t,n){return r;function r(o){return yt(o)?kt(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||nt(o)?t(o):n(o)}}const ZT={continuation:{tokenize:S3},exit:j3,name:"blockQuote",tokenize:v3};function v3(e,t,n){const r=this;return s;function s(i){if(i===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),o}return n(i)}function o(i){return yt(i)?(e.enter("blockQuotePrefixWhitespace"),e.consume(i),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(i))}}function S3(e,t,n){const r=this;return s;function s(i){return yt(i)?kt(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):o(i)}function o(i){return e.attempt(ZT,t,n)(i)}}function j3(e){e.exit("blockQuote")}const eM={name:"characterEscape",tokenize:C3};function C3(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return d3(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const tM={name:"characterReference",tokenize:N3};function N3(e,t,n){const r=this;let s=0,o,i;return a;function a(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),c}function c(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,i=_n,d(h))}function u(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,i=u3,d):(e.enter("characterReferenceValue"),o=7,i=ew,d(h))}function d(h){if(h===59&&s){const f=e.exit("characterReferenceValue");return i===_n&&!dx(r.sliceSerialize(f))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return i(h)&&s++<o?(e.consume(h),d):n(h)}}const vS={partial:!0,tokenize:A3},SS={concrete:!0,name:"codeFenced",tokenize:E3};function E3(e,t,n){const r=this,s={partial:!0,tokenize:O};let o=0,i=0,a;return c;function c(N){return u(N)}function u(N){const P=r.events[r.events.length-1];return o=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,a=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(N)}function d(N){return N===a?(i++,e.consume(N),d):i<3?n(N):(e.exit("codeFencedFenceSequence"),yt(N)?kt(e,h,"whitespace")(N):h(N))}function h(N){return N===null||nt(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(vS,w,C)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(N))}function f(N){return N===null||nt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(N)):yt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),kt(e,p,"whitespace")(N)):N===96&&N===a?n(N):(e.consume(N),f)}function p(N){return N===null||nt(N)?h(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(N))}function m(N){return N===null||nt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(N)):N===96&&N===a?n(N):(e.consume(N),m)}function w(N){return e.attempt(s,C,b)(N)}function b(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),x}function x(N){return o>0&&yt(N)?kt(e,v,"linePrefix",o+1)(N):v(N)}function v(N){return N===null||nt(N)?e.check(vS,w,C)(N):(e.enter("codeFlowValue"),S(N))}function S(N){return N===null||nt(N)?(e.exit("codeFlowValue"),v(N)):(e.consume(N),S)}function C(N){return e.exit("codeFenced"),t(N)}function O(N,P,M){let R=0;return L;function L(re){return N.enter("lineEnding"),N.consume(re),N.exit("lineEnding"),H}function H(re){return N.enter("codeFencedFence"),yt(re)?kt(N,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(re):_(re)}function _(re){return re===a?(N.enter("codeFencedFenceSequence"),Y(re)):M(re)}function Y(re){return re===a?(R++,N.consume(re),Y):R>=i?(N.exit("codeFencedFenceSequence"),yt(re)?kt(N,se,"whitespace")(re):se(re)):M(re)}function se(re){return re===null||nt(re)?(N.exit("codeFencedFence"),P(re)):M(re)}}}function A3(e,t,n){const r=this;return s;function s(i){return i===null?n(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o)}function o(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}const Xm={name:"codeIndented",tokenize:M3},T3={partial:!0,tokenize:R3};function M3(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),kt(e,o,"linePrefix",5)(u)}function o(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?i(u):n(u)}function i(u){return u===null?c(u):nt(u)?e.attempt(T3,i,c)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||nt(u)?(e.exit("codeFlowValue"),i(u)):(e.consume(u),a)}function c(u){return e.exit("codeIndented"),t(u)}}function R3(e,t,n){const r=this;return s;function s(i){return r.parser.lazy[r.now().line]?n(i):nt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s):kt(e,o,"linePrefix",5)(i)}function o(i){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):nt(i)?s(i):n(i)}}const I3={name:"codeText",previous:O3,resolve:D3,tokenize:L3};function D3(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function O3(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function L3(e,t,n){let r=0,s,o;return i;function i(h){return e.enter("codeText"),e.enter("codeTextSequence"),a(h)}function a(h){return h===96?(e.consume(h),r++,a):(e.exit("codeTextSequence"),c(h))}function c(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),c):h===96?(o=e.enter("codeTextSequence"),s=0,d(h)):nt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(h))}function u(h){return h===null||h===32||h===96||nt(h)?(e.exit("codeTextData"),c(h)):(e.consume(h),u)}function d(h){return h===96?(e.consume(h),s++,d):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(o.type="codeTextData",u(h))}}class $3{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&wc(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),wc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),wc(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);wc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);wc(this.left,n.reverse())}}}function wc(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 nM(e){const t={};let n=-1,r,s,o,i,a,c,u;const d=new $3(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,P3(d,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(i=d.get(o),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank")i[0]==="enter"&&(s&&(d.get(s)[1].type="lineEndingBlank"),i[1].type="lineEnding",s=o);else if(!(i[1].type==="linePrefix"||i[1].type==="listItemIndent"))break;s&&(r[1].end={...d.get(s)[1].start},a=d.slice(s,n),a.unshift(r),d.splice(s,n-s+1,a))}}return $r(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function P3(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const o=[];let i=n._tokenizer;i||(i=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const a=i.events,c=[],u={};let d,h,f=-1,p=n,m=0,w=0;const b=[w];for(;p;){for(;e.get(++s)[1]!==p;);o.push(s),p._tokenizer||(d=r.sliceStream(p),p.next||d.push(null),h&&i.defineSkip(p.start),p._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),p._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),h=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(w=f+1,b.push(w),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(i.events=[],p?(p._tokenizer=void 0,p.previous=void 0):b.pop(),f=b.length;f--;){const x=a.slice(b[f],b[f+1]),v=o.pop();c.push([v,v+x.length-1]),e.splice(v,2,x)}for(c.reverse(),f=-1;++f<c.length;)u[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return u}const z3={resolve:B3,tokenize:_3},F3={partial:!0,tokenize:W3};function B3(e){return nM(e),e}function _3(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?o(a):nt(a)?e.check(F3,i,o)(a):(e.consume(a),s)}function o(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function i(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function W3(e,t,n){const r=this;return s;function s(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),kt(e,o,"linePrefix")}function o(i){if(i===null||nt(i))return n(i);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function rM(e,t,n,r,s,o,i,a,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return h;function h(x){return x===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(x),e.exit(o),f):x===null||x===32||x===41||Gh(x)?n(x):(e.enter(r),e.enter(i),e.enter(a),e.enter("chunkString",{contentType:"string"}),w(x))}function f(x){return x===62?(e.enter(o),e.consume(x),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(a),f(x)):x===null||x===60||nt(x)?n(x):(e.consume(x),x===92?m:p)}function m(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function w(x){return!d&&(x===null||x===41||It(x))?(e.exit("chunkString"),e.exit(a),e.exit(i),e.exit(r),t(x)):d<u&&x===40?(e.consume(x),d++,w):x===41?(e.consume(x),d--,w):x===null||x===32||x===40||Gh(x)?n(x):(e.consume(x),x===92?b:w)}function b(x){return x===40||x===41||x===92?(e.consume(x),w):w(x)}}function sM(e,t,n,r,s,o){const i=this;let a=0,c;return u;function u(p){return e.enter(r),e.enter(s),e.consume(p),e.exit(s),e.enter(o),d}function d(p){return a>999||p===null||p===91||p===93&&!c||p===94&&!a&&"_hiddenFootnoteSupport"in i.parser.constructs?n(p):p===93?(e.exit(o),e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):nt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||nt(p)||a++>999?(e.exit("chunkString"),d(p)):(e.consume(p),c||(c=!yt(p)),p===92?f:h)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,h):h(p)}}function oM(e,t,n,r,s,o){let i;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(s),e.consume(f),e.exit(s),i=f===40?41:f,c):n(f)}function c(f){return f===i?(e.enter(s),e.consume(f),e.exit(s),e.exit(r),t):(e.enter(o),u(f))}function u(f){return f===i?(e.exit(o),c(i)):f===null?n(f):nt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),kt(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===i||f===null||nt(f)?(e.exit("chunkString"),u(f)):(e.consume(f),f===92?h:d)}function h(f){return f===i||f===92?(e.consume(f),d):d(f)}}function Bc(e,t){let n;return r;function r(s){return nt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):yt(s)?kt(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const H3={name:"definition",tokenize:K3},U3={partial:!0,tokenize:V3};function K3(e,t,n){const r=this;let s;return o;function o(p){return e.enter("definition"),i(p)}function i(p){return sM.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return s=ys(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return It(p)?Bc(e,u)(p):u(p)}function u(p){return rM(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(U3,h,h)(p)}function h(p){return yt(p)?kt(e,f,"whitespace")(p):f(p)}function f(p){return p===null||nt(p)?(e.exit("definition"),r.parser.defined.push(s),t(p)):n(p)}}function V3(e,t,n){return r;function r(a){return It(a)?Bc(e,s)(a):n(a)}function s(a){return oM(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return yt(a)?kt(e,i,"whitespace")(a):i(a)}function i(a){return a===null||nt(a)?t(a):n(a)}}const q3={name:"hardBreakEscape",tokenize:Y3};function Y3(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return nt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const G3={name:"headingAtx",resolve:J3,tokenize:X3};function J3(e,t){let n=e.length-2,r=3,s,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},$r(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function X3(e,t,n){let r=0;return s;function s(d){return e.enter("atxHeading"),o(d)}function o(d){return e.enter("atxHeadingSequence"),i(d)}function i(d){return d===35&&r++<6?(e.consume(d),i):d===null||It(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||nt(d)?(e.exit("atxHeading"),t(d)):yt(d)?kt(e,a,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),a(d))}function u(d){return d===null||d===35||It(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),u)}}const Q3=["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"],jS=["pre","script","style","textarea"],Z3={concrete:!0,name:"htmlFlow",resolveTo:nW,tokenize:rW},eW={partial:!0,tokenize:oW},tW={partial:!0,tokenize:sW};function nW(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(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}function rW(e,t,n){const r=this;let s,o,i,a,c;return u;function u(E){return d(E)}function d(E){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(E),h}function h(E){return E===33?(e.consume(E),f):E===47?(e.consume(E),o=!0,w):E===63?(e.consume(E),s=3,r.interrupt?t:j):or(E)?(e.consume(E),i=String.fromCharCode(E),b):n(E)}function f(E){return E===45?(e.consume(E),s=2,p):E===91?(e.consume(E),s=5,a=0,m):or(E)?(e.consume(E),s=4,r.interrupt?t:j):n(E)}function p(E){return E===45?(e.consume(E),r.interrupt?t:j):n(E)}function m(E){const K="CDATA[";return E===K.charCodeAt(a++)?(e.consume(E),a===K.length?r.interrupt?t:_:m):n(E)}function w(E){return or(E)?(e.consume(E),i=String.fromCharCode(E),b):n(E)}function b(E){if(E===null||E===47||E===62||It(E)){const K=E===47,z=i.toLowerCase();return!K&&!o&&jS.includes(z)?(s=1,r.interrupt?t(E):_(E)):Q3.includes(i.toLowerCase())?(s=6,K?(e.consume(E),x):r.interrupt?t(E):_(E)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(E):o?v(E):S(E))}return E===45||_n(E)?(e.consume(E),i+=String.fromCharCode(E),b):n(E)}function x(E){return E===62?(e.consume(E),r.interrupt?t:_):n(E)}function v(E){return yt(E)?(e.consume(E),v):L(E)}function S(E){return E===47?(e.consume(E),L):E===58||E===95||or(E)?(e.consume(E),C):yt(E)?(e.consume(E),S):L(E)}function C(E){return E===45||E===46||E===58||E===95||_n(E)?(e.consume(E),C):O(E)}function O(E){return E===61?(e.consume(E),N):yt(E)?(e.consume(E),O):S(E)}function N(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),c=E,P):yt(E)?(e.consume(E),N):M(E)}function P(E){return E===c?(e.consume(E),c=null,R):E===null||nt(E)?n(E):(e.consume(E),P)}function M(E){return E===null||E===34||E===39||E===47||E===60||E===61||E===62||E===96||It(E)?O(E):(e.consume(E),M)}function R(E){return E===47||E===62||yt(E)?S(E):n(E)}function L(E){return E===62?(e.consume(E),H):n(E)}function H(E){return E===null||nt(E)?_(E):yt(E)?(e.consume(E),H):n(E)}function _(E){return E===45&&s===2?(e.consume(E),T):E===60&&s===1?(e.consume(E),W):E===62&&s===4?(e.consume(E),ae):E===63&&s===3?(e.consume(E),j):E===93&&s===5?(e.consume(E),ge):nt(E)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(eW,me,Y)(E)):E===null||nt(E)?(e.exit("htmlFlowData"),Y(E)):(e.consume(E),_)}function Y(E){return e.check(tW,se,me)(E)}function se(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),re}function re(E){return E===null||nt(E)?Y(E):(e.enter("htmlFlowData"),_(E))}function T(E){return E===45?(e.consume(E),j):_(E)}function W(E){return E===47?(e.consume(E),i="",le):_(E)}function le(E){if(E===62){const K=i.toLowerCase();return jS.includes(K)?(e.consume(E),ae):_(E)}return or(E)&&i.length<8?(e.consume(E),i+=String.fromCharCode(E),le):_(E)}function ge(E){return E===93?(e.consume(E),j):_(E)}function j(E){return E===62?(e.consume(E),ae):E===45&&s===2?(e.consume(E),j):_(E)}function ae(E){return E===null||nt(E)?(e.exit("htmlFlowData"),me(E)):(e.consume(E),ae)}function me(E){return e.exit("htmlFlow"),t(E)}}function sW(e,t,n){const r=this;return s;function s(i){return nt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o):n(i)}function o(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}function oW(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Fu,t,n)}}const iW={name:"htmlText",tokenize:aW};function aW(e,t,n){const r=this;let s,o,i;return a;function a(j){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(j),c}function c(j){return j===33?(e.consume(j),u):j===47?(e.consume(j),O):j===63?(e.consume(j),S):or(j)?(e.consume(j),M):n(j)}function u(j){return j===45?(e.consume(j),d):j===91?(e.consume(j),o=0,m):or(j)?(e.consume(j),v):n(j)}function d(j){return j===45?(e.consume(j),p):n(j)}function h(j){return j===null?n(j):j===45?(e.consume(j),f):nt(j)?(i=h,W(j)):(e.consume(j),h)}function f(j){return j===45?(e.consume(j),p):h(j)}function p(j){return j===62?T(j):j===45?f(j):h(j)}function m(j){const ae="CDATA[";return j===ae.charCodeAt(o++)?(e.consume(j),o===ae.length?w:m):n(j)}function w(j){return j===null?n(j):j===93?(e.consume(j),b):nt(j)?(i=w,W(j)):(e.consume(j),w)}function b(j){return j===93?(e.consume(j),x):w(j)}function x(j){return j===62?T(j):j===93?(e.consume(j),x):w(j)}function v(j){return j===null||j===62?T(j):nt(j)?(i=v,W(j)):(e.consume(j),v)}function S(j){return j===null?n(j):j===63?(e.consume(j),C):nt(j)?(i=S,W(j)):(e.consume(j),S)}function C(j){return j===62?T(j):S(j)}function O(j){return or(j)?(e.consume(j),N):n(j)}function N(j){return j===45||_n(j)?(e.consume(j),N):P(j)}function P(j){return nt(j)?(i=P,W(j)):yt(j)?(e.consume(j),P):T(j)}function M(j){return j===45||_n(j)?(e.consume(j),M):j===47||j===62||It(j)?R(j):n(j)}function R(j){return j===47?(e.consume(j),T):j===58||j===95||or(j)?(e.consume(j),L):nt(j)?(i=R,W(j)):yt(j)?(e.consume(j),R):T(j)}function L(j){return j===45||j===46||j===58||j===95||_n(j)?(e.consume(j),L):H(j)}function H(j){return j===61?(e.consume(j),_):nt(j)?(i=H,W(j)):yt(j)?(e.consume(j),H):R(j)}function _(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),s=j,Y):nt(j)?(i=_,W(j)):yt(j)?(e.consume(j),_):(e.consume(j),se)}function Y(j){return j===s?(e.consume(j),s=void 0,re):j===null?n(j):nt(j)?(i=Y,W(j)):(e.consume(j),Y)}function se(j){return j===null||j===34||j===39||j===60||j===61||j===96?n(j):j===47||j===62||It(j)?R(j):(e.consume(j),se)}function re(j){return j===47||j===62||It(j)?R(j):n(j)}function T(j){return j===62?(e.consume(j),e.exit("htmlTextData"),e.exit("htmlText"),t):n(j)}function W(j){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),le}function le(j){return yt(j)?kt(e,ge,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):ge(j)}function ge(j){return e.enter("htmlTextData"),i(j)}}const hx={name:"labelEnd",resolveAll:dW,resolveTo:hW,tokenize:fW},lW={tokenize:pW},cW={tokenize:mW},uW={tokenize:gW};function dW(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&$r(e,0,e.length,n),e}function hW(e,t){let n=e.length,r=0,s,o,i,a;for(;n--;)if(s=e[n][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(i){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(i=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[o][1].start},end:{...e[i][1].end}},d={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[i-2][1].start}};return a=[["enter",c,t],["enter",u,t]],a=Jr(a,e.slice(o+1,o+r+3)),a=Jr(a,[["enter",d,t]]),a=Jr(a,yp(t.parser.constructs.insideSpan.null,e.slice(o+r+4,i-3),t)),a=Jr(a,[["exit",d,t],e[i-2],e[i-1],["exit",u,t]]),a=Jr(a,e.slice(i+1)),a=Jr(a,[["exit",c,t]]),$r(e,o,e.length,a),e}function fW(e,t,n){const r=this;let s=r.events.length,o,i;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return a;function a(f){return o?o._inactive?h(f):(i=r.parser.defined.includes(ys(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),c):n(f)}function c(f){return f===40?e.attempt(lW,d,i?d:h)(f):f===91?e.attempt(cW,d,i?u:h)(f):i?d(f):h(f)}function u(f){return e.attempt(uW,d,h)(f)}function d(f){return t(f)}function h(f){return o._balanced=!0,n(f)}}function pW(e,t,n){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),s}function s(h){return It(h)?Bc(e,o)(h):o(h)}function o(h){return h===41?d(h):rM(e,i,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function i(h){return It(h)?Bc(e,c)(h):d(h)}function a(h){return n(h)}function c(h){return h===34||h===39||h===40?oM(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):d(h)}function u(h){return It(h)?Bc(e,d)(h):d(h)}function d(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function mW(e,t,n){const r=this;return s;function s(a){return sM.call(r,e,o,i,"reference","referenceMarker","referenceString")(a)}function o(a){return r.parser.defined.includes(ys(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function i(a){return n(a)}}function gW(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const yW={name:"labelStartImage",resolveAll:hx.resolveAll,tokenize:wW};function wW(e,t,n){const r=this;return s;function s(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),o}function o(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),i):n(a)}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const bW={name:"labelStartLink",resolveAll:hx.resolveAll,tokenize:xW};function xW(e,t,n){const r=this;return s;function s(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),o}function o(i){return i===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(i):t(i)}}const Qm={name:"lineEnding",tokenize:kW};function kW(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),kt(e,t,"linePrefix")}}const uh={name:"thematicBreak",tokenize:vW};function vW(e,t,n){let r=0,s;return o;function o(u){return e.enter("thematicBreak"),i(u)}function i(u){return s=u,a(u)}function a(u){return u===s?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||nt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),yt(u)?kt(e,a,"whitespace")(u):a(u))}}const gr={continuation:{tokenize:NW},exit:AW,name:"list",tokenize:CW},SW={partial:!0,tokenize:TW},jW={partial:!0,tokenize:EW};function CW(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,i=0;return a;function a(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:ew(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(uh,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return ew(p)&&++i<10?(e.consume(p),c):(!r.interrupt||i<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Fu,r.interrupt?n:d,e.attempt(SW,f,h))}function d(p){return r.containerState.initialBlankLine=!0,o++,f(p)}function h(p){return yt(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function NW(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Fu,s,o);function s(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,kt(e,t,"listItemIndent",r.containerState.size+1)(a)}function o(a){return r.containerState.furtherBlankLines||!yt(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(jW,t,i)(a))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,kt(e,e.attempt(gr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function EW(e,t,n){const r=this;return kt(e,s,"listItemIndent",r.containerState.size+1);function s(o){const i=r.events[r.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(o):n(o)}}function AW(e){e.exit(this.containerState.type)}function TW(e,t,n){const r=this;return kt(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const i=r.events[r.events.length-1];return!yt(o)&&i&&i[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const CS={name:"setextUnderline",resolveTo:MW,tokenize:RW};function MW(e,t){let n=e.length,r,s,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const i={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",i,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=i,e.push(["exit",i,t]),e}function RW(e,t,n){const r=this;let s;return o;function o(u){let d=r.events.length,h;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){h=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),s=u,i(u)):n(u)}function i(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===s?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),yt(u)?kt(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||nt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const IW={tokenize:DW};function DW(e){const t=this,n=e.attempt(Fu,r,e.attempt(this.parser.constructs.flowInitial,s,kt(e,e.attempt(this.parser.constructs.flow,s,e.attempt(z3,s)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const OW={resolveAll:aM()},LW=iM("string"),$W=iM("text");function iM(e){return{resolveAll:aM(e==="text"?PW:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,i,a);return i;function i(d){return u(d)?o(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),o(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const h=s[d];let f=-1;if(h)for(;++f<h.length;){const p=h[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function aM(e){return t;function t(n,r){let s=-1,o;for(;++s<=n.length;)o===void 0?n[s]&&n[s][1].type==="data"&&(o=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==o+2&&(n[o][1].end=n[s-1][1].end,n.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(n,r):n}}function PW(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let o=s.length,i=-1,a=0,c;for(;o--;){const u=s[o];if(typeof u=="string"){for(i=u.length;u.charCodeAt(i-1)===32;)a++,i--;if(i)break;i=-1}else if(u===-2)c=!0,a++;else if(u!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||c||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?i:r.start._bufferIndex+i,_index:r.start._index+o,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const zW={42:gr,43:gr,45:gr,48:gr,49:gr,50:gr,51:gr,52:gr,53:gr,54:gr,55:gr,56:gr,57:gr,62:ZT},FW={91:H3},BW={[-2]:Xm,[-1]:Xm,32:Xm},_W={35:G3,42:uh,45:[CS,uh],60:Z3,61:CS,95:uh,96:SS,126:SS},WW={38:tM,92:eM},HW={[-5]:Qm,[-4]:Qm,[-3]:Qm,33:yW,38:tM,42:tw,60:[b3,iW],91:bW,92:[q3,eM],93:hx,95:tw,96:I3},UW={null:[tw,OW]},KW={null:[42,95]},VW={null:[]},qW=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:KW,contentInitial:FW,disable:VW,document:zW,flow:_W,flowInitial:BW,insideSpan:UW,string:WW,text:HW},Symbol.toStringTag,{value:"Module"}));function YW(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},o=[];let i=[],a=[];const c={attempt:P(O),check:P(N),consume:v,enter:S,exit:C,interrupt:P(N,{interrupt:!0})},u={code:null,containerState:{},defineSkip:w,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:h};let d=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function h(H){return i=Jr(i,H),b(),i[i.length-1]!==null?[]:(M(t,0),u.events=yp(o,u.events,u),u.events)}function f(H,_){return JW(p(H),_)}function p(H){return GW(i,H)}function m(){const{_bufferIndex:H,_index:_,line:Y,column:se,offset:re}=r;return{_bufferIndex:H,_index:_,line:Y,column:se,offset:re}}function w(H){s[H.line]=H.column,L()}function b(){let H;for(;r._index<i.length;){const _=i[r._index];if(typeof _=="string")for(H=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===H&&r._bufferIndex<_.length;)x(_.charCodeAt(r._bufferIndex));else x(_)}}function x(H){d=d(H)}function v(H){nt(H)?(r.line++,r.column=1,r.offset+=H===-3?2:1,L()):H!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=H}function S(H,_){const Y=_||{};return Y.type=H,Y.start=m(),u.events.push(["enter",Y,u]),a.push(Y),Y}function C(H){const _=a.pop();return _.end=m(),u.events.push(["exit",_,u]),_}function O(H,_){M(H,_.from)}function N(H,_){_.restore()}function P(H,_){return Y;function Y(se,re,T){let W,le,ge,j;return Array.isArray(se)?me(se):"tokenize"in se?me([se]):ae(se);function ae(xe){return Oe;function Oe(F){const J=F!==null&&xe[F],ze=F!==null&&xe.null,ye=[...Array.isArray(J)?J:J?[J]:[],...Array.isArray(ze)?ze:ze?[ze]:[]];return me(ye)(F)}}function me(xe){return W=xe,le=0,xe.length===0?T:E(xe[le])}function E(xe){return Oe;function Oe(F){return j=R(),ge=xe,xe.partial||(u.currentConstruct=xe),xe.name&&u.parser.constructs.disable.null.includes(xe.name)?z():xe.tokenize.call(_?Object.assign(Object.create(u),_):u,c,K,z)(F)}}function K(xe){return H(ge,j),re}function z(xe){return j.restore(),++le<W.length?E(W[le]):T}}}function M(H,_){H.resolveAll&&!o.includes(H)&&o.push(H),H.resolve&&$r(u.events,_,u.events.length-_,H.resolve(u.events.slice(_),u)),H.resolveTo&&(u.events=H.resolveTo(u.events,u))}function R(){const H=m(),_=u.previous,Y=u.currentConstruct,se=u.events.length,re=Array.from(a);return{from:se,restore:T};function T(){r=H,u.previous=_,u.currentConstruct=Y,u.events.length=se,a=re,L()}}function L(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function GW(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,o=t.end._bufferIndex;let i;if(n===s)i=[e[n].slice(r,o)];else{if(i=e.slice(n,s),r>-1){const a=i[0];typeof a=="string"?i[0]=a.slice(r):i.shift()}o>0&&i.push(e[s].slice(0,o))}return i}function JW(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const o=e[n];let i;if(typeof o=="string")i=o;else switch(o){case-5:{i="\r";break}case-4:{i=`
|
|
106
|
+
`;break}case-3:{i=`\r
|
|
107
|
+
`;break}case-2:{i=t?" ":" ";break}case-1:{if(!t&&s)continue;i=" ";break}default:i=String.fromCharCode(o)}s=o===-2,r.push(i)}return r.join("")}function XW(e){const r={constructs:XT([qW,...(e||{}).extensions||[]]),content:s(h3),defined:[],document:s(p3),flow:s(IW),lazy:{},string:s(LW),text:s($W)};return r;function s(o){return i;function i(a){return YW(r,o,a)}}}function QW(e){for(;!nM(e););return e}const NS=/[\0\t\n\r]/g;function ZW(){let e=1,t="",n=!0,r;return s;function s(o,i,a){const c=[];let u,d,h,f,p;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(i||void 0).decode(o)),h=0,t="",n&&(o.charCodeAt(0)===65279&&h++,n=void 0);h<o.length;){if(NS.lastIndex=h,u=NS.exec(o),f=u&&u.index!==void 0?u.index:o.length,p=o.charCodeAt(f),!u){t=o.slice(h);break}if(p===10&&h===f&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),h<f&&(c.push(o.slice(h,f)),e+=f-h),p){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}h=f+1}return a&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const e6=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function t6(e){return e.replace(e6,n6)}function n6(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return QT(n.slice(o?2:1),o?16:10)}return dx(n)||e}const lM={}.hasOwnProperty;function r6(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),s6(n)(QW(XW(n).document().write(ZW()(e,t,!0))))}function s6(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(he),autolinkProtocol:R,autolinkEmail:R,atxHeading:o(oe),blockQuote:o(ze),characterEscape:R,characterReference:R,codeFenced:o(ye),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:o(ye,i),codeText:o(Z,i),codeTextData:R,data:R,codeFlowValue:R,definition:o(Ce),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:o(Ee),hardBreakEscape:o(ne),hardBreakTrailing:o(ne),htmlFlow:o(Ie,i),htmlFlowData:R,htmlText:o(Ie,i),htmlTextData:R,image:o(Q),label:i,link:o(he),listItem:o(ee),listItemValue:f,listOrdered:o(te,h),listUnordered:o(te),paragraph:o(U),reference:E,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:o(oe),strong:o(I),thematicBreak:o(ue)},exit:{atxHeading:c(),atxHeadingSequence:O,autolink:c(),autolinkEmail:J,autolinkProtocol:F,blockQuote:c(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:z,characterReferenceMarkerNumeric:z,characterReferenceValue:xe,characterReference:Oe,codeFenced:c(b),codeFencedFence:w,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:L,codeIndented:c(x),codeText:c(re),codeTextData:L,data:L,definition:c(),definitionDestinationString:C,definitionLabelString:v,definitionTitleString:S,emphasis:c(),hardBreakEscape:c(_),hardBreakTrailing:c(_),htmlFlow:c(Y),htmlFlowData:L,htmlText:c(se),htmlTextData:L,image:c(W),label:ge,labelText:le,lineEnding:H,link:c(T),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:K,resourceDestinationString:j,resourceTitleString:ae,resource:me,setextHeading:c(M),setextHeadingLineSequence:P,setextHeadingText:N,strong:c(),thematicBreak:c()}};cM(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(G){let ie={type:"root",children:[]};const we={stack:[ie],tokenStack:[],config:t,enter:a,exit:u,buffer:i,resume:d,data:n},ve=[];let de=-1;for(;++de<G.length;)if(G[de][1].type==="listOrdered"||G[de][1].type==="listUnordered")if(G[de][0]==="enter")ve.push(de);else{const be=ve.pop();de=s(G,be,de)}for(de=-1;++de<G.length;){const be=t[G[de][0]];lM.call(be,G[de][1].type)&&be[G[de][1].type].call(Object.assign({sliceSerialize:G[de][2].sliceSerialize},we),G[de][1])}if(we.tokenStack.length>0){const be=we.tokenStack[we.tokenStack.length-1];(be[1]||ES).call(we,void 0,be[0])}for(ie.position={start:Yo(G.length>0?G[0][1].start:{line:1,column:1,offset:0}),end:Yo(G.length>0?G[G.length-2][1].end:{line:1,column:1,offset:0})},de=-1;++de<t.transforms.length;)ie=t.transforms[de](ie)||ie;return ie}function s(G,ie,we){let ve=ie-1,de=-1,be=!1,Le,Ye,at,Ge;for(;++ve<=we;){const Ke=G[ve];switch(Ke[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ke[0]==="enter"?de++:de--,Ge=void 0;break}case"lineEndingBlank":{Ke[0]==="enter"&&(Le&&!Ge&&!de&&!at&&(at=ve),Ge=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ge=void 0}if(!de&&Ke[0]==="enter"&&Ke[1].type==="listItemPrefix"||de===-1&&Ke[0]==="exit"&&(Ke[1].type==="listUnordered"||Ke[1].type==="listOrdered")){if(Le){let rt=ve;for(Ye=void 0;rt--;){const gt=G[rt];if(gt[1].type==="lineEnding"||gt[1].type==="lineEndingBlank"){if(gt[0]==="exit")continue;Ye&&(G[Ye][1].type="lineEndingBlank",be=!0),gt[1].type="lineEnding",Ye=rt}else if(!(gt[1].type==="linePrefix"||gt[1].type==="blockQuotePrefix"||gt[1].type==="blockQuotePrefixWhitespace"||gt[1].type==="blockQuoteMarker"||gt[1].type==="listItemIndent"))break}at&&(!Ye||at<Ye)&&(Le._spread=!0),Le.end=Object.assign({},Ye?G[Ye][1].start:Ke[1].end),G.splice(Ye||ve,0,["exit",Le,Ke[2]]),ve++,we++}if(Ke[1].type==="listItemPrefix"){const rt={type:"listItem",_spread:!1,start:Object.assign({},Ke[1].start),end:void 0};Le=rt,G.splice(ve,0,["enter",rt,Ke[2]]),ve++,we++,at=void 0,Ge=!0}}}return G[ie][1]._spread=be,we}function o(G,ie){return we;function we(ve){a.call(this,G(ve),ve),ie&&ie.call(this,ve)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(G,ie,we){this.stack[this.stack.length-1].children.push(G),this.stack.push(G),this.tokenStack.push([ie,we||void 0]),G.position={start:Yo(ie.start),end:void 0}}function c(G){return ie;function ie(we){G&&G.call(this,we),u.call(this,we)}}function u(G,ie){const we=this.stack.pop(),ve=this.tokenStack.pop();if(ve)ve[0].type!==G.type&&(ie?ie.call(this,G,ve[0]):(ve[1]||ES).call(this,G,ve[0]));else throw new Error("Cannot close `"+G.type+"` ("+Fc({start:G.start,end:G.end})+"): it’s not open");we.position.end=Yo(G.end)}function d(){return ux(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function f(G){if(this.data.expectingFirstListItemValue){const ie=this.stack[this.stack.length-2];ie.start=Number.parseInt(this.sliceSerialize(G),10),this.data.expectingFirstListItemValue=void 0}}function p(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.lang=G}function m(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.meta=G}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.value=G.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.value=G.replace(/(\r?\n|\r)$/g,"")}function v(G){const ie=this.resume(),we=this.stack[this.stack.length-1];we.label=ie,we.identifier=ys(this.sliceSerialize(G)).toLowerCase()}function S(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.title=G}function C(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.url=G}function O(G){const ie=this.stack[this.stack.length-1];if(!ie.depth){const we=this.sliceSerialize(G).length;ie.depth=we}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function P(G){const ie=this.stack[this.stack.length-1];ie.depth=this.sliceSerialize(G).codePointAt(0)===61?1:2}function M(){this.data.setextHeadingSlurpLineEnding=void 0}function R(G){const we=this.stack[this.stack.length-1].children;let ve=we[we.length-1];(!ve||ve.type!=="text")&&(ve=V(),ve.position={start:Yo(G.start),end:void 0},we.push(ve)),this.stack.push(ve)}function L(G){const ie=this.stack.pop();ie.value+=this.sliceSerialize(G),ie.position.end=Yo(G.end)}function H(G){const ie=this.stack[this.stack.length-1];if(this.data.atHardBreak){const we=ie.children[ie.children.length-1];we.position.end=Yo(G.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ie.type)&&(R.call(this,G),L.call(this,G))}function _(){this.data.atHardBreak=!0}function Y(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.value=G}function se(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.value=G}function re(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.value=G}function T(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const ie=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=ie,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function W(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const ie=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=ie,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function le(G){const ie=this.sliceSerialize(G),we=this.stack[this.stack.length-2];we.label=t6(ie),we.identifier=ys(ie).toLowerCase()}function ge(){const G=this.stack[this.stack.length-1],ie=this.resume(),we=this.stack[this.stack.length-1];if(this.data.inReference=!0,we.type==="link"){const ve=G.children;we.children=ve}else we.alt=ie}function j(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.url=G}function ae(){const G=this.resume(),ie=this.stack[this.stack.length-1];ie.title=G}function me(){this.data.inReference=void 0}function E(){this.data.referenceType="collapsed"}function K(G){const ie=this.resume(),we=this.stack[this.stack.length-1];we.label=ie,we.identifier=ys(this.sliceSerialize(G)).toLowerCase(),this.data.referenceType="full"}function z(G){this.data.characterReferenceType=G.type}function xe(G){const ie=this.sliceSerialize(G),we=this.data.characterReferenceType;let ve;we?(ve=QT(ie,we==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ve=dx(ie);const de=this.stack[this.stack.length-1];de.value+=ve}function Oe(G){const ie=this.stack.pop();ie.position.end=Yo(G.end)}function F(G){L.call(this,G);const ie=this.stack[this.stack.length-1];ie.url=this.sliceSerialize(G)}function J(G){L.call(this,G);const ie=this.stack[this.stack.length-1];ie.url="mailto:"+this.sliceSerialize(G)}function ze(){return{type:"blockquote",children:[]}}function ye(){return{type:"code",lang:null,meta:null,value:""}}function Z(){return{type:"inlineCode",value:""}}function Ce(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ee(){return{type:"emphasis",children:[]}}function oe(){return{type:"heading",depth:0,children:[]}}function ne(){return{type:"break"}}function Ie(){return{type:"html",value:""}}function Q(){return{type:"image",title:null,url:"",alt:null}}function he(){return{type:"link",title:null,url:"",children:[]}}function te(G){return{type:"list",ordered:G.type==="listOrdered",start:null,spread:G._spread,children:[]}}function ee(G){return{type:"listItem",spread:G._spread,checked:null,children:[]}}function U(){return{type:"paragraph",children:[]}}function I(){return{type:"strong",children:[]}}function V(){return{type:"text",value:""}}function ue(){return{type:"thematicBreak"}}}function Yo(e){return{line:e.line,column:e.column,offset:e.offset}}function cM(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?cM(e,r):o6(e,r)}}function o6(e,t){let n;for(n in t)if(lM.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function ES(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Fc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Fc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Fc({start:t.start,end:t.end})+") is still open")}function i6(e){const t=this;t.parser=n;function n(r){return r6(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function a6(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function l6(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
108
|
+
`}]}function c6(e,t){const n=t.value?t.value+`
|
|
109
|
+
`:"",r={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function u6(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function d6(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function h6(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Gl(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let i,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),i=e.footnoteOrder.length):i=o+1,a+=1,e.footnoteCounts.set(r,a);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function f6(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function p6(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function uM(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const s=e.all(t),o=s[0];o&&o.type==="text"?o.value="["+o.value:s.unshift({type:"text",value:"["});const i=s[s.length-1];return i&&i.type==="text"?i.value+=r:s.push({type:"text",value:r}),s}function m6(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return uM(e,t);const s={src:Gl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,o),e.applyData(t,o)}function g6(e,t){const n={src:Gl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function y6(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function w6(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return uM(e,t);const s={href:Gl(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function b6(e,t){const n={href:Gl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function x6(e,t,n){const r=e.all(t),s=n?k6(n):dM(t),o={},i=[];if(typeof t.checked=="boolean"){const d=r[0];let h;d&&d.type==="element"&&d.tagName==="p"?h=d:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const d=r[a];(s||a!==0||d.type!=="element"||d.tagName!=="p")&&i.push({type:"text",value:`
|
|
110
|
+
`}),d.type==="element"&&d.tagName==="p"&&!s?i.push(...d.children):i.push(d)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&i.push({type:"text",value:`
|
|
111
|
+
`});const u={type:"element",tagName:"li",properties:o,children:i};return e.patch(t,u),e.applyData(t,u)}function k6(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=dM(n[r])}return t}function dM(e){const t=e.spread;return t??e.children.length>1}function v6(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const i=r[s];if(i.type==="element"&&i.tagName==="li"&&i.properties&&Array.isArray(i.properties.className)&&i.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function S6(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function j6(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function C6(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function N6(e,t){const n=e.all(t),r=n.shift(),s=[];if(r){const i={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],i),s.push(i)}if(n.length>0){const i={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=ix(t.children[1]),c=UT(t.children[t.children.length-1]);a&&c&&(i.position={start:a,end:c}),s.push(i)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)}function E6(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",i=n&&n.type==="table"?n.align:void 0,a=i?i.length:t.children.length;let c=-1;const u=[];for(;++c<a;){const h=t.children[c],f={},p=i?i[c]:void 0;p&&(f.align=p);let m={type:"element",tagName:o,properties:f,children:[]};h&&(m.children=e.all(h),e.patch(h,m),m=e.applyData(h,m)),u.push(m)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function A6(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const AS=9,TS=32;function T6(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(MS(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(MS(t.slice(s),s>0,!1)),o.join("")}function MS(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===AS||o===TS;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===AS||o===TS;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function M6(e,t){const n={type:"text",value:T6(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function R6(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const I6={blockquote:a6,break:l6,code:c6,delete:u6,emphasis:d6,footnoteReference:h6,heading:f6,html:p6,imageReference:m6,image:g6,inlineCode:y6,linkReference:w6,link:b6,listItem:x6,list:v6,paragraph:S6,root:j6,strong:C6,table:N6,tableCell:A6,tableRow:E6,text:M6,thematicBreak:R6,toml:Md,yaml:Md,definition:Md,footnoteDefinition:Md};function Md(){}const hM=-1,wp=0,_c=1,Jh=2,fx=3,px=4,mx=5,gx=6,fM=7,pM=8,mM=typeof self=="object"?self:globalThis,RS=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new mM[e](t)},D6=(e,t)=>{const n=(s,o)=>(e.set(o,s),s),r=s=>{if(e.has(s))return e.get(s);const[o,i]=t[s];switch(o){case wp:case hM:return n(i,s);case _c:{const a=n([],s);for(const c of i)a.push(r(c));return a}case Jh:{const a=n({},s);for(const[c,u]of i)a[r(c)]=r(u);return a}case fx:return n(new Date(i),s);case px:{const{source:a,flags:c}=i;return n(new RegExp(a,c),s)}case mx:{const a=n(new Map,s);for(const[c,u]of i)a.set(r(c),r(u));return a}case gx:{const a=n(new Set,s);for(const c of i)a.add(r(c));return a}case fM:{const{name:a,message:c}=i;return n(typeof mM[a]=="function"?RS(a,c):new Error(c),s)}case pM:return n(BigInt(i),s);case"BigInt":return n(Object(BigInt(i)),s);case"ArrayBuffer":return n(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:a}=new Uint8Array(i);return n(new DataView(a),i)}}return n(RS(o,i),s)};return r},IS=e=>D6(new Map,e)(0),Yi="",{toString:O6}={},{keys:L6}=Object,bc=e=>{const t=typeof e;if(t!=="object"||!e)return[wp,t];const n=O6.call(e).slice(8,-1);switch(n){case"Array":return[_c,Yi];case"Object":return[Jh,Yi];case"Date":return[fx,Yi];case"RegExp":return[px,Yi];case"Map":return[mx,Yi];case"Set":return[gx,Yi];case"DataView":return[_c,n]}return n.includes("Array")?[_c,n]:e instanceof Error?[fM,e.name||"Error"]:[Jh,n]},Rd=([e,t])=>e===wp&&(t==="function"||t==="symbol"),$6=(e,t,n,r)=>{const s=(i,a)=>{const c=r.push(i)-1;return n.set(a,c),c},o=i=>{if(n.has(i))return n.get(i);let[a,c]=bc(i);switch(a){case wp:{let d=i;switch(c){case"bigint":a=pM,d=i.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return s([hM],i)}return s([a,d],i)}case _c:{if(c){let f=i;return c==="DataView"?f=new Uint8Array(i.buffer):c==="ArrayBuffer"&&(f=new Uint8Array(i)),s([c,[...f]],i)}const d=[],h=s([a,d],i);for(const f of i)d.push(o(f));return h}case Jh:{if(c)switch(c){case"BigInt":return s([c,i.toString()],i);case"Boolean":case"Number":case"String":return s([c,i.valueOf()],i)}if(t&&"toJSON"in i)return o(i.toJSON());const d=[],h=s([a,d],i);for(const f of L6(i))(e||!Rd(bc(i[f])))&&d.push([o(f),o(i[f])]);return h}case fx:return s([a,isNaN(i.getTime())?Yi:i.toISOString()],i);case px:{const{source:d,flags:h}=i;return s([a,{source:d,flags:h}],i)}case mx:{const d=[],h=s([a,d],i);for(const[f,p]of i)(e||!(Rd(bc(f))||Rd(bc(p))))&&d.push([o(f),o(p)]);return h}case gx:{const d=[],h=s([a,d],i);for(const f of i)(e||!Rd(bc(f)))&&d.push(o(f));return h}}const{message:u}=i;return s([a,{name:c,message:u}],i)};return o},DS=(e,{json:t,lossy:n}={})=>{const r=[];return $6(!(t||n),!!t,new Map,r)(e),r},Xh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?IS(DS(e,t)):structuredClone(e):(e,t)=>IS(DS(e,t));function P6(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function z6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function F6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||P6,r=e.options.footnoteBackLabel||z6,s=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const d=e.all(u),h=String(u.identifier).toUpperCase(),f=Gl(h.toLowerCase());let p=0;const m=[],w=e.footnoteCounts.get(h);for(;w!==void 0&&++p<=w;){m.length>0&&m.push({type:"text",value:" "});let v=typeof n=="string"?n:n(c,p);typeof v=="string"&&(v={type:"text",value:v}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,p),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const b=d[d.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const v=b.children[b.children.length-1];v&&v.type==="text"?v.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...m)}else d.push(...m);const x={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(d,!0)};e.patch(u,x),a.push(x)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Xh(i),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
|
|
112
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
|
|
113
|
+
`}]}}const bp=function(e){if(e==null)return H6;if(typeof e=="function")return xp(e);if(typeof e=="object")return Array.isArray(e)?B6(e):_6(e);if(typeof e=="string")return W6(e);throw new Error("Expected function, string, or object as test")};function B6(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=bp(e[n]);return xp(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function _6(e){const t=e;return xp(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function W6(e){return xp(t);function t(n){return n&&n.type===e}}function xp(e){return t;function t(n,r,s){return!!(U6(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function H6(){return!0}function U6(e){return e!==null&&typeof e=="object"&&"type"in e}const gM=[],K6=!0,nw=!1,V6="skip";function yM(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=bp(s),i=r?-1:1;a(e,void 0,[])();function a(c,u,d){const h=c&&typeof c=="object"?c:{};if(typeof h.type=="string"){const p=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(c.type+(p?"<"+p+">":""))+")"})}return f;function f(){let p=gM,m,w,b;if((!t||o(c,u,d[d.length-1]||void 0))&&(p=q6(n(c,d)),p[0]===nw))return p;if("children"in c&&c.children){const x=c;if(x.children&&p[0]!==V6)for(w=(r?x.children.length:-1)+i,b=d.concat(x);w>-1&&w<x.children.length;){const v=x.children[w];if(m=a(v,w,b)(),m[0]===nw)return m;w=typeof m[1]=="number"?m[1]:w+i}}return p}}}function q6(e){return Array.isArray(e)?e:typeof e=="number"?[K6,e]:e==null?gM:[e]}function yx(e,t,n,r){let s,o,i;typeof t=="function"&&typeof n!="function"?(o=void 0,i=t,s=n):(o=t,i=n,s=r),yM(e,o,a,s);function a(c,u){const d=u[u.length-1],h=d?d.children.indexOf(c):void 0;return i(c,h,d)}}const rw={}.hasOwnProperty,Y6={};function G6(e,t){const n=t||Y6,r=new Map,s=new Map,o=new Map,i={...I6,...n.handlers},a={all:u,applyData:X6,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:i,one:c,options:n,patch:J6,wrap:Z6};return yx(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const h=d.type==="definition"?r:s,f=String(d.identifier).toUpperCase();h.has(f)||h.set(f,d)}}),a;function c(d,h){const f=d.type,p=a.handlers[f];if(rw.call(a.handlers,f)&&p)return p(a,d,h);if(a.options.passThrough&&a.options.passThrough.includes(f)){if("children"in d){const{children:w,...b}=d,x=Xh(b);return x.children=a.all(d),x}return Xh(d)}return(a.options.unknownHandler||Q6)(a,d,h)}function u(d){const h=[];if("children"in d){const f=d.children;let p=-1;for(;++p<f.length;){const m=a.one(f[p],d);if(m){if(p&&f[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=OS(m.value)),!Array.isArray(m)&&m.type==="element")){const w=m.children[0];w&&w.type==="text"&&(w.value=OS(w.value))}Array.isArray(m)?h.push(...m):h.push(m)}}}return h}}function J6(e,t){e.position&&(t.position=z5(e))}function X6(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const i="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:i}}n.type==="element"&&o&&Object.assign(n.properties,Xh(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function Q6(e,t){const n=t.data||{},r="value"in t&&!(rw.call(n,"hProperties")||rw.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)}function Z6(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
114
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
115
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
116
|
+
`}),n}function OS(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function LS(e,t){const n=G6(e,t),r=n.one(e,void 0),s=F6(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
|
|
117
|
+
`},s),o}function eH(e,t){return e&&"run"in e?async function(n,r){const s=LS(n,{file:r,...t});await e.run(s,r)}:function(n,r){return LS(n,{file:r,...e||t})}}function $S(e){if(e)throw e}var dh=Object.prototype.hasOwnProperty,wM=Object.prototype.toString,PS=Object.defineProperty,zS=Object.getOwnPropertyDescriptor,FS=function(t){return typeof Array.isArray=="function"?Array.isArray(t):wM.call(t)==="[object Array]"},BS=function(t){if(!t||wM.call(t)!=="[object Object]")return!1;var n=dh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&dh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||dh.call(t,s)},_S=function(t,n){PS&&n.name==="__proto__"?PS(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},WS=function(t,n){if(n==="__proto__")if(dh.call(t,n)){if(zS)return zS(t,n).value}else return;return t[n]},tH=function e(){var t,n,r,s,o,i,a=arguments[0],c=1,u=arguments.length,d=!1;for(typeof a=="boolean"&&(d=a,a=arguments[1]||{},c=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});c<u;++c)if(t=arguments[c],t!=null)for(n in t)r=WS(a,n),s=WS(t,n),a!==s&&(d&&s&&(BS(s)||(o=FS(s)))?(o?(o=!1,i=r&&FS(r)?r:[]):i=r&&BS(r)?r:{},_S(a,{name:n,newValue:e(d,i,s)})):typeof s<"u"&&_S(a,{name:n,newValue:s}));return a};const Zm=eA(tH);function sw(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function nH(){const e=[],t={run:n,use:r};return t;function n(...s){let o=-1;const i=s.pop();if(typeof i!="function")throw new TypeError("Expected function as last argument, not "+i);a(null,...s);function a(c,...u){const d=e[++o];let h=-1;if(c){i(c);return}for(;++h<s.length;)(u[h]===null||u[h]===void 0)&&(u[h]=s[h]);s=u,d?rH(d,a)(...u):i(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function rH(e,t){let n;return r;function r(...i){const a=e.length>i.length;let c;a&&i.push(s);try{c=e.apply(this,i)}catch(u){const d=u;if(a&&n)throw d;return s(d)}a||(c&&c.then&&typeof c.then=="function"?c.then(o,s):c instanceof Error?s(c):o(c))}function s(i,...a){n||(n=!0,t(i,...a))}function o(i){s(null,i)}}const Os={basename:sH,dirname:oH,extname:iH,join:aH,sep:"/"};function sH(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Bu(e);let n=0,r=-1,s=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else r<0&&(o=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let i=-1,a=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else i<0&&(o=!0,i=s+1),a>-1&&(e.codePointAt(s)===t.codePointAt(a--)?a<0&&(r=s):(a=-1,r=i));return n===r?r=i:r<0&&(r=e.length),e.slice(n,r)}function oH(e){if(Bu(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function iH(e){Bu(e);let t=e.length,n=-1,r=0,s=-1,o=0,i;for(;t--;){const a=e.codePointAt(t);if(a===47){if(i){r=t+1;break}continue}n<0&&(i=!0,n=t+1),a===46?s<0?s=t:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||n<0||o===0||o===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function aH(...e){let t=-1,n;for(;++t<e.length;)Bu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":lH(n)}function lH(e){Bu(e);const t=e.codePointAt(0)===47;let n=cH(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function cH(e,t){let n="",r=0,s=-1,o=0,i=-1,a,c;for(;++i<=e.length;){if(i<e.length)a=e.codePointAt(i);else{if(a===47)break;a=47}if(a===47){if(!(s===i-1||o===1))if(s!==i-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),s=i,o=0;continue}}else if(n.length>0){n="",r=0,s=i,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,i):n=e.slice(s+1,i),r=i-s-1;s=i,o=0}else a===46&&o>-1?o++:o=-1}return n}function Bu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const uH={cwd:dH};function dH(){return"/"}function ow(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function hH(e){if(typeof e=="string")e=new URL(e);else if(!ow(e)){const t=new 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(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return fH(e)}function fH(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const eg=["history","path","basename","stem","extname","dirname"];class bM{constructor(t){let n;t?ow(t)?n={path:t}:typeof t=="string"||pH(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":uH.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<eg.length;){const o=eg[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let s;for(s in n)eg.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Os.basename(this.path):void 0}set basename(t){ng(t,"basename"),tg(t,"basename"),this.path=Os.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Os.dirname(this.path):void 0}set dirname(t){HS(this.basename,"dirname"),this.path=Os.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Os.extname(this.path):void 0}set extname(t){if(tg(t,"extname"),HS(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Os.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ow(t)&&(t=hH(t)),ng(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Os.basename(this.path,this.extname):void 0}set stem(t){ng(t,"stem"),tg(t,"stem"),this.path=Os.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new Kn(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function tg(e,t){if(e&&e.includes(Os.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Os.sep+"`")}function ng(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function HS(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function pH(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const mH=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},gH={}.hasOwnProperty;class wx extends mH{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=nH()}copy(){const t=new wx;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Zm(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(og("data",this.frozen),this.namespace[t]=n,this):gH.call(this.namespace,t)&&this.namespace[t]||void 0:t?(og("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Id(t),r=this.parser||this.Parser;return rg("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),rg("process",this.parser||this.Parser),sg("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,i){const a=Id(t),c=r.parse(a);r.run(c,a,function(d,h,f){if(d||!h||!f)return u(d);const p=h,m=r.stringify(p,f);bH(m)?f.value=m:f.result=m,u(d,f)});function u(d,h){d||!h?i(d):o?o(h):n(void 0,h)}}}processSync(t){let n=!1,r;return this.freeze(),rg("processSync",this.parser||this.Parser),sg("processSync",this.compiler||this.Compiler),this.process(t,s),KS("processSync","process",n),r;function s(o,i){n=!0,$S(o),r=i}}run(t,n,r){US(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(i,a){const c=Id(n);s.run(t,c,u);function u(d,h,f){const p=h||t;d?a(d):i?i(p):r(void 0,p,f)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),KS("runSync","run",r),s;function o(i,a){$S(i),s=a,r=!0}}stringify(t,n){this.freeze();const r=Id(n),s=this.compiler||this.Compiler;return sg("stringify",s),US(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(og("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):i(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...h]=u;c(d,h)}else i(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function i(u){if(!("plugins"in u)&&!("settings"in u))throw new 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");a(u.plugins),u.settings&&(s.settings=Zm(!0,s.settings,u.settings))}function a(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const h=u[d];o(h)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let h=-1,f=-1;for(;++h<r.length;)if(r[h][0]===u){f=h;break}if(f===-1)r.push([u,...d]);else if(d.length>0){let[p,...m]=d;const w=r[f][1];sw(w)&&sw(p)&&(p=Zm(!0,w,p)),r[f]=[u,p,...m]}}}}const yH=new wx().freeze();function rg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function sg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function og(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function US(e){if(!sw(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function KS(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Id(e){return wH(e)?e:new bM(e)}function wH(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function bH(e){return typeof e=="string"||xH(e)}function xH(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const kH="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",VS=[],qS={allowDangerousHtml:!0},vH=/^(https?|ircs?|mailto|xmpp)$/i,SH=[{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:"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 jl(e){const t=jH(e),n=CH(e);return NH(t.runSync(t.parse(n),n),e)}function jH(e){const t=e.rehypePlugins||VS,n=e.remarkPlugins||VS,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...qS}:qS;return yH().use(i6).use(n).use(eH,r).use(t)}function CH(e){const t=e.children||"",n=new bM;return typeof t=="string"&&(n.value=t),n}function NH(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,i=t.skipHtml,a=t.unwrapDisallowed,c=t.urlTransform||xM;for(const d of SH)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+kH+d.id,void 0);return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),yx(e,u),H5(e,{Fragment:l.Fragment,components:s,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function u(d,h,f){if(d.type==="raw"&&f&&typeof h=="number")return i?f.children.splice(h,1):f.children[h]={type:"text",value:d.value},h;if(d.type==="element"){let p;for(p in Jm)if(Object.hasOwn(Jm,p)&&Object.hasOwn(d.properties,p)){const m=d.properties[p],w=Jm[p];(w===null||w.includes(d.tagName))&&(d.properties[p]=c(String(m||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):o?o.includes(d.tagName):!1;if(!p&&r&&typeof h=="number"&&(p=!r(d,h,f)),p&&f&&typeof h=="number")return a&&d.children?f.children.splice(h,1,...d.children):f.children.splice(h,1),h}}}function xM(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||vH.test(e.slice(0,t))?e:""}function EH(e){return/^(file:\/\/|agentbox-agent:)/i.test(e)?e:xM(e)}const kM="mp3|wav|m4a|aac|ogg|mp4|mov|m4v|webm",Qh=`html?|pdf|png|jpe?g|gif|webp|svg|csv|md|markdown|${kM}`,AH=new RegExp(String.raw`(?<![\w./:@~-])(?:\.\/)?[\w-][\w./-]*\.(?:${Qh})\b`,"gi"),TH=new RegExp(String.raw`["“]([^"”\r\n]+\.(?:${Qh}))["”]|['‘]([^'’\r\n]+\.(?:${Qh}))['’]`,"gi"),MH=new RegExp(String.raw`\.(?:${kM})$`,"i");function iw(e){const t=String(e??"");return/^[a-z]+:/i.test(t)?!1:MH.test(t.split(/[?#]/)[0])}const RH=new RegExp(String.raw`(?<![\w./:@~-])(?:~|/)/?[\w./-]*\.(?:${Qh})\b`,"gi"),IH=new RegExp("(?<![\\w./:@-])(?:localhost|127\\.0\\.0\\.1):\\d{2,5}(?:\\/[^\\s<>()[\\]`'\"]*)?","gi"),DH=/(^|\n)([ \t]*)((?:~\/|\/)[\w./-]*[\w-])(\/?)[ \t]*(?=\n|$)/g,OH=/\.[a-z0-9]{1,8}$/i,LH=/\.(png|jpe?g|gif|webp|svg)$/i,$H=new Set(["link","linkReference","image","imageReference","definition","inlineCode","code","html"]);function Wc(e,t){var s;const n=t.replace(/\/+$/,"");if(!n)return null;let r=e;if(r.startsWith("~/")){const o=(s=n.match(/^\/(?:Users|home)\/[^/]+/))==null?void 0:s[0];if(!o)return null;r=o+r.slice(1)}return r.startsWith(n+"/")?r.slice(n.length+1):null}function PH(e,t){var a;const n=[],r=[];for(const c of e.matchAll(TH)){const u=c[1]??c[2],d=c.index+1;if(r.push({start:d,end:d+u.length}),!/^(?:~\/|\/|\.?\/?[\w-])[\w ./()-]*$/u.test(u))continue;const h=/^(?:~\/|\/)/.test(u);let f=h?Wc(u,t):u;const p=(a=t.match(/^\/(?:Users|home)\/[^/]+/))==null?void 0:a[0];!h&&!u.includes("/")&&p&&/\bDownloads(?: folder)?\s+as\s*$/i.test(e.slice(0,c.index))&&(f=`file://${p}/Downloads/${encodeURIComponent(u)}`),f&&n.push({at:d,text:u,url:f})}const s=c=>r.some(u=>c>=u.start&&c<u.end);for(const c of e.matchAll(AH))s(c.index)||n.push({at:c.index,text:c[0],url:c[0]});if(t){for(const c of e.matchAll(RH)){if(s(c.index))continue;const u=Wc(c[0],t);u&&n.push({at:c.index??0,text:c[0],url:u})}for(const c of e.matchAll(DH)){const[,u,d,h,f]=c;if(OH.test(h))continue;const p=Wc(h,t);p&&n.push({at:c.index+u.length+d.length,text:h+f,url:`${p}/`})}}for(const c of e.matchAll(IH)){const u=c[0].replace(/[.,;:!?]+$/,"");n.push({at:c.index??0,text:u,url:`http://${u}`})}n.sort((c,u)=>c.at-u.at);const o=[];let i=0;for(const c of n)c.at<i||(c.at>i&&o.push({type:"text",value:e.slice(i,c.at)}),o.push(LH.test(c.url)?{type:"image",url:c.url,alt:c.text}:{type:"link",url:c.url,children:[{type:"text",value:c.text}]}),i=c.at+c.text.length);return o.length?(i<e.length&&o.push({type:"text",value:e.slice(i)}),o):[]}function vM(e,t={}){if(!e||!Array.isArray(e.children))return;const n=String((t==null?void 0:t.dir)??""),r=[];for(const s of e.children){if(s.type==="text"&&typeof s.value=="string"){const o=PH(s.value,n);if(o.length){r.push(...o);continue}r.push(s);continue}$H.has(s.type)||vM(s,t),r.push(s)}e.children=r}function zH(e={}){return t=>{vM(t,e)}}const SM=/^(?:[a-z][a-z0-9+.-]*:)/i;function aw(e){const t=(e??"").trim();if(!t)return"file";if(SM.test(t)&&!/^file:/i.test(t))return"link";if(/\/$/.test(t))return"folder";const n=t.replace(/[?#].*$/,"");return/\.html?$/i.test(n)?"page":/\.(md|markdown|txt|pdf|docx?|rtf)$/i.test(n)?"doc":/\.(png|jpe?g|gif|webp|svg|heic)$/i.test(n)?"image":iw(t)?"media":qh(t)?"code":"file"}function Zh(e){const t=(e??"").trim();if(/^mailto:/i.test(t))return t.slice(7);if(SM.test(t)&&!/^file:/i.test(t))return t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/\/+$/,"");const n=t.replace(/^file:\/\//i,"").replace(/\/+$/,"").split("/");return n[n.length-1]||t}function jM(e,t){const n=Zh(e),r=t==null?void 0:t.trim();return!r||r===e?n:aw(e)==="link"?!/\s/.test(r)&&/[/.:]/.test(r)?n:null:r.endsWith(n)?n:!/\s/.test(r)&&/[/.]/.test(r)?Zh(r):null}function FH(e,{thread:t,name:n}){const r=e.replace(/\/+$/,"").split("/"),s=r[r.length-1]??e;if(r[r.length-2]!=="designs"||!/^w-[a-f0-9]{10}$/i.test(s))return s;if(s===t)return"Designs for this thread";const o=n==null?void 0:n(s);return o?`Designs for ${o}`:s}const BH="modulepreload",_H=function(e,t){return new URL(e,t).href},YS={},ms=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){const i=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),c=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(u=>{if(u=_H(u,r),u in YS)return;YS[u]=!0;const d=u.endsWith(".css"),h=d?'[rel="stylesheet"]':"";if(!!r)for(let m=i.length-1;m>=0;m--){const w=i[m];if(w.href===u&&(!d||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${h}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":BH,d||(p.as="script"),p.crossOrigin="",p.href=u,c&&p.setAttribute("nonce",c),document.head.appendChild(p),d)return new Promise((m,w)=>{p.addEventListener("load",m),p.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return s.then(i=>{for(const a of i||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})},WH=/^(zsh|bash|sh|fish|ksh|dash|tcsh|csh|Shell)$/i;function HH(e){const t=String(e).replace(/^-+/,"");return(t.split("/").pop()||t).replace(/^-+/,"")}function CM(e,t){if(t)return!1;const n=String(e||"").trim();return n?!WH.test(HH(n)):!1}function UH(e){let t=!1;return(n,r)=>{const s=CM(n,r);t&&!s&&e(),t=s}}const KH=/https?:\/\/[^\s"'<>`]+/g,VH=/[.,;:!?)\]}'"]+$/;function qH(e,t){var c,u;if(!e(t))return[];let n=t;for(;n>0&&((c=e(n))!=null&&c.wrapped)&&e(n-1);)n-=1;const r=[e(n).text];for(let d=n+1;(u=e(d))!=null&&u.wrapped;d+=1)r.push(e(d).text);const s=[];let o="";for(const d of r)s.push(o.length),o+=d;const i=d=>{let h=s.length-1;for(;h>0&&s[h]>d;)h-=1;return{x:d-s[h]+1,y:n+h+1}},a=[];for(const d of o.matchAll(KH)){const h=d[0].replace(VH,"");if(!/^https?:\/\/./.test(h))continue;const f=i(d.index),p=i(d.index+h.length-1);f.y>t+1||p.y<t+1||a.push({url:h,range:{start:f,end:p}})}return a}const GS="invalid range";function YH(e,{warn:t=console.warn}={}){var o,i;const n=(i=(o=e==null?void 0:e._core)==null?void 0:o._accessibilityManager)==null?void 0:i.value,r=n==null?void 0:n._handleSelectionChange;if(typeof r!="function"||r.guardsInvalidRange)return!1;const s=function(...a){try{return r.apply(this,a)}catch(c){if((c==null?void 0:c.message)!==GS)throw c;t(`xterm mapped the selection onto no cells and threw "${GS}"; cleared the terminal's selection instead`),e.clearSelection()}};return s.guardsInvalidRange=!0,n._handleSelectionChange=s,!0}function GH(e,{chunk:t=16384,onError:n}={}){let r="",s=!1;async function o(){if(!s){s=!0;try{for(;r;){const i=r.slice(0,t);r=r.slice(i.length),await e(i)}}catch(i){r="",n==null||n(i)}finally{s=!1}}}return{push(i){r+=i,o()}}}const JH={ArrowLeft:"\x1Bb",ArrowRight:"\x1Bf"};function XH(e,t){if(!t||!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;const n=JH[e.key];if(n)return e.type==="keydown"?n:""}const JS="zero.terminal.size",NM={height:120,width:280},QH={height:120,width:320},ZH=4e3;function eU(e,t,n,r){const s=NM[e],o=Math.max(s,r-QH[e]);return Math.round(Math.min(o,Math.max(s,t+n)))}function tU(e){let t;try{t=JSON.parse(e??"")}catch{return{}}if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const r of["height","width"]){const s=t[r];Number.isFinite(s)&&s>=NM[r]&&s<=ZH&&(n[r]=s)}return n}function bx(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round","aria-hidden":"true",children:l.jsx("path",{d:"M6.6 6.6 17.4 17.4M17.4 6.6 6.6 17.4"})})}const XS=new Map,ig=new Map;function xx({product:e,id:t,headerTarget:n,startOpen:r=!1,commandSession:s=!1,onOpenChange:o,onCommandFinished:i}){const a=JSON.stringify({product:e,id:t}),c=g.useRef(i);c.current=i;const u=ig.get(a),[d,h]=g.useState((u==null?void 0:u.open)??r),[f,p]=g.useState((u==null?void 0:u.placement)??"bottom"),[m,w]=g.useState(""),[b,x]=g.useState(""),[v,S]=g.useState(!1),[C,O]=g.useState("Shell"),[N,P]=g.useState(0),M=g.useRef(null),R=g.useRef(null),[L,H]=g.useState(()=>tU(localStorage.getItem(JS)));g.useEffect(()=>{ig.set(a,{open:d,placement:f})},[a,d,f]),g.useEffect(()=>{var le;localStorage.setItem(JS,JSON.stringify(L));const W=(le=R.current)==null?void 0:le.parentElement;if(W){for(const[ge,j]of[["--task-terminal-h",L.height],["--task-terminal-w",L.width]])j?W.style.setProperty(ge,`${j}px`):W.style.removeProperty(ge);return()=>{W.style.removeProperty("--task-terminal-h"),W.style.removeProperty("--task-terminal-w")}}},[L,d,f]);const _=f==="bottom"?"height":"width";function Y(W){var Oe;const le=(Oe=R.current)==null?void 0:Oe.parentElement;if(W.button!==0||!R.current||!le)return;W.preventDefault();const ge=W.currentTarget,j=_==="height",ae=R.current.getBoundingClientRect(),me=j?ae.height:ae.width,E=j?le.clientHeight:le.clientWidth,K=j?W.clientY:W.clientX;ge.setPointerCapture(W.pointerId),ge.classList.add("dragging");const z=F=>{const J=eU(_,me,K-(j?F.clientY:F.clientX),E);H(ze=>({...ze,[_]:J}))},xe=()=>{ge.classList.remove("dragging"),ge.removeEventListener("pointermove",z),ge.removeEventListener("pointerup",xe),ge.removeEventListener("pointercancel",xe)};ge.addEventListener("pointermove",z),ge.addEventListener("pointerup",xe),ge.addEventListener("pointercancel",xe)}g.useEffect(()=>{o==null||o(d)},[d,o]),g.useEffect(()=>{const W=()=>h(!0),le=()=>h(ge=>!ge);return window.addEventListener("task-terminal-open",W),window.addEventListener("task-terminal-toggle",le),()=>{window.removeEventListener("task-terminal-open",W),window.removeEventListener("task-terminal-toggle",le)}},[]),g.useEffect(()=>{if(!d||!M.current)return;let W=!1,le,ge=()=>{};return w(""),S(!1),(async()=>{try{const[{Terminal:j},{FitAddon:ae},{SerializeAddon:me},E]=await Promise.all([ms(()=>import("./xterm-BT7tBf8A.js"),[],import.meta.url),ms(()=>import("./addon-fit-YJmn1quW.js"),[],import.meta.url),ms(()=>import("./addon-serialize-CsFQTvP_.js"),[],import.meta.url),q.assistiveTech()]);if(W||!M.current)return;const K=getComputedStyle(M.current),z=new j({cursorBlink:!0,screenReaderMode:E,allowTransparency:!0,fontFamily:"Menlo, Monaco, monospace",fontSize:12,scrollback:5e3,allowProposedApi:!1,theme:{background:"#00000000",foreground:K.color},convertEol:!1}),xe=new ae,Oe=new me;z.loadAddon(Oe),z.loadAddon(xe),z.open(M.current),YH(z);const F=()=>z.buffer.active,J=V=>{var G;const ue=F().getLine(V);return ue?{text:ue.translateToString(!((G=F().getLine(V+1))!=null&&G.isWrapped)),wrapped:ue.isWrapped}:void 0};z.registerLinkProvider({provideLinks:(V,ue)=>{const G=qH(J,V-1);ue(G.length?G.map(ie=>({range:ie.range,text:ie.url,activate:()=>{window.open(ie.url,"_blank")}})):void 0)}});const ze=UH(()=>{var V;return(V=c.current)==null?void 0:V.call(c)});let ye=0,Z=!1,Ce="";const Ee=V=>{W||w(V instanceof Error?V.message:String(V))},oe=()=>{var V,ue;!Z||W||!((V=M.current)!=null&&V.clientWidth)||!((ue=M.current)!=null&&ue.clientHeight)||(xe.fit(),Z&&q.terminal({product:e,id:t,action:"resize",cols:Math.max(2,Math.min(500,z.cols)),rows:Math.max(2,Math.min(300,z.rows))}).catch(Ee))},ne=new ResizeObserver(oe);ne.observe(M.current);const Ie=GH(V=>q.terminal({product:e,id:t,action:"write",data:V}),{onError:Ee}),Q=z.onData(V=>Ie.push(V)),he=/Mac/.test(navigator.platform);z.attachCustomKeyEventHandler(V=>{const ue=XH(V,he);return ue===void 0?!0:(ue&&Ie.push(ue),V.preventDefault(),!1)}),ge=()=>{Z&&XS.set(a,{token:Ce,screen:Oe.serialize({scrollback:1e3}),offset:ye,cols:z.cols,rows:z.rows}),ne.disconnect(),Q.dispose(),z.dispose()};const te=async V=>{W||(x(V.cwd),O(V.process),S(V.exited),ze(V.process,V.exited),V.truncated&&(z.reset(),z.writeln("[Earlier terminal output omitted]")),await new Promise(ue=>z.write(V.data,ue)),ye=V.offset)};let ee=await q.terminal({product:e,id:t,action:"open"});if(W)return;Ce=ee.token;const U=XS.get(a);(U==null?void 0:U.token)===Ce&&(z.resize(U.cols,U.rows),await new Promise(V=>z.write(U.screen,V)),ee=await q.terminal({product:e,id:t,action:"read",offset:U.offset})),await te(ee),Z=!0,oe(),z.focus();const I=async()=>{try{const V=await q.terminal({product:e,id:t,action:"read",offset:ye,wait:1e3});await te(V),W||(le=setTimeout(I,V.live?0:150))}catch(V){Ee(V)}};le=setTimeout(I,0)}catch(j){W||w(j instanceof Error?j.message:String(j))}})(),()=>{W=!0,le&&clearTimeout(le),ge()}},[d,e,t,N]);async function se(){try{await q.terminal({product:e,id:t,action:"close"}),ig.set(a,{open:!1,placement:f}),S(!0),O("Ended"),h(!1)}catch(W){w(String(W))}}async function re(){try{await q.terminal({product:e,id:t,action:"close"}),P(W=>W+1)}catch(W){w(String(W))}}const T=l.jsx("button",{className:`icon-btn terminal-header-control${d?" on":""}`,"data-hint":"terminal","data-hint-align":"right",title:d?"Hide terminal":"Open terminal","aria-label":d?"Hide terminal":"Open terminal","aria-expanded":d,onClick:()=>h(!d),children:l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),l.jsx("path",{d:"m7 9 3 3-3 3m6 0h4"})]})});return l.jsxs(l.Fragment,{children:[n&&bs.createPortal(T,n),d&&l.jsxs("section",{ref:R,className:`task-terminal task-terminal-${f}${L[_]?" task-terminal-sized":""}`,"aria-label":"Task terminal",children:[l.jsx("div",{className:"task-terminal-grip",role:"separator","aria-orientation":_==="height"?"horizontal":"vertical","aria-label":"Resize terminal",title:"Drag to resize. Double-click to reset.",onPointerDown:Y,onDoubleClick:()=>H(W=>{const le={...W};return delete le[_],le})}),l.jsx(nU,{cwd:b,processName:C,exited:v,placement:f,onStop:()=>void q.terminal({product:e,id:t,action:"write",data:""}).catch(W=>w(String(W))),onEnd:()=>void se(),onPlacement:()=>p(f==="bottom"?"side":"bottom"),onHide:()=>h(!1)}),m&&l.jsxs("div",{className:"task-terminal-message",role:"alert",children:[m," ",l.jsx("button",{onClick:()=>P(W=>W+1),children:"Retry"})]}),l.jsx("div",{className:"task-terminal-screen",ref:M}),v&&l.jsx("div",{className:"task-terminal-message",children:s?"Command exited.":l.jsxs(l.Fragment,{children:["Shell exited. ",l.jsx("button",{onClick:()=>void re(),children:"New session"})]})})]})]})}function nU({cwd:e,processName:t,exited:n,placement:r,onStop:s,onEnd:o,onPlacement:i,onHide:a}){const c=CM(t,n);return l.jsxs("header",{className:"task-terminal-toolbar",children:[l.jsx("strong",{children:"Terminal"}),l.jsx("span",{className:"task-terminal-folder",title:e,children:e.split("/").filter(Boolean).pop()||"Opening…"}),l.jsxs("span",{className:"task-terminal-controls",children:[l.jsx("span",{className:"task-terminal-process",children:t}),c&&l.jsx("button",{className:"task-terminal-word",title:`Stop ${t} (Ctrl+C). The shell stays open.`,onClick:s,children:"Stop command"}),l.jsx("button",{className:"task-terminal-word",title:"End this shell and everything it started. The terminal closes.",onClick:o,children:"End shell"}),l.jsx("button",{className:"task-terminal-icon","aria-label":r==="bottom"?"Move terminal to side":"Move terminal to bottom",title:r==="bottom"?"Move to side":"Move to bottom",onClick:i,children:l.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":"true",children:[l.jsx("rect",{x:"2",y:"3",width:"16",height:"14",rx:"2"}),r==="bottom"?l.jsx("path",{d:"M12 3v14"}):l.jsx("path",{d:"M2 12h16"})]})}),l.jsx("button",{className:"task-terminal-icon task-terminal-hide","aria-label":"Hide terminal panel",title:"Hide the terminal. The shell keeps running.",onClick:a,children:l.jsx(bx,{})})]})]})}function rU(e,t){let n=!1,r,s;const o=async()=>{try{const i=await e(),a=JSON.stringify(i);!n&&a!==s&&(s=a,t(i))}catch{}finally{n||(r=setTimeout(o,1e3))}};return o(),()=>{n=!0,clearTimeout(r)}}const tr=(e,t,n=null,r=[])=>({name:e,description:t,menuDescription:null,whole:!0,argumentHint:n,aliases:r}),EM=[tr("model","Show models or change this task’s model","[model]"),tr("effort","Show or change reasoning effort","[level]"),tr("compact","Free up context in this conversation"),tr("review","Review uncommitted changes, a branch, or specific instructions","[--base branch | --commit sha | instructions]"),tr("status","Show this task’s configuration and conversation status"),tr("usage","Show the account’s last reported usage"),tr("skills","List skills available in this project"),tr("mcp","Show this conversation’s connected MCP servers"),tr("goal","View, pause, or clear this conversation’s goal","[pause | clear]"),tr("diff","Show staged and unstaged changes"),tr("rename","Rename this task","<name>"),tr("copy","Copy the last assistant response"),tr("help","Show available commands and remaining compatibility gaps")],hh=EM.filter(e=>["model","effort","diff","rename","help"].includes(e.name)),sU=tr("fork","Start a new task from this conversation","<what to try instead>"),oU={codex:EM,claude:[tr("remote-control","Continue this conversation in Claude on another device",null,["rc"]),sU,...Ty.map(e=>hh.find(t=>t.name===e.name)??e),...hh.filter(e=>!Ty.some(t=>t.name===e.name))],local:hh};function lw(e){const t=Ih(e)??Ih();return oU[t.commandMenu]??[]}function iU(e,t){if(typeof e!="string")return null;const n=e.trim().match(/^\/([a-z][a-z0-9:_-]*)(?:\s+([\s\S]*))?$/i);if(!n)return null;const r=n[1].toLowerCase(),s=(n[2]??"").trim(),o=lw(t).find(a=>SA(a).includes(r));if(!o)return{name:r,args:s,route:"unavailable"};if(o.name==="fork")return{name:"fork",args:s,route:"fork"};const i=(Ih(t)??Ih()).commandRoute;return{name:o.name,args:s,route:o.name==="remote-control"?"remote":i==="codex"?"codex":hh.some(a=>a.name===o.name)?"local":i}}const cw=120,aU=24;function lU(e){const t=e.search(/[.!?](\s|$)/);return t>=aU&&t<cw?e.slice(0,t+1):zs(e,cw)}function kx(e){const t=e.trim(),n=t.split(`
|
|
118
|
+
`),r=(n[0]??"").trim();return r.length<=cw?{title:r,body:n.slice(1).join(`
|
|
119
|
+
`).trim()}:{title:lU(r),body:t}}function cU(e){const t=(e.body??"").trim();if(!t)return e.title;if(t===e.title)return t;const n=kx(t);return n.body===t&&n.title===e.title?t:`${e.title}
|
|
120
|
+
${t}`}function uU(e,t=[]){return Vl().some(n=>n.id===e||n.model===e)?"claude":t.some(n=>n.id===e)||/^(gpt|o\d|codex)/i.test(e)?"codex":"claude"}function dU(e){var t;return((t=Vl().find(n=>n.model===e))==null?void 0:t.id)??e}const ef=e=>`${e.engine}:${e.model}`;function hU(e,{codexModels:t=[],codexDefault:n=null,codexOffered:r,claudeOffered:s=!0,limit:o=3}){var d,h;const i=[],a=new Set,c=f=>{i.length>=o||a.has(ef(f))||(a.add(ef(f)),i.push(f))},u=e.filter(f=>typeof f.model=="string"&&f.model).slice().sort((f,p)=>(p.createdAt??0)-(f.createdAt??0));for(const f of u){const p=f.model,m=f.engine==="codex"||f.engine==="claude"?f.engine:uU(p,t);m==="codex"&&!r||m==="claude"&&!s||c({engine:m,model:m==="claude"?dU(p):p})}if(!s){r&&c({engine:"codex",model:n??((d=t[0])==null?void 0:d.id)??xa});for(const f of r?t:[])c({engine:"codex",model:f.id});return i}c({engine:"claude",model:np}),c({engine:"claude",model:"sonnet"}),r&&c({engine:"codex",model:n??((h=t[0])==null?void 0:h.id)??xa});for(const f of Vl())c({engine:"claude",model:f.id});return i}function fU({codexModels:e=[],codexOffered:t,claudeOffered:n=!0}){return{claude:n?Vl().map(r=>({engine:"claude",model:r.id})):[],codex:t?e.map(r=>({engine:"codex",model:r.id})):[]}}function pU(e,t){const n=new Set([...t.claude,...t.codex].map(ef));return n.size-e.filter(r=>n.has(ef(r))).length}const mU=(e,t)=>!!e&&!!t&&e.engine===t.engine&&e.model===t.model;function gU({engine:e,model:t,effort:n,engineCount:r,codexDefault:s}){const o=e==="codex"?n2("codex",t,s)?{model:t}:{}:{model:t||np};return{...r>1?{engine:e}:{},...o,...n?{effort:n}:{}}}function yU(e=Date.now()){const t=new Date(e);return t.setDate(t.getDate()+1),t.setHours(8,0,0,0),t.getTime()}function wU(e=Date.now()){const t=new Date(e),n=(8-t.getDay())%7||7;return t.setDate(t.getDate()+n),t.setHours(8,0,0,0),t.getTime()}const bU=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],xU=e=>String(e).padStart(2,"0");function uw(e){const t=new Date(e);return`${bU[t.getDay()]} ${t.getHours()}:${xU(t.getMinutes())}`}function kU(e,t=Date.now()){const n=ap(e??"",t);return!n||n.ts<=t?null:{ts:n.ts,hint:uw(n.ts)}}function vU(e,t){var r;const n=(e??"").trim();return!n&&!t.length?null:kx(n||`Attached: ${(r=t[0])==null?void 0:r.name}`)}const SU=e=>{var t;return((t=e.team)==null?void 0:t.direct)===!0};function jU(e){return e.filter(t=>!SU(t))}function QS(e,{defaultProduct:t,remembered:n}){return e.find(r=>r.slug===t)??e.find(r=>r.slug===n)??e.find(r=>!r.practice)??e[0]??null}const ZS=["#ee6018","#5b9bd5","#9a8f86","#6aa37a","#b48ead","#d0a65a","#4fa3a5"];function AM(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)>>>0;return ZS[t%ZS.length]}function vx(e,t){return e.filter(n=>n.id!==t)}function dw(e,t){const n=(t??"").trim().toLowerCase();return n?e.filter(r=>r.name.toLowerCase().includes(n)||r.email.toLowerCase().startsWith(n)):e.slice()}function CU(e){return e?`Message ${bn(e)}`:"What do you need done?"}function NU(e){return e.length?`Goes to ${kp(e)}'s ${e.length>1?"inboxes":"inbox"}.`:""}function kp(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const EU=[{id:"team",label:"Team",line:"Teammates see its summary on the Team board."},{id:"people",label:"Chosen people",line:"Only the people you pick see its summary."},{id:"private",label:"Private",line:"Only you see it. It is not on the Team board."}];function AU(e,t){if(e!=="people")return{visibility:e};const n=[...new Set(t.filter(Boolean))];return n.length?{visibility:"people",visibleTo:n}:{visibility:"private"}}function TU(e){const{who:t}=Mo(e);return t==="private"?"private":t==="people"?"people":"team"}function MU(e){return Mo(e).people}function hw(e,t){const n=e.map(r=>t.find(s=>s.id===r)).filter(r=>!!r);return n.length?n.length>2?`${n.length} people`:n.map(r=>bn(r)).join(" and "):"Chosen people"}function ej(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}function RU(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function IU(e,t,n){const s=bp((n||{}).ignore||[]),o=DU(t);let i=-1;for(;++i<o.length;)yM(e,"text",a);function a(u,d){let h=-1,f;for(;++h<d.length;){const p=d[h],m=f?f.children:void 0;if(s(p,m?m.indexOf(p):void 0,f))return;f=p}if(f)return c(u,d)}function c(u,d){const h=d[d.length-1],f=o[i][0],p=o[i][1];let m=0;const b=h.children.indexOf(u);let x=!1,v=[];f.lastIndex=0;let S=f.exec(u.value);for(;S;){const C=S.index,O={index:S.index,input:S.input,stack:[...d,u]};let N=p(...S,O);if(typeof N=="string"&&(N=N.length>0?{type:"text",value:N}:void 0),N===!1?f.lastIndex=C+1:(m!==C&&v.push({type:"text",value:u.value.slice(m,C)}),Array.isArray(N)?v.push(...N):N&&v.push(N),m=C+S[0].length,x=!0),!f.global)break;S=f.exec(u.value)}return x?(m<u.value.length&&v.push({type:"text",value:u.value.slice(m)}),h.children.splice(b,1,...v)):v=[u],b+v.length}}function DU(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const s=n[r];t.push([OU(s[0]),LU(s[1])])}return t}function OU(e){return typeof e=="string"?new RegExp(RU(e),"g"):e}function LU(e){return typeof e=="function"?e:function(){return e}}const ag="phrasing",lg=["autolink","link","image","label"];function $U(){return{transforms:[HU],enter:{literalAutolink:zU,literalAutolinkEmail:cg,literalAutolinkHttp:cg,literalAutolinkWww:cg},exit:{literalAutolink:WU,literalAutolinkEmail:_U,literalAutolinkHttp:FU,literalAutolinkWww:BU}}}function PU(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ag,notInConstruct:lg},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ag,notInConstruct:lg},{character:":",before:"[ps]",after:"\\/",inConstruct:ag,notInConstruct:lg}]}}function zU(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function cg(e){this.config.enter.autolinkProtocol.call(this,e)}function FU(e){this.config.exit.autolinkProtocol.call(this,e)}function BU(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function _U(e){this.config.exit.autolinkEmail.call(this,e)}function WU(e){this.exit(e)}function HU(e){IU(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,UU],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),KU]],{ignore:["link","linkReference"]})}function UU(e,t,n,r,s){let o="";if(!TM(s)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!VU(n)))return!1;const i=qU(n+r);if(!i[0])return!1;const a={type:"link",title:null,url:o+t+i[0],children:[{type:"text",value:t+i[0]}]};return i[1]?[a,{type:"text",value:i[1]}]:a}function KU(e,t,n,r){return!TM(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function VU(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function qU(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const s=ej(e,"(");let o=ej(e,")");for(;r!==-1&&s>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function TM(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||va(n)||gp(n))&&(!t||n!==47)}MM.peek=nK;function YU(){this.buffer()}function GU(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function JU(){this.buffer()}function XU(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function QU(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ys(this.sliceSerialize(e)).toLowerCase(),n.label=t}function ZU(e){this.exit(e)}function eK(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ys(this.sliceSerialize(e)).toLowerCase(),n.label=t}function tK(e){this.exit(e)}function nK(){return"["}function MM(e,t,n,r){const s=n.createTracker(r);let o=s.move("[^");const i=n.enter("footnoteReference"),a=n.enter("reference");return o+=s.move(n.safe(n.associationId(e),{after:"]",before:o})),a(),i(),o+=s.move("]"),o}function rK(){return{enter:{gfmFootnoteCallString:YU,gfmFootnoteCall:GU,gfmFootnoteDefinitionLabelString:JU,gfmFootnoteDefinition:XU},exit:{gfmFootnoteCallString:QU,gfmFootnoteCall:ZU,gfmFootnoteDefinitionLabelString:eK,gfmFootnoteDefinition:tK}}}function sK(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:MM},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,s,o,i){const a=o.createTracker(i);let c=a.move("[^");const u=o.enter("footnoteDefinition"),d=o.enter("label");return c+=a.move(o.safe(o.associationId(r),{before:c,after:"]"})),d(),c+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),c+=a.move((t?`
|
|
121
|
+
`:" ")+o.indentLines(o.containerFlow(r,a.current()),t?RM:oK))),u(),c}}function oK(e,t,n){return t===0?e:RM(e,t,n)}function RM(e,t,n){return(n?"":" ")+e}const iK=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];IM.peek=dK;function aK(){return{canContainEols:["delete"],enter:{strikethrough:cK},exit:{strikethrough:uK}}}function lK(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:iK}],handlers:{delete:IM}}}function cK(e){this.enter({type:"delete",children:[]},e)}function uK(e){this.exit(e)}function IM(e,t,n,r){const s=n.createTracker(r),o=n.enter("strikethrough");let i=s.move("~~");return i+=n.containerPhrasing(e,{...s.current(),before:i,after:"~"}),i+=s.move("~~"),o(),i}function dK(){return"~"}function hK(e){return e.length}function fK(e,t){const n=t||{},r=(n.align||[]).concat(),s=n.stringLength||hK,o=[],i=[],a=[],c=[];let u=0,d=-1;for(;++d<e.length;){const w=[],b=[];let x=-1;for(e[d].length>u&&(u=e[d].length);++x<e[d].length;){const v=pK(e[d][x]);if(n.alignDelimiters!==!1){const S=s(v);b[x]=S,(c[x]===void 0||S>c[x])&&(c[x]=S)}w.push(v)}i[d]=w,a[d]=b}let h=-1;if(typeof r=="object"&&"length"in r)for(;++h<u;)o[h]=tj(r[h]);else{const w=tj(r);for(;++h<u;)o[h]=w}h=-1;const f=[],p=[];for(;++h<u;){const w=o[h];let b="",x="";w===99?(b=":",x=":"):w===108?b=":":w===114&&(x=":");let v=n.alignDelimiters===!1?1:Math.max(1,c[h]-b.length-x.length);const S=b+"-".repeat(v)+x;n.alignDelimiters!==!1&&(v=b.length+v+x.length,v>c[h]&&(c[h]=v),p[h]=v),f[h]=S}i.splice(1,0,f),a.splice(1,0,p),d=-1;const m=[];for(;++d<i.length;){const w=i[d],b=a[d];h=-1;const x=[];for(;++h<u;){const v=w[h]||"";let S="",C="";if(n.alignDelimiters!==!1){const O=c[h]-(b[h]||0),N=o[h];N===114?S=" ".repeat(O):N===99?O%2?(S=" ".repeat(O/2+.5),C=" ".repeat(O/2-.5)):(S=" ".repeat(O/2),C=S):C=" ".repeat(O)}n.delimiterStart!==!1&&!h&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&v==="")&&(n.delimiterStart!==!1||h)&&x.push(" "),n.alignDelimiters!==!1&&x.push(S),x.push(v),n.alignDelimiters!==!1&&x.push(C),n.padding!==!1&&x.push(" "),(n.delimiterEnd!==!1||h!==u-1)&&x.push("|")}m.push(n.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return m.join(`
|
|
122
|
+
`)}function pK(e){return e==null?"":String(e)}function tj(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function mK(e,t,n,r){const s=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const i=n.indentLines(n.containerFlow(e,o.current()),gK);return s(),i}function gK(e,t,n){return">"+(n?"":" ")+e}function yK(e,t){return nj(e,t.inConstruct,!0)&&!nj(e,t.notInConstruct,!1)}function nj(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function rj(e,t,n,r){let s=-1;for(;++s<n.unsafe.length;)if(n.unsafe[s].character===`
|
|
123
|
+
`&&yK(n.stack,n.unsafe[s]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
124
|
+
`}function wK(e,t){const n=String(e);let r=n.indexOf(t),s=r,o=0,i=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===s?++o>i&&(i=o):o=1,s=r+t.length,r=n.indexOf(t,s);return i}function bK(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function xK(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function kK(e,t,n,r){const s=xK(n),o=e.value||"",i=s==="`"?"GraveAccent":"Tilde";if(bK(e,n)){const h=n.enter("codeIndented"),f=n.indentLines(o,vK);return h(),f}const a=n.createTracker(r),c=s.repeat(Math.max(wK(o,s)+1,3)),u=n.enter("codeFenced");let d=a.move(c);if(e.lang){const h=n.enter(`codeFencedLang${i}`);d+=a.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...a.current()})),h()}if(e.lang&&e.meta){const h=n.enter(`codeFencedMeta${i}`);d+=a.move(" "),d+=a.move(n.safe(e.meta,{before:d,after:`
|
|
125
|
+
`,encode:["`"],...a.current()})),h()}return d+=a.move(`
|
|
126
|
+
`),o&&(d+=a.move(o+`
|
|
127
|
+
`)),d+=a.move(c),u(),d}function vK(e,t,n){return(n?"":" ")+e}function Sx(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function SK(e,t,n,r){const s=Sx(n),o=s==='"'?"Quote":"Apostrophe",i=n.enter("definition");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("[");return u+=c.move(n.safe(n.associationId(e),{before:u,after:"]",...c.current()})),u+=c.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(a=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
128
|
+
`,...c.current()}))),a(),e.title&&(a=n.enter(`title${o}`),u+=c.move(" "+s),u+=c.move(n.safe(e.title,{before:u,after:s,...c.current()})),u+=c.move(s),a()),i(),u}function jK(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function mu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function tf(e,t,n){const r=Il(e),s=Il(t);return r===void 0?s===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}DM.peek=CK;function DM(e,t,n,r){const s=jK(n),o=n.enter("emphasis"),i=n.createTracker(r),a=i.move(s);let c=i.move(n.containerPhrasing(e,{after:s,before:a,...i.current()}));const u=c.charCodeAt(0),d=tf(r.before.charCodeAt(r.before.length-1),u,s);d.inside&&(c=mu(u)+c.slice(1));const h=c.charCodeAt(c.length-1),f=tf(r.after.charCodeAt(0),h,s);f.inside&&(c=c.slice(0,-1)+mu(h));const p=i.move(s);return o(),n.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},a+c+p}function CK(e,t,n){return n.options.emphasis||"*"}function NK(e,t){let n=!1;return yx(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,nw}),!!((!e.depth||e.depth<3)&&ux(e)&&(t.options.setext||n))}function EK(e,t,n,r){const s=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(NK(e,n)){const d=n.enter("headingSetext"),h=n.enter("phrasing"),f=n.containerPhrasing(e,{...o.current(),before:`
|
|
129
|
+
`,after:`
|
|
130
|
+
`});return h(),d(),f+`
|
|
131
|
+
`+(s===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.lastIndexOf(`
|
|
132
|
+
`))+1))}const i="#".repeat(s),a=n.enter("headingAtx"),c=n.enter("phrasing");o.move(i+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
133
|
+
`,...o.current()});return/^[\t ]/.test(u)&&(u=mu(u.charCodeAt(0))+u.slice(1)),u=u?i+" "+u:i,n.options.closeAtx&&(u+=" "+i),c(),a(),u}OM.peek=AK;function OM(e){return e.value||""}function AK(){return"<"}LM.peek=TK;function LM(e,t,n,r){const s=Sx(n),o=s==='"'?"Quote":"Apostrophe",i=n.enter("image");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(a=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),a(),e.title&&(a=n.enter(`title${o}`),u+=c.move(" "+s),u+=c.move(n.safe(e.title,{before:u,after:s,...c.current()})),u+=c.move(s),a()),u+=c.move(")"),i(),u}function TK(){return"!"}$M.peek=MK;function $M(e,t,n,r){const s=e.referenceType,o=n.enter("imageReference");let i=n.enter("label");const a=n.createTracker(r);let c=a.move("![");const u=n.safe(e.alt,{before:c,after:"]",...a.current()});c+=a.move(u+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const h=n.safe(n.associationId(e),{before:c,after:"]",...a.current()});return i(),n.stack=d,o(),s==="full"||!u||u!==h?c+=a.move(h+"]"):s==="shortcut"?c=c.slice(0,-1):c+=a.move("]"),c}function MK(){return"!"}PM.peek=RK;function PM(e,t,n){let r=e.value||"",s="`",o=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const i=n.unsafe[o],a=n.compilePattern(i);let c;if(i.atBreak)for(;c=a.exec(r);){let u=c.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(c.index+1)}}return s+r+s}function RK(){return"`"}function zM(e,t){const n=ux(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}FM.peek=IK;function FM(e,t,n,r){const s=Sx(n),o=s==='"'?"Quote":"Apostrophe",i=n.createTracker(r);let a,c;if(zM(e,n)){const d=n.stack;n.stack=[],a=n.enter("autolink");let h=i.move("<");return h+=i.move(n.containerPhrasing(e,{before:h,after:">",...i.current()})),h+=i.move(">"),a(),n.stack=d,h}a=n.enter("link"),c=n.enter("label");let u=i.move("[");return u+=i.move(n.containerPhrasing(e,{before:u,after:"](",...i.current()})),u+=i.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=i.move("<"),u+=i.move(n.safe(e.url,{before:u,after:">",...i.current()})),u+=i.move(">")):(c=n.enter("destinationRaw"),u+=i.move(n.safe(e.url,{before:u,after:e.title?" ":")",...i.current()}))),c(),e.title&&(c=n.enter(`title${o}`),u+=i.move(" "+s),u+=i.move(n.safe(e.title,{before:u,after:s,...i.current()})),u+=i.move(s),c()),u+=i.move(")"),a(),u}function IK(e,t,n){return zM(e,n)?"<":"["}BM.peek=DK;function BM(e,t,n,r){const s=e.referenceType,o=n.enter("linkReference");let i=n.enter("label");const a=n.createTracker(r);let c=a.move("[");const u=n.containerPhrasing(e,{before:c,after:"]",...a.current()});c+=a.move(u+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const h=n.safe(n.associationId(e),{before:c,after:"]",...a.current()});return i(),n.stack=d,o(),s==="full"||!u||u!==h?c+=a.move(h+"]"):s==="shortcut"?c=c.slice(0,-1):c+=a.move("]"),c}function DK(){return"["}function jx(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function OK(e){const t=jx(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function LK(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function _M(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function $K(e,t,n,r){const s=n.enter("list"),o=n.bulletCurrent;let i=e.ordered?LK(n):jx(n);const a=e.ordered?i==="."?")":".":OK(n);let c=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),_M(n)===i&&d){let h=-1;for(;++h<e.children.length;){const f=e.children[h];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(i=a),n.bulletCurrent=i;const u=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=o,s(),u}function PK(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function zK(e,t,n,r){const s=PK(n);let o=n.bulletCurrent||jx(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let i=o.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const a=n.createTracker(r);a.move(o+" ".repeat(i-o.length)),a.shift(i);const c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,a.current()),d);return c(),u;function d(h,f,p){return f?(p?"":" ".repeat(i))+h:(p?o:o+" ".repeat(i-o.length))+h}}function FK(e,t,n,r){const s=n.enter("paragraph"),o=n.enter("phrasing"),i=n.containerPhrasing(e,r);return o(),s(),i}const BK=bp(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function _K(e,t,n,r){return(e.children.some(function(i){return BK(i)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function WK(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}WM.peek=HK;function WM(e,t,n,r){const s=WK(n),o=n.enter("strong"),i=n.createTracker(r),a=i.move(s+s);let c=i.move(n.containerPhrasing(e,{after:s,before:a,...i.current()}));const u=c.charCodeAt(0),d=tf(r.before.charCodeAt(r.before.length-1),u,s);d.inside&&(c=mu(u)+c.slice(1));const h=c.charCodeAt(c.length-1),f=tf(r.after.charCodeAt(0),h,s);f.inside&&(c=c.slice(0,-1)+mu(h));const p=i.move(s+s);return o(),n.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},a+c+p}function HK(e,t,n){return n.options.strong||"*"}function UK(e,t,n,r){return n.safe(e.value,r)}function KK(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function VK(e,t,n){const r=(_M(n)+(n.options.ruleSpaces?" ":"")).repeat(KK(n));return n.options.ruleSpaces?r.slice(0,-1):r}const HM={blockquote:mK,break:rj,code:kK,definition:SK,emphasis:DM,hardBreak:rj,heading:EK,html:OM,image:LM,imageReference:$M,inlineCode:PM,link:FM,linkReference:BM,list:$K,listItem:zK,paragraph:FK,root:_K,strong:WM,text:UK,thematicBreak:VK};function qK(){return{enter:{table:YK,tableData:sj,tableHeader:sj,tableRow:JK},exit:{codeText:XK,table:GK,tableData:ug,tableHeader:ug,tableRow:ug}}}function YK(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function GK(e){this.exit(e),this.data.inTable=void 0}function JK(e){this.enter({type:"tableRow",children:[]},e)}function ug(e){this.exit(e)}function sj(e){this.enter({type:"tableCell",children:[]},e)}function XK(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,QK));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function QK(e,t){return t==="|"?t:e}function ZK(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,s=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
134
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:i,tableCell:c,tableRow:a}};function i(p,m,w,b){return u(d(p,w,b),p.align)}function a(p,m,w,b){const x=h(p,w,b),v=u([x]);return v.slice(0,v.indexOf(`
|
|
135
|
+
`))}function c(p,m,w,b){const x=w.enter("tableCell"),v=w.enter("phrasing"),S=w.containerPhrasing(p,{...b,before:o,after:o});return v(),x(),S}function u(p,m){return fK(p,{align:m,alignDelimiters:r,padding:n,stringLength:s})}function d(p,m,w){const b=p.children;let x=-1;const v=[],S=m.enter("table");for(;++x<b.length;)v[x]=h(b[x],m,w);return S(),v}function h(p,m,w){const b=p.children;let x=-1;const v=[],S=m.enter("tableRow");for(;++x<b.length;)v[x]=c(b[x],p,m,w);return S(),v}function f(p,m,w){let b=HM.inlineCode(p,m,w);return w.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function eV(){return{exit:{taskListCheckValueChecked:oj,taskListCheckValueUnchecked:oj,paragraph:nV}}}function tV(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:rV}}}function oj(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function nV(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=t.children;let o=-1,i;for(;++o<s.length;){const a=s[o];if(a.type==="paragraph"){i=a;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function rV(e,t,n,r){const s=e.children[0],o=typeof e.checked=="boolean"&&s&&s.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);o&&a.move(i);let c=HM.listItem(e,t,n,{...r,...a.current()});return o&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(d){return d+i}}function sV(){return[$U(),rK(),aK(),qK(),eV()]}function oV(e){return{extensions:[PU(),sK(e),lK(),ZK(e),tV()]}}const iV={tokenize:hV,partial:!0},UM={tokenize:fV,partial:!0},KM={tokenize:pV,partial:!0},VM={tokenize:mV,partial:!0},aV={tokenize:gV,partial:!0},qM={name:"wwwAutolink",tokenize:uV,previous:GM},YM={name:"protocolAutolink",tokenize:dV,previous:JM},Io={name:"emailAutolink",tokenize:cV,previous:XM},Vs={};function lV(){return{text:Vs}}let Fi=48;for(;Fi<123;)Vs[Fi]=Io,Fi++,Fi===58?Fi=65:Fi===91&&(Fi=97);Vs[43]=Io;Vs[45]=Io;Vs[46]=Io;Vs[95]=Io;Vs[72]=[Io,YM];Vs[104]=[Io,YM];Vs[87]=[Io,qM];Vs[119]=[Io,qM];function cV(e,t,n){const r=this;let s,o;return i;function i(h){return!fw(h)||!XM.call(r,r.previous)||Cx(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(h))}function a(h){return fw(h)?(e.consume(h),a):h===64?(e.consume(h),c):n(h)}function c(h){return h===46?e.check(aV,d,u)(h):h===45||h===95||_n(h)?(o=!0,e.consume(h),c):d(h)}function u(h){return e.consume(h),s=!0,c}function d(h){return o&&s&&or(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function uV(e,t,n){const r=this;return s;function s(i){return i!==87&&i!==119||!GM.call(r,r.previous)||Cx(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(iV,e.attempt(UM,e.attempt(KM,o),n),n)(i))}function o(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function dV(e,t,n){const r=this;let s="",o=!1;return i;function i(h){return(h===72||h===104)&&JM.call(r,r.previous)&&!Cx(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(h),e.consume(h),a):n(h)}function a(h){if(or(h)&&s.length<5)return s+=String.fromCodePoint(h),e.consume(h),a;if(h===58){const f=s.toLowerCase();if(f==="http"||f==="https")return e.consume(h),c}return n(h)}function c(h){return h===47?(e.consume(h),o?u:(o=!0,c)):n(h)}function u(h){return h===null||Gh(h)||It(h)||va(h)||gp(h)?n(h):e.attempt(UM,e.attempt(KM,d),n)(h)}function d(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function hV(e,t,n){let r=0;return s;function s(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),s):i===46&&r===3?(e.consume(i),o):n(i)}function o(i){return i===null?n(i):t(i)}}function fV(e,t,n){let r,s,o;return i;function i(u){return u===46||u===95?e.check(VM,c,a)(u):u===null||It(u)||va(u)||u!==45&&gp(u)?c(u):(o=!0,e.consume(u),i)}function a(u){return u===95?r=!0:(s=r,r=void 0),e.consume(u),i}function c(u){return s||r||!o?n(u):t(u)}}function pV(e,t){let n=0,r=0;return s;function s(i){return i===40?(n++,e.consume(i),s):i===41&&r<n?o(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(VM,t,o)(i):i===null||It(i)||va(i)?t(i):(e.consume(i),s)}function o(i){return i===41&&r++,e.consume(i),s}}function mV(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),o):a===93?(e.consume(a),s):a===60||a===null||It(a)||va(a)?t(a):n(a)}function s(a){return a===null||a===40||a===91||It(a)||va(a)?t(a):r(a)}function o(a){return or(a)?i(a):n(a)}function i(a){return a===59?(e.consume(a),r):or(a)?(e.consume(a),i):n(a)}}function gV(e,t,n){return r;function r(o){return e.consume(o),s}function s(o){return _n(o)?n(o):t(o)}}function GM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||It(e)}function JM(e){return!or(e)}function XM(e){return!(e===47||fw(e))}function fw(e){return e===43||e===45||e===46||e===95||_n(e)}function Cx(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const yV={tokenize:CV,partial:!0};function wV(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:vV,continuation:{tokenize:SV},exit:jV}},text:{91:{name:"gfmFootnoteCall",tokenize:kV},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:bV,resolveTo:xV}}}}function bV(e,t,n){const r=this;let s=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;s--;){const c=r.events[s][1];if(c.type==="labelImage"){i=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return a;function a(c){if(!i||!i._balanced)return n(c);const u=ys(r.sliceSerialize({start:i.end,end:r.now()}));return u.codePointAt(0)!==94||!o.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function xV(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function kV(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,i;return a;function a(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),c}function c(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(h){if(o>999||h===93&&!i||h===null||h===91||It(h))return n(h);if(h===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return s.includes(ys(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return It(h)||(i=!0),o++,e.consume(h),h===92?d:u}function d(h){return h===91||h===92||h===93?(e.consume(h),o++,u):u(h)}}function vV(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,i=0,a;return c;function c(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(m)}function d(m){if(i>999||m===93&&!a||m===null||m===91||It(m))return n(m);if(m===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return o=ys(r.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return It(m)||(a=!0),i++,e.consume(m),m===92?h:d}function h(m){return m===91||m===92||m===93?(e.consume(m),i++,d):d(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),s.includes(o)||s.push(o),kt(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function SV(e,t,n){return e.check(Fu,t,e.attempt(yV,t,n))}function jV(e){e.exit("gfmFootnoteDefinition")}function CV(e,t,n){const r=this;return kt(e,s,"gfmFootnoteDefinitionIndent",5);function s(o){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(o):n(o)}}function NV(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:s};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function s(i,a){let c=-1;for(;++c<i.length;)if(i[c][0]==="enter"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._close){let u=c;for(;u--;)if(i[u][0]==="exit"&&i[u][1].type==="strikethroughSequenceTemporary"&&i[u][1]._open&&i[c][1].end.offset-i[c][1].start.offset===i[u][1].end.offset-i[u][1].start.offset){i[c][1].type="strikethroughSequence",i[u][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},i[u][1].start),end:Object.assign({},i[c][1].end)},h={type:"strikethroughText",start:Object.assign({},i[u][1].end),end:Object.assign({},i[c][1].start)},f=[["enter",d,a],["enter",i[u][1],a],["exit",i[u][1],a],["enter",h,a]],p=a.parser.constructs.insideSpan.null;p&&$r(f,f.length,0,yp(p,i.slice(u+1,c),a)),$r(f,f.length,0,[["exit",h,a],["enter",i[c][1],a],["exit",i[c][1],a],["exit",d,a]]),$r(i,u-1,c-u+3,f),c=u+f.length-2;break}}for(c=-1;++c<i.length;)i[c][1].type==="strikethroughSequenceTemporary"&&(i[c][1].type="data");return i}function o(i,a,c){const u=this.previous,d=this.events;let h=0;return f;function f(m){return u===126&&d[d.length-1][1].type!=="characterEscape"?c(m):(i.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const w=Il(u);if(m===126)return h>1?c(m):(i.consume(m),h++,p);if(h<2&&!n)return c(m);const b=i.exit("strikethroughSequenceTemporary"),x=Il(m);return b._open=!x||x===2&&!!w,b._close=!w||w===2&&!!x,a(m)}}}class EV{constructor(){this.map=[]}add(t,n,r){AV(this,t,n,r)}consume(t){if(this.map.sort(function(o,i){return o[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let s=r.pop();for(;s;){for(const o of s)t.push(o);s=r.pop()}this.map.length=0}}function AV(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function TV(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function MV(){return{flow:{null:{name:"table",tokenize:RV,resolveAll:IV}}}}function RV(e,t,n){const r=this;let s=0,o=0,i;return a;function a(L){let H=r.events.length-1;for(;H>-1;){const se=r.events[H][1].type;if(se==="lineEnding"||se==="linePrefix")H--;else break}const _=H>-1?r.events[H][1].type:null,Y=_==="tableHead"||_==="tableRow"?N:c;return Y===N&&r.parser.lazy[r.now().line]?n(L):Y(L)}function c(L){return e.enter("tableHead"),e.enter("tableRow"),u(L)}function u(L){return L===124||(i=!0,o+=1),d(L)}function d(L){return L===null?n(L):nt(L)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),p):n(L):yt(L)?kt(e,d,"whitespace")(L):(o+=1,i&&(i=!1,s+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),i=!0,d):(e.enter("data"),h(L)))}function h(L){return L===null||L===124||It(L)?(e.exit("data"),d(L)):(e.consume(L),L===92?f:h)}function f(L){return L===92||L===124?(e.consume(L),h):h(L)}function p(L){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(L):(e.enter("tableDelimiterRow"),i=!1,yt(L)?kt(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):m(L))}function m(L){return L===45||L===58?b(L):L===124?(i=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),w):O(L)}function w(L){return yt(L)?kt(e,b,"whitespace")(L):b(L)}function b(L){return L===58?(o+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),x):L===45?(o+=1,x(L)):L===null||nt(L)?C(L):O(L)}function x(L){return L===45?(e.enter("tableDelimiterFiller"),v(L)):O(L)}function v(L){return L===45?(e.consume(L),v):L===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),S):(e.exit("tableDelimiterFiller"),S(L))}function S(L){return yt(L)?kt(e,C,"whitespace")(L):C(L)}function C(L){return L===124?m(L):L===null||nt(L)?!i||s!==o?O(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(L)):O(L)}function O(L){return n(L)}function N(L){return e.enter("tableRow"),P(L)}function P(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),P):L===null||nt(L)?(e.exit("tableRow"),t(L)):yt(L)?kt(e,P,"whitespace")(L):(e.enter("data"),M(L))}function M(L){return L===null||L===124||It(L)?(e.exit("data"),P(L)):(e.consume(L),L===92?R:M)}function R(L){return L===92||L===124?(e.consume(L),M):M(L)}}function IV(e,t){let n=-1,r=!0,s=0,o=[0,0,0,0],i=[0,0,0,0],a=!1,c=0,u,d,h;const f=new EV;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,c!==0&&(ij(f,t,c,u,d),d=void 0,c=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,h=void 0,o=[0,0,0,0],i=[0,n+1,0,0],a&&(a=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",d,t]])),s=m.type==="tableDelimiterRow"?2:d?3:1):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(o[1]!==0&&(i[0]=i[1],h=Dd(f,t,o,s,void 0,h),o=[0,0,0,0]),i[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(i[0]=i[1],h=Dd(f,t,o,s,void 0,h)),o=i,i=[o[1],n,0,0])):m.type==="tableHead"?(a=!0,c=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(c=n,o[1]!==0?(i[0]=i[1],h=Dd(f,t,o,s,n,h)):i[1]!==0&&(h=Dd(f,t,i,s,n,h)),s=0):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&ij(f,t,c,u,d),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=TV(t.events,n))}return e}function Dd(e,t,n,r,s,o){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(o.end=Object.assign({},dl(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const c=dl(t.events,n[1]);if(o={type:i,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const u=dl(t.events,n[2]),d=dl(t.events,n[3]),h={type:a,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",h,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,w=n[3]-n[2]-1;e.add(m,w,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return s!==void 0&&(o.end=Object.assign({},dl(t.events,s)),e.add(s,0,[["exit",o,t]]),o=void 0),o}function ij(e,t,n,r,s){const o=[],i=dl(t.events,n);s&&(s.end=Object.assign({},i),o.push(["exit",s,t])),r.end=Object.assign({},i),o.push(["exit",r,t]),e.add(n+1,0,o)}function dl(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const DV={name:"tasklistCheck",tokenize:LV};function OV(){return{text:{91:DV}}}function LV(e,t,n){const r=this;return s;function s(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),o)}function o(c){return It(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),i):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),i):n(c)}function i(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(c)}function a(c){return nt(c)?t(c):yt(c)?e.check({tokenize:$V},t,n)(c):n(c)}}function $V(e,t,n){return kt(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function PV(e){return XT([lV(),wV(),NV(e),MV(),OV()])}const zV={};function Cl(e){const t=this,n=e||zV,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(PV(n)),o.push(sV()),i.push(oV(n))}const fa=["default","acceptEdits","plan","auto","dontAsk","bypassPermissions"],sa={default:"Manual",acceptEdits:"Accept edits",plan:"Plan",auto:"Auto",dontAsk:"Don't Ask",bypassPermissions:"Bypass Permissions",custom:"Custom"},FV={default:"manual mode on",acceptEdits:"accept edits on",plan:"plan mode on",auto:"auto mode on",dontAsk:"don't ask on",bypassPermissions:"bypass permissions on",custom:"set by hand"},nf={default:"Runs without asking: reads only.",acceptEdits:"Runs without asking: reads, file edits, and common filesystem commands like mkdir, mv and cp.",plan:"Runs without asking: reads, plus commands the classifier approves when auto mode is available.",auto:"Runs without asking: everything, with background safety checks.",dontAsk:"Runs without asking: only pre-approved tools. Nothing else is put in front of you, so nothing waits.",bypassPermissions:"Runs without asking: everything.",custom:"Set by hand in zero.config.json. The screen leaves it exactly as it found it."},pw="A mode is only the starting point. Your own rules sit on top of it: an allow rule can let something through without asking, and your deny rules still apply. A few dangerous actions are never auto-approved, whatever you pick.",BV={default:"runs reads only",acceptEdits:"runs reads, edits and everyday file commands",plan:"runs reads, plans and approved commands",auto:"runs everything, with safety checks",dontAsk:"runs what is already approved, and never waits",bypassPermissions:"runs everything",custom:"set by hand"},mw={default:["manual","default"],acceptEdits:["accept-edits","acceptedits","accept","edits"],plan:["plan"],auto:["auto"],dontAsk:["dont-ask","dontask","deny"],bypassPermissions:["bypass-permissions","bypasspermissions","bypass","yolo"],custom:[]},_V={default:"/manual",acceptEdits:"/accept-edits",plan:"/plan",auto:"/auto",dontAsk:"/dont-ask",bypassPermissions:"/bypass-permissions",custom:"/custom"},WV="What this message runs without asking";function aj(e){if(!e.startsWith("/"))return null;const t=e.slice(1);return/\s/.test(t)?null:t.toLowerCase()}function HV(e){if(e===null)return[];if(e==="")return[...fa];const t=fa.filter(r=>{var s;return(s=mw[r][0])==null?void 0:s.startsWith(e)}),n=fa.filter(r=>!t.includes(r)&&mw[r].some(s=>s.startsWith(e)));return[...t,...n]}function UV(e){return e?fa.find(t=>mw[t].includes(e))??null:null}const dg=["default","acceptEdits","plan","auto"];function KV(e){if(!e)return"default";const t=dg.indexOf(e);return t<0?"default":dg[(t+1)%dg.length]}const VV="/clear",qV="whatever this project is already set to",QM=["clear","reset","project"];function YV(e,t){const n=HV(e);return!t||e===null?n:e===""?[...n,null]:QM.some(r=>r.startsWith(e))?[...n,null]:n}function GV(e){return!!e&&QM.includes(e)}function JV(e){return e.kind==="mode"?`mode:${e.mode??"clear"}`:e.kind==="codexMode"?`codex:${e.mode??"clear"}`:`cmd:${e.cmd.name}`}function XV(e,t,n,r=[]){if(e===null)return[];const s=ZM(n,r).filter(a=>[a.name,...a.aliases].some(c=>c.startsWith(e.toLowerCase())));if(!n)return[...o2(e,t).map(c=>({kind:"codexMode",mode:c})),...s.map(c=>({kind:"command",cmd:c}))];const o=YV(e,t).map(a=>({kind:"mode",mode:a})),i=s.map(a=>({kind:"command",cmd:a}));return[...o,...i]}function ZM(e,t){return[...e?t.filter(r=>!lw("claude-code").some(s=>s.name===r||s.aliases.includes(r))).map(r=>({name:r,description:eR,menuDescription:null,whole:!0,argumentHint:"[arguments]",aliases:[]})):[],...lw(e?"claude-code":"codex")]}const eR="Run this Claude Code command";function QV(e){return e.kind==="command"}function ZV(e,t,n){const r=e.match(/^\/([a-z][a-z0-9:_-]*)\s/i);if(!r)return null;const s=r[1].toLowerCase();return ZM(t,n).find(o=>o.name===s||o.aliases.includes(s))??null}function e8(e){var n;if(e.description===eR)return"what it should do, then ⌘↵";const t=(n=e.argumentHint)==null?void 0:n.replace(/^[<[]|[>\]]$/g,"");return t?`${t}, then ⌘↵`:"⌘↵ to run"}function t8(e){return e.kind==="command"?{typed:`/${e.cmd.name}`,says:lz(e.cmd)}:e.mode===null?{typed:VV,says:qV}:e.kind==="codexMode"?{typed:Lb[e.mode],says:s2[e.mode]}:{typed:_V[e.mode],says:BV[e.mode]}}function n8(e){if(typeof e!="string")return null;const t=e.trim();return/^\/compact(?:\s|$)/i.test(t)?{name:"compact",valid:/^\/compact$/i.test(t)}:null}const gw=Object.freeze({running:"Compacting this conversation…",done:"Conversation compacted. You can continue this task.",failed:"Couldn’t compact this conversation. Try again.",busy:"Wait for the current response to finish and pause any active goal, then run /compact.",unavailable:"Compaction isn’t available with this Codex version.",missing:"This task doesn’t have a Codex conversation to compact yet.",invalid:"Run /compact on its own. Your draft has been kept."}),gu=new Set;async function tR(e){let t;try{t=await q.compact(e)}catch{t={state:"failed",at:Date.now()}}for(const n of gu)n(e,t);return t}async function r8(e,t){let n;for(const r of gu)r(e,{state:"pending",text:"Running command…",at:Date.now()});try{n=await q.command({...e,text:t})}catch{n={state:"failed",text:"The command failed. Your draft has been kept.",at:Date.now()}}for(const r of gu)r(e,n.state==="copy"?{...n,text:"Response ready to copy."}:n);return n}function s8({item:e,engine:t="codex"}){const[n,r]=g.useState(null);return g.useEffect(()=>{let s=!1,o;const i=(c,u)=>{c.id!==e.id||c.product!==e.product||s||(clearTimeout(o),r(u),u.state==="running"&&(o=setTimeout(a,500)))},a=async()=>{try{const c=await q.compactionStatus(e);c&&i(e,c)}catch{s||i(e,{state:"failed",at:Date.now()})}};return r(null),gu.add(i),a(),()=>{s=!0,clearTimeout(o),gu.delete(i)}},[e.product,e.id]),!n||n.name==="remote-control"&&n.state==="done"||n.state==="forward"?null:l.jsx("div",{className:"thread",children:l.jsxs("div",{className:"thread-block",role:n.state==="failed"?"alert":"status","aria-live":"polite",children:[l.jsx("div",{className:"thread-head",children:n.name?`/${n.name}`:t==="codex"?"Codex":"Claude Code"}),l.jsx("p",{style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:n.text??gw[n.state]??gw.failed}),n.state==="failed"&&!n.text&&l.jsx("button",{type:"button",className:"compose-word",onClick:()=>void tR(e),children:"Try again"})]})})}const yw=e=>e&&e[0].toUpperCase()+e.slice(1);function nR(e,t="Starts now"){return e.repeat?yw(To(e.repeat)):e.runAt?yw(o8(e.runAt)):t}function o8(e,t=Date.now()){const n=Math.round((e-t)/6e4);if(n<=0)return"Starts now";if(n<90)return`Starts in ${n} minutes`;const r=new Date(e),s=r.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}).toLowerCase().replace(/\s/g,"");return new Date(t).toDateString()===r.toDateString()?`Starts at ${s}`:`Starts ${r.toLocaleDateString(void 0,{weekday:"long"})} at ${s}`}const fh=e=>new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}).toUpperCase(),rR=e=>new Date(e).toLocaleString(void 0,{weekday:"short",hour:"numeric",minute:"2-digit"}).toUpperCase();function i8(e=Date.now()){const t=[{label:"Now",ts:0,hint:""},{label:"In 30 minutes",ts:e+18e5,hint:fh(e+18e5)},{label:"In 4 hours",ts:e+144e5,hint:fh(e+144e5)}],n=new Date(e);n.setHours(18,0,0,0),n.getTime()>e&&t.push({label:"This evening",ts:n.getTime(),hint:fh(n.getTime())});const r=new Date(e+864e5);return r.setHours(8,0,0,0),t.push({label:"Tomorrow",ts:r.getTime(),hint:rR(r.getTime())}),t}function sR(e=Date.now()){const t=new Date(e).getDay(),n=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t];return[{label:"Once",rule:null},{label:"Every morning at 8:00am",rule:{every:"day",at:"08:00"}},{label:"Every weekday at 9:00am",rule:{every:"weekday",at:"09:00"}},{label:`Every ${n} at 9:00am`,rule:{every:"week",on:t,at:"09:00"}}]}function a8(e,t=Date.now()){const n=(e??"").trim();if(!n)return null;const r=MA(n);if(r&&"rule"in r)return{runAt:0,repeat:r.rule};const s=ap(n,t);return s?{runAt:s.ts,repeat:null}:null}function l8(e,t=Date.now()){return e.repeat?To(e.repeat):e.runAt?new Date(t).toDateString()===new Date(e.runAt).toDateString()?fh(e.runAt):rR(e.runAt):"now"}function oR(e,t){const n=(t??"").trim().toLowerCase().replace(/\s+/g," ");if(!n)return!0;const r=e.toLowerCase();return r.startsWith(n)||r.split(" ").some((s,o)=>o>0&&s.startsWith(n))}function iR(e,t=Date.now()){const n=(e??"").trim().replace(/\s+/g," ");if(!n)return null;const r=a8(n,t);return r?{label:yw(n),hint:l8(r,t),value:r}:null}function aR(e,t){return t.some(n=>n.label.toLowerCase()===e.label.toLowerCase()||!!n.ts&&!!e.value.runAt&&Math.round(n.ts/6e4)===Math.round(e.value.runAt/6e4)||!!n.value.repeat&&!!e.value.repeat&&To(n.value.repeat)===To(e.value.repeat))}function lj(e,t){return e.repeat||t.repeat?!!e.repeat&&!!t.repeat&&To(e.repeat)===To(t.repeat):!0}function c8(e,t=Date.now()){const n=i8(t).filter(s=>oR(s.label,e)).map(s=>({label:s.label,hint:s.hint,ts:s.ts,value:{runAt:s.ts,repeat:null}})),r=iR(e,t);return!r||aR(r,n)?n:[{label:r.label,hint:r.hint,ts:null,value:r.value,typed:!0},...n]}function u8(e,t=Date.now(),n=!1){const r=sR(t).filter(o=>oR(o.label,e)).map(o=>({label:o.label,hint:"",ts:null,value:{runAt:0,repeat:o.rule}})),s=iR(e,t);return!s||aR(s,r)||n&&!s.value.repeat?r:[{label:s.label,hint:s.hint,ts:null,value:s.value,typed:!0},...r]}function d8({value:e,onChange:t,note:n,only:r,empty:s,onOpenChange:o}){const[i,a]=g.useState(!1);g.useEffect(()=>{o==null||o(i)},[i]);const c=r==="repeat",[u,d]=g.useState(c?"repeat":"start"),[h,f]=g.useState(""),p=g.useRef(null),m=g.useRef(null);hp(p,i,[u,h]),g.useEffect(()=>{if(!i)return;f(""),d(c||e.repeat?"repeat":"start");const M=R=>{var L;(L=p.current)!=null&&L.contains(R.target)||a(!1)};return document.addEventListener("pointerdown",M),()=>document.removeEventListener("pointerdown",M)},[i]),g.useEffect(()=>{var M;i&&((M=m.current)==null||M.focus())},[i,u]);const w=M=>{t(M),a(!1)},b=!!n,x=M=>!!M.repeat&&b,v=u==="start"?c8(h):u8(h,Date.now(),c),S=!!h.trim()&&!v.length,C=()=>{if(!h.trim())return;const M=v.find(R=>!x(R.value));M&&w(M.value)},O=S&&l.jsx("span",{className:"when-row empty",children:l.jsx("span",{className:"when-row-label",children:c?"not a repeat":"not a time"})}),N=M=>l.jsxs("button",{type:"button",className:`when-row ${M.typed?"typed":""} ${!M.typed&&(M.ts===null?lj(M.value,e):!e.repeat&&e.runAt===M.ts)?"on":""} ${x(M.value)?"off":""}`,disabled:x(M.value),onClick:()=>w(M.value),children:[l.jsx("span",{className:"when-row-label",children:M.label}),l.jsx("span",{className:"when-row-hint",children:M.hint||(lj(M.value,e)&&M.value.repeat?"✓":"")})]},M.typed?"typed":M.label),P=M=>l.jsx("span",{className:"when-type-row",children:l.jsx("input",{ref:m,className:"when-type",value:h,placeholder:M,onChange:R=>f(R.target.value),onKeyDown:R=>{R.stopPropagation(),R.key==="Escape"&&(R.preventDefault(),a(!1)),R.key==="Enter"&&(R.preventDefault(),C())}})});return l.jsxs("span",{className:"when-wrap",ref:p,children:[i&&l.jsx("span",{className:"when-menu",role:"dialog","aria-label":c?"How often this comes back":"When this runs",children:u==="start"?l.jsxs(l.Fragment,{children:[v.map(N),O,P("or type: in three hours, 9am, tomorrow"),l.jsx("span",{className:"when-sep"}),l.jsxs("button",{type:"button",className:"when-door",onClick:()=>{d("repeat"),f("")},children:[l.jsx("span",{className:"when-door-label",children:"Repeats…"}),l.jsx("span",{className:"when-door-arrow",children:"›"})]})]}):l.jsxs(l.Fragment,{children:[!c&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:"when-door back",onClick:()=>{d("start"),f("")},children:[l.jsx("span",{className:"when-door-arrow",children:"‹"}),l.jsx("span",{className:"when-door-label",children:"Starts"})]}),l.jsx("span",{className:"when-sep"})]}),n&&l.jsx("span",{className:"when-note",children:n}),v.map(N),O,P("or type: every friday at 5pm")]})}),l.jsx("button",{type:"button",className:`compose-word ${e.runAt||e.repeat?"set":""} ${i?"open":""}`,title:c?"How often this comes back":"When this runs","aria-haspopup":"dialog","aria-expanded":i,onClick:()=>a(M=>!M),children:nR(e,s)})]})}const Nx=Object.freeze([{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra"},{id:"max",label:"Max"}]);function lR(e){return typeof e=="string"&&Nx.some(t=>t.id===e)}function vp(e){return typeof e=="string"&&/^[a-z][a-z0-9]{0,23}$/.test(e)}function h8(e){const t=Nx.find(n=>n.id===e);return t?t.label:vp(e)?e.charAt(0).toUpperCase()+e.slice(1):null}const Ex=Nx.map(e=>({id:e.id,label:e.label}));function _u(e,t,{codexModels:n=[],codexDefault:r=null}={}){if(e!=="codex")return Ex;const s=t??Qr(e,r);if(s===xa)return[];const o=n.find(i=>i.id===s);return((o==null?void 0:o.levels)??[]).filter(i=>vp(i)).map(i=>({id:i,label:h8(i)??i}))}function Ax(e,t=Ex){return!!e&&t.some(n=>n.id===e)}function Sp(e,t,{codexModels:n=[],codexDefault:r=null}={}){var o,i;const s=t??Qr(e,r);return e==="codex"?s===xa?null:((o=n.find(a=>a.id===s))==null?void 0:o.defaultLevel)??null:((i=Vl().find(a=>a.id===s))==null?void 0:i.defaultLevel)??null}function cR(e,t,n){return Ax(e,t)?e:n&&t.some(r=>r.id===n)?n:null}function Tx(e,t=Ex){var n;return Ax(e,t)?((n=t.find(r=>r.id===e))==null?void 0:n.label)??null:null}const cj="zero.lastEffort";function ww(e=null){return e==="codex"?`${cj}.codex`:cj}function bw(e=globalThis.localStorage,t=null){try{const n=e==null?void 0:e.getItem(ww(t));return(t==="codex"?vp(n):lR(n))?n:null}catch{return null}}function f8(e,t=globalThis.localStorage,n=null){try{(n==="codex"?vp(e):lR(e))?t==null||t.setItem(ww(n),e):t==null||t.removeItem(ww(n))}catch{}}const uR=g.createContext({updates:{},start:()=>{}}),p8=()=>g.useContext(uR);function m8({children:e}){const[t,n]=g.useState({}),[r,s]=g.useState(null),[o,i]=g.useState(!1),[a,c]=g.useState(0),u=g.useRef(new Set),d=g.useRef(0),h=g.useRef({}),f=w=>{w!=null&&w.engine&&n(b=>({...b,[w.engine]:w}))};g.useEffect(()=>{let w=!0,b=!1;const x=async()=>{if(!b){b=!0;try{for(const S of["claude","codex"])try{const C=await q.agentUpdate(S,"check");w&&f(C)}catch{}Date.now()-d.current>36e5&&(d.current=Date.now(),await Promise.allSettled(["claude","codex"].map(S=>q.agentUpdate(S,"refresh"))),w&&window.dispatchEvent(new Event("agent-models-changed")))}finally{b=!1}}};x();const v=setInterval(x,36e5);return window.addEventListener("focus",x),()=>{w=!1,clearInterval(v),window.removeEventListener("focus",x)}},[]),g.useEffect(()=>{let w=!0;const x=setInterval(async()=>{for(const v of["claude","codex"])try{const S=await q.agentUpdate(v,"status");if(!w)continue;h.current[v]==="running"&&S.state==="current"&&window.dispatchEvent(new Event("agent-models-changed")),h.current[v]=S.state,f(S)}catch{}},Ta(1e3,sr()));return()=>{w=!1,clearInterval(x)}},[]);const p=async w=>{var b;if(s(w),((b=t[w])==null?void 0:b.state)==="running"){i(!0);return}if(!u.current.has(w)){u.current.add(w),i(!1);try{const x=await q.agentUpdate(w,"start");f(x),h.current[w]=x.state,c(v=>v+1),i(x.state==="running"),x.state==="current"&&window.dispatchEvent(new Event("agent-models-changed"))}catch(x){f({engine:w,state:"failed",message:x instanceof Error?x.message:String(x)})}finally{u.current.delete(w)}}},m=r?t[r]:null;return l.jsx(uR.Provider,{value:{updates:t,start:p},children:l.jsxs("div",{className:"agent-update-host",children:[l.jsx("div",{className:"agent-update-app",children:e}),r&&l.jsxs("section",{className:"agent-update-panel",role:"dialog","aria-label":`Update ${r==="codex"?"Codex":"Claude Code"}`,onKeyDown:w=>{w.key==="Escape"&&(w.stopPropagation(),s(null))},children:[l.jsxs("header",{className:"agent-update-heading",children:[l.jsxs("span",{children:["Update ",r==="codex"?"Codex":"Claude Code"]}),l.jsx("button",{type:"button",onClick:()=>s(null),"aria-label":"Hide update terminal",children:"×"})]}),(m==null?void 0:m.message)&&l.jsxs("div",{className:"agent-update-status",role:"status",children:[m.message," ",m.state==="failed"&&l.jsx("button",{type:"button",onClick:()=>void p(r),children:"Retry"})]}),!o&&!(m!=null&&m.message)&&l.jsx("div",{className:"agent-update-status",role:"status",children:"Checking the installed agent…"}),o&&l.jsx(xx,{product:"@agent-update",id:r,startOpen:!0,commandSession:!0},`${r}:${a}`)]})]})})}function g8({value:e,onChange:t,title:n,onOpenChange:r,engine:s=null,codexModels:o=[],codexDefault:i=null,effort:a=null,onEffortChange:c,openAtStart:u=!1}){const[d,h]=g.useState(u),{updates:f,start:p}=p8(),m=s==="codex"?"codex":"claude",w=f[m],b=["available","running","failed"].includes(w==null?void 0:w.state),[x,v]=g.useState(0),S=g.useRef(null),C=Qr(s,i),O=Ob(s,e,{codexModels:o,codexDefault:i}),N=c?_u(s,e,{codexModels:o,codexDefault:i}):[],P=cR(a,N,Sp(s,e,{codexModels:o,codexDefault:i}));g.useEffect(()=>{r==null||r(d)},[d]),hp(S,d,[O.length,N.length,b]),g.useEffect(()=>{if(!d)return;v(Math.max(0,O.findIndex(L=>L.id===(e??C))));const R=L=>{var H;(H=S.current)!=null&&H.contains(L.target)||h(!1)};return document.addEventListener("pointerdown",R),()=>document.removeEventListener("pointerdown",R)},[d,e,s]);const M=R=>{t(R===C?null:R),h(!1)};return l.jsxs("span",{className:"compose-word-wrap",ref:S,children:[d&&l.jsxs("span",{className:"prio-menu model-menu",role:"listbox","aria-label":"Model",children:[b&&l.jsxs("span",{className:"model-update-row",children:[l.jsx("span",{children:m==="codex"?"Codex":"Claude Code"}),l.jsx("button",{type:"button",title:`Update ${m==="codex"?"Codex":"Claude Code"} in the app terminal`,onClick:()=>{h(!1),p(m)},children:w.state==="running"?"Updating…":"Update now"})]}),O.map((R,L)=>l.jsx("button",{role:"option","aria-selected":R.id===(e??C),className:`prio-menu-row ${L===x?"cursor":""} ${R.id===(e??C)?"on":""}`,onPointerEnter:()=>v(L),onClick:()=>M(R.id),children:l.jsx("span",{className:"prio-menu-label",children:R.label})},R.id)),c&&N.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"model-menu-rule",role:"separator"}),l.jsx("span",{className:"effort-head",id:"effort-head",children:"Effort"}),l.jsx("span",{className:"effort-strip",role:"radiogroup","aria-labelledby":"effort-head",children:N.map(R=>l.jsx("button",{type:"button",role:"radio","aria-checked":R.id===P,className:R.id===P?"on":"",onClick:()=>c(R.id===a?null:R.id),children:R.label},R.id))})]})]}),l.jsx("button",{type:"button",className:`compose-word ${e?"set":""} ${d?"open":""}`,title:n??"Which model picks this up","aria-haspopup":"listbox","aria-expanded":d,onClick:()=>h(R=>!R),onKeyDown:R=>{if(!d){(R.key==="ArrowUp"||R.key==="ArrowDown"||R.key==="Enter"||R.key===" ")&&(R.preventDefault(),h(!0));return}R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),h(!1)),R.key==="ArrowDown"&&(R.preventDefault(),v(L=>(L+1)%O.length)),R.key==="ArrowUp"&&(R.preventDefault(),v(L=>(L-1+O.length)%O.length)),R.key==="Enter"&&(R.preventDefault(),O[x]&&M(O[x].id))},children:ql(s,e,{codexModels:o,codexDefault:i})})]})}const uj=e=>/\.(png|jpe?g|gif|webp)$/i.test(e);function y8(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(String(r.result).split(",")[1]??""),r.onerror=n,r.readAsDataURL(e)})}async function rf(e){var n,r,s,o,i,a,c,u;const t=[];for(const d of Array.from(e)){const h=((r=(n=window.zero)==null?void 0:n.pathForFile)==null?void 0:r.call(n,d))??null;if(h){const f=uj(d.name);let p=null;if(f)try{p=((i=await((o=(s=window.zero)==null?void 0:s.stageAttachment)==null?void 0:o.call(s,{name:d.name||"file",srcPath:h})))==null?void 0:i.path)??null}catch{p=null}t.push({name:d.name||"file",srcPath:p??h,image:f})}else{const f=d.name&&d.name!=="image.png"?d.name:`pasted-${Date.now()%1e5}.png`,p=d.type.startsWith("image/")||uj(f),m=await y8(d);let w=null;try{w=((u=await((c=(a=window.zero)==null?void 0:a.stageAttachment)==null?void 0:c.call(a,{name:f,dataBase64:m})))==null?void 0:u.path)??null}catch{w=null}t.push(w?{name:f,srcPath:w,image:p}:{name:f,dataBase64:m,image:p})}}return t}async function dR(e){var n;const t=[];for(const r of Array.from(((n=e.clipboardData)==null?void 0:n.items)??[]))if(r.kind==="file"){const s=r.getAsFile();s&&t.push(s)}return t.length?rf(t):[]}async function hR(e,t){var r;return!t.length||!((r=window.zero)!=null&&r.saveAttachments)?"":(await window.zero.saveAttachments({product:e,files:t.map(({name:s,dataBase64:o,srcPath:i})=>({name:s,dataBase64:o,srcPath:i}))})).map(s=>s.image?``:`[${s.name}](${s.rel})`).join(`
|
|
136
|
+
`)}const w8=`${xA}://file`;function vo(e){if(!e||!e.startsWith("/"))return e;const t=e.split("/").filter(Boolean).map(encodeURIComponent);return`${w8}/${t.join("/")}`}const dj=/^\s*([-*+•]|\d+[.)])\s/,b8=/[{}<>]|=>|&&|\|\||`|:\/\/|;\s*$|^\s*[$#>]\s|^\s*(const|let|var|function|class|def|import|export|return|if|for|while|echo|cd|npm|git|sudo)\b/,x8=/\S {2,}\S/,k8=.8,v8=40,hj=.2,S8=.4,j8=4;function fR(e){return e.split(`
|
|
137
|
+
`).filter(t=>t.trim().length>0)}function pR(e){const t=fR(e);if(t.length<2||t.filter(a=>/^[ \t]/.test(a)).length/t.length>S8||t.filter(a=>b8.test(a)).length/t.length>hj||t.filter(a=>x8.test(a)).length/t.length>hj||t.reduce((a,c)=>a+c.trim().split(/\s+/).length,0)/t.length<j8)return!1;const i=Math.max(...t.map(a=>a.length));return i<v8?!1:C8(e.split(`
|
|
138
|
+
`),i)>0}function mR(e,t,n){return!e.trim()||!t.trim()||dj.test(t)||/^[ \t]/.test(t)||dj.test(e)||/^[ \t]/.test(e)?!1:e.length>=n*k8}function C8(e,t){let n=0;for(let r=0;r<e.length-1;r+=1)mR(e[r],e[r+1],t)&&(n+=1);return n}function Mx(e){if(!pR(e))return e;const t=fR(e),n=Math.max(...t.map(i=>i.length)),r=e.split(`
|
|
139
|
+
`),s=[];let o=null;for(const i of r){if(o!==null&&s.length&&mR(o,i,n)){const a=s[s.length-1];s[s.length-1]=`${a.replace(/\s+$/,"")} ${i.trim()}`}else s.push(i);o=i}return s.join(`
|
|
140
|
+
`)}const N8=new RegExp(`^(file|${Y2.join("|")}):`,"i");function Rx(e){var r,s,o;const t=((r=e==null?void 0:e.querySelector("code"))==null?void 0:r.className)??"",n=(o=(s=/language-([\w-]+)/.exec(t))==null?void 0:s[1])==null?void 0:o.toLowerCase();return!!n&&!["text","txt","plain","markdown","md","email"].includes(n)}function E8(e){const t=(e==null?void 0:e.innerText)??"";return Rx(e)?t:Mx(t)}function A8(e){if(!e.complete||!e.naturalWidth)return null;try{const t=document.createElement("canvas");t.width=e.naturalWidth,t.height=e.naturalHeight;const n=t.getContext("2d");return n?(n.drawImage(e,0,0),t.toDataURL("image/png")):null}catch{return null}}function T8(e,t){Array.from(e.querySelectorAll("img")).forEach((r,s)=>{const o=t[s],i=o?A8(o):null;if(i){r.setAttribute("src",i),r.removeAttribute("crossorigin");return}const a=r.getAttribute("alt");r.replaceWith(a?document.createTextNode(a):document.createTextNode(""))});for(const r of Array.from(e.querySelectorAll("a"))){const s=r.getAttribute("href")??"";N8.test(s)&&r.replaceWith(document.createTextNode(r.textContent??""))}for(const r of Array.from(e.querySelectorAll("pre"))){if(Rx(r))continue;const s=r.querySelector("code")??r,o=s.textContent??"";pR(o)&&(s.textContent=Mx(o))}}function M8(e,t){var f;if(!t||!e.clipboardData)return;const n=window.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return;const r=n.getRangeAt(0);if(!t.contains(r.commonAncestorContainer))return;const s=document.createElement("div");s.appendChild(r.cloneContents());const o=Array.from(t.querySelectorAll("img")).filter(p=>r.intersectsNode(p)),i=document.createDocumentFragment();for(;s.firstChild;)i.appendChild(s.firstChild);T8(i,o);const a=document.createElement("div");a.appendChild(i),e.clipboardData.setData("text/html",a.innerHTML);const c=r.commonAncestorContainer,u=((f=c.nodeType===1?c:c.parentElement)==null?void 0:f.closest("pre"))??null,d=n.toString(),h=u&&t.contains(u)&&!Rx(u);e.clipboardData.setData("text/plain",h?Mx(d):d),e.preventDefault()}const R8=new RegExp("^(?:"+["(?:flowchart|graph)(?:\\s+(?:TB|TD|BT|RL|LR))?\\s*;?","sequenceDiagram","classDiagram(?:-v2)?","stateDiagram(?:-v2)?","erDiagram","journey","gantt","pie(?:\\s+.*)?","gitGraph(?:\\s+.*)?","mindmap","timeline","quadrantChart","requirementDiagram","C4(?:Context|Container|Component|Dynamic|Deployment)","(?:xychart|sankey|block|packet|architecture|kanban|radar)(?:-beta)?"].join("|")+")$");function I8(e,t){const n=t.replace(/^\s*\n/,"").replace(/\s+$/,"");if(!n.trim())return null;const r=e==null?void 0:e.toLowerCase();if(r==="mermaid")return n;if(r)return null;const s=n.split(`
|
|
141
|
+
`,1)[0].trim();return R8.test(s)?n:null}let fj=null,D8=0;const pj=()=>{const e=document.documentElement;return`${e.getAttribute("data-theme")}|${e.getAttribute("data-skin")}`};function Bi(e){const t=document.createElement("span");t.style.color=`var(${e})`,document.body.appendChild(t);const n=getComputedStyle(t).color;return t.remove(),n}async function O8(e){var o,i;fj??(fj=ms(()=>import("./mermaid.core-CnYzvFkz.js").then(a=>a.bA),__vite__mapDeps([0,1]),import.meta.url).then(a=>a.default));const t=await fj,n=Bi("--bg-raised"),r=getComputedStyle(document.body).fontFamily;t.initialize({startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,theme:"base",fontFamily:r,themeVariables:{darkMode:document.documentElement.getAttribute("data-theme")!=="light",fontFamily:r,fontSize:"14px",background:n,primaryColor:Bi("--bg"),primaryBorderColor:Bi("--line-strong"),primaryTextColor:Bi("--text"),secondaryColor:n,tertiaryColor:n,lineColor:Bi("--text-faint"),textColor:Bi("--text"),edgeLabelBackground:n,clusterBkg:n,clusterBorder:Bi("--line-strong")}});const s=`ab-chart-${++D8}`;try{return(await t.render(s,e)).svg}finally{(o=document.getElementById(s))==null||o.remove(),(i=document.getElementById(`d${s}`))==null||i.remove()}}function L8({source:e,fallback:t}){const[n,r]=g.useState(pj),[s,o]=g.useState(null),[i,a]=g.useState(!1),[c,u]=g.useState(!1);return g.useEffect(()=>{const d=new MutationObserver(()=>r(pj()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-skin"]}),()=>d.disconnect()},[]),g.useEffect(()=>{let d=!0;return O8(e).then(h=>{d&&(o(h),a(!1))}).catch(()=>{d&&a(!0)}),()=>{d=!1}},[e,n]),i?l.jsx(l.Fragment,{children:t}):l.jsxs("div",{className:"code-wrap diagram-wrap",children:[s?l.jsx("div",{className:"diagram",role:"img","aria-label":"Chart",dangerouslySetInnerHTML:{__html:s}}):l.jsx("div",{className:"diagram diagram-pending"}),l.jsx("button",{className:`code-copy ${c?"copied":""}`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{u(!0),setTimeout(()=>u(!1),1600)}).catch(()=>{})},children:c?"copied ✓":"copy"})]})}const Ix="png|jpe?g|gif|webp|svg|html?|pdf|md|markdown|csv|txt|json|ya?ml|sql|sh|css|jsx?|tsx?|mjs|cjs|py|rb|go|rs|toml|change",$8=new RegExp(String.raw`(?<![\w./:@-])(?:\.\/)?[\w-][\w./-]*\.(?:${Ix})\b`,"gi"),P8=new RegExp(String.raw`!?\[[^\]\n]*\]\(\s*([^)\s]+?)\s*(?:\s+"[^"]*")?\)`,"g"),z8=new RegExp(String.raw`(?<![\w.:@/-])/[\w-][\w./-]*\.(?:${Ix})\b`,"gi"),F8=/^([a-z]+:|\/|#)/i,B8=/\.(png|jpe?g|gif|webp)$/i;function yu(...e){const t=e[e.length-1],n=t&&typeof t=="object"?e.pop():null,r=String((n==null?void 0:n.dir)??"").replace(/\/+$/,""),s=[],o=new Set,i=a=>{if(!a)return;let c=a.replace(/^\.\//,"").trim();if(r&&c.startsWith(r+"/")&&(c=c.slice(r.length+1)),!c||F8.test(c)||!new RegExp(String.raw`\.(?:${Ix})$`,"i").test(c))return;const u=c.toLowerCase();o.has(u)||(o.add(u),s.push(c))};for(const a of e){if(!a)continue;const c=String(a),u=[];for(const d of c.matchAll(P8))u.push({at:d.index??0,path:d[1]});for(const d of c.matchAll($8))u.push({at:d.index??0,path:d[0]});if(r)for(const d of c.matchAll(z8))u.push({at:d.index??0,path:d[0]});u.sort((d,h)=>d.at-h.at);for(const d of u)i(d.path)}return s}function mj(e){return B8.test(String(e??""))}const _8=new RegExp("(?<![\\w./:@~-])(?:~\\/|\\/)[\\w./-]+","g"),W8=new RegExp("(?<![\\w./:@~-])[\\w-][\\w.-]*(?:\\/[\\w.-]+)*\\/(?=[\\s)`'\"\\]]|$)","g"),H8=/\.[a-z0-9]{1,8}$/i,gj=e=>e.includes("/")?e.slice(0,e.lastIndexOf("/")):"";function U8(e,t){if(!t)return[];const n=[],r=s=>{const o=String(s??"").replace(/\/+$/,"");o&&!n.includes(o)&&n.push(o)};for(const s of e)if(s){for(const o of String(s).matchAll(_8)){const i=o[0].replace(/[.,;:]+$/,""),a=Wc(i,t);if(!a)continue;const c=a.replace(/\/+$/,"");r(H8.test(c)&&!a.endsWith("/")?gj(c):c)}for(const o of String(s).matchAll(W8))r(o[0])}for(const s of yu(...e,{dir:t}))r(gj(s));return n}function K8({dir:e,repo:t,id:n,texts:r}){const s=[...e?U8(r,e).map(o=>`${e}/${o}`):[],e&&n&&`${e}/designs/${n}`,t&&n&&`${t}/.claude/worktrees/${n}`,e,e&&`${e}/designs`,e&&`${e}/attachments`,t,t&&`${t}/designs`].filter(Boolean);return[...new Set(s)]}function V8(e){const t=e;if(!t||typeof t!="object"||!Array.isArray(t.files))return null;const n=t.files.length,r=Number(t.plus??0),s=Number(t.minus??0);return!Number.isFinite(r)||!Number.isFinite(s)||n<=0||r<=0&&s<=0?null:{files:n,plus:r,minus:s}}function yj(e){return Math.abs(e).toLocaleString("en-US")}function gR(e){const t=[];return e.plus>0&&t.push({sign:"+",text:`+${yj(e.plus)}`}),e.minus>0&&t.push({sign:"−",text:`−${yj(e.minus)}`}),t}function yR(e){return e.files===1?"1 file":`${e.files} files`}function q8(e){return`${gR(e).map(t=>t.text).join(" ")} in ${yR(e)}`}const wR=/(^|\/)(designs?|demos?)\/[^?#]*\.html?$/i,Y8=/\.change$/i;function G8(e){return wR.test(String(e??"").split(/[?#]/)[0])}function J8(e){const t=String(e??"").split(/[?#]/)[0];return wR.test(t)||Y8.test(t)}function X8(e,t=null){return yu(e.result,e.note,e.body,e.answer,{dir:t}).filter(G8)}const Q8=new Set(["state.md","decisions.md","notes.md","instructions.md","memory.md","claude.md","readme.md"]);function bR(e){const t=String(e??"").split(/[?#]/)[0].split("/").pop()??"";return Q8.has(t.toLowerCase())}function wj(e,t=[],n=null){const r=i=>J8(i)&&!bR(i),s=yu(e.result,e.note,e.body,e.answer,{dir:n}).filter(r),o=new Set(s.map(i=>i.toLowerCase()));return[...s,...t.filter(i=>r(i)&&!o.has(i.toLowerCase()))]}function Z8(e){return Math.max(0,e.offsetWidth-e.clientWidth)}function e9(e){const t=e==null?void 0:e.parentElement;if(!e||!t)return()=>{};const n=()=>t.style.setProperty("--scroll-gutter",`${Z8(e)}px`);if(n(),typeof ResizeObserver>"u")return()=>{};const r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()}const ji=e=>globalThis.localStorage;function Ro(e){return`zero.draft.${e.product}:${e.id}`}function fi(e,t){return ji().getItem(Ro(e))??""}function Dl(e,t,n){const r=ji();t?r.setItem(Ro(e),t):r.removeItem(Ro(e))}function bj(e,t){const n=ji();n.removeItem(Ro(e)),n.removeItem(Hc(e))}function Hc(e){return`zero.draftimg.${e.product}:${e.id}`}function Ol(e,t){const n=ji().getItem(Hc(e));if(!n)return[];try{const r=JSON.parse(n);return Array.isArray(r)?r.filter(s=>s&&typeof s=="object"&&typeof s.name=="string"&&(s.dataBase64||s.srcPath)).map(s=>({name:s.name,dataBase64:s.dataBase64,srcPath:s.srcPath,image:!!s.image})):[]}catch{return[]}}function Dx(e,t,n){const r=ji();let s=(t??[]).slice();const o=[],i=()=>{const a=s.map(c=>!!c.dataBase64).lastIndexOf(!0);return a<0?!1:(o.unshift(s[a]),s=s.filter((c,u)=>u!==a),!0)};for(;;){if(!s.length){try{r.removeItem(Hc(e))}catch{}return{kept:s,dropped:o}}const a=JSON.stringify(s);if(a.length<=xR)try{return r.setItem(Hc(e),a),{kept:s,dropped:o}}catch{}if(!i()){try{r.removeItem(Hc(e))}catch{}return{kept:[],dropped:o}}}}function t9(e,t){return!!fi(e).trim()||Ol(e).length>0}function hg(e,t,n=[],r){const s=String(t??"").trim(),o=(n??[]).filter(i=>i&&!!i.name&&(!!i.dataBase64||!!i.srcPath));return!s&&!o.length||fi(e).trim()||Ol(e).length?!1:(s&&Dl(e,s),o.length&&Dx(e,o),!0)}function n9(e,t,n=[],r){const s=fi(e);Dl(e,[s,t.trim()].filter(Boolean).join(`
|
|
142
|
+
|
|
143
|
+
`)),Dx(e,[...Ol(e),...n]),typeof window<"u"&&window.dispatchEvent(new CustomEvent("zero:reply-restored",{detail:Ro(e)}))}const Uc="zero.draft.compose",xR=3e6,Ac={text:"",attachments:[],priority:null,when:{runAt:0,repeat:null},dropped:0},r9=e=>{if(!e||typeof e!="object")return null;const t=e,n=typeof t.name=="string"?t.name:"";if(!n)return null;const r=typeof t.dataBase64=="string"?t.dataBase64:void 0,s=typeof t.srcPath=="string"?t.srcPath:void 0;return!r&&!s?null:{name:n,...r?{dataBase64:r}:{},...s?{srcPath:s}:{},image:!!t.image}};function Ox(e){let t=null;try{t=ji(e).getItem(Uc)}catch{return{...Ac}}if(!t)return{...Ac};let n;try{n=JSON.parse(t)}catch{return{...Ac}}if(!n||typeof n!="object")return{...Ac};const r=n,s=r.when&&typeof r.when=="object"?r.when:{};return{text:typeof r.text=="string"?r.text:"",attachments:(Array.isArray(r.attachments)?r.attachments:[]).map(r9).filter(o=>!!o),priority:typeof r.priority=="string"?r.priority:null,when:{runAt:typeof s.runAt=="number"?s.runAt:0,repeat:s.repeat??null},dropped:typeof r.dropped=="number"&&r.dropped>0?r.dropped:0}}function xw(e){return!e.text.trim()&&!e.attachments.length&&!e.priority&&!e.when.runAt&&!e.when.repeat}function kR(e,t){const n=ji();if(xw(e)){try{n.removeItem(Uc)}catch{}return{...Ac}}let r=e.attachments.slice(),s=0;const o=()=>{const a={...e,attachments:r,dropped:s},c=JSON.stringify(a);if(c.length>xR)return null;try{n.setItem(Uc,c)}catch{return null}return a};for(;;){const a=o();if(a)return a;const c=r.map(u=>!!u.dataBase64).lastIndexOf(!0);if(c<0)break;r=r.filter((u,d)=>d!==c),s+=1}const i={...e,attachments:r,dropped:s};try{n.setItem(Uc,JSON.stringify(i))}catch{return i}return i}function kw(e){try{ji(e).removeItem(Uc)}catch{}}function s9(e,t){return!e||xw(e)||!xw(Ox(t))?!1:(kR(e),!0)}const vR=3;function o9(e,t=vR){const n=(e??"").split(`
|
|
144
|
+
`).map(s=>s.trim()).filter(Boolean);if(!n.length)return"";const r=n.slice(0,t).map(s=>`> ${s}`);return n.length>t&&r.push(`> …${n.length-t} more line${n.length-t===1?"":"s"}`),r.join(`
|
|
145
|
+
`)}function i9(e,t,n=vR){const r=o9(t,n);if(!r)return e;const s=e??"";return s.includes(r)?s:s.trim()?`${r}
|
|
146
|
+
|
|
147
|
+
${s}`:`${r}
|
|
148
|
+
|
|
149
|
+
`}const vw=["problem","progress","solution"],jp={waiting:"Waiting",running:"In progress",scheduled:"Scheduled",done:"Done"};function Sw(e,t){return(e==null?void 0:e.start)==="later"?"Not started":jp[t]}function wu(e,t){return e==="waiting"?t?"need":"wait":e==="running"?"run":e==="scheduled"?"sched":"done"}function xj(e){return e==="done"?[]:[{id:"done",word:jp.done,glyph:"done"}]}const jw=6e4,Cw=60*jw,fg=24*Cw;function Lx(e,t=Date.now()){const n=Math.max(0,t-e);if(n<jw)return"just now";if(n<Cw)return`${Math.floor(n/jw)} min ago`;if(n<fg){const r=Math.floor(n/Cw);return`${r} hour${r===1?"":"s"} ago`}return n<2*fg?"Yesterday":`${Math.floor(n/fg)} days ago`}const a9=e=>(e||"Someone").split(/\s+/)[0];function l9(e,{me:t,now:n=Date.now(),pending:r={}}){var i;let s=null;for(const a of vw){const c=(i=e.wrote)==null?void 0:i[a];c&&(c.source==="agent"||c.source==="founder")&&(s===null||c.ts>s)&&(s=c.ts);const u=r[a];Number.isFinite(u)&&(s===null||u>s)&&(s=u)}if(s===null)return null;const o=Lx(s,n);return o.charAt(0).toUpperCase()+o.slice(1)}const c9="A thread you cannot see";function SR(e,t,n){var r;return!e.createdBy||!t||e.createdBy===t?"You":((r=n.get(e.createdBy))==null?void 0:r.name)||"Someone"}function jR(e,t,n){return Kb(e,t,n)?$u(e,n).length?"people":"team":"private"}const Nw={team:"Team",people:"Chosen people",private:"Only you"};function u9(e,t){return e.length?e.length>2?`${e.length} people`:e.map(n=>{var r;return a9((r=t.get(n))==null?void 0:r.name)}).join(" and "):"Nobody yet"}const CR="threads.summary.open";function d9(e){try{return e.getItem(CR)!=="0"}catch{return!0}}function h9(e){var o;const t=i=>i.kind!=="work",n=new Set(e.filter(t).filter(i=>i.uid&&!i.inReplyTo).map(i=>i.uid)),r={},s=[];for(const i of e){if(t(i)&&i.inReplyTo&&n.has(i.inReplyTo)){(r[o=i.inReplyTo]??(r[o]=[])).push(i);continue}s.push(i)}return{events:s,replies:r}}const f9=3;function NR(e,t=Date.now()){const n=e.length,r=`${n} ${n===1?"reply":"replies"}`,s=[];for(let c=e.length-1;c>=0&&s.length<f9;c-=1){const u=e[c].by??"you";s.includes(u)||s.push(u)}s.reverse();const o=e.reduce((c,u)=>Math.max(c,u.at??0),0),i=Lx(o,t),a=n?`Last reply ${/^[A-Z]/.test(i)?i[0].toLowerCase()+i.slice(1):i}`:"";return{count:r,faces:s,last:a}}const ai={start:440,min:320,max:760,chat:560};function kj(e,t){const n=Math.min(ai.max,t-ai.chat),r=Number.isFinite(e)?e:ai.start;return Math.round(Math.max(ai.min,Math.min(r,n)))}const vj="zero.chatThreadWidth";function p9(e){return e&&e.chat===0&&e.threads.length===1?e.threads[0].uid:null}const Go=(e,t,n)=>({name:e,icon:t,emoji:n.trim().split(`
|
|
150
|
+
`).map(r=>{const[s,...o]=r.trim().split(" ");return[s,o.join(" ")]})}),Ew=[Go("Smileys","😀",`
|
|
151
|
+
😀 grin smile happy
|
|
152
|
+
😃 smile happy joy
|
|
153
|
+
😄 smile happy laugh
|
|
154
|
+
😁 grin beam teeth
|
|
155
|
+
😆 laugh lol squint
|
|
156
|
+
😅 sweat relief nervous laugh
|
|
157
|
+
🤣 rofl rolling laugh
|
|
158
|
+
😂 joy tears laugh lol
|
|
159
|
+
🙂 slight smile
|
|
160
|
+
🙃 upside down silly
|
|
161
|
+
😉 wink
|
|
162
|
+
😊 blush smile happy
|
|
163
|
+
😇 halo angel innocent
|
|
164
|
+
🥰 love hearts adore
|
|
165
|
+
😍 heart eyes love
|
|
166
|
+
🤩 star struck wow
|
|
167
|
+
😘 kiss blow
|
|
168
|
+
😋 yum tasty
|
|
169
|
+
😛 tongue
|
|
170
|
+
😜 wink tongue crazy
|
|
171
|
+
🤪 zany crazy goofy
|
|
172
|
+
🤑 money rich
|
|
173
|
+
🤗 hug hugs
|
|
174
|
+
🤭 oops giggle
|
|
175
|
+
🤫 shush quiet secret
|
|
176
|
+
🤔 think thinking hmm
|
|
177
|
+
🤐 zip quiet
|
|
178
|
+
🤨 raised eyebrow skeptical
|
|
179
|
+
😐 neutral meh
|
|
180
|
+
😑 expressionless blank
|
|
181
|
+
😶 no mouth speechless
|
|
182
|
+
😏 smirk
|
|
183
|
+
😒 unamused
|
|
184
|
+
🙄 eye roll
|
|
185
|
+
😬 grimace awkward yikes
|
|
186
|
+
😮💨 exhale sigh relief
|
|
187
|
+
😌 relieved calm
|
|
188
|
+
😔 pensive sad
|
|
189
|
+
😪 sleepy
|
|
190
|
+
😴 sleep zzz tired
|
|
191
|
+
😷 mask sick
|
|
192
|
+
🤒 thermometer sick ill
|
|
193
|
+
🤯 mind blown exploding wow
|
|
194
|
+
🥳 party celebrate birthday
|
|
195
|
+
😎 cool sunglasses
|
|
196
|
+
🤓 nerd geek
|
|
197
|
+
🧐 monocle inspect curious
|
|
198
|
+
😕 confused
|
|
199
|
+
😟 worried
|
|
200
|
+
🙁 frown sad
|
|
201
|
+
😮 open mouth surprise
|
|
202
|
+
😯 hushed surprise
|
|
203
|
+
😲 astonished shock
|
|
204
|
+
😳 flushed embarrassed
|
|
205
|
+
🥺 pleading puppy please
|
|
206
|
+
🥹 holding back tears grateful
|
|
207
|
+
😢 cry sad tear
|
|
208
|
+
😭 sob crying
|
|
209
|
+
😱 scream fear
|
|
210
|
+
😖 confounded
|
|
211
|
+
😣 persevere struggle
|
|
212
|
+
😞 disappointed
|
|
213
|
+
😓 sweat downcast
|
|
214
|
+
😩 weary tired
|
|
215
|
+
😫 tired exhausted
|
|
216
|
+
🥱 yawn bored tired
|
|
217
|
+
😤 triumph huff
|
|
218
|
+
😡 angry mad rage
|
|
219
|
+
😠 angry mad
|
|
220
|
+
🤬 swearing cursing
|
|
221
|
+
💀 skull dead lol
|
|
222
|
+
💩 poop
|
|
223
|
+
🤡 clown
|
|
224
|
+
👻 ghost boo
|
|
225
|
+
👽 alien
|
|
226
|
+
🤖 robot bot
|
|
227
|
+
😺 cat smile
|
|
228
|
+
🫠 melting
|
|
229
|
+
🫡 salute respect
|
|
230
|
+
🫣 peek
|
|
231
|
+
🫢 gasp
|
|
232
|
+
`),Go("People","👋",`
|
|
233
|
+
👋 wave hello hi bye
|
|
234
|
+
🤚 raised back hand
|
|
235
|
+
✋ hand high five stop
|
|
236
|
+
🖖 vulcan
|
|
237
|
+
👌 ok okay perfect
|
|
238
|
+
🤌 pinched italian
|
|
239
|
+
🤏 pinch small tiny
|
|
240
|
+
✌️ victory peace
|
|
241
|
+
🤞 fingers crossed luck hope
|
|
242
|
+
🫰 snap
|
|
243
|
+
🤟 love you
|
|
244
|
+
🤘 rock horns
|
|
245
|
+
🤙 call me shaka
|
|
246
|
+
👈 point left
|
|
247
|
+
👉 point right
|
|
248
|
+
👆 point up
|
|
249
|
+
👇 point down
|
|
250
|
+
☝️ index up one
|
|
251
|
+
👍 thumbs up yes good like +1
|
|
252
|
+
👎 thumbs down no bad -1
|
|
253
|
+
✊ fist
|
|
254
|
+
👊 punch fist bump
|
|
255
|
+
🤛 left fist bump
|
|
256
|
+
🤜 right fist bump
|
|
257
|
+
👏 clap applause bravo
|
|
258
|
+
🙌 raised hands hooray praise
|
|
259
|
+
🫶 heart hands love
|
|
260
|
+
👐 open hands
|
|
261
|
+
🤲 palms up
|
|
262
|
+
🤝 handshake deal agree
|
|
263
|
+
🙏 pray please thanks thank you
|
|
264
|
+
✍️ writing write
|
|
265
|
+
💪 muscle strong flex
|
|
266
|
+
🧠 brain smart think
|
|
267
|
+
👀 eyes look looking see
|
|
268
|
+
👁️ eye
|
|
269
|
+
👄 mouth lips
|
|
270
|
+
🙋 raising hand me
|
|
271
|
+
🙆 ok gesture
|
|
272
|
+
🙅 no gesture
|
|
273
|
+
🤷 shrug dunno whatever
|
|
274
|
+
🤦 facepalm
|
|
275
|
+
🙇 bow sorry
|
|
276
|
+
💁 tipping hand
|
|
277
|
+
🧑💻 developer coder laptop
|
|
278
|
+
🧑🎨 artist designer
|
|
279
|
+
🧑🚀 astronaut
|
|
280
|
+
🕵️ detective investigate
|
|
281
|
+
🏃 run running
|
|
282
|
+
🚶 walk walking
|
|
283
|
+
🧘 yoga calm meditate
|
|
284
|
+
💃 dance dancer
|
|
285
|
+
🕺 dance disco
|
|
286
|
+
👯 party dancing
|
|
287
|
+
🫂 hug people
|
|
288
|
+
👶 baby
|
|
289
|
+
🧙 wizard magic
|
|
290
|
+
🥷 ninja
|
|
291
|
+
🦸 hero superhero
|
|
292
|
+
`),Go("Hearts and symbols","❤️",`
|
|
293
|
+
❤️ heart love red
|
|
294
|
+
🧡 orange heart
|
|
295
|
+
💛 yellow heart
|
|
296
|
+
💚 green heart
|
|
297
|
+
💙 blue heart
|
|
298
|
+
💜 purple heart
|
|
299
|
+
🖤 black heart
|
|
300
|
+
🤍 white heart
|
|
301
|
+
🤎 brown heart
|
|
302
|
+
💔 broken heart sad
|
|
303
|
+
❤️🔥 heart on fire
|
|
304
|
+
💕 two hearts love
|
|
305
|
+
💖 sparkling heart
|
|
306
|
+
💯 hundred 100 perfect
|
|
307
|
+
✅ check done yes tick
|
|
308
|
+
☑️ check box ballot
|
|
309
|
+
✔️ check mark
|
|
310
|
+
❌ cross no wrong x
|
|
311
|
+
❎ cross box
|
|
312
|
+
➕ plus add
|
|
313
|
+
➖ minus
|
|
314
|
+
❓ question
|
|
315
|
+
❗ exclamation important
|
|
316
|
+
‼️ double exclamation
|
|
317
|
+
⁉️ interrobang
|
|
318
|
+
⚠️ warning caution
|
|
319
|
+
🚫 prohibited no forbidden
|
|
320
|
+
⛔ no entry stop
|
|
321
|
+
🔴 red circle
|
|
322
|
+
🟠 orange circle
|
|
323
|
+
🟡 yellow circle
|
|
324
|
+
🟢 green circle
|
|
325
|
+
🔵 blue circle
|
|
326
|
+
🟣 purple circle
|
|
327
|
+
⚫ black circle
|
|
328
|
+
⚪ white circle
|
|
329
|
+
⭐ star favourite
|
|
330
|
+
🌟 glowing star
|
|
331
|
+
✨ sparkles new magic
|
|
332
|
+
💫 dizzy
|
|
333
|
+
💥 boom collision
|
|
334
|
+
🔥 fire hot lit
|
|
335
|
+
💬 speech bubble comment
|
|
336
|
+
💭 thought bubble
|
|
337
|
+
🗯️ anger bubble
|
|
338
|
+
💤 zzz sleep
|
|
339
|
+
🆗 ok button
|
|
340
|
+
🆕 new
|
|
341
|
+
🆒 cool
|
|
342
|
+
🔝 top
|
|
343
|
+
🔜 soon
|
|
344
|
+
♻️ recycle
|
|
345
|
+
➡️ right arrow
|
|
346
|
+
⬅️ left arrow
|
|
347
|
+
⬆️ up arrow
|
|
348
|
+
⬇️ down arrow
|
|
349
|
+
🔁 repeat
|
|
350
|
+
🔄 refresh sync
|
|
351
|
+
⏩ fast forward
|
|
352
|
+
⏸️ pause
|
|
353
|
+
⏹️ stop
|
|
354
|
+
▶️ play
|
|
355
|
+
`),Go("Animals and nature","🐶",`
|
|
356
|
+
🐶 dog puppy
|
|
357
|
+
🐱 cat kitten
|
|
358
|
+
🐭 mouse
|
|
359
|
+
🐹 hamster
|
|
360
|
+
🐰 rabbit bunny
|
|
361
|
+
🦊 fox
|
|
362
|
+
🐻 bear
|
|
363
|
+
🐼 panda
|
|
364
|
+
🐨 koala
|
|
365
|
+
🐯 tiger
|
|
366
|
+
🦁 lion
|
|
367
|
+
🐮 cow
|
|
368
|
+
🐷 pig
|
|
369
|
+
🐸 frog
|
|
370
|
+
🐵 monkey
|
|
371
|
+
🙈 see no evil monkey
|
|
372
|
+
🙉 hear no evil
|
|
373
|
+
🙊 speak no evil
|
|
374
|
+
🐔 chicken
|
|
375
|
+
🐧 penguin
|
|
376
|
+
🐦 bird
|
|
377
|
+
🦆 duck
|
|
378
|
+
🦉 owl
|
|
379
|
+
🦄 unicorn
|
|
380
|
+
🐝 bee busy
|
|
381
|
+
🐛 bug caterpillar
|
|
382
|
+
🦋 butterfly
|
|
383
|
+
🐌 snail slow
|
|
384
|
+
🐢 turtle slow
|
|
385
|
+
🐍 snake
|
|
386
|
+
🐙 octopus
|
|
387
|
+
🦀 crab
|
|
388
|
+
🐳 whale
|
|
389
|
+
🐬 dolphin
|
|
390
|
+
🦈 shark
|
|
391
|
+
🐘 elephant
|
|
392
|
+
🦒 giraffe
|
|
393
|
+
🦥 sloth slow
|
|
394
|
+
🐿️ squirrel
|
|
395
|
+
🌵 cactus
|
|
396
|
+
🌲 evergreen tree
|
|
397
|
+
🌳 tree
|
|
398
|
+
🌴 palm tree
|
|
399
|
+
🌱 seedling sprout grow
|
|
400
|
+
🌿 herb
|
|
401
|
+
🍀 clover luck
|
|
402
|
+
🍁 maple leaf autumn
|
|
403
|
+
🍂 fallen leaves fall
|
|
404
|
+
🌸 cherry blossom flower
|
|
405
|
+
🌹 rose
|
|
406
|
+
🌻 sunflower
|
|
407
|
+
🌷 tulip
|
|
408
|
+
🌈 rainbow
|
|
409
|
+
☀️ sun sunny
|
|
410
|
+
🌤️ sun cloud
|
|
411
|
+
☁️ cloud
|
|
412
|
+
🌧️ rain
|
|
413
|
+
⛈️ storm thunder
|
|
414
|
+
❄️ snow snowflake cold
|
|
415
|
+
⚡ lightning zap fast
|
|
416
|
+
🌊 wave ocean
|
|
417
|
+
🌙 moon night
|
|
418
|
+
🌍 earth globe world
|
|
419
|
+
`),Go("Food and drink","🍕",`
|
|
420
|
+
🍏 green apple
|
|
421
|
+
🍎 apple red
|
|
422
|
+
🍊 orange tangerine
|
|
423
|
+
🍋 lemon
|
|
424
|
+
🍌 banana
|
|
425
|
+
🍉 watermelon
|
|
426
|
+
🍇 grapes
|
|
427
|
+
🍓 strawberry
|
|
428
|
+
🫐 blueberries
|
|
429
|
+
🍒 cherries
|
|
430
|
+
🍑 peach
|
|
431
|
+
🥭 mango
|
|
432
|
+
🍍 pineapple
|
|
433
|
+
🥥 coconut
|
|
434
|
+
🥑 avocado
|
|
435
|
+
🍆 eggplant
|
|
436
|
+
🥕 carrot
|
|
437
|
+
🌽 corn
|
|
438
|
+
🌶️ hot pepper spicy
|
|
439
|
+
🥦 broccoli
|
|
440
|
+
🍄 mushroom
|
|
441
|
+
🥐 croissant
|
|
442
|
+
🍞 bread
|
|
443
|
+
🥯 bagel
|
|
444
|
+
🧀 cheese
|
|
445
|
+
🥚 egg
|
|
446
|
+
🍳 cooking fried egg
|
|
447
|
+
🥞 pancakes
|
|
448
|
+
🥓 bacon
|
|
449
|
+
🍔 burger hamburger
|
|
450
|
+
🍟 fries
|
|
451
|
+
🍕 pizza
|
|
452
|
+
🌭 hot dog
|
|
453
|
+
🥪 sandwich
|
|
454
|
+
🌮 taco
|
|
455
|
+
🌯 burrito
|
|
456
|
+
🥗 salad
|
|
457
|
+
🍝 pasta spaghetti
|
|
458
|
+
🍜 ramen noodles
|
|
459
|
+
🍣 sushi
|
|
460
|
+
🍱 bento
|
|
461
|
+
🍿 popcorn
|
|
462
|
+
🍩 donut doughnut
|
|
463
|
+
🍪 cookie
|
|
464
|
+
🎂 birthday cake
|
|
465
|
+
🍰 cake slice
|
|
466
|
+
🧁 cupcake
|
|
467
|
+
🍫 chocolate
|
|
468
|
+
🍬 candy
|
|
469
|
+
🍦 ice cream
|
|
470
|
+
☕ coffee tea hot
|
|
471
|
+
🍵 tea matcha
|
|
472
|
+
🧋 boba bubble tea
|
|
473
|
+
🥤 drink soda cup
|
|
474
|
+
🍺 beer
|
|
475
|
+
🍻 cheers beers
|
|
476
|
+
🥂 cheers champagne toast
|
|
477
|
+
🍷 wine
|
|
478
|
+
🍸 cocktail
|
|
479
|
+
🍾 champagne celebrate
|
|
480
|
+
`),Go("Activities","⚽",`
|
|
481
|
+
🎉 party tada celebrate hooray
|
|
482
|
+
🎊 confetti celebrate
|
|
483
|
+
🎈 balloon
|
|
484
|
+
🎁 gift present
|
|
485
|
+
🎀 ribbon
|
|
486
|
+
🏆 trophy win winner
|
|
487
|
+
🥇 gold medal first
|
|
488
|
+
🥈 silver medal second
|
|
489
|
+
🥉 bronze medal third
|
|
490
|
+
🏅 medal
|
|
491
|
+
🎯 bullseye target goal direct hit
|
|
492
|
+
⚽ soccer football
|
|
493
|
+
🏀 basketball
|
|
494
|
+
🏈 american football
|
|
495
|
+
⚾ baseball
|
|
496
|
+
🎾 tennis
|
|
497
|
+
🏐 volleyball
|
|
498
|
+
🏓 ping pong
|
|
499
|
+
🏸 badminton
|
|
500
|
+
⛳ golf
|
|
501
|
+
🎳 bowling
|
|
502
|
+
🏋️ weights lift gym
|
|
503
|
+
🚴 bike cycling
|
|
504
|
+
🏊 swim swimming
|
|
505
|
+
🧗 climbing
|
|
506
|
+
⛷️ ski skiing
|
|
507
|
+
🏄 surf surfing
|
|
508
|
+
🎮 video game controller gaming
|
|
509
|
+
🕹️ joystick
|
|
510
|
+
🎲 dice game
|
|
511
|
+
♟️ chess
|
|
512
|
+
🧩 puzzle piece
|
|
513
|
+
🎨 art palette paint
|
|
514
|
+
🎭 theatre drama
|
|
515
|
+
🎬 film movie clapper
|
|
516
|
+
🎤 microphone sing
|
|
517
|
+
🎧 headphones music
|
|
518
|
+
🎵 music note
|
|
519
|
+
🎶 music notes
|
|
520
|
+
🎸 guitar
|
|
521
|
+
🎹 piano keyboard
|
|
522
|
+
🥁 drum
|
|
523
|
+
🎺 trumpet
|
|
524
|
+
🎻 violin
|
|
525
|
+
🪩 disco ball
|
|
526
|
+
`),Go("Travel and places","✈️",`
|
|
527
|
+
🚀 rocket launch ship fast
|
|
528
|
+
✈️ airplane plane flight travel
|
|
529
|
+
🛫 departure takeoff
|
|
530
|
+
🛬 arrival landing
|
|
531
|
+
🚗 car
|
|
532
|
+
🚕 taxi
|
|
533
|
+
🚌 bus
|
|
534
|
+
🚲 bicycle bike
|
|
535
|
+
🛴 scooter
|
|
536
|
+
🚂 train
|
|
537
|
+
🚇 metro subway
|
|
538
|
+
🚢 ship boat
|
|
539
|
+
⛵ sailboat
|
|
540
|
+
🛶 canoe
|
|
541
|
+
🚁 helicopter
|
|
542
|
+
🛸 ufo
|
|
543
|
+
🚦 traffic light
|
|
544
|
+
🚧 construction wip
|
|
545
|
+
⚓ anchor
|
|
546
|
+
🗺️ map
|
|
547
|
+
🧭 compass direction
|
|
548
|
+
🏔️ mountain snow
|
|
549
|
+
⛰️ mountain
|
|
550
|
+
🏕️ camping
|
|
551
|
+
🏖️ beach
|
|
552
|
+
🏝️ island
|
|
553
|
+
🏜️ desert
|
|
554
|
+
🏠 house home
|
|
555
|
+
🏡 garden home
|
|
556
|
+
🏢 office building
|
|
557
|
+
🏗️ building construction
|
|
558
|
+
🏛️ classical building
|
|
559
|
+
🏰 castle
|
|
560
|
+
🗽 statue liberty
|
|
561
|
+
🗼 tower
|
|
562
|
+
🌉 bridge
|
|
563
|
+
🌆 city dusk
|
|
564
|
+
🌃 night city
|
|
565
|
+
🎡 ferris wheel
|
|
566
|
+
🎢 roller coaster
|
|
567
|
+
⛲ fountain
|
|
568
|
+
🌅 sunrise
|
|
569
|
+
🌄 sunrise mountains
|
|
570
|
+
🌌 milky way
|
|
571
|
+
`),Go("Objects","💡",`
|
|
572
|
+
💡 idea light bulb
|
|
573
|
+
📌 pin pushpin
|
|
574
|
+
📍 location pin
|
|
575
|
+
📎 paperclip attach
|
|
576
|
+
🔗 link
|
|
577
|
+
✏️ pencil edit
|
|
578
|
+
🖊️ pen
|
|
579
|
+
🖍️ crayon
|
|
580
|
+
📝 memo note write
|
|
581
|
+
📄 page document
|
|
582
|
+
📃 page curl
|
|
583
|
+
📑 bookmark tabs
|
|
584
|
+
📊 bar chart stats
|
|
585
|
+
📈 chart up growth
|
|
586
|
+
📉 chart down decline
|
|
587
|
+
🗂️ dividers folders
|
|
588
|
+
📁 folder
|
|
589
|
+
📂 open folder
|
|
590
|
+
📅 calendar date
|
|
591
|
+
📆 tear off calendar
|
|
592
|
+
🗓️ spiral calendar schedule
|
|
593
|
+
📋 clipboard
|
|
594
|
+
🗒️ notepad
|
|
595
|
+
📚 books
|
|
596
|
+
📖 book read
|
|
597
|
+
🔖 bookmark
|
|
598
|
+
💼 briefcase work
|
|
599
|
+
🧾 receipt
|
|
600
|
+
💰 money bag
|
|
601
|
+
💵 dollar money
|
|
602
|
+
💳 credit card
|
|
603
|
+
💸 money flying spend
|
|
604
|
+
📦 package box ship
|
|
605
|
+
📬 mailbox mail
|
|
606
|
+
📧 email
|
|
607
|
+
✉️ envelope letter
|
|
608
|
+
📨 incoming mail
|
|
609
|
+
📮 postbox
|
|
610
|
+
📣 megaphone announce
|
|
611
|
+
📢 loudspeaker
|
|
612
|
+
🔔 bell notification
|
|
613
|
+
🔕 bell off mute
|
|
614
|
+
💻 laptop computer
|
|
615
|
+
🖥️ desktop computer
|
|
616
|
+
⌨️ keyboard
|
|
617
|
+
🖱️ mouse
|
|
618
|
+
📱 phone mobile
|
|
619
|
+
☎️ telephone
|
|
620
|
+
🔋 battery
|
|
621
|
+
🔌 plug
|
|
622
|
+
📷 camera photo
|
|
623
|
+
📸 camera flash
|
|
624
|
+
🎥 movie camera video
|
|
625
|
+
📺 tv
|
|
626
|
+
🔍 search magnifying glass
|
|
627
|
+
🔎 search magnifying right
|
|
628
|
+
🔒 lock locked secure
|
|
629
|
+
🔓 unlock open
|
|
630
|
+
🔑 key
|
|
631
|
+
🔨 hammer
|
|
632
|
+
🛠️ tools fix
|
|
633
|
+
🔧 wrench fix
|
|
634
|
+
🪛 screwdriver
|
|
635
|
+
⚙️ gear settings
|
|
636
|
+
🧪 test tube experiment
|
|
637
|
+
🔬 microscope
|
|
638
|
+
🧲 magnet
|
|
639
|
+
🧹 broom clean
|
|
640
|
+
🗑️ trash bin delete
|
|
641
|
+
⏰ alarm clock
|
|
642
|
+
⏳ hourglass waiting
|
|
643
|
+
⌛ hourglass done
|
|
644
|
+
⏱️ stopwatch timer
|
|
645
|
+
🕐 clock time
|
|
646
|
+
🧯 fire extinguisher
|
|
647
|
+
🛒 cart shopping
|
|
648
|
+
🎫 ticket
|
|
649
|
+
🏷️ label tag
|
|
650
|
+
🪄 magic wand
|
|
651
|
+
🧸 teddy bear
|
|
652
|
+
🕯️ candle
|
|
653
|
+
🪴 potted plant
|
|
654
|
+
🛋️ couch
|
|
655
|
+
🛏️ bed sleep
|
|
656
|
+
🚪 door
|
|
657
|
+
🪞 mirror
|
|
658
|
+
💎 gem diamond
|
|
659
|
+
👑 crown king queen
|
|
660
|
+
🎓 graduation cap
|
|
661
|
+
🧳 luggage travel
|
|
662
|
+
☂️ umbrella
|
|
663
|
+
🌂 closed umbrella
|
|
664
|
+
`)];function m9(e){const t=e.trim().toLowerCase();if(!t)return[];const n=Ew.flatMap(o=>o.emoji),r=n.filter(([,o])=>o.split(" ").some(i=>i.startsWith(t))),s=n.filter(o=>!r.includes(o)&&o[1].includes(t));return[...r,...s]}const g9=["👍","🙏","👀","✅","🎉","❤️","😄","🤔"],Sj=320,jj=360,xc=8;function y9(e){const t=Math.max(xc,Math.min(e.right-Sj,window.innerWidth-Sj-xc)),n=e.top-6-jj,r=n>=xc?n:Math.max(xc,Math.min(e.bottom+6,window.innerHeight-jj-xc));return{left:Math.round(t),top:Math.round(r)}}function ER({onPick:e,onClose:t,title:n="React"}){const r=g.useRef(null),s=g.useRef(null),[o,i]=g.useState(null);g.useEffect(()=>{const c=d=>{var f,p;const h=d.target;!((f=r.current)!=null&&f.contains(h))&&!((p=s.current)!=null&&p.contains(h))&&t()},u=d=>{d.key==="Escape"&&(d.stopPropagation(),t())};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u)}},[t]);const a=()=>{var u;if(o){i(null);return}const c=(u=r.current)==null?void 0:u.getBoundingClientRect();c&&i(y9(c))};return l.jsxs("div",{className:"chat-emoji",ref:r,role:"group","aria-label":n,children:[g9.map(c=>l.jsx("button",{type:"button",className:"chat-emoji-one",title:c,onClick:()=>e(c),children:c},c)),l.jsx("button",{type:"button",className:"chat-emoji-one chat-emoji-more",title:"More emoji","aria-label":"More emoji","aria-expanded":!!o,onClick:a,children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"square","aria-hidden":"true",children:l.jsx("path",{d:"M8 3v10M3 8h10"})})}),o&&bs.createPortal(l.jsx(w9,{onPick:e,at:o,boxRef:s}),document.body)]})}function w9({onPick:e,at:t,boxRef:n}){const[r,s]=g.useState(""),[o,i]=g.useState(null),a=g.useRef(null),c=r.trim()?m9(r):null;g.useEffect(()=>{var h;if(!o)return;const d=(h=a.current)==null?void 0:h.querySelector(`[data-group="${o}"]`);d&&a.current&&(a.current.scrollTop=d.offsetTop-a.current.offsetTop),i(null)},[o,r]);const u=([d,h])=>l.jsx("button",{type:"button",className:"chat-emoji-cell",title:h.split(" ")[0],onClick:()=>e(d),children:d},d);return l.jsxs("div",{className:"chat-emoji-all",ref:n,style:t,role:"dialog","aria-label":"All emoji",children:[l.jsx("input",{className:"chat-emoji-search",placeholder:"Search emoji","aria-label":"Search emoji",autoFocus:!0,value:r,onChange:d=>s(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(c!=null&&c.length)&&(d.preventDefault(),e(c[0][0]))}}),l.jsx("div",{className:"chat-emoji-tabs",children:Ew.map(d=>l.jsx("button",{type:"button",className:"chat-emoji-tab",title:d.name,"aria-label":d.name,onClick:()=>{s(""),i(d.name)},children:d.icon},d.name))}),l.jsx("div",{className:"chat-emoji-scroll",ref:a,children:c?c.length?l.jsx("div",{className:"chat-emoji-grid",children:c.map(u)}):l.jsxs("div",{className:"chat-emoji-none",children:["No emoji for “",r.trim(),"”"]}):Ew.map(d=>l.jsxs("section",{"data-group":d.name,children:[l.jsx("div",{className:"chat-emoji-group",children:d.name}),l.jsx("div",{className:"chat-emoji-grid",children:d.emoji.map(u)})]},d.name))})]})}function AR({on:e,me:t,onReact:n}){const r=Object.entries(e??{}).filter(([,s])=>s.length);return r.length?l.jsx("div",{className:"chat-chips",children:r.map(([s,o])=>{const i=!!t&&o.includes(t);return l.jsxs("button",{type:"button",className:`chat-chip${i?" mine":""}`,"aria-pressed":i,title:i?`You and ${o.length-1} other${o.length===2?"":"s"}`:`${o.length}`,onClick:()=>n(s,i),children:[l.jsx("span",{className:"chat-chip-emoji",children:s}),l.jsx("span",{className:"chat-chip-count",children:o.length})]},s)})}):null}function TR({onReact:e,onQuote:t,replyLabel:n="Reply",onHandToAgent:r}){const[s,o]=g.useState(!1);return l.jsxs("div",{className:`chat-acts${s?" open":""}`,children:[s&&l.jsx(ER,{onPick:i=>{o(!1),e(i)},onClose:()=>o(!1)}),l.jsx("button",{type:"button",className:"chat-act",title:"React","aria-label":"React",onClick:()=>o(i=>!i),children:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M14 8A6 6 0 1 1 8 2"}),l.jsx("path",{d:"M5.8 6.4h.01M10 6.4h.01",strokeWidth:"1.6"}),l.jsx("path",{d:"M5.6 9.6c.6.8 1.4 1.2 2.4 1.2s1.8-.4 2.4-1.2"}),l.jsx("path",{d:"M12.5 1.8v3.4M10.8 3.5h3.4"})]})}),t&&l.jsx("button",{type:"button",className:"chat-act",title:n,"aria-label":n,onClick:t,children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"miter","aria-hidden":"true",children:l.jsx("path",{d:"M2 2.8h12v8.4H7.2L3.6 14v-2.8H2z"})})}),r&&l.jsxs("button",{type:"button",className:"chat-act chat-act-hand",title:"Hand to an agent","aria-label":"Hand to an agent",onClick:r,children:[l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"miter","aria-hidden":"true",children:[l.jsx("path",{d:"M2.2 2.2h11.6v11.6H2.2z"}),l.jsx("path",{d:"M2.2 6.1h11.6M6.1 6.1v7.7"})]}),l.jsx("span",{className:"chat-act-word",children:"Hand to an agent"})]})]})}const b9={bold:["**","**"],italic:["*","*"],strike:["~~","~~"],code:["`","`"]},x9={bullet:()=>"- ",number:e=>`${e+1}. `,quote:()=>"> "},pg={bold:"bold text",italic:"italic text",strike:"strike",code:"code",link:"text",bullet:"item",number:"item",quote:"quote"};function k9(e,t,n){const r=e.lastIndexOf(`
|
|
665
|
+
`,t-1)+1,s=e.indexOf(`
|
|
666
|
+
`,n);return{start:r,end:s===-1?e.length:s}}function v9(e,t,n,r){const s=e.slice(t,n);if(r==="link"){const p=`[${s||pg.link}]()`,m=t+p.length-1;return{text:e.slice(0,t)+p+e.slice(n),from:m,to:m}}const o=x9[r];if(o){const{start:f,end:p}=k9(e,t,n),w=(e.slice(f,p)||pg[r]).split(`
|
|
667
|
+
`),b=w.map((S,C)=>o(C)),x=w.every((S,C)=>S.startsWith(b[C])),v=w.map((S,C)=>x?S.slice(b[C].length):b[C]+S).join(`
|
|
668
|
+
`);return{text:e.slice(0,f)+v+e.slice(p),from:f,to:f+v.length}}const[i,a]=b9[r];if(s.startsWith(i)&&s.endsWith(a)&&s.length>=i.length+a.length){const f=s.slice(i.length,s.length-a.length);return{text:e.slice(0,t)+f+e.slice(n),from:t,to:t+f.length}}const c=e.slice(t-i.length,t),u=e.slice(n,n+a.length);if(s&&c===i&&u===a){const f=t-i.length;return{text:e.slice(0,f)+s+e.slice(n+a.length),from:f,to:f+s.length}}const d=s||pg[r],h=i+d+a;return{text:e.slice(0,t)+h+e.slice(n),from:t+i.length,to:t+i.length+d.length}}function Cj(e,t,n,r){const s=t+r.length;return{text:e.slice(0,t)+r+e.slice(n),from:s,to:s}}const S9=[{what:"bold",title:"Bold",glyph:l.jsx("span",{className:"fmt-letter fmt-b",children:"B"})},{what:"italic",title:"Italic",glyph:l.jsx("span",{className:"fmt-letter fmt-i",children:"I"})},{what:"strike",title:"Strikethrough",glyph:l.jsx("span",{className:"fmt-letter fmt-s",children:"S"})},{what:"link",title:"Link",glyph:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M6.6 9.4a2.6 2.6 0 0 0 3.7 0l2.4-2.4a2.6 2.6 0 0 0-3.7-3.7l-1 1"}),l.jsx("path",{d:"M9.4 6.6a2.6 2.6 0 0 0-3.7 0L3.3 9a2.6 2.6 0 0 0 3.7 3.7l1-1"})]})},{what:"bullet",title:"Bulleted list",glyph:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M6 4h8M6 8h8M6 12h8"}),l.jsx("path",{d:"M2.6 4h.01M2.6 8h.01M2.6 12h.01",strokeWidth:"1.8"})]})},{what:"number",title:"Numbered list",glyph:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M6.5 4h7.5M6.5 8h7.5M6.5 12h7.5"}),l.jsx("path",{d:"M2 2.9h.9V5M1.4 11.2h1.6L1.4 13h1.7",strokeWidth:"1.1"})]})},{what:"quote",title:"Quote",glyph:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M2.6 3.4v9.2",strokeWidth:"1.8"}),l.jsx("path",{d:"M6 4.8h8M6 8h8M6 11.2h5"})]})},{what:"code",title:"Code",glyph:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"miter","aria-hidden":"true",children:l.jsx("path",{d:"M5.6 4.4 1.8 8l3.8 3.6M10.4 4.4 14.2 8l-3.8 3.6"})})}];function j9({box:e,onChange:t,onAttach:n}){const[r,s]=g.useState(!1),o=g.useRef(null),i=c=>{const u=e.current;if(!u)return;const d=c(u.value,u.selectionStart??u.value.length,u.selectionEnd??u.value.length);t(d.text),requestAnimationFrame(()=>{u.focus(),u.setSelectionRange(d.from,d.to)})},a=c=>c.preventDefault();return l.jsxs("div",{className:"fmt-bar",role:"toolbar","aria-label":"Formatting",children:[S9.map(({what:c,title:u,glyph:d})=>l.jsx("button",{type:"button",className:"fmt-btn",title:u,"aria-label":u,onMouseDown:a,onClick:()=>i((h,f,p)=>v9(h,f,p,c)),children:d},c)),l.jsx("span",{className:"fmt-gap","aria-hidden":"true"}),l.jsx("button",{type:"button",className:"fmt-btn",title:"Mention someone","aria-label":"Mention someone",onMouseDown:a,onClick:()=>i((c,u,d)=>Cj(c,u,d,"@")),children:l.jsx("span",{className:"fmt-letter",children:"@"})}),n&&l.jsx("button",{type:"button",className:"fmt-btn",title:"Attach a file","aria-label":"Attach a file",onMouseDown:a,onClick:n,children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":"true",children:l.jsx("path",{d:"M8 3v10M3 8h10"})})}),l.jsxs("span",{className:"fmt-emoji-wrap",ref:o,children:[r&&l.jsx(ER,{title:"Add an emoji",onClose:()=>s(!1),onPick:c=>{s(!1),i((u,d,h)=>Cj(u,d,h,c))}}),l.jsx("button",{type:"button",className:"fmt-btn",title:"Add an emoji","aria-label":"Add an emoji",onMouseDown:a,onClick:()=>s(c=>!c),children:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6"}),l.jsx("path",{d:"M5.8 6.4h.01M10.2 6.4h.01",strokeWidth:"1.6"}),l.jsx("path",{d:"M5.6 9.6c.6.8 1.4 1.2 2.4 1.2s1.8-.4 2.4-1.2"})]})})]})]})}function Od({ask:e,askAll:t,options:n,peekOption:r,askPeek:s,selectedOption:o,selRef:i,onPick:a,onOptionEnter:c,onAskEnter:u,setPeek:d,setAskPeek:h,keep:f}){return l.jsxs("div",{className:"opt-strip",children:[l.jsx("div",{className:`opt-head ${e?"opt-head-ask":""}`,onMouseEnter:p=>u(p.currentTarget),onMouseLeave:()=>h(!1),children:l.jsx("span",{children:e||"Their options · pick or write your own"})}),r&&l.jsxs("div",{className:"opt-peek",children:[l.jsxs("div",{className:"opt-peek-head",children:["Option ",r.n,", in full"]}),l.jsx(jl,{remarkPlugins:[Cl],children:r.text.replace(/\s*\(recommended\)/i,"")})]}),!r&&s&&l.jsxs("div",{className:"opt-peek",children:[l.jsx("div",{className:"opt-peek-head",children:"The question, in full"}),l.jsx(jl,{remarkPlugins:[Cl],children:t})]}),n.map(p=>l.jsxs("button",{ref:p.n===o?i:void 0,className:`opt-row ${p.n===o?"selected":""}`,onClick:()=>a(p.n),onMouseEnter:m=>c(p.n,m.currentTarget),onMouseLeave:()=>d(null),children:[l.jsx("span",{className:"opt-key",children:p.n}),l.jsx("span",{className:"opt-text",children:l.jsx(jl,{remarkPlugins:[Cl],components:{p:({children:m})=>l.jsx(l.Fragment,{children:m})},children:p.text.replace(/\s*\(recommended\)/i,"")})}),p.n===o?l.jsx("span",{className:"opt-rec",children:"↵ send"}):p.recommended&&l.jsx("span",{className:"opt-rec",children:"recommended"})]},p.n)),f&&l.jsxs("button",{className:"opt-row",onClick:f.onKeep,children:[l.jsx("span",{className:"opt-key",children:"esc"}),l.jsx("span",{className:"opt-text",children:f.label})]})]})}const C9=100;function N9(e){return e.replace(/\s+/g," ").trim()}function E9(e,t){if(e.length<=t)return e;const n=e.slice(0,t),r=n.lastIndexOf(" ");return`${(r>t*.6?n.slice(0,r):n).trimEnd()}…`}function A9(e){const t=(e??[]).filter(r=>r&&r.name);if(!t.length)return"";const n=t.every(r=>r.image)?"image":"file";return`${t.length} ${n}${t.length===1?"":"s"}`}function T9(e,t=[],n,r=C9){const s=N9(String(e??"")),o=A9(t);return!s&&!o?{draft:!1,text:n?`Reply to ${n}…`:"Reply…",files:""}:s?{draft:!0,text:E9(s,r),files:o}:{draft:!0,text:o,files:""}}const Cp=.4,Nj=3;function M9(e,t=Cp){const n=e.paneHeight*t-e.chromeHeight-e.padY;return Number.isFinite(n)?Math.max(Nj,Math.floor(n/e.lineHeight)):Nj}function MR(e,t=Cp){return M9(e,t)*e.lineHeight+e.padY}function R9(e,t=Cp){const n=Math.min(e.scrollHeight,MR(e,t));return Math.max(e.floor,n)}const kc=e=>{const t=parseFloat(e);return Number.isFinite(t)?t:0};function I9(e){const t=getComputedStyle(e),n=kc(t.lineHeight)||kc(t.fontSize)*1.55||22,r=kc(t.paddingTop)+kc(t.paddingBottom),s=e.closest(".dock-card"),o=e.closest(".focus-pane"),i=(o==null?void 0:o.getBoundingClientRect().height)||window.innerHeight||0,a=s?Math.max(0,s.getBoundingClientRect().height-e.getBoundingClientRect().height):0;return{paneHeight:i,chromeHeight:a,lineHeight:n,padY:r,floor:kc(t.minHeight),scrollHeight:e.scrollHeight}}function Ej(e,t=Cp){if(!e)return;e.style.height="auto";const n=I9(e),r=R9(n,t);e.style.maxHeight=`${MR(n,t)}px`,e.style.height=`${r}px`}const D9=2500,Aj=["wheel","touchstart","keydown","mousedown"],O9=700,L9="p, h1, h2, h3, h4, h5, h6, li, pre, blockquote, tr, img, iframe";function mg(e){if(typeof e.querySelectorAll!="function"||typeof e.getBoundingClientRect!="function")return null;const t=e.getBoundingClientRect().top,n=e.querySelectorAll(L9);let r=0,s=n.length-1,o=-1;for(;r<=s;){const a=r+s>>1;n[a].getBoundingClientRect().bottom>t?(o=a,s=a-1):r=a+1}if(o<0)return null;const i=n[o];return{node:i,offset:i.getBoundingClientRect().top-t}}function $9(e,t){if(!t.node.isConnected||!e.contains(t.node))return!1;const n=t.node.getBoundingClientRect().top-e.getBoundingClientRect().top,r=Math.max(0,Math.min(Np(e),Math.round(e.scrollTop+n-t.offset)));return Math.round(e.scrollTop)!==r&&(e.scrollTop=r),!0}function gg(e){var r;const t=e.clientWidth,n=(r=e.firstElementChild)==null?void 0:r.clientWidth;return typeof t=="number"?t*1e5+(typeof n=="number"?n:0):-1}function Np(e){return Math.max(0,Math.round(e.scrollHeight-e.clientHeight))}function Ld(e){return Math.max(0,Np(e)-Math.round(e.scrollTop))}const $d=24,Tj=new WeakMap,Aw=e=>{const t=Tj.get(e);if(t)return t;const n={live:0,placed:null};return Tj.set(e,n),n};function P9(e,t={}){if(!e)return()=>{};const n=t.now??(()=>Date.now());let r=!0,s=!0,o=-1,i=!1,a=-1/0;const c=()=>n()-a<=O9;let u=gg(e),d=null;const h=()=>{if(!r)return;if(Aw(e).live>0){i=!0,o=Math.round(e.scrollTop);return}i&&(i=!1,s=Ld(e)<=$d,o=Math.round(e.scrollTop));const S=gg(e),C=S!==u;if(u=S,C&&!s){d&&$9(e,d)&&(o=Math.round(e.scrollTop),d=mg(e));return}if(!C&&c()&&o>=0&&Math.round(e.scrollTop)!==o&&(s=Ld(e)<=$d),!s){d=mg(e);return}const O=Np(e);Math.round(e.scrollTop)!==O&&(e.scrollTop=O),o=O},f=()=>{if(r){if(gg(e)!==u){h();return}c()&&Math.round(e.scrollTop)!==o&&(s=Ld(e)<=$d),s||(d=mg(e)),o=Math.round(e.scrollTop)}},p=globalThis.ResizeObserver,m=p?new p(()=>h()):null,w=()=>h(),b=()=>{a=n()};function x(){if(r){r=!1,m==null||m.disconnect(),e.removeEventListener("scroll",f),e.removeEventListener("load",w,!0);for(const S of Aj)e.removeEventListener(S,b)}}e.addEventListener("scroll",f,{passive:!0}),e.addEventListener("load",w,!0);for(const S of Aj)e.addEventListener(S,b,{passive:!0});m&&(m.observe(e),e.firstElementChild&&m.observe(e.firstElementChild));const v=Aw(e).placed;return v!==null&&Math.round(e.scrollTop)===v&&(s=Ld(e)<=$d,o=v),h(),x}function z9(e,t,n={}){if(!e||!(t>0))return()=>{};const r=n.now??(()=>Date.now()),s=n.window??D9,o=r();let i=!0;const a=Aw(e);a.live+=1,a.placed=null;const c=()=>{if(!i)return;const m=Math.min(t,Np(e));Math.round(e.scrollTop)!==m&&(e.scrollTop=m),m>=t&&p()},u=["wheel","touchstart","keydown","mousedown"],d=globalThis.ResizeObserver,h=d?new d(()=>c()):null,f=setInterval(()=>{if(r()-o>=s){p();return}c()},100);function p(){if(i){i=!1,a.live=Math.max(0,a.live-1),a.placed=Math.round(e.scrollTop),h==null||h.disconnect(),clearInterval(f);for(const m of u)e.removeEventListener(m,p)}}for(const m of u)e.addEventListener(m,p,{passive:!0});return h&&(h.observe(e),e.firstElementChild&&h.observe(e.firstElementChild)),c(),p}function F9(e){return e.scrollHeight-e.clientHeight>1}function B9(e,t){return e===null?null:t?e:null}const _9=130;function W9(e){return/^\s*\d+[.)]\s/.test(e)||/^\s*[-*+]\s/.test(e)||/^!\[[^\]]*\]\([^)]*\)$/.test(e)||/^>/.test(e)||/^([-*_]\s*){3,}$/.test(e)}function H9(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/[*_`#]/g,"").replace(/\s+/g," ").trim()}const U9=/where we were|^\s*gist\s*$/i;function RR(e){const t=e[ip(e)]??"",n=(e.title??"").replace(/…$/,"").trim();let r="";for(const s of t.split(`
|
|
669
|
+
`)){let o=s.trim();if(!o)continue;if(/^#{1,4}\s/.test(o)){r=o.replace(/^#{1,4}\s*/,"");continue}if(W9(o)||U9.test(r))continue;n&&o.startsWith(n)&&(o=o.slice(n.length).trim());const i=o.match(/^\*\*(.+?)\*\*/),a=H9(i?i[1]:o);if(a)return a}return""}function K9(e){return zs(RR(e),_9)}function V9(e,t,n){return e?t.length>e.length?!0:!!n&&n.scrollHeight-n.clientHeight>1:!1}const Mj={Bash:"ran",Read:"read",Write:"wrote",Edit:"changed",MultiEdit:"changed",NotebookEdit:"changed",Glob:"looked for",Grep:"searched for",WebFetch:"fetched",WebSearch:"searched the web for",Task:"sent off a helper",TodoWrite:"kept its list",ListAgents:"listed the other sessions",SendMessage:"messaged",ToolSearch:"looked up a tool",Skill:"used a skill",AskUserQuestion:"asked a question",BashOutput:"checked on a command",KillShell:"stopped a command",ExitPlanMode:"finished planning"};function q9(e){const t=String(e??"").trim();return t?Mj[t]?Mj[t]:(t.startsWith("mcp__")?t.slice(t.lastIndexOf("__")+2):t).replace(/_+/g," ").trim().toLowerCase()||"did something":"did something"}const Rj=3;function Ll(e,t="",n=""){const r=String(e??"").trim();if(!r)return"";if(!r.startsWith("/")&&!r.startsWith("~"))return r;let s=r;s=s.replace(/^\/private\/tmp\//,"/tmp/");const o=String(t??"").replace(/^\/private\/tmp\//,"/tmp/").replace(/\/+$/,"");if(o&&(s===o||s.startsWith(`${o}/`))){const a=s===o?"":s.slice(o.length+1);return a?Ij(a):"./"}const i=String(n??"").replace(/\/+$/,"");return i&&s.startsWith(`${i}/`)&&(s=`~/${s.slice(i.length+1)}`),Ij(s)}function Ij(e){const t=e.startsWith("~/")?"~/":e.startsWith("/")?"/":"",r=e.slice(t.length).split("/").filter(Boolean);return r.length<=Rj?t+r.join("/"):`…/${r.slice(-Rj).join("/")}`}const Y9=[/^cd\s+(?:"[^"]*"|'[^']*'|[^\s;&|]+)\s*(?:&&|;|\n)\s*/,/^export\s+[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|'[^']*'|[^\s;&]*)\s*(?:&&|;|\n)\s*/,/^[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|'[^']*'|[^\s;&]*)\s*(?:&&|;|\n)\s*/,/^(?:source|\.)\s+(?:"[^"]*"|'[^']*'|[^\s;&|]+)\s*(?:&&|;|\n)\s*/,/^echo\s+(?:"[^"]*(?:===|---)[^"]*"|'[^']*(?:===|---)[^']*')\s*(?:&&|;|\n)\s*/],G9=/<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1([\s\S]*)$/,J9=12;function X9(e,t){for(const n of String(e??"").split(`
|
|
670
|
+
`)){const r=n.trim();if(!(!r||r===t)&&!(r.startsWith("#")||r.startsWith("//")))return r}return""}function IR(e){let t=String(e??"").trim();if(!t)return"";const n=t;for(let s=0;s<6;s+=1){const o=t;for(const i of Y9)t=t.replace(i,"");if(t===o)break}const r=t.match(G9);if(r){const s=t.slice(0,r.index).trim(),o=s.length<=J9?X9(r[3],r[2]):"";t=o?`${s} … ${o}`:`${s} …`}return t=t.replace(/\s+/g," ").trim(),t||n.replace(/\s+/g," ").trim()}const Q9=new Set(["claim_work_item","release_work_item","update_work_item","list_work_items","list_documents","list_products","list_skills","list_chats","get_product"]);function Z9(e){const t=String(e??"").trim();return t?t==="ToolSearch"?!0:Q9.has(t.startsWith("mcp__")?t.slice(t.lastIndexOf("__")+2):t):!1}const eq=new Set(["echo","cd","pwd","true","false",":","sleep","clear","date","printf","set"]),tq=/^[0-9]*>>?&?(?:[0-9]+|\/dev\/null)$/,nq=[{verb:"read",doing:"Reading",heads:["cat","head","tail","less","more","nl","bat"],take:"files",skip:["-n","-c","-m"]},{verb:"counted the lines in",doing:"Counting the lines in",heads:["wc"],take:"files"},{verb:"searched for",doing:"Searching for",heads:["grep","rg","ag","ack"],take:"first",many:"things",skip:["-e","-m","-A","-B","-C"]},{verb:"listed",doing:"Listing",heads:["ls"],take:"files",empty:"./",many:"folders"},{verb:"looked for",doing:"Looking for",heads:["find","fd"],take:"named",many:"things"},{verb:"copied",doing:"Copying",heads:["cp"],take:"files"},{verb:"moved",doing:"Moving",heads:["mv"],take:"files"},{verb:"deleted",doing:"Deleting",heads:["rm"],take:"files"},{verb:"made a folder",doing:"Making a folder",heads:["mkdir"],take:"files",many:"folders",plural:{verb:"made folders",doing:"Making folders"}},{verb:"made a file",doing:"Making a file",heads:["touch"],take:"files",plural:{verb:"made files",doing:"Making files"}},{verb:"fetched",doing:"Fetching",heads:["curl","wget"],take:"url",many:"pages",skip:["-o","-w","-H","-X","-d","-u","-A","-e","-F","--output","--header","--data"]}],DR=new Map;for(const e of nq)for(const t of e.heads)DR.set(t,e);const rq={status:{verb:"checked what changed",doing:"Checking what changed"},diff:{verb:"checked what changed",doing:"Checking what changed"},log:{verb:"read the code history",doing:"Reading the code history"},show:{verb:"read the code history",doing:"Reading the code history"},blame:{verb:"read the code history",doing:"Reading the code history"},add:{verb:"saved the changes",doing:"Saving the changes"},commit:{verb:"saved the changes",doing:"Saving the changes"},branch:{verb:"looked at the branches",doing:"Looking at the branches"},push:{verb:"pushed the branch",doing:"Pushing the branch"},fetch:{verb:"fetched the latest code",doing:"Fetching the latest code"},pull:{verb:"fetched the latest code",doing:"Fetching the latest code"},merge:{verb:"merged the branch",doing:"Merging the branch"},checkout:{verb:"switched branch",doing:"Switching branch"},switch:{verb:"switched branch",doing:"Switching branch"}},sq={verb:"ran the tests",doing:"Running the tests",many:"test files"},Dj={verb:"ran a script",doing:"Running a script",many:"scripts"},oq=new Set(["npx","npm","pnpm","yarn","bun"]),iq=new Set(["sh","bash","zsh","/bin/sh","/bin/bash","/bin/zsh"]),OR=new Set(["node","python","python3","ruby","osascript","deno","tsx"]),LR=new Set(["vitest","jest","pytest","mocha","ava"]),aq=/\.(?:test|spec)\.[a-z]+$/,$R=e=>String(e).split("/").filter(Boolean).pop()??"";function ir(e){const t=String(e);return t.length>1&&(t[0]==='"'||t[0]==="'")&&t[t.length-1]===t[0]?t.slice(1,-1):t}function Tw(e,t){const n=[];let r="",s="";for(let o=0;o<e.length;o+=1){const i=e[o];if(s){r+=i,i===s&&(s="");continue}if(i==='"'||i==="'"){s=i,r+=i;continue}const a=e.slice(o,o+2);if(t.includes(a)){n.push(r),r="",o+=1;continue}if(t.includes(i)){n.push(r),r="";continue}r+=i}return n.push(r),n.map(o=>o.trim()).filter(Boolean)}const lq=e=>Tw(e,[" "," "]),Wu=e=>e.startsWith("-")&&e!=="-",Ep=e=>/[./]/.test(e)&&!e.startsWith("-");function Kc(e,t=[]){const n=[];for(let r=0;r<e.length;r+=1){const s=e[r],o=s[0]==='"'||s[0]==="'",i=ir(s);if(!o){if(tq.test(i))continue;if(/[<>`]/.test(i)||i.includes("$("))return null}if(Wu(i)){t.includes(i)&&(r+=1);continue}n.push(i)}return n}function $x(e,t,n){const r=lq(e);if(!r.length)return"noise";const s=ir(r[0]),o=r.slice(1);if(eq.has(s))return Kc(o)===null?null:"noise";if(s==="timeout"||s==="nice"||s==="arch"||s==="env"){const c=o.filter(u=>!Wu(ir(u))&&!/^[0-9]+$/.test(ir(u)));return c.length?$x(c.join(" "),t,n):null}if(iq.has(s)){const c=o.findIndex(d=>/^-[a-z]*c$/.test(ir(d)));if(c<0||!o[c+1])return null;const u=zR(ir(o[c+1]),t,n);return u?{...u,names:u.subject?[u.subject]:[],whole:!0}:null}if(s==="git")return dq(o,t,n);if(s==="sed"||s==="perl")return mq(o,t,n);if(oq.has(s))return gq(o,t,n);if(OR.has(s)||/\.(?:sh|mjs|js|py)$/.test(s)){const c=Kc(o);if(c===null)return null;if(e.includes("…")){const d=e.slice(e.lastIndexOf("…")+1).trim();return{...Dj,names:d?[d]:[]}}const u=c.find(Ep);return{...Dj,names:u?[$R(u)]:[]}}if(LR.has(s))return PR(o);if(s==="tsc")return{verb:"checked the types",doing:"Checking the types",names:[]};if(s==="eslint")return{verb:"checked the code style",doing:"Checking the code style",names:[]};const i=DR.get(s);if(!i)return null;const a=Kc(o,i.skip);return a===null?null:{...i,names:uq(i,a,t,n)}}const cq=/^(?:https?:\/\/|www\.|localhost|127\.0\.0\.1)/;function uq(e,t,n,r){if(e.take==="first")return t.slice(0,1);if(e.take==="url"){const o=t.find(i=>cq.test(i));return o?[o]:t.slice(0,1)}if(e.take==="named"){const o=t.find(i=>/[*?]/.test(i));return o?[o]:t.slice(0,1).map(i=>Ll(i,n,r))}const s=t.filter(Ep).map(o=>Ll(o,n,r));return s.length?s:e.empty?[e.empty]:[]}function dq(e,t,n){const r=[...e];for(;r.length&&Wu(ir(r[0]));){const i=ir(r.shift());(i==="-C"||i==="--git-dir"||i==="--work-tree")&&r.shift()}const s=ir(r[0]??""),o=rq[s];return o?{...o,names:fq(s,r.slice(1),t,n)}:null}const hq=new Set(["origin","upstream",".","--","HEAD"]);function fq(e,t,n,r){if(e==="commit"){const i=t.findIndex(c=>ir(c)==="-m"||ir(c)==="--message"),a=i>=0?ir(t[i+1]??""):"";return a?[a]:[]}const s=Kc(t,["-m","--message","-C","-S"]);if(s===null)return[];if(e==="push"||e==="merge"||e==="checkout"||e==="switch"||e==="fetch"||e==="pull"){const i=s.filter(a=>a&&!hq.has(a));return i.length?[i[i.length-1]]:[]}const o=s.filter(Ep).map(i=>Ll(i,n,r));return o.length?o:s.length?[s[0]]:[]}const pq=/^['"]?[0-9,$]*[a-zA-Z]?[/#|]/;function mq(e,t,n){const r=Kc(e);if(r===null)return null;const s=e.map(ir).filter(Wu),o=s.some(a=>a.startsWith("-i")),i=[...r].reverse().find(a=>Ep(a)&&!pq.test(a));return o?i?{verb:"changed",doing:"Changing",names:[Ll(i,t,n)]}:null:s.some(a=>a==="-n"||a==="-e"||a==="-E")&&i?{verb:"read",doing:"Reading",names:[Ll(i,t,n)]}:null}function gq(e,t,n){const r=e.map(ir).filter(o=>o!=="--yes"&&o!=="-y"&&o!=="-s");let s=r[0]??"";return(s==="run"||s==="exec")&&(s=r[1]??""),s=s.replace(/@[^@/]*$/,""),s==="test"||LR.has(s)?PR(r.slice(1)):s==="tsc"||s==="typecheck"?{verb:"checked the types",doing:"Checking the types",names:[]}:s==="eslint"||s==="lint"?{verb:"checked the code style",doing:"Checking the code style",names:[]}:s==="build"||s==="vite"&&r.includes("build")?{verb:"built the app",doing:"Building the app",names:[]}:s==="install"||s==="ci"||s==="i"?{verb:"installed the packages",doing:"Installing the packages",names:[]}:OR.has(s)?$x(r.join(" "),t,n):null}function PR(e){const n=e.map(ir).filter(r=>!Wu(r)&&r!=="run").filter(r=>aq.test(r)||r.includes("/"));return{...sq,names:n.map($R)}}function yq(e,t="files"){const n=[...new Set(e.filter(Boolean))];return n.length?n.length>3?`${n.length} ${t}`:n.length===1?n[0]:`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`:""}function zR(e,t="",n=""){const r=IR(e);if(!r)return null;const s=[];for(const c of Tw(r,["&&","||",";",`
|
|
671
|
+
`])){const u=Tw(c,["|"])[0]??"",d=$x(u,t,n);if(d===null)return null;d!=="noise"&&s.push(d)}if(!s.length)return null;const o=s[0];if(s.some(c=>c.verb!==o.verb))return null;if(o.whole)return{verb:o.verb,doing:o.doing,subject:o.names[0]??""};const i=[...new Set(s.flatMap(c=>c.names).filter(Boolean))],a=i.length>1&&o.plural?o.plural:o;return{verb:a.verb,doing:a.doing,subject:yq(i,o.many)}}const wq=3;function bq(e,{min:t=wq}={}){const n=[];let r=[];const s=()=>{r.length&&(r.length>=t?n.push({kind:"run",at:r[0].at??0,items:r}):n.push(...r),r=[])};for(const o of e??[]){if(o&&o.kind==="work"&&!o.yours&&!o.standalone){r.push(o);continue}s(),n.push(o)}return s(),n}const xq=new Set(["ran","read","wrote","edited","looked for","searched for","fetched","messaged"]),Oj=3;function kq(e){const t=(e??[]).filter(Boolean);if(!t.length)return"";const n=new Map;for(const i of t)n.set(i.verb,(n.get(i.verb)??0)+1);const r=[...n.entries()].sort((i,a)=>a[1]-i[1]||i[0].localeCompare(a[0]));if(r.length===1&&xq.has(r[0][0]))return`${t.length} thing${t.length===1?"":"s"} it ${r[0][0]}`;const s=r.slice(0,Oj).map(([i,a])=>a===1?i:`${i} ${a}`),o=r.slice(Oj).reduce((i,[,a])=>i+a,0);return o&&s.push(`${o} more`),`${t.length} things it did · ${s.join(" · ")}`}function vq(e){const t=(e??[]).filter(n=>n&&n.failed).length;return t?`${t} failed`:""}const Sq=new Set(["Edit","Write","MultiEdit","NotebookEdit"]);function jq(e,t){if(!Sq.has(String(e??"")))return"";const n=t??{};return String(n.file_path??n.notebook_path??"").trim()}function Cq(e,t){const n=String(t??"").trim().replace(/^\/private\/tmp\//,"/tmp/");if(!n)return null;let r=null;for(const s of e??[]){const o=String(s??"").trim();!o||!(o===n||n.endsWith(`/${o}`)||o.replace(/^\/private\/tmp\//,"/tmp/")===n)||(!r||o.length>r.length)&&(r=s)}return r}function $l(e){return e.status==="waiting"}function Ap(e){return $l(e)&&e.waitingFor==="input needed"}function Nq(e){return(e==null?void 0:e.waitingFor)==="permission prompt"}function Tp(e){const t=(e==null?void 0:e.repliedAt)??0;return!t||!(e!=null&&e.status)||FR(e)?!1:!Eq(e,t)}function Eq(e,t){return((e==null?void 0:e.statusAt)??0)<=t?!1:(e==null?void 0:e.status)==="idle"||(e==null?void 0:e.status)==="waiting"}function Pd(e){return e!=null&&e.sessionId?`session:${e.sessionId}`:`pid:${(e==null?void 0:e.pid)??0}:${(e==null?void 0:e.startedAt)??0}`}function Aq(e,t=Date.now()){return((e==null?void 0:e.runAt)??0)>t}function FR(e){return((e==null?void 0:e.doneThrough)??0)>0}function Px(e){if(!Number.isFinite(e)||e<0)return"a moment";const t=Math.floor(e/864e5);if(t>=1)return`${t} day${t===1?"":"s"}`;const n=Math.floor(e/36e5);if(n>=1)return`${n} hour${n===1?"":"s"}`;const r=Math.max(1,Math.floor(e/6e4));return`${r} minute${r===1?"":"s"}`}function BR(e){const t=e.productName;return t||(e.cwd??"").split("/").filter(Boolean).pop()||"an unknown folder"}function _R(e){return String(e??"").replace(/```[\s\S]*?```/g," ").replace(/\[Image[^\]]*\]/g," ").replace(/[*_`#>]/g,"").replace(/\s+/g," ").replace(/ +([.,;:!?])/g,"$1").trim()}function sf(e,t=180){const n=_R(e);if(!n)return"";if(n.length<=t)return n;const r=n.slice(0,t+1),s=Math.max(r.lastIndexOf(". "),r.lastIndexOf("? "),r.lastIndexOf("! "));return s>40?n.slice(0,s+1):`${n.slice(0,r.lastIndexOf(" ")>40?r.lastIndexOf(" "):t).trimEnd()}…`}function Tq(e,t=180){return sf(e.lastSaid,t)}function Mq(e,t=320){const n=_R(e);if(!n)return"";if(n.length<=t)return n;const r=n.slice(-t),s=[r.indexOf(". "),r.indexOf("? "),r.indexOf("! ")].filter(a=>a>=0),o=s.length?Math.min(...s)+2:-1;return`…${(o>=0&&o<t-40?r.slice(o):r.slice(r.indexOf(" ")+1)).trim()}`}function Rq(e,t){const n=Number(e==null?void 0:e.saidAt)||0;if(!n)return"**It stopped here:**";const r=Mw(n,t),s=Math.max(Number(e==null?void 0:e.repliedAt)||0,...WR(e).map(o=>Number(o==null?void 0:o.at)||0));return s&&s>n?`**It has not answered yet. It last spoke ${r}:**`:`**It answered ${r}:**`}function Iq(e,t=180){return sf(e.lastAsked,t)}function zx(e){return String((e==null?void 0:e.about)??"").replace(/\s+/g," ").trim()}function Dq(e,t=Date.now()){const n=zx(e);return n?`${e.name}: ${n}`:Ap(e)?`${e.name} is waiting for you`:$l(e)?`${e.name} needs you where it is running`:Tp(e)?`${e.name} is working on what you told it`:`${e.name} has been quiet for ${Px(t-(e.lastActiveAt??e.startedAt??t))}`}function WR(e){const t=((e==null?void 0:e.asked)??[]).filter(a=>a&&a.text),n=((e==null?void 0:e.spoke)??[]).filter(a=>a&&a.text);if(!n.length||!t.length)return t;const r=new Set(t.map(a=>a.text.replace(/\s+/g," ").trim())),s=[...t];for(const a of n){const c=String(a.text).replace(/\s+/g," ").trim();r.has(c)||(r.add(c),s.push({at:a.at,text:c}))}const[o,...i]=s;return i.sort((a,c)=>(a.at??0)-(c.at??0)),o?[o,...i]:[]}const Oq=60;function Lq(e){const t=e.filter(n=>n.text.length>=Oq);return t.length?t:e}function Mw(e,t){if(!e)return"";const n=t-e;return n<0||n<9e4?"just now":`${Px(n)} ago`}function $q(e,t=Date.now()){const n=WR(e),r=Mq(e.lastSaid),s=BR(e),o=[],[i,...a]=n;if(i){const u=Mw(i.at,t);o.push(`**You started it${u?` ${u}`:""} with:**
|
|
672
|
+
|
|
673
|
+
“${sf(i.text,420)}”`)}else{const u=Iq(e);u&&o.push(`**The last thing you told it:**
|
|
674
|
+
|
|
675
|
+
“${u}”`)}if(a.length){const u=Lq(a).slice(-3),d=u.map(f=>{const p=Mw(f.at,t);return`- ${p?`${p}: `:""}“${sf(f.text,260)}”`}),h=a.length>u.length?`, over ${a.length} more messages,`:"";o.push(`**Then${h} you said:**
|
|
676
|
+
|
|
677
|
+
${d.join(`
|
|
678
|
+
`)}`)}r&&o.push(`${Rq(e,t)}
|
|
679
|
+
|
|
680
|
+
“${r}”`);const c=(e.touched??[]).slice(-3);return o.push(c.length?`It is working in ${s}, in ${Pq(c)}.`:`It is working in ${s}.`),`
|
|
681
|
+
|
|
682
|
+
${o.join(`
|
|
683
|
+
|
|
684
|
+
`)}`}function Pq(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function zq(e,t=Date.now()){const n=Px(t-(e.lastActiveAt??e.startedAt??t)),r=Dq(e,t),s=$q(e,t);return Tp(e)?{title:r,body:`**You replied, and ${e.name} is working on it.**
|
|
685
|
+
|
|
686
|
+
It comes back to your inbox when it stops, whether it finishes or asks you something. Nothing here needs you meanwhile.${s}`}:Ap(e)?{title:r,body:`**Reply to ${e.name}, which has been waiting ${n}.**
|
|
687
|
+
|
|
688
|
+
It finished what it was doing and stopped for an answer. Whatever you type here goes straight into it.${s}`}:$l(e)?{title:r,body:`**Answer ${e.name} in its own window, not here.**
|
|
689
|
+
|
|
690
|
+
It is asking to approve something, and a message from ${Je} would wait behind that box instead of clearing it.${s}`}:{title:r,body:`**Close ${e.name} if you no longer need it here.**
|
|
691
|
+
|
|
692
|
+
It is asking for nothing and has done nothing for ${n}. Closing it takes it out of your inbox and leaves the session running.${s}`}}function Fq(e,t=Date.now(),n="all"){return e.startedByZero||n==="off"||Tp(e)||!$l(e)&&!zx(e)||n==="waiting"&&!$l(e)?!1:!Aq(e,t)&&!FR(e)}function Bq(e,t=Date.now(),n="all"){return e.startedByZero||n==="off"?!1:Tp(e)}function HR(e){return!e.startedByZero}const _q=24*60*60*1e3;function Wq(e,t=Date.now()){if(!HR(e))return!1;const n=e.lastActiveAt||e.startedAt||0;return n>0&&t-n<=_q}function Hq(e){return zx(e)||Tq(e)||"Has not said anything yet"}function Uq(e,t){return(t.lastActiveAt??0)-(e.lastActiveAt??0)}const UR=3,Kq=40;function Vq(e){return e?`Show the ${e} message${e===1?"":"s"} in between`:""}const qq=20,Yq=200;function Gq(e){return e?`and ${e} more thing${e===1?"":"s"} it ran, not shown`:""}function Lj(e,t){return!t||t<=e?"":`${t-e} more line${t-e===1?"":"s"} came back, not kept`}function Jq(e,{opening:t=UR,keep:n=Kq,whole:r=!1}={}){const s=(e??[]).filter(d=>d&&(d.kind==="work"?!0:!!d.text)),o=[];if(s.forEach((d,h)=>{d.kind!=="work"&&o.push(h)}),r||o.length<=n)return{events:$j(s),omitted:0};const i=o[t],a=o[o.length-(n-t)],c=s.slice(a);c.length&&c[0].kind!=="work"&&c[0].same&&(c[0]={...c[0],resumed:!0});const u=[...s.slice(0,i),...c];return{events:$j(u),omitted:o.length-n}}function Xq(e,t,{opening:n=UR}={}){if(!t)return-1;let r=0;for(let s=0;s<((e==null?void 0:e.length)??0);s+=1)if(e[s].kind!=="work"&&(r+=1,r===n+1))return s-1;return((e==null?void 0:e.length)??0)-1}function $j(e,{run:t=qq,total:n=Yq}={}){const r=[];let s=0,o=0;for(const u of e){if(u.kind!=="work"){o&&(r[r.length-1]={...r[r.length-1],more:o},o=0),s=0,r.push(u);continue}if(s+=1,s>t){o+=1;continue}r.push(u)}o&&(r[r.length-1]={...r[r.length-1],more:o});const i=r.filter(u=>u.kind==="work").length;if(i<=n)return r;let a=i-n;const c=[];for(const u of r){if(a&&u.kind==="work"&&!u.more){a-=1;continue}c.push(u)}return c}function yg(e){let t=0;for(const n of e??[])!n||n.kind==="work"||!n.text||n.same||(t+=1);return t}const Qq=/<\/(?:antml:)?(?:result|invoke|parameter|function_calls)>|<(?:antml:)?parameter\s+name=/;function Zq(e){const t=[];let n=0;for(;n<e.length;){if(e.startsWith("```",n)){const o=e.indexOf("```",n+3),i=o<0?e.length:o+3;t.push([n,i]),n=i;continue}if(e[n]==="`"){const o=e.indexOf("`",n+1),i=o<0?n+1:o+1;t.push([n,i]),n=i;continue}n+=1}const r=new RegExp(Qq.source,"g");let s=r.exec(e);for(;s;){if(!t.some(([o,i])=>s.index>=o&&s.index<i))return s.index;s=r.exec(e)}return-1}function e7(e){if(typeof e!="string")return e;const t=Zq(e);return t<0?e:e.slice(0,t).trimEnd()}function wg(e){const t=e==null?void 0:e.trim();return t&&t!=="(withdrawn)"?t:null}function Pj(e,t){var n,r;return((r=(n=e.wrote)==null?void 0:n[t])==null?void 0:r.ts)??e.updatedAt}function t7(e){var t,n;return e.status!=="done"?null:((n=(t=e.wrote)==null?void 0:t.status)==null?void 0:n.source)==="founder"?"founder":"agent"}function n7(e){var t;return t7(e)==="agent"&&!!((t=e.result)!=null&&t.trim())}function zj(e,t){const n=wg(e.answer);if(n)return{kind:"replied",text:n,at:Pj(e,"answer")};if(!t)return null;const r=wg(t.answer);return r?{kind:"said",text:r,at:Pj(t,"answer"),on:t.title}:t.kind==="directive"?{kind:"said",text:wg(t.body)??t.title,at:t.createdAt,on:t.title}:{kind:"origin",title:t.title,at:t.updatedAt}}function KR(e,t){var n,r;return e.agent||t.session||(n=t.runNow)!=null&&n.includes(e.id)?!1:!!((r=t.queued)!=null&&r.includes(e.id))||!!t.inProgress}function r7(e,t,n){return KR(e,t)?[{id:"run-now",label:"Run Now",keywords:"start go next urgent jump queue",run:n}]:[]}const s7=e=>e.dataBase64?`data:image/png;base64,${e.dataBase64}`:e.srcPath?vo(e.srcPath):"";function VR({attachments:e,onRemove:t}){return e.length?l.jsx("div",{className:"attach-row",children:e.map((n,r)=>n.image?l.jsxs("div",{className:"attach-thumb",title:n.name,children:[l.jsx("img",{src:s7(n),alt:n.name}),l.jsx("button",{className:"attach-remove",onClick:()=>t(r),children:"×"})]},r):l.jsxs("button",{className:"attach-chip",title:"Remove",onClick:()=>t(r),children:[n.name," ×"]},r))}):null}const bg=44;function o7(e){const t=e.trim();if(t.length<=bg)return t.replace(/[,;:.\s]+$/,"");const n=t.slice(0,bg),r=n.lastIndexOf(" ");return`${(r>bg/2?n.slice(0,r):n).replace(/[,;:.\s]+$/,"")}…`}function i7({title:e,onBack:t}){return l.jsxs("div",{className:"urgent-bar",children:[l.jsxs("button",{className:"urgent-return",onClick:t,children:[l.jsx("span",{className:"urgent-return-arrow",children:"←"})," Back to ",o7(e)]}),l.jsx("span",{className:"urgent-word",children:"Urgent"})]})}const a7={ran:"ran commands",read:"read files",wrote:"wrote files",changed:"changed files",deleted:"deleted files","searched for":"searched files","looked for":"looked for files",fetched:"read web pages"};function l7(e){if(!e.length)return"";const t=e.length===1?`${e[0].verb} ${e[0].subject||""}`.trim():[...new Set(e.map(n=>a7[n.verb]||n.verb))].join(", ");return t.charAt(0).toUpperCase()+t.slice(1)}function Mp(e){(e.key==="Enter"||e.key===" ")&&e.stopPropagation()}function c7(e){let t=0;return e.forEach((n,r)=>{n.kind!=="work"&&(t=r+1)}),e.slice(t).filter(n=>n.kind==="work")}function u7(e,t){const n=[...e],r=s=>s.replace(/\s+/g," ").trim();for(const s of t)for(let o=n.length-1;o>=0;o--){const i=n[o];if(!(i.at!=null&&s.startedAt!=null&&i.at<s.startedAt-1e3)&&r(i.full||i.subject||"")===r(s.detail)){n.splice(o,1);break}}return n}function d7(e,t){const n=(e.subject??"").trim();if(/^Undid\b/.test(e.verb))return{lead:t?`${t} ${e.verb.replace(/^Undid/,"undid")}`:e.verb,choice:n||null,picked:!1};const r=/^You picked option \d+$/.test(e.verb);let s=r?"picked":e.verb.replace(/^You\s+/,"").replace(/^moved it to Later$/,"moved to Later");return!r&&n&&(s+=/^was\b/.test(n)?`, ${n}`:` ${n}`),{lead:t?`${t} ${s}`:s.charAt(0).toUpperCase()+s.slice(1),choice:r?n:null,picked:r}}function Fj(e){const t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()}function h7(e,t=Date.now()){if(!e)return"";const n=Math.round((Fj(t)-Fj(e))/864e5),r=new Date(e),s=r.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}).replace(/\s/g,"");return`${n<=0?"Today":n===1?"Yesterday":n<7?r.toLocaleDateString("en-US",{weekday:"short"}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})} ${s}`.toUpperCase()}function f7(e,t=-1){let n=null;return e.map((r,s)=>{if(s>0&&s-1===t&&(n=null),r.kind==="run"||r.kind==="work")return!1;const o=r.who==="you"&&n!=="you"&&s>0;return n=r.who??null,o})}function p7(e,t=-1){const n=r=>r.kind!=="run"&&r.kind!=="work";return e.map((r,s)=>{if(!n(r)||r.who!=="you")return!1;for(let o=s+1;o<e.length;o++){if(o-1===t)return!0;if(n(e[o]))return e[o].who!=="you"}return s<e.length-1})}const m7=/^!\[[^\]\n]*\]\([^)\s]+\)$/,g7=/^\[[^\]\n]*\]\(attachments\/[^)\s]+\)$/,y7=e=>m7.test(e.trim())||g7.test(e.trim());function w7(e){const t=[];let n=[];const r=()=>{const s=n.join(`
|
|
693
|
+
`).replace(/^\n+|\n+$/g,"");s.trim()&&t.push({text:s}),n=[]};for(const s of e.split(`
|
|
694
|
+
`))y7(s)?(r(),t.push({embed:s.trim()})):n.push(s);return r(),t.some(s=>"embed"in s)?t:[{text:e}]}function fn(e){const t=typeof e=="string"?e.trim():"";return t&&t!=="(withdrawn)"?t:null}function Rr(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function b7(e,t){const n=Math.round((of(e)-of(t))/864e5),r=Pl(e);return n<=0?`until ${r}`:n===1?`until tomorrow ${r}`:n<7?`until ${new Date(e).toLocaleDateString(void 0,{weekday:"short"})} ${r}`:`until ${new Date(e).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})} ${r}`}const x7=/^Option (\d+): ([^\n]+)$/,k7=6e4,v7=6e4;function S7(e,t){var b,x,v,S,C;const n=[];let r=null,s=!0,o=!1;const i=(t??In)===In;let a=!1,c=null,u=null,d=0,h,f,p,m=null;const w=()=>{for(let O=d;O<n.length;O+=1)h&&!n[O].by&&(n[O].by=h),f&&!n[O].uid&&(n[O].uid=f),p&&n[O].message&&!n[O].inReplyTo&&(n[O].inReplyTo=p)};for(const[O,N]of e.entries()){w(),d=n.length,h=typeof N.by=="string"?N.by:void 0,f=typeof N.uid=="string"?N.uid:void 0;const P=(b=N.patch)==null?void 0:b.inReplyTo;p=typeof P=="string"&&P?P:void 0;const M=N.patch??null;Rr(M,"label")&&(u=String(M.label??""));const R=N.source==="founder",L=R?"you":"agent",H=N.ts;if(!(N.heartbeat||N.release)){if(N.claim){n.push({at:H,who:"agent",said:"An agent picked it up",pickup:!0});continue}if(s&&Rr(M,"title")){const _=e[O+1],Y=!N.by&&!(_!=null&&_.by)&&String(((x=_==null?void 0:_.patch)==null?void 0:x.title)??"")===String(M.title??"")&&Math.abs(Number(_==null?void 0:_.ts)-Number(N.ts))<=v7,se=N.source==="system"&&!fn(M.body)&&(_==null?void 0:_.source)==="founder"&&(N.by?_.by===N.by:Y);if(se&&Rr(_.patch,"title")||(s=!1,r=String(M.title??""),fn(M.body)&&(o=!0),se&&fn((v=_.patch)==null?void 0:v.body)))continue;n.push({at:H,who:L,said:R?"You opened this":"An agent opened this",...fn(M.body)?{words:fn(M.body),message:!0,field:"body"}:{}});continue}if(!(!M||!Object.keys(M).length)){if(Array.isArray(M.labels)&&M.labels.includes("codex")&&M.labels.some(_=>typeof _=="string"&&_.startsWith("codex:"))&&c){const _=n.findIndex(se=>se.field==="body");_>=0&&n[_].who==="agent"&&(n[_]={...n[_],who:"you",said:"You opened this",words:c});const Y=n.findIndex(se=>se.said==="An agent opened this"&&!se.field);Y>=0&&(n[Y]={...n[Y],said:"Brought in from Codex"})}if(!o&&fn(M.body)&&!Rr(M,"answer")&&!fn(M.result)&&!fn(M.note)){o=!0,Rr(M,"title")&&(r=String(M.title??"")),n.push({at:H,who:L,said:R?"You opened this":"An agent opened this",words:fn(M.body),message:!0,field:"body"});continue}if(o&&fn(M.body)&&!Rr(M,"answer")&&!fn(M.result)&&!fn(M.note)){const _=n.findIndex(Y=>Y.field==="body");if(_>=0&&n[_].who===L){const Y=fn(M.body);n[_].words!==Y&&(n[_]={...n[_],words:Y})}if(R&&(c=fn(M.body)),!Rr(M,"title"))continue}if(Rr(M,"answer")){const _=fn(M.answer);m=R&&_?{at:H,by:h}:null,a=i&&!!_&&jA(_)!==null;const Y=_?x7.exec(_):null;if(Y){n.push({at:H,who:"you",said:`You picked option ${Y[1]}`,words:Y[2].replace(/\s*\(recommended\)\s*$/i,"").trim(),field:"answer",answers:!0});continue}n.push(_?{at:H,who:"you",said:"You replied",words:_,message:!0,field:"answer"}:{at:H,who:"you",said:"You withdrew your reply"});continue}if(fn(M.result)){n.push({at:H,who:"agent",said:"It came back to you",words:fn(M.result),message:!0,field:"result"});continue}if(fn(M.note)){n.push({at:H,who:"agent",said:"It checked in",words:fn(M.note),message:!0,field:"note"});continue}if(Rr(M,"title")&&String(M.title??"")!==r){const _=r;r=String(M.title??""),n.push({at:H,who:L,said:R?"You renamed it":"It renamed itself",..._?{words:`was "${_}"`}:{}});continue}if(Rr(M,"snoozedUntil")||Rr(M,"runAt")){const _=Number(Rr(M,"snoozedUntil")?M.snoozedUntil:M.runAt)||0;if(_)n.push({at:H,who:L,said:R?"You moved it to Later":"It paused this",words:b7(_,H)});else{if(R&&m&&m.by===h&&H-m.at<=k7)continue;n.push({at:H,who:L,said:R?"You brought it back":"It let this run now"})}continue}if(Rr(M,"status")){const _=String(M.status??"");if(_==="claimed")continue;if(_==="done"){n.push({at:H,who:L,said:R?"You marked it done":"It closed this"});continue}if(_==="blocked"){if(N.source==="system"&&!a&&((S=n.at(-1))==null?void 0:S.field)==="result"){a=!1;continue}if(R)continue;n.push({at:H,who:"agent",said:a?"It answered you":"It stopped and asked you"}),a=!1;continue}if(_==="open"){if(N.source==="system"&&((C=n.at(-1))==null?void 0:C.field)==="result")continue;n.push({at:H,who:L,said:R?"You sent it back":"It handed this back"});continue}}}}}return w(),j7(n,r,u)}function j7(e,t,n){const r=(n??"").trim(),s=(t??"").trim();if(!r||!s||r===s)return e;const o=e.findIndex(h=>h.field==="body"),i=o>=0?o:e.findIndex(h=>/opened this$/.test(h.said));if(i<0)return e;const a=h=>h.replace(/\s+/g," ").trim().toLowerCase(),c=a(s.replace(/…$/,"")).slice(0,40),u=e[i].words??"";if(c&&a(u).includes(c))return e;const d=e.slice();return d[i]={...e[i],words:u?`${s}
|
|
695
|
+
|
|
696
|
+
${u}`:s,message:!0,field:"body"},d}function C7(e,t){const n=e.filter(a=>a.pickup),r=[...t].filter(a=>a&&a.text).sort((a,c)=>a.startedAt-c.startedAt);if(!n.length||!r.length)return e;const s=r.map(()=>!1),o=new Map;for(const a of n)for(let c=r.length-1;c>=0;c-=1)if(!(s[c]||r[c].startedAt>a.at)){s[c]=!0,o.set(a,[r[c]]);break}const i=r.filter((a,c)=>!s[c]);if(i.length){const a=[...i,...o.get(n[0])??[]].sort((c,u)=>c.startedAt-u.startedAt);o.set(n[0],a)}return e.map(a=>{const c=o.get(a);if(!(c!=null&&c.length))return a;const u=c.map(d=>RF([d])).filter(d=>!!d);return u.length?{...a,runs:u}:a})}function qR(e,t=Date.now()){const n=Math.floor((of(t)-of(e))/864e5);return n===0?"Today":n===1?"Yesterday":new Date(e).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})}function Pl(e){return new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}).replace(/\s?([AP])M/i,(t,n)=>n.toLowerCase()+"m")}function of(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}const N7=10*6e4,Bj=e=>e.by??e.who??"";function E7(e,t=Date.now()){const n=[];let r=null;for(let s=0;s<e.length;s++){const o=e[s],i=qR(o.at,t),a=i===r?null:i;r=i;const c=e[s-1],u=!!c&&c.kind!=="work"&&o.kind!=="work"&&a===null&&Bj(c)===Bj(o)&&o.at-c.at<=N7;n.push({day:a,head:o.kind!=="work"&&!u})}return n}const A7=340,T7=A7+90,M7=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Fx({children:e}){const t=g.useRef(null),[n,r]=g.useState(!1),[s,o]=g.useState(!1);return M7(()=>{const i=t.current;i&&!s&&r(i.scrollHeight>T7)},[e,s]),l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:t,className:`msg-body${n&&!s?" chat-folded":""}`,children:e}),n&&l.jsx("button",{type:"button",className:"chat-more",onClick:()=>o(i=>!i),children:s?"Show less":"Show the whole message"})]})}const _j="chat-thread-dragging";function R7({grip:e,win:t,body:n,pointerId:r,onMove:s}){var d;let o=!0;const i=h=>h.pointerId==null||h.pointerId===r,a=h=>{if(i(h)){if(!h.buttons){u();return}s(h.clientX??0)}},c=h=>{i(h)&&u()};function u(){var h,f;if(o){o=!1,t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",c),t.removeEventListener("pointercancel",c),t.removeEventListener("blur",u),n.classList.remove(_j);try{(h=e.hasPointerCapture)!=null&&h.call(e,r)&&((f=e.releasePointerCapture)==null||f.call(e,r))}catch{}}}n.classList.add(_j);try{(d=e.setPointerCapture)==null||d.call(e,r)}catch{}return t.addEventListener("pointermove",a),t.addEventListener("pointerup",c),t.addEventListener("pointercancel",c),t.addEventListener("blur",u),u}const zd=typeof window>"u"?g.useEffect:g.useLayoutEffect,Wj=24;function I7({parent:e,replies:t,md:n,width:r,reactions:s,onReact:o,onSend:i,onClose:a,onResize:c}){const u=g.useContext(Xt),d=(u==null?void 0:u.me)??null,h=g.useRef(null),f=g.useRef(null),p=g.useRef(null),[m,w]=g.useState(""),[b,x]=g.useState([]);g.useEffect(()=>{x(R=>R.filter(L=>!t.some(H=>(H.by??d)===d&&H.at>=L.at-5e3&&(H.text??"").trim()===L.text.trim())))},[t,d]),g.useEffect(()=>{var R;w(""),x([]),(R=p.current)==null||R.focus()},[e.uid]),zd(()=>{var L;const R=(L=h.current)==null?void 0:L.parentElement;if(R)return R.dataset.thread="open",()=>{delete R.dataset.thread}},[]),zd(()=>{var R,L;(L=(R=h.current)==null?void 0:R.parentElement)==null||L.style.setProperty("--chat-thread-w",`${r}px`)},[r]);const v=t.length+b.length;zd(()=>{const R=f.current;R&&(R.scrollTop=R.scrollHeight)},[e.uid,v]),zd(()=>{const R=p.current;R&&(R.style.height="auto",R.style.height=`${Math.min(R.scrollHeight,200)}px`)},[m]);const S=()=>{const R=m.trim();R&&(x(L=>[...L,{at:Date.now(),text:R}]),w(""),i(R))},C=R=>{R.key==="Enter"&&!R.shiftKey&&!R.nativeEvent.isComposing&&(R.preventDefault(),S()),R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),a())},O=g.useRef(null);g.useEffect(()=>()=>{var R;return(R=O.current)==null?void 0:R.call(O)},[]);const N=R=>{var H,_;const L=(H=h.current)==null?void 0:H.getBoundingClientRect().right;L!=null&&(R.preventDefault(),(_=O.current)==null||_.call(O),O.current=R7({grip:R.currentTarget,win:window,body:document.body,pointerId:R.pointerId,onMove:Y=>c(L-Y)}))},P=R=>{R.key==="ArrowLeft"&&(R.preventDefault(),c(r+Wj)),R.key==="ArrowRight"&&(R.preventDefault(),c(r-Wj))},M=(R,L=!1)=>{const H=R.by??d,_=!!d&&H===d,Y=H?(u==null?void 0:u.byId.get(H))??null:null;return l.jsx("div",{className:"thread-block is-msg",children:l.jsxs("div",{className:`msg chat-msg${L?" sending":""}`,children:[l.jsx("div",{className:"chat-gutter",children:l.jsx(Rt,{person:Y,me:_,size:"lg"})}),l.jsxs("div",{className:"msg-head",children:[l.jsx("span",{className:"msg-who",children:_?"You":(Y==null?void 0:Y.name)??"A teammate"}),l.jsx("span",{className:"msg-when",children:Pl(R.at)})]}),l.jsx(Fx,{children:n(R.text??"")}),R.uid&&l.jsx(AR,{on:s==null?void 0:s[R.uid],me:d,onReact:(se,re)=>o==null?void 0:o(R.uid,se,re)}),R.uid&&o&&l.jsx(TR,{onReact:se=>{var re;return o(R.uid,se,(((re=s==null?void 0:s[R.uid])==null?void 0:re[se])??[]).includes(d??""))}})]})},`${R.uid??"p"}-${R.at}`)};return l.jsxs("aside",{className:"chat-thread-panel",ref:h,style:{width:r},"aria-label":"Thread",children:[l.jsx("div",{className:"chat-thread-grip",role:"separator","aria-orientation":"vertical","aria-label":"Resize thread","aria-valuemin":ai.min,"aria-valuemax":ai.max,"aria-valuenow":r,tabIndex:0,onPointerDown:N,onKeyDown:P,onDoubleClick:()=>c(ai.start),title:"Drag to resize. Double-click to reset."}),l.jsxs("div",{className:"chat-thread-head",children:[l.jsx("span",{className:"chat-thread-title",children:"Thread"}),l.jsx("button",{type:"button",className:"chat-thread-close","aria-label":"Close thread",title:"Close thread",onClick:a,children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"square","aria-hidden":"true",children:l.jsx("path",{d:"M3.5 3.5l9 9M12.5 3.5l-9 9"})})})]}),l.jsxs("div",{className:"chat-thread-body",ref:f,children:[M(e),(t.length>0||b.length>0)&&l.jsx("div",{className:"chat-day chat-thread-count",children:NR([...t,...b.map(R=>({at:R.at,who:"you",text:R.text}))]).count}),t.map(R=>M(R)),b.map(R=>M({at:R.at,text:R.text},!0))]}),l.jsx("div",{className:"chat-thread-foot",children:l.jsxs("div",{className:"chat-thread-box",children:[l.jsx("textarea",{ref:p,rows:1,value:m,placeholder:"Reply in thread…","aria-label":"Reply in thread",onChange:R=>w(R.target.value),onKeyDown:C}),l.jsx("button",{type:"button",className:"chat-thread-send",disabled:!m.trim(),onClick:S,children:"Send"})]})})]})}function D7({replies:e,open:t,onOpen:n,fresh:r=0}){const s=g.useContext(Xt),o=NR(e);return l.jsxs("button",{type:"button",className:`chat-thread-line${r?" fresh":""}${t?" open":""}`,onClick:n,"aria-expanded":t,children:[l.jsx("span",{className:"chat-thread-faces","aria-hidden":"true",children:o.faces.map(i=>l.jsx(Rt,{person:(s==null?void 0:s.byId.get(i))??null,me:i===(s==null?void 0:s.me)},i))}),l.jsx("span",{className:"chat-thread-n",children:r?`${r} new ${r===1?"reply":"replies"}`:o.count}),l.jsx("span",{className:"chat-thread-last",children:o.last})]})}function bu(){return l.jsx("span",{className:"agent-face","aria-hidden":"true",children:l.jsxs("svg",{className:"agent-eyes",viewBox:"0 0 16 16",children:[l.jsx("rect",{x:"4.5",y:"5.5",width:"2",height:"5",rx:"1"}),l.jsx("rect",{x:"9.5",y:"5.5",width:"2",height:"5",rx:"1"})]})})}function Bx({rows:e,onOpen:t,onApprove:n,onReject:r,label:s}){if(!e.length)return null;const o=c=>!!n&&!!c.approve,i=e.some(o),a=i?[...e.filter(o),...e.filter(c=>!o(c))]:e;return l.jsxs("div",{className:i?"made made-waiting":"made",children:[(i||s)&&l.jsx("div",{className:"made-label",children:i?"Still waiting on you":s}),l.jsx("div",{className:"made-list",children:a.map(c=>{const u=o(c);return l.jsxs("div",{className:"made-row",children:[l.jsxs("button",{type:"button",className:"made-open",onClick:()=>t(c.id),children:[l.jsx("span",{className:"made-title",children:c.title}),!u&&l.jsx("span",{className:`made-state ${c.state??""}`,children:$B(c.state)})]}),u&&r&&l.jsx("button",{type:"button",className:"made-reject","aria-label":`Reject: ${c.title}`,title:`Reject: ${c.title}`,onClick:()=>r(c.id),children:"No"}),u&&l.jsx("button",{type:"button",className:"made-approve","aria-label":`Approve: ${c.title}`,title:`Approve: ${c.title}`,onClick:()=>n(c.id),children:"Approve"})]},c.id)})})]})}const _x=g.createContext(null);function xg(e,t){const n={codexModels:t.codexModels,codexDefault:t.codexDefault},r=ih(globalThis.localStorage,e,t.codexDefault)??Qr(e,t.codexDefault),s=bw(globalThis.localStorage,e)??Sp(e,r,n);return{model:r||null,effort:s}}const O7=(e,t,n)=>{const r={codexModels:n.codexModels,codexDefault:n.codexDefault};return[ql(e,t.model,r),Tx(t.effort,_u(e,t.model,r))].filter(Boolean).join(" · ")},YR=e=>`zero.chatProject.${e.product}/${e.id}`,L7=(e,t)=>{var n;try{const r=(n=globalThis.localStorage)==null?void 0:n.getItem(YR(e));return t.find(s=>s.slug===r)??null}catch{return null}};function $7({on:e,where:t,text:n,setText:r,input:s,people:o}){const i=g.useContext(_x),a=e&&!!i,c=(i==null?void 0:i.projects)??[],u=g.useMemo(()=>a?F1(n,c):[],[a,n,c]),[d,h]=g.useState([]),[f,p]=g.useState(0),[m,w]=g.useState(0),[b,x]=g.useState(null),[v,S]=g.useState(null),[C,O]=g.useState(0),N=g.useRef(null),P=j=>{var ae;return d[j]??(i?xg(((ae=u[j])==null?void 0:ae.engine)??"claude",i):{model:null,effort:null})},M=a?zB(n,f):null,R=u.some(j=>f>j.start&&f<=j.end),L=!M||b===n||R||v!==null?[]:[...o.filter(j=>z1(j,M.query)).map(j=>({kind:"person",label:j,insert:`@${j.split(/\s+/)[0]} `})),...uT.filter(j=>z1(j.label,M.query)).map(j=>({kind:"agent",label:j.label,engine:j.engine,hint:i?O7(j.engine,xg(j.engine,i),i):""}))];g.useEffect(()=>{w(0)},[M==null?void 0:M.query,L.length]),g.useEffect(()=>{const j=s.current,ae=N.current;!j||!ae||(ae.style.top=`${j.offsetTop}px`,ae.style.height=`${j.offsetHeight}px`,ae.scrollTop=j.scrollTop)}),g.useEffect(()=>{v!==null&&v>=u.length&&S(null)},[u.length,v]);const H=j=>requestAnimationFrame(()=>{var ae,me;(ae=s.current)==null||ae.focus(),(me=s.current)==null||me.setSelectionRange(j,j),p(j)}),_=j=>{if(!M)return;const ae=n.slice(0,M.start),me=j.kind==="person"?j.insert:`${Gb(j.label,L7(t,c))} `;if(r(ae+me+n.slice(f)),j.kind==="agent"&&i){const E=u.filter(K=>K.start<M.start).length;h(K=>{const z=u.map((xe,Oe)=>K[Oe]);return z.splice(E,0,xg(j.engine,i)),z})}H(ae.length+me.length)},Y=j=>{p(j.selectionStart),N.current&&(N.current.scrollTop=j.scrollTop)},se=j=>{var z,xe;Y(j);const ae=j.selectionStart,me=u.findIndex(Oe=>ae>Oe.start&&ae<=Oe.end);if(me<0){S(null);return}const E=(z=N.current)==null?void 0:z.querySelector(`[data-mention="${me}"]`),K=(xe=j.closest(".dock-card"))==null?void 0:xe.getBoundingClientRect();O(E&&K?Math.max(0,E.getBoundingClientRect().left-K.left-4):12),S(me)},re=j=>v!==null&&j.key==="Escape"?(j.preventDefault(),j.stopPropagation(),S(null),!0):L.length?j.key==="ArrowDown"?(j.preventDefault(),w(ae=>(ae+1)%L.length),!0):j.key==="ArrowUp"?(j.preventDefault(),w(ae=>(ae-1+L.length)%L.length),!0):j.key==="Enter"&&!j.metaKey&&!j.ctrlKey||j.key==="Tab"?(j.preventDefault(),_(L[m]??L[0]),!0):j.key==="Escape"?(j.preventDefault(),j.stopPropagation(),x(n),!0):!1:!1,T=j=>{var E;if(!a)return j;const ae=F1(j,c);if(!ae.length)return j;const me=ae[ae.length-1].project;try{me&&((E=globalThis.localStorage)==null||E.setItem(YR(t),me.slug))}catch{}return WB(j,ae,ae.map((K,z)=>P(z)))},W=L.length>0&&l.jsxs("div",{className:"mention-menu",role:"listbox",children:[L.some(j=>j.kind==="person")&&l.jsx("div",{className:"mention-head",children:"People"}),L.map((j,ae)=>{var me;return l.jsxs("div",{children:[j.kind==="agent"&&((me=L[ae-1])==null?void 0:me.kind)!=="agent"&&l.jsx("div",{className:"mention-head",children:"Agents"}),l.jsxs("button",{type:"button",className:`mention-row${ae===m?" cursor":""}`,onMouseDown:E=>{E.preventDefault(),_(j)},onMouseEnter:()=>w(ae),children:[j.kind==="agent"?l.jsx(bu,{}):l.jsx("span",{className:"tm-av",children:j.label.slice(0,2)}),l.jsx("span",{className:"mention-name",children:j.label}),l.jsx("span",{className:"mention-hint",children:j.kind==="agent"?j.hint:"in this chat"})]})]},`${j.kind}:${j.label}`)})]}),le=a&&u.length>0&&l.jsxs("div",{className:"mention-layer",ref:N,"aria-hidden":"true",children:[u.reduce((j,ae,me)=>(j.out.push(n.slice(j.at,ae.start)),j.out.push(l.jsx("span",{"data-mention":me,className:`mention-chip${ae.project?"":" loose"}`,children:n.slice(ae.start,ae.end)},me)),{at:ae.end,out:j.out}),{at:0,out:[]}).out,n.slice(u[u.length-1].end),""]}),ge=v!==null&&u[v]&&i&&l.jsx(P7,{x:C,mention:u[v],pick:P(v),ctx:i,onProject:j=>{r(BB(n,u[v],j))},onPick:j=>h(ae=>{const me=u.map((E,K)=>ae[K]??P(K));return me[v]=j,me}),onClose:()=>S(null)});return{live:a,mentions:u,block:a?FB(u):null,menu:W,chips:le,card:ge,keyDown:re,track:Y,click:se,encode:T}}function P7({x:e,mention:t,pick:n,ctx:r,onProject:s,onPick:o,onClose:i}){var m;const[a,c]=g.useState(t.project?null:"project"),u={codexModels:r.codexModels,codexDefault:r.codexDefault},d=Ob(t.engine,n.model,u),h=_u(t.engine,n.model,u),f=g.useRef(null);g.useEffect(()=>{const w=b=>{var v,S;const x=b.target;(v=f.current)!=null&&v.contains(x)||(S=x.closest)!=null&&S.call(x,".dock-input")||i()};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]);const p=a==="project"?r.projects.map(w=>{var b;return{id:w.slug,label:w.name,on:((b=t.project)==null?void 0:b.slug)===w.slug,go:()=>{s(w),c(null)}}}):a==="model"?d.map(w=>({id:w.id,label:w.label,on:(n.model??"")===w.id,go:()=>{o({model:w.id||null,effort:Sp(t.engine,w.id||null,u)??n.effort}),c(null)}})):a==="effort"?h.map(w=>({id:w.id,label:w.label,on:n.effort===w.id,go:()=>{o({...n,effort:w.id}),c(null)}})):null;return l.jsxs("div",{className:"mention-card",ref:f,style:{left:e},onMouseDown:w=>w.preventDefault(),children:[l.jsxs("div",{className:"mention-card-head",children:[l.jsx(bu,{}),t.label]}),p?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mention-head",children:a==="project"?"Works in":a==="model"?"Model":"Effort"}),p.map(w=>l.jsxs("button",{type:"button",className:`mention-field${w.on?" cursor":""}`,onClick:w.go,children:[l.jsx("span",{className:"v",children:w.label}),w.on&&l.jsx("span",{className:"chk",children:"✓"})]},w.id||w.label))]}):l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:"mention-field",onClick:()=>c("project"),children:[l.jsx("span",{className:"k",children:"Project"}),l.jsx("span",{className:"v",children:((m=t.project)==null?void 0:m.name)??"Pick one"}),l.jsx(kg,{})]}),l.jsxs("button",{type:"button",className:"mention-field",onClick:()=>c("model"),children:[l.jsx("span",{className:"k",children:"Model"}),l.jsx("span",{className:"v",children:ql(t.engine,n.model,u)}),l.jsx(kg,{})]}),h.length>0&&l.jsxs("button",{type:"button",className:"mention-field",onClick:()=>c("effort"),children:[l.jsx("span",{className:"k",children:"Effort"}),l.jsx("span",{className:"v",children:Tx(n.effort,h)??"Its own"}),l.jsx(kg,{})]})]})]})}const kg=()=>l.jsx("svg",{className:"car",viewBox:"0 0 10 10",width:"10",height:"10",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":"true",children:l.jsx("path",{d:"M2 3.8 5 6.8 8 3.8"})});function z7({text:e,md:t}){const n=dT(e).filter(r=>r.task&&r.project);return n.length?l.jsx(l.Fragment,{children:n.map(r=>l.jsx(F7,{link:r,md:t},r.task))}):null}function F7({link:e,md:t}){var m,w,b,x,v;const n=g.useContext(_x),r=g.useContext(Xt),s=n==null?void 0:n.find(e.project,e.task),o=s||(w=(m=r==null?void 0:r.state)==null?void 0:m.cards)==null?void 0:w.find(S=>S.threadId===e.task),i=s?n.stateOf(s):(o==null?void 0:o.state)??null,a=((b=n==null?void 0:n.projects.find(S=>S.slug===e.project))==null?void 0:b.name)??(s==null?void 0:s.productName)??(o==null?void 0:o.project)??e.project,c={codexModels:(n==null?void 0:n.codexModels)??[],codexDefault:(n==null?void 0:n.codexDefault)??null},u=[a,ql(e.engine,e.model,c),Tx(e.effort,_u(e.engine,e.model,c))].filter(Boolean).join(" · "),d=((v=(x=s==null?void 0:s.wrote)==null?void 0:x.result)==null?void 0:v.ts)??(s==null?void 0:s.updatedAt)??(o==null?void 0:o.updatedAt)??null,h=s?n.filed(s):[],f=(h.length?h:s?[s]:[]).map(S=>({id:S.id,title:S.label||S.title,state:n.stateOf(S)})),p=s!=null&&s.result?l.jsx(Fx,{children:t(s.result)}):l.jsx("div",{className:"msg-body chat-agent-state",children:!s&&!o?`Asked to work in ${a}. Only people in that project can open it.`:i==="running"?`Working on it in ${a}.`:i==="scheduled"?"Waiting to start.":i==="done"?"Finished.":(o==null?void 0:o.progress)??`Started in ${a}.`});return l.jsxs("div",{className:"msg chat-msg chat-agent",children:[l.jsx("div",{className:"chat-gutter",children:l.jsx(bu,{})}),l.jsxs("div",{className:"msg-head",children:[s?l.jsx("button",{type:"button",className:"msg-who chat-agent-name",onClick:()=>n.open(s),children:e.label}):l.jsx("span",{className:"msg-who",children:e.label}),l.jsxs("span",{className:"msg-when",children:[u,d?` · ${Pl(d)}`:""]})]}),p,f.length>0&&l.jsx("div",{className:"chat-agent-made",children:l.jsx(Bx,{rows:f,onOpen:S=>{const C=[...h,...s?[s]:[]].find(O=>O.id===S);C&&n.open(C)}})})]})}const B7=6;function GR({events:e,omitted:t=0,onWhole:n,onOpenOrigin:r,onSendNow:s,name:o,landOn:i,md:a,code:c,tail:u,chat:d=!1,reactions:h,onReact:f,onQuote:p,onHandToAgent:m,replies:w,openThread:b=null,onOpenThread:x,freshThreads:v}){const[S,C]=g.useState(new Map),[O,N]=g.useState(new Set),P=g.useRef(null),M=g.useContext(Xt),R=E=>{const K=E.by;return M&&K&&K!==M.me?M.byId.get(K)??{id:K,email:"",name:"A teammate",avatarUrl:null}:null};g.useEffect(()=>{C(new Map),N(new Set)},[i]);const[L,H]=g.useState(!1),_=e.some(E=>E.kind!=="work"&&E.pending&&!E.held);g.useEffect(()=>{_||H(!1)},[_]),g.useEffect(()=>{var K;const E=(K=P.current)==null?void 0:K.closest(".focus-scroll");return P9(E)},[i]);const Y=d?-2:Xq(e,t),se=g.useRef(null),re=()=>{var E;return(E=P.current)==null?void 0:E.closest(".focus-scroll")},T=()=>{const E=re();se.current=E?E.scrollHeight-E.scrollTop:null,n()};g.useLayoutEffect(()=>{const E=se.current;if(E===null)return;se.current=null;const K=re();K&&(K.scrollTop=Math.max(0,K.scrollHeight-E))},[e]);const W=bq(e.map((E,K)=>({...E,i:K})),{min:1}),le=W.findIndex(E=>{var K;return(E.kind==="run"?(K=E.items[E.items.length-1])==null?void 0:K.i:E.i)===Y}),ge=f7(W,le),j=p7(W,le),ae=d?E7(W.map(E=>E.kind==="run"?{kind:"work",at:E.at}:E)):null,me=(E,K)=>l.jsxs(l.Fragment,{children:[E.pending?l.jsx("span",{className:"msg-when msg-sending",children:E.held?"Sending… press Z to undo":L?"Sending now…":s?"Waiting for its current step":"Sending…"}):l.jsx("span",{className:"msg-when",children:K}),E.pending&&!E.held&&!L&&s&&l.jsx("button",{type:"button",className:"msg-now",onClick:()=>{H(!0),s()},children:"Send now"}),E.on&&l.jsxs("button",{type:"button",className:"msg-on",onClick:r,children:["on ",E.on]})]});return l.jsxs("div",{className:`thread${d?" is-chat":""}`,children:[d&&t>0&&l.jsx("button",{type:"button",className:"thread-gap thread-gap-top",onClick:T,children:`Show ${t} earlier message${t===1?"":"s"}`}),W.map((E,K)=>{var ze,ye,Z,Ce;const z=E.kind==="run"?((ze=E.items[0])==null?void 0:ze.i)??-1:E.i,xe=E.kind==="run"?((ye=E.items[E.items.length-1])==null?void 0:ye.i)??-1:E.i,Oe=(Ee,oe)=>C(ne=>{const Ie=new Map(ne);return oe===yo?Ie.delete(Ee):Ie.set(Ee,oe),Ie}),F=ae==null?void 0:ae[K],J=E.kind==="run"?"is-run":E.kind==="work"?E.yours?"is-act":"is-work":F&&!F.head?"is-msg is-chat-cont":E.same?"is-msg-same":"is-msg";return l.jsxs("div",{className:`thread-block ${J} ${xe===Y?"has-gap":""}${d&&E.kind!=="work"&&E.kind!=="run"&&E.uid&&E.uid===b?" is-thread-open":""}`,children:[(F==null?void 0:F.day)&&l.jsx("div",{className:"chat-day",children:F.day}),E.kind==="work"&&E.yours?l.jsx(ZR,{act:E}):E.kind==="run"?l.jsx(W7,{items:E.items,open:O.has(z),onToggle:()=>N(Ee=>{const oe=new Set(Ee);return oe.has(z)?oe.delete(z):oe.add(z),oe}),lineState:Ee=>S.get(Ee)??yo,onStepLine:Oe,code:c}):E.kind==="work"?l.jsx(QR,{work:E,state:S.get(z)??yo,onStep:Ee=>Oe(z,Ee),code:c}):F?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`msg chat-msg${F.head?"":" cont"}${E.pending?" sending":""}`,children:[l.jsx("div",{className:"chat-gutter",children:F.head?l.jsx(Rt,{person:R(E)??(M!=null&&M.me?M.byId.get(M.me):null),me:!R(E)&&E.who==="you",agent:E.who==="it",size:"lg"}):l.jsx("span",{className:"chat-gt",children:Pl(E.at)})}),F.head&&l.jsxs("div",{className:"msg-head",children:[l.jsx("span",{className:"msg-who",children:((Z=R(E))==null?void 0:Z.name)??(E.who==="you"?"You":o)}),me(E,Pl(E.at))]}),l.jsx(Fx,{children:a(E.text??"")}),E.uid&&l.jsx(AR,{on:h==null?void 0:h[E.uid],me:(M==null?void 0:M.me)??null,onReact:(Ee,oe)=>f==null?void 0:f(E.uid,Ee,oe)}),E.uid&&x&&(((Ce=w==null?void 0:w[E.uid])==null?void 0:Ce.length)??0)>0&&l.jsx(D7,{replies:w[E.uid],open:E.uid===b,onOpen:()=>x(E.uid),fresh:(v==null?void 0:v[E.uid])??0}),E.uid&&f&&l.jsx(TR,{onReact:Ee=>{var oe;return f(E.uid,Ee,(((oe=h==null?void 0:h[E.uid])==null?void 0:oe[Ee])??[]).includes((M==null?void 0:M.me)??""))},...x?{onQuote:()=>x(E.uid),replyLabel:"Reply in thread"}:{onQuote:()=>p==null?void 0:p(E.text??"")},onHandToAgent:m})]}),l.jsx(z7,{text:E.text??"",md:a})]}):l.jsxs("div",{className:`msg ${E.who==="you"&&!R(E)?"yours":""} ${ge[K]?"turn":""} ${j[K]?"turn-end":""}${E.same&&!E.resumed?"same":""} ${E.pending?"sending":""}`,children:[(!E.same||E.resumed)&&l.jsxs("div",{className:"msg-head",children:[l.jsx("span",{className:"msg-who",children:R(E)?l.jsxs(l.Fragment,{children:[l.jsx(Rt,{person:R(E)}),bn(R(E))]}):E.who==="you"?"You":o}),me(E,H7(E.at))]}),E.who==="you"?l.jsx("div",{className:"msg-body typed",children:w7(E.text??"").map((Ee,oe,ne)=>"embed"in Ee?l.jsx("div",{className:"typed-embed",children:a(Ee.embed)},oe):ne.length===1?Ee.text:l.jsx("span",{children:Ee.text},oe))}):l.jsx("div",{className:"msg-body",children:a(E.text??"")})]}),u==null?void 0:u(xe),xe===Y&&l.jsx("button",{type:"button",className:"thread-gap",onClick:T,children:Vq(t)})]},`${E.at}-${z}-${K}`)}),l.jsx("div",{ref:P})]})}const _7=[{who:"them",lines:[96,88,61]},{work:54},{work:38},{who:"you",lines:[72]},{who:"them",lines:[93,84,90,47]},{work:46},{who:"them",lines:[88,71]},{work:61},{who:"them",lines:[91,86,94,79,52]},{who:"you",lines:[83,44]},{who:"them",lines:[90,76,58]}];function JR({head:e}){return l.jsxs("div",{className:"thread thread-waiting","aria-busy":"true",children:[l.jsx("div",{className:"thread-head",children:e}),_7.map((t,n)=>"work"in t?l.jsx("div",{className:"sk-did",style:{width:`${t.work}%`}},n):l.jsxs("div",{className:`sk-msg ${t.who==="you"?"yours":""}`,children:[l.jsx("div",{className:"sk-name"}),t.lines.map((r,s)=>l.jsx("div",{className:"sk-line",style:{width:`${r}%`}},s))]},n))]})}const XR=l.jsx("svg",{viewBox:"0 0 8 8",width:"8",height:"8","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M2.6 1.2 L5.6 4 L2.6 6.8",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function W7({items:e,open:t,onToggle:n,lineState:r,onStepLine:s,code:o}){const i=vq(e);return l.jsxs("div",{className:`did-run ${t?"open":""}`,children:[l.jsxs("button",{className:"did-head did-run-head",onKeyDown:Mp,"aria-expanded":t,title:kq(e),onClick:n,children:[l.jsx("span",{className:"did-run-mark",children:XR}),l.jsx("span",{className:"did-verb",children:l7(e)}),!!i&&l.jsx("span",{className:"did-run-bad",children:i})]}),t&&l.jsx("div",{className:"did-run-body",children:e.map(a=>l.jsx(QR,{work:a,state:r(a.i),onStep:c=>s(a.i,c),code:o},a.i))})]})}const yo=0,Hj=1,vg=2;function QR({work:e,state:t,onStep:n,code:r}){const s=(e.output??"").split(`
|
|
697
|
+
`).filter((m,w,b)=>!(w===b.length-1&&m==="")),o=g.useRef(null),[i,a]=g.useState(!1);g.useLayoutEffect(()=>{const m=o.current;if(!m){a(!1);return}const w=()=>a(m.scrollWidth>m.clientWidth+1);w();const b=new ResizeObserver(w);return b.observe(m),()=>b.disconnect()},[e.subject]);const c=s.length>0||!!e.full||i,u=e.full||(i?e.subject:""),d=t===vg?s:s.slice(0,B7),h=s.length-d.length,f=r&&e.file?Cq(r.paths,e.file):null,p=c&&t===yo&&e.lines>1?l.jsxs("span",{className:"did-note",children:[e.lines," lines"]}):null;return l.jsxs("div",{className:`did ${e.failed?"bad":""} ${t!==yo?"open":""}`,children:[l.jsxs("div",{className:"did-line",children:[l.jsxs("button",{className:"did-head",onKeyDown:Mp,onClick:()=>n(t===yo?Hj:yo),disabled:!c,children:[c&&l.jsx("span",{className:"did-mark",children:XR}),l.jsx("span",{className:"did-verb",children:e.verb}),e.subject&&!f&&l.jsx("code",{className:"did-cmd",ref:o,children:e.subject}),!f&&p]}),f&&l.jsxs("button",{type:"button",className:"did-file",title:`Open ${f} in the code`,onClick:()=>r.open(f),children:[l.jsx("span",{className:"did-file-mark","aria-hidden":"true"}),l.jsx("code",{className:"did-cmd",ref:f?o:void 0,children:e.subject||f})]}),f&&p]}),t!==yo&&!!u&&l.jsx("pre",{className:"did-full",children:u}),t!==yo&&s.length>0&&l.jsx("pre",{className:"did-out",children:d.join(`
|
|
698
|
+
`)}),t===Hj&&h>0&&l.jsxs("button",{className:"did-more",onClick:()=>n(vg),children:["show all ",s.length," lines"]}),t===vg&&!!Lj(s.length,e.lines)&&l.jsx("div",{className:"did-cut",children:Lj(s.length,e.lines)}),!!e.more&&l.jsx("div",{className:"did-cut",children:Gq(e.more)})]})}function ZR({act:e}){const t=g.useContext(Xt),n=t&&e.by&&e.by!==t.me?t.byId.get(e.by)??{id:e.by,email:"",name:"A teammate"}:null,r=d7(e,n?bn(n):null);return l.jsxs("div",{className:`act-line ${r.picked?"is-pick":""}`,children:[l.jsxs("span",{className:"act-said",children:[r.lead,r.choice&&l.jsxs("span",{className:"act-choice",children:[" ",r.choice]})]}),l.jsx("span",{className:"act-when",children:h7(e.at)})]})}function H7(e){return e?`${qR(e)} ${Pl(e)}`:""}function U7({pid:e,sessionId:t,cwd:n,name:r,movedAt:s,md:o}){const[i,a]=g.useState(null),[c,u]=g.useState(!1);g.useEffect(()=>{u(!1)},[e,t,n]);const d=g.useRef(null),h=`${e}|${t??""}|${n}`;return g.useEffect(()=>{let f=!0;return d.current!==h&&(a(null),d.current=h),q.agentConversation({pid:e,sessionId:t,cwd:n,whole:c}).then(p=>{f&&a(p!=null&&p.ok?{events:p.turns??[],omitted:p.omitted??0,total:p.total??0}:{events:[],omitted:0,total:0,error:(p==null?void 0:p.reason)??"That conversation could not be read."})}).catch(p=>{f&&a({events:[],omitted:0,total:0,error:String((p==null?void 0:p.message)??p)})}),()=>{f=!1}},[e,t,n,s,c]),i?i.error?l.jsx("div",{className:"thread-wait",children:i.error}):i.events.length?l.jsx(GR,{events:i.events,omitted:i.omitted,onWhole:()=>u(!0),name:r,landOn:`${t??e}`,md:o}):l.jsx("div",{className:"thread-wait",children:"Nothing has been said in this session yet."}):l.jsx(JR,{head:`Reading the conversation with ${r}…`})}const K7=[0,1,2,7,null,3,6,5,4];function V7({still:e=!1}){return l.jsx("span",{className:`live-mark ${e?"is-still":""}`,"aria-hidden":"true",children:K7.map((t,n)=>l.jsx("span",{className:"live-lattice-cell","data-hole":t===null||void 0,style:t===null?void 0:{animationDelay:`${t*186-1488}ms`}},n))})}const q7=/^(\d\d):(\d\d):(\d\d) {2}(.*)$/,Y7=/^# exited \((-?\d+)\)/;function G7(e,t,n,r){const s=new Date(_h(e,t,n,r));return`${s.getHours()%12===0?12:s.getHours()%12}:${String(s.getMinutes()).padStart(2,"0")}:${String(s.getSeconds()).padStart(2,"0")}`}function J7(e){const t=e.replace(/\s+/g," ").trim();return t.length<=300?t:`${t.slice(0,300).trim()}…`}const X7=/^\d{2}:\d{2}:\d{2}\s{2}== RESULT \([^)]*\bERROR\b[^)]*\) ==$/m;function Q7(e){const t=X7.exec(e);if(!t)return"";const n=e.slice(t.index+t[0].length),r=n.search(/^# exited \(/m);return(r===-1?n:n.slice(0,r)).trim()}function li(e){return e.replace(/[^\S\n]+$/gm,"").replace(/\n{3,}/g,`
|
|
699
|
+
|
|
700
|
+
`).trim()}function Z7(e){const t=[];let n=!1,r=!1,s=0;const o=Q7((e==null?void 0:e.text)??""),i=o?li(o.split(`
|
|
701
|
+
`)[0]):"";for(const a of((e==null?void 0:e.text)??"").split(`
|
|
702
|
+
`)){const c=q7.exec(a);if(!c){if(Y7.test(a)){r=!0,n=!1;continue}if(a.startsWith("#")||n||r)continue;const p=t[t.length-1];if(!p||p.kind!=="say")continue;if(!a.trim()){s+=1;continue}p.text=li(`${p.text}${s?`
|
|
703
|
+
|
|
704
|
+
`:`
|
|
705
|
+
`}${a}`),s=0;continue}s=0;const u=c[4],d=_h(e.startedAt,Number(c[1]),Number(c[2]),Number(c[3])),h=G7(e.startedAt,Number(c[1]),Number(c[2]),Number(c[3]));if(u.startsWith("== RESULT")){n=!0;continue}if(n=!1,u.startsWith("stderr:")||!u.trim())continue;const f=u.startsWith("[")?"tool":"say";if(f==="say"&&i&&li(u)===i){t.push({time:h,at:d,kind:"say",text:Xz(o)});continue}t.push({time:h,at:d,kind:f,text:f==="tool"?J7(u):li(u)})}return t}const eY=/^\[([^\]]+)\]\s*(.*)$/,tY=/^w-[0-9a-f]{10}$/i;function Uj(e,t,n){const r=t==="Bash"?zR(n):null,s=r?r.subject:tY.test(n.trim())?"":t==="Bash"?IR(n):Ll(n);return{kind:"work",at:e,verb:r?r.verb:q9(t),subject:s,...jq(t,{file_path:n.trim()})?{file:n.trim()}:{},...r||s&&s!==n.trim()?{full:n.trim()}:{},output:"",lines:0,failed:!1}}function Rw(e){const t=[];for(const n of Z7(e)){if(n.kind==="tool"){const r=eY.exec(n.text);if(r&&Z9(r[1])||(r==null?void 0:r[1])==="Write"&&/(?:^|\/)runs\/[^/]+\/the-change-it-made\.change$/.test(r[2].trim()))continue;t.push(r?Uj(n.at,r[1],r[2]):Uj(n.at,"",n.text));continue}t.push({at:n.at,who:"it",text:n.text})}return t}function Kj(e){return{kind:"work",standalone:!0,at:e.at,verb:e.said,subject:e.words??"",output:"",lines:0,failed:!1,...e.who==="you"?{yours:!0}:{},...e.who==="you"&&e.by?{by:e.by}:{}}}const zl=e=>e.replace(/\s+/g," ").trim().toLowerCase();function af(e){const t=(e.split(`
|
|
706
|
+
`).find(n=>n.trim())??"").trim();return zl(t.replace(/\*\*/g,"")).replace(/[.?!:]+$/,"")}const Iw=40;function eI(e){const t=e.split(`
|
|
707
|
+
`),n=t.findIndex(s=>s.trim());if(n<0)return null;const r=t.slice(n+1).join(`
|
|
708
|
+
`).replace(/^\s+/,"");return r.trim()?r:null}function Wx(e){return e.kind!=="work"&&!!(e.text??"").trim()}function Vj(e){return Wx(e.node)}function qj(e,t){if(af(e)===af(t))return!0;const n=zl(e),r=eI(t);return!n||!r||n.length<Iw?!1:zl(r).replace(n,"").trim()===""}function nY(e){const t=new Set,n=new Map;return e.forEach((r,s)=>{if(!Wx(r.node))return;if(r.node.who==="you"){n.clear();return}if(!r.answer)return;const o=`${r.answer.field}
|
|
709
|
+
${zl(r.answer.text)}`,i=n.get(o);i!==void 0&&t.add(i),n.set(o,s)}),t}function rY(e){const t=new Map;e.forEach((o,i)=>{o.run!==null&&Wx(o.node)&&t.set(o.run,i)});const n=nY(e),r=new Map;let s=-1;for(let o=0;o<e.length;o+=1){const i=e[o];if(!Vj(i)||n.has(o))continue;const a=s>=0?e[s]:null,c=a&&Vj(a)?a:null;if(!c||c.node.who!=="it"||i.node.who!=="it"){s=o;continue}const u=zl(c.node.text??""),d=zl(i.node.text??"");if(!u||!d){s=o;continue}if(u===d){c.answer&&!i.answer?n.add(o):(n.add(s),s=o);continue}const h=i.run!==null&&t.get(i.run)===o&&!!c.answer,f=c.run!==null&&t.get(c.run)===s&&!!i.answer;if(h&&qj(c.node.text??"",i.node.text??"")){n.add(o);continue}if(f&&qj(i.node.text??"",c.node.text??"")){n.add(s),s=o;continue}if(d.includes(u)&&u.length>=Iw){n.add(s),s=o;continue}if(u.includes(d)&&d.length>=Iw){n.add(o);continue}if(af(c.node.text??"")!==af(i.node.text??"")){s=o;continue}const p=eI(i.node.text??"");p&&r.set(o,p),s=o}return e.map((o,i)=>{const a=r.get(i);return a?{...o,node:{...o.node,text:a}}:o}).filter((o,i)=>!n.has(i))}function sY(e,t,n,r={}){const s=C7(S7(e,r.engine),t),o=[];let i=-1,a=null;const c=[];if(!s.some(C=>C.pickup)){for(const C of t)if(C!=null&&C.text)for(const O of Rw(C))c.push({node:O,run:C.startedAt,answer:null})}for(const C of s){if(C.pickup){const O=C.runs??[];if(!O.length){c.push({node:Kj(C),run:null,answer:null});continue}for(const N of O)for(const P of Rw({startedAt:N.startedAt,text:N.raw}))c.push({node:P,run:N.startedAt,answer:null});continue}if(C.message&&C.words){const O=C.who==="agent"&&(C.field==="result"||C.field==="note");c.push({node:{at:C.at,who:C.who==="you"?"you":"it",text:C.words,...C.by?{by:C.by}:{},...C.uid?{uid:C.uid}:{},...C.inReplyTo?{inReplyTo:C.inReplyTo}:{}},run:null,answer:O?{at:C.at,text:C.words,field:C.field}:null});continue}c.push({node:Kj(C),run:null,answer:null,...C.answers?{answers:!0}:{}})}for(const C of r.undone??[]){for(let O=c.length-1;O>=0;O-=1){const N=c[O].node;N.kind==="work"&&N.yours&&N.at>=C.from&&N.at<=C.at&&c.splice(O,1)}c.push({node:{kind:"work",at:C.at,verb:C.words,subject:C.choice??"",output:"",lines:0,failed:!1,yours:!0},run:null,answer:null})}if(n!=null&&n.text){const C=li(n.text),O=c.some(N=>N.node.kind!=="work"&&N.node.who==="it"&&li(N.node.text??"")===C);C&&!O&&c.push({node:{at:n.at,who:"it",text:C},run:n.run,answer:null})}const u=new Set;for(const C of[...r.pending??[]].sort((O,N)=>O.at-N.at)){const O=li(C.text);if(!O)continue;const N=c.find(P=>!u.has(P)&&P.node.kind!=="work"&&P.node.who==="you"&&(P.node.at??0)>=C.at&&li(P.node.text??"")===O);if(N){u.add(N);continue}c.push({node:{at:C.at,who:"you",text:C.text,pending:!0,held:C.held},run:null,answer:null})}const d=c.map(C=>{if(C.node.kind==="work")return C;const O=e7(C.node.text??"");return O===(C.node.text??"")?C:{...C,node:{...C.node,text:O},answer:C.answer?{...C.answer,text:O}:null}});d.sort((C,O)=>(C.node.at??0)-(O.node.at??0));const h=rY(d);let f;for(const C of h){if(C.node.kind==="work"){C.answers&&(a=null),o.push(C.node);continue}const O=C.run!==null&&C.run===f;f=C.run,i=o.length,C.answer?a={i:o.length,...C.answer}:C.run===null&&(a=null),o.push(O?{...C.node,same:!0}:C.node)}const p=a&&a.i===i?{at:a.at,text:a.text,field:a.field}:null,m=yg(o),w=[];if(p){for(let C=o.length-1;C>a.i;C-=1){const O=o[C];O.kind==="work"&&O.yours&&(w.unshift(O),o.splice(C,1))}o.splice(a.i,1)}const b=r.chat?h9(o):{events:o,replies:{}},x=yg(Object.values(b.replies).flat()),v=Jq(b.events,r.chat?{whole:!!r.whole,opening:0,keep:60}:{whole:!!r.whole}),S=yg(v.events)+(p?1:0);return{events:v.events,outcome:p,after:w,total:m,omitted:m-x-S,replies:b.replies}}const oY=15e3;function iY({item:e,facts:t}){var O,N,P,M,R,L;const[n,r]=g.useState(!1),s=g.useId(),[o,i]=g.useState([]),[a,c]=g.useState(!1);g.useEffect(()=>{if(i([]),c(!1),!n||!t.session)return;let H=!0;const _=()=>q.sessionTrace({product:e.product,id:e.id}).then(re=>{if(!H)return;const T=((re==null?void 0:re.sessions)??[]).at(-1);i(T?c7(Rw(T)).filter(W=>W.kind==="work"):[]),c(!1)}).catch(()=>{H&&c(!0)});_();const Y=q.onChanged(_),se=setInterval(_,Ta(8e3,sr()));return()=>{H=!1,Y(),clearInterval(se)}},[n,e.id,e.product,(O=t.session)==null?void 0:O.startedAt]),g.useEffect(()=>r(!1),[e.id,e.product,(N=t.session)==null?void 0:N.startedAt]);const[u,d]=g.useState(()=>Date.now()),h=!!t.session||!!((P=t.silent)!=null&&P.endedAt);g.useEffect(()=>{if(!h)return;const H=setInterval(()=>d(Date.now()),oY);return()=>clearInterval(H)},[h]);const f=KA(e,{...t,now:u});if(!f)return null;const p=f.state==="working",m=t.session?Dy(Math.max(0,u-t.session.startedAt)):f.state==="silent"&&((M=t.silent)!=null&&M.endedAt)?Dy(Math.max(0,u-t.silent.endedAt)):null,w=((R=t.session)==null?void 0:R.activity)??[],b=w[w.length-1],x=p?(b==null?void 0:b.label)||"Thinking":HA(f.state,((L=t.session)==null?void 0:L.helpers)??0),v=u7(o,w),S=v.slice(-5),C=v.length-S.length;return l.jsxs("div",{className:"live-activity",children:[l.jsxs("div",{className:`live-brief live-${f.state}`,children:[l.jsx(V7,{still:!p}),p?l.jsxs("button",{type:"button",className:"live-disclosure",onKeyDown:Mp,"aria-expanded":n,"aria-controls":s,onClick:()=>r(H=>!H),children:[l.jsx("span",{className:"live-word is-shimmering",children:x}),w.length>1&&l.jsxs("span",{className:"live-span",children:["+",w.length-1]}),m&&l.jsx("span",{className:"live-span",children:m}),l.jsx("svg",{className:"live-chevron",viewBox:"0 0 12 12","aria-hidden":"true",children:l.jsx("path",{d:"m4 2 4 4-4 4"})})]}):l.jsx("span",{className:"live-word",children:f.state==="signin"||f.state==="limit"?f.line:x}),!p&&m&&l.jsx("span",{className:"live-span",children:m}),l.jsx("span",{className:"live-announcement",role:"status",children:p?x:f.line})]}),p&&n&&l.jsxs("div",{className:"live-details",id:s,children:[C>0&&l.jsxs("div",{className:"live-earlier",children:[C," earlier ",C===1?"step":"steps"," since it last said something"]}),S.map((H,_)=>l.jsx(Yj,{label:`${H.verb.charAt(0).toUpperCase()}${H.verb.slice(1)} ${H.subject}`.trim(),detail:H.full||H.subject||""},`${H.at}-${_}`)),w.map(H=>l.jsx(Yj,{label:H.label,detail:H.detail},H.id)),a&&l.jsx("div",{children:"Couldn’t read the command history."}),!a&&!w.length&&!S.length&&l.jsx("div",{children:"No commands yet."})]})]})}function Yj({label:e,detail:t}){return l.jsxs("details",{className:"live-command",children:[l.jsxs("summary",{onKeyDown:Mp,children:[l.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[l.jsx("rect",{x:"1.5",y:"1.5",width:"13",height:"13",rx:"3"}),l.jsx("path",{d:"m4 5 3 3-3 3m5 0h3"})]}),l.jsx("span",{children:e})]}),l.jsx("pre",{children:t})]})}function Hx(e,t){return!!t&&Sl(t.products.get(e.product))&&hi(e)}function aY({item:e}){const t=g.useContext(Xt);if(!t)return null;const n=e.assignee===t.me,r=n?(e.people??[]).find(i=>i!==t.me)??e.createdBy:e.assignee,s=bn(t.byId.get(r??"")),o=oT(e.due);return l.jsxs("span",{className:"fm-said",children:[e.productName," · ",n?`${s} gave you this`:`with ${s}`,o&&l.jsxs(l.Fragment,{children:[" · ",l.jsx("span",{className:"tm-due-word",children:o})]})]})}function lY({item:e}){const t=g.useContext(Xt);if(!t)return null;const n=[...new Set([...e.people??[],e.createdBy,e.assignee].filter(r=>!!r&&r!=="agent"))];return n.length<2?null:l.jsx("span",{className:"tm-people",style:{marginLeft:"auto"},children:n.map(r=>l.jsx(Rt,{person:t.byId.get(r),me:r===t.me},r))})}function cY({product:e,onAdd:t}){const n=g.useContext(Xt),r=g4(e,(n==null?void 0:n.me)??null,(n==null?void 0:n.state.people)??[]);return r?l.jsxs("button",{type:"button",className:"tm-add-people",title:"Add people to a new conversation",onClick:()=>t(r),children:[l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("circle",{cx:"6",cy:"5.5",r:"2.5"}),l.jsx("path",{d:"M1.75 13c0-2.2 1.9-3.6 4.25-3.6 1 0 1.9.25 2.6.7"}),l.jsx("path",{d:"M12 9v5M9.5 11.5h5"})]}),"Add people"]}):null}function uY({item:e}){var d,h,f,p,m;const t=g.useContext(Xt),[n,r]=g.useState(!1),[s,o]=g.useState(null);if(!t||!Hx(e,t)||e.assignee!==t.me||(h=(d=t.products.get(e.product))==null?void 0:d.team)!=null&&h.direct||((p=(f=e.wrote)==null?void 0:f.assignee)==null?void 0:p.by)===t.me)return null;const i=(e.people??[]).find(w=>w!==t.me)??e.createdBy??void 0,a=[["Give it to an agent","agent"],["Do it myself","me"],[`Hand it back to ${bn(t.byId.get(i??""))}`,"back"]],c=async w=>{r(!0),o(null);const b=await q.teamRoute({product:e.product,id:e.id,route:w});r(!1),b.ok||o(b.error??"That did not work.")},u=((m=(e.body??e.title).split(`
|
|
710
|
+
`).find(w=>w.trim()))==null?void 0:m.replace(/\*\*/g,"").trim())??e.title;return l.jsxs("div",{className:"opt-strip",children:[l.jsx("div",{className:"opt-head opt-head-ask",children:l.jsx("span",{children:u})}),a.map(([w,b],x)=>l.jsxs("button",{className:"opt-row",disabled:n,onClick:()=>c(b),children:[l.jsx("span",{className:"opt-key",children:x+1}),l.jsx("span",{className:"opt-text",children:w})]},b)),s&&l.jsx("div",{className:"opt-head",children:l.jsx("span",{className:"tm-error",children:s})})]})}const dY=15e3;function Gj({parts:e}){const t=e.filter(Boolean);return l.jsx("span",{className:"fm-said",children:t.join(" · ")})}function hY({item:e,facts:t,returned:n,lead:r,stateShown:s,onAddPeople:o}){const[i,a]=g.useState(()=>Date.now()),c=!!t.session;g.useEffect(()=>{if(!c)return;const f=setInterval(()=>a(Date.now()),dY);return()=>clearInterval(f)},[c]);const u=LF(e,{...t,now:i}),d=g.useContext(Xt),h=o?l.jsx(cY,{product:(d==null?void 0:d.products.get(e.product))??null,onAdd:o}):null;return Hx(e,d)?l.jsxs("div",{className:"focus-meta by-lead",children:[r,l.jsx(aY,{item:e}),l.jsx(lY,{item:e}),h]}):l.jsxs("div",{className:"focus-meta by-lead","aria-label":u.line,title:Vi[u.where],children:[r??(!s&&u.stateWord&&l.jsx("span",{className:"live-word",children:u.stateWord})),u.span&&l.jsx("span",{className:"live-span",children:u.span}),r||s?l.jsx(Gj,{parts:PF(u,u.age?`last moved ${u.age} ago`:null)}):l.jsx(Gj,{parts:[u.project,u.whereWord,u.engineWord,u.age?pn(e)?`nothing has started for ${u.age}`:nr(e)?`downloaded ${u.age} ago`:`last moved ${u.age} ago`:null]}),n&&l.jsx("span",{className:"chip chip-returned",children:"back from Later"}),h]})}const fY=(e,t)=>e.on===t.on&&e.emoji===t.emoji;function pY(e,t){return[...e.filter(n=>!fY(n,t)),t]}function mY(e,t,n){if(!t.length||!n)return e;const r={};for(const[s,o]of Object.entries(e??{}))r[s]={...o};for(const s of t){const o=r[s.on]??(r[s.on]={}),i=(o[s.emoji]??[]).filter(a=>a!==n);s.off||i.push(n),i.length?o[s.emoji]=i:delete o[s.emoji],Object.keys(o).length||delete r[s.on]}return r}function gY(e,t,n){const r=e.filter(s=>{var o;return(((o=t==null?void 0:t[s.on])==null?void 0:o[s.emoji])??[]).includes(n??"")===s.off});return r.length===e.length?e:r}function yY(e,t,n){const[r,s]=g.useState([]);g.useEffect(()=>{s(i=>gY(i,e,t))},[e,t]);const o=g.useCallback((i,a,c)=>{const u={on:i,emoji:a,off:c};s(d=>pY(d,u)),n(u).catch(()=>s(d=>d.filter(h=>h!==u)))},[n]);return{reactions:mY(e,r,t),react:o}}function wY(e){const t=e.map((r,s)=>({e:r,i:s})).filter(({e:r})=>r.kind!=="work"),n=[];return t.forEach(({e:r,i:s},o)=>{const i=t[o+1];r.who==="it"&&i&&i.e.who==="you"&&n.push(s)}),n}function bY(e,t){const n=wY(e),r=new Map,s=[];for(const o of[...t].sort((i,a)=>(i.at??0)-(a.at??0))){const i=n.find(c=>e[c].at>=(o.at??0));if(i===void 0){s.push(o);continue}const a=r.get(i);a?a.push(o):r.set(i,[o])}return{onTurn:r,atFoot:s}}function xY(e){const t=r=>(r==null?void 0:r.kind)!=="work"||!!(r!=null&&r.yours);let n=e.length;for(;n>0&&!t(e[n-1]);)n-=1;return n===e.length?e:e.slice(0,n)}const tI="zero.undoMarks.v1",nI=()=>{try{return globalThis.localStorage??null}catch{return null}},kY=e=>{const t=e;return!!t&&typeof t.product=="string"&&typeof t.id=="string"&&typeof t.words=="string"&&Number.isFinite(t.from)&&Number.isFinite(t.at)};function Dw(e=nI()){try{const t=JSON.parse((e==null?void 0:e.getItem(tI))??"[]");return Array.isArray(t)?t.filter(kY):[]}catch{return[]}}function vY(e,t=nI()){const n=[...Dw(t),e].slice(-300);try{t==null||t.setItem(tI,JSON.stringify(n))}catch{}}function SY(e,t,n){return e.filter(r=>r.product===t&&r.id===n)}const Ow="undo-marks-changed",jY=8e3,CY="The agent";function NY({item:e,engine:t,session:n,opening:r,sending:s,filed:o=[],onOpenFiled:i,onApproveFiled:a,onRejectFiled:c,onOpenOrigin:u,onSendNow:d,md:h,clean:f,onOpenDoc:p,chat:m=!1,onQuote:w,onHandToAgent:b,thread:x}){var Oe;const[v,S]=g.useState(null),[C,O]=g.useState([]),[N,P]=g.useState([]),[M,R]=g.useState(!1);g.useEffect(()=>{R(!1)},[e.product,e.id]);const L=((Oe=g.useContext(Xt))==null?void 0:Oe.me)??null,H=g.useCallback(F=>q.teamReact({product:e.product,id:e.id,...F}).then(J=>{if(!(J!=null&&J.ok))throw new Error((J==null?void 0:J.error)??"that reaction did not save")}),[e.product,e.id]),_=yY(e.reactions,L,H),[Y,se]=g.useState(()=>Dw());if(g.useEffect(()=>{const F=()=>se(Dw());return window.addEventListener(Ow,F),()=>window.removeEventListener(Ow,F)},[]),g.useEffect(()=>{S(null),O([]),P([])},[e.product,e.id]),g.useEffect(()=>{let F=!0;const J=()=>{q.itemHistory({product:e.product,id:e.id}).then(Z=>{F&&S({lines:(Z==null?void 0:Z.lines)??[],error:Z!=null&&Z.ok||Z==null?void 0:Z.error})}).catch(Z=>{F&&S({lines:[],error:String((Z==null?void 0:Z.message)??Z)})}),q.sessionTrace({product:e.product,id:e.id}).then(Z=>{F&&O((Z==null?void 0:Z.sessions)??[])}).catch(()=>{F&&O([])}),q.codeChange({product:e.product,src:Rh(e.id)}).then(Z=>{var Ee;if(!F)return;const Ce=(Z!=null&&Z.ok?(Ee=Z.change)==null?void 0:Ee.files:null)??[];P(Ce.map(oe=>oe.path).filter(Boolean))}).catch(()=>{F&&P([])})};if(J(),!n)return()=>{F=!1};const ze=q.onChanged(J),ye=setInterval(J,Ta(jY,sr()));return()=>{F=!1,ze(),clearInterval(ye)}},[e.product,e.id,e.updatedAt,n==null?void 0:n.startedAt]),!v)return l.jsx(JR,{head:"Reading this conversation…"});if(v.error)return l.jsx("div",{className:"thread-wait",children:v.error});const re=n!=null&&n.saying&&n.sayingAt?{text:n.saying,at:n.sayingAt,run:n.startedAt}:null,T=sY(v.lines,C,re,{whole:M,engine:t,pending:s,chat:m,undone:SY(Y,e.product,e.id)}),W=T.events.map(F=>F.kind==="work"?F:{...F,text:f(F.text??"")}),le=n?xY(W):W,ge=r?[{at:r.at,who:"you",text:r.text,on:r.on},...le]:le,{omitted:j,outcome:ae,after:me}=T,E=m&&(x!=null&&x.open)?T.events.find(F=>F.kind!=="work"&&F.uid===x.open)??null:null;if(!W.length&&!r&&!ae)return l.jsx("div",{className:"thread-wait",children:"Nothing has been said here yet."});const K=bY(ge,o),z=F=>l.jsx(Bx,{rows:F,label:"Filed from this thread",onOpen:J=>i==null?void 0:i(J),onApprove:a,onReject:c}),xe=ae&&(n7(e)&&ae.field==="result"?l.jsx("div",{className:"outcome",children:h(f(ae.text))}):l.jsxs("div",{className:"appendix appendix-foot",children:[l.jsx("div",{className:"appendix-label",children:ae.field==="result"?"Result":"Latest checkpoint"}),h(f(ae.text))]}));return l.jsxs(l.Fragment,{children:[l.jsx(GR,{events:ge,omitted:j,chat:m,name:CY,landOn:e.id,onWhole:()=>R(!0),onOpenOrigin:u,onSendNow:n&&(n.engine??t)!=="codex"?d:void 0,md:h,code:N.length&&p?{paths:N,open:F=>p(Rh(e.id),F)}:null,tail:F=>{const J=K.onTurn.get(F);return J?z(J):null},...m?{reactions:_.reactions,onReact:_.react,onQuote:w,onHandToAgent:b,...x?{replies:T.replies,openThread:x.open,onOpenThread:x.onOpen,freshThreads:x.fresh}:{}}:{}}),m&&x&&E&&x.host&&bs.createPortal(l.jsx(I7,{parent:E,replies:T.replies[E.uid]??[],md:F=>h(f(F)),width:x.width,reactions:_.reactions,onReact:_.react,onSend:F=>x.onSend(E.uid,F),onClose:x.onClose,onResize:x.onResize}),x.host),xe,me.length>0&&l.jsx("div",{className:`act-after${m?" is-chat":""}`,children:me.map((F,J)=>l.jsx(ZR,{act:F},`${F.at}-${J}`))}),z(K.atFoot)]})}const EY=59,AY=new Set(["a","an","the","for","to","of","on","in","at","and","or","but","so","by","with","from","before","after","until","it","as","is"]);function TY(e,t=EY){const n=(e??"").replace(/\s+/g," ").trim();if(n.length<=t)return n;const r=[];for(const s of n.split(" ")){if([...r,s].join(" ").length>t)break;r.push(s)}if(!r.length)return`${n.slice(0,t)}…`;for(;r.length>1&&AY.has(r[r.length-1].toLowerCase().replace(/[^a-z]/g,""));)r.pop();return`${r.join(" ").replace(/[,;:.\-–]+$/,"")}…`}const MY=1180,RY=872,IY=e=>e>=MY,DY=e=>e>=RY;function rI({choice:e,fits:t,override:n}){return t?e:n??!1}function OY(e){return e.fits?{choice:!e.choice,override:null}:{choice:e.choice,override:!rI(e)}}function sI(e,t,n){const[r,s]=g.useState(null),[o,i]=g.useState(e);o!==e&&(i(e),s(null));const a={choice:t,fits:e,override:o===e?r:null},c=rI(a),u=g.useCallback(()=>{const d=OY(a);d.choice!==t&&n(d.choice),s(d.override)},[t,e,r,n]);return[c,u]}function LY(){const[e,t]=g.useState(()=>typeof window>"u"?1440:window.innerWidth);return g.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function Nl({kind:e}){return l.jsx("span",{className:`ts-st ts-st-${e}`,"aria-hidden":"true"})}function Sg(){return l.jsx("svg",{className:"ts-caret",viewBox:"0 0 12 12",width:"10",height:"10",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:l.jsx("path",{d:"M3 4.5 6 7.5l3-3"})})}function $Y(){return l.jsx("svg",{className:"ts-pen",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:l.jsx("path",{d:"m4 20 1-4.5L15.5 5a2.1 2.1 0 0 1 3 3L8 18.5 4 20Z"})})}function Lw(){return l.jsxs("svg",{className:"ts-who",width:"13",height:"12",viewBox:"0 0 24 22",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"7",r:"4"}),l.jsx("path",{d:"M4.5 20.5c.8-4 3.8-6.3 7.5-6.3s6.7 2.3 7.5 6.3"})]})}function oI({open:e=!1}){return l.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[l.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"1.5"}),e&&l.jsx("rect",{x:"14.5",y:"4.5",width:"6",height:"15",fill:"currentColor",stroke:"none",opacity:".5"}),l.jsx("path",{d:"M14.5 4.5v15"})]})}const lf=(e,t)=>!e.assignee||e.assignee==="agent"||e.assignee===t;function PY(e=1/0){const[t,n]=g.useState(()=>typeof localStorage>"u"?!0:d9(localStorage));return g.useEffect(()=>{try{localStorage.setItem(CR,t?"1":"0")}catch{}},[t]),sI(DY(e),t,n)}function zY(e,t=!0){g.useEffect(()=>{if(!t)return;const n=r=>{if(r.key!=="s"&&r.key!=="S"||r.metaKey||r.ctrlKey||r.altKey||r.defaultPrevented)return;const s=r.target;s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.tagName==="SELECT"||s.isContentEditable)||(r.preventDefault(),r.stopImmediatePropagation(),r.repeat||e())};return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[e,t])}function FY({item:e}){const t=g.useContext(Xt),n=up(e);return l.jsxs("span",{className:"ts-lead",children:[l.jsx(Nl,{kind:wu(n,lf(e,(t==null?void 0:t.me)??null))}),Sw(e,n)]})}function BY({item:e,team:t,onOpen:n}){const r=(t==null?void 0:t.me)??null,s=up(e),o=kr(e.priority),i=(t==null?void 0:t.byId)??new Map,a=SR(e,r,i),c=a==="You"?r?i.get(r)??null:null:i.get(e.createdBy??"")??null,u=jR(e,(t==null?void 0:t.state.since)??null,t==null?void 0:t.products.get(e.product));return l.jsxs("button",{type:"button",className:"ts-rail","aria-label":"Show the summary",title:"Show the summary",onClick:n,children:[l.jsx("span",{className:"ts-rail-ic","data-hint":"summary","data-hint-align":"right",children:l.jsx(oI,{})}),l.jsx("span",{className:"ts-rail-mark",title:jp[s],children:l.jsx(Nl,{kind:wu(s,lf(e,r))})}),l.jsx("span",{className:"ts-rail-mark",title:`${Ma(o)} priority`,children:l.jsx(xi,{id:o})}),t&&l.jsx("span",{className:"ts-rail-mark",title:`Owner: ${a}`,children:l.jsx(Rt,{person:c,me:a==="You"})}),t&&l.jsx("span",{className:"ts-rail-mark",title:`Visible to ${Nw[u]}`,children:u==="private"?l.jsx(Lw,{}):l.jsx(Rl,{className:"ts-who"})})]})}const _Y="Not written yet",WY=["problem","progress"];function iI({steps:e}){return l.jsx("ol",{className:"ts-trail",children:e.map((t,n)=>l.jsx("li",{className:`ts-step${n===e.length-1?" ts-step-last":""}`,children:l.jsx($T,{text:t})},n))})}const HY=(e,t)=>JSON.stringify(e??null)===JSON.stringify(t??null);function UY({item:e,team:t,onFinish:n,onClose:r}){const s=(t==null?void 0:t.me)??null,[o,i]=g.useState({}),[a,c]=g.useState(null);g.useEffect(()=>{i({}),c(null)},[e.product,e.id]),g.useEffect(()=>{i(F=>{var ye,Z;let J=!1;const ze={...F};for(const Ce of Object.keys(F)){const Ee=((Z=(ye=e.wrote)==null?void 0:ye[Ce])==null?void 0:Z.ts)??0;(HY(e[Ce],F[Ce].value)||Ee>=F[Ce].ts)&&(delete ze[Ce],J=!0)}return J?ze:F})},[e]);const u=F=>o[F]?o[F].value:e[F],d=g.useCallback(async F=>{const J=Date.now();i(ye=>({...ye,...Object.fromEntries(Object.entries(F).map(([Z,Ce])=>[Z,{value:Ce,ts:J}]))})),c(null),(await q.threadEdit(e.product,e.id,F)).ok||(i(ye=>{const Z={...ye};for(const Ce of Object.keys(F))delete Z[Ce];return Z}),c("That change did not save."))},[e.product,e.id]),[h,f]=g.useState(null),[p,m]=g.useState(!1),[w,b]=g.useState("");g.useEffect(()=>{h!=="visibility"&&(m(!1),b(""))},[h]);const x=g.useRef(null);g.useEffect(()=>{if(!h)return;const F=ze=>{var ye;(ye=x.current)!=null&&ye.contains(ze.target)||f(null)},J=ze=>{ze.key==="Escape"&&(ze.preventDefault(),ze.stopImmediatePropagation(),f(null))};return document.addEventListener("pointerdown",F),window.addEventListener("keydown",J,!0),()=>{document.removeEventListener("pointerdown",F),window.removeEventListener("keydown",J,!0)}},[h]),g.useEffect(()=>{f(null)},[e.product,e.id]);const v=F=>J=>{h===F&&(x.current=J)},S=up(e),C=kr(u("priority")),O=jR({...e,visibility:u("visibility"),visibleTo:u("visibleTo")??e.visibleTo},(t==null?void 0:t.state.since)??null,t==null?void 0:t.products.get(e.product)),N=$u({visibility:u("visibility")??e.visibility,visibleTo:u("visibleTo")??e.visibleTo},t==null?void 0:t.products.get(e.product)),P=g.useMemo(()=>vx((t==null?void 0:t.state.people)??[],(t==null?void 0:t.me)??null),[t]),M=SR(e,s,(t==null?void 0:t.byId)??new Map),R=M==="You"?null:(t==null?void 0:t.byId.get(e.createdBy??""))??null,L=pB({...e,...Object.fromEntries(vw.filter(F=>o[F]).map(F=>[F,o[F].value]))}),H=F=>typeof u(F)=="string",[_,Y]=g.useState(null),[se,re]=g.useState(""),T=g.useRef(""),W=g.useRef(""),le=g.useRef(null),ge=g.useRef(!1),j=g.useRef(null);g.useEffect(()=>()=>{le.current&&clearTimeout(le.current)},[]),g.useEffect(()=>{Y(null)},[e.product,e.id]);const ae=F=>{const J=L[F];T.current=J,W.current=J,ge.current=!1,re(J),Y(F)},me=(F,J)=>{J!==W.current&&(W.current=J,d({[F]:J}))},E=F=>{re(F),le.current&&clearTimeout(le.current);const J=_;le.current=setTimeout(()=>me(J,F),600)},K=()=>{_&&(le.current&&clearTimeout(le.current),ge.current||me(_,se),Y(null))},z=F=>{F.key==="Escape"?(F.preventDefault(),F.stopPropagation(),K()):F.key==="Enter"&&!F.shiftKey&&!F.nativeEvent.isComposing&&_!=="progress"&&(F.preventDefault(),K())};g.useLayoutEffect(()=>{const F=j.current;F&&(F.style.height="auto",F.style.height=`${F.scrollHeight}px`)},[se,_]),g.useEffect(()=>{const F=j.current;!F||!_||(F.focus(),F.setSelectionRange(F.value.length,F.value.length))},[_]);const xe=_?"You are editing · saves as you type":a,Oe=l9(e,{me:s,pending:Object.fromEntries(vw.filter(F=>o[F]).map(F=>[F,o[F].ts]))});return l.jsxs("aside",{className:"ts-panel","aria-label":"Summary",children:[r&&l.jsx("button",{type:"button",className:"ts-close","data-hint":"summary","data-hint-align":"right",title:"Hide the summary",onClick:r,children:l.jsx(oI,{open:!0})}),l.jsx("h2",{className:"ts-title",children:Co(e)}),WY.filter(F=>{var J;return _===F||((J=L[F])==null?void 0:J.trim())}).map(F=>l.jsxs("div",{className:`ts-sec${F==="progress"?" ts-sec-done":""}`,children:[l.jsx("div",{className:"ts-h",children:F==="problem"?"Context":"Done"}),_===F?l.jsx("textarea",{ref:j,className:"ts-edit",rows:1,value:se,"aria-label":F,onChange:J=>E(J.target.value),onBlur:K,onKeyDown:z}):l.jsxs("div",{className:`ts-line${H(F)?"":" dim"}`,role:"button",tabIndex:0,title:"Click to edit",onClick:()=>ae(F),onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),ae(F))},children:[F==="progress"?l.jsx(iI,{steps:zy(L[F])}):l.jsx($T,{text:L[F]}),l.jsx($Y,{})]})]},F)),xe&&l.jsx("div",{className:`ts-by${a&&!_?" ts-by-error":""}`,children:xe}),l.jsxs("div",{className:"ts-foot",children:[l.jsx("div",{className:"ts-rule"}),l.jsxs("div",{className:"ts-props",children:[l.jsx("span",{className:"ts-label",children:"Status"}),n&&xj(S).length?l.jsxs("span",{className:"ts-value ts-menu-anchor",ref:v("status"),children:[l.jsxs("button",{type:"button",className:"ts-prop-btn","aria-haspopup":"listbox","aria-expanded":h==="status",title:"Change the status",onClick:()=>f(h==="status"?null:"status"),children:[l.jsx(Nl,{kind:wu(S,lf(e,s))}),Sw(e,S),l.jsx(Sg,{})]}),h==="status"&&l.jsx("span",{className:"prio-menu ts-menu",role:"listbox","aria-label":"Status",children:xj(S).map(F=>l.jsxs("button",{type:"button",role:"option","aria-selected":!1,className:"prio-menu-row",onClick:()=>{f(null),n()},children:[l.jsx(Nl,{kind:F.glyph}),l.jsx("span",{className:"prio-menu-label",children:F.word})]},F.id))})]}):l.jsxs("span",{className:"ts-value",children:[l.jsx(Nl,{kind:wu(S,lf(e,s))}),Sw(e,S)]}),l.jsx("span",{className:"ts-label",children:"Priority"}),l.jsxs("span",{className:"ts-value ts-menu-anchor",ref:v("priority"),children:[l.jsxs("button",{type:"button",className:"ts-prop-btn","aria-haspopup":"listbox","aria-expanded":h==="priority",title:"Change the priority",onClick:()=>f(h==="priority"?null:"priority"),children:[l.jsx(xi,{id:C}),Ma(C),l.jsx(Sg,{})]}),h==="priority"&&l.jsx("span",{className:"prio-menu ts-menu",role:"listbox","aria-label":"Priority",children:wr.map(F=>l.jsxs("button",{type:"button",role:"option","aria-selected":F.id===C,className:`prio-menu-row${F.id===C?" on":""}`,onClick:()=>{f(null),F.id!==C&&d({priority:hu(F.id)})},children:[l.jsx(xi,{id:F.id}),l.jsx("span",{className:"prio-menu-label",children:F.label})]},F.id))})]}),l.jsx("span",{className:"ts-label",children:"Owner"}),l.jsxs("span",{className:"ts-value",children:[R&&l.jsx(Rt,{person:R}),M]}),l.jsx("span",{className:"ts-label",children:"Project"}),l.jsx("span",{className:"ts-value",children:e.productName}),t&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"ts-label",children:"Visible to"}),l.jsxs("span",{className:"ts-value ts-menu-anchor",ref:v("visibility"),children:[l.jsxs("button",{type:"button",className:"ts-prop-btn","aria-haspopup":"listbox","aria-expanded":h==="visibility",title:"Change who sees it",onClick:()=>{m(!1),f(h==="visibility"?null:"visibility")},children:[O==="private"?l.jsx(Lw,{}):l.jsx(Rl,{className:"ts-who"}),O==="people"?u9(N,(t==null?void 0:t.byId)??new Map):Nw[O],l.jsx(Sg,{})]}),h==="visibility"&&l.jsx("span",{className:"prio-menu ts-menu",role:"listbox","aria-label":"Visible to",children:p?l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"prio-menu-row",onClick:()=>m(!1),children:l.jsx("span",{className:"prio-menu-label",children:"‹ Visible to"})}),P.length>6&&l.jsx("input",{className:"ts-find",placeholder:"Find a person",value:w,onChange:F=>b(F.target.value)}),dw(P,w).map(F=>l.jsxs("button",{type:"button",role:"option","aria-selected":N.includes(F.id),className:`prio-menu-row${N.includes(F.id)?" on":""}`,onClick:()=>{const J=N.includes(F.id)?N.filter(ze=>ze!==F.id):[...N,F.id];d(J.length?{visibility:"people",visibleTo:J}:{visibility:"private",visibleTo:[]})},children:[l.jsx(Rt,{person:F}),l.jsx("span",{className:"prio-menu-label",children:F.name})]},F.id)),!P.length&&l.jsx("span",{className:"ts-menu-none",children:"Nobody else is on the team yet."})]}):["team","people","private"].map(F=>l.jsxs("button",{type:"button",role:"option","aria-selected":F===O,className:`prio-menu-row${F===O?" on":""}`,onClick:()=>{if(F==="people"){m(!0);return}f(null),F!==O&&d({visibility:F})},children:[F==="private"?l.jsx(Lw,{}):l.jsx(Rl,{className:"ts-who"}),l.jsx("span",{className:"prio-menu-label",children:Nw[F]})]},F))})]})]}),Oe&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"ts-label",children:"Updated"}),l.jsx("span",{className:"ts-value",children:Oe})]})]})]})]})}function KY({from:e,name:t,onBack:n}){return l.jsxs("button",{type:"button",className:"back-esc thread-crumb","data-hint":"back",onClick:n,"aria-label":`Back to ${e} (esc)`,title:t,children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5"})}),l.jsx("span",{className:"thread-crumb-from",children:e}),l.jsx("span",{className:"thread-crumb-sep","aria-hidden":"true",children:"/"}),l.jsx("span",{className:"thread-crumb-name",children:TY(t)})]})}function VY({card:e,person:t,now:n=Date.now()}){const r=jp[e.state],s=l.jsx(Nl,{kind:wu(e.state,!1)}),o=(t==null?void 0:t.name)||"Someone";if(!e.visible)return l.jsxs("article",{className:"ts-ticket ts-ticket-private",children:[l.jsx("p",{className:"ts-tk-lead dim",children:"Private thread"}),l.jsxs("div",{className:"ts-tk-foot",children:[l.jsx(Rt,{person:t}),l.jsx("b",{children:o}),l.jsxs("span",{className:"ts-tk-state",children:[s,r]})]})]});const i=Number.isFinite(e.priority)?kr(e.priority):null,a=c=>c.length?l.jsx("p",{children:c.map((u,d)=>l.jsxs("span",{className:u.title?"":"dim",children:[d>0&&", ",u.title??c9]},u.id))}):l.jsx("p",{className:"dim",children:"Nothing"});return l.jsxs("article",{className:"ts-ticket",children:[l.jsxs("div",{className:"ts-tk-top",children:[l.jsxs("span",{children:[s,e.state==="waiting"?`Waiting on ${o.split(/\s+/)[0]}`:r]}),i&&l.jsxs(l.Fragment,{children:[l.jsx("i",{className:"ts-sep"}),l.jsxs("span",{children:[l.jsx(xi,{id:i}),Ma(i)]})]}),e.project&&l.jsxs(l.Fragment,{children:[l.jsx("i",{className:"ts-sep"}),l.jsx("span",{children:e.project})]}),l.jsx("i",{className:"ts-sep"}),l.jsx("span",{children:"Visible to the team"})]}),l.jsx("p",{className:`ts-tk-lead${e.problem?"":" dim"}`,children:e.problem||_Y}),zy(e.progress).length>0&&l.jsxs("div",{className:"ts-tk-done",children:[l.jsx("span",{className:"ts-h",children:"Done"}),l.jsx(iI,{steps:zy(e.progress)})]}),l.jsxs("div",{className:"ts-tk-grid ts-tk-next",children:[l.jsxs("div",{children:[l.jsx("span",{className:"ts-h",children:"Blocked by"}),a(e.blockedBy)]}),l.jsxs("div",{children:[l.jsx("span",{className:"ts-h",children:"Blocks"}),a(e.blocks)]})]}),l.jsxs("div",{className:"ts-tk-foot",children:[l.jsx(Rt,{person:t}),l.jsx("b",{children:o}),l.jsxs("span",{children:["· kept up to date by the agent · ",Lx(e.updatedAt,n)]})]})]})}function qY({person:e,onMessage:t}){return l.jsxs("button",{type:"button",className:"ts-msgbtn",onClick:t,children:[l.jsx(Rt,{person:e}),"Message ",bn(e)]})}function YY(e){const t=e.split(`
|
|
711
|
+
`),n=[];let r=!1;for(const s of t)/^#{1,4}\s/.test(s)?r=/option/i.test(s):r&&s.trim()&&!/^\s*\d+[.)]\s/.test(s)&&(r=!1),r||n.push(s);return n.join(`
|
|
712
|
+
`)}const GY=/^[\w-][\w./-]*\.(png|jpe?g|gif|webp|html?|pdf|md|csv|txt|json|mp3|wav|m4a|aac|ogg|mp4|mov|m4v|webm)$/i;function JY(e,t=Date.now()){const n=new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return`${op(e,t).toLowerCase()} ${n}`}function Jj({children:e}){const t=g.useRef(null),[n,r]=g.useState(!1);return l.jsxs("div",{className:"code-wrap",children:[l.jsx("pre",{ref:t,children:e}),l.jsx("button",{className:`code-copy ${n?"copied":""}`,onClick:()=>{navigator.clipboard.writeText(E8(t.current)).then(()=>{r(!0),setTimeout(()=>r(!1),1600)}).catch(()=>{})},children:n?"copied ✓":"copy"})]})}function jg({src:e,alt:t,roots:n,onOpen:r,find:s}){const[o,i]=g.useState(0),[a,c]=g.useState(void 0),[u,d]=g.useState(!1),f=!!e&&!/^(data|https?|file):/.test(e)&&!e.startsWith("/")&&o>=n.length;if(g.useEffect(()=>{if(!f||a!==void 0||!s)return;let b=!0;return s(e.replace(/^\.\//,"")).then(x=>{b&&c(x||null)}).catch(()=>{b&&c(null)}),()=>{b=!1}},[f,a,e]),!e)return null;if(/^data:/.test(e))return l.jsx("img",{src:e,alt:t??"",className:"inline-image"});const p=(b,x)=>r?l.jsx("button",{type:"button",className:"inline-image-open","data-copy-file":/^https?:/.test(b)?void 0:b,title:b,onClick:()=>r(b),children:x}):x;if(/^https?:/.test(e))return p(e,l.jsx("img",{src:e,alt:t??"",className:"inline-image"}));if(/^file:\/\//.test(e)){const b=decodeURIComponent(e.slice(7));return p(b,l.jsx("img",{src:vo(b),alt:t??"",className:"inline-image",crossOrigin:"anonymous"}))}if(e.startsWith("/"))return u?l.jsxs("span",{className:"missing-artifact",children:["missing image: ",e]}):p(e,l.jsx("img",{src:vo(e),alt:t??"",className:"inline-image",crossOrigin:"anonymous",onError:()=>d(!0)}));const m=e.replace(/^\.\//,""),w=n.map(b=>vo(`${b}/${m}`));if(o>=w.length){const b=s?a:null;return b?p(b,l.jsx("img",{src:vo(b),alt:t??"",className:"inline-image",crossOrigin:"anonymous",onError:()=>c(null)})):b===void 0?null:l.jsxs("span",{className:"missing-artifact",children:["missing image: ",m]})}return p(m,l.jsx("img",{src:w[o],alt:t??"",className:"inline-image",crossOrigin:"anonymous",onError:()=>i(o+1)}))}function Xj({src:e,label:t,roots:n,onOpen:r}){const[s,o]=g.useState(0),i=e.replace(/^\.\//,""),a=e.startsWith("/")?[vo(e)]:n.map(h=>vo(`${h}/${i}`)),c=l.jsxs("button",{type:"button",className:"inline-media-name mention mention-media","data-copy-file":i,title:i,onClick:()=>r==null?void 0:r(i),children:[l.jsx(Yh,{kind:"media"}),l.jsx("span",{className:"mention-name",children:jM(i,t)??t})]});if(s>=a.length)return l.jsx("span",{className:"inline-media-missing",children:c});const u=()=>o(s+1),d=/\.(mp4|mov|m4v|webm)(?:[?#]|$)/i.test(i);return l.jsxs("span",{className:"inline-media",children:[c,d?l.jsx("video",{src:a[s],controls:!0,preload:"metadata",onError:u},a[s]):l.jsx("audio",{src:a[s],controls:!0,preload:"metadata",onError:u},a[s])]})}const XY=6;function QY({product:e,folder:t,onOpen:n,quiet:r,thread:s}){const o=g.useContext(nx),[i,a]=g.useState(null);g.useEffect(()=>{const p=window.zero;if(r||!(p!=null&&p.folderPictures))return;let m=!0;return p.folderPictures({product:e,src:t}).then(w=>{m&&(w!=null&&w.ok)&&w.pictures&&a({pictures:w.pictures,total:w.total??w.pictures.length})}).catch(()=>{}),()=>{m=!1}},[e,t,r]);const c=t.replace(/\/+$/,""),u=i!=null&&i.total?`${i.total} picture${i.total===1?"":"s"}`:null,d=l.jsxs("button",{type:"button",className:"folder-preview-name","data-folder":c,title:`${c}/`,onClick:()=>n(t),children:[l.jsx(Yh,{kind:"folder"}),l.jsx("span",{className:"folder-preview-path",children:FH(t,{thread:s,name:o==null?void 0:o.name})}),u&&l.jsx("span",{className:"folder-preview-count",children:u})]});if(!(i!=null&&i.pictures.length))return d;const h=i.pictures.slice(0,XY),f=i.total-h.length;return l.jsxs("span",{className:"folder-preview",children:[d,l.jsx("span",{className:"folder-preview-grid",children:h.map(p=>{const m=p.split("/").pop()??p;return l.jsxs("button",{type:"button",className:"folder-preview-shot","data-copy-file":p,title:m,onClick:()=>n(p),children:[l.jsx("img",{src:vo(p),alt:m,crossOrigin:"anonymous",loading:"lazy"}),l.jsx("span",{className:"folder-preview-label",children:m})]},p)})}),f>0&&l.jsxs("button",{type:"button",className:"folder-preview-more",onClick:()=>n(t),children:[f," more in the folder"]})]})}function Cg({kind:e,product:t,src:n,fallback:r,onOpen:s,children:o}){const[i,a]=g.useState(r);return g.useEffect(()=>{var c,u;a(r),!(!n||/^https?:/.test(n))&&((u=(c=window.zero)==null?void 0:c.openArtifact)==null||u.call(c,{product:t,src:qh(n)??n,mode:"resolve"}).then(d=>{d!=null&&d.ok&&d.opened&&a(`file://${d.opened}`)}).catch(()=>{}))},[t,n]),l.jsx(Yy,{kind:e,href:i,title:n,onClick:c=>{c.preventDefault(),s()},children:o})}function aI(e){return typeof e=="string"?e:Array.isArray(e)&&e.every(t=>typeof t=="string")?e.join(""):null}function ZY(e,t){const n=aI(t);return n===null?t:jM(e,n)??t}function eG({product:e,path:t,fallback:n,open:r,onOpen:s}){const[o,i]=g.useState(null);return g.useEffect(()=>{let a=!0;const c=window.zero;return c!=null&&c.openArtifact?(c.openArtifact({product:e,src:t,mode:"resolve"}).then(u=>{a&&i(u!=null&&u.ok&&u.opened?`file://${u.opened}`:null)}).catch(()=>{a&&i(null)}),()=>{a=!1}):(i(n??null),()=>{a=!1})},[e,t]),o?r?l.jsxs("button",{type:"button",className:"embed-collapsed",onClick:s,children:[l.jsx("span",{className:"ec-mark","aria-hidden":"true"}),l.jsx("span",{className:"ec-name",children:t}),l.jsx("span",{className:"ec-state",children:"open on the right"})]}):l.jsxs("div",{className:"artifact-embed",children:[l.jsxs("div",{className:"artifact-embed-bar",children:[l.jsx("button",{type:"button",className:"artifact-embed-path",onClick:s,children:t}),l.jsx("a",{href:o,target:"_blank",rel:"noreferrer",children:"open ↗"})]}),l.jsx("iframe",{src:o,tabIndex:-1,sandbox:"allow-scripts",title:t})]}):null}function tG({artifactView:e,previewSample:t,onOpenArtifact:n,artifactSlot:r,inlineArtifacts:s,headerTarget:o,cornerHeaderTarget:i,crumbFrom:a,item:c,parent:u,blockedBy:d,filed:h=[],runningMode:f,engineChoice:p,runningEngine:m,codexModels:w,codexModelDefault:b,session:x,live:v,stoppable:S,productDir:C,repoDir:O,selectedOption:N,interruptedFrom:P,onBackToInterrupted:M,returnedFromSnooze:R,scheduledUntil:L,scheduledByAgent:H,replyOpen:_,sending:Y,stalled:se,openDoc:re,resumeAt:T,onScrolled:W,onOpenDoc:le,onRedeliver:ge,onUnschedule:j,onClose:ae,onResolve:me,onPick:E,onReply:K,onReplySend:z,onReplyClose:xe,onStop:Oe,onRunNow:F,onPin:J,onReopen:ze,onSnooze:ye,onReveal:Z,onOpenItem:Ce,onApproveFiled:Ee,onRejectFiled:oe,closeAsk:ne,onNotice:Ie,onHandToAgent:Q,onAddPeople:he}){var B,tn,Ba;const te=g.useContext(Xt),ee=Hx(c,te),U=wl(c),I=c.agent??null,V=I?Ap(I):!1,ue=zj(c,u),G=!I&&(ue==null?void 0:ue.kind)==="said"?{text:ue.text,at:ue.at,on:ue.on}:null,ie=pn(c),we=nr(c),ve=ie||we,de=fe=>{const Ze=h.find(ft=>ft.id===fe);Ze&&Ce(Ze.item)},be=g.useContext(OT),Le=fe=>{const Ze=k1(be,fe,c.product);Ze?Ce(Ze):Ie(`Ticket ${fe} is not available in your threads.`)},Ye=fe=>{const Ze=k1(be,fe,c.product);return Ze?Co(Ze):null},at=fe=>{const Ze=h.find(ft=>ft.id===fe);Ze&&(Ee==null||Ee(Ze.item))},Ge=fe=>{const Ze=h.find(ft=>ft.id===fe);Ze&&(oe==null||oe(Ze.item))},Ke=I?Nq(I):!1,rt=((tn=(B=te==null?void 0:te.products.get(c.product))==null?void 0:B.team)==null?void 0:tn.direct)===!0,gt=S&&!rt,Ve=rt&&te?te.byId.get((c.people??[]).find(fe=>fe!==te.me)??(c.createdBy!==te.me?c.createdBy??"":c.assignee??""))??null:null,Ln=rt?(Ba=te==null?void 0:te.products.get(c.product))==null?void 0:Ba.team:null,ln=Ln&&te?[...new Set([...Ln.people??[],...Ln.sharedBy?[Ln.sharedBy]:[]])].filter(fe=>fe!==te.me).map(fe=>te.byId.get(fe)??null).filter(fe=>!!fe):[],Sn=rt&&te?ln.length>1?ln.map(fe=>bn(fe)):[bn(Ve)].filter(Boolean):null,Ys=Sn!=null&&Sn.length?kp(Sn):null,ts=ln.length>1?ln.map(fe=>fe.name).join(", "):(Ve==null?void 0:Ve.name)||Ys,ns=!I&&!ve&&!rt,rs=g.useRef(null),[cr,Do]=g.useState(1/0);g.useLayoutEffect(()=>{const fe=rs.current;if(!fe||(Do(fe.clientWidth),typeof ResizeObserver>"u"))return;const Ze=new ResizeObserver(()=>Do(fe.clientWidth));return Ze.observe(fe),()=>Ze.disconnect()},[]);const[zr,Dt]=g.useState(null),Gs=rt?dp(c,(te==null?void 0:te.me)??null):null,Js=Gs?Object.fromEntries(Gs.threads.map(fe=>[fe.uid,fe.fresh])):void 0;g.useEffect(()=>{Dt(re?null:p9(Gs))},[c.product,c.id]);const[Sr,ur]=g.useState(()=>{const fe=Number(typeof localStorage>"u"?NaN:localStorage.getItem(vj));return Number.isFinite(fe)&&fe>0?fe:ai.start}),qn=kj(Sr,Number.isFinite(cr)?cr:1400),_t=g.useCallback(fe=>{var ft;const Ze=kj(fe,((ft=rs.current)==null?void 0:ft.clientWidth)??1400);ur(Ze);try{localStorage.setItem(vj,String(Ze))}catch{}},[]);g.useEffect(()=>{if(!zr)return;const fe=Ze=>{var nn,Xn;if(Ze.key!=="Escape"||Ze.defaultPrevented)return;const ft=Ze.target;(nn=ft==null?void 0:ft.closest)!=null&&nn.call(ft,'.chat-emoji, .chat-emoji-all, .prio-menu, .th-menu, [role="dialog"]')||(Xn=ft==null?void 0:ft.closest)!=null&&Xn.call(ft,'textarea, input, [contenteditable="true"]')&&!ft.closest(".chat-thread-panel")||(Ze.preventDefault(),Ze.stopImmediatePropagation(),Dt(null))};return window.addEventListener("keydown",fe,!0),()=>window.removeEventListener("keydown",fe,!0)},[zr]),g.useEffect(()=>{re&&Dt(null)},[re]);const[Fr,Oo]=PY(cr),Br=ns&&!re,Oa=Br&&Fr;zY(Oo,Br);const _r=!I&&!rt?ql(m??null,c.model??null,{codexModels:w,codexDefault:b}):null,[Lo,et]=g.useState(!1);g.useEffect(()=>{_||et(!1)},[_]);const mn=g.useMemo(()=>T9(fi(c),Ol(c),I==null?void 0:I.name),[_,c.product,c.id,I==null?void 0:I.name]),jr=g.useRef(null),Yn=g.useRef(null),dr=g.useRef("");g.useEffect(()=>{if(!(!T||T.id!==c.id||dr.current===c.id)&&jr.current)return dr.current=c.id,z9(jr.current,T.top)},[c.id,T]),g.useEffect(()=>{if(!rt)return;const fe=jr.current;if(!fe)return;let Ze=!0;const ft=()=>{Ze=fe.scrollHeight-fe.scrollTop-fe.clientHeight<80},nn=()=>{Ze&&(fe.scrollTop=fe.scrollHeight)};fe.addEventListener("scroll",ft,{passive:!0});const Xn=new MutationObserver(nn);return Xn.observe(fe,{childList:!0,subtree:!0,characterData:!0}),nn(),()=>{fe.removeEventListener("scroll",ft),Xn.disconnect()}},[rt,c.id]),g.useEffect(()=>e9(jr.current),[c.id]),g.useEffect(()=>{const fe=jr.current;if(!fe||!W)return;let Ze=!1;const ft=()=>{Ze=!0},nn=()=>{Ze&&W(Math.round(fe.scrollTop))},Xn=["wheel","touchstart","keydown","mousedown"];for(const $n of Xn)fe.addEventListener($n,ft,{passive:!0});return fe.addEventListener("scroll",nn,{passive:!0}),()=>{for(const $n of Xn)fe.removeEventListener($n,ft);fe.removeEventListener("scroll",nn)}},[c.id,W]);const cn=g.useRef(null);g.useEffect(()=>{var fe;N!==null&&((fe=cn.current)==null||fe.scrollIntoView({block:"nearest"}))},[N]);const[Gn,jn]=g.useState(null);g.useEffect(()=>{jn(null)},[c.id]);const La=(fe,Ze)=>{const ft=Ze.querySelector(".opt-text");jn(B9(fe,!!ft&&F9(ft)))},ss=Gn===null?null:U.find(fe=>fe.n===Gn)??null,[vs,Wr]=g.useState(!1);g.useEffect(()=>{Wr(!1)},[c.id]);const Xs=fe=>{Wr(V9(Wt,Zs,fe.querySelector("span")))},Cn=c.product,[Ss,js]=g.useState(null);g.useEffect(()=>{let fe=!0;if(js(null),I)return()=>{fe=!1};const Ze=()=>{q.codeChange({product:c.product,src:Rh(c.id)}).then(nn=>{fe&&js(nn!=null&&nn.ok?V8(nn.change):null)}).catch(()=>{fe&&js(null)})};if(Ze(),!x)return()=>{fe=!1};const ft=setInterval(Ze,Ta(4e3,sr()));return()=>{fe=!1,clearInterval(ft)}},[c.product,c.id,c.updatedAt,x==null?void 0:x.startedAt,I]);const Ai=g.useRef({onOpenDoc:le,onNotice:Ie});g.useLayoutEffect(()=>{Ai.current={onOpenDoc:le,onNotice:Ie}});const{resolveSrc:$a,mdComponents:Xl,openHref:Ti,roots:$o}=g.useMemo(()=>{const fe=Fe=>!Fe||/^(https?|file|data):/.test(Fe)||!C?Fe:`file://${C}/${Fe.replace(/^\.\//,"")}`,Ze=[c.result,c.note,c.body,c.answer],ft=K8({dir:C,repo:O,id:c.id,texts:Ze}),nn=yu(...Ze,{dir:C}).some(mj),Xn=Fe=>{const vt=window.zero;return vt!=null&&vt.openArtifact?vt.openArtifact({product:Cn,src:Fe,mode:"resolve"}).then(zt=>zt!=null&&zt.ok&&zt.opened&&mj(zt.opened)?zt.opened:null):Promise.resolve(null)},$n=Fe=>{if(!Fe)return;const{onOpenDoc:vt,onNotice:zt}=Ai.current;if(vt&&(!/^https?:/.test(Fe)&&S_(Fe)||Ib(Fe))){vt(Fe);return}const un=window.zero;if(!(un!=null&&un.openArtifact)){window.open(fe(Fe),"_blank");return}const Hr=qh(Fe);un.openArtifact({product:Cn,src:Hr??Fe,...Hr?{mode:"source"}:{}}).then(At=>{At!=null&&At.ok||zt((At==null?void 0:At.error)||`${Fe} could not be opened.`)}).catch(()=>zt(`${Fe} could not be opened.`))};return{resolveSrc:fe,mdComponents:{pre:({children:Fe})=>{var Hr,At,Qu;const vt=Array.isArray(Fe)?Fe[0]:Fe,zt=(At=/language-([\w-]+)/.exec(((Hr=vt==null?void 0:vt.props)==null?void 0:Hr.className)??""))==null?void 0:At[1],un=I8(zt,String(((Qu=vt==null?void 0:vt.props)==null?void 0:Qu.children)??""));return un?l.jsx(L8,{source:un,fallback:l.jsx(Jj,{children:Fe})}):l.jsx(Jj,{children:Fe})},a:({href:Fe,children:vt})=>{const zt=Fe!=null&&Fe.startsWith(uu)?zc(Fe.slice(uu.length)):zc(Fe??"");if(zt)return l.jsx(LT,{id:zt,children:vt});if(Fe!=null&&Fe.startsWith(Yb))return l.jsx("span",{className:"chat-at",children:vt});if(Fe&&/\/$/.test(Fe)&&!/^(https?|data|file|mailto):/i.test(Fe))return l.jsx(QY,{product:Cn,folder:Fe,onOpen:$n,quiet:nn,thread:c.id},Fe);if(Fe&&!/^(https?|data):/.test(Fe)&&/\.(png|jpe?g|gif|webp|svg)(?:[?#]|$)/i.test(Fe)){const un=typeof vt=="string"?vt:Fe;return l.jsx(jg,{src:Fe,alt:un,roots:ft,onOpen:$n,find:Xn},Fe)}return Fe&&iw(Fe)?l.jsx(Xj,{src:Fe,label:aI(vt)??void 0,roots:ft,onOpen:$n},Fe):l.jsx(Cg,{kind:aw(Fe??""),product:Cn,src:Fe,fallback:fe(Fe),onOpen:()=>$n(Fe),children:Fe?ZY(Fe,vt):vt})},img:({src:Fe,alt:vt})=>l.jsx(jg,{src:Fe,alt:vt,roots:ft,onOpen:$n,find:Xn},Fe),code:({children:Fe,className:vt})=>{const zt=String(Fe??"");if(!vt&&zc(zt))return l.jsx("code",{children:Fe});const un=!vt&&qh(zt);if(un)return l.jsx(Cg,{kind:"code",product:Cn,src:un,fallback:fe(un),onOpen:()=>$n(un),children:Zh(zt)});const Hr=zt.trim(),At=!vt&&C&&Wc(Hr,C)||Hr;return!vt&&GY.test(At)?/\.(png|jpe?g|gif|webp)$/i.test(At)?l.jsx(jg,{src:At,alt:Hr,roots:ft,onOpen:$n,find:Xn},At):iw(At)?l.jsx(Xj,{src:At,label:Hr,roots:ft,onOpen:$n},At):l.jsx(Cg,{kind:aw(At),product:Cn,src:At,fallback:fe(At),onOpen:()=>$n(At),children:Zh(At)}):l.jsx("code",{className:vt,children:Fe})}},openHref:$n,roots:ft}},[Cn,C,O,c.id,c.result,c.note,c.body,c.answer]),Ql=g.useMemo(()=>[Cl,iB,[zH,{dir:C??null}]],[C]),is=fe=>l.jsx(jl,{remarkPlugins:Ql,components:Xl,urlTransform:EH,children:fe}),Po=g.useRef(null),zo=g.useCallback(fe=>{Po.current=fe,r==null||r(fe)},[r]);g.useEffect(()=>{var fe;r&&((fe=Po.current)==null||fe.scrollIntoView({block:"nearest"}))},[re,!!r]);const Cs=g.useMemo(()=>X8(c,C),[c.result,c.note,c.body,c.answer,C]),en=Sy(q.isFixtures,location.search)?"review-bundle.change":"artifact-layout-sample.change",Fo=t==="multiple"?["designs/w-n13/the-first-row.html",en,"artifact-layout-sample.md"]:t?[t==="code"?en:t==="notes"?"artifact-layout-sample.md":"designs/w-n13/the-first-row.html"]:[...new Set([...Cs,...yu(c.result,c.note,c.body,c.answer,{dir:C}).filter(fe=>/\.(md|markdown)$/i.test(fe)&&!bR(fe))])],$=Fb(c),Re=$,ht=e==="focus",Ht=Re&&!ht,hr=Re&&ht&&_,Jn=ip(c),Qs=(c[Jn]??"").trim(),Wt=g.useMemo(()=>K9(c),[c.result,c.note,c.body,c.title]),Zs=g.useMemo(()=>RR(c),[c.result,c.note,c.body,c.title]),fr=fe=>($&&Qs&&fe.trim()===Qs?YY(fe):fe).replace(/^##\s*Gist\s*\n+/i,""),Pa=l.jsx(hY,{item:rt?{...c,productName:"Messages"}:c,returned:!!R,facts:{...v,session:x,stalled:se,scheduledUntil:L,engineChoice:p,engine:m,inProgress:gt},lead:ns&&!Br?l.jsx(FY,{item:c}):null,stateShown:ns&&Br,onAddPeople:he}),Zl=Ss?l.jsxs("span",{className:"change-figures",title:q8(Ss),children:[gR(Ss).map(({sign:fe,text:Ze})=>l.jsx("span",{className:fe==="+"?"code-plus":"code-minus",children:Ze},fe)),l.jsxs("span",{className:"cf-files",children:["in ",yR(Ss)]})]}):null,ec=c.status!=="done",qp=KR(c,{session:x,queued:v.queued,runNow:v.runNow,inProgress:v.inProgress}),[za,Mi]=g.useState(!1),Fa=l.jsx(U4,{change:Zl,onViewChange:()=>le==null?void 0:le(Rh(c.id)),terminal:rt?null:za?"open":"closed",onToggleTerminal:()=>window.dispatchEvent(new Event("task-terminal-toggle")),onFinish:ec?me:null,onRunNow:qp&&F?F:null,pinned:ec&&J?!!c.pinned:null,onPin:J},`${c.product}:${c.id}`),Xu=gt?l.jsxs("button",{type:"button",className:"dock-stop",onClick:Oe,"aria-label":x?"Stop this agent":"Stop this task",title:x?"Stop this agent. It goes back to your inbox.":"Stop this task. It goes back to your inbox.",children:[l.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",focusable:"false",children:l.jsx("rect",{x:"1.5",y:"1.5",width:"9",height:"9",fill:"currentColor"})}),"Stop"]}):null,eo=l.jsx("button",{className:"back-esc","data-hint":"back",onClick:ae,"aria-label":"Back (esc)",title:"Back (esc)",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5"})})}),as=l.jsxs("div",{className:"keep-line",children:[l.jsx("div",{className:"keep-line-title",title:c.title,children:rt&&ts?ts:Co(c)}),Pa]}),Ns=rt&&ts?ts:Co(c),Ri=Br&&a?l.jsx(KY,{from:a,name:Ns,onBack:ae}):l.jsxs(l.Fragment,{children:[eo,as]});return l.jsx(nx.Provider,{value:{open:Le,name:Ye},children:l.jsxs("div",{className:"focus-pane",ref:rs,"data-summary":Oa?"open":Br?"rail":void 0,children:[!o&&eo,o?bs.createPortal(Ri,o):as,i&&bs.createPortal(l.jsx("span",{className:"ts-top",children:Fa}),i),l.jsx("div",{className:"focus-scroll",ref:jr,children:l.jsxs("div",{className:"focus",children:[P&&l.jsx(i7,{title:P,onBack:M??ae}),l.jsxs("div",{className:"focus-body markdown agent-thread",ref:Yn,onCopy:fe=>M8(fe.nativeEvent,Yn.current),children:[l.jsx(nG,{recap:G?null:zj(c,u),onOpen:()=>u&&Ce(u)}),se&&l.jsxs("button",{className:"stalled-bar",onClick:ge,children:[l.jsx("span",{className:"stalled-bar-label",children:"The agent stopped without finishing this. Your answer is still waiting."}),l.jsx("span",{className:"stalled-bar-go",children:"restart the agent →"})]}),c.status==="blocked"&&d&&l.jsxs("button",{className:"blocked-by",onClick:()=>Ce(d),children:[l.jsx("span",{className:"blocked-by-label",children:"Waiting on"}),l.jsx("span",{className:"blocked-by-title",children:d.title}),l.jsx("span",{className:"blocked-by-go",children:"open →"})]}),c.answer==="(withdrawn)"&&l.jsx("div",{className:"your-reply your-reply-withdrawn",children:l.jsx("div",{className:"your-reply-label",children:"You withdrew your reply (Z undoes a send)"})}),I&&l.jsx(U7,{pid:I.pid,sessionId:I.sessionId,cwd:I.cwd,name:I.name,movedAt:I.lastActiveAt??0,md:is}),ve?l.jsx("div",{className:"outcome",children:is(c.body??"")}):!I&&l.jsx(NY,{item:c,chat:rt,engine:m,session:x,opening:G,sending:Y,onSendNow:()=>q.sendNow({product:c.product,id:c.id}).catch(()=>{}),onOpenOrigin:()=>u&&Ce(u),md:is,clean:fr,onOpenDoc:le,filed:h.map(fe=>({...fe,at:fe.item.createdAt??0})),onOpenFiled:de,onApproveFiled:Ee&&at,onRejectFiled:oe&&Ge,onQuote:fe=>{Dl(c,i9(fi(c),fe)),window.dispatchEvent(new CustomEvent("zero:reply-restored",{detail:Ro(c)})),K()},onHandToAgent:Q?()=>Q(c):void 0,thread:rt?{open:zr,host:rs.current,width:qn,onOpen:fe=>Dt(fe),onClose:()=>Dt(null),onResize:_t,onSend:(fe,Ze)=>q.answer({product:c.product,id:c.id,answer:Ze,inReplyTo:fe}).catch(()=>Ie("That reply did not send. Try again.")),fresh:Js}:void 0}),(ve||I)&&l.jsx(Bx,{rows:h,label:"Filed from this thread",onOpen:de,onApprove:Ee&&at,onReject:oe&&Ge}),ne&&!ht&&l.jsx(Od,{ask:ne.ask,askAll:ne.ask,options:ne.options,peekOption:null,askPeek:!1,selectedOption:N,selRef:cn,onPick:ne.onPick,onOptionEnter:()=>{},onAskEnter:()=>{},setPeek:()=>{},setAskPeek:()=>{},keep:ne.keep}),Ht&&(ne?null:l.jsx(Od,{ask:Wt,askAll:Zs,options:U,peekOption:ss,askPeek:vs,selectedOption:N,selRef:cn,onPick:E,onOptionEnter:La,onAskEnter:Xs,setPeek:jn,setAskPeek:Wr})),!I&&l.jsx(v_,{product:c.product,id:c.id},`remote:${c.product}:${c.id}`),!I&&l.jsx(s8,{engine:m??"claude-code",item:c},`${c.product}:${c.id}`),!ee&&l.jsx(iY,{item:c,facts:{...v,session:x,stalled:se,scheduledUntil:L}})]}),r&&l.jsx("div",{className:"inline-artifact",ref:zo}),s&&!t&&l.jsx(H_,{product:Cn,paths:Fo,revision:c.updatedAt,openDoc:re,onOpen:fe=>n==null?void 0:n(fe,"beside")}),s&&t&&l.jsx("div",{className:"artifact-entry-list","aria-label":"Attachments",children:Fo.map(fe=>l.jsx(L_,{product:Cn,path:fe,revision:c.updatedAt,open:re===fe,onOpen:()=>n==null?void 0:n(fe,"beside"),onAddContext:Sy(q.isFixtures,location.search)?Ze=>{Dl(c,TP(fi(c),fe,Ze)),window.dispatchEvent(new CustomEvent("zero:reply-restored",{detail:Ro(c)})),K()}:void 0},fe))}),!s&&Cs.map(fe=>{const Ze=!!re&&re===fe;return Ze?null:l.jsx(eG,{product:Cn,path:fe,fallback:$a(fe),open:Ze,onOpen:()=>Ti(fe)},fe)}),(c.start==="later"&&!!j||(L??0)>0&&!!j||!!I&&!V&&!!Z||!I&&c.status==="blocked"&&!x)&&l.jsxs("div",{className:"focus-actions",children:[c.start==="later"&&j&&l.jsxs("button",{className:"focus-unschedule",onClick:j,children:["start it now",l.jsxs("span",{className:"dim",children:[" · ","not started yet"]})]}),c.start!=="later"&&(L??0)>0&&j&&l.jsxs("button",{className:"focus-unschedule",onClick:j,children:[H?"let it run now":"back to inbox",l.jsxs("span",{className:"dim",children:[" · ",(c.snoozedUntil??0)>Date.now()?"in Later until":H?"the agent paused this until":"scheduled for"," ",JY(L)]})]}),I&&!V&&Z&&l.jsxs("button",{className:"focus-stop",onClick:Z,children:["take me to it",l.jsxs("span",{className:"dim",children:[" · ","opens the app it is running in"]})]}),!I&&c.status==="blocked"&&!x&&l.jsx("button",{onClick:ze,children:"send back to agent"})]})]})}),l.jsx("div",{className:"focus-dock",children:l.jsx("div",{className:"focus-dock-inner",children:l.jsxs("div",{className:"dock-card",children:[!Re&&l.jsx(uY,{item:c}),ne&&ht&&l.jsx(Od,{ask:ne.ask,askAll:ne.ask,options:ne.options,peekOption:null,askPeek:!1,selectedOption:N,selRef:cn,onPick:ne.onPick,onOptionEnter:()=>{},onAskEnter:()=>{},setPeek:()=>{},setAskPeek:()=>{},keep:ne.keep}),hr&&(ne?null:l.jsx(Od,{ask:Wt,askAll:Zs,options:U,peekOption:ss,askPeek:vs,selectedOption:N,selRef:cn,onPick:E,onOptionEnter:La,onAskEnter:Xs,setPeek:jn,setAskPeek:Wr})),we||ie?null:Ke?l.jsx("div",{className:"dock-pill dock-pill-static",children:l.jsx("span",{className:"dock-pill-text",children:"Answer this one in its own window. A message from here would wait behind the box it is stuck on."})}):_?l.jsx(oG,{item:c,runningMode:f,runningEngine:m,codexModels:w,codexModelDefault:b,onSend:z,onClose:xe,onNotice:Ie,openModel:Lo,talkTo:rt?Sn:null,stop:Xu}):l.jsxs("button",{className:`dock-pill${mn.draft?" dock-pill-kept":""}`,onClick:K,children:[l.jsx("span",{className:"dock-pill-text",children:mn.text}),mn.files&&l.jsx("span",{className:"dock-pill-files",children:mn.files}),_r&&l.jsx("span",{className:"ts-model",title:"Which model this conversation runs on",onClick:fe=>{fe.stopPropagation(),et(!0),K()},children:_r}),l.jsx("span",{className:"dock-pill-key",children:l.jsx("kbd",{children:"R"})})]})]})})}),Oa&&l.jsx(UY,{item:c,team:te,onFinish:ec?me:null,onClose:Oo}),Br&&!Fr&&l.jsx(BY,{item:c,team:te,onOpen:Oo}),!rt&&l.jsx(xx,{product:c.product,id:c.id,onOpenChange:Mi},`${c.product}:${c.id}`)]})})}function nG({recap:e,onOpen:t}){if(!e||e.kind==="replied")return null;const n=e.kind==="said"?e.on:e.title;return l.jsxs("div",{className:"origin origin-oneline",onClick:t,title:`Open ${n}`,children:[l.jsxs("div",{className:"origin-label",children:["In response to · ",Bs(e.at)," ago",l.jsx("span",{className:"origin-open",children:"open →"})]}),l.jsx("div",{className:"origin-title",children:n})]})}function rG({rows:e,at:t,onPick:n,onHover:r}){const s=g.useRef(null);return g.useEffect(()=>{var o,i;(i=(o=s.current)==null?void 0:o.querySelector(".slash-row.cursor"))==null||i.scrollIntoView({block:"nearest"})},[t,e.length]),l.jsx("div",{className:"slash-menu",role:"listbox","aria-label":WV,ref:s,children:e.map((o,i)=>{const{typed:a,says:c}=t8(o);return l.jsxs("button",{className:i===t?"slash-row cursor":"slash-row",role:"option","aria-selected":i===t,onMouseDown:u=>{u.preventDefault(),n(o)},onMouseEnter:()=>r(i),children:[l.jsx("span",{className:"slash-cmd",children:a}),l.jsx("span",{className:"slash-hint",children:c})]},JV(o))})})}function sG({value:e,options:t,label:n,onChange:r}){const[s,o]=g.useState(!1),i=g.useRef(null);hp(i,s),g.useEffect(()=>{if(!s)return;const c=u=>{i.current&&!i.current.contains(u.target)&&o(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const a=t.find(c=>c.value===e);return l.jsxs("span",{className:"compose-word-wrap",ref:i,children:[s&&l.jsx("span",{className:"prio-menu model-menu",role:"listbox","aria-label":n,children:t.map(c=>l.jsx("button",{type:"button",role:"option","aria-selected":c.value===e,className:`prio-menu-row ${c.value===e?"on":""}`,onClick:()=>{r(c.value),o(!1)},children:l.jsx("span",{className:"prio-menu-label",children:c.label})},c.value))}),l.jsx("button",{type:"button",className:`compose-word set ${s?"open":""}`,title:n,"aria-haspopup":"listbox","aria-expanded":s,onClick:()=>o(c=>!c),children:((a==null?void 0:a.label)??e).replace(/(^|\s)\S/g,c=>c.toUpperCase())})]})}function oG({item:e,runningMode:t,runningEngine:n,codexModels:r=[],codexModelDefault:s=null,onSend:o,onClose:i,onNotice:a,stop:c,openModel:u=!1,talkTo:d=null}){var ee;g.useEffect(()=>{const U=document.querySelector(".dock-input");U&&(U.placeholder=d!=null&&d.length?`Reply to ${kp(d)}`:"What should the agent do next?")});const[h,f]=g.useState(()=>fi(e)),[p,m]=g.useState(()=>Ol(e));g.useEffect(()=>{const U=I=>{I.detail===Ro(e)&&(f(fi(e)),m(Ol(e)))};return window.addEventListener("zero:reply-restored",U),()=>window.removeEventListener("zero:reply-restored",U)},[e.product,e.id]);const[w,b]=g.useState(0),[x,v]=g.useState(null),S=kr(e.priority),C=x??S,[O,N]=g.useState(!1),[P,M]=g.useState(e.model??null),[R,L]=g.useState(e.effort??null);g.useEffect(()=>{N(!1),M(e.model??null),L(e.effort??null)},[e.product,e.id,e.model,e.effort]);const H=g.useRef(null),_=g.useRef(null),Y=()=>{var U;return(U=_.current)==null?void 0:U.click()},se=$7({on:!!(d!=null&&d.length)&&!e.agent,where:e,text:h,setText:f,input:H,people:d??[]}),[re,T]=g.useState(e.answerMode??null),[W,le]=g.useState(0),[ge,j]=g.useState([]),ae=!e.agent&&(n??In)===In&&h.startsWith("/");g.useEffect(()=>{if(j([]),!!ae)return rU(()=>q.commandCatalog(e),j)},[e.product,e.id,n,ae]),g.useEffect(()=>{Dl(e,h)},[h,e.product,e.id]),g.useEffect(()=>{const{dropped:U}=Dx(e,p);b(U.length)},[p,e.product,e.id]),g.useEffect(()=>{var U;(U=H.current)==null||U.focus()},[]),g.useEffect(()=>{T(e.answerMode??null)},[e.id,e.product]),g.useEffect(()=>{Ej(H.current)}),g.useEffect(()=>{var V;const U=(V=H.current)==null?void 0:V.closest(".focus-pane");if(!U||typeof ResizeObserver>"u")return;const I=new ResizeObserver(()=>Ej(H.current));return I.observe(U),()=>I.disconnect()},[]);const me=async U=>{if(!h.trim()&&!p.length)return;if(se.block){a(se.block);return}const I=h,V=()=>{var de;((de=H.current)==null?void 0:de.value)===I&&(f(""),bj(e))},ue=n==="codex"&&!e.agent?n8(h):null;if(ue){if(!ue.valid||p.length){a(gw.invalid);return}const de=await tR({product:e.product,id:e.id});(de.state==="running"||de.state==="done")&&V();return}if(e.agent?null:iU(h,n??"claude-code")){if(p.length){a("Send this command without attachments. Your draft has been kept.");return}const de=await r8({product:e.product,id:e.id},h);if(de.state==="copy")try{await navigator.clipboard.writeText(de.text??""),a("Response copied.")}catch{a("Could not copy the response. Your draft has been kept.");return}if(["done","copy"].includes(de.state)&&V(),de.state!=="forward")return}const ie=h.trim(),we={words:ie,attachments:p},ve=await hR(e.product,p);bj(e),o([se.encode(ie),ve].filter(Boolean).join(`
|
|
713
|
+
|
|
714
|
+
`),x?hu(x):void 0,Ie,we,re,O?{model:P,effort:R}:void 0)},E=!!h.trim()||p.length>0,K=(n??In)===In,z=!e.agent,xe=e.agent?null:aj(h),Oe=XV(xe,re!==null,K,ge),F=Oe.length>0,J=e.agent?null:ZV(h,K,ge),ze=re??(K?t??"auto":Dh),ye=U=>K?FV[U]:i2[U];g.useEffect(()=>{le(0)},[xe,ge]);const Z=U=>{if(U===null){a(`Permissions · back to this project's setting, ${ye(K?t??"auto":Dh)}`);return}a(`Permissions · ${ye(U)} for this thread`)},Ce=U=>{var I;T(U),Z(U),aj(h)!==null&&f(""),(I=H.current)==null||I.focus()},Ee=U=>{var I;if(U.kind==="mode"||U.kind==="codexMode"){Ce(U.mode);return}QV(U)&&(f(cz(U.cmd)),(I=H.current)==null||I.focus())},oe=U=>{const I=z&&U.startsWith("/")&&U.endsWith(" ")?U.slice(1,-1).toLowerCase():null,V=K?UV(I):l2(I);if(V){Ce(V);return}if(re!==null&&GV(I)){Ce(null);return}f(U)};g.useEffect(()=>{if(E)return;const U=I=>{var ue,G;((G=(ue=I.target)==null?void 0:ue.closest)==null?void 0:G.call(ue,".dock-card"))||i()};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[E,i]);const ne=!!rp(e),[Ie,Q]=g.useState(null),he=Ry(h),te=g.useRef(null);return g.useEffect(()=>{const U=he&&"rule"in he?he.rule:null;U&&!a1(U,te.current)&&Q(U),!U&&te.current&&a1(Ie,te.current)&&Q(null),te.current=U},[he&&"rule"in he?he.rule.at:null]),l.jsxs(l.Fragment,{children:[F&&l.jsx(rG,{rows:Oe,at:W,onPick:Ee,onHover:le}),J&&/^\/\S+\s*$/.test(h)&&l.jsxs("div",{className:"dock-ghost",style:{top:((ee=H.current)==null?void 0:ee.offsetTop)??0},"aria-hidden":!0,children:[l.jsx("span",{className:"dock-ghost-typed",children:h.endsWith(" ")?h:`${h} `}),e8(J)]}),se.menu,se.card,se.chips,l.jsx("textarea",{className:`dock-input${se.live?" with-mentions":""}`,ref:H,value:h,onChange:U=>{oe(U.target.value),se.track(U.target)},onSelect:U=>se.track(U.currentTarget),onScroll:U=>se.track(U.currentTarget),onClick:U=>se.click(U.currentTarget),placeholder:"What should the agent do next?",onKeyDown:U=>{var I;if(!se.keyDown(U)){if(U.key==="Tab"&&U.shiftKey&&z){U.preventDefault();const V=K?KV(ze):a2(ze);T(V),Z(V);return}if(F){if(U.key==="ArrowDown"){U.preventDefault(),le(V=>(V+1)%Oe.length);return}if(U.key==="ArrowUp"){U.preventDefault(),le(V=>(V-1+Oe.length)%Oe.length);return}if(U.key==="Enter"&&!U.metaKey&&!U.ctrlKey||U.key==="Tab"){U.preventDefault(),Ee(Oe[W]??Oe[0]);return}if(U.key==="Escape"){U.preventDefault(),U.stopPropagation(),f("");return}}(U.metaKey||U.ctrlKey)&&U.key==="Enter"&&me(),U.key==="Escape"&&(U.stopPropagation(),E?(I=H.current)==null||I.blur():i())}},onPaste:async U=>{const I=await dR(U);I.length&&(U.preventDefault(),m(V=>[...V,...I]))},onDragOver:U=>U.preventDefault(),onDrop:async U=>{U.preventDefault();const I=await rf(U.dataTransfer.files);I.length&&m(V=>[...V,...I])}}),l.jsx("input",{ref:_,type:"file",multiple:!0,style:{display:"none"},onChange:async U=>{const I=await rf(U.target.files??[]);I.length&&m(V=>[...V,...I]),U.target.value=""}}),l.jsx(VR,{attachments:p,onRemove:U=>m(I=>I.filter((V,ue)=>ue!==U))}),Ie&&l.jsx("div",{className:"compose-note",children:ne?"This changes the repeating task.":"This makes it repeating."}),he&&"unreadable"in he&&l.jsx("div",{className:"compose-note",children:"Not understood, so this happens once."}),w>0&&l.jsx("div",{className:"compose-note",children:w===1?"One pasted image is too big to save. Closing the box loses it.":`${w} pasted images are too big to save. Closing the box loses them.`}),l.jsxs("div",{className:"compose-sentence",children:[d!=null&&d.length?l.jsx(j9,{box:H,onChange:oe,onAttach:Y}):null,!(d!=null&&d.length)&&sr()?l.jsx("button",{type:"button",className:"compose-attach","aria-label":"Attach a file or picture",title:"Attach a file or picture",onClick:Y,children:l.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"m21 11.5-8.6 8.6a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6l8-8"})})}):null,l.jsx("span",{className:"compose-clauses",children:e.agent?l.jsxs("span",{className:"dim",children:["Goes straight into ",e.agent.name,"."]}):d!=null&&d.length?l.jsx("span",{className:"dim",children:se.block??NU(d)}):l.jsxs(l.Fragment,{children:[l.jsx(OB,{variant:"word",value:C,set:!!x,onChange:v,title:"Priority"})," priority. ",Ie&&l.jsxs(l.Fragment,{children:[l.jsx(d8,{value:{runAt:0,repeat:Ie},onChange:U=>Q(U.repeat),only:"repeat",empty:"Runs once"}),". "]}),z&&l.jsxs(l.Fragment,{children:["In ",l.jsx(sG,{label:"What this message may do",value:ze,options:K?fa.map(U=>({value:U,label:sa[U]})):ua.map(U=>({value:U,label:Oh[U].label})),onChange:U=>Ce(U)})," Mode. "]}),"On ",l.jsx(g8,{value:P,onChange:U=>{N(!0),M(U)},engine:n,codexModels:r,codexDefault:s,effort:R,onEffortChange:U=>{N(!0),L(U)},title:"Which model this conversation runs on",openAtStart:u}),"."]})}),c&&!E?c:l.jsxs("button",{className:"dock-send",onClick:()=>me(),disabled:!E||!!se.block,title:se.block??"Send · ⌘↵",children:["Send ",l.jsx("kbd",{children:"⌘↵"})]})]})]})}function $w({kind:e,children:t}){return l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="open"?l.jsx("path",{d:"M11 3h6v6m0-6-8 8M7 4H4a1 1 0 0 0-1 1v11a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1v-3"}):e==="close"?l.jsx("path",{d:"m5 5 10 10M15 5 5 15"}):t})}function iG(e,t){return{label:t?"Exit Focus":"Focus",hint:t?"Return to the task · Esc":"Give this document the full workspace",icon:e==="text"?null:`${e.startsWith("corners")?"corners":e}-${t?"exit":"enter"}`}}function aG({style:e,focused:t,onClick:n}){const r=iG(e,t);return l.jsxs("button",{type:"button",className:`artifact-expand focus-mode-control${e==="corners-icon"||e==="corners-bare"?" focus-icon-only":""}${e==="corners-bare"?" focus-bare":""}`,title:r.hint,"aria-label":r.label,onClick:n,children:[r.icon&&l.jsx($w,{children:e.startsWith("corners")?l.jsx("path",{d:t?"M3 7h4V3m6 0v4h4M3 13h4v4m6 0v-4h4":"M7 3H3v4m10-4h4v4M3 13v4h4m6 0h4v-4"}):l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"2.5",y:"3.5",width:"15",height:"13",rx:"1"}),t?l.jsx(l.Fragment,{children:l.jsx("path",{d:"M7.5 3.5v13M12 8l-2 2 2 2m-2-2h5"})}):l.jsx("rect",{x:"6",y:"6.5",width:"8",height:"7",rx:".5"})]})}),e!=="corners-icon"&&e!=="corners-bare"&&l.jsx("span",{children:r.label}),t&&e==="text"&&l.jsx("kbd",{children:"Esc"})]})}const lG=1e3,lI=8e3,cG=4e3,uG=2e3,dG="allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-downloads";async function hG(e,t=fetch,n=cG){const r=new AbortController,s=setTimeout(()=>r.abort(),n);try{return await t(e,{mode:"no-cors",cache:"no-store",signal:r.signal}),"up"}catch{return r.signal.aborted?"slow":"down"}finally{clearTimeout(s)}}function fG(e){try{return new URL(e).host}catch{return e}}function cI(e){const t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function pG(e,t,n){const r=fG(t),s=cI(n);return e==="down"?{state:"down",label:"Not running",host:r,detail:"Nothing is answering here. It opens by itself once the app starts.",retry:!0,clock:s}:n>=lI?{state:"slow",label:"Still trying",host:r,detail:"It is slow to answer. This keeps trying.",retry:!0,clock:s}:n>=lG?{state:"connecting",label:"Connecting",host:r,detail:"Waiting for the app to answer.",retry:!1,clock:s}:null}function mG(e,t){return e==="down"?!1:e!=="up"||t<6e4}function gG(e,t){return e&&(t==="up"||t==="slow")}function yG(e){const t=e!==null&&Ib(e),[n,r]=g.useState("checking"),[s,o]=g.useState(0),[i,a]=g.useState(0),[c,u]=g.useState(0),d=g.useRef("checking");g.useEffect(()=>{if(!t||!e)return;let f=!0,p,m;const w=()=>{clearTimeout(m);const x=Date.now();u(0);const v=()=>{const S=Date.now()-x;u(S),f&&mG(d.current,S)&&(m=setTimeout(v,500))};m=setTimeout(v,500)};d.current="checking",r("checking"),w();const b=async()=>{const x=await hG(e);f&&(d.current==="down"&&x!=="down"&&(o(v=>v+1),d.current=x,w()),d.current=x,r(x),x!=="up"&&(p=setTimeout(b,uG)))};return b(),()=>{f=!1,clearTimeout(p),clearTimeout(m)}},[t,e,i]);const h=g.useCallback(()=>{d.current="checking",r("checking"),o(f=>f+1),a(f=>f+1)},[]);return{local:t,phase:n,attempt:s,waited:c,retry:h}}function wG({status:e,onRetry:t}){return e?l.jsxs("div",{className:"local-status","data-state":e.state,role:"status","aria-live":"polite",children:[l.jsx("div",{className:"local-status-host",children:e.host}),l.jsxs("div",{className:"local-status-log",children:[l.jsxs("div",{className:"local-status-line",children:[l.jsx("span",{className:"local-status-mark",children:"›"}),l.jsx("span",{children:"Opening"}),l.jsx("span",{className:"local-status-clock",children:"0:00"})]}),e.state==="slow"&&l.jsxs("div",{className:"local-status-line",children:[l.jsx("span",{className:"local-status-mark",children:"›"}),l.jsx("span",{children:"Slow to answer"}),l.jsx("span",{className:"local-status-clock",children:cI(lI)})]}),l.jsxs("div",{className:"local-status-line local-status-now",children:[l.jsx("span",{className:"local-status-dot","aria-hidden":"true"}),l.jsx("span",{children:e.label}),e.state!=="down"&&l.jsx("span",{className:"local-status-clock",children:e.clock})]})]}),l.jsx("div",{className:"local-status-detail",children:e.detail}),e.retry&&l.jsx("button",{type:"button",className:"local-status-retry",onClick:t,children:"Try again"})]}):l.jsx("div",{className:"local-status","data-state":"quiet","aria-hidden":"true"})}function En(e){this.content=e}En.prototype={constructor:En,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,s=r.find(e),o=r.content.slice();return s==-1?o.push(n||e,t):(o[s+1]=t,n&&(o[s]=n)),new En(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new En(n)},addToStart:function(e,t){return new En([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new En(n)},addBefore:function(e,t,n){var r=this.remove(t),s=r.content.slice(),o=r.find(e);return s.splice(o==-1?s.length:o,0,t,n),new En(s)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=En.from(e),e.size?new En(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=En.from(e),e.size?new En(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=En.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}};En.from=function(e){if(e instanceof En)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new En(t)};function uI(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),o=t.child(r);if(s==o){n+=s.nodeSize;continue}if(!s.sameMarkup(o))return n;if(s.isText&&s.text!=o.text){let i=s.text,a=o.text,c=0;for(;i[c]==a[c];c++)n++;return c&&c<i.length&&c<a.length&&fI(i.charCodeAt(c-1))&&hI(i.charCodeAt(c))&&n--,n}if(s.content.size||o.content.size){let i=uI(s.content,o.content,n+1);if(i!=null)return i}n+=s.nodeSize}}function dI(e,t,n,r){for(let s=e.childCount,o=t.childCount;;){if(s==0||o==0)return s==o?null:{a:n,b:r};let i=e.child(--s),a=t.child(--o),c=i.nodeSize;if(i==a){n-=c,r-=c;continue}if(!i.sameMarkup(a))return{a:n,b:r};if(i.isText&&i.text!=a.text){let u=i.text,d=a.text,h=u.length,f=d.length;for(;h>0&&f>0&&u[h-1]==d[f-1];)h--,f--,n--,r--;return h&&f&&h<u.length&&fI(u.charCodeAt(h-1))&&hI(u.charCodeAt(h))&&(n++,r++),{a:n,b:r}}if(i.content.size||a.content.size){let u=dI(i.content,a.content,n-1,r-1);if(u)return u}n-=c,r-=c}}function hI(e){return e>=56320&&e<57344}function fI(e){return e>=55296&&e<56320}class je{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,s=0,o){for(let i=0,a=0;a<n;i++){let c=this.content[i],u=a+c.nodeSize;if(u>t&&r(c,s+a,o||null,i)!==!1&&c.content.size){let d=a+1;c.nodesBetween(Math.max(0,t-d),Math.min(c.content.size,n-d),r,s+d)}a=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,s){let o="",i=!0;return this.nodesBetween(t,n,(a,c)=>{let u=a.isText?a.text.slice(Math.max(t,c)-c,n-c):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&r&&(i?i=!1:o+=r),o+=u},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,s=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),o=1);o<t.content.length;o++)s.push(t.content[o]);return new je(s,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],s=0;if(n>t)for(let o=0,i=0;i<n;o++){let a=this.content[o],c=i+a.nodeSize;c>t&&((i<t||c>n)&&(a.isText?a=a.cut(Math.max(0,t-i),Math.min(a.text.length,n-i)):a=a.cut(Math.max(0,t-i-1),Math.min(a.content.size,n-i-1))),r.push(a),s+=a.nodeSize),i=c}return new je(r,s)}cutByIndex(t,n){return t==n?je.empty:t==0&&n==this.content.length?this:new je(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let s=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return s[t]=n,new je(s,o)}addToStart(t){return new je([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new je(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];t(s,r,n),r+=s.nodeSize}}findDiffStart(t,n=0){return uI(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return dI(this,t,n,r)}findIndex(t){if(t==0)return Fd(0,t);if(t==this.size)return Fd(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),o=r+s.nodeSize;if(o>=t)return o==t?Fd(n+1,o):Fd(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return je.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return je.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return je.empty;let n,r=0;for(let s=0;s<t.length;s++){let o=t[s];r+=o.nodeSize,s&&o.isText&&t[s-1].sameMarkup(o)?(n||(n=t.slice(0,s)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new je(n||t,r)}static from(t){if(!t)return je.empty;if(t instanceof je)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new je([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}je.empty=new je([],0);const Ng={index:0,offset:0};function Fd(e,t){return Ng.index=e,Ng.offset=t,Ng}function cf(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!cf(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!cf(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}let Mt=class Pw{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let s=0;s<t.length;s++){let o=t[s];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,s));else{if(o.type.excludes(this.type))return t;!r&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,s)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&cf(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Pw.none;if(t instanceof Pw)return[t];let n=t.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Mt.none=[];class xu extends Error{}class Pe{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=mI(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new Pe(r,this.openStart,this.openEnd)}removeBetween(t,n){return new Pe(pI(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Pe.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Pe(je.fromJSON(t,n.content),r,s)}static maxOpen(t,n=!0){let r=0,s=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)s++;return new Pe(t,r,s)}}Pe.empty=new Pe(je.empty,0,0);function pI(e,t,n){let{index:r,offset:s}=e.findIndex(t),o=e.maybeChild(r),{index:i,offset:a}=e.findIndex(n);if(s==t||o.isText){if(a!=n&&!e.child(i).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return e.replaceChild(r,o.copy(pI(o.content,t-s-1,n-s-1)))}function mI(e,t,n,r,s,o){let{index:i,offset:a}=e.findIndex(t),c=e.maybeChild(i);if(a==t||c.isText)return o&&r<=0&&s<=0&&!o.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let u=mI(c.content,t-a-1,n,i==0?r-1:0,i==e.childCount-1?s-1:0,c);return u&&e.replaceChild(i,c.copy(u))}function bG(e,t,n){if(n.openStart>e.depth)throw new xu("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new xu("Inconsistent open depths");return gI(e,t,n,0)}function gI(e,t,n,r){let s=e.index(r),o=e.node(r);if(s==t.index(r)&&r<e.depth-n.openStart){let i=gI(e,t,n,r+1);return o.copy(o.content.replaceChild(s,i))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let i=e.parent,a=i.content;return ma(i,a.cut(0,e.parentOffset).append(n.content).append(a.cut(t.parentOffset)))}else{let{start:i,end:a}=xG(n,e);return ma(o,wI(e,i,a,t,r))}else return ma(o,uf(e,t,r))}function yI(e,t){if(!t.type.compatibleContent(e.type))throw new xu("Cannot join "+t.type.name+" onto "+e.type.name)}function zw(e,t,n){let r=e.node(n);return yI(r,t.node(n)),r}function pa(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Vc(e,t,n,r){let s=(t||e).node(n),o=0,i=t?t.index(n):s.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(pa(e.nodeAfter,r),o++));for(let a=o;a<i;a++)pa(s.child(a),r);t&&t.depth==n&&t.textOffset&&pa(t.nodeBefore,r)}function ma(e,t){if(!e.type.validContent(t))throw new xu("Invalid content for node "+e.type.name);return e.copy(t)}function wI(e,t,n,r,s){let o=e.depth>s&&zw(e,t,s+1),i=r.depth>s&&zw(n,r,s+1),a=[];return Vc(null,e,s,a),o&&i&&t.index(s)==n.index(s)?(yI(o,i),pa(ma(o,wI(e,t,n,r,s+1)),a)):(o&&pa(ma(o,uf(e,t,s+1)),a),Vc(t,n,s,a),i&&pa(ma(i,uf(n,r,s+1)),a)),Vc(r,null,s,a),new je(a)}function uf(e,t,n){let r=[];if(Vc(null,e,n,r),e.depth>n){let s=zw(e,t,n+1);pa(ma(s,uf(e,t,n+1)),r)}return Vc(t,null,n,r),new je(r)}function xG(e,t){let n=t.depth-e.openStart,s=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)s=t.node(o).copy(je.from(s));return{start:s.resolveNoCache(e.openStart+n),end:s.resolveNoCache(s.content.size-e.openEnd-n)}}class ku{constructor(t,n,r){this.pos=t,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=t.child(n);return r?t.child(n).cut(r):s}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)s+=r.child(o).nodeSize;return s}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return Mt.none;if(this.textOffset)return t.child(n).marks;let r=t.maybeChild(n-1),s=t.maybeChild(n);if(!r){let a=r;r=s,s=a}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=t.parent.maybeChild(t.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!n||n(this.node(r))))return new df(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,o=n;for(let i=t;;){let{index:a,offset:c}=i.content.findIndex(o),u=o-c;if(r.push(i,a,s+c),!u||(i=i.child(a),i.isText))break;o=u-1,s+=c+1}return new ku(n,r,o)}static resolveCached(t,n){let r=Qj.get(t);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==n)return i}else Qj.set(t,r=new kG);let s=r.elts[r.i]=ku.resolve(t,n);return r.i=(r.i+1)%vG,s}}class kG{constructor(){this.elts=[],this.i=0}}const vG=12,Qj=new WeakMap;class df{constructor(t,n,r){this.$from=t,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const SG=Object.create(null);let pi=class Fw{constructor(t,n,r,s=Mt.none){this.type=t,this.attrs=n,this.marks=s,this.content=r||je.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,r,s=0){this.content.nodesBetween(t,n,r,s,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,r,s){return this.content.textBetween(t,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,r){return this.type==t&&cf(this.attrs,n||t.defaultAttrs||SG)&&Mt.sameSet(this.marks,r||Mt.none)}copy(t=null){return t==this.content?this:new Fw(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Fw(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,r=!1){if(t==n)return Pe.empty;let s=this.resolve(t),o=this.resolve(n),i=r?0:s.sharedDepth(n),a=s.start(i),u=s.node(i).content.cut(s.pos-a,o.pos-a);return new Pe(u,s.depth-i,o.depth-i)}replace(t,n,r){return bG(this.resolve(t),this.resolve(n),r)}nodeAt(t){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(t);if(n=n.maybeChild(r),!n)return null;if(s==t||n.isText)return n;t-=s+1}}childAfter(t){let{index:n,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(t){return ku.resolveCached(this,t)}resolveNoCache(t){return ku.resolve(this,t)}rangeHasMark(t,n,r){let s=!1;return n>t&&this.nodesBetween(t,n,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),bI(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,r=je.empty,s=0,o=r.childCount){let i=this.contentMatchAt(t).matchFragment(r,s,o),a=i&&i.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let c=s;c<o;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(t,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(t).matchType(r),i=o&&o.matchFragment(this.content,n);return i?i.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=Mt.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),t=r.addToSet(t)}if(!Mt.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,r)}let s=je.fromJSON(t,n.content),o=t.nodeType(n.type).create(n.attrs,s,r);return o.type.checkAttrs(o.attrs),o}};pi.prototype.text=void 0;class hf extends pi{constructor(t,n,r,s){if(super(t,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):bI(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new hf(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new hf(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function bI(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class Sa{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new jG(t,n);if(r.next==null)return Sa.empty;let s=xI(r);r.next&&r.err("Unexpected trailing text");let o=RG(MG(s));return IG(o,r),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,r=t.childCount){let s=this;for(let o=n;s&&o<r;o++)s=s.matchType(t.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let r=0;r<t.next.length;r++)if(this.next[n].type==t.next[r].type)return!0;return!1}fillBefore(t,n=!1,r=0){let s=[this];function o(i,a){let c=i.matchFragment(t,r);if(c&&(!n||c.validEnd))return je.from(a.map(u=>u.createAndFill()));for(let u=0;u<i.next.length;u++){let{type:d,next:h}=i.next[u];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(h)==-1){s.push(h);let f=o(h,a.concat(d));if(f)return f}}return null}return o(this,[])}findWrapping(t){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==t)return this.wrapCache[r+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(t)){let i=[];for(let a=s;a.type;a=a.via)i.push(a.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:a,next:c}=o.next[i];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!s.type||c.validEnd)&&(r.push({match:a.contentMatch,type:a,via:s}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(r){t.push(r);for(let s=0;s<r.next.length;s++)t.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),t.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+t.indexOf(r.next[i].next);return o}).join(`
|
|
715
|
+
`)}}Sa.empty=new Sa(!0);class jG{constructor(t,n){this.string=t,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function xI(e){let t=[];do t.push(CG(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function CG(e){let t=[];do t.push(NG(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function NG(e){let t=TG(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=EG(e,t);else break;return t}function Zj(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function EG(e,t){let n=Zj(e),r=n;return e.eat(",")&&(e.next!="}"?r=Zj(e):r=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function AG(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let s=[];for(let o in n){let i=n[o];i.isInGroup(t)&&s.push(i)}return s.length==0&&e.err("No node type or group '"+t+"' found"),s}function TG(e){if(e.eat("(")){let t=xI(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=AG(e,e.next).map(n=>(e.inline==null?e.inline=n.isInline:e.inline!=n.isInline&&e.err("Mixing inline and block content"),{type:"name",value:n}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function MG(e){let t=[[]];return s(o(e,0),n()),t;function n(){return t.push([])-1}function r(i,a,c){let u={term:c,to:a};return t[i].push(u),u}function s(i,a){i.forEach(c=>c.to=a)}function o(i,a){if(i.type=="choice")return i.exprs.reduce((c,u)=>c.concat(o(u,a)),[]);if(i.type=="seq")for(let c=0;;c++){let u=o(i.exprs[c],a);if(c==i.exprs.length-1)return u;s(u,a=n())}else if(i.type=="star"){let c=n();return r(a,c),s(o(i.expr,c),c),[r(c)]}else if(i.type=="plus"){let c=n();return s(o(i.expr,a),c),s(o(i.expr,c),c),[r(c)]}else{if(i.type=="opt")return[r(a)].concat(o(i.expr,a));if(i.type=="range"){let c=a;for(let u=0;u<i.min;u++){let d=n();s(o(i.expr,c),d),c=d}if(i.max==-1)s(o(i.expr,c),c);else for(let u=i.min;u<i.max;u++){let d=n();r(c,d),s(o(i.expr,c),d),c=d}return[r(c)]}else{if(i.type=="name")return[r(a,void 0,i.value)];throw new Error("Unknown expr type")}}}}function kI(e,t){return t-e}function eC(e,t){let n=[];return r(t),n.sort(kI);function r(s){let o=e[s];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(s);for(let i=0;i<o.length;i++){let{term:a,to:c}=o[i];!a&&n.indexOf(c)==-1&&r(c)}}}function RG(e){let t=Object.create(null);return n(eC(e,0));function n(r){let s=[];r.forEach(i=>{e[i].forEach(({term:a,to:c})=>{if(!a)return;let u;for(let d=0;d<s.length;d++)s[d][0]==a&&(u=s[d][1]);eC(e,c).forEach(d=>{u||s.push([a,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let o=t[r.join(",")]=new Sa(r.indexOf(e.length-1)>-1);for(let i=0;i<s.length;i++){let a=s[i][1].sort(kI);o.next.push({type:s[i][0],next:t[a.join(",")]||n(a)})}return o}}function IG(e,t){for(let n=0,r=[e];n<r.length;n++){let s=r[n],o=!s.validEnd,i=[];for(let a=0;a<s.next.length;a++){let{type:c,next:u}=s.next[a];i.push(c.name),o&&!(c.isText||c.hasRequiredAttrs())&&(o=!1),r.indexOf(u)==-1&&r.push(u)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function vI(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function SI(e,t){let n=Object.create(null);for(let r in e){let s=t&&t[r];if(s===void 0){let o=e[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function jI(e,t,n,r){for(let s in t)if(!(s in e))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in e)e[s].validate&&e[s].validate(t[s])}function CI(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new OG(e,r,t[r]);return n}let tC=class NI{constructor(t,n,r){this.name=t,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=CI(t,r.attrs),this.defaultAttrs=vI(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Sa.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:SI(this.attrs,t)}create(t=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new pi(this,this.computeAttrs(t),je.from(n),Mt.setFrom(r))}createChecked(t=null,n,r){return n=je.from(n),this.checkContent(n),new pi(this,this.computeAttrs(t),n,Mt.setFrom(r))}createAndFill(t=null,n,r){if(t=this.computeAttrs(t),n=je.from(n),n.size){let i=this.contentMatch.fillBefore(n);if(!i)return null;n=i.append(n)}let s=this.contentMatch.matchFragment(n),o=s&&s.fillBefore(je.empty,!0);return o?new pi(this,t,n.append(o),Mt.setFrom(r)):null}validContent(t){let n=this.contentMatch.matchFragment(t);if(!n||!n.validEnd)return!1;for(let r=0;r<t.childCount;r++)if(!this.allowsMarks(t.child(r).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){jI(this.attrs,t,"node",this.name)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let n=0;n<t.length;n++)if(!this.allowsMarkType(t[n].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let n;for(let r=0;r<t.length;r++)this.allowsMarkType(t[r].type)?n&&n.push(t[r]):n||(n=t.slice(0,r));return n?n.length?n:Mt.none:t}static compile(t,n){let r=Object.create(null);t.forEach((o,i)=>r[o]=new NI(o,n,i));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function DG(e,t,n){let r=n.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}class OG{constructor(t,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?DG(t,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Rp{constructor(t,n,r,s){this.name=t,this.rank=n,this.schema=r,this.spec=s,this.attrs=CI(t,s.attrs),this.excluded=null;let o=vI(this.attrs);this.instance=o?new Mt(this,o):null}create(t=null){return!t&&this.instance?this.instance:new Mt(this,SI(this.attrs,t))}static compile(t,n){let r=Object.create(null),s=0;return t.forEach((o,i)=>r[o]=new Rp(o,s++,n,i)),r}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}checkAttrs(t){jI(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class EI{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in t)n[s]=t[s];n.nodes=En.from(t.nodes),n.marks=En.from(t.marks||{}),this.nodes=tC.compile(this.spec.nodes,this),this.marks=Rp.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",a=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=Sa.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=a=="_"?null:a?nC(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:nC(this,i.split(" "))}this.nodeFromJSON=s=>pi.fromJSON(this,s),this.markFromJSON=s=>Mt.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,n=null,r,s){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof tC){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(n,r,s)}text(t,n){let r=this.nodes.text;return new hf(r,r.defaultAttrs,t,Mt.setFrom(n))}mark(t,n){return typeof t=="string"&&(t=this.marks[t]),t.create(n)}nodeType(t){let n=this.nodes[t];if(!n)throw new RangeError("Unknown node type: "+t);return n}}function nC(e,t){let n=[];for(let r=0;r<t.length;r++){let s=t[r],o=e.marks[s],i=o;if(o)n.push(o);else for(let a in e.marks){let c=e.marks[a];(s=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(s)>-1)&&n.push(i=c)}if(!i)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}function LG(e){return e.tag!=null}function $G(e){return e.style!=null}class mi{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(LG(s))this.tags.push(s);else if($G(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=t.nodes[s.node];return o.contentMatch.matchType(o)})}parse(t,n={}){let r=new sC(this,n,!1);return r.addAll(t,Mt.none,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new sC(this,n,!0);return r.addAll(t,Mt.none,n.from,n.to),Pe.maxOpen(r.finish())}matchTag(t,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(FG(t,o.tag)&&(o.namespace===void 0||t.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(t);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(t,n,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],a=i.style;if(!(a.indexOf(t)!=0||i.context&&!r.matchesContext(i.context)||a.length>t.length&&(a.charCodeAt(t.length)!=61||a.slice(t.length+1)!=n))){if(i.getAttrs){let c=i.getAttrs(n);if(c===!1)continue;i.attrs=c||void 0}return i}}}static schemaRules(t){let n=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<n.length;i++){let a=n[i];if((a.priority==null?50:a.priority)<o)break}n.splice(i,0,s)}for(let s in t.marks){let o=t.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=oC(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in t.nodes){let o=t.nodes[s].spec.parseDOM;o&&o.forEach(i=>{r(i=oC(i)),i.node||i.ignore||i.mark||(i.node=s)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new mi(t,mi.schemaRules(t)))}}const AI={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},PG={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},TI={ol:!0,ul:!0},vu=1,Bw=2,qc=4;function rC(e,t,n){return t!=null?(t?vu:0)|(t==="full"?Bw:0):e&&e.whitespace=="pre"?vu|Bw:n&~qc}class Bd{constructor(t,n,r,s,o,i){this.type=t,this.attrs=n,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=Mt.none,this.match=o||(i&qc?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(je.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(t.type))?(this.match=r,s):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&vu)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let n=je.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(je.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!AI.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class sC{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,o,i=rC(null,n.preserveWhitespace,0)|(r?qc:0);s?o=new Bd(s.type,s.attrs,Mt.none,!0,n.topMatch||s.type.contentMatch,i):r?o=new Bd(null,null,Mt.none,!0,null,i):o=new Bd(t.schema.topNodeType,null,Mt.none,!0,null,i),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let r=t.nodeValue,s=this.top,o=s.options&Bw?"full":this.localPreserveWS||(s.options&vu)>0,{schema:i}=this.parser;if(o==="full"||s.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
|
|
716
|
+
`);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let c=0;c<a.length;c++)c&&this.insertNode(i.linebreakReplacement.create(),n,!0),a[c]&&this.insertNode(i.text(a[c]),n,!/\S/.test(a[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=s.content[s.content.length-1],c=t.previousSibling;(!a||c&&c.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),n,!/\S/.test(r)),this.findInText(t)}else this.findInside(t)}addElement(t,n,r){let s=this.localPreserveWS,o=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let i=t.nodeName.toLowerCase(),a;TI.hasOwnProperty(i)&&this.parser.normalizeLists&&zG(t);let c=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(a=this.parser.matchTag(t,this,r));e:if(c?c.ignore:PG.hasOwnProperty(i))this.findInside(t),this.ignoreFallback(t,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(t=c.skip);let u,d=this.needsBlock;if(AI.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),u=!0,o.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let h=c&&c.skip?n:this.readStyles(t,n);h&&this.addAll(t,h),u&&this.sync(o),this.needsBlock=d}else{let u=this.readStyles(t,n);u&&this.addElementByRule(t,c,u,c.consuming===!1?a:void 0)}this.localPreserveWS=s}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
717
|
+
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let r=t.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let a=void 0;;){let c=this.parser.matchStyle(o,i,this,a);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)a=c;else break}}return n}addElementByRule(t,n,r,s){let o,i;if(n.node)if(i=this.parser.schema.nodes[n.node],i.isLeaf)this.insertNode(i.create(n.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let c=this.enter(i,n.attrs||null,r,n.preserveWhitespace);c&&(o=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let a=this.top;if(i&&i.isLeaf)this.findInside(t);else if(s)this.addElement(t,r,s);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=t;typeof n.contentElement=="string"?c=t.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(t):n.contentElement&&(c=n.contentElement),this.findAround(t,c,!0),this.addAll(c,r),this.findAround(t,c,!1)}o&&this.sync(a)&&this.open--}addAll(t,n,r,s){let o=r||0;for(let i=r?t.childNodes[r]:t.firstChild,a=s==null?null:t.childNodes[s];i!=a;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i,n);this.findAtPoint(t,o)}findPlace(t,n,r){let s,o;for(let i=this.open,a=0;i>=0;i--){let c=this.nodes[i],u=c.findWrapping(t);if(u&&(!s||s.length>u.length+a)&&(s=u,o=c,!u.length))break;if(c.solid){if(r)break;a+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)n=this.enterInner(s[i],null,n,!1);return n}insertNode(t,n,r){if(t.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let s=this.findPlace(t,n,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(t.type));let i=Mt.none;for(let a of s.concat(t.marks))(o.type?o.type.allowsMarkType(a.type):iC(a.type,t.type))&&(i=a.addToSet(i));return o.content.push(t.mark(i)),!0}return!1}enter(t,n,r,s){let o=this.findPlace(t.create(n),r,!1);return o&&(o=this.enterInner(t,n,r,!0,s)),o}enterInner(t,n,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(t);let a=rC(t,o,i.options);i.options&qc&&i.content.length==0&&(a|=qc);let c=Mt.none;return r=r.filter(u=>(i.type?i.type.allowsMarkType(u.type):iC(u.type,t))?(c=u.addToSet(c),!1):!0),this.nodes.push(new Bd(t,n,c,s,null,a)),this.open++,r}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=vu)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)t+=r[s].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,r){if(t!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&t.nodeType==1&&t.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(a,c)=>{for(;a>=0;a--){let u=n[a];if(u==""){if(a==n.length-1||a==0)continue;for(;c>=o;c--)if(i(a-1,c))return!0;return!1}else{let d=c>0||c==0&&s?this.nodes[c].type:r&&c>=o?r.node(c-o).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return i(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function zG(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&TI.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}function FG(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function oC(e){let t={};for(let n in e)t[n]=e[n];return t}function iC(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let o=[],i=a=>{o.push(a);for(let c=0;c<a.edgeCount;c++){let{type:u,next:d}=a.edge(c);if(u==t||o.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class Ia{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},r){r||(r=_d(n).createDocumentFragment());let s=r,o=[];return t.forEach(i=>{if(o.length||i.marks.length){let a=0,c=0;for(;a<o.length&&c<i.marks.length;){let u=i.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(o[a][0])||u.type.spec.spanning===!1)break;a++,c++}for(;a<o.length;)s=o.pop()[1];for(;c<i.marks.length;){let u=i.marks[c++],d=this.serializeMark(u,i.isInline,n);d&&(o.push([u,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,n))}),r}serializeNodeInner(t,n){if(t.isText)return _d(n).createTextNode(t.text);let{dom:r,contentDOM:s}=ph(_d(n),this.nodes[t.type.name](t),null,t.attrs);if(s){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,s)}return r}serializeNode(t,n={}){let r=this.serializeNodeInner(t,n);for(let s=t.marks.length-1;s>=0;s--){let o=this.serializeMark(t.marks[s],t.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(t,n,r={}){let s=this.marks[t.type.name];return s&&ph(_d(r),s(t,n),null,t.attrs)}static renderSpec(t,n,r=null,s){return typeof n=="string"?{dom:t.createTextNode(n)}:ph(t,n,r,s)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Ia(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=aC(t.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(t){return aC(t.marks)}}function aC(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function _d(e){return e.document||window.document}const lC=new WeakMap;function BG(e){let t=lC.get(e);return t===void 0&&lC.set(e,t=_G(e)),t}function _G(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(e),t}function ph(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let s=t[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=BG(r))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(n=s.slice(0,i),s=s.slice(i+1));let a,c=n?e.createElementNS(n,s):e.createElement(s),u=t[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let h in u)if(u[h]!=null){let f=h.indexOf(" ");f>0?c.setAttributeNS(h.slice(0,f),h.slice(f+1),u[h]):h=="style"&&c.style?c.style.cssText=u[h]:c.setAttribute(h,u[h])}}for(let h=d;h<t.length;h++){let f=t[h];if(f===0){if(h<t.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof f=="string")c.appendChild(e.createTextNode(f));else{let{dom:p,contentDOM:m}=ph(e,f,n,r);if(c.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:c,contentDOM:a}}const MI=65535,RI=Math.pow(2,16);function WG(e,t){return e+t*RI}function cC(e){return e&MI}function HG(e){return(e-(e&MI))/RI}const II=1,DI=2,mh=4,OI=8;class _w{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&OI)>0}get deletedBefore(){return(this.delInfo&(II|mh))>0}get deletedAfter(){return(this.delInfo&(DI|mh))>0}get deletedAcross(){return(this.delInfo&mh)>0}}class Or{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Or.empty)return Or.empty}recover(t){let n=0,r=cC(t);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+HG(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?s:0);if(c>t)break;let u=this.ranges[a+o],d=this.ranges[a+i],h=c+u;if(t<=h){let f=u?t==c?-1:t==h?1:n:n,p=c+s+(f<0?0:d);if(r)return p;let m=t==(n<0?c:h)?null:WG(a/3,t-c),w=t==c?DI:t==h?II:mh;return(n<0?t!=c:t!=h)&&(w|=OI),new _w(p,w,m)}s+=d-u}return r?t+s:new _w(t+s,0,null)}touches(t,n){let r=0,s=cC(n),o=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?r:0);if(c>t)break;let u=this.ranges[a+o],d=c+u;if(t<=d&&a==s*3)return!0;r+=this.ranges[a+i]-u}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],a=i-(this.inverted?o:0),c=i+(this.inverted?0:o),u=this.ranges[s+n],d=this.ranges[s+r];t(a,a+u,c,c+d),o+=d-u}}invert(){return new Or(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Or.empty:new Or(t<0?[0,-t,0]:[0,0,t])}}Or.empty=new Or([]);class Su{constructor(t,n,r=0,s=t?t.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Su(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,r=this._maps.length;n<t._maps.length;n++){let s=t.getMirror(n);this.appendMap(t._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this._maps.length+t._maps.length;n>=0;n--){let s=t.getMirror(n);this.appendMap(t._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let t=new Su;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],a=i.mapResult(t,n);if(a.recover!=null){let c=this.getMirror(o);if(c!=null&&c>o&&c<this.to){o=c,t=this._maps[c].recover(a.recover);continue}}s|=a.delInfo,t=a.pos}return r?t:new _w(t,s,null)}}const Eg=Object.create(null);class Vn{getMap(){return Or.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Eg[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Eg)throw new RangeError("Duplicate use of step JSON ID "+t);return Eg[t]=n,n.prototype.jsonID=t,n}}class on{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new on(t,null)}static fail(t){return new on(null,t)}static fromReplace(t,n,r,s){try{return on.ok(t.replace(n,r,s))}catch(o){if(o instanceof xu)return on.fail(o.message);throw o}}}function Ux(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let o=e.child(s);o.content.size&&(o=o.copy(Ux(o.content,t,o))),o.isInline&&(o=t(o,n,s)),r.push(o)}return je.fromArray(r)}class ci extends Vn{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new Pe(Ux(n.content,(i,a)=>!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),n.openStart,n.openEnd);return on.fromReplace(t,this.from,this.to,o)}invert(){return new Ws(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ci(n.pos,r.pos,this.mark)}merge(t){return t instanceof ci&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ci(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ci(n.from,n.to,t.markFromJSON(n.mark))}}Vn.jsonID("addMark",ci);class Ws extends Vn{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new Pe(Ux(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),t),n.openStart,n.openEnd);return on.fromReplace(t,this.from,this.to,r)}invert(){return new ci(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ws(n.pos,r.pos,this.mark)}merge(t){return t instanceof Ws&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Ws(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ws(n.from,n.to,t.markFromJSON(n.mark))}}Vn.jsonID("removeMark",Ws);class ui extends Vn{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return on.fromReplace(t,this.pos,this.pos+1,new Pe(je.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new ui(this.pos,n.marks[s]);return new ui(this.pos,this.mark)}}return new ja(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new ui(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ui(n.pos,t.markFromJSON(n.mark))}}Vn.jsonID("addNodeMark",ui);class ja extends Vn{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return on.fromReplace(t,this.pos,this.pos+1,new Pe(je.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ui(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new ja(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ja(n.pos,t.markFromJSON(n.mark))}}Vn.jsonID("removeNodeMark",ja);class sn extends Vn{constructor(t,n,r,s=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=s}apply(t){return this.structure&&Ww(t,this.from,this.to)?on.fail("Structure replace would overwrite content"):on.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Or([this.from,this.to-this.from,this.slice.size])}invert(t){return new sn(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&sn.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new sn(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof sn)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Pe.empty:new Pe(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new sn(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Pe.empty:new Pe(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new sn(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new sn(n.from,n.to,Pe.fromJSON(t,n.slice),!!n.structure)}}sn.MAP_BIAS=1;Vn.jsonID("replace",sn);class yn extends Vn{constructor(t,n,r,s,o,i,a=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=a}apply(t){if(this.structure&&(Ww(t,this.from,this.gapFrom)||Ww(t,this.gapTo,this.to)))return on.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return on.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?on.fromReplace(t,this.from,this.to,r):on.fail("Content does not fit in gap")}getMap(){return new Or([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new yn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||o>r.pos?null:new yn(n.pos,r.pos,s,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new yn(n.from,n.to,n.gapFrom,n.gapTo,Pe.fromJSON(t,n.slice),n.insert,!!n.structure)}}Vn.jsonID("replaceAround",yn);function Ww(e,t,n){let r=e.resolve(t),s=n-t,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function UG(e,t,n,r){let s=[],o=[],i,a;e.doc.nodesBetween(t,n,(c,u,d)=>{if(!c.isInline)return;let h=c.marks;if(!r.isInSet(h)&&d.type.allowsMarkType(r.type)){let f=Math.max(u,t),p=Math.min(u+c.nodeSize,n),m=r.addToSet(h);for(let w=0;w<h.length;w++)h[w].isInSet(m)||(i&&i.to==f&&i.mark.eq(h[w])?i.to=p:s.push(i=new Ws(f,p,h[w])));a&&a.to==f?a.to=p:o.push(a=new ci(f,p,r))}}),s.forEach(c=>e.step(c)),o.forEach(c=>e.step(c))}function KG(e,t,n,r){let s=[],o=0;e.doc.nodesBetween(t,n,(i,a)=>{if(!i.isInline)return;o++;let c=null;if(r instanceof Rp){let u=i.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(i.marks)&&(c=[r]):c=i.marks;if(c&&c.length){let u=Math.min(a+i.nodeSize,n);for(let d=0;d<c.length;d++){let h=c[d],f;for(let p=0;p<s.length;p++){let m=s[p];m.step==o-1&&h.eq(s[p].style)&&(f=m)}f?(f.to=u,f.step=o):s.push({style:h,from:Math.max(a,t),to:u,step:o})}}}),s.forEach(i=>e.step(new Ws(i.from,i.to,i.style)))}function Kx(e,t,n,r=n.contentMatch,s=!0){let o=e.doc.nodeAt(t),i=[],a=t+1;for(let c=0;c<o.childCount;c++){let u=o.child(c),d=a+u.nodeSize,h=r.matchType(u.type);if(!h)i.push(new sn(a,d,Pe.empty));else{r=h;for(let f=0;f<u.marks.length;f++)n.allowsMarkType(u.marks[f].type)||e.step(new Ws(a,d,u.marks[f]));if(s&&u.isText&&n.whitespace!="pre"){let f,p=/\r?\n|\r/g,m;for(;f=p.exec(u.text);)m||(m=new Pe(je.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),i.push(new sn(a+f.index,a+f.index+f[0].length,m))}}a=d}if(!r.validEnd){let c=r.fillBefore(je.empty,!0);e.replace(a,a,new Pe(c,0,0))}for(let c=i.length-1;c>=0;c--)e.step(i[c])}function VG(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Jl(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let r=e.depth,s=0,o=0;;--r){let i=e.$from.node(r),a=e.$from.index(r)+s,c=e.$to.indexAfter(r)-o;if(r<e.depth&&i.canReplace(a,c,n))return r;if(r==0||i.type.spec.isolating||!VG(i,a,c))break;a&&(s=1),c<i.childCount&&(o=1)}return null}function qG(e,t,n){let{$from:r,$to:s,depth:o}=t,i=r.before(o+1),a=s.after(o+1),c=i,u=a,d=je.empty,h=0;for(let m=o,w=!1;m>n;m--)w||r.index(m)>0?(w=!0,d=je.from(r.node(m).copy(d)),h++):c--;let f=je.empty,p=0;for(let m=o,w=!1;m>n;m--)w||s.after(m+1)<s.end(m)?(w=!0,f=je.from(s.node(m).copy(f)),p++):u++;e.step(new yn(c,u,i,a,new Pe(d.append(f),h,p),d.size-h,!0))}function Vx(e,t,n=null,r=e){let s=YG(e,t),o=s&&GG(r,t);return o?s.map(uC).concat({type:t,attrs:n}).concat(o.map(uC)):null}function uC(e){return{type:e,attrs:null}}function YG(e,t){let{parent:n,startIndex:r,endIndex:s}=e,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;let i=o.length?o[0]:t;return n.canReplaceWith(r,s,i)?o:null}function GG(e,t){let{parent:n,startIndex:r,endIndex:s}=e,o=n.child(r),i=t.contentMatch.findWrapping(o.type);if(!i)return null;let c=(i.length?i[i.length-1]:t).contentMatch;for(let u=r;c&&u<s;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:i}function JG(e,t,n){let r=je.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let a=n[i].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=je.from(n[i].type.create(n[i].attrs,r))}let s=t.start,o=t.end;e.step(new yn(s,o,s,o,new Pe(r,0,0),n.length,!0))}function XG(e,t,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(i,a)=>{let c=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,c)&&QG(e.doc,e.mapping.slice(o).map(a),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?u=!1:!p&&m&&(u=!0)}u===!1&&$I(e,i,a,o),Kx(e,e.mapping.slice(o).map(a,1),r,void 0,u===null);let d=e.mapping.slice(o),h=d.map(a,1),f=d.map(a+i.nodeSize,1);return e.step(new yn(h,f,h+1,f-1,new Pe(je.from(r.create(c,null,i.marks)),0,0),1,!0)),u===!0&&LI(e,i,a,o),!1}})}function LI(e,t,n,r){t.forEach((s,o)=>{if(s.isText){let i,a=/\r?\n|\r/g;for(;i=a.exec(s.text);){let c=e.mapping.slice(r).map(n+1+o+i.index);e.replaceWith(c,c+1,t.type.schema.linebreakReplacement.create())}}})}function $I(e,t,n,r){t.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+o);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
718
|
+
`))}})}function QG(e,t,n){let r=e.resolve(t),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function ZG(e,t,n,r,s){let o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let i=n.create(r,null,s||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,i);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new yn(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new Pe(je.from(i),0,0),1,!0))}function No(e,t,n=1,r){let s=e.resolve(t),o=s.depth-n,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let u=s.depth-1,d=n-2;u>o;u--,d--){let h=s.node(u),f=s.index(u);if(h.type.spec.isolating)return!1;let p=h.content.cutByIndex(f,h.childCount),m=r&&r[d+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let w=r&&r[d]||h;if(!h.canReplace(f+1,h.childCount)||!w.type.validContent(p))return!1}let a=s.indexAfter(o),c=r&&r[0];return s.node(o).canReplaceWith(a,a,c?c.type:s.node(o+1).type)}function eJ(e,t,n=1,r){let s=e.doc.resolve(t),o=je.empty,i=je.empty;for(let a=s.depth,c=s.depth-n,u=n-1;a>c;a--,u--){o=je.from(s.node(a).copy(o));let d=r&&r[u];i=je.from(d?d.type.create(d.attrs,i):s.node(a).copy(i))}e.step(new sn(t,t,new Pe(o.append(i),n,n),!0))}function Ci(e,t){let n=e.resolve(t),r=n.index();return PI(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function tJ(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let s=0;s<t.childCount;s++){let o=t.child(s),i=o.type==r?e.type.schema.nodes.text:o.type;if(n=n.matchType(i),!n||!e.type.allowsMarks(o.marks))return!1}return n.validEnd}function PI(e,t){return!!(e&&t&&!e.isLeaf&&tJ(e,t))}function Ip(e,t,n=-1){let r=e.resolve(t);for(let s=r.depth;;s--){let o,i,a=r.index(s);if(s==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(s+1),a++,i=r.node(s).maybeChild(a)):(o=r.node(s).maybeChild(a-1),i=r.node(s+1)),o&&!o.isTextblock&&PI(o,i)&&r.node(s).canReplace(a,a+1))return t;if(s==0)break;t=n<0?r.before(s):r.after(s)}}function nJ(e,t,n){let r=null,{linebreakReplacement:s}=e.doc.type.schema,o=e.doc.resolve(t-n),i=o.node().type;if(s&&i.inlineContent){let d=i.whitespace=="pre",h=!!i.contentMatch.matchType(s);d&&!h?r=!1:!d&&h&&(r=!0)}let a=e.steps.length;if(r===!1){let d=e.doc.resolve(t+n);$I(e,d.node(),d.before(),a)}i.inlineContent&&Kx(e,t+n-1,i,o.node().contentMatchAt(o.index()),r==null);let c=e.mapping.slice(a),u=c.map(t-n);if(e.step(new sn(u,c.map(t+n,-1),Pe.empty,!0)),r===!0){let d=e.doc.resolve(u);LI(e,d.node(),d.before(),e.steps.length)}return e}function rJ(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,n))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,n))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function zI(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let o=0;o<n.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let i=r.depth;i>=0;i--){let a=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,c=r.index(i)+(a>0?1:0),u=r.node(i),d=!1;if(o==1)d=u.canReplace(c,c,s);else{let h=u.contentMatchAt(c).findWrapping(s.firstChild.type);d=h&&u.canReplaceWith(c,c,h[0])}if(d)return a==0?r.pos:a<0?r.before(i+1):r.after(i+1)}return null}function Dp(e,t,n=t,r=Pe.empty){if(t==n&&!r.size)return null;let s=e.resolve(t),o=e.resolve(n);return FI(s,o,r)?new sn(t,n,r):new sJ(s,o,r).fit()}function FI(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class sJ{constructor(t,n,r){this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=je.empty;for(let s=0;s<=t.depth;s++){let o=t.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(s))})}for(let s=t.depth;s>0;s--)this.placed=je.from(t.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(t<0?this.$to:r.doc.resolve(t));if(!s)return null;let o=this.placed,i=r.depth,a=s.depth;for(;i&&a&&o.childCount==1;)o=o.firstChild.content,i--,a--;let c=new Pe(o,i,a);return t>-1?new yn(r.pos,t,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new sn(r.pos,s.pos,c):null}findFittable(){let t=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<t;r++){let o=n.firstChild;if(n.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){t=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?t:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=Ag(this.unplaced.content,r-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let a=this.depth;a>=0;a--){let{type:c,match:u}=this.frontier[a],d,h=null;if(n==1&&(i?u.matchType(i.type)||(h=u.fillBefore(je.from(i),!1)):o&&c.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:h};if(n==2&&i&&(d=u.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:d};if(o&&u.matchType(o.type))break}}}openMore(){let{content:t,openStart:n,openEnd:r}=this.unplaced,s=Ag(t,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new Pe(t,n+1,Math.max(r,s.size+n>=t.size-r?n+1:0)),!0)}dropNode(){let{content:t,openStart:n,openEnd:r}=this.unplaced,s=Ag(t,n);if(s.childCount<=1&&n>0){let o=t.size-n<=n+s.size;this.unplaced=new Pe(Tc(t,n-1,1),n-1,o?n-1:r)}else this.unplaced=new Pe(Tc(t,n,1),n,r)}placeNodes({sliceDepth:t,frontierDepth:n,parent:r,inject:s,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let w=0;w<o.length;w++)this.openFrontierNode(o[w]);let i=this.unplaced,a=r?r.content:i.content,c=i.openStart-t,u=0,d=[],{match:h,type:f}=this.frontier[n];if(s){for(let w=0;w<s.childCount;w++)d.push(s.child(w));h=h.matchFragment(s)}let p=a.size+t-(i.content.size-i.openEnd);for(;u<a.childCount;){let w=a.child(u),b=h.matchType(w.type);if(!b)break;u++,(u>1||c==0||w.content.size)&&(h=b,d.push(BI(w.mark(f.allowedMarks(w.marks)),u==1?c:0,u==a.childCount?p:-1)))}let m=u==a.childCount;m||(p=-1),this.placed=Mc(this.placed,n,je.from(d)),this.frontier[n].match=h,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,b=a;w<p;w++){let x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=m?t==0?Pe.empty:new Pe(Tc(i.content,t-1,1),t-1,p<0?i.openEnd:t-1):new Pe(Tc(i.content,t,u),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],n;if(!t.type.isTextblock||!Tg(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(t){e:for(let n=Math.min(this.depth,t.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],o=n<t.depth&&t.end(n+1)==t.pos+(t.depth-(n+1)),i=Tg(t,n,s,r,o);if(i){for(let a=n-1;a>=0;a--){let{match:c,type:u}=this.frontier[a],d=Tg(t,a,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:i,move:o?t.doc.resolve(t.after(n+1)):t}}}}close(t){let n=this.findCloseLevel(t);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Mc(this.placed,n.depth,n.fit)),t=n.move;for(let r=n.depth+1;r<=t.depth;r++){let s=t.node(r),o=s.type.contentMatch.fillBefore(s.content,!0,t.index(r));this.openFrontierNode(s.type,s.attrs,o)}return t}openFrontierNode(t,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(t),this.placed=Mc(this.placed,this.depth,je.from(t.create(n,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(je.empty,!0);n.childCount&&(this.placed=Mc(this.placed,this.frontier.length,n))}}function Tc(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Tc(e.firstChild.content,t-1,n)))}function Mc(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Mc(e.lastChild.content,t-1,n)))}function Ag(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function BI(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,BI(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(je.empty,!0)))),e.copy(r)}function Tg(e,t,n,r,s){let o=e.node(t),i=s?e.indexAfter(t):e.index(t);if(i==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,i);return a&&!oJ(n,o.content,i)?a:null}function oJ(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function iJ(e){return e.spec.defining||e.spec.definingForContent}function aJ(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let s=e.doc.resolve(t),o=e.doc.resolve(n);if(FI(s,o,r))return e.step(new sn(t,n,r));let i=WI(s,o);i[i.length-1]==0&&i.pop();let a=-(s.depth+1);i.unshift(a);for(let f=s.depth,p=s.pos-1;f>0;f--,p--){let m=s.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;i.indexOf(f)>-1?a=f:s.before(f)==p&&i.splice(1,0,-f)}let c=i.indexOf(a),u=[],d=r.openStart;for(let f=r.content,p=0;;p++){let m=f.firstChild;if(u.push(m),p==r.openStart)break;f=m.content}for(let f=d-1;f>=0;f--){let p=u[f],m=iJ(p.type);if(m&&!p.sameMarkup(s.node(Math.abs(a)-1)))d=f;else if(m||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+d+1)%(r.openStart+1),m=u[p];if(m)for(let w=0;w<i.length;w++){let b=i[(w+c)%i.length],x=!0;b<0&&(x=!1,b=-b);let v=s.node(b-1),S=s.index(b-1);if(v.canReplaceWith(S,S,m.type,m.marks))return e.replace(s.before(b),x?o.after(b):n,new Pe(_I(r.content,0,r.openStart,p),p,r.openEnd))}}let h=e.steps.length;for(let f=i.length-1;f>=0&&(e.replace(t,n,r),!(e.steps.length>h));f--){let p=i[f];p<0||(t=s.before(p),n=o.after(p))}}function _I(e,t,n,r,s){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(_I(o.content,t+1,n,r,o)))}if(t>r){let o=s.contentMatchAt(0),i=o.fillBefore(e).append(e);e=i.append(o.matchFragment(i).fillBefore(je.empty,!0))}return e}function lJ(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let s=rJ(e.doc,t,r.type);s!=null&&(t=n=s)}e.replaceRange(t,n,new Pe(je.from(r),0,0))}function cJ(e,t,n){let r=e.doc.resolve(t),s=e.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let i=r.sharedDepth(n),a=!1;for(let c=r.depth;c>i;c--)r.node(c).type.spec.isolating&&(a=!0);for(let c=s.depth;c>i;c--)s.node(c).type.spec.isolating&&(a=!0);if(!a){for(let c=r.depth;c>0&&t==r.start(c);c--)t=r.before(c);for(let c=s.depth;c>0&&n==s.start(c);c--)n=s.before(c);r=e.doc.resolve(t),s=e.doc.resolve(n)}}let o=WI(r,s);for(let i=0;i<o.length;i++){let a=o[i],c=i==o.length-1;if(c&&a==0||r.node(a).type.contentMatch.validEnd)return e.delete(r.start(a),s.end(a));if(a>0&&(c||r.node(a-1).canReplace(r.index(a-1),s.indexAfter(a-1))))return e.delete(r.before(a),s.after(a))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&s.end(i)-n!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}function WI(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let s=r;s>=0;s--){let o=e.start(s);if(o<e.pos-(e.depth-s)||t.end(s)>t.pos+(t.depth-s)||e.node(s).type.spec.isolating||t.node(s).type.spec.isolating)break;(o==t.start(s)||s==e.depth&&s==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&s&&t.start(s-1)==o-1)&&n.push(s)}return n}class El extends Vn{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return on.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return on.fromReplace(t,this.pos,this.pos+1,new Pe(je.from(s),0,n.isLeaf?0:1))}getMap(){return Or.empty}invert(t){return new El(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new El(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new El(n.pos,n.attr,n.value)}}Vn.jsonID("attr",El);class ju extends Vn{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return on.ok(r)}getMap(){return Or.empty}invert(t){return new ju(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ju(n.attr,n.value)}}Vn.jsonID("docAttr",ju);let Fl=class extends Error{};Fl=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Fl.prototype=Object.create(Error.prototype);Fl.prototype.constructor=Fl;Fl.prototype.name="TransformError";class qx{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Su}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let n=this.maybeStep(t);if(n.failed)throw new Fl(n.failed);return this}maybeStep(t){let n=t.apply(this.doc);return n.failed||this.addStep(t,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let t=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(t=s.map(t,1),n=s.map(n,-1)),s.forEach((o,i,a,c)=>{t=Math.min(t,a),n=Math.max(n,c)})}return t==1e9?null:{from:t,to:n}}addStep(t,n){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=n}replace(t,n=t,r=Pe.empty){let s=Dp(this.doc,t,n,r);return s&&this.step(s),this}replaceWith(t,n,r){return this.replace(t,n,new Pe(je.from(r),0,0))}delete(t,n){return this.replace(t,n,Pe.empty)}insert(t,n){return this.replaceWith(t,t,n)}replaceRange(t,n,r){return aJ(this,t,n,r),this}replaceRangeWith(t,n,r){return lJ(this,t,n,r),this}deleteRange(t,n){return cJ(this,t,n),this}lift(t,n){return qG(this,t,n),this}join(t,n=1){return nJ(this,t,n),this}wrap(t,n){return JG(this,t,n),this}setBlockType(t,n=t,r,s=null){return XG(this,t,n,r,s),this}setNodeMarkup(t,n,r=null,s){return ZG(this,t,n,r,s),this}setNodeAttribute(t,n,r){return this.step(new El(t,n,r)),this}setDocAttribute(t,n){return this.step(new ju(t,n)),this}addNodeMark(t,n){return this.step(new ui(t,n)),this}removeNodeMark(t,n){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(n instanceof Mt)n.isInSet(r.marks)&&this.step(new ja(t,n));else{let s=r.marks,o,i=[];for(;o=n.isInSet(s);)i.push(new ja(t,o)),s=o.removeFromSet(s);for(let a=i.length-1;a>=0;a--)this.step(i[a])}return this}split(t,n=1,r){return eJ(this,t,n,r),this}addMark(t,n,r){return UG(this,t,n,r),this}removeMark(t,n,r){return KG(this,t,n,r),this}clearIncompatible(t,n,r){return Kx(this,t,n,r),this}}const Mg=Object.create(null);class ot{constructor(t,n,r){this.$anchor=t,this.$head=n,this.ranges=r||[new HI(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=Pe.empty){let r=n.content.lastChild,s=null;for(let a=0;a<n.openEnd;a++)s=r,r=r.lastChild;let o=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:c,$to:u}=i[a],d=t.mapping.slice(o);t.replaceRange(d.map(c.pos),d.map(u.pos),a?Pe.empty:n),a==0&&fC(t,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(t,n){let r=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:a}=s[o],c=t.mapping.slice(r),u=c.map(i.pos),d=c.map(a.pos);o?t.deleteRange(u,d):(t.replaceRangeWith(u,d,n),fC(t,r,n.isInline?-1:1))}}static findFrom(t,n,r=!1){let s=t.parent.inlineContent?new Xe(t):hl(t.node(0),t.parent,t.pos,t.index(),n,r);if(s)return s;for(let o=t.depth-1;o>=0;o--){let i=n<0?hl(t.node(0),t.node(o),t.before(o+1),t.index(o),n,r):hl(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,n,r);if(i)return i}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Pr(t.node(0))}static atStart(t){return hl(t,t,0,0,1)||new Pr(t)}static atEnd(t){return hl(t,t,t.content.size,t.childCount,-1)||new Pr(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Mg[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Mg)throw new RangeError("Duplicate use of selection JSON ID "+t);return Mg[t]=n,n.prototype.jsonID=t,n}getBookmark(){return Xe.between(this.$anchor,this.$head).getBookmark()}}ot.prototype.visible=!0;class HI{constructor(t,n){this.$from=t,this.$to=n}}let dC=!1;function hC(e){!dC&&!e.parent.inlineContent&&(dC=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Xe extends ot{constructor(t,n=t){hC(t),hC(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return ot.near(r);let s=t.resolve(n.map(this.anchor));return new Xe(s.parent.inlineContent?s:r,r)}replace(t,n=Pe.empty){if(super.replace(t,n),n==Pe.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof Xe&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Op(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Xe(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let s=t.resolve(n);return new this(s,r==n?s:t.resolve(r))}static between(t,n,r){let s=t.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let o=ot.findFrom(n,r,!0)||ot.findFrom(n,-r,!0);if(o)n=o.$head;else return ot.near(n,r)}return t.parent.inlineContent||(s==0?t=n:(t=(ot.findFrom(t,-r,!0)||ot.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=s<0&&(t=n))),new Xe(t,n)}}ot.jsonID("text",Xe);class Op{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Op(t.map(this.anchor),t.map(this.head))}resolve(t){return Xe.between(t.resolve(this.anchor),t.resolve(this.head))}}class Qe extends ot{constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),o=t.resolve(s);return r?ot.near(o):new Qe(o)}content(){return new Pe(je.from(this.node),0,0)}eq(t){return t instanceof Qe&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Yx(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Qe(t.resolve(n.anchor))}static create(t,n){return new Qe(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}Qe.prototype.visible=!1;ot.jsonID("node",Qe);class Yx{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Op(r,r):new Yx(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&Qe.isSelectable(r)?new Qe(n):ot.near(n)}}class Pr extends ot{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=Pe.empty){if(n==Pe.empty){t.delete(0,t.doc.content.size);let r=ot.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Pr(t)}map(t){return new Pr(t)}eq(t){return t instanceof Pr}getBookmark(){return uJ}}ot.jsonID("all",Pr);const uJ={map(){return this},resolve(e){return new Pr(e)}};function hl(e,t,n,r,s,o=!1){if(t.inlineContent)return Xe.create(e,n);for(let i=r-(s>0?0:1);s>0?i<t.childCount:i>=0;i+=s){let a=t.child(i);if(a.isAtom){if(!o&&Qe.isSelectable(a))return Qe.create(e,n-(s<0?a.nodeSize:0))}else{let c=hl(e,a,n+s,s<0?a.childCount:0,s,o);if(c)return c}n+=a.nodeSize*s}return null}function fC(e,t,n){let r=e.steps.length-1;if(r<t)return;let s=e.steps[r];if(!(s instanceof sn||s instanceof yn))return;let o=e.mapping.maps[r],i;o.forEach((a,c,u,d)=>{i==null&&(i=d)}),e.setSelection(ot.near(e.doc.resolve(i),n))}const pC=1,Wd=2,mC=4;class dJ extends qx{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=(this.updated|pC)&~Wd,this.storedMarks=null,this}get selectionSet(){return(this.updated&pC)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=Wd,this}ensureMarks(t){return Mt.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Wd)>0}addStep(t,n){super.addStep(t,n),this.updated=this.updated&~Wd,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,n=!0){let r=this.selection;return n&&(t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Mt.none))),r.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,n,r){let s=this.doc.type.schema;if(n==null)return t?this.replaceSelectionWith(s.text(t),!0):this.deleteSelection();{if(r==null&&(r=n),!t)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(n);o=r==n?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(t,o)),!this.selection.empty&&this.selection.to==n+t.length&&this.setSelection(ot.near(this.selection.$to)),this}}setMeta(t,n){return this.meta[typeof t=="string"?t:t.key]=n,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=mC,this}get scrolledIntoView(){return(this.updated&mC)>0}}function gC(e,t){return!t||!e?e:e.bind(t)}class Rc{constructor(t,n,r){this.name=t,this.init=gC(n.init,r),this.apply=gC(n.apply,r)}}const hJ=[new Rc("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Rc("selection",{init(e,t){return e.selection||ot.atStart(t.doc)},apply(e){return e.selection}}),new Rc("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Rc("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class Rg{constructor(t,n){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=hJ.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Rc(r.key,r.spec.state,r))})}}class xl{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let n=[t],r=this.applyInner(t),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let a=this.config.plugins[i];if(a.spec.appendTransaction){let c=s?s[i].n:0,u=s?s[i].state:this,d=c<n.length&&a.spec.appendTransaction.call(a,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",t),!s){s=[];for(let h=0;h<this.config.plugins.length;h++)s.push(h<i?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),o=!0}s&&(s[i]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new xl(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];n[o.name]=o.apply(t,this[o.name],this,n)}return n}get tr(){return new dJ(this)}static create(t){let n=new Rg(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new xl(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(t,r);return r}reconfigure(t){let n=new Rg(this.schema,t.plugins),r=n.fields,s=new xl(n);for(let o=0;o<r.length;o++){let i=r[o].name;s[i]=this.hasOwnProperty(i)?this[i]:r[o].init(t,s)}return s}toJSON(t){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=t[r],o=s.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(s,this[s.key]))}return n}static fromJSON(t,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let s=new Rg(t.schema,t.plugins),o=new xl(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=pi.fromJSON(t.schema,n.doc);else if(i.name=="selection")o.selection=ot.fromJSON(o.doc,n.selection);else if(i.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let a in r){let c=r[a],u=c.spec.state;if(c.key==i.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){o[i.name]=u.fromJSON.call(c,t,n[a],o);return}}o[i.name]=i.init(t,o)}}),o}}function UI(e,t,n){for(let r in e){let s=e[r];s instanceof Function?s=s.bind(t):r=="handleDOMEvents"&&(s=UI(s,t,{})),n[r]=s}return n}class an{constructor(t){this.spec=t,this.props={},t.props&&UI(t.props,this,this.props),this.key=t.key?t.key.key:KI("plugin")}getState(t){return t[this.key]}}const Ig=Object.create(null);function KI(e){return e in Ig?e+"$"+ ++Ig[e]:(Ig[e]=0,e+"$")}class On{constructor(t="key"){this.key=KI(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Mn=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Bl=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t};let Hw=null;const go=function(e,t,n){let r=Hw||(Hw=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},fJ=function(){Hw=null},Ca=function(e,t,n,r){return n&&(yC(e,t,n,r,-1)||yC(e,t,n,r,1))},pJ=/^(img|br|input|textarea|hr)$/i;function yC(e,t,n,r,s){for(var o;;){if(e==n&&t==r)return!0;if(t==(s<0?0:Xr(e))){let i=e.parentNode;if(!i||i.nodeType!=1||Hu(e)||pJ.test(e.nodeName)||e.contentEditable=="false")return!1;t=Mn(e)+(s<0?0:1),e=i}else if(e.nodeType==1){let i=e.childNodes[t+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)t+=s;else return!1;else e=i,t=s<0?Xr(e):0}else return!1}}function Xr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function mJ(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=Xr(e)}else if(e.parentNode&&!Hu(e))t=Mn(e),e=e.parentNode;else return null}}function gJ(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Hu(e))t=Mn(e)+1,e=e.parentNode;else return null}}function yJ(e,t,n){for(let r=t==0,s=t==Xr(e);r||s;){if(e==n)return!0;let o=Mn(e);if(e=e.parentNode,!e)return!1;r=r&&o==0,s=s&&o==Xr(e)}}function Hu(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Lp=function(e){return e.focusNode&&Ca(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function ea(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function wJ(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function bJ(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Xr(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Xr(r.startContainer),r.startOffset)}}}const Ks=typeof navigator<"u"?navigator:null,wC=typeof document<"u"?document:null,Ni=Ks&&Ks.userAgent||"",Uw=/Edge\/(\d+)/.exec(Ni),VI=/MSIE \d/.exec(Ni),Kw=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ni),xr=!!(VI||Kw||Uw),gi=VI?document.documentMode:Kw?+Kw[1]:Uw?+Uw[1]:0,Zr=!xr&&/gecko\/(\d+)/i.test(Ni);Zr&&+(/Firefox\/(\d+)/.exec(Ni)||[0,0])[1];const Vw=!xr&&/Chrome\/(\d+)/.exec(Ni),Dn=!!Vw,qI=Vw?+Vw[1]:0,Hn=!xr&&!!Ks&&/Apple Computer/.test(Ks.vendor),_l=Hn&&(/Mobile\/\w+/.test(Ni)||!!Ks&&Ks.maxTouchPoints>2),Gr=_l||(Ks?/Mac/.test(Ks.platform):!1),YI=Ks?/Win/.test(Ks.platform):!1,So=/Android \d/.test(Ni),Uu=!!wC&&"webkitFontSmoothing"in wC.documentElement.style,xJ=Uu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function kJ(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function lo(e,t){return typeof e=="number"?e:e[t]}function vJ(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function bC(e,t,n){if(!qw(t)&&t.left==0)return;let r=e.someProp("scrollThreshold")||0,s=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let i=n||e.dom;i;){if(i.nodeType!=1){i=Bl(i);continue}let a=i,c=a==o.body,u=c?kJ(o):vJ(a),d=0,h=0;if(t.top<u.top+lo(r,"top")?h=-(u.top-t.top+lo(s,"top")):t.bottom>u.bottom-lo(r,"bottom")&&(h=t.bottom-t.top>u.bottom-u.top?t.top+lo(s,"top")-u.top:t.bottom-u.bottom+lo(s,"bottom")),t.left<u.left+lo(r,"left")?d=-(u.left-t.left+lo(s,"left")):t.right>u.right-lo(r,"right")&&(d=t.right-u.right+lo(s,"right")),d||h)if(c)o.defaultView.scrollBy(d,h);else{let p=a.scrollLeft,m=a.scrollTop;h&&(a.scrollTop+=h),d&&(a.scrollLeft+=d);let w=a.scrollLeft-p,b=a.scrollTop-m;t={left:t.left-w,top:t.top-b,right:t.right-w,bottom:t.bottom-b}}let f=c?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:Bl(i)}}function SJ(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,s;for(let o=(t.left+t.right)/2,i=n+1;i<Math.min(innerHeight,t.bottom);i+=5){let a=e.root.elementFromPoint(o,i);if(!a||a==e.dom||!e.dom.contains(a))continue;let c=a.getBoundingClientRect();if(c.top>=n-20){r=a,s=c.top;break}}return{refDOM:r,refTop:s,stack:GI(e.dom)}}function GI(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Bl(r));return t}function jJ({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;JI(n,r==0?0:r-t)}function JI(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:s,left:o}=e[n];r.scrollTop!=s+t&&(r.scrollTop=s+t),r.scrollLeft!=o&&(r.scrollLeft=o)}}let al=null;function CJ(e){if(e.setActive)return e.setActive();if(al)return e.focus(al);let t=GI(e);e.focus(al==null?{get preventScroll(){return al={preventScroll:!0},!0}}:void 0),al||(al=!1,JI(t,0))}function XI(e,t){let n,r=2e8,s,o=0,i=t.top,a=t.top,c,u;for(let d=e.firstChild,h=0;d;d=d.nextSibling,h++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=go(d).getClientRects();else continue;for(let p=0;p<f.length;p++){let m=f[p];if(m.top<=i&&m.bottom>=a){i=Math.max(m.bottom,i),a=Math.min(m.top,a);let w=m.left>t.left?m.left-t.left:m.right<t.left?t.left-m.right:0;if(w<r){n=d,r=w,s=w&&n.nodeType==3?{left:m.right<t.left?m.right:m.left,top:t.top}:t,d.nodeType==1&&w&&(o=h+(t.left>=(m.left+m.right)/2?1:0));continue}}else m.top>t.top&&!c&&m.left<=t.left&&m.right>=t.left&&(c=d,u={left:Math.max(m.left,Math.min(m.right,t.left)),top:m.top});!n&&(t.left>=m.right&&t.top>=m.top||t.left>=m.left&&t.top>=m.bottom)&&(o=h+1)}}return!n&&c&&(n=c,s=u,r=0),n&&n.nodeType==3?NJ(n,s):!n||r&&n.nodeType==1?{node:e,offset:o}:XI(n,s)}function NJ(e,t){let n=e.nodeValue.length,r=document.createRange(),s;for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let i=Zo(r,1);if(i.top!=i.bottom&&Gx(t,i)){s={node:e,offset:o+(t.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:e,offset:0}}function Gx(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function EJ(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function AJ(e,t,n){let{node:r,offset:s}=XI(t,n),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return e.docView.posFromDOM(r,s,o)}function TJ(e,t,n,r){let s=-1;for(let o=t,i=!1;o!=e.dom;){let a=e.docView.nearestDesc(o,!0),c;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((c=a.dom.getBoundingClientRect()).width||c.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!i&&c.left>r.left||c.top>r.top?s=a.posBefore:(!i&&c.right<r.left||c.bottom<r.top)&&(s=a.posAfter),i=!0),!a.contentDOM&&s<0&&!a.node.isText))return(a.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return s>-1?s:e.docView.posFromDOM(t,n,-1)}function QI(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=s;;){let i=e.childNodes[o];if(i.nodeType==1){let a=i.getClientRects();for(let c=0;c<a.length;c++){let u=a[c];if(Gx(t,u))return QI(i,t,u)}}if((o=(o+1)%r)==s)break}return e}function MJ(e,t){let n=e.dom.ownerDocument,r,s=0,o=bJ(n,t.left,t.top);o&&({node:r,offset:s}=o);let i=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),a;if(!i||!e.dom.contains(i.nodeType!=1?i.parentNode:i)){let u=e.dom.getBoundingClientRect();if(!Gx(t,u)||(i=QI(e.dom,t,u),!i))return null}if(Hn)for(let u=i;r&&u;u=Bl(u))u.draggable&&(r=void 0);if(i=EJ(i,t),r){if(Zr&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],h;d.nodeName=="IMG"&&(h=d.getBoundingClientRect()).right<=t.left&&h.bottom>t.top&&s++}let u;Uu&&s&&r.nodeType==1&&(u=r.childNodes[s-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=t.top&&s--,r==e.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(a=TJ(e,r,s,t))}a==null&&(a=AJ(e,i,t));let c=e.docView.nearestDesc(i,!0);return{pos:a,inside:c?c.posAtStart-c.border:-1}}function qw(e){return e.top<e.bottom||e.left<e.right}function Zo(e,t){let n=e.getClientRects();if(n.length){let r=n[t<0?0:n.length-1];if(qw(r))return r}return Array.prototype.find.call(n,qw)||e.getBoundingClientRect()}const RJ=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ZI(e,t,n){let{node:r,offset:s,atom:o}=e.docView.domFromPos(t,n<0?-1:1),i=Uu||Zr;if(r.nodeType==3)if(i&&(RJ.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let c=Zo(go(r,s,s),n);if(Zr&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let u=Zo(go(r,s-1,s-1),-1);if(u.top==c.top){let d=Zo(go(r,s,s+1),-1);if(d.top!=c.top)return vc(d,d.left<u.left)}}return c}else{let c=s,u=s,d=n<0?1:-1;return n<0&&!s?(u++,d=-1):n>=0&&s==r.nodeValue.length?(c--,d=1):n<0?c--:u++,vc(Zo(go(r,c,u),d),d<0)}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(o==null&&s&&(n<0||s==Xr(r))){let c=r.childNodes[s-1];if(c.nodeType==1)return Dg(c.getBoundingClientRect(),!1)}if(o==null&&s<Xr(r)){let c=r.childNodes[s];if(c.nodeType==1)return Dg(c.getBoundingClientRect(),!0)}return Dg(r.getBoundingClientRect(),n>=0)}if(o==null&&s&&(n<0||s==Xr(r))){let c=r.childNodes[s-1],u=c.nodeType==3?go(c,Xr(c)-(i?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return vc(Zo(u,1),!1)}if(o==null&&s<Xr(r)){let c=r.childNodes[s];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?go(c,0,i?0:1):c.nodeType==1?c:null:null;if(u)return vc(Zo(u,-1),!0)}return vc(Zo(r.nodeType==3?go(r):r,-n),n>=0)}function vc(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Dg(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function eD(e,t,n){let r=e.state,s=e.root.activeElement;r!=t&&e.updateState(t),s!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),s!=e.dom&&s&&s.focus()}}function IJ(e,t,n){let r=t.selection,s=n=="up"?r.$from:r.$to;return eD(e,t,()=>{let{node:o}=e.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let a=e.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let i=ZI(e,s.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let c;if(a.nodeType==1)c=a.getClientRects();else if(a.nodeType==3)c=go(a,0,a.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const DJ=/[\u0590-\u08ac]/;function OJ(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,a=e.domSelection();return a?!DJ.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:i:eD(e,t,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:h}=e.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let p=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:m,focusOffset:w}=e.domSelectionRange(),b=m&&!p.contains(m.nodeType==1?m:m.parentNode)||c==m&&u==w;try{a.collapse(d,h),c&&(c!=d||u!=h)&&a.extend&&a.extend(c,u)}catch{}return f!=null&&(a.caretBidiLevel=f),b}):r.pos==r.start()||r.pos==r.end()}let xC=null,kC=null,vC=!1;function LJ(e,t,n){return xC==t&&kC==n?vC:(xC=t,kC=n,vC=n=="up"||n=="down"?IJ(e,t,n):OJ(e,t,n))}const es=0,SC=1,oa=2,ws=3;class Ku{constructor(t,n,r,s){this.parent=t,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=es,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,n,r){return!1}matchesHack(t){return!1}parseRule(t){return null}stopEvent(t){return!1}get size(){let t=0;for(let n=0;n<this.children.length;n++)t+=this.children[n].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==t)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,n,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode))if(r<0){let o,i;if(t==this.contentDOM)o=t.childNodes[n-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;o=t.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(t==this.contentDOM)o=t.childNodes[n];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;o=t.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(t==this.dom&&this.contentDOM)s=n>Mn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=t;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&n==t.childNodes.length)for(let o=t;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(t,n=!1){for(let r=!0,s=t;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!n||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(t.nodeType==1?t:t.parentNode):i==t))r=!1;else return o}}getDesc(t){let n=t.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(t,n,r){for(let s=t;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(t,n,r)}return-1}descAt(t){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],o=r+s.size;if(r==t&&o!=r){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let a=s.children[i];if(a.size){s=a;break}}return s}if(t<o)return s.descAt(t-r-s.border);r=o}}domFromPos(t,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,s=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],a=o+i.size;if(a>t||i instanceof nD){s=t-o;break}o=a}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof tD&&o.side>=0;r--);if(n<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&n&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?Mn(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?Mn(o.dom):this.contentDOM.childNodes.length}}}parseRange(t,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=r,a=0;;a++){let c=this.children[a],u=i+c.size;if(s==-1&&t<=u){let d=i+c.border;if(t>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(t,n,d);t=i;for(let h=a;h>0;h--){let f=this.children[h-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=Mn(f.dom)+1;break}t-=f.size}s==-1&&(s=0)}if(s>-1&&(u>n||a==this.children.length-1)){n=u;for(let d=a+1;d<this.children.length;d++){let h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=Mn(h.dom);break}n+=h.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=u}return{node:this.contentDOM,from:t,to:n,fromOffset:s,toOffset:o}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[t<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(t)}domAfterPos(t){let{node:n,offset:r}=this.domFromPos(t,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]}setSelection(t,n,r,s=!1){let o=Math.min(t,n),i=Math.max(t,n);for(let p=0,m=0;p<this.children.length;p++){let w=this.children[p],b=m+w.size;if(o>m&&i<b)return w.setSelection(t-m-w.border,n-m-w.border,r,s);m=b}let a=this.domFromPos(t,t?-1:1),c=n==t?a:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),h=!1;if((Zr||Hn)&&t==n){let{node:p,offset:m}=a;if(p.nodeType==3){if(h=!!(m&&p.nodeValue[m-1]==`
|
|
719
|
+
`),h&&m==p.nodeValue.length)for(let w=p,b;w;w=w.parentNode){if(b=w.nextSibling){b.nodeName=="BR"&&(a=c={node:b.parentNode,offset:Mn(b)+1});break}let x=w.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let w=p.childNodes[m-1];h=w&&(w.nodeName=="BR"||w.contentEditable=="false")}}if(Zr&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(s=!0)}if(!(s||h&&Hn)&&Ca(a.node,a.offset,d.anchorNode,d.anchorOffset)&&Ca(c.node,c.offset,d.focusNode,d.focusOffset))return;let f=!1;if((u.extend||t==n)&&!(h&&Zr)){u.collapse(a.node,a.offset);try{t!=n&&u.extend(c.node,c.offset),f=!0}catch{}}if(!f){if(t>n){let m=a;a=c,c=m}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(a.node,a.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,n){for(let r=0,s=0;s<this.children.length;s++){let o=this.children[s],i=r+o.size;if(r==i?t<=i&&n>=r:t<i&&n>r){let a=r+o.border,c=i-o.border;if(t>=a&&n<=c){this.dirty=t==r||n==i?oa:SC,t==a&&n==c&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ws:o.markDirty(t-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?oa:ws}r=i}this.dirty=oa}markParentsDirty(){let t=1;for(let n=this.parent;n;n=n.parent,t++){let r=t==1?oa:SC;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}}class tD extends Ku{constructor(t,n,r,s){let o,i=n.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(i.nodeType!=1){let a=document.createElement("span");a.appendChild(i),i=a}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(t,[],i,null),this.widget=n,this.widget=n,o=this}matchesWidget(t){return this.dirty==es&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let n=this.widget.spec.stopEvent;return n?n(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class $J extends Ku{constructor(t,n,r,s){super(t,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(t,n){return t!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class yi extends Ku{constructor(t,n,r,s,o){super(t,[],r,s),this.mark=n,this.spec=o}static create(t,n,r,s){let o=s.nodeViews[n.type.name],i=o&&o(n,s,r);return(!i||!i.dom)&&(i=Ia.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new yi(t,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&ws||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=ws&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=es){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=es}}slice(t,n,r){let s=yi.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;n<i&&(o=Gw(o,n,i,r)),t>0&&(o=Gw(o,0,t,r));for(let a=0;a<o.length;a++)o[a].parent=s;return s.children=o,s}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class wi extends Ku{constructor(t,n,r,s,o,i,a){super(t,[],o,i),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=a}static create(t,n,r,s,o,i){let a=o.nodeViews[n.type.name],c,u=a&&a(n,o,()=>{if(!c)return i;if(c.parent)return c.parent.posBeforeChild(c)},r,s),d=u&&u.dom,h=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:h}=Ia.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let f=d;return d=oD(d,r,n),u?c=new PJ(t,n,r,s,d,h||null,f,u):n.isText?new $p(t,n,r,s,d,f):new wi(t,n,r,s,d,h||null,f)}parseRule(t){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let s=this.children[r];if(this.dom.contains(s.dom.parentNode)){n.contentElement=s.dom.parentNode;break}}if(!n.contentElement){let r=t&&t.find(s=>s.nodeType==1&&t.indexOf(s.parentNode)<0&&this.dom.contains(s));r?n.contentElement=r:n.getContent=()=>je.empty}}return n}matchesNode(t,n,r){return this.dirty==es&&t.eq(this.node)&&ff(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){let r=this.node.inlineContent,s=n,o=t.composing?this.localCompositionInfo(t,n):null,i=o&&o.pos>-1?o:null,a=o&&o.pos<0,c=new FJ(this,i&&i.node,t);WJ(this.node,this.innerDeco,(u,d,h)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,t,d):u.type.side>=0&&!h&&c.syncToMarks(d==this.node.childCount?Mt.none:this.node.child(d).marks,r,t,d),c.placeWidget(u,t,s)},(u,d,h,f)=>{c.syncToMarks(u.marks,r,t,f);let p;c.findNodeMatch(u,d,h,f)||a&&t.state.selection.from>s&&t.state.selection.to<s+u.nodeSize&&(p=c.findIndexWithChild(o.node))>-1&&c.updateNodeAt(u,d,h,p,t)||c.updateNextNode(u,d,h,t,f,s)||c.addNode(u,d,h,t,s),s+=u.nodeSize}),c.syncToMarks([],r,t,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==oa)&&(i&&this.protectLocalComposition(t,i),rD(this.contentDOM,this.children,t),_l&&HJ(this.dom))}localCompositionInfo(t,n){let{from:r,to:s}=t.state.selection;if(!(t.state.selection instanceof Xe)||r<n||s>n+this.node.content.size)return null;let o=t.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,a=UJ(this.node.content,i,r-n,s-n);return a<0?null:{node:o,pos:a,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new $J(this,o,n,s);t.input.compositionNodes.push(i),this.children=Gw(this.children,r,r+s.length,t,i)}update(t,n,r,s){return this.dirty==ws||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,r,s),!0)}updateInner(t,n,r,s){this.updateOuterDeco(n),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=es}updateOuterDeco(t){if(ff(t,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=sD(this.dom,this.nodeDOM,Yw(this.outerDeco,this.node,n),Yw(t,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function jC(e,t,n,r,s){oD(r,t,e);let o=new wi(void 0,e,t,n,r,r,r);return o.contentDOM&&o.updateChildren(s,0),o}class $p extends wi{constructor(t,n,r,s,o,i){super(t,n,r,s,o,null,i)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,r,s){return this.dirty==ws||this.dirty!=es&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=es||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=t,this.dirty=es,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,n,r){let s=this.node.cut(t,n),o=document.createTextNode(s.text);return new $p(this.parent,s,this.outerDeco,this.innerDeco,o,o)}markDirty(t,n){super.markDirty(t,n),this.dom!=this.nodeDOM&&(t==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ws)}get domAtom(){return!1}isText(t){return this.node.text==t}}class nD extends Ku{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==es&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class PJ extends wi{constructor(t,n,r,s,o,i,a,c){super(t,n,r,s,o,i,a),this.spec=c}update(t,n,r,s){if(this.dirty==ws)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let o=this.spec.update(t,n,r);return o&&this.updateInner(t,n,r,s),o}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,n,r,s){this.spec.setSelection?this.spec.setSelection(t,n,r.root):super.setSelection(t,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function rD(e,t,n){let r=e.firstChild,s=!1;for(let o=0;o<t.length;o++){let i=t[o],a=i.dom;if(a.parentNode==e){for(;a!=r;)r=CC(r),s=!0;r=r.nextSibling}else s=!0,e.insertBefore(a,r);if(i instanceof yi){let c=r?r.previousSibling:e.lastChild;rD(i.contentDOM,i.children,n),r=c?c.nextSibling:e.firstChild}}for(;r;)r=CC(r),s=!0;s&&n.trackWrites==e&&(n.trackWrites=null)}const Yc=function(e){e&&(this.nodeName=e)};Yc.prototype=Object.create(null);const ia=[new Yc];function Yw(e,t,n){if(e.length==0)return ia;let r=n?ia[0]:new Yc,s=[r];for(let o=0;o<e.length;o++){let i=e[o].type.attrs;if(i){i.nodeName&&s.push(r=new Yc(i.nodeName));for(let a in i){let c=i[a];c!=null&&(n&&s.length==1&&s.push(r=new Yc(t.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+c:a=="style"?r.style=(r.style?r.style+";":"")+c:a!="nodeName"&&(r[a]=c))}}}return s}function sD(e,t,n,r){if(n==ia&&r==ia)return t;let s=t;for(let o=0;o<r.length;o++){let i=r[o],a=n[o];if(o){let c;a&&a.nodeName==i.nodeName&&s!=e&&(c=s.parentNode)&&c.nodeName.toLowerCase()==i.nodeName||(c=document.createElement(i.nodeName),c.pmIsDeco=!0,c.appendChild(s),a=ia[0]),s=c}zJ(s,a||ia[0],i)}return s}function zJ(e,t,n){for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&e.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&e.classList.add(s[o]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(t.style);)e.style.removeProperty(s[1])}n.style&&(e.style.cssText+=n.style)}}function oD(e,t,n){return sD(e,e,ia,Yw(t,n,e.nodeType!=1))}function ff(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function CC(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class FJ{constructor(t,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=BJ(t.node.content,t)}destroyBetween(t,n){if(t!=n){for(let r=t;r<n;r++)this.top.children[r].destroy();this.top.children.splice(t,n-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,n,r,s){let o=0,i=this.stack.length>>1,a=Math.min(i,t.length);for(;o<a&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(t[o])&&t[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=es,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<t.length;){this.stack.push(this.top,this.index+1);let c=-1,u=this.top.children.length;s<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let d=this.index;d<u;d++){let h=this.top.children[d];if(h.matchesMark(t[i])&&!this.isLocked(h.dom)){c=d;break}}if(c<0&&this.index<this.top.children.length){let d=this.top.children[this.index];d instanceof yi&&d.dirty!=ws&&d.mark.type==t[i].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(t[i])&&(d.mark=t[i],c=this.index,this.changed=!0)}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let d=yi.create(this.top,t[i],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,i++}}findNodeMatch(t,n,r,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(t,n,r))o=this.top.children.indexOf(i,this.index);else for(let a=this.index,c=Math.min(this.top.children.length,a+5);a<c;a++){let u=this.top.children[a];if(u.matchesNode(t,n,r)&&!this.preMatch.matched.has(u)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(t,n,r,s,o){let i=this.top.children[s];return i.dirty==ws&&i.dom==i.contentDOM&&(i.dirty=oa),i.update(t,n,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(t){for(;;){let n=t.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=t.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}t=n}}updateNextNode(t,n,r,s,o,i){for(let a=this.index;a<this.top.children.length;a++){let c=this.top.children[a];if(c instanceof wi){let u=this.preMatch.matched.get(c);if(u!=null&&u!=o)return!1;let d=c.dom,h,f=this.isLocked(d)&&!(t.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==t.text&&c.dirty!=ws&&ff(n,c.outerDeco));if(!f&&c.update(t,n,r,s))return this.destroyBetween(this.index,a),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(h=this.recreateWrapper(c,t,n,r,s,i)))return this.destroyBetween(this.index,a),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=oa,h.updateChildren(s,i+1),h.dirty=es),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,n,r,s,o,i){if(t.dirty||n.isAtom||!t.children.length||!t.node.content.eq(n.content)||!ff(r,t.outerDeco)||!s.eq(t.innerDeco))return null;let a=wi.create(this.top,n,r,s,o,i);if(a.contentDOM){a.children=t.children,t.children=[];for(let c of a.children)c.parent=a}return t.destroy(),a}addNode(t,n,r,s,o){let i=wi.create(this.top,t,n,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(t,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(t)&&(t==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new tD(this.top,t,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],n=this.top;for(;t instanceof yi;)n=t,t=n.children[n.children.length-1];(!t||!(t instanceof $p)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Hn||Dn)&&t&&t.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(t,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(t))this.index++;else{let r=document.createElement(t);t=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),t=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new nD(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function BJ(e,t){let n=t,r=n.children.length,s=e.childCount,o=new Map,i=[];e:for(;s>0;){let a;for(;;)if(r){let u=n.children[r-1];if(u instanceof yi)n=u,r=u.children.length;else{a=u,r--;break}}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=a.node;if(c){if(c!=e.child(s-1))break;--s,o.set(a,s),i.push(a)}}return{index:s,matched:o,matches:i.reverse()}}function _J(e,t){return e.type.side-t.type.side}function WJ(e,t,n,r){let s=t.locals(e),o=0;if(s.length==0){for(let u=0;u<e.childCount;u++){let d=e.child(u);r(d,s,t.forChild(o,d),u),o+=d.nodeSize}return}let i=0,a=[],c=null;for(let u=0;;){let d,h;for(;i<s.length&&s[i].to==o;){let b=s[i++];b.widget&&(d?(h||(h=[d])).push(b):d=b)}if(d)if(h){h.sort(_J);for(let b=0;b<h.length;b++)n(h[b],u,!!c)}else n(d,u,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(u<e.childCount)p=u,f=e.child(u++);else break;for(let b=0;b<a.length;b++)a[b].to<=o&&a.splice(b--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)a.push(s[i++]);let m=o+f.nodeSize;if(f.isText){let b=m;i<s.length&&s[i].from<b&&(b=s[i].from);for(let x=0;x<a.length;x++)a[x].to<b&&(b=a[x].to);b<m&&(c=f.cut(b-o),f=f.cut(0,b-o),m=b,p=-1)}else for(;i<s.length&&s[i].to<m;)i++;let w=f.isInline&&!f.isLeaf?a.filter(b=>!b.inline):a.slice();r(f,w,t.forChild(o,f),p),o=m}}function HJ(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function UJ(e,t,n,r){for(let s=0,o=0;s<e.childCount&&o<=r;){let i=e.child(s++),a=o;if(o+=i.nodeSize,!i.isText)continue;let c=i.text;for(;s<e.childCount;){let u=e.child(s++);if(o+=u.nodeSize,!u.isText)break;c+=u.text}if(o>=n){if(o>=r&&c.slice(r-t.length-a,r-a)==t)return r-t.length;let u=a<r?c.lastIndexOf(t,r-a-1):-1;if(u>=0&&u+t.length+a>=n)return a+u;if(n==r&&c.length>=r+t.length-a&&c.slice(r-a,r-a+t.length)==t)return r}}return-1}function Gw(e,t,n,r,s){let o=[];for(let i=0,a=0;i<e.length;i++){let c=e[i],u=a,d=a+=c.size;u>=n||d<=t?o.push(c):(u<t&&o.push(c.slice(0,t-u,r)),s&&(o.push(s),s=void 0),d>n&&o.push(c.slice(n-u,c.size,r)))}return o}function Jx(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),o=s&&s.size==0,i=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let a=r.resolve(i),c,u;if(Lp(n)){for(c=i;s&&!s.node;)s=s.parent;let h=s.node;if(s&&h.isAtom&&Qe.isSelectable(h)&&s.parent&&!(h.isInline&&yJ(n.focusNode,n.focusOffset,s.dom))){let f=s.posBefore;u=new Qe(i==f?a:r.resolve(f))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=i,f=i;for(let p=0;p<n.rangeCount;p++){let m=n.getRangeAt(p);h=Math.min(h,e.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,e.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(h<0)return null;[c,i]=f==e.state.selection.anchor?[f,h]:[h,f],a=r.resolve(i)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let h=t=="pointer"||e.state.selection.head<a.pos&&!o?1:-1;u=Xx(e,d,a,h)}return u}function iD(e){return e.editable?e.hasFocus():lD(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Eo(e,t=!1){let n=e.state.selection;if(aD(e,n),!iD(e))return;let r=e.input.mouseDown;if(!t&&Dn&&r){let s=e.domSelectionRange(),o=e.domObserver.currentSelection;if(s.anchorNode&&o.anchorNode&&Ca(s.anchorNode,s.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)VJ(e);else{let{anchor:s,head:o}=n,i,a;NC&&!(n instanceof Xe)&&(n.$from.parent.inlineContent||(i=EC(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=EC(e,n.to))),e.docView.setSelection(s,o,e,t),NC&&(i&&AC(i),a&&AC(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&KJ(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}const NC=Hn||Dn&&qI<63;function EC(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(Hn&&s&&s.contentEditable=="false")return Og(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Og(s);if(o)return Og(o)}}function Og(e){return e.contentEditable="true",Hn&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function AC(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function KJ(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!iD(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function VJ(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,Mn(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&xr&&gi<=11&&(n.disabled=!0,n.disabled=!1)}function aD(e,t){if(t instanceof Qe){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(TC(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else TC(e)}function TC(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Xx(e,t,n,r){return e.someProp("createSelectionBetween",s=>s(e,t,n))||Xe.between(t,n,r)}function MC(e){return e.editable&&!e.hasFocus()?!1:lD(e)}function lD(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function qJ(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Ca(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Jw(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),o=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return o&&ot.findFrom(o,t)}function ei(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function RC(e,t,n){let r=e.state.selection;if(r instanceof Xe)if(n.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(s.pos+o.nodeSize*(t<0?-1:1));return ei(e,new Xe(r.$anchor,i))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let s=Jw(e.state,t);return s&&s instanceof Qe?ei(e,s):!1}else if(!(Gr&&n.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let a=t<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=e.docView.descAt(a))&&!i.contentDOM?Qe.isSelectable(o)?ei(e,new Qe(t<0?e.state.doc.resolve(s.pos-o.nodeSize):s)):Uu?ei(e,new Xe(e.state.doc.resolve(t<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Qe&&r.node.isInline)return ei(e,new Xe(t>0?r.$to:r.$from));{let s=Jw(e.state,t);return s?ei(e,s):!1}}}function pf(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Gc(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function ll(e,t){return t<0?YJ(e):GJ(e)}function YJ(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,o,i=!1;for(Zr&&n.nodeType==1&&r<pf(n)&&Gc(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(Gc(a,-1))s=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(cD(n))break;{let a=n.previousSibling;for(;a&&Gc(a,-1);)s=n.parentNode,o=Mn(a),a=a.previousSibling;if(a)n=a,r=pf(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}i?Xw(e,n,r):s&&Xw(e,s,o)}function GJ(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s=pf(n),o,i;for(;;)if(r<s){if(n.nodeType!=1)break;let a=n.childNodes[r];if(Gc(a,1))o=n,i=++r;else break}else{if(cD(n))break;{let a=n.nextSibling;for(;a&&Gc(a,1);)o=a.parentNode,i=Mn(a)+1,a=a.nextSibling;if(a)n=a,r=0,s=pf(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&Xw(e,o,i)}function cD(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function JJ(e,t){for(;e&&t==e.childNodes.length&&!Hu(e);)t=Mn(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function XJ(e,t){for(;e&&!t&&!Hu(e);)t=Mn(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Xw(e,t,n){if(t.nodeType!=3){let o,i;(i=JJ(t,n))?(t=i,n=0):(o=XJ(t,n))&&(t=o,n=o.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Lp(r)){let o=document.createRange();o.setEnd(t,n),o.setStart(t,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&Eo(e)},50)}function IC(e,t){let n=e.state.doc.resolve(t);if(!(Dn||YI)&&n.parent.inlineContent){let s=e.coordsAtPos(t);if(t>n.start()){let o=e.coordsAtPos(t-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(t<n.end()){let o=e.coordsAtPos(t+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function DC(e,t,n){let r=e.state.selection;if(r instanceof Xe&&!r.empty||n.indexOf("s")>-1||Gr&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let i=Jw(e.state,t);if(i&&i instanceof Qe)return ei(e,i)}if(!s.parent.inlineContent){let i=t<0?s:o,a=r instanceof Pr?ot.near(i,t):ot.findFrom(i,t);return a?ei(e,a):!1}return!1}function OC(e,t){if(!(e.state.selection instanceof Xe))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=e.state.tr;return t<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),e.dispatch(i),!0}return!1}function LC(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function QJ(e){if(!Hn||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;LC(e,r,"true"),setTimeout(()=>LC(e,r,"false"),20)}return!1}function ZJ(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function eX(e,t){let n=t.keyCode,r=ZJ(t);if(n==8||Gr&&n==72&&r=="c")return OC(e,-1)||ll(e,-1);if(n==46&&!t.shiftKey||Gr&&n==68&&r=="c")return OC(e,1)||ll(e,1);if(n==13||n==27)return!0;if(n==37||Gr&&n==66&&r=="c"){let s=n==37?IC(e,e.state.selection.from)=="ltr"?-1:1:-1;return RC(e,s,r)||ll(e,s)}else if(n==39||Gr&&n==70&&r=="c"){let s=n==39?IC(e,e.state.selection.from)=="ltr"?1:-1:1;return RC(e,s,r)||ll(e,s)}else{if(n==38||Gr&&n==80&&r=="c")return DC(e,-1,r)||ll(e,-1);if(n==40||Gr&&n==78&&r=="c")return QJ(e)||DC(e,1,r)||ll(e,1);if(r==(Gr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Qx(e,t){e.someProp("transformCopied",p=>{t=p(t,e)});let n=[],{content:r,openStart:s,openEnd:o}=t;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=e.someProp("clipboardSerializer")||Ia.fromSchema(e.state.schema),a=mD(),c=a.createElement("div");c.appendChild(i.serializeFragment(r,{document:a}));let u=c.firstChild,d,h=0;for(;u&&u.nodeType==1&&(d=pD[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let m=a.createElement(d[p]);for(;c.firstChild;)m.appendChild(c.firstChild);c.appendChild(m),h++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${s} ${o}${h?` -${h}`:""} ${JSON.stringify(n)}`);let f=e.someProp("clipboardTextSerializer",p=>p(t,e))||t.content.textBetween(0,t.content.size,`
|
|
720
|
+
|
|
721
|
+
`);return{dom:c,text:f,slice:t}}function uD(e,t,n,r,s){let o=s.parent.type.spec.code,i,a;if(!n&&!t)return null;let c=!!t&&(r||o||!n);if(c){if(e.someProp("transformPastedText",f=>{t=f(t,o||r,e)}),o)return a=new Pe(je.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
722
|
+
`))),0,0),e.someProp("transformPasted",f=>{a=f(a,e,!0)}),a;let h=e.someProp("clipboardTextParser",f=>f(t,s,r,e));if(h)a=h;else{let f=s.marks(),{schema:p}=e.state,m=Ia.fromSchema(p);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(w=>{let b=i.appendChild(document.createElement("p"));w&&b.appendChild(m.serializeNode(p.text(w,f)))})}}else e.someProp("transformPastedHTML",h=>{n=h(n,e)}),i=sX(n),Uu&&oX(i);let u=i&&i.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let h=+d[3];h>0;h--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(a||(a=(e.someProp("clipboardParser")||e.someProp("domParser")||mi.fromSchema(e.state.schema)).parseSlice(i,{preserveWhitespace:!!(c||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!tX.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)a=iX($C(a,+d[1],+d[2]),d[4]);else if(a=Pe.maxOpen(nX(a.content,s),!0),a.openStart||a.openEnd){let h=0,f=0;for(let p=a.content.firstChild;h<a.openStart&&!p.type.spec.isolating;h++,p=p.firstChild);for(let p=a.content.lastChild;f<a.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);a=$C(a,h,f)}return e.someProp("transformPasted",h=>{a=h(a,e,c)}),a}const tX=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function nX(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.index(n)),o,i=[];if(e.forEach(a=>{if(!i)return;let c=s.findWrapping(a.type),u;if(!c)return i=null;if(u=i.length&&o.length&&hD(c,o,a,i[i.length-1],0))i[i.length-1]=u;else{i.length&&(i[i.length-1]=fD(i[i.length-1],o.length));let d=dD(a,c);i.push(d),s=s.matchType(d.type),o=c}}),i)return je.from(i)}return e}function dD(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,je.from(e));return e}function hD(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let o=hD(e,t,n,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(je.from(dD(n,e,s+1))))}}function fD(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,fD(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(je.empty,!0);return e.copy(n.append(r))}function Qw(e,t,n,r,s,o){let i=t<0?e.firstChild:e.lastChild,a=i.content;return e.childCount>1&&(o=0),s<r-1&&(a=Qw(a,t,n,r,s+1,o)),s>=n&&(a=t<0?i.contentMatchAt(0).fillBefore(a,o<=s).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore(je.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,i.copy(a))}function $C(e,t,n){return t<e.openStart&&(e=new Pe(Qw(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Pe(Qw(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const pD={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function mD(){return document.implementation.createHTMLDocument("title")}let Lg=null;function rX(e){let t=window.trustedTypes;return t?(Lg||(Lg=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Lg.createHTML(e)):e}function sX(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=mD(),r=n.body,s=/<([a-z][^>\s]+)/i.exec(e),o;if((o=s&&pD[s[1].toLowerCase()])&&(e=o.map(i=>"<"+i+">").join("")+e+o.map(i=>"</"+i+">").reverse().join("")),r.innerHTML=rX(e),o)for(let i=0;i<o.length;i++)r=r.querySelector(o[i])||r;for(let i=0;i<n.styleSheets.length;i++){let a=n.styleSheets[i];for(let c=0;c<a.rules.length;c++){let u=a.rules[c];if(u instanceof CSSStyleRule){let d=r.querySelectorAll(u.selectorText);for(let h=0;h<d.length;h++)d[h].style.cssText+=u.style.cssText}}}return r}function oX(e){let t=e.querySelectorAll(Dn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function iX(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:s,openStart:o,openEnd:i}=e;for(let a=r.length-2;a>=0;a-=2){let c=n.nodes[r[a]];if(!c||c.hasRequiredAttrs())break;s=je.from(c.create(r[a+1],s)),o++,i++}return new Pe(s,o,i)}const ar={},lr={},aX={touchstart:!0,touchmove:!0};class lX{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function cX(e){for(let t in ar){let n=ar[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=r=>{dX(e,r)&&!Zx(e,r)&&(e.editable||!(r.type in lr))&&n(e,r)},aX[t]?{passive:!0}:void 0)}Hn&&e.dom.addEventListener("input",()=>null),Zw(e)}function jo(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function uX(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function Zw(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=r=>Zx(e,r))})}function Zx(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function dX(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function hX(e,t){!Zx(e,t)&&ar[t.type]&&(e.editable||!(t.type in lr))&&ar[t.type](e,t)}lr.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!bD(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(So&&Dn&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),_l&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",s=>s(e,ea(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||eX(e,n)?n.preventDefault():jo(e,"key")};lr.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};lr.keypress=(e,t)=>{let n=t;if(bD(e)||!n.charCode||n.ctrlKey&&!n.altKey||Gr&&n.metaKey)return;if(e.someProp("handleKeyPress",s=>s(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof Xe)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),o=()=>e.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!e.someProp("handleTextInput",i=>i(e,r.$from.pos,r.$to.pos,s,o))&&e.dispatch(o()),n.preventDefault()}};function Vu(e){return{left:e.clientX,top:e.clientY}}function fX(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function ek(e,t,n,r,s){if(r==-1)return!1;let o=e.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(e.someProp(t,a=>i>o.depth?a(e,n,o.nodeAfter,o.before(i),s,!0):a(e,n,o.node(i),o.before(i),s,!1)))return!0;return!1}function qu(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function pX(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Qe.isSelectable(r)?(qu(e,new Qe(n)),!0):!1}function mX(e,t){if(t==-1)return!1;let n=e.state.selection,r,s;n instanceof Qe&&(r=n.node);let o=e.state.doc.resolve(t);for(let i=o.depth+1;i>0;i--){let a=i>o.depth?o.nodeAfter:o.node(i);if(Qe.isSelectable(a)){r&&n.$from.depth>0&&i>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?s=o.before(n.$from.depth):s=o.before(i);break}}return s!=null?(qu(e,Qe.create(e.state.doc,s)),!0):!1}function gX(e,t,n,r,s){return ek(e,"handleClickOn",t,n,r)||e.someProp("handleClick",o=>o(e,t,r))||(s?mX(e,n):pX(e,n))}function yX(e,t,n,r){return ek(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",s=>s(e,t,r))}function wX(e,t,n,r){return ek(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",s=>s(e,t,r))||bX(e,n,r)}function bX(e,t,n){if(n.button!=0)return!1;let r=gD(e,t,!0),s=e.state.doc;return r?(qu(e,r),r instanceof Xe&&s.eq(e.state.doc)&&(e.input.mouseDown=new kX(e,r)),!0):!1}function gD(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?Xe.create(r,0,r.content.size):null;let s=r.resolve(t);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),a=s.before(o);if(i.inlineContent)return Xe.create(r,a+1,a+1+i.content.size);if(n&&Qe.isSelectable(i))return Qe.create(r,a)}return null}function tk(e){return mf(e)}const yD=Gr?"metaKey":"ctrlKey";ar.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=tk(e),s=Date.now(),o="singleClick";s-e.input.lastClick.time<500&&fX(n,e.input.lastClick)&&!n[yD]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?o="doubleClick":e.input.lastClick.type=="doubleClick"&&(o="tripleClick")),e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:o,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let i=e.posAtCoords(Vu(n));i&&(o=="singleClick"?e.input.mouseDown=new xX(e,i,n,!!r):(o=="doubleClick"?yX:wX)(e,i.pos,i.inside,n)?n.preventDefault():jo(e,"pointer"))};class wD{constructor(t){this.view=t,this.mightDrag=null,t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(t){this.done()}move(t){t.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class xX extends wD{constructor(t,n,r,s){super(t),this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=t.state.doc,this.selectNode=!!r[yD],this.allowDefault=r.shiftKey;let o,i;if(n.inside>-1)o=t.state.doc.nodeAt(n.inside),i=n.inside;else{let d=t.state.doc.resolve(n.pos);o=d.parent,i=d.depth?d.before():0}const a=s?null:r.target,c=a?t.docView.nearestDesc(a,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=t.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof Qe&&u.from<=i&&u.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Zr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),jo(t,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Eo(this.view)})}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Vu(t))),this.updateAllowDefault(t),this.allowDefault||!n?jo(this.view,"pointer"):gX(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Hn&&this.mightDrag&&!this.mightDrag.node.isAtom||Dn&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(qu(this.view,ot.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):jo(this.view,"pointer")}move(t){this.updateAllowDefault(t),jo(this.view,"pointer"),super.move(t)}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class kX extends wD{constructor(t,n){super(t),this.startSelection=n,this.startDoc=t.state.doc}move(t){if(t.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}t.preventDefault(),jo(this.view,"pointer");let n=this.view.posAtCoords(Vu(t)),r=n&&gD(this.view,n.inside,!1);if(!r)return;let{doc:s}=this.view.state,o=this.startSelection,[i,a]=r.from<o.from?[o.to,r.from]:[o.from,r.to];qu(this.view,Xe.create(s,i,a))}}ar.touchstart=e=>{e.input.lastTouch=Date.now(),tk(e),jo(e,"pointer")};ar.touchmove=e=>{e.input.lastTouch=Date.now(),jo(e,"pointer")};ar.contextmenu=e=>tk(e);function bD(e,t){return e.composing?!0:Hn&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const vX=So?5e3:-1;lr.compositionstart=lr.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Xe&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Dn&&YI&&SX(e)))e.markCursor=e.state.storedMarks||n.marks(),mf(e,!0),e.markCursor=null;else if(mf(e,!t.selection.empty),Zr&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let a=e.domSelection();a&&a.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}e.input.composing=!0}xD(e,vX)};function SX(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}lr.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,xD(e,20))};function xD(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>mf(e),t))}function kD(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function jX(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=mJ(t.focusNode,t.focusOffset),r=gJ(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let i=n.pmViewDesc;if(!(!i||!i.isText(n.nodeValue)))return r}}return n||r}function mf(e,t=!1){if(!(So&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),kD(e),t||e.docView&&e.docView.dirty){let n=Jx(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function CX(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const Cu=xr&&gi<15||_l&&xJ<604;ar.copy=lr.cut=(e,t)=>{let n=t,r=e.state.selection,s=n.type=="cut";if(r.empty)return;let o=Cu?null:n.clipboardData,i=r.content(),{dom:a,text:c}=Qx(e,i);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",c)):CX(e,a),s&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function NX(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function EX(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Nu(e,r.value,null,s,t):Nu(e,r.textContent,r.innerHTML,s,t)},50)}function Nu(e,t,n,r,s){let o=uD(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",c=>c(e,s,o||Pe.empty)))return!0;if(!o)return!1;let i=NX(o),a=i?e.state.tr.replaceSelectionWith(i,r):e.state.tr.replaceSelection(o);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function vD(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}lr.paste=(e,t)=>{let n=t;if(e.composing&&!So)return;let r=Cu?null:n.clipboardData,s=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Nu(e,vD(r),r.getData("text/html"),s,n)?n.preventDefault():EX(e,n)};class SD{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}}const AX=Gr?"altKey":"ctrlKey";function jD(e,t){let n;return e.someProp("dragCopies",r=>{n=n||r(t)}),n!=null?!n:!t[AX]}ar.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=e.state.selection,o=s.empty?null:e.posAtCoords(Vu(n)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof Qe?s.to-1:s.to))){if(r&&r.mightDrag)i=Qe.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=e.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=e.docView&&(i=Qe.create(e.state.doc,h.posBefore))}}let a=(i||e.state.selection).content(),{dom:c,text:u,slice:d}=Qx(e,a);(!n.dataTransfer.files.length||!Dn||qI>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Cu?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Cu||n.dataTransfer.setData("text/plain",u),e.dragging=new SD(d,jD(e,n),i)};ar.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};lr.dragover=lr.dragenter=(e,t)=>t.preventDefault();lr.drop=(e,t)=>{try{TX(e,t,e.dragging)}finally{e.dragging=null}};function TX(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Vu(t));if(!r)return;let s=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",p=>{o=p(o,e,!1)}):o=uD(e,vD(t.dataTransfer),Cu?null:t.dataTransfer.getData("text/html"),!1,s);let i=!!(n&&jD(e,t));if(e.someProp("handleDrop",p=>p(e,t,o||Pe.empty,i))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?zI(e.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=e.state.tr;if(i){let{node:p}=n;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,h=c.doc;if(d?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(h))return;let f=c.doc.resolve(u);if(d&&Qe.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Qe(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,w,b,x)=>p=x),c.setSelection(Xx(e,f,c.doc.resolve(p)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}ar.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Eo(e)},20))};ar.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};ar.beforeinput=(e,t)=>{if(So&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",o=>o(e,ea(8,"Backspace")))))return;let{$cursor:s}=e.state.selection;s&&s.pos>0&&e.dispatch(e.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let e in lr)ar[e]=lr[e];function Eu(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class gf{constructor(t,n){this.toDOM=t,this.spec=n||ga,this.side=this.spec.side||0}map(t,n,r,s){let{pos:o,deleted:i}=t.mapResult(n.from+s,this.side<0?-1:1);return i?null:new Wn(o-r,o-r,this)}valid(){return!0}eq(t){return this==t||t instanceof gf&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Eu(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class bi{constructor(t,n){this.attrs=t,this.spec=n||ga}map(t,n,r,s){let o=t.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,i=t.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new Wn(o,i,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof bi&&Eu(this.attrs,t.attrs)&&Eu(this.spec,t.spec)}static is(t){return t.type instanceof bi}destroy(){}}class nk{constructor(t,n){this.attrs=t,this.spec=n||ga}map(t,n,r,s){let o=t.mapResult(n.from+s,1);if(o.deleted)return null;let i=t.mapResult(n.to+s,-1);return i.deleted||i.pos<=o.pos?null:new Wn(o.pos-r,i.pos-r,this)}valid(t,n){let{index:r,offset:s}=t.content.findIndex(n.from),o;return s==n.from&&!(o=t.child(r)).isText&&s+o.nodeSize==n.to}eq(t){return this==t||t instanceof nk&&Eu(this.attrs,t.attrs)&&Eu(this.spec,t.spec)}destroy(){}}class Wn{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new Wn(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new Wn(t,t,new gf(n,r))}static inline(t,n,r,s){return new Wn(t,n,new bi(r,s))}static node(t,n,r,s){return new Wn(t,n,new nk(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof bi}get widget(){return this.type instanceof gf}}const fl=[],ga={};class Vt{constructor(t,n){this.local=t.length?t:fl,this.children=n.length?n:fl}static create(t,n){return n.length?yf(n,t,0,ga):Fn}find(t,n,r){let s=[];return this.findInner(t??0,n??1e9,s,0,r),s}findInner(t,n,r,s,o){for(let i=0;i<this.local.length;i++){let a=this.local[i];a.from<=n&&a.to>=t&&(!o||o(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<n&&this.children[i+1]>t){let a=this.children[i]+1;this.children[i+2].findInner(t-a,n-a,r,s+a,o)}}map(t,n,r){return this==Fn||t.maps.length==0?this:this.mapInner(t,n,0,0,r||ga)}mapInner(t,n,r,s,o){let i;for(let a=0;a<this.local.length;a++){let c=this.local[a].map(t,r,s);c&&c.type.valid(n,c)?(i||(i=[])).push(c):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?MX(this.children,i||[],t,n,r,s,o):i?new Vt(i.sort(ya),fl):Fn}add(t,n){return n.length?this==Fn?Vt.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let s,o=0;t.forEach((a,c)=>{let u=c+r,d;if(d=ND(n,a,u)){for(s||(s=this.children.slice());o<s.length&&s[o]<c;)o+=3;s[o]==c?s[o+2]=s[o+2].addInner(a,d,u+1):s.splice(o,0,c,c+a.nodeSize,yf(d,a,u+1,ga)),o+=3}});let i=CD(o?ED(n):n,-r);for(let a=0;a<i.length;a++)i[a].type.valid(t,i[a])||i.splice(a--,1);return new Vt(i.length?this.local.concat(i).sort(ya):this.local,s||this.children)}remove(t){return t.length==0||this==Fn?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,a=r[o]+n,c=r[o+1]+n;for(let d=0,h;d<t.length;d++)(h=t[d])&&h.from>a&&h.to<c&&(t[d]=null,(i||(i=[])).push(h));if(!i)continue;r==this.children&&(r=this.children.slice());let u=r[o+2].removeInner(i,a+1);u!=Fn?r[o+2]=u:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<t.length;o++)if(i=t[o])for(let a=0;a<s.length;a++)s[a].eq(i,n)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new Vt(s,r):Fn}forChild(t,n){if(this==Fn)return this;if(n.isLeaf)return Vt.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=t){this.children[a]==t&&(r=this.children[a+2]);break}let o=t+1,i=o+n.content.size;for(let a=0;a<this.local.length;a++){let c=this.local[a];if(c.from<i&&c.to>o&&c.type instanceof bi){let u=Math.max(o,c.from)-o,d=Math.min(i,c.to)-o;u<d&&(s||(s=[])).push(c.copy(u,d))}}if(s){let a=new Vt(s.sort(ya),fl);return r?new oi([a,r]):a}return r||Fn}eq(t){if(this==t)return!0;if(!(t instanceof Vt)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return rk(this.localsInner(t))}localsInner(t){if(this==Fn)return fl;if(t.inlineContent||!this.local.some(bi.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof bi||n.push(this.local[r]);return n}forEachSet(t){t(this)}}Vt.empty=new Vt([],[]);Vt.removeOverlap=rk;const Fn=Vt.empty;class oi{constructor(t){this.members=t}map(t,n){const r=this.members.map(s=>s.map(t,n,ga));return oi.from(r)}forChild(t,n){if(n.isLeaf)return Vt.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(t,n);o!=Fn&&(o instanceof oi?r=r.concat(o.members):r.push(o))}return oi.from(r)}eq(t){if(!(t instanceof oi)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(t);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let i=0;i<o.length;i++)n.push(o[i])}}return n?rk(r?n:n.sort(ya)):fl}static from(t){switch(t.length){case 0:return Fn;case 1:return t[0];default:return new oi(t.every(n=>n instanceof Vt)?t:t.reduce((n,r)=>n.concat(r instanceof Vt?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function MX(e,t,n,r,s,o,i){let a=e.slice();for(let u=0,d=o;u<n.maps.length;u++){let h=0;n.maps[u].forEach((f,p,m,w)=>{let b=w-m-(p-f);for(let x=0;x<a.length;x+=3){let v=a[x+1];if(v<0||f>v+d-h)continue;let S=a[x]+d-h;p>=S?a[x+1]=f<=S?-2:-1:f>=d&&b&&(a[x]+=b,a[x+1]+=b)}h+=b}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<a.length;u+=3)if(a[u+1]<0){if(a[u+1]==-2){c=!0,a[u+1]=-1;continue}let d=n.map(e[u]+o),h=d-s;if(h<0||h>=r.content.size){c=!0;continue}let f=n.map(e[u+1]+o,-1),p=f-s,{index:m,offset:w}=r.content.findIndex(h),b=r.maybeChild(m);if(b&&w==h&&w+b.nodeSize==p){let x=a[u+2].mapInner(n,b,d+1,e[u]+o+1,i);x!=Fn?(a[u]=h,a[u+1]=p,a[u+2]=x):(a[u+1]=-2,c=!0)}else c=!0}if(c){let u=RX(a,e,t,n,s,o,i),d=yf(u,r,0,i);t=d.local;for(let h=0;h<a.length;h+=3)a[h+1]<0&&(a.splice(h,3),h-=3);for(let h=0,f=0;h<d.children.length;h+=3){let p=d.children[h];for(;f<a.length&&a[f]<p;)f+=3;a.splice(f,0,d.children[h],d.children[h+1],d.children[h+2])}}return new Vt(t.sort(ya),a)}function CD(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new Wn(s.from+t,s.to+t,s.type))}return n}function RX(e,t,n,r,s,o,i){function a(c,u){for(let d=0;d<c.local.length;d++){let h=c.local[d].map(r,s,u);h?n.push(h):i.onRemove&&i.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)a(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<e.length;c+=3)e[c+1]==-1&&a(e[c+2],t[c]+o+1);return n}function ND(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let o=0,i;o<e.length;o++)(i=e[o])&&i.from>n&&i.to<r&&((s||(s=[])).push(i),e[o]=null);return s}function ED(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function yf(e,t,n,r){let s=[],o=!1;t.forEach((a,c)=>{let u=ND(e,a,c+n);if(u){o=!0;let d=yf(u,a,n+c+1,r);d!=Fn&&s.push(c,c+a.nodeSize,d)}});let i=CD(o?ED(e):e,-n).sort(ya);for(let a=0;a<i.length;a++)i[a].type.valid(t,i[a])||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1));return i.length||s.length?new Vt(i,s):Fn}function ya(e,t){return e.from-t.from||e.to-t.to}function rk(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let o=t[s];if(o.from==r.from){o.to!=r.to&&(t==e&&(t=e.slice()),t[s]=o.copy(o.from,r.to),PC(t,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,o.from),PC(t,s,r.copy(o.from,r.to)));break}}}return t}function PC(e,t,n){for(;t<e.length&&ya(n,e[t])>0;)t++;e.splice(t,0,n)}function $g(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Fn&&t.push(r)}),e.cursorWrapper&&t.push(Vt.create(e.state.doc,[e.cursorWrapper.deco])),oi.from(t)}const IX={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},DX=xr&&gi<=11;class OX{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class LX{constructor(t,n){this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new OX,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);xr&&gi<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Hn&&t.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),DX&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,IX)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(MC(this.view)){if(this.suppressingSelectionUpdates)return Eo(this.view);if(xr&&gi<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Ca(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let n=new Set,r;for(let o=t.focusNode;o;o=Bl(o))n.add(o);for(let o=t.anchorNode;o;o=Bl(o))if(n.has(o)){r=o;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=t.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&MC(t)&&!this.ignoreSelectionChange(r),o=-1,i=-1,a=!1,c=[];if(t.editable)for(let d=0;d<n.length;d++){let h=this.registerMutation(n[d],c);h&&(o=o<0?h.from:Math.min(h.from,o),i=i<0?h.to:Math.max(h.to,i),h.typeOver&&(a=!0))}if(c.some(d=>d.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||Dn&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&n.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of c)if(d.nodeName=="BR"&&d.parentNode){let h=d.nextSibling;for(;h&&h.nodeType==1;){if(h.contentEditable=="false"){d.parentNode.removeChild(d);break}h=h.firstChild}}}else if(Zr&&c.length){let d=c.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,f]=d;h.parentNode&&h.parentNode.parentNode==f.parentNode?f.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let f of d){let p=f.parentNode;p&&p.nodeName=="LI"&&(!h||zX(t,h)!=p)&&f.remove()}}}let u=null;o<0&&s&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Lp(r)&&(u=Jx(t))&&u.eq(ot.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Eo(t),this.currentSelection.set(r),t.scrollToSelection()):(o>-1||s)&&(o>-1&&(t.docView.markDirty(o,i),$X(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,FX(t,c)),this.handleDOMChange(o,i,a,c),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||Eo(t),this.currentSelection.set(r))}registerMutation(t,n){if(n.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let d=0;d<t.addedNodes.length;d++){let h=t.addedNodes[d];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let s=t.previousSibling,o=t.nextSibling;if(xr&&gi<=11&&t.addedNodes.length)for(let d=0;d<t.addedNodes.length;d++){let{previousSibling:h,nextSibling:f}=t.addedNodes[d];(!h||Array.prototype.indexOf.call(t.addedNodes,h)<0)&&(s=h),(!f||Array.prototype.indexOf.call(t.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==t.target?Mn(s)+1:0,a=r.localPosFromDOM(t.target,i,-1),c=o&&o.parentNode==t.target?Mn(o):t.target.childNodes.length,u=r.localPosFromDOM(t.target,c,1);return{from:a,to:u}}else return t.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=t.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let zC=new WeakMap,FC=!1;function $X(e){if(!zC.has(e)&&(zC.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=Zr,FC)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),FC=!0}}function BC(e,t){let n=t.startContainer,r=t.startOffset,s=t.endContainer,o=t.endOffset,i=e.domAtPos(e.state.selection.anchor);return Ca(i.node,i.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function PX(e,t){if(t.getComposedRanges){let s=t.getComposedRanges(e.root)[0];if(s)return BC(e,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?BC(e,n):null}function zX(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function FX(e,t){var n;let{focusNode:r,focusOffset:s}=e.domSelectionRange();for(let o of t)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let i=o.nextSibling;for(;i&&i.nodeName!="TD"&&i.nodeName!="TH";)i=i.nextSibling;if(i){let a=i;for(;;){let c=a.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;a=c}a.insertBefore(o,a.firstChild),r==o&&e.domSelection().collapse(o,s)}else o.parentNode.removeChild(o)}}function BX(e,t,n,r){let{node:s,fromOffset:o,toOffset:i,from:a,to:c}=e.docView.parseRange(t,n),u=e.domSelectionRange(),d,h=u.anchorNode;if(h&&e.dom.contains(h.nodeType==1?h:h.parentNode)&&(d=[{node:h,offset:u.anchorOffset}],Lp(u)||d.push({node:u.focusNode,offset:u.focusOffset})),Dn&&e.input.lastKeyCode===8)for(let x=i;x>o;x--){let v=s.childNodes[x-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){i=x;break}if(!S||S.size)break}let f=e.state.doc,p=e.someProp("domParser")||mi.fromSchema(e.state.schema),m=f.resolve(a),w=null,b=p.parse(s,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:o,to:i,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:_X(r),context:m});if(d&&d[0].pos!=null){let x=d[0].pos,v=d[1]&&d[1].pos;v==null&&(v=x),w={anchor:x+a,head:v+a}}return{doc:b,sel:w,from:a,to:c}}const _X=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(Hn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||Hn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},WX=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function HX(e,t,n,r,s){let o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let P=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,M=Jx(e,P);if(M&&!e.state.selection.eq(M)){if(Dn&&So&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",L=>L(e,ea(13,"Enter"))))return;let R=e.state.tr.setSelection(M);P=="pointer"?R.setMeta("pointer",!0):P=="key"&&R.scrollIntoView(),o&&R.setMeta("composition",o),e.dispatch(R)}return}let i=e.state.doc.resolve(t),a=i.sharedDepth(n);t=i.before(a+1),n=e.state.doc.resolve(n).after(a+1);let c=e.state.selection,u=BX(e,t,n,s),d=e.state.doc,h=d.slice(u.from,u.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p="end"):(f=e.state.selection.from,p="start"),e.input.lastKeyCode=null;let m=VX(h.content,u.doc.content,u.from,f,p);if(m&&e.input.domChangeCount++,(_l&&e.input.lastIOSEnter>Date.now()-225||So)&&s.some(P=>P.nodeType==1&&!WX.test(P.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",P=>P(e,ea(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof Xe&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let P=_C(e,e.state.doc,u.sel);if(P&&!P.eq(e.state.selection)){let M=e.state.tr.setSelection(P);o&&M.setMeta("composition",o),e.dispatch(M)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof Xe&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),xr&&gi<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>u.from&&u.doc.textBetween(m.start-u.from-1,m.start-u.from+1)==" "&&(m.start--,m.endA--,m.endB--);let w=u.doc.resolveNoCache(m.start-u.from),b=u.doc.resolveNoCache(m.endB-u.from),x=d.resolve(m.start),v=w.sameParent(b)&&w.parent.inlineContent&&x.end()>=m.endA;if((_l&&e.input.lastIOSEnter>Date.now()-225&&(!v||s.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!v&&w.pos<u.doc.content.size&&(!w.sameParent(b)||!w.parent.inlineContent)&&w.pos<b.pos&&!/\S/.test(u.doc.textBetween(w.pos,b.pos,"","")))&&e.someProp("handleKeyDown",P=>P(e,ea(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&KX(d,m.start,m.endA,w,b)&&e.someProp("handleKeyDown",P=>P(e,ea(8,"Backspace")))){So&&Dn&&e.domObserver.suppressSelectionUpdates();return}Dn&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),So&&!v&&w.start()!=b.start()&&b.parentOffset==0&&w.depth==b.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,b=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(P){return P(e,ea(13,"Enter"))})},20));let S=m.start,C=m.endA,O=P=>{let M=P||e.state.tr.replace(S,C,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let R=_C(e,M.doc,u.sel);R&&!(Dn&&e.composing&&R.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(R.head==S||R.head==M.mapping.map(C)-1)||xr&&R.empty&&R.head==S)&&M.setSelection(R)}return o&&M.setMeta("composition",o),M.scrollIntoView()},N;if(v)if(w.pos==b.pos){xr&&gi<=11&&w.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Eo(e),20));let P=O(e.state.tr.delete(S,C)),M=d.resolve(m.start).marksAcross(d.resolve(m.endA));M&&P.ensureMarks(M),e.dispatch(P)}else if(m.endA==m.endB&&(N=UX(w.parent.content.cut(w.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let P=O(e.state.tr);N.type=="add"?P.addMark(S,C,N.mark):P.removeMark(S,C,N.mark),e.dispatch(P)}else if(w.parent.child(w.index()).isText&&w.index()==b.index()-(b.textOffset?0:1)){let P=w.parent.textBetween(w.parentOffset,b.parentOffset),M=()=>O(e.state.tr.insertText(P,S,C));e.someProp("handleTextInput",R=>R(e,S,C,P,M))||e.dispatch(M())}else e.dispatch(O());else e.dispatch(O())}function _C(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Xx(e,t.resolve(n.anchor),t.resolve(n.head))}function UX(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,s=n,o=r,i,a,c;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<n.length;d++)o=n[d].removeFromSet(o);if(s.length==1&&o.length==0)a=s[0],i="add",c=d=>d.mark(a.addToSet(d.marks));else if(s.length==0&&o.length==1)a=o[0],i="remove",c=d=>d.mark(a.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<t.childCount;d++)u.push(c(t.child(d)));if(je.from(u).eq(e))return{mark:a,type:i}}function KX(e,t,n,r,s){if(n-t<=s.pos-r.pos||Pg(r,!0,!1)<s.pos)return!1;let o=e.resolve(t);if(!r.parent.isTextblock){let a=o.nodeAfter;return a!=null&&n==t+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=e.resolve(Pg(o,!0,!0));return!i.parent.isTextblock||i.pos>n||Pg(i,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Pg(e,t,n){let r=e.depth,s=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,s++,t=!1;if(n){let o=e.node(r).maybeChild(e.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function VX(e,t,n,r,s){let o=e.findDiffStart(t,n),i=n+e.size,a=n+t.size;if(o==null)return null;let{a:c,b:u}=e.findDiffEnd(t,i,a);if(s=="end"){let d=Math.max(0,o-Math.min(c,u));r-=c+d-o}if(c<o&&i<a){let d=r<=o&&r>=c?o-r:0;o-=d,u=o+(u-c),c=o}else if(u<o){let d=r<=o&&r>=u?o-r:0;o-=d,c=o+(c-u),u=o}return{start:o,endA:c,endB:u}}class AD{constructor(t,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new lX,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(VC),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=UC(this),HC(this),this.nodeViews=KC(this),this.docView=jC(this.state.doc,WC(this),$g(this),this.dom,this),this.domObserver=new LX(this,(r,s,o,i)=>HX(this,r,s,o,i)),this.domObserver.start(),cX(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let n in t)this._props[n]=t[n];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Zw(this);let n=this._props;this._props=t,t.plugins&&(t.plugins.forEach(VC),this.directPlugins=t.plugins),this.updateStateInner(t.state,n)}setProps(t){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in t)n[r]=t[r];this.update(n)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,n){var r;let s=this.state,o=!1,i=!1;t.storedMarks&&this.composing&&(kD(this),i=!0),this.state=t;let a=s.plugins!=t.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=KC(this);YX(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&Zw(this),this.editable=UC(this),HC(this);let c=$g(this),u=WC(this),d=s.plugins!=t.plugins&&!s.doc.eq(t.doc)?"reset":t.scrollToSelection>s.scrollToSelection?"to selection":"preserve",h=o||!this.docView.matchesNode(t.doc,u,c);(h||!t.selection.eq(s.selection))&&(i=!0);let f=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&SJ(this);if(i){this.domObserver.stop();let p=h&&(xr||Dn)&&!this.composing&&!s.selection.empty&&!t.selection.empty&&qX(s.selection,t.selection);if(h){let w=Dn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=jX(this)),(o||!this.docView.update(t.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=jC(t.doc,u,c,this.dom,this)),w&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let m=this.input.mouseDown;p||!(m&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&qJ(this)&&m.delaySelUpdate())?Eo(this,p):(aD(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&jJ(f)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Qe){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&bC(this,n.getBoundingClientRect(),t)}else bC(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,t)}}updateDraggedNode(t,n){let r=t.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new SD(t.slice,t.move,s<0?void 0:Qe.create(this.state.doc,s))}someProp(t,n){let r=this._props&&this._props[t],s;if(r!=null&&(s=n?n(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let a=this.directPlugins[i].props[t];if(a!=null&&(s=n?n(a):a))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let a=o[i].props[t];if(a!=null&&(s=n?n(a):a))return s}}hasFocus(){if(xr){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&CJ(this.dom),Eo(this),this.domObserver.start()}get root(){let t=this._root;if(t==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return t||document}updateRoot(){this._root=null}posAtCoords(t){return MJ(this,t)}coordsAtPos(t,n=1){return ZI(this,t,n)}domAtPos(t,n=0){return this.docView.domFromPos(t,n)}nodeDOM(t){let n=this.docView.descAt(t);return n?n.nodeDOM:null}posAtDOM(t,n,r=-1){let s=this.docView.posFromDOM(t,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(t,n){return LJ(this,n||this.state,t)}pasteHTML(t,n){return Nu(this,"",t,!1,n||new ClipboardEvent("paste"))}pasteText(t,n){return Nu(this,t,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(t){return Qx(this,t)}destroy(){this.docView&&(uX(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],$g(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,fJ())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return hX(this,t)}domSelectionRange(){let t=this.domSelection();return t?Hn&&this.root.nodeType===11&&wJ(this.dom.ownerDocument)==this.dom&&PX(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}AD.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function WC(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(e.state)),n)for(let r in n)r=="class"?t.class+=" "+n[r]:r=="style"?t.style=(t.style?t.style+";":"")+n[r]:!t[r]&&r!="contenteditable"&&r!="nodeName"&&(t[r]=String(n[r]))}),t.translate||(t.translate="no"),[Wn.node(0,e.state.doc.content.size,t)]}function HC(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Wn.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function UC(e){return!e.someProp("editable",t=>t(e.state)===!1)}function qX(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function KC(e){let t=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(t,s)||(t[s]=r[s])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function YX(e,t){let n=0,r=0;for(let s in e){if(e[s]!=t[s])return!0;n++}for(let s in t)r++;return n!=r}function VC(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var ki={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},wf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},GX=typeof navigator<"u"&&/Mac/.test(navigator.platform),JX=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Rn=0;Rn<10;Rn++)ki[48+Rn]=ki[96+Rn]=String(Rn);for(var Rn=1;Rn<=24;Rn++)ki[Rn+111]="F"+Rn;for(var Rn=65;Rn<=90;Rn++)ki[Rn]=String.fromCharCode(Rn+32),wf[Rn]=String.fromCharCode(Rn);for(var zg in ki)wf.hasOwnProperty(zg)||(wf[zg]=ki[zg]);function XX(e){var t=GX&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||JX&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?wf:ki)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const QX=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ZX=typeof navigator<"u"&&/Win/.test(navigator.platform);function eQ(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,o,i;for(let a=0;a<t.length-1;a++){let c=t[a];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))QX?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),i&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function tQ(e){let t=Object.create(null);for(let n in e)t[eQ(n)]=e[n];return t}function Fg(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function nQ(e){return new an({props:{handleKeyDown:sk(e)}})}function sk(e){let t=tQ(e);return function(n,r){let s=XX(r),o,i=t[Fg(s,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=t[Fg(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ZX&&r.ctrlKey&&r.altKey)&&(o=ki[r.keyCode])&&o!=s){let a=t[Fg(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const ok=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function TD(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const MD=(e,t,n)=>{let r=TD(e,n);if(!r)return!1;let s=ik(r);if(!s){let i=r.blockRange(),a=i&&Jl(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)}let o=s.nodeBefore;if(FD(e,s,t,-1))return!0;if(r.parent.content.size==0&&(Wl(o,"end")||Qe.isSelectable(o)))for(let i=r.depth;;i--){let a=Dp(e.doc,r.before(i),r.after(i),Pe.empty);if(a&&a.slice.size<a.to-a.from){if(t){let c=e.tr.step(a);c.setSelection(Wl(o,"end")?ot.findFrom(c.doc.resolve(c.mapping.map(s.pos,-1)),-1):Qe.create(c.doc,s.pos-o.nodeSize)),t(c.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return o.isAtom&&s.depth==r.depth-1?(t&&t(e.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},rQ=(e,t,n)=>{let r=TD(e,n);if(!r)return!1;let s=ik(r);return s?RD(e,s,t):!1},sQ=(e,t,n)=>{let r=DD(e,n);if(!r)return!1;let s=ak(r);return s?RD(e,s,t):!1};function RD(e,t,n){let r=t.nodeBefore,s=r,o=t.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let i=t.nodeAfter,a=i,c=t.pos+1;for(;!a.isTextblock;c++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let u=Dp(e.doc,o,c,Pe.empty);if(!u||u.from!=o||u instanceof sn&&u.slice.size>=c-o)return!1;if(n){let d=e.tr.step(u);d.setSelection(Xe.create(d.doc,o)),n(d.scrollIntoView())}return!0}function Wl(e,t,n=!1){for(let r=e;r;r=t=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const ID=(e,t,n)=>{let{$head:r,empty:s}=e.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=ik(r)}let i=o&&o.nodeBefore;return!i||!Qe.isSelectable(i)?!1:(t&&t(e.tr.setSelection(Qe.create(e.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function ik(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function DD(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const OD=(e,t,n)=>{let r=DD(e,n);if(!r)return!1;let s=ak(r);if(!s)return!1;let o=s.nodeAfter;if(FD(e,s,t,1))return!0;if(r.parent.content.size==0&&(Wl(o,"start")||Qe.isSelectable(o))){let i=Dp(e.doc,r.before(),r.after(),Pe.empty);if(i&&i.slice.size<i.to-i.from){if(t){let a=e.tr.step(i);a.setSelection(Wl(o,"start")?ot.findFrom(a.doc.resolve(a.mapping.map(s.pos)),1):Qe.create(a.doc,a.mapping.map(s.pos))),t(a.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(t&&t(e.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},LD=(e,t,n)=>{let{$head:r,empty:s}=e.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=ak(r)}let i=o&&o.nodeAfter;return!i||!Qe.isSelectable(i)?!1:(t&&t(e.tr.setSelection(Qe.create(e.doc,o.pos)).scrollIntoView()),!0)};function ak(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const oQ=(e,t)=>{let n=e.selection,r=n instanceof Qe,s;if(r){if(n.node.isTextblock||!Ci(e.doc,n.from))return!1;s=n.from}else if(s=Ip(e.doc,n.from,-1),s==null)return!1;if(t){let o=e.tr.join(s);r&&o.setSelection(Qe.create(o.doc,s-e.doc.resolve(s).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0},iQ=(e,t)=>{let n=e.selection,r;if(n instanceof Qe){if(n.node.isTextblock||!Ci(e.doc,n.to))return!1;r=n.to}else if(r=Ip(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},aQ=(e,t)=>{let{$from:n,$to:r}=e.selection,s=n.blockRange(r),o=s&&Jl(s);return o==null?!1:(t&&t(e.tr.lift(s,o).scrollIntoView()),!0)},$D=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
723
|
+
`).scrollIntoView()),!0)};function lk(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const lQ=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),o=n.indexAfter(-1),i=lk(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(t){let a=n.after(),c=e.tr.replaceWith(a,a,i.createAndFill());c.setSelection(ot.near(c.doc.resolve(a),1)),t(c.scrollIntoView())}return!0},PD=(e,t)=>{let n=e.selection,{$from:r,$to:s}=n;if(n instanceof Pr||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=lk(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let i=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,a=e.tr.insert(i,o.createAndFill());a.setSelection(Xe.create(a.doc,i+1)),t(a.scrollIntoView())}return!0},zD=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(No(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Jl(r);return s==null?!1:(t&&t(e.tr.lift(r,s).scrollIntoView()),!0)};function cQ(e){return(t,n)=>{if(t.selection instanceof Qe&&t.selection.node.isBlock){let{$from:p}=t.selection;return!p.parentOffset||!No(t.doc,p.pos)?!1:(n&&n(t.tr.split(p.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof Xe||t.selection instanceof Pr)&&r.deleteSelection();let{$from:s}=r.selection,o=r.steps.length,i=[],a,c,u=!1,d=!1;for(let p=s.depth;;p--)if(s.node(p).isBlock){u=s.end(p)==s.pos+(s.depth-p),d=s.start(p)==s.pos-(s.depth-p),c=lk(s.node(p-1).contentMatchAt(s.indexAfter(p-1))),i.unshift(u&&c?{type:c}:null),a=p;break}else{if(p==1)return!1;i.unshift(null)}let h=s.pos,f=No(r.doc,h,i.length,i);if(f||(i[0]=c?{type:c}:null,f=No(r.doc,h,i.length,i)),!f)return!1;if(r.split(h,i.length,i),!u&&d&&s.node(a).type!=c){let p=r.mapping.slice(o),m=p.map(s.before(a)),w=r.doc.resolve(m);c&&s.node(a-1).canReplaceWith(w.index(),w.index()+1,c)&&r.setNodeMarkup(p.map(s.before(a)),c)}return n&&n(r.scrollIntoView()),!0}}const uQ=cQ(),dQ=(e,t)=>{let{$from:n,to:r}=e.selection,s,o=n.sharedDepth(r);return o==0?!1:(s=n.before(o),t&&t(e.tr.setSelection(Qe.create(e.doc,s))),!0)};function hQ(e,t,n){let r=t.nodeBefore,s=t.nodeAfter,o=t.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(o,o+1)||!(s.isTextblock||Ci(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function FD(e,t,n,r){let s=t.nodeBefore,o=t.nodeAfter,i,a,c=s.type.spec.isolating||o.type.spec.isolating;if(!c&&hQ(e,t,n))return!0;let u=!c&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(i=(a=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&a.matchType(i[0]||o.type).validEnd){if(n){let p=t.pos+o.nodeSize,m=je.empty;for(let x=i.length-1;x>=0;x--)m=je.from(i[x].create(null,m));m=je.from(s.copy(m));let w=e.tr.step(new yn(t.pos-1,p,t.pos,p,new Pe(m,1,0),i.length,!0)),b=w.doc.resolve(p+2*i.length);b.nodeAfter&&b.nodeAfter.type==s.type&&Ci(w.doc,b.pos)&&w.join(b.pos),n(w.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&c?null:ot.findFrom(t,1),h=d&&d.$from.blockRange(d.$to),f=h&&Jl(h);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(h,f).scrollIntoView()),!0;if(u&&Wl(o,"start",!0)&&Wl(s,"end")){let p=s,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let w=o,b=1;for(;!w.isTextblock;w=w.firstChild)b++;if(p.canReplace(p.childCount,p.childCount,w.content)){if(n){let x=je.empty;for(let S=m.length-1;S>=0;S--)x=je.from(m[S].copy(x));let v=e.tr.step(new yn(t.pos-m.length,t.pos+o.nodeSize,t.pos+b,t.pos+o.nodeSize-b,new Pe(x,m.length,0),0,!0));n(v.scrollIntoView())}return!0}}return!1}function BD(e){return function(t,n){let r=t.selection,s=e<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(n&&n(t.tr.setSelection(Xe.create(t.doc,e<0?s.start(o):s.end(o)))),!0):!1}}const fQ=BD(-1),pQ=BD(1);function mQ(e,t=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o),a=i&&Vx(i,e,t);return a?(r&&r(n.tr.wrap(i,a).scrollIntoView()),!0):!1}}function qC(e,t=null){return function(n,r){let s=!1;for(let o=0;o<n.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:a}}=n.selection.ranges[o];n.doc.nodesBetween(i,a,(c,u)=>{if(s)return!1;if(!(!c.isTextblock||c.hasMarkup(e,t)))if(c.type==e)s=!0;else{let d=n.doc.resolve(u),h=d.index();s=d.parent.canReplaceWith(h,h+1,e)}})}if(!s)return!1;if(r){let o=n.tr;for(let i=0;i<n.selection.ranges.length;i++){let{$from:{pos:a},$to:{pos:c}}=n.selection.ranges[i];o.setBlockType(a,c,e,t)}r(o.scrollIntoView())}return!0}}function ck(...e){return function(t,n,r){for(let s=0;s<e.length;s++)if(e[s](t,n,r))return!0;return!1}}ck(ok,MD,ID);ck(ok,OD,LD);ck($D,PD,zD,uQ);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function gQ(e,t=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o);if(!i)return!1;let a=r?n.tr:null;return yQ(a,i,e,t)?(r&&r(a.scrollIntoView()),!0):!1}}function yQ(e,t,n,r=null){let s=!1,o=t,i=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let c=i.resolve(t.start-2);o=new df(c,c,t.depth),t.endIndex<t.parent.childCount&&(t=new df(t.$from,i.resolve(t.$to.end(t.depth)),t.depth)),s=!0}let a=Vx(o,n,r,t);return a?(e&&wQ(e,t,a,s,n),!0):!1}function wQ(e,t,n,r,s){let o=je.empty;for(let d=n.length-1;d>=0;d--)o=je.from(n[d].type.create(n[d].attrs,o));e.step(new yn(t.start-(r?2:0),t.end,t.start,t.end,new Pe(o,0,0),n.length,!0));let i=0;for(let d=0;d<n.length;d++)n[d].type==s&&(i=d+1);let a=n.length-i,c=t.start+n.length-(r?2:0),u=t.parent;for(let d=t.startIndex,h=t.endIndex,f=!0;d<h;d++,f=!1)!f&&No(e.doc,c,a)&&(e.split(c,a),c+=2*a),c+=u.child(d).nodeSize;return e}function bQ(e){return function(t,n){let{$from:r,$to:s}=t.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==e);return o?n?r.node(o.depth-1).type==e?xQ(t,n,e,o):kQ(t,n,o):!0:!1}}function xQ(e,t,n,r){let s=e.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new yn(o-1,i,o,i,new Pe(je.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new df(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const a=Jl(r);if(a==null)return!1;s.lift(r,a);let c=s.doc.resolve(s.mapping.map(o,-1)-1);return Ci(s.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&s.join(c.pos),t(s.scrollIntoView()),!0}function kQ(e,t,n){let r=e.tr,s=n.parent;for(let p=n.end,m=n.endIndex-1,w=n.startIndex;m>w;m--)p-=s.child(m).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(n.start),i=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,c=n.endIndex==s.childCount,u=o.node(-1),d=o.index(-1);if(!u.canReplace(d+(a?0:1),d+1,i.content.append(c?je.empty:je.from(s))))return!1;let h=o.pos,f=h+i.nodeSize;return r.step(new yn(h-(a?1:0),f+(c?1:0),h+1,f-1,new Pe((a?je.empty:je.from(s.copy(je.empty))).append(c?je.empty:je.from(s.copy(je.empty))),a?0:1,c?0:1),a?0:1)),t(r.scrollIntoView()),!0}function vQ(e){return function(t,n){let{$from:r,$to:s}=t.selection,o=r.blockRange(s,u=>u.childCount>0&&u.firstChild.type==e);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let a=o.parent,c=a.child(i-1);if(c.type!=e)return!1;if(n){let u=c.lastChild&&c.lastChild.type==a.type,d=je.from(u?e.create():null),h=new Pe(je.from(e.create(null,je.from(a.type.create(null,d)))),u?3:1,0),f=o.start,p=o.end;n(t.tr.step(new yn(f-(u?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0}}function Pp(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:s}=n,{storedMarks:o}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,o=n.storedMarks,n}}}class zp{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:n,state:r}=this,{view:s}=n,{tr:o}=r,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>{const h=c(...d)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(o),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:r,editor:s,state:o}=this,{view:i}=s,a=[],c=!!t,u=t||o.tr,d=()=>(!c&&n&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),a.every(f=>f===!0)),h={...Object.fromEntries(Object.entries(r).map(([f,p])=>[f,(...w)=>{const b=this.buildProps(u,n),x=p(...w)(b);return a.push(x),h}])),run:d};return h}createCan(t){const{rawCommands:n,state:r}=this,s=!1,o=t||r.tr,i=this.buildProps(o,s);return{...Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...d)=>u(...d)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,s)}}buildProps(t,n=!0){const{rawCommands:r,editor:s,state:o}=this,{view:i}=s,a={tr:t,editor:s,view:i,state:Pp({state:o,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([c,u])=>[c,(...d)=>u(...d)(a)]))}};return a}}class SQ{constructor(){this.callbacks={}}on(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),this}emit(t,...n){const r=this.callbacks[t];return r&&r.forEach(s=>s.apply(this,n)),this}off(t,n){const r=this.callbacks[t];return r&&(n?this.callbacks[t]=r.filter(s=>s!==n):delete this.callbacks[t]),this}once(t,n){const r=(...s)=>{this.off(t,r),n.apply(this,s)};return this.on(t,r)}removeAllListeners(){this.callbacks={}}}function Ue(e,t,n){return e.config[t]===void 0&&e.parent?Ue(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?Ue(e.parent,t,n):null}):e.config[t]}function Fp(e){const t=e.filter(s=>s.type==="extension"),n=e.filter(s=>s.type==="node"),r=e.filter(s=>s.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:r}}function _D(e){const t=[],{nodeExtensions:n,markExtensions:r}=Fp(e),s=[...n,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage,extensions:s},c=Ue(i,"addGlobalAttributes",a);if(!c)return;c().forEach(d=>{d.types.forEach(h=>{Object.entries(d.attributes).forEach(([f,p])=>{t.push({type:h,name:f,attribute:{...o,...p}})})})})}),s.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},c=Ue(i,"addAttributes",a);if(!c)return;const u=c();Object.entries(u).forEach(([d,h])=>{const f={...o,...h};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,t.push({type:i.name,name:d,attribute:f})})}),t}function xn(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Bt(...e){return e.filter(t=>!!t).reduce((t,n)=>{const r={...t};return Object.entries(n).forEach(([s,o])=>{if(!r[s]){r[s]=o;return}if(s==="class"){const a=o?String(o).split(" "):[],c=r[s]?r[s].split(" "):[],u=a.filter(d=>!c.includes(d));r[s]=[...c,...u].join(" ")}else if(s==="style"){const a=o?o.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[h,f]=d.split(":").map(p=>p.trim());u.set(h,f)}),a.forEach(d=>{const[h,f]=d.split(":").map(p=>p.trim());u.set(h,f)}),r[s]=Array.from(u.entries()).map(([d,h])=>`${d}: ${h}`).join("; ")}else r[s]=o}),r},{})}function eb(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>Bt(n,r),{})}function WD(e){return typeof e=="function"}function pt(e,t=void 0,...n){return WD(e)?t?e.bind(t)(...n):e(...n):e}function jQ(e={}){return Object.keys(e).length===0&&e.constructor===Object}function CQ(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function YC(e,t){return"style"in e?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;const s=t.reduce((o,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(n):CQ(n.getAttribute(i.name));return a==null?o:{...o,[i.name]:a}},{});return{...r,...s}}}}function GC(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&jQ(n)?!1:n!=null))}function NQ(e,t){var n;const r=_D(e),{nodeExtensions:s,markExtensions:o}=Fp(e),i=(n=s.find(u=>Ue(u,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(s.map(u=>{const d=r.filter(x=>x.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:t},f=e.reduce((x,v)=>{const S=Ue(v,"extendNodeSchema",h);return{...x,...S?S(u):{}}},{}),p=GC({...f,content:pt(Ue(u,"content",h)),marks:pt(Ue(u,"marks",h)),group:pt(Ue(u,"group",h)),inline:pt(Ue(u,"inline",h)),atom:pt(Ue(u,"atom",h)),selectable:pt(Ue(u,"selectable",h)),draggable:pt(Ue(u,"draggable",h)),code:pt(Ue(u,"code",h)),whitespace:pt(Ue(u,"whitespace",h)),linebreakReplacement:pt(Ue(u,"linebreakReplacement",h)),defining:pt(Ue(u,"defining",h)),isolating:pt(Ue(u,"isolating",h)),attrs:Object.fromEntries(d.map(x=>{var v;return[x.name,{default:(v=x==null?void 0:x.attribute)===null||v===void 0?void 0:v.default}]}))}),m=pt(Ue(u,"parseHTML",h));m&&(p.parseDOM=m.map(x=>YC(x,d)));const w=Ue(u,"renderHTML",h);w&&(p.toDOM=x=>w({node:x,HTMLAttributes:eb(x,d)}));const b=Ue(u,"renderText",h);return b&&(p.toText=b),[u.name,p]})),c=Object.fromEntries(o.map(u=>{const d=r.filter(b=>b.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:t},f=e.reduce((b,x)=>{const v=Ue(x,"extendMarkSchema",h);return{...b,...v?v(u):{}}},{}),p=GC({...f,inclusive:pt(Ue(u,"inclusive",h)),excludes:pt(Ue(u,"excludes",h)),group:pt(Ue(u,"group",h)),spanning:pt(Ue(u,"spanning",h)),code:pt(Ue(u,"code",h)),attrs:Object.fromEntries(d.map(b=>{var x;return[b.name,{default:(x=b==null?void 0:b.attribute)===null||x===void 0?void 0:x.default}]}))}),m=pt(Ue(u,"parseHTML",h));m&&(p.parseDOM=m.map(b=>YC(b,d)));const w=Ue(u,"renderHTML",h);return w&&(p.toDOM=b=>w({mark:b,HTMLAttributes:eb(b,d)})),[u.name,p]}));return new EI({topNode:i,nodes:a,marks:c})}function Bg(e,t){return t.nodes[e]||t.marks[e]||null}function JC(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function uk(e,t){const n=Ia.fromSchema(t).serializeFragment(e),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}const EQ=(e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(s,o,i,a)=>{var c,u;const d=((u=(c=s.type.spec).toText)===null||u===void 0?void 0:u.call(c,{node:s,pos:o,parent:i,index:a}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-o))}),n};function dk(e){return Object.prototype.toString.call(e)==="[object RegExp]"}class Yu{constructor(t){this.find=t.find,this.handler=t.handler}}const AQ=(e,t)=>{if(dk(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Hd(e){var t;const{editor:n,from:r,to:s,text:o,rules:i,plugin:a}=e,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!((t=u.nodeBefore||u.nodeAfter)===null||t===void 0)&&t.marks.find(f=>f.type.spec.code))return!1;let d=!1;const h=EQ(u)+o;return i.forEach(f=>{if(d)return;const p=AQ(h,f.find);if(!p)return;const m=c.state.tr,w=Pp({state:c.state,transaction:m}),b={from:r-(p[0].length-o.length),to:s},{commands:x,chain:v,can:S}=new zp({editor:n,state:w});f.handler({state:w,range:b,match:p,commands:x,chain:v,can:S})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:s,text:o}),c.dispatch(m),d=!0)}),d}function TQ(e){const{editor:t,rules:n}=e,r=new an({state:{init(){return null},apply(s,o,i){const a=s.getMeta(r);if(a)return a;const c=s.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=uk(je.from(d),i.schema);const{from:h}=c,f=h+d.length;Hd({editor:t,from:h,to:f,text:d,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,a){return Hd({editor:t,from:o,to:i,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&Hd({editor:t,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?Hd({editor:t,from:i.pos,to:i.pos,text:`
|
|
724
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function MQ(e){return Object.prototype.toString.call(e).slice(8,-1)}function Ud(e){return MQ(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function Bp(e,t){const n={...e};return Ud(e)&&Ud(t)&&Object.keys(t).forEach(r=>{Ud(t[r])&&Ud(e[r])?n[r]=Bp(e[r],t[r]):n[r]=t[r]}),n}let Da=class tb{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=pt(Ue(this,"addOptions",{name:this.name}))),this.storage=pt(Ue(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new tb(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>Bp(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new tb(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=pt(Ue(n,"addOptions",{name:n.name})),n.storage=pt(Ue(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:r}=t.state,s=t.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!!!i.find(u=>(u==null?void 0:u.type.name)===n.name))return!1;const c=i.find(u=>(u==null?void 0:u.type.name)===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",s.pos),t.view.dispatch(r),!0}return!1}};function RQ(e){return typeof e=="number"}class IQ{constructor(t){this.find=t.find,this.handler=t.handler}}const DQ=(e,t,n)=>{if(dk(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=e,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function OQ(e){const{editor:t,state:n,from:r,to:s,rule:o,pasteEvent:i,dropEvent:a}=e,{commands:c,chain:u,can:d}=new zp({editor:t,state:n}),h=[];return n.doc.nodesBetween(r,s,(p,m)=>{if(!p.isTextblock||p.type.spec.code)return;const w=Math.max(r,m),b=Math.min(s,m+p.content.size),x=p.textBetween(w-m,b-m,void 0,"");DQ(x,o.find,i).forEach(S=>{if(S.index===void 0)return;const C=w+S.index+1,O=C+S[0].length,N={from:n.tr.mapping.map(C),to:n.tr.mapping.map(O)},P=o.handler({state:n,range:N,match:S,commands:c,chain:u,can:d,pasteEvent:i,dropEvent:a});h.push(P)})}),h.every(p=>p!==null)}let Kd=null;const LQ=e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=n.clipboardData)===null||t===void 0||t.setData("text/html",e),n};function $Q(e){const{editor:t,rules:n}=e;let r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const c=({state:d,from:h,to:f,rule:p,pasteEvt:m})=>{const w=d.tr,b=Pp({state:d,transaction:w});if(!(!OQ({editor:t,state:b,from:Math.max(h-1,0),to:f.b-1,rule:p,pasteEvent:m,dropEvent:a})||!w.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return n.map(d=>new an({view(h){const f=m=>{var w;r=!((w=h.dom.parentElement)===null||w===void 0)&&w.contains(m.target)?h.dom.parentElement:null,r&&(Kd=t)},p=()=>{Kd&&(Kd=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(h,f)=>{if(o=r===h.dom.parentElement,a=f,!o){const p=Kd;p!=null&&p.isEditable&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(h,f)=>{var p;const m=(p=f.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return i=f,s=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(h,f,p)=>{const m=h[0],w=m.getMeta("uiEvent")==="paste"&&!s,b=m.getMeta("uiEvent")==="drop"&&!o,x=m.getMeta("applyPasteRules"),v=!!x;if(!w&&!b&&!v)return;if(v){let{text:O}=x;typeof O=="string"?O=O:O=uk(je.from(O),p.schema);const{from:N}=x,P=N+O.length,M=LQ(O);return c({rule:d,state:p,from:N,to:{b:P},pasteEvt:M})}const S=f.doc.content.findDiffStart(p.doc.content),C=f.doc.content.findDiffEnd(p.doc.content);if(!(!RQ(S)||!C||S===C.b))return c({rule:d,state:p,from:S,to:C,pasteEvt:i})}}))}function PQ(e){const t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}class kl{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=kl.resolve(t),this.schema=NQ(this.extensions,n),this.setupExtensions()}static resolve(t){const n=kl.sort(kl.flatten(t)),r=PQ(n.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),n}static flatten(t){return t.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},s=Ue(n,"addExtensions",r);return s?[n,...this.flatten(s())]:n}).flat(10)}static sort(t){return t.sort((r,s)=>{const o=Ue(r,"priority")||100,i=Ue(s,"priority")||100;return o>i?-1:o<i?1:0})}get commands(){return this.extensions.reduce((t,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Bg(n.name,this.schema)},s=Ue(n,"addCommands",r);return s?{...t,...s()}:t},{})}get plugins(){const{editor:t}=this,n=kl.sort([...this.extensions].reverse()),r=[],s=[],o=n.map(i=>{const a={name:i.name,options:i.options,storage:i.storage,editor:t,type:Bg(i.name,this.schema)},c=[],u=Ue(i,"addKeyboardShortcuts",a);let d={};if(i.type==="mark"&&Ue(i,"exitable",a)&&(d.ArrowRight=()=>Da.handleExit({editor:t,mark:i})),u){const w=Object.fromEntries(Object.entries(u()).map(([b,x])=>[b,()=>x({editor:t})]));d={...d,...w}}const h=nQ(d);c.push(h);const f=Ue(i,"addInputRules",a);JC(i,t.options.enableInputRules)&&f&&r.push(...f());const p=Ue(i,"addPasteRules",a);JC(i,t.options.enablePasteRules)&&p&&s.push(...p());const m=Ue(i,"addProseMirrorPlugins",a);if(m){const w=m();c.push(...w)}return c}).flat();return[TQ({editor:t,rules:r}),...$Q({editor:t,rules:s}),...o]}get attributes(){return _D(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:n}=Fp(this.extensions);return Object.fromEntries(n.filter(r=>!!Ue(r,"addNodeView")).map(r=>{const s=this.attributes.filter(c=>c.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:t,type:xn(r.name,this.schema)},i=Ue(r,"addNodeView",o);if(!i)return[];const a=(c,u,d,h,f)=>{const p=eb(c,s);return i()({node:c,view:u,getPos:d,decorations:h,innerDecorations:f,editor:t,extension:r,HTMLAttributes:p})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(t=>{var n;this.editor.extensionStorage[t.name]=t.storage;const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Bg(t.name,this.schema)};t.type==="mark"&&(!((n=pt(Ue(t,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(t.name);const s=Ue(t,"onBeforeCreate",r),o=Ue(t,"onCreate",r),i=Ue(t,"onUpdate",r),a=Ue(t,"onSelectionUpdate",r),c=Ue(t,"onTransaction",r),u=Ue(t,"onFocus",r),d=Ue(t,"onBlur",r),h=Ue(t,"onDestroy",r);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),i&&this.editor.on("update",i),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),h&&this.editor.on("destroy",h)})}}class kn{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=pt(Ue(this,"addOptions",{name:this.name}))),this.storage=pt(Ue(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new kn(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>Bp(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new kn({...this.config,...t});return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=pt(Ue(n,"addOptions",{name:n.name})),n.storage=pt(Ue(n,"addStorage",{name:n.name,options:n.options})),n}}function HD(e,t,n){const{from:r,to:s}=t,{blockSeparator:o=`
|
|
725
|
+
|
|
726
|
+
`,textSerializers:i={}}=n||{};let a="";return e.nodesBetween(r,s,(c,u,d,h)=>{var f;c.isBlock&&u>r&&(a+=o);const p=i==null?void 0:i[c.type.name];if(p)return d&&(a+=p({node:c,pos:u,parent:d,index:h,range:t})),!1;c.isText&&(a+=(f=c==null?void 0:c.text)===null||f===void 0?void 0:f.slice(Math.max(r,u)-u,s-u))}),a}function UD(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}const zQ=kn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new an({key:new On("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:s}=t,{ranges:o}=s,i=Math.min(...o.map(d=>d.$from.pos)),a=Math.max(...o.map(d=>d.$to.pos)),c=UD(n);return HD(r,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),FQ=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),BQ=(e=!1)=>({commands:t})=>t.setContent("",e),_Q=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:s}=r;return n&&s.forEach(({$from:o,$to:i})=>{e.doc.nodesBetween(o.pos,i.pos,(a,c)=>{if(a.type.isText)return;const{doc:u,mapping:d}=t,h=u.resolve(d.map(c)),f=u.resolve(d.map(c+a.nodeSize)),p=h.blockRange(f);if(!p)return;const m=Jl(p);if(a.type.isTextblock){const{defaultType:w}=h.parent.contentMatchAt(h.index());t.setNodeMarkup(p.start,w)}(m||m===0)&&t.lift(p,m)})}),!0},WQ=e=>t=>e(t),HQ=()=>({state:e,dispatch:t})=>PD(e,t),UQ=(e,t)=>({editor:n,tr:r})=>{const{state:s}=n,o=s.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const i=r.mapping.map(t);return r.insert(i,o.content),r.setSelection(new Xe(r.doc.resolve(Math.max(i-1,0)))),!0},KQ=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(t){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},VQ=e=>({tr:t,state:n,dispatch:r})=>{const s=xn(e,n.schema),o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const c=o.before(i),u=o.after(i);t.delete(c,u).scrollIntoView()}return!0}return!1},qQ=e=>({tr:t,dispatch:n})=>{const{from:r,to:s}=e;return n&&t.delete(r,s),!0},YQ=()=>({state:e,dispatch:t})=>ok(e,t),GQ=()=>({commands:e})=>e.keyboardShortcut("Enter"),JQ=()=>({state:e,dispatch:t})=>lQ(e,t);function bf(e,t,n={strict:!0}){const r=Object.keys(t);return r.length?r.every(s=>n.strict?t[s]===e[s]:dk(t[s])?t[s].test(e[s]):t[s]===e[s]):!0}function KD(e,t,n={}){return e.find(r=>r.type===t&&bf(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function XC(e,t,n={}){return!!KD(e,t,n)}function hk(e,t,n){var r;if(!e||!t)return;let s=e.parent.childAfter(e.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===t))&&(s=e.parent.childBefore(e.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===t)||(n=n||((r=s.node.marks[0])===null||r===void 0?void 0:r.attrs),!KD([...s.node.marks],t,n)))return;let i=s.index,a=e.start()+s.offset,c=i+1,u=a+s.node.nodeSize;for(;i>0&&XC([...e.parent.child(i-1).marks],t,n);)i-=1,a-=e.parent.child(i).nodeSize;for(;c<e.parent.childCount&&XC([...e.parent.child(c).marks],t,n);)u+=e.parent.child(c).nodeSize,c+=1;return{from:a,to:u}}function Ei(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const XQ=(e,t={})=>({tr:n,state:r,dispatch:s})=>{const o=Ei(e,r.schema),{doc:i,selection:a}=n,{$from:c,from:u,to:d}=a;if(s){const h=hk(c,o,t);if(h&&h.from<=u&&h.to>=d){const f=Xe.create(i,h.from,h.to);n.setSelection(f)}}return!0},QQ=e=>t=>{const n=typeof e=="function"?e(t):e;for(let r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1};function VD(e){return e instanceof Xe}function aa(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function qD(e,t=null){if(!t)return null;const n=ot.atStart(e),r=ot.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return r;const s=n.from,o=r.to;return t==="all"?Xe.create(e,aa(0,s,o),aa(e.content.size,s,o)):Xe.create(e,aa(t,s,o),aa(t,s,o))}function QC(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function xf(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ZQ(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const eZ=(e=null,t={})=>({editor:n,view:r,tr:s,dispatch:o})=>{t={scrollIntoView:!0,...t};const i=()=>{(xf()||QC())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),ZQ()&&!xf()&&!QC()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&e===null||e===!1)return!0;if(o&&e===null&&!VD(n.state.selection))return i(),!0;const a=qD(s.doc,e)||n.state.selection,c=n.state.selection.eq(a);return o&&(c||s.setSelection(a),c&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},tZ=(e,t)=>n=>e.every((r,s)=>t(r,{...n,index:s})),nZ=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),YD=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&YD(r)}return e};function Vd(e){const t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return YD(n)}function Au(e,t,n){if(e instanceof pi||e instanceof je)return e;n={slice:!0,parseOptions:{},...n};const r=typeof e=="object"&&e!==null,s=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return je.fromArray(e.map(a=>t.nodeFromJSON(a)));const i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",o),Au("",t,n)}if(s){if(n.errorOnInvalidContent){let i=!1,a="";const c=new EI({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(i=!0,a=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?mi.fromSchema(c).parseSlice(Vd(e),n.parseOptions):mi.fromSchema(c).parse(Vd(e),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=mi.fromSchema(t);return n.slice?o.parseSlice(Vd(e),n.parseOptions).content:o.parse(Vd(e),n.parseOptions)}return Au("",t,n)}function rZ(e,t,n){const r=e.steps.length-1;if(r<t)return;const s=e.steps[r];if(!(s instanceof sn||s instanceof yn))return;const o=e.mapping.maps[r];let i=0;o.forEach((a,c,u,d)=>{i===0&&(i=d)}),e.setSelection(ot.near(e.doc.resolve(i),n))}const sZ=e=>!("type"in e),oZ=(e,t,n)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const c=b=>{o.emit("contentError",{editor:o,error:b,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Au(t,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(b){c(b)}try{a=Au(t,o.schema,{parseOptions:u,errorOnInvalidContent:(i=n.errorOnInvalidContent)!==null&&i!==void 0?i:o.options.enableContentCheck})}catch(b){return c(b),!1}let{from:d,to:h}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},f=!0,p=!0;if((sZ(a)?a:[a]).forEach(b=>{b.check(),f=f?b.isText&&b.marks.length===0:!1,p=p?b.isBlock:!1}),d===h&&p){const{parent:b}=r.doc.resolve(d);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(d-=1,h+=1)}let w;if(f){if(Array.isArray(t))w=t.map(b=>b.text||"").join("");else if(t instanceof je){let b="";t.forEach(x=>{x.text&&(b+=x.text)}),w=b}else typeof t=="object"&&t&&t.text?w=t.text:w=t;r.insertText(w,d,h)}else w=a,r.replaceWith(d,h,w);n.updateSelection&&rZ(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:w}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:w})}return!0},iZ=()=>({state:e,dispatch:t})=>oQ(e,t),aZ=()=>({state:e,dispatch:t})=>iQ(e,t),lZ=()=>({state:e,dispatch:t})=>MD(e,t),cZ=()=>({state:e,dispatch:t})=>OD(e,t),uZ=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Ip(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},dZ=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Ip(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},hZ=()=>({state:e,dispatch:t})=>rQ(e,t),fZ=()=>({state:e,dispatch:t})=>sQ(e,t);function GD(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function pZ(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let r,s,o,i;for(let a=0;a<t.length-1;a+=1){const c=t[a];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))xf()||GD()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const mZ=e=>({editor:t,view:n,tr:r,dispatch:s})=>{const o=pZ(e).split(/-(?!$)/),i=o.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),c=t.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,a))});return c==null||c.steps.forEach(u=>{const d=u.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function Tu(e,t,n={}){const{from:r,to:s,empty:o}=e.selection,i=t?xn(t,e.schema):null,a=[];e.doc.nodesBetween(r,s,(h,f)=>{if(h.isText)return;const p=Math.max(r,f),m=Math.min(s,f+h.nodeSize);a.push({node:h,from:p,to:m})});const c=s-r,u=a.filter(h=>i?i.name===h.node.type.name:!0).filter(h=>bf(h.node.attrs,n,{strict:!1}));return o?!!u.length:u.reduce((h,f)=>h+f.to-f.from,0)>=c}const gZ=(e,t={})=>({state:n,dispatch:r})=>{const s=xn(e,n.schema);return Tu(n,s,t)?aQ(n,r):!1},yZ=()=>({state:e,dispatch:t})=>zD(e,t),wZ=e=>({state:t,dispatch:n})=>{const r=xn(e,t.schema);return bQ(r)(t,n)},bZ=()=>({state:e,dispatch:t})=>$D(e,t);function _p(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function ZC(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,s)=>(n.includes(s)||(r[s]=e[s]),r),{})}const xZ=(e,t)=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const a=_p(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(o=xn(e,r.schema)),a==="mark"&&(i=Ei(e,r.schema)),s&&n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{o&&o===u.type&&n.setNodeMarkup(d,void 0,ZC(u.attrs,t)),i&&u.marks.length&&u.marks.forEach(h=>{i===h.type&&n.addMark(d,d+u.nodeSize,i.create(ZC(h.attrs,t)))})})}),!0):!1},kZ=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),vZ=()=>({tr:e,dispatch:t})=>{if(t){const n=new Pr(e.doc);e.setSelection(n)}return!0},SZ=()=>({state:e,dispatch:t})=>ID(e,t),jZ=()=>({state:e,dispatch:t})=>LD(e,t),CZ=()=>({state:e,dispatch:t})=>dQ(e,t),NZ=()=>({state:e,dispatch:t})=>pQ(e,t),EZ=()=>({state:e,dispatch:t})=>fQ(e,t);function nb(e,t,n={},r={}){return Au(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const AZ=(e,t=!1,n={},r={})=>({editor:s,tr:o,dispatch:i,commands:a})=>{var c,u;const{doc:d}=o;if(n.preserveWhitespace!=="full"){const h=nb(e,s.schema,n,{errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck});return i&&o.replaceWith(0,d.content.size,h).setMeta("preventUpdate",!t),!0}return i&&o.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:d.content.size},e,{parseOptions:n,errorOnInvalidContent:(u=r.errorOnInvalidContent)!==null&&u!==void 0?u:s.options.enableContentCheck})};function JD(e,t){const n=Ei(t,e.schema),{from:r,to:s,empty:o}=e.selection,i=[];o?(e.storedMarks&&i.push(...e.storedMarks),i.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,s,c=>{i.push(...c.marks)});const a=i.find(c=>c.type.name===n.name);return a?{...a.attrs}:{}}function TZ(e,t){const n=new qx(e);return t.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function MZ(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function RZ(e,t,n){const r=[];return e.nodesBetween(t.from,t.to,(s,o)=>{n(s)&&r.push({node:s,pos:o})}),r}function XD(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function fk(e){return t=>XD(t.$from,e)}function IZ(e,t){const n={from:0,to:e.content.size};return HD(e,n,t)}function DZ(e,t){const n=xn(t,e.schema),{from:r,to:s}=e.selection,o=[];e.doc.nodesBetween(r,s,a=>{o.push(a)});const i=o.reverse().find(a=>a.type.name===n.name);return i?{...i.attrs}:{}}function QD(e,t){const n=_p(typeof t=="string"?t:t.name,e.schema);return n==="node"?DZ(e,t):n==="mark"?JD(e,t):{}}function OZ(e,t=JSON.stringify){const n={};return e.filter(r=>{const s=t(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function LZ(e){const t=OZ(e);return t.length===1?t:t.filter((n,r)=>!t.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function $Z(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((s,o)=>{const i=[];if(s.ranges.length)s.forEach((a,c)=>{i.push({from:a,to:c})});else{const{from:a,to:c}=n[o];if(a===void 0||c===void 0)return;i.push({from:a,to:c})}i.forEach(({from:a,to:c})=>{const u=t.slice(o).map(a,-1),d=t.slice(o).map(c),h=t.invert().map(u,-1),f=t.invert().map(d);r.push({oldRange:{from:h,to:f},newRange:{from:u,to:d}})})}),LZ(r)}function pk(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(s=>{const o=n.resolve(e),i=hk(o,s.type);i&&r.push({mark:s,...i})}):n.nodesBetween(e,t,(s,o)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}function gh(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=e.find(o=>o.type===t&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}function rb(e,t,n={}){const{empty:r,ranges:s}=e.selection,o=t?Ei(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(h=>o?o.name===h.type.name:!0).find(h=>bf(h.attrs,n,{strict:!1}));let i=0;const a=[];if(s.forEach(({$from:h,$to:f})=>{const p=h.pos,m=f.pos;e.doc.nodesBetween(p,m,(w,b)=>{if(!w.isText&&!w.marks.length)return;const x=Math.max(p,b),v=Math.min(m,b+w.nodeSize),S=v-x;i+=S,a.push(...w.marks.map(C=>({mark:C,from:x,to:v})))})}),i===0)return!1;const c=a.filter(h=>o?o.name===h.mark.type.name:!0).filter(h=>bf(h.mark.attrs,n,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),u=a.filter(h=>o?h.mark.type!==o&&h.mark.type.excludes(o):!0).reduce((h,f)=>h+f.to-f.from,0);return(c>0?c+u:c)>=i}function PZ(e,t,n={}){if(!t)return Tu(e,null,n)||rb(e,null,n);const r=_p(t,e.schema);return r==="node"?Tu(e,t,n):r==="mark"?rb(e,t,n):!1}function eN(e,t){const{nodeExtensions:n}=Fp(t),r=n.find(i=>i.name===e);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=pt(Ue(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function Wp(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(e.type.name==="hardBreak")return!0;if(e.isText)return/^\s*$/m.test((r=e.text)!==null&&r!==void 0?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let s=!0;return e.content.forEach(o=>{s!==!1&&(Wp(o,{ignoreWhitespace:n,checkChildren:t})||(s=!1))}),s}return!1}function zZ(e){return e instanceof Qe}function FZ(e,t,n){var r;const{selection:s}=t;let o=null;if(VD(s)&&(o=s.$cursor),o){const a=(r=e.storedMarks)!==null&&r!==void 0?r:o.marks();return!!n.isInSet(a)||!a.some(c=>c.type.excludes(n))}const{ranges:i}=s;return i.some(({$from:a,$to:c})=>{let u=a.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(a.pos,c.pos,(d,h,f)=>{if(u)return!1;if(d.isInline){const p=!f||f.type.allowsMarkType(n),m=!!n.isInSet(d.marks)||!d.marks.some(w=>w.type.excludes(n));u=p&&m}return!u}),u})}const BZ=(e,t={})=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=n,{empty:i,ranges:a}=o,c=Ei(e,r.schema);if(s)if(i){const u=JD(r,c);n.addStoredMark(c.create({...u,...t}))}else a.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;r.doc.nodesBetween(d,h,(f,p)=>{const m=Math.max(p,d),w=Math.min(p+f.nodeSize,h);f.marks.find(x=>x.type===c)?f.marks.forEach(x=>{c===x.type&&n.addMark(m,w,c.create({...x.attrs,...t}))}):n.addMark(m,w,c.create(t))})});return FZ(r,n,c)},_Z=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),WZ=(e,t={})=>({state:n,dispatch:r,chain:s})=>{const o=xn(e,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:a})=>qC(o,{...i,...t})(n)?!0:a.clearNodes()).command(({state:a})=>qC(o,{...i,...t})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},HZ=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,s=aa(e,0,r.content.size),o=Qe.create(r,s);t.setSelection(o)}return!0},UZ=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,{from:s,to:o}=typeof e=="number"?{from:e,to:e}:e,i=Xe.atStart(r).from,a=Xe.atEnd(r).to,c=aa(s,i,a),u=aa(o,i,a),d=Xe.create(r,c,u);t.setSelection(d)}return!0},KZ=e=>({state:t,dispatch:n})=>{const r=xn(e,t.schema);return vQ(r)(t,n)};function tN(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(s=>t==null?void 0:t.includes(s.type.name));e.tr.ensureMarks(r)}}const VZ=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:s})=>{const{selection:o,doc:i}=t,{$from:a,$to:c}=o,u=s.extensionManager.attributes,d=gh(u,a.node().type.name,a.node().attrs);if(o instanceof Qe&&o.node.isBlock)return!a.parentOffset||!No(i,a.pos)?!1:(r&&(e&&tN(n,s.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,f=a.depth===0?void 0:MZ(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=h&&f?[{type:f,attrs:d}]:void 0,m=No(t.doc,t.mapping.map(a.pos),1,p);if(!p&&!m&&No(t.doc,t.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:d}]:void 0),r){if(m&&(o instanceof Xe&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,p),f&&!h&&!a.parentOffset&&a.parent.type!==f)){const w=t.mapping.map(a.before()),b=t.doc.resolve(w);a.node(-1).canReplaceWith(b.index(),b.index()+1,f)&&t.setNodeMarkup(t.mapping.map(a.before()),f)}e&&tN(n,s.extensionManager.splittableMarks),t.scrollIntoView()}return m},qZ=(e,t={})=>({tr:n,state:r,dispatch:s,editor:o})=>{var i;const a=xn(e,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const h=c.node(-1);if(h.type!==a)return!1;const f=o.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==a||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let x=je.empty;const v=c.index(-1)?1:c.index(-2)?2:3;for(let M=c.depth-v;M>=c.depth-3;M-=1)x=je.from(c.node(M).copy(x));const S=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,C={...gh(f,c.node().type.name,c.node().attrs),...t},O=((i=a.contentMatch.defaultType)===null||i===void 0?void 0:i.createAndFill(C))||void 0;x=x.append(je.from(a.createAndFill(null,O)||void 0));const N=c.before(c.depth-(v-1));n.replace(N,c.after(-S),new Pe(x,4-v,0));let P=-1;n.doc.nodesBetween(N,n.doc.content.size,(M,R)=>{if(P>-1)return!1;M.isTextblock&&M.content.size===0&&(P=R+1)}),P>-1&&n.setSelection(Xe.near(n.doc.resolve(P))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?h.contentMatchAt(0).defaultType:null,m={...gh(f,h.type.name,h.attrs),...t},w={...gh(f,c.node().type.name,c.node().attrs),...t};n.delete(c.pos,u.pos);const b=p?[{type:a,attrs:m},{type:p,attrs:w}]:[{type:a,attrs:m}];if(!No(n.doc,c.pos,2))return!1;if(s){const{selection:x,storedMarks:v}=r,{splittableMarks:S}=o.extensionManager,C=v||x.$to.parentOffset&&x.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!C||!s)return!0;const O=C.filter(N=>S.includes(N.type.name));n.ensureMarks(O)}return!0},_g=(e,t)=>{const n=fk(i=>i.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=e.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&Ci(e.doc,n.pos)&&e.join(n.pos),!0},Wg=(e,t)=>{const n=fk(i=>i.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=e.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&Ci(e.doc,r)&&e.join(r),!0},YZ=(e,t,n,r={})=>({editor:s,tr:o,state:i,dispatch:a,chain:c,commands:u,can:d})=>{const{extensions:h,splittableMarks:f}=s.extensionManager,p=xn(e,i.schema),m=xn(t,i.schema),{selection:w,storedMarks:b}=i,{$from:x,$to:v}=w,S=x.blockRange(v),C=b||w.$to.parentOffset&&w.$from.marks();if(!S)return!1;const O=fk(N=>eN(N.type.name,h))(w);if(S.depth>=1&&O&&S.depth-O.depth<=1){if(O.node.type===p)return u.liftListItem(m);if(eN(O.node.type.name,h)&&p.validContent(O.node.content)&&a)return c().command(()=>(o.setNodeMarkup(O.pos,p),!0)).command(()=>_g(o,p)).command(()=>Wg(o,p)).run()}return!n||!C||!a?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>_g(o,p)).command(()=>Wg(o,p)).run():c().command(()=>{const N=d().wrapInList(p,r),P=C.filter(M=>f.includes(M.type.name));return o.ensureMarks(P),N?!0:u.clearNodes()}).wrapInList(p,r).command(()=>_g(o,p)).command(()=>Wg(o,p)).run()},GZ=(e,t={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=n,i=Ei(e,r.schema);return rb(r,i,t)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,t)},JZ=(e,t,n={})=>({state:r,commands:s})=>{const o=xn(e,r.schema),i=xn(t,r.schema),a=Tu(r,o,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),a?s.setNode(i,c):s.setNode(o,{...c,...n})},XZ=(e,t={})=>({state:n,commands:r})=>{const s=xn(e,n.schema);return Tu(n,s,t)?r.lift(s):r.wrapIn(s,t)},QZ=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let o;if(s.spec.isInputRules&&(o=s.getState(e))){if(t){const i=e.tr,a=o.transform;for(let c=a.steps.length-1;c>=0;c-=1)i.step(a.steps[c].invert(a.docs[c]));if(o.text){const c=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,e.schema.text(o.text,c))}else i.delete(o.from,o.to)}return!0}}return!1},ZZ=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:s}=n;return r||t&&s.forEach(o=>{e.removeMark(o.$from.pos,o.$to.pos)}),!0},eee=(e,t={})=>({tr:n,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=t,{selection:a}=n,c=Ei(e,r.schema),{$from:u,empty:d,ranges:h}=a;if(!s)return!0;if(d&&i){let{from:f,to:p}=a;const m=(o=u.marks().find(b=>b.type===c))===null||o===void 0?void 0:o.attrs,w=hk(u,c,m);w&&(f=w.from,p=w.to),n.removeMark(f,p,c)}else h.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,c)});return n.removeStoredMark(c),!0},tee=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const a=_p(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(o=xn(e,r.schema)),a==="mark"&&(i=Ei(e,r.schema)),s&&n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let h,f,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(w,b)=>{o&&o===w.type&&(p=Math.max(b,u),m=Math.min(b+w.nodeSize,d),h=b,f=w)}):r.doc.nodesBetween(u,d,(w,b)=>{b<u&&o&&o===w.type&&(p=Math.max(b,u),m=Math.min(b+w.nodeSize,d),h=b,f=w),b>=u&&b<=d&&(o&&o===w.type&&n.setNodeMarkup(b,void 0,{...w.attrs,...t}),i&&w.marks.length&&w.marks.forEach(x=>{if(i===x.type){const v=Math.max(b,u),S=Math.min(b+w.nodeSize,d);n.addMark(v,S,i.create({...x.attrs,...t}))}}))}),f&&(h!==void 0&&n.setNodeMarkup(h,void 0,{...f.attrs,...t}),i&&f.marks.length&&f.marks.forEach(w=>{i===w.type&&n.addMark(p,m,i.create({...w.attrs,...t}))}))}),!0):!1},nee=(e,t={})=>({state:n,dispatch:r})=>{const s=xn(e,n.schema);return mQ(s,t)(n,r)},ree=(e,t={})=>({state:n,dispatch:r})=>{const s=xn(e,n.schema);return gQ(s,t)(n,r)};var see=Object.freeze({__proto__:null,blur:FQ,clearContent:BQ,clearNodes:_Q,command:WQ,createParagraphNear:HQ,cut:UQ,deleteCurrentNode:KQ,deleteNode:VQ,deleteRange:qQ,deleteSelection:YQ,enter:GQ,exitCode:JQ,extendMarkRange:XQ,first:QQ,focus:eZ,forEach:tZ,insertContent:nZ,insertContentAt:oZ,joinBackward:lZ,joinDown:aZ,joinForward:cZ,joinItemBackward:uZ,joinItemForward:dZ,joinTextblockBackward:hZ,joinTextblockForward:fZ,joinUp:iZ,keyboardShortcut:mZ,lift:gZ,liftEmptyBlock:yZ,liftListItem:wZ,newlineInCode:bZ,resetAttributes:xZ,scrollIntoView:kZ,selectAll:vZ,selectNodeBackward:SZ,selectNodeForward:jZ,selectParentNode:CZ,selectTextblockEnd:NZ,selectTextblockStart:EZ,setContent:AZ,setMark:BZ,setMeta:_Z,setNode:WZ,setNodeSelection:HZ,setTextSelection:UZ,sinkListItem:KZ,splitBlock:VZ,splitListItem:qZ,toggleList:YZ,toggleMark:GZ,toggleNode:JZ,toggleWrap:XZ,undoInputRule:QZ,unsetAllMarks:ZZ,unsetMark:eee,updateAttributes:tee,wrapIn:nee,wrapInList:ree});const oee=kn.create({name:"commands",addCommands(){return{...see}}}),iee=kn.create({name:"drop",addProseMirrorPlugins(){return[new an({key:new On("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),aee=kn.create({name:"editable",addProseMirrorPlugins(){return[new an({key:new On("editable"),props:{editable:()=>this.editor.options.editable}})]}}),lee=new On("focusEvents"),cee=kn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new an({key:lee,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),uee=kn.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:a})=>{const{selection:c,doc:u}=a,{empty:d,$anchor:h}=c,{pos:f,parent:p}=h,m=h.parent.isTextblock&&f>0?a.doc.resolve(f-1):h,w=m.parent.type.spec.isolating,b=h.pos-h.parentOffset,x=w&&m.parent.childCount===1?b===h.pos:ot.atStart(u).from===f;return!d||!p.type.isTextblock||p.textContent.length||!x||x&&h.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return xf()||GD()?o:s},addProseMirrorPlugins(){return[new an({key:new On("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(w=>w.getMeta("composition")))return;const r=e.some(w=>w.docChanged)&&!t.doc.eq(n.doc),s=e.some(w=>w.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:a}=t.selection,c=ot.atStart(t.doc).from,u=ot.atEnd(t.doc).to;if(o||!(i===c&&a===u)||!Wp(n.doc))return;const f=n.tr,p=Pp({state:n,transaction:f}),{commands:m}=new zp({editor:this.editor,state:p});if(m.clearNodes(),!!f.steps.length)return f}})]}}),dee=kn.create({name:"paste",addProseMirrorPlugins(){return[new an({key:new On("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),hee=kn.create({name:"tabindex",addProseMirrorPlugins(){return[new an({key:new On("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class ta{get name(){return this.node.type.name}constructor(t,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new ta(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new ta(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new ta(t,this.editor)}get children(){const t=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,i=this.pos+r+(o?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(i);if(!s&&a.depth<=this.depth)return;const c=new ta(a,this.editor,s,s?n:null);s&&(c.actualDepth=this.depth+1),t.push(new ta(a,this.editor,s,s?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===t)if(Object.keys(n).length>0){const o=s.node.attrs,i=Object.keys(n);for(let a=0;a<i.length;a+=1){const c=i[a];if(o[c]!==n[c])break}}else r=s;s=s.parent}return r}querySelector(t,n={}){return this.querySelectorAll(t,n,!0)[0]||null}querySelectorAll(t,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(n);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===t&&o.every(c=>n[c]===i.node.attrs[c])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(t,n,r))))}),s}setAttribute(t){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(n)}}const fee=`.ProseMirror {
|
|
727
|
+
position: relative;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
.ProseMirror {
|
|
731
|
+
word-wrap: break-word;
|
|
732
|
+
white-space: pre-wrap;
|
|
733
|
+
white-space: break-spaces;
|
|
734
|
+
-webkit-font-variant-ligatures: none;
|
|
735
|
+
font-variant-ligatures: none;
|
|
736
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.ProseMirror [contenteditable="false"] {
|
|
740
|
+
white-space: normal;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
744
|
+
white-space: pre-wrap;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
.ProseMirror pre {
|
|
748
|
+
white-space: pre-wrap;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
img.ProseMirror-separator {
|
|
752
|
+
display: inline !important;
|
|
753
|
+
border: none !important;
|
|
754
|
+
margin: 0 !important;
|
|
755
|
+
width: 0 !important;
|
|
756
|
+
height: 0 !important;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
.ProseMirror-gapcursor {
|
|
760
|
+
display: none;
|
|
761
|
+
pointer-events: none;
|
|
762
|
+
position: absolute;
|
|
763
|
+
margin: 0;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
.ProseMirror-gapcursor:after {
|
|
767
|
+
content: "";
|
|
768
|
+
display: block;
|
|
769
|
+
position: absolute;
|
|
770
|
+
top: -2px;
|
|
771
|
+
width: 20px;
|
|
772
|
+
border-top: 1px solid black;
|
|
773
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
@keyframes ProseMirror-cursor-blink {
|
|
777
|
+
to {
|
|
778
|
+
visibility: hidden;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.ProseMirror-hideselection *::selection {
|
|
783
|
+
background: transparent;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
787
|
+
background: transparent;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
.ProseMirror-hideselection * {
|
|
791
|
+
caret-color: transparent;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
795
|
+
display: block;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
799
|
+
opacity: 0
|
|
800
|
+
}`;function pee(e,t,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return t&&s.setAttribute("nonce",t),s.setAttribute("data-tiptap-style",""),s.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(s),s}class mee extends SQ{constructor(t={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:s})=>this.options.onDrop(n,r,s)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=pee(fee,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,n=!0){this.setOptions({editable:t}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,n){const r=WD(n)?n(t,[...this.state.plugins]):[...this.state.plugins,t],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(t){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(t).forEach(o=>{const i=typeof o=="string"?`${o}$`:o.key;r=r.filter(a=>!a.key.startsWith(i))}),n.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var t,n;const s=[...this.options.enableCoreExtensions?[aee,zQ.configure({blockSeparator:(n=(t=this.options.coreExtensionOptions)===null||t===void 0?void 0:t.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),oee,cee,uee,hee,iee,dee].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new kl(s,this)}createCommandManager(){this.commandManager=new zp({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var t;let n;try{n=nb(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(i){if(!(i instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(i.message))throw i;this.emit("contentError",{editor:this,error:i,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),n=nb(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=qD(n,this.options.autofocus);this.view=new AD(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:xl.create({doc:n,selection:r||void 0})});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(i=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(i)});return}const n=this.state.apply(t),r=!this.state.selection.eq(n.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:n}),this.view.updateState(n),this.emit("transaction",{editor:this,transaction:t}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=t.getMeta("focus"),o=t.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:t}),o&&this.emit("blur",{editor:this,event:o.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return QD(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,s=typeof t=="string"?n:t;return PZ(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return uk(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:n=`
|
|
801
|
+
|
|
802
|
+
`,textSerializers:r={}}=t||{};return IZ(this.state.doc,{blockSeparator:n,textSerializers:{...UD(this.schema),...r}})}get isEmpty(){return Wp(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const t=this.view.dom;t&&t.editor&&delete t.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!(!((t=this.view)===null||t===void 0)&&t.docView)}$node(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(t,n))||null}$nodes(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(t,n))||null}$pos(t){const n=this.state.doc.resolve(t);return new ta(n,this)}get $doc(){return this.$pos(0)}}function Hl(e){return new Yu({find:e.find,handler:({state:t,range:n,match:r})=>{const s=pt(e.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=t,i=r[r.length-1],a=r[0];if(i){const c=a.search(/\S/),u=n.from+a.indexOf(i),d=u+i.length;if(pk(n.from,n.to,t.doc).filter(p=>p.mark.type.excluded.find(w=>w===e.type&&w!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&o.delete(d,n.to),u>n.from&&o.delete(n.from+c,u);const f=n.from+c+i.length;o.addMark(n.from+c,f,e.type.create(s||{})),o.removeStoredMark(e.type)}}})}function gee(e){return new Yu({find:e.find,handler:({state:t,range:n,match:r})=>{const s=pt(e.getAttributes,void 0,r)||{},{tr:o}=t,i=n.from;let a=n.to;const c=e.type.create(s);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=i+u;d>a?d=a:a=d+r[1].length;const h=r[0][r[0].length-1];o.insertText(h,i+r[0].length-1),o.replaceWith(d,a,c)}else if(r[0]){const u=e.type.isInline?i:i-1;o.insert(u,e.type.create(s)).delete(o.mapping.map(i),o.mapping.map(a))}o.scrollIntoView()}})}function sb(e){return new Yu({find:e.find,handler:({state:t,range:n,match:r})=>{const s=t.doc.resolve(n.from),o=pt(e.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)}})}function nN(e){return new Yu({find:e.find,handler:({state:t,range:n,match:r})=>{let s=e.replace,o=n.from;const i=n.to;if(r[1]){const a=r[0].lastIndexOf(r[1]);s+=r[0].slice(a+r[1].length),o+=a;const c=o-i;c>0&&(s=r[0].slice(a-c,a)+s,o=i)}t.tr.insertText(s,o,i)}})}function Ul(e){return new Yu({find:e.find,handler:({state:t,range:n,match:r,chain:s})=>{const o=pt(e.getAttributes,void 0,r)||{},i=t.tr.delete(n.from,n.to),c=i.doc.resolve(n.from).blockRange(),u=c&&Vx(c,e.type,o);if(!u)return null;if(i.wrap(c,u),e.keepMarks&&e.editor){const{selection:h,storedMarks:f}=t,{splittableMarks:p}=e.editor.extensionManager,m=f||h.$to.parentOffset&&h.$from.marks();if(m){const w=m.filter(b=>p.includes(b.type.name));i.ensureMarks(w)}}if(e.keepAttributes){const h=e.type.name==="bulletList"||e.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(h,o).run()}const d=i.doc.resolve(n.from-1).nodeBefore;d&&d.type===e.type&&Ci(i.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,d))&&i.join(n.from-1)}})}let vn=class ob{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=pt(Ue(this,"addOptions",{name:this.name}))),this.storage=pt(Ue(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ob(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>Bp(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new ob(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=pt(Ue(n,"addOptions",{name:n.name})),n.storage=pt(Ue(n,"addStorage",{name:n.name,options:n.options})),n}};function Na(e){return new IQ({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:s})=>{const o=pt(e.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=t,a=r[r.length-1],c=r[0];let u=n.to;if(a){const d=c.search(/\S/),h=n.from+c.indexOf(a),f=h+a.length;if(pk(n.from,n.to,t.doc).filter(m=>m.mark.type.excluded.find(b=>b===e.type&&b!==m.mark.type)).filter(m=>m.to>h).length)return null;f<n.to&&i.delete(f,n.to),h>n.from&&i.delete(n.from+d,h),u=n.from+d+a.length,i.addMark(n.from+d,u,e.type.create(o||{})),i.removeStoredMark(e.type)}}})}function yee(e,t){const{selection:n}=e,{$from:r}=n;if(n instanceof Qe){const o=r.index();return r.parent.canReplaceWith(o,o+1,t)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(t))return!0;s-=1}return!1}function wee(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ZD={exports:{}},Hg={};/**
|
|
803
|
+
* @license React
|
|
804
|
+
* use-sync-external-store-shim.production.min.js
|
|
805
|
+
*
|
|
806
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
807
|
+
*
|
|
808
|
+
* This source code is licensed under the MIT license found in the
|
|
809
|
+
* LICENSE file in the root directory of this source tree.
|
|
810
|
+
*/var rN;function bee(){if(rN)return Hg;rN=1;var e=Bn;function t(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function a(h,f){var p=f(),m=r({inst:{value:p,getSnapshot:f}}),w=m[0].inst,b=m[1];return o(function(){w.value=p,w.getSnapshot=f,c(w)&&b({inst:w})},[h,p,f]),s(function(){return c(w)&&b({inst:w}),h(function(){c(w)&&b({inst:w})})},[h]),i(p),p}function c(h){var f=h.getSnapshot;h=h.value;try{var p=f();return!n(h,p)}catch{return!0}}function u(h,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:a;return Hg.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Hg}ZD.exports=bee();var mk=ZD.exports;const xee=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},kee=({contentComponent:e})=>{const t=mk.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return Bn.createElement(Bn.Fragment,null,Object.values(t))};function vee(){const e=new Set;let t={};return{subscribe(n){return e.add(n),()=>{e.delete(n)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:I$.createPortal(r.reactElement,r.element,n)},e.forEach(s=>s())},removeRenderer(n){const r={...t};delete r[n],t=r,e.forEach(s=>s())}}}class See extends Bn.Component{constructor(t){var n;super(t),this.editorContentRef=Bn.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((n=t.editor)===null||n===void 0)&&n.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const n=this.editorContentRef.current;n.append(...t.options.element.childNodes),t.setOptions({element:n}),t.contentComponent=vee(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const t=this.props.editor;if(!t||(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!t.options.element.firstChild))return;const n=document.createElement("div");n.append(...t.options.element.childNodes),t.setOptions({element:n})}render(){const{editor:t,innerRef:n,...r}=this.props;return Bn.createElement(Bn.Fragment,null,Bn.createElement("div",{ref:xee(n,this.editorContentRef),...r}),(t==null?void 0:t.contentComponent)&&Bn.createElement(kee,{contentComponent:t.contentComponent}))}}const jee=g.forwardRef((e,t)=>{const n=Bn.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return Bn.createElement(See,{key:n,innerRef:t,...e})}),Cee=Bn.memo(jee);var Nee=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,s,o;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!e(t[s],n[s]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(s of t.entries())if(!n.has(s[0]))return!1;for(s of t.entries())if(!e(s[1],n.get(s[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(s of t.entries())if(!n.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(r=t.length,r!=n.length)return!1;for(s=r;s--!==0;)if(t[s]!==n[s])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(o=Object.keys(t),r=o.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,o[s]))return!1;for(s=r;s--!==0;){var i=o[s];if(!(i==="_owner"&&t.$$typeof)&&!e(t[i],n[i]))return!1}return!0}return t!==t&&n!==n},Eee=wee(Nee),eO={exports:{}},Ug={};/**
|
|
811
|
+
* @license React
|
|
812
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
813
|
+
*
|
|
814
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
815
|
+
*
|
|
816
|
+
* This source code is licensed under the MIT license found in the
|
|
817
|
+
* LICENSE file in the root directory of this source tree.
|
|
818
|
+
*/var sN;function Aee(){if(sN)return Ug;sN=1;var e=Bn,t=mk;function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,a=e.useMemo,c=e.useDebugValue;return Ug.useSyncExternalStoreWithSelector=function(u,d,h,f,p){var m=o(null);if(m.current===null){var w={hasValue:!1,value:null};m.current=w}else w=m.current;m=a(function(){function x(N){if(!v){if(v=!0,S=N,N=f(N),p!==void 0&&w.hasValue){var P=w.value;if(p(P,N))return C=P}return C=N}if(P=C,r(S,N))return P;var M=f(N);return p!==void 0&&p(P,M)?P:(S=N,C=M)}var v=!1,S,C,O=h===void 0?null:h;return[function(){return x(d())},O===null?void 0:function(){return x(O())}]},[d,h,f,p]);var b=s(u,m[0],m[1]);return i(function(){w.hasValue=!0,w.value=b},[b]),c(b),b},Ug}eO.exports=Aee();var Tee=eO.exports;const Mee=typeof window<"u"?g.useLayoutEffect:g.useEffect;class Ree{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function Iee(e){var t;const[n]=g.useState(()=>new Ree(e.editor)),r=Tee.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,(t=e.equalityFn)!==null&&t!==void 0?t:Eee);return Mee(()=>n.watch(e.editor),[e.editor,n]),g.useDebugValue(r),r}const Dee=!1,ib=typeof window>"u",Oee=ib||!!(typeof window<"u"&&window.next);class gk{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?ib||Oee?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const t={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)===null||o===void 0?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)===null||o===void 0?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)===null||o===void 0?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)===null||o===void 0?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)===null||o===void 0?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)===null||o===void 0?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)===null||o===void 0?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)===null||o===void 0?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)===null||o===void 0?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)===null||o===void 0?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)===null||o===void 0?void 0:o.call(s,...r)}};return new mee(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,n){return Object.keys(t).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&t.extensions&&n.extensions?t.extensions.length!==n.extensions.length?!1:t.extensions.every((s,o)=>{var i;return s===((i=n.extensions)===null||i===void 0?void 0:i[o])}):t[r]===n[r])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?gk.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=t;return}if(this.previousDeps.length===t.length&&this.previousDeps.every((r,s)=>r===t[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===t){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===t&&this.setEditor(null))},1)}}function Lee(e={},t=[]){const n=g.useRef(e);n.current=e;const[r]=g.useState(()=>new gk(n)),s=mk.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return g.useDebugValue(s),g.useEffect(r.onRender(t)),Iee({editor:s,selector:({transactionNumber:o})=>e.shouldRerenderOnTransaction===!1?null:e.immediatelyRender&&o===0?0:o+1}),s}const $ee=g.createContext({editor:null});$ee.Consumer;const Pee=g.createContext({onDragStart:void 0}),zee=()=>g.useContext(Pee);Bn.forwardRef((e,t)=>{const{onDragStart:n}=zee(),r=e.as||"div";return Bn.createElement(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});const Fee=/^\s*>\s$/,Bee=vn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",Bt(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ul({find:Fee,type:this.type})]}}),_ee=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Wee=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Hee=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Uee=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Kee=Da.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",Bt(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Hl({find:_ee,type:this.type}),Hl({find:Hee,type:this.type})]},addPasteRules(){return[Na({find:Wee,type:this.type}),Na({find:Uee,type:this.type})]}}),Vee="listItem",oN="textStyle",iN=/^\s*([-+*])\s$/,qee=vn.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",Bt(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Vee,this.editor.getAttributes(oN)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Ul({find:iN,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Ul({find:iN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(oN),editor:this.editor})),[e]}}),Yee=/(^|[^`])`([^`]+)`(?!`)/,Gee=/(^|[^`])`([^`]+)`(?!`)/g,Jee=Da.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",Bt(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Hl({find:Yee,type:this.type})]},addPasteRules(){return[Na({find:Gee,type:this.type})]}}),Xee=/^```([a-z]+)?[\s\n]$/,Qee=/^~~~([a-z]+)?[\s\n]$/,Zee=vn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,o=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",Bt(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
|
|
819
|
+
|
|
820
|
+
`);return!o||!i?!1:e.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:o}=n;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const a=s.after();return a===void 0?!1:r.nodeAt(a)?e.commands.command(({tr:u})=>(u.setSelection(ot.near(r.resolve(a))),!0)):e.commands.exitCode()}}},addInputRules(){return[sb({find:Xee,type:this.type,getAttributes:e=>({language:e[1]})}),sb({find:Qee,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new an({key:new On("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s==null?void 0:s.mode;if(!n||!o)return!1;const{tr:i,schema:a}=e.state,c=a.text(n.replace(/\r\n?/g,`
|
|
821
|
+
`));return i.replaceSelectionWith(this.type.create({language:o},c)),i.selection.$from.parent.type!==this.type&&i.setSelection(Xe.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),e.dispatch(i),!0}}})]}}),ete=vn.create({name:"doc",topNode:!0,content:"block+"});function tte(e={}){return new an({view(t){return new nte(t,e)}})}class nte{constructor(t,n){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return t.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){if(this.cursorPos!=null&&n.doc!=t.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,a=o.height/s.offsetHeight;if(n){let h=t.nodeBefore,f=t.nodeAfter;if(h||f){let p=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(p){let m=p.getBoundingClientRect(),w=h?m.bottom:m.top;h&&f&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*a;r={left:m.left,right:m.right,top:w-b,bottom:w+b}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:h.left-f,right:h.left+f,top:h.top,bottom:h.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let h=c.getBoundingClientRect(),f=h.width/c.offsetWidth,p=h.height/c.offsetHeight;u=h.left-c.scrollLeft*f,d=h.top-c.scrollTop*p}this.element.style.left=(r.left-u)/i+"px",this.element.style.top=(r.top-d)/a+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}computeTarget(t){let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,n,t):s;if(!n||o)return null;let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=zI(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}return i}dragover(t){if(!this.editorView.editable)return;this.lastDragEvent=t;let n=this.computeTarget(t);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const rte=kn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[tte(this.options)]}});class Gt extends ot{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return Gt.valid(r)?new Gt(r):ot.near(r)}content(){return Pe.empty}eq(t){return t instanceof Gt&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Gt(t.resolve(n.pos))}getBookmark(){return new yk(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!ste(t)||!ote(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(t.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&Gt.valid(t))return t;let s=t.pos,o=null;for(let i=t.depth;;i--){let a=t.node(i);if(n>0?t.indexAfter(i)<a.childCount:t.index(i)>0){o=a.child(n>0?t.indexAfter(i):t.index(i)-1);break}else if(i==0)return null;s+=n;let c=t.doc.resolve(s);if(Gt.valid(c))return c}for(;;){let i=n>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!Qe.isSelectable(o)){t=t.doc.resolve(s+o.nodeSize*n),r=!1;continue e}break}o=i,s+=n;let a=t.doc.resolve(s);if(Gt.valid(a))return a}return null}}}Gt.prototype.visible=!1;Gt.findFrom=Gt.findGapCursorFrom;ot.jsonID("gapcursor",Gt);class yk{constructor(t){this.pos=t}map(t){return new yk(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return Gt.valid(n)?new Gt(n):ot.near(n)}}function tO(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function ste(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||tO(s.type))return!0;if(s.inlineContent)return!1}}return!0}function ote(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||tO(s.type))return!0;if(s.inlineContent)return!1}}return!0}function ite(){return new an({props:{decorations:ute,createSelectionBetween(e,t,n){return t.pos==n.pos&&Gt.valid(n)?new Gt(n):null},handleClick:lte,handleKeyDown:ate,handleDOMEvents:{beforeinput:cte}}})}const ate=sk({ArrowLeft:qd("horiz",-1),ArrowRight:qd("horiz",1),ArrowUp:qd("vert",-1),ArrowDown:qd("vert",1)});function qd(e,t){const n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,s,o){let i=r.selection,a=t>0?i.$to:i.$from,c=i.empty;if(i instanceof Xe){if(!o.endOfTextblock(n)||a.depth==0)return!1;c=!1,a=r.doc.resolve(t>0?a.after():a.before())}let u=Gt.findGapCursorFrom(a,t,c);return u?(s&&s(r.tr.setSelection(new Gt(u))),!0):!1}}function lte(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Gt.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&Qe.isSelectable(e.state.doc.nodeAt(s.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Gt(r))),!0)}function cte(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof Gt))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=je.empty;for(let i=r.length-1;i>=0;i--)s=je.from(r[i].createAndFill(null,s));let o=e.state.tr.replace(n.pos,n.pos,new Pe(s,0,0));return o.setSelection(Xe.near(o.doc.resolve(n.pos+1))),e.dispatch(o),!1}function ute(e){if(!(e.selection instanceof Gt))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Vt.create(e.doc,[Wn.widget(e.selection.head,t,{key:"gapcursor"})])}const dte=kn.create({name:"gapCursor",addProseMirrorPlugins(){return[ite()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=pt(Ue(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),hte=vn.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",Bt(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
822
|
+
`},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:s,storedMarks:o}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:a}=r.extensionManager,c=o||s.$to.parentOffset&&s.$from.marks();return t().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&i){const h=c.filter(f=>a.includes(f.type.name));u.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),fte=vn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,Bt(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>sb({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var kf=200,wn=function(){};wn.prototype.append=function(t){return t.length?(t=wn.from(t),!this.length&&t||t.length<kf&&this.leafAppend(t)||this.length<kf&&t.leafPrepend(this)||this.appendInner(t)):this};wn.prototype.prepend=function(t){return t.length?wn.from(t).append(this):this};wn.prototype.appendInner=function(t){return new pte(this,t)};wn.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?wn.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};wn.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};wn.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};wn.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(t(o,i))},n,r),s};wn.from=function(t){return t instanceof wn?t:t&&t.length?new nO(t):wn.empty};var nO=function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new t(this.values.slice(s,o))},t.prototype.getInner=function(s){return this.values[s]},t.prototype.forEachInner=function(s,o,i,a){for(var c=o;c<i;c++)if(s(this.values[c],a+c)===!1)return!1},t.prototype.forEachInvertedInner=function(s,o,i,a){for(var c=o-1;c>=i;c--)if(s(this.values[c],a+c)===!1)return!1},t.prototype.leafAppend=function(s){if(this.length+s.length<=kf)return new t(this.values.concat(s.flatten()))},t.prototype.leafPrepend=function(s){if(this.length+s.length<=kf)return new t(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(wn);wn.empty=new nO([]);var pte=function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,s,o,i){var a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(o,a),i)===!1||o>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,o)-a,i+a)===!1)return!1},t.prototype.forEachInvertedInner=function(r,s,o,i){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(o,a)-a,i+a)===!1||o<a&&this.left.forEachInvertedInner(r,Math.min(s,a),o,i)===!1)return!1},t.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},t.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new t(this.left,s)},t.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new t(s,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t}(wn);const mte=500;class gs{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;n&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=t.tr,a,c,u=[],d=[];return this.items.forEach((h,f)=>{if(!h.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,d.push(h);return}if(s){d.push(new Ls(h.map));let p=h.step.map(s.slice(o)),m;p&&i.maybeStep(p).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],u.push(new Ls(m,void 0,void 0,u.length+d.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(h.step);if(h.selection)return a=s?h.selection.map(s.slice(o)):h.selection,c=new gs(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:i,selection:a}}addTransform(t,n,r,s){let o=[],i=this.eventCount,a=this.items,c=!s&&a.length?a.get(a.length-1):null;for(let d=0;d<t.steps.length;d++){let h=t.steps[d].invert(t.docs[d]),f=new Ls(t.mapping.maps[d],h,n),p;(p=c&&c.merge(f))&&(f=p,d?o.pop():a=a.slice(0,a.length-1)),o.push(f),n&&(i++,n=void 0),s||(c=f)}let u=i-r.depth;return u>yte&&(a=gte(a,u),i-=u),new gs(a.append(o),i)}remapping(t,n){let r=new Su;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=t?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},t,n),r}addMaps(t){return this.eventCount==0?this:new gs(this.items.append(t.map(n=>new Ls(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),o=t.mapping,i=t.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},s);let c=n;this.items.forEach(f=>{let p=o.getMirror(--c);if(p==null)return;i=Math.min(i,p);let m=o.maps[p];if(f.step){let w=t.steps[p].invert(t.docs[p]),b=f.selection&&f.selection.map(o.slice(c+1,p));b&&a++,r.push(new Ls(m,w,b))}else r.push(new Ls(m))},s);let u=[];for(let f=n;f<i;f++)u.push(new Ls(o.maps[f]));let d=this.items.slice(0,s).append(u).append(r),h=new gs(d,a);return h.emptyItemCount()>mte&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,s=[],o=0;return this.items.forEach((i,a)=>{if(a>=t)s.push(i),i.selection&&o++;else if(i.step){let c=i.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=i.selection&&i.selection.map(n.slice(r));d&&o++;let h=new Ls(u.invert(),c,d),f,p=s.length-1;(f=s.length&&s[p].merge(h))?s[p]=f:s.push(h)}}else i.map&&r--},this.items.length,0),new gs(wn.from(s.reverse()),o)}}gs.empty=new gs(wn.empty,0);function gte(e,t){let n;return e.forEach((r,s)=>{if(r.selection&&t--==0)return n=s,!1}),e.slice(n)}class Ls{constructor(t,n,r,s){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=s}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new Ls(n.getMap().invert(),n,this.selection)}}}class ti{constructor(t,n,r,s,o){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const yte=20;function wte(e,t,n,r){let s=n.getMeta(wa),o;if(s)return s.historyState;n.getMeta(kte)&&(e=new ti(e.done,e.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(i&&i.getMeta(wa))return i.getMeta(wa).redo?new ti(e.done.addTransform(n,void 0,r,yh(t)),e.undone,aN(n.mapping.maps),e.prevTime,e.prevComposition):new ti(e.done,e.undone.addTransform(n,void 0,r,yh(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),c=e.prevTime==0||!i&&e.prevComposition!=a&&(e.prevTime<(n.time||0)-r.newGroupDelay||!bte(n,e.prevRanges)),u=i?Kg(e.prevRanges,n.mapping):aN(n.mapping.maps);return new ti(e.done.addTransform(n,c?t.selection.getBookmark():void 0,r,yh(t)),gs.empty,u,n.time,a??e.prevComposition)}else return(o=n.getMeta("rebased"))?new ti(e.done.rebased(n,o),e.undone.rebased(n,o),Kg(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new ti(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Kg(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function bte(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<t.length;o+=2)r<=t[o+1]&&s>=t[o]&&(n=!0)}),n}function aN(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,s,o,i)=>t.push(o,i));return t}function Kg(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),o=t.map(e[r+1],-1);s<=o&&n.push(s,o)}return n}function xte(e,t,n){let r=yh(t),s=wa.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),a=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),s,r),c=new ti(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(i).setMeta(wa,{redo:n,historyState:c})}let Vg=!1,lN=null;function yh(e){let t=e.plugins;if(lN!=t){Vg=!1,lN=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Vg=!0;break}}return Vg}const wa=new On("history"),kte=new On("closeHistory");function vte(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new an({key:wa,state:{init(){return new ti(gs.empty,gs.empty,null,0,-1)},apply(t,n,r){return wte(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,s=r=="historyUndo"?sO:r=="historyRedo"?oO:null;return!s||!t.editable?!1:(n.preventDefault(),s(t.state,t.dispatch))}}}})}function rO(e,t){return(n,r)=>{let s=wa.getState(n);if(!s||(e?s.undone:s.done).eventCount==0)return!1;if(r){let o=xte(s,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}const sO=rO(!1,!0),oO=rO(!0,!0),Ste=kn.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>sO(e,t),redo:()=>({state:e,dispatch:t})=>oO(e,t)}},addProseMirrorPlugins(){return[vte(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),jte=vn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",Bt(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!yee(t,t.schema.nodes[this.name]))return!1;const{selection:n}=t,{$from:r,$to:s}=n,o=e();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):zZ(n)?o.insertContentAt(s.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:i,dispatch:a})=>{var c;if(a){const{$to:u}=i.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?i.setSelection(Xe.create(i.doc,u.pos+1)):u.nodeAfter.isBlock?i.setSelection(Qe.create(i.doc,u.pos)):i.setSelection(Xe.create(i.doc,u.pos));else{const h=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();h&&(i.insert(d,h),i.setSelection(Xe.create(i.doc,d+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[gee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Cte=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Nte=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ete=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Ate=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Tte=Da.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",Bt(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Hl({find:Cte,type:this.type}),Hl({find:Ete,type:this.type})]},addPasteRules(){return[Na({find:Nte,type:this.type}),Na({find:Ate,type:this.type})]}}),Mte=vn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",Bt(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Rte="listItem",cN="textStyle",uN=/^(\d+)\.\s$/,Ite=vn.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",Bt(this.options.HTMLAttributes,n),0]:["ol",Bt(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Rte,this.editor.getAttributes(cN)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=Ul({find:uN,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Ul({find:uN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(cN)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),Dte=vn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",Bt(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Ote=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Lte=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,$te=Da.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",Bt(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Hl({find:Ote,type:this.type})]},addPasteRules(){return[Na({find:Lte,type:this.type})]}}),Pte=vn.create({name:"text",group:"inline"}),zte=kn.create({name:"starterKit",addExtensions(){const e=[];return this.options.bold!==!1&&e.push(Kee.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(Bee.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(qee.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Jee.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Zee.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(ete.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(rte.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(dte.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(hte.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(fte.configure(this.options.heading)),this.options.history!==!1&&e.push(Ste.configure(this.options.history)),this.options.horizontalRule!==!1&&e.push(jte.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Tte.configure(this.options.italic)),this.options.listItem!==!1&&e.push(Mte.configure(this.options.listItem)),this.options.orderedList!==!1&&e.push(Ite.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Dte.configure(this.options.paragraph)),this.options.strike!==!1&&e.push($te.configure(this.options.strike)),this.options.text!==!1&&e.push(Pte.configure(this.options.text)),e}}),Fte=kn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new an({key:new On("placeholder"),props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,s=[];if(!n)return null;const o=this.editor.isEmpty;return e.descendants((i,a)=>{const c=r>=a&&r<=a+i.nodeSize,u=!i.isLeaf&&Wp(i);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const h=Wn.node(a,a+i.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:a,hasAnchor:c}):this.options.placeholder});s.push(h)}return this.options.includeChildren}),Vt.create(e,s)}}})]}}),Bte=vn.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",Bt(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),_te=/^\s*(\[([( |x])?\])\s$/,Wte=vn.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{const t=e.getAttribute("data-checked");return t===""||t==="true"},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",Bt(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),c=document.createElement("div"),u=()=>{var d,h;a.ariaLabel=((h=(d=this.options.a11y)===null||d===void 0?void 0:d.checkboxLabel)===null||h===void 0?void 0:h.call(d,e,a.checked))||`Task item checkbox for ${e.textContent||"empty task item"}`};return u(),o.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",d=>d.preventDefault()),a.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:h}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const p=n();if(typeof p!="number")return!1;const m=f.doc.nodeAt(p);return f.setNodeMarkup(p,void 0,{...m==null?void 0:m.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,h)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,h])=>{s.setAttribute(d,h)}),s.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,o.append(a,i),s.append(o,c),Object.entries(t).forEach(([d,h])=>{s.setAttribute(d,h)}),{dom:s,contentDOM:c,update:d=>d.type!==this.type?!1:(s.dataset.checked=d.attrs.checked,a.checked=d.attrs.checked,u(),!0)}}},addInputRules(){return[Ul({find:_te,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),Hte="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Ute="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",ab="numeric",lb="ascii",cb="alpha",Jc="asciinumeric",Ic="alphanumeric",ub="domain",iO="emoji",Kte="scheme",Vte="slashscheme",qg="whitespace";function qte(e,t){return e in t||(t[e]=[]),t[e]}function la(e,t,n){t[ab]&&(t[Jc]=!0,t[Ic]=!0),t[lb]&&(t[Jc]=!0,t[cb]=!0),t[Jc]&&(t[Ic]=!0),t[cb]&&(t[Ic]=!0),t[Ic]&&(t[ub]=!0),t[iO]&&(t[ub]=!0);for(const r in t){const s=qte(r,n);s.indexOf(e)<0&&s.push(e)}}function Yte(e,t){const n={};for(const r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function br(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}br.groups={};br.prototype={accepts(){return!!this.t},go(e){const t=this,n=t.j[e];if(n)return n;for(let r=0;r<t.jr.length;r++){const s=t.jr[r][0],o=t.jr[r][1];if(o&&s.test(e))return o}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let s=0;s<e.length;s++)this.tt(e[s],t,n,r)},tr(e,t,n,r){r=r||br.groups;let s;return t&&t.j?s=t:(s=new br(t),n&&r&&la(t,n,r)),this.jr.push([e,s]),s},ts(e,t,n,r){let s=this;const o=e.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(e[i]);return s.tt(e[o-1],t,n,r)},tt(e,t,n,r){r=r||br.groups;const s=this;if(t&&t.j)return s.j[e]=t,t;const o=t;let i,a=s.go(e);if(a?(i=new br,Object.assign(i.j,a.j),i.jr.push.apply(i.jr,a.jr),i.jd=a.jd,i.t=a.t):i=new br,o){if(r)if(i.t&&typeof i.t=="string"){const c=Object.assign(Yte(i.t,r),n);la(o,c,r)}else n&&la(o,n,r);i.t=o}return s.j[e]=i,i}};const mt=(e,t,n,r,s)=>e.ta(t,n,r,s),Yt=(e,t,n,r,s)=>e.tr(t,n,r,s),dN=(e,t,n,r,s)=>e.ts(t,n,r,s),Me=(e,t,n,r,s)=>e.tt(t,n,r,s),po="WORD",db="UWORD",aO="ASCIINUMERICAL",lO="ALPHANUMERICAL",Mu="LOCALHOST",hb="TLD",fb="UTLD",wh="SCHEME",pl="SLASH_SCHEME",wk="NUM",pb="WS",bk="NL",Xc="OPENBRACE",Qc="CLOSEBRACE",vf="OPENBRACKET",Sf="CLOSEBRACKET",jf="OPENPAREN",Cf="CLOSEPAREN",Nf="OPENANGLEBRACKET",Ef="CLOSEANGLEBRACKET",Af="FULLWIDTHLEFTPAREN",Tf="FULLWIDTHRIGHTPAREN",Mf="LEFTCORNERBRACKET",Rf="RIGHTCORNERBRACKET",If="LEFTWHITECORNERBRACKET",Df="RIGHTWHITECORNERBRACKET",Of="FULLWIDTHLESSTHAN",Lf="FULLWIDTHGREATERTHAN",$f="AMPERSAND",Pf="APOSTROPHE",zf="ASTERISK",ni="AT",Ff="BACKSLASH",Bf="BACKTICK",_f="CARET",ca="COLON",xk="COMMA",Wf="DOLLAR",$s="DOT",Hf="EQUALS",kk="EXCLAMATION",Yr="HYPHEN",Zc="PERCENT",Uf="PIPE",Kf="PLUS",Vf="POUND",eu="QUERY",vk="QUOTE",cO="FULLWIDTHMIDDLEDOT",Sk="SEMI",Ps="SLASH",tu="TILDE",qf="UNDERSCORE",uO="EMOJI",Yf="SYM";var dO=Object.freeze({__proto__:null,ALPHANUMERICAL:lO,AMPERSAND:$f,APOSTROPHE:Pf,ASCIINUMERICAL:aO,ASTERISK:zf,AT:ni,BACKSLASH:Ff,BACKTICK:Bf,CARET:_f,CLOSEANGLEBRACKET:Ef,CLOSEBRACE:Qc,CLOSEBRACKET:Sf,CLOSEPAREN:Cf,COLON:ca,COMMA:xk,DOLLAR:Wf,DOT:$s,EMOJI:uO,EQUALS:Hf,EXCLAMATION:kk,FULLWIDTHGREATERTHAN:Lf,FULLWIDTHLEFTPAREN:Af,FULLWIDTHLESSTHAN:Of,FULLWIDTHMIDDLEDOT:cO,FULLWIDTHRIGHTPAREN:Tf,HYPHEN:Yr,LEFTCORNERBRACKET:Mf,LEFTWHITECORNERBRACKET:If,LOCALHOST:Mu,NL:bk,NUM:wk,OPENANGLEBRACKET:Nf,OPENBRACE:Xc,OPENBRACKET:vf,OPENPAREN:jf,PERCENT:Zc,PIPE:Uf,PLUS:Kf,POUND:Vf,QUERY:eu,QUOTE:vk,RIGHTCORNERBRACKET:Rf,RIGHTWHITECORNERBRACKET:Df,SCHEME:wh,SEMI:Sk,SLASH:Ps,SLASH_SCHEME:pl,SYM:Yf,TILDE:tu,TLD:hb,UNDERSCORE:qf,UTLD:fb,UWORD:db,WORD:po,WS:pb});const co=/[a-z]/,Sc=new RegExp("\\p{L}","u"),Yg=new RegExp("\\p{Emoji}","u"),uo=/\d/,Gg=/\s/,hN="\r",Jg=`
|
|
823
|
+
`,Gte="️",Jte="",Xg="";let Yd=null,Gd=null;function Xte(e=[]){const t={};br.groups=t;const n=new br;Yd==null&&(Yd=fN(Hte)),Gd==null&&(Gd=fN(Ute)),Me(n,"'",Pf),Me(n,"{",Xc),Me(n,"}",Qc),Me(n,"[",vf),Me(n,"]",Sf),Me(n,"(",jf),Me(n,")",Cf),Me(n,"<",Nf),Me(n,">",Ef),Me(n,"(",Af),Me(n,")",Tf),Me(n,"「",Mf),Me(n,"」",Rf),Me(n,"『",If),Me(n,"』",Df),Me(n,"<",Of),Me(n,">",Lf),Me(n,"&",$f),Me(n,"*",zf),Me(n,"@",ni),Me(n,"`",Bf),Me(n,"^",_f),Me(n,":",ca),Me(n,",",xk),Me(n,"$",Wf),Me(n,".",$s),Me(n,"=",Hf),Me(n,"!",kk),Me(n,"-",Yr),Me(n,"%",Zc),Me(n,"|",Uf),Me(n,"+",Kf),Me(n,"#",Vf),Me(n,"?",eu),Me(n,'"',vk),Me(n,"/",Ps),Me(n,";",Sk),Me(n,"~",tu),Me(n,"_",qf),Me(n,"\\",Ff),Me(n,"・",cO);const r=Yt(n,uo,wk,{[ab]:!0});Yt(r,uo,r);const s=Yt(r,co,aO,{[Jc]:!0}),o=Yt(r,Sc,lO,{[Ic]:!0}),i=Yt(n,co,po,{[lb]:!0});Yt(i,uo,s),Yt(i,co,i),Yt(s,uo,s),Yt(s,co,s);const a=Yt(n,Sc,db,{[cb]:!0});Yt(a,co),Yt(a,uo,o),Yt(a,Sc,a),Yt(o,uo,o),Yt(o,co),Yt(o,Sc,o);const c=Me(n,Jg,bk,{[qg]:!0}),u=Me(n,hN,pb,{[qg]:!0}),d=Yt(n,Gg,pb,{[qg]:!0});Me(n,Xg,d),Me(u,Jg,c),Me(u,Xg,d),Yt(u,Gg,d),Me(d,hN),Me(d,Jg),Yt(d,Gg,d),Me(d,Xg,d);const h=Yt(n,Yg,uO,{[iO]:!0});Me(h,"#"),Yt(h,Yg,h),Me(h,Gte,h);const f=Me(h,Jte);Me(f,"#"),Yt(f,Yg,h);const p=[[co,i],[uo,s]],m=[[co,null],[Sc,a],[uo,o]];for(let w=0;w<Yd.length;w++)Jo(n,Yd[w],hb,po,p);for(let w=0;w<Gd.length;w++)Jo(n,Gd[w],fb,db,m);la(hb,{tld:!0,ascii:!0},t),la(fb,{utld:!0,alpha:!0},t),Jo(n,"file",wh,po,p),Jo(n,"mailto",wh,po,p),Jo(n,"http",pl,po,p),Jo(n,"https",pl,po,p),Jo(n,"ftp",pl,po,p),Jo(n,"ftps",pl,po,p),la(wh,{scheme:!0,ascii:!0},t),la(pl,{slashscheme:!0,ascii:!0},t),e=e.sort((w,b)=>w[0]>b[0]?1:-1);for(let w=0;w<e.length;w++){const b=e[w][0],v=e[w][1]?{[Kte]:!0}:{[Vte]:!0};b.indexOf("-")>=0?v[ub]=!0:co.test(b)?uo.test(b)?v[Jc]=!0:v[lb]=!0:v[ab]=!0,dN(n,b,b,v)}return dN(n,"localhost",Mu,{ascii:!0}),n.jd=new br(Yf),{start:n,tokens:Object.assign({groups:t},dO)}}function hO(e,t){const n=Qte(t.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,s=[];let o=0,i=0;for(;i<r;){let a=e,c=null,u=0,d=null,h=-1,f=-1;for(;i<r&&(c=a.go(n[i]));)a=c,a.accepts()?(h=0,f=0,d=a):h>=0&&(h+=n[i].length,f++),u+=n[i].length,o+=n[i].length,i++;o-=h,i-=f,u-=h,s.push({t:d.t,v:t.slice(o-u,o),s:o-u,e:o})}return s}function Qte(e){const t=[],n=e.length;let r=0;for(;r<n;){let s=e.charCodeAt(r),o,i=s<55296||s>56319||r+1===n||(o=e.charCodeAt(r+1))<56320||o>57343?e[r]:e.slice(r,r+2);t.push(i),r+=i.length}return t}function Jo(e,t,n,r,s){let o;const i=t.length;for(let a=0;a<i-1;a++){const c=t[a];e.j[c]?o=e.j[c]:(o=new br(r),o.jr=s.slice(),e.j[c]=o),e=o}return o=new br(n),o.jr=s.slice(),e.j[t[i-1]]=o,o}function fN(e){const t=[],n=[];let r=0,s="0123456789";for(;r<e.length;){let o=0;for(;s.indexOf(e[r+o])>=0;)o++;if(o>0){t.push(n.join(""));for(let i=parseInt(e.substring(r,r+o),10);i>0;i--)n.pop();r+=o}else n.push(e[r]),r++}return t}const Ru={defaultProtocol:"http",events:null,format:pN,formatHref:pN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function jk(e,t=null){let n=Object.assign({},Ru);e&&(n=Object.assign(n,e instanceof jk?e.o:e));const r=n.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=s}jk.prototype={o:Ru,ignoreTags:[],defaultRender(e){return e},check(e){return this.get("validate",e.toString(),e)},get(e,t,n){const r=t!=null;let s=this.o[e];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Ru[e],typeof s=="function"&&r&&(s=s(t,n))):typeof s=="function"&&r&&(s=s(t,n.t,n)),s)},getObj(e,t,n){let r=this.o[e];return typeof r=="function"&&t!=null&&(r=r(t,n.t,n)),r},render(e){const t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}};function pN(e){return e}function fO(e,t){this.t="token",this.v=e,this.tk=t}fO.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){const t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=Ru.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){const t=this,n=this.toHref(e.get("defaultProtocol")),r=e.get("formatHref",n,this),s=e.get("tagName",n,t),o=this.toFormattedString(e),i={},a=e.get("className",n,t),c=e.get("target",n,t),u=e.get("rel",n,t),d=e.getObj("attributes",n,t),h=e.getObj("events",n,t);return i.href=r,a&&(i.class=a),c&&(i.target=c),u&&(i.rel=u),d&&Object.assign(i,d),{tagName:s,attributes:i,content:o,eventListeners:h}}};function Hp(e,t){class n extends fO{constructor(s,o){super(s,o),this.t=e}}for(const r in t)n.prototype[r]=t[r];return n.t=e,n}const Zte=Hp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),mN=Hp("text"),ene=Hp("nl"),Jd=Hp("url",{isLink:!0,toHref(e=Ru.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){const e=this.tk;return e.length>=2&&e[0].t!==Mu&&e[1].t===ca}}),qr=e=>new br(e);function tne({groups:e}){const t=e.domain.concat([$f,zf,ni,Ff,Bf,_f,Wf,Hf,Yr,wk,Zc,Uf,Kf,Vf,Ps,Yf,tu,qf]),n=[Pf,ca,xk,$s,kk,Zc,eu,vk,Sk,Nf,Ef,Xc,Qc,Sf,vf,jf,Cf,Af,Tf,Mf,Rf,If,Df,Of,Lf],r=[$f,Pf,zf,Ff,Bf,_f,Wf,Hf,Yr,Xc,Qc,Zc,Uf,Kf,Vf,eu,Ps,Yf,tu,qf],s=qr(),o=Me(s,tu);mt(o,r,o),mt(o,e.domain,o);const i=qr(),a=qr(),c=qr();mt(s,e.domain,i),mt(s,e.scheme,a),mt(s,e.slashscheme,c),mt(i,r,o),mt(i,e.domain,i);const u=Me(i,ni);Me(o,ni,u),Me(a,ni,u),Me(c,ni,u);const d=Me(o,$s);mt(d,r,o),mt(d,e.domain,o);const h=qr();mt(u,e.domain,h),mt(h,e.domain,h);const f=Me(h,$s);mt(f,e.domain,h);const p=qr(Zte);mt(f,e.tld,p),mt(f,e.utld,p),Me(u,Mu,p);const m=Me(h,Yr);Me(m,Yr,m),mt(m,e.domain,h),mt(p,e.domain,h),Me(p,$s,f),Me(p,Yr,m);const w=Me(i,Yr),b=Me(i,$s);Me(w,Yr,w),mt(w,e.domain,i),mt(b,r,o),mt(b,e.domain,i);const x=qr(Jd);mt(b,e.tld,x),mt(b,e.utld,x),mt(x,e.domain,i),mt(x,r,o),Me(x,$s,b),Me(x,Yr,w),Me(x,ni,u);const v=Me(x,ca),S=qr(Jd);mt(v,e.numeric,S);const C=qr(Jd),O=qr();mt(C,t,C),mt(C,n,O),mt(O,t,C),mt(O,n,O),Me(x,Ps,C),Me(S,Ps,C);const N=Me(a,ca),P=Me(c,ca),M=Me(P,Ps),R=Me(M,Ps);mt(a,e.domain,i),Me(a,$s,b),Me(a,Yr,w),mt(c,e.domain,i),Me(c,$s,b),Me(c,Yr,w),mt(N,e.domain,C),Me(N,Ps,C),Me(N,eu,C),mt(R,e.domain,C),mt(R,t,C),Me(R,Ps,C);const L=[[Xc,Qc],[vf,Sf],[jf,Cf],[Nf,Ef],[Af,Tf],[Mf,Rf],[If,Df],[Of,Lf]];for(let H=0;H<L.length;H++){const[_,Y]=L[H],se=Me(C,_);Me(O,_,se);const re=qr(Jd);mt(se,t,re);const T=qr();mt(se,n,T),Me(se,Y,C),mt(re,t,re),mt(re,n,T),mt(T,t,re),mt(T,n,T),Me(re,Y,C),Me(T,Y,C)}return Me(s,Mu,x),Me(s,bk,ene),{start:s,tokens:dO}}function nne(e,t,n){let r=n.length,s=0,o=[],i=[];for(;s<r;){let a=e,c=null,u=null,d=0,h=null,f=-1;for(;s<r&&!(c=a.go(n[s].t));)i.push(n[s++]);for(;s<r&&(u=c||a.go(n[s].t));)c=null,a=u,a.accepts()?(f=0,h=a):f>=0&&f++,s++,d++;if(f<0)s-=d,s<r&&(i.push(n[s]),s++);else{i.length>0&&(o.push(Qg(mN,t,i)),i=[]),s-=f,d-=f;const p=h.t,m=n.slice(s-d,s);o.push(Qg(p,t,m))}}return i.length>0&&o.push(Qg(mN,t,i)),o}function Qg(e,t,n){const r=n[0].s,s=n[n.length-1].e,o=t.slice(r,s);return new e(o,n)}const rne=typeof console<"u"&&console&&console.warn||(()=>{}),sne="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ft={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function one(){return br.groups={},Ft.scanner=null,Ft.parser=null,Ft.tokenQueue=[],Ft.pluginQueue=[],Ft.customSchemes=[],Ft.initialized=!1,Ft}function gN(e,t=!1){if(Ft.initialized&&rne(`linkifyjs: already initialized - will not register custom scheme "${e}" ${sne}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw new Error(`linkifyjs: incorrect scheme format.
|
|
824
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
825
|
+
2. Cannot start or end with "-"
|
|
826
|
+
3. "-" cannot repeat`);Ft.customSchemes.push([e,t])}function ine(){Ft.scanner=Xte(Ft.customSchemes);for(let e=0;e<Ft.tokenQueue.length;e++)Ft.tokenQueue[e][1]({scanner:Ft.scanner});Ft.parser=tne(Ft.scanner.tokens);for(let e=0;e<Ft.pluginQueue.length;e++)Ft.pluginQueue[e][1]({scanner:Ft.scanner,parser:Ft.parser});return Ft.initialized=!0,Ft}function Ck(e){return Ft.initialized||ine(),nne(Ft.parser.start,e,hO(Ft.scanner.start,e))}Ck.scan=hO;function pO(e,t=null,n=null){if(t&&typeof t=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}const r=new jk(n),s=Ck(e),o=[];for(let i=0;i<s.length;i++){const a=s[i];a.isLink&&(!t||a.t===t)&&r.check(a)&&o.push(a.toFormattedObject(r))}return o}const Nk="[\0- -\u2029 ]",ane=new RegExp(Nk),lne=new RegExp(`${Nk}$`),cne=new RegExp(Nk,"g");function une(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function dne(e){return new an({key:new On("autolink"),appendTransaction:(t,n,r)=>{const s=t.some(u=>u.docChanged)&&!n.doc.eq(r.doc),o=t.some(u=>u.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,a=TZ(n.doc,[...t]);if($Z(a).forEach(({newRange:u})=>{const d=RZ(r.doc,u,p=>p.isTextblock);let h,f;if(d.length>1)h=d[0],f=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!lne.test(p))return;h=d[0],f=r.doc.textBetween(h.pos,u.to,void 0," ")}if(h&&f){const p=f.split(ane).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],w=h.pos+f.lastIndexOf(m);if(!m)return!1;const b=Ck(m).map(x=>x.toObject(e.defaultProtocol));if(!une(b))return!1;b.filter(x=>x.isLink).map(x=>({...x,from:w+x.start+1,to:w+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>e.validate(x.value)).filter(x=>e.shouldAutoLink(x.value)).forEach(x=>{pk(x.from,x.to,r.doc).some(v=>v.mark.type===e.type)||i.addMark(x.from,x.to,e.type.create({href:x.href}))})}}),!!i.steps.length)return i}})}function hne(e){return new an({key:new On("handleClickLink"),props:{handleClick:(t,n,r)=>{var s,o;if(r.button!==0||!t.editable)return!1;let i=r.target;const a=[];for(;i.nodeName!=="DIV";)a.push(i),i=i.parentNode;if(!a.find(f=>f.nodeName==="A"))return!1;const c=QD(t.state,e.type.name),u=r.target,d=(s=u==null?void 0:u.href)!==null&&s!==void 0?s:c.href,h=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:c.target;return u&&d?(window.open(d,h),!0):!1}}})}function fne(e){return new an({key:new On("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{state:s}=t,{selection:o}=s,{empty:i}=o;if(i)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=pO(a,{defaultProtocol:e.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c?!1:e.editor.commands.setMark(e.type,{href:c.href})}}})}function _i(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!e||e.replace(cne,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const pne=Da.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e=="string"){gN(e);return}gN(e.scheme,e.optionalSlashes)})},onDestroy(){one()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,t)=>!!_i(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{const t=e.getAttribute("href");return!t||!this.options.isAllowedUri(t,{defaultValidate:n=>!!_i(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:t=>!!_i(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Bt(this.options.HTMLAttributes,e),0]:["a",Bt(this.options.HTMLAttributes,{...e,href:""}),0]},addCommands(){return{setLink:e=>({chain:t})=>{const{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:r=>!!_i(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta("preventAutolink",!0).run():!1},toggleLink:e=>({chain:t})=>{const{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:r=>!!_i(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Na({find:e=>{const t=[];if(e){const{protocols:n,defaultProtocol:r}=this.options,s=pO(e).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!_i(i,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(o=>t.push({text:o.value,data:{href:o.href},index:o.start}))}return t},type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(dne({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!_i(s,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&e.push(hne({type:this.type})),this.options.linkOnPaste&&e.push(fne({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}});let mb,gb;if(typeof WeakMap<"u"){let e=new WeakMap;mb=t=>e.get(t),gb=(t,n)=>(e.set(t,n),n)}else{const e=[];let n=0;mb=r=>{for(let s=0;s<e.length;s+=2)if(e[s]==r)return e[s+1]},gb=(r,s)=>(n==10&&(n=0),e[n++]=r,e[n++]=s)}var Jt=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,s=t/this.width|0;let o=r+1,i=s+1;for(let a=1;o<this.width&&this.map[t+a]==n;a++)o++;for(let a=1;i<this.height&&this.map[t+this.width*a]==n;a++)i++;return{left:r,top:s,right:o,bottom:i}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:s,top:o,bottom:i}=this.findCell(e);return t=="horiz"?(n<0?r==0:s==this.width)?null:this.map[o*this.width+(n<0?r-1:s)]:(n<0?o==0:i==this.height)?null:this.map[r+this.width*(n<0?o-1:i)]}rectBetween(e,t){const{left:n,right:r,top:s,bottom:o}=this.findCell(e),{left:i,right:a,top:c,bottom:u}=this.findCell(t);return{left:Math.min(n,i),top:Math.min(s,c),right:Math.max(r,a),bottom:Math.max(o,u)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let s=e.left;s<e.right;s++){const o=r*this.width+s,i=this.map[o];n[i]||(n[i]=!0,!(s==e.left&&s&&this.map[o-1]==i||r==e.top&&r&&this.map[o-this.width]==i)&&t.push(i))}return t}positionAt(e,t,n){for(let r=0,s=0;;r++){const o=s+n.child(r).nodeSize;if(r==e){let i=t+e*this.width;const a=(e+1)*this.width;for(;i<a&&this.map[i]<s;)i++;return i==a?o-1:this.map[i]}s=o}}static get(e){return mb(e)||gb(e,mne(e))}};function mne(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);const t=gne(e),n=e.childCount,r=[];let s=0,o=null;const i=[];for(let u=0,d=t*n;u<d;u++)r[u]=0;for(let u=0,d=0;u<n;u++){const h=e.child(u);d++;for(let m=0;;m++){for(;s<r.length&&r[s]!=0;)s++;if(m==h.childCount)break;const w=h.child(m),{colspan:b,rowspan:x,colwidth:v}=w.attrs;for(let S=0;S<x;S++){if(S+u>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:x-S});break}const C=s+S*t;for(let O=0;O<b;O++){r[C+O]==0?r[C+O]=d:(o||(o=[])).push({type:"collision",row:u,pos:d,n:b-O});const N=v&&v[O];if(N){const P=(C+O)%t*2,M=i[P];M==null||M!=N&&i[P+1]==1?(i[P]=N,i[P+1]=1):M==N&&i[P+1]++}}}s+=b,d+=w.nodeSize}const f=(u+1)*t;let p=0;for(;s<f;)r[s++]==0&&p++;p&&(o||(o=[])).push({type:"missing",row:u,n:p}),d++}(t===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new Jt(t,n,r,o);let c=!1;for(let u=0;!c&&u<i.length;u+=2)i[u]!=null&&i[u+1]<n&&(c=!0);return c&&yne(a,i,e),a}function gne(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const s=e.child(r);let o=0;if(n)for(let i=0;i<r;i++){const a=e.child(i);for(let c=0;c<a.childCount;c++){const u=a.child(c);i+u.attrs.rowspan>r&&(o+=u.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const a=s.child(i);o+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}t==-1?t=o:t!=o&&(t=Math.max(t,o))}return t}function yne(e,t,n){e.problems||(e.problems=[]);const r={};for(let s=0;s<e.map.length;s++){const o=e.map[s];if(r[o])continue;r[o]=!0;const i=n.nodeAt(o);if(!i)throw new RangeError(`No cell with offset ${o} found`);let a=null;const c=i.attrs;for(let u=0;u<c.colspan;u++){const d=t[(s+u)%e.width*2];d!=null&&(!c.colwidth||c.colwidth[u]!=d)&&((a||(a=wne(c)))[u]=d)}a&&e.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function wne(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Un(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],s=r.spec.tableRole;s&&(t[s]=r)}}return t}const ii=new On("selectingCells");function Ea(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function bne(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function ks(e){const t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function Up(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const n=Ea(t.$head)||xne(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function xne(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function yb(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function kne(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Ek(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function mO(e,t,n){const r=e.node(-1),s=Jt.get(r),o=e.start(-1),i=s.nextCell(e.pos-o,t,n);return i==null?null:e.node(0).resolve(o+i)}function Aa(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function gO(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(t,0,0)}return r}function vne(e,t,n){const r=Un(t.type.schema).header_cell;for(let s=0;s<e.height;s++)if(t.nodeAt(e.map[n+s*e.width]).type!=r)return!1;return!0}var Pt=class mo extends ot{constructor(t,n=t){const r=t.node(-1),s=Jt.get(r),o=t.start(-1),i=s.rectBetween(t.pos-o,n.pos-o),a=t.node(0),c=s.cellsInRect(i).filter(d=>d!=n.pos-o);c.unshift(n.pos-o);const u=c.map(d=>{const h=r.nodeAt(d);if(!h)throw new RangeError(`No cell with offset ${d} found`);const f=o+d+1;return new HI(a.resolve(f),a.resolve(f+h.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=n}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),s=t.resolve(n.map(this.$headCell.pos));if(yb(r)&&yb(s)&&Ek(r,s)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?mo.rowSelection(r,s):o&&this.isColSelection()?mo.colSelection(r,s):new mo(r,s)}return Xe.between(r,s)}content(){const t=this.$anchorCell.node(-1),n=Jt.get(t),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},i=[];for(let c=s.top;c<s.bottom;c++){const u=[];for(let d=c*n.width+s.left,h=s.left;h<s.right;h++,d++){const f=n.map[d];if(o[f])continue;o[f]=!0;const p=n.findCell(f);let m=t.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const w=s.left-p.left,b=p.right-s.right;if(w>0||b>0){let x=m.attrs;if(w>0&&(x=Aa(x,0,w)),b>0&&(x=Aa(x,x.colspan-b,b)),p.left<s.left){if(m=m.type.createAndFill(x),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else m=m.type.create(x,m.content)}if(p.top<s.top||p.bottom>s.bottom){const x={...m.attrs,rowspan:Math.min(p.bottom,s.bottom)-Math.max(p.top,s.top)};p.top<s.top?m=m.type.createAndFill(x):m=m.type.create(x,m.content)}u.push(m)}i.push(t.child(c).copy(je.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?t:i;return new Pe(je.from(a),1,1)}replace(t,n=Pe.empty){const r=t.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:a,$to:c}=s[i],u=t.mapping.slice(r);t.replace(u.map(a.pos),u.map(c.pos),i?Pe.empty:n)}const o=ot.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);o&&t.setSelection(o)}replaceWith(t,n){this.replace(t,new Pe(je.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),r=Jt.get(n),s=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<o.length;i++)t(n.nodeAt(o[i]),s+o[i])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const r=t+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),s=Jt.get(r),o=t.start(-1),i=s.findCell(t.pos-o),a=s.findCell(n.pos-o),c=t.node(0);return i.top<=a.top?(i.top>0&&(t=c.resolve(o+s.map[i.left])),a.bottom<s.height&&(n=c.resolve(o+s.map[s.width*(s.height-1)+a.right-1]))):(a.top>0&&(n=c.resolve(o+s.map[a.left])),i.bottom<s.height&&(t=c.resolve(o+s.map[s.width*(s.height-1)+i.right-1]))),new mo(t,n)}isRowSelection(){const t=this.$anchorCell.node(-1),n=Jt.get(t),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(s,o)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,a)==n.width}eq(t){return t instanceof mo&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),s=Jt.get(r),o=t.start(-1),i=s.findCell(t.pos-o),a=s.findCell(n.pos-o),c=t.node(0);return i.left<=a.left?(i.left>0&&(t=c.resolve(o+s.map[i.top*s.width])),a.right<s.width&&(n=c.resolve(o+s.map[s.width*(a.top+1)-1]))):(a.left>0&&(n=c.resolve(o+s.map[a.top*s.width])),i.right<s.width&&(t=c.resolve(o+s.map[s.width*(i.top+1)-1]))),new mo(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new mo(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new mo(t.resolve(n),t.resolve(r))}getBookmark(){return new Sne(this.$anchorCell.pos,this.$headCell.pos)}};Pt.prototype.visible=!1;ot.jsonID("cell",Pt);var Sne=class yO{constructor(t,n){this.anchor=t,this.head=n}map(t){return new yO(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Ek(n,r)?new Pt(n,r):ot.near(r,1)}};function jne(e){if(!(e.selection instanceof Pt))return null;const t=[];return e.selection.forEachCell((n,r)=>{t.push(Wn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Vt.create(e.doc,t)}function Cne({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,s=e.depth;for(;s>=0&&!(e.after(s+1)<e.end(s));s--,n++);for(let o=t.depth;o>=0&&!(t.before(o+1)>t.start(o));o--,r--);return n==r&&/row|table/.test(e.node(s).type.spec.tableRole)}function Nne({$from:e,$to:t}){let n,r;for(let s=e.depth;s>0;s--){const o=e.node(s);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let s=t.depth;s>0;s--){const o=t.node(s);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&t.parentOffset===0}function Ene(e,t,n){const r=(t||e).selection,s=(t||e).doc;let o,i;if(r instanceof Qe&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")o=Pt.create(s,r.from);else if(i=="row"){const a=s.resolve(r.from+1);o=Pt.rowSelection(a,a)}else if(!n){const a=Jt.get(r.node),c=r.from+1,u=c+a.map[a.width*a.height-1];o=Pt.create(s,c+1,u)}}else r instanceof Xe&&Cne(r)?o=Xe.create(s,r.from):r instanceof Xe&&Nne(r)&&(o=Xe.create(s,r.$from.start(),r.$from.end()));return o&&(t||(t=e.tr)).setSelection(o),t}const Ane=new On("fix-tables");function wO(e,t,n,r){const s=e.childCount,o=t.childCount;e:for(let i=0,a=0;i<o;i++){const c=t.child(i);for(let u=a,d=Math.min(s,i+3);u<d;u++)if(e.child(u)==c){a=u+1,n+=c.nodeSize;continue e}r(c,n),a<s&&e.child(a).sameMarkup(c)?wO(e.child(a),c,n+1,r):c.nodesBetween(0,c.content.size,r,n+1),n+=c.nodeSize}}function bO(e,t){let n;const r=(s,o)=>{s.type.spec.tableRole=="table"&&(n=Tne(e,s,o,n))};return t?t.doc!=e.doc&&wO(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Tne(e,t,n,r){const s=Jt.get(t);if(!s.problems)return r;r||(r=e.tr);const o=[];for(let c=0;c<s.height;c++)o.push(0);for(let c=0;c<s.problems.length;c++){const u=s.problems[c];if(u.type=="collision"){const d=t.nodeAt(u.pos);if(!d)continue;const h=d.attrs;for(let f=0;f<h.rowspan;f++)o[u.row+f]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,Aa(h,h.colspan-u.n,u.n))}else if(u.type=="missing")o[u.row]+=u.n;else if(u.type=="overlong_rowspan"){const d=t.nodeAt(u.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){const d=t.nodeAt(u.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...d.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+t.nodeSize)}}let i,a;for(let c=0;c<o.length;c++)o[c]&&(i==null&&(i=c),a=c);for(let c=0,u=n+1;c<s.height;c++){const d=t.child(c),h=u+d.nodeSize,f=o[c];if(f>0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);const m=[];for(let b=0;b<f;b++){const x=Un(e.schema)[p].createAndFill();x&&m.push(x)}const w=(c==0||i==c-1)&&a==c?u+1:h-1;r.insert(r.mapping.map(w),m)}u=h}return r.setMeta(Ane,{fixTables:!0})}function qs(e){const t=e.selection,n=Up(e),r=n.node(-1),s=n.start(-1),o=Jt.get(r);return{...t instanceof Pt?o.rectBetween(t.$anchorCell.pos-s,t.$headCell.pos-s):o.findCell(n.pos-s),tableStart:s,map:o,table:r}}function xO(e,{map:t,tableStart:n,table:r},s){let o=s>0?-1:0;vne(t,r,s+o)&&(o=s==0||s==t.width?null:0);for(let i=0;i<t.height;i++){const a=i*t.width+s;if(s>0&&s<t.width&&t.map[a-1]==t.map[a]){const c=t.map[a],u=r.nodeAt(c);e.setNodeMarkup(e.mapping.map(n+c),null,gO(u.attrs,s-t.colCount(c))),i+=u.attrs.rowspan-1}else{const c=o==null?Un(r.type.schema).cell:r.nodeAt(t.map[a+o]).type,u=t.positionAt(i,s,r);e.insert(e.mapping.map(n+u),c.createAndFill())}}return e}function Mne(e,t){if(!ks(e))return!1;if(t){const n=qs(e);t(xO(e.tr,n,n.left))}return!0}function Rne(e,t){if(!ks(e))return!1;if(t){const n=qs(e);t(xO(e.tr,n,n.right))}return!0}function Ine(e,{map:t,table:n,tableStart:r},s){const o=e.mapping.maps.length;for(let i=0;i<t.height;){const a=i*t.width+s,c=t.map[a],u=n.nodeAt(c),d=u.attrs;if(s>0&&t.map[a-1]==c||s<t.width-1&&t.map[a+1]==c)e.setNodeMarkup(e.mapping.slice(o).map(r+c),null,Aa(d,s-t.colCount(c)));else{const h=e.mapping.slice(o).map(r+c);e.delete(h,h+u.nodeSize)}i+=d.rowspan}}function Dne(e,t){if(!ks(e))return!1;if(t){const n=qs(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;Ine(r,n,s),s!=n.left;s--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=Jt.get(o)}t(r)}return!0}function One(e,t,n){var r;const s=Un(t.type.schema).header_cell;for(let o=0;o<e.width;o++)if(((r=t.nodeAt(e.map[o+n*e.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function kO(e,{map:t,tableStart:n,table:r},s){let o=n;for(let u=0;u<s;u++)o+=r.child(u).nodeSize;const i=[];let a=s>0?-1:0;One(t,r,s+a)&&(a=s==0||s==t.height?null:0);for(let u=0,d=t.width*s;u<t.width;u++,d++)if(s>0&&s<t.height&&t.map[d]==t.map[d-t.width]){const h=t.map[d],f=r.nodeAt(h).attrs;e.setNodeMarkup(n+h,null,{...f,rowspan:f.rowspan+1}),u+=f.colspan-1}else{var c;const h=a==null?Un(r.type.schema).cell:(c=r.nodeAt(t.map[d+a*t.width]))===null||c===void 0?void 0:c.type,f=h==null?void 0:h.createAndFill();f&&i.push(f)}return e.insert(o,Un(r.type.schema).row.create(null,i)),e}function Lne(e,t){if(!ks(e))return!1;if(t){const n=qs(e);t(kO(e.tr,n,n.top))}return!0}function $ne(e,t){if(!ks(e))return!1;if(t){const n=qs(e);t(kO(e.tr,n,n.bottom))}return!0}function Pne(e,{map:t,table:n,tableStart:r},s){let o=0;for(let u=0;u<s;u++)o+=n.child(u).nodeSize;const i=o+n.child(s).nodeSize,a=e.mapping.maps.length;e.delete(o+r,i+r);const c=new Set;for(let u=0,d=s*t.width;u<t.width;u++,d++){const h=t.map[d];if(!c.has(h)){if(c.add(h),s>0&&h==t.map[d-t.width]){const f=n.nodeAt(h).attrs;e.setNodeMarkup(e.mapping.slice(a).map(h+r),null,{...f,rowspan:f.rowspan-1}),u+=f.colspan-1}else if(s<t.height&&h==t.map[d+t.width]){const f=n.nodeAt(h),p=f.attrs,m=f.type.create({...p,rowspan:f.attrs.rowspan-1},f.content),w=t.positionAt(s+1,u,n);e.insert(e.mapping.slice(a).map(r+w),m),u+=p.colspan-1}}}}function zne(e,t){if(!ks(e))return!1;if(t){const n=qs(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;Pne(r,n,s),s!=n.top;s--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=Jt.get(n.table)}t(r)}return!0}function yN(e){const t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function Fne({width:e,height:t,map:n},r){let s=r.top*e+r.left,o=s,i=(r.bottom-1)*e+r.left,a=s+(r.right-r.left-1);for(let c=r.top;c<r.bottom;c++){if(r.left>0&&n[o]==n[o-1]||r.right<e&&n[a]==n[a+1])return!0;o+=e,a+=e}for(let c=r.left;c<r.right;c++){if(r.top>0&&n[s]==n[s-e]||r.bottom<t&&n[i]==n[i+e])return!0;s++,i++}return!1}function wN(e,t){const n=e.selection;if(!(n instanceof Pt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=qs(e),{map:s}=r;if(Fne(s,r))return!1;if(t){const o=e.tr,i={};let a=je.empty,c,u;for(let d=r.top;d<r.bottom;d++)for(let h=r.left;h<r.right;h++){const f=s.map[d*s.width+h],p=r.table.nodeAt(f);if(!(i[f]||!p))if(i[f]=!0,c==null)c=f,u=p;else{yN(p)||(a=a.append(p.content));const m=o.mapping.map(f+r.tableStart);o.delete(m,m+p.nodeSize)}}if(c==null||u==null)return!0;if(o.setNodeMarkup(c+r.tableStart,null,{...gO(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const d=c+1+u.content.size,h=yN(u)?c+1:d;o.replaceWith(h+r.tableStart,d+r.tableStart,a)}o.setSelection(new Pt(o.doc.resolve(c+r.tableStart))),t(o)}return!0}function bN(e,t){const n=Un(e.schema);return Bne(({node:r})=>n[r.type.spec.tableRole])(e,t)}function Bne(e){return(t,n)=>{const r=t.selection;let s,o;if(r instanceof Pt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var i;if(s=bne(r.$from),!s)return!1;o=(i=Ea(r.$from))===null||i===void 0?void 0:i.pos}if(s==null||o==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let a=s.attrs;const c=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const d=qs(t),h=t.tr;for(let p=0;p<d.right-d.left;p++)c.push(u?{...a,colwidth:u&&u[p]?[u[p]]:null}:a);let f;for(let p=d.top;p<d.bottom;p++){let m=d.map.positionAt(p,d.left,d.table);p==d.top&&(m+=s.nodeSize);for(let w=d.left,b=0;w<d.right;w++,b++)w==d.left&&p==d.top||h.insert(f=h.mapping.map(m+d.tableStart,1),e({node:s,row:p,col:w}).createAndFill(c[b]))}h.setNodeMarkup(o,e({node:s,row:d.top,col:d.left}),c[0]),r instanceof Pt&&h.setSelection(new Pt(h.doc.resolve(r.$anchorCell.pos),f?h.doc.resolve(f):void 0)),n(h)}return!0}}function _ne(e,t){return function(n,r){if(!ks(n))return!1;const s=Up(n);if(s.nodeAfter.attrs[e]===t)return!1;if(r){const o=n.tr;n.selection instanceof Pt?n.selection.forEachCell((i,a)=>{i.attrs[e]!==t&&o.setNodeMarkup(a,null,{...i.attrs,[e]:t})}):o.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[e]:t}),r(o)}return!0}}function Wne(e){return function(t,n){if(!ks(t))return!1;if(n){const r=Un(t.schema),s=qs(t),o=t.tr,i=s.map.cellsInRect(e=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:e=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),a=i.map(c=>s.table.nodeAt(c));for(let c=0;c<i.length;c++)a[c].type==r.header_cell&&o.setNodeMarkup(s.tableStart+i[c],r.cell,a[c].attrs);if(o.steps.length===0)for(let c=0;c<i.length;c++)o.setNodeMarkup(s.tableStart+i[c],r.header_cell,a[c].attrs);n(o)}return!0}}function xN(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let s=0;s<r.length;s++){const o=t.table.nodeAt(r[s]);if(o&&o.type!==n.header_cell)return!1}return!0}function Iu(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?Wne(e):function(n,r){if(!ks(n))return!1;if(r){const s=Un(n.schema),o=qs(n),i=n.tr,a=xN("row",o,s),c=xN("column",o,s),u=(e==="column"?a:e==="row"&&c)?1:0,d=e=="column"?{left:0,top:u,right:1,bottom:o.map.height}:e=="row"?{left:u,top:0,right:o.map.width,bottom:1}:o,h=e=="column"?c?s.cell:s.header_cell:e=="row"?a?s.cell:s.header_cell:s.cell;o.map.cellsInRect(d).forEach(f=>{const p=f+o.tableStart,m=i.doc.nodeAt(p);m&&i.setNodeMarkup(p,h,m.attrs)}),r(i)}return!0}}Iu("row",{useDeprecatedLogic:!0});Iu("column",{useDeprecatedLogic:!0});const Hne=Iu("cell",{useDeprecatedLogic:!0});function Une(e,t){if(t<0){const n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,s=e.before();r>=0;r--){const o=e.node(-1).child(r),i=o.lastChild;if(i)return s-1-i.nodeSize;s-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const n=e.node(-1);for(let r=e.indexAfter(-1),s=e.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return s+1;s+=o.nodeSize}}return null}function kN(e){return function(t,n){if(!ks(t))return!1;const r=Une(Up(t),e);if(r==null)return!1;if(n){const s=t.doc.resolve(r);n(t.tr.setSelection(Xe.between(s,kne(s))).scrollIntoView())}return!0}}function Kne(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Xd(e,t){const n=e.selection;if(!(n instanceof Pt))return!1;if(t){const r=e.tr,s=Un(e.schema).cell.createAndFill().content;n.forEachCell((o,i)=>{o.content.eq(s)||r.replace(r.mapping.map(i+1),r.mapping.map(i+o.nodeSize-1),new Pe(s,0,0))}),r.docChanged&&t(r)}return!0}function Vne(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;const s=t.child(0),o=s.type.spec.tableRole,i=s.type.schema,a=[];if(o=="row")for(let c=0;c<t.childCount;c++){let u=t.child(c).content;const d=c?0:Math.max(0,n-1),h=c<t.childCount-1?0:Math.max(0,r-1);(d||h)&&(u=wb(Un(i).row,new Pe(u,d,h)).content),a.push(u)}else if(o=="cell"||o=="header_cell")a.push(n||r?wb(Un(i).row,new Pe(t,n,r)).content:t);else return null;return qne(i,a)}function qne(e,t){const n=[];for(let s=0;s<t.length;s++){const o=t[s];for(let i=o.childCount-1;i>=0;i--){const{rowspan:a,colspan:c}=o.child(i).attrs;for(let u=s;u<s+a;u++)n[u]=(n[u]||0)+c}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=t.length&&t.push(je.empty),n[s]<r){const o=Un(e).cell.createAndFill(),i=[];for(let a=n[s];a<r;a++)i.push(o);t[s]=t[s].append(je.from(i))}return{height:t.length,width:r,rows:t}}function wb(e,t){const n=e.createAndFill();return new qx(n).replace(0,n.content.size,t).doc}function Yne({width:e,height:t,rows:n},r,s){if(e!=r){const o=[],i=[];for(let a=0;a<n.length;a++){const c=n[a],u=[];for(let d=o[a]||0,h=0;d<r;h++){let f=c.child(h%c.childCount);d+f.attrs.colspan>r&&(f=f.type.createChecked(Aa(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),u.push(f),d+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)o[a+p]=(o[a+p]||0)+f.attrs.colspan}i.push(je.from(u))}n=i,e=r}if(t!=s){const o=[];for(let i=0,a=0;i<s;i++,a++){const c=[],u=n[a%t];for(let d=0;d<u.childCount;d++){let h=u.child(d);i+h.attrs.rowspan>s&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,s-h.attrs.rowspan)},h.content)),c.push(h)}o.push(je.from(c))}n=o,t=s}return{width:e,height:t,rows:n}}function Gne(e,t,n,r,s,o,i){const a=e.doc.type.schema,c=Un(a);let u,d;if(s>t.width)for(let h=0,f=0;h<t.height;h++){const p=n.child(h);f+=p.nodeSize;const m=[];let w;p.lastChild==null||p.lastChild.type==c.cell?w=u||(u=c.cell.createAndFill()):w=d||(d=c.header_cell.createAndFill());for(let b=t.width;b<s;b++)m.push(w);e.insert(e.mapping.slice(i).map(f-1+r),m)}if(o>t.height){const h=[];for(let m=0,w=(t.height-1)*t.width;m<Math.max(t.width,s);m++){const b=m>=t.width?!1:n.nodeAt(t.map[w+m]).type==c.header_cell;h.push(b?d||(d=c.header_cell.createAndFill()):u||(u=c.cell.createAndFill()))}const f=c.row.create(null,je.from(h)),p=[];for(let m=t.height;m<o;m++)p.push(f);e.insert(e.mapping.slice(i).map(r+n.nodeSize-2),p)}return!!(u||d)}function vN(e,t,n,r,s,o,i,a){if(i==0||i==t.height)return!1;let c=!1;for(let u=s;u<o;u++){const d=i*t.width+u,h=t.map[d];if(t.map[d-t.width]==h){c=!0;const f=n.nodeAt(h),{top:p,left:m}=t.findCell(h);e.setNodeMarkup(e.mapping.slice(a).map(h+r),null,{...f.attrs,rowspan:i-p}),e.insert(e.mapping.slice(a).map(t.positionAt(i,m,n)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-i})),u+=f.attrs.colspan-1}}return c}function SN(e,t,n,r,s,o,i,a){if(i==0||i==t.width)return!1;let c=!1;for(let u=s;u<o;u++){const d=u*t.width+i,h=t.map[d];if(t.map[d-1]==h){c=!0;const f=n.nodeAt(h),p=t.colCount(h),m=e.mapping.slice(a).map(h+r);e.setNodeMarkup(m,null,Aa(f.attrs,i-p,f.attrs.colspan-(i-p))),e.insert(m+f.nodeSize,f.type.createAndFill(Aa(f.attrs,0,i-p))),u+=f.attrs.rowspan-1}}return c}function jN(e,t,n,r,s){let o=n?e.doc.nodeAt(n-1):e.doc;if(!o)throw new Error("No table found");let i=Jt.get(o);const{top:a,left:c}=r,u=c+s.width,d=a+s.height,h=e.tr;let f=0;function p(){if(o=n?h.doc.nodeAt(n-1):h.doc,!o)throw new Error("No table found");i=Jt.get(o),f=h.mapping.maps.length}Gne(h,i,o,n,u,d,f)&&p(),vN(h,i,o,n,c,u,a,f)&&p(),vN(h,i,o,n,c,u,d,f)&&p(),SN(h,i,o,n,a,d,c,f)&&p(),SN(h,i,o,n,a,d,u,f)&&p();for(let m=a;m<d;m++){const w=i.positionAt(m,c,o),b=i.positionAt(m,u,o);h.replace(h.mapping.slice(f).map(w+n),h.mapping.slice(f).map(b+n),new Pe(s.rows[m-a],0,0))}p(),h.setSelection(new Pt(h.doc.resolve(n+i.positionAt(a,c,o)),h.doc.resolve(n+i.positionAt(d-1,u-1,o)))),t(h)}const Jne=sk({ArrowLeft:Qd("horiz",-1),ArrowRight:Qd("horiz",1),ArrowUp:Qd("vert",-1),ArrowDown:Qd("vert",1),"Shift-ArrowLeft":Zd("horiz",-1),"Shift-ArrowRight":Zd("horiz",1),"Shift-ArrowUp":Zd("vert",-1),"Shift-ArrowDown":Zd("vert",1),Backspace:Xd,"Mod-Backspace":Xd,Delete:Xd,"Mod-Delete":Xd});function bh(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Qd(e,t){return(n,r,s)=>{if(!s)return!1;const o=n.selection;if(o instanceof Pt)return bh(n,r,ot.near(o.$headCell,t));if(e!="horiz"&&!o.empty)return!1;const i=vO(s,e,t);if(i==null)return!1;if(e=="horiz")return bh(n,r,ot.near(n.doc.resolve(o.head+t),t));{const a=n.doc.resolve(i),c=mO(a,e,t);let u;return c?u=ot.near(c,1):t<0?u=ot.near(n.doc.resolve(a.before(-1)),-1):u=ot.near(n.doc.resolve(a.after(-1)),1),bh(n,r,u)}}}function Zd(e,t){return(n,r,s)=>{if(!s)return!1;const o=n.selection;let i;if(o instanceof Pt)i=o;else{const c=vO(s,e,t);if(c==null)return!1;i=new Pt(n.doc.resolve(c))}const a=mO(i.$headCell,e,t);return a?bh(n,r,new Pt(i.$anchorCell,a)):!1}}function Xne(e,t){const n=e.state.doc,r=Ea(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new Pt(r))),!0):!1}function Qne(e,t,n){if(!ks(e.state))return!1;let r=Vne(n);const s=e.state.selection;if(s instanceof Pt){r||(r={width:1,height:1,rows:[je.from(wb(Un(e.state.schema).cell,n))]});const o=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),a=Jt.get(o).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return r=Yne(r,a.right-a.left,a.bottom-a.top),jN(e.state,e.dispatch,i,a,r),!0}else if(r){const o=Up(e.state),i=o.start(-1);return jN(e.state,e.dispatch,i,Jt.get(o.node(-1)).findCell(o.pos-i),r),!0}else return!1}function Zne(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;const r=CN(e,t.target);let s;if(t.shiftKey&&e.state.selection instanceof Pt)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(s=Ea(e.state.selection.$anchor))!=null&&((n=Zg(e,t))===null||n===void 0?void 0:n.pos)!=s.pos)o(s,t),t.preventDefault();else if(!r)return;function o(c,u){let d=Zg(e,u);const h=ii.getState(e.state)==null;if(!d||!Ek(c,d))if(h)d=c;else return;const f=new Pt(c,d);if(h||!e.state.selection.eq(f)){const p=e.state.tr.setSelection(f);h&&p.setMeta(ii,c.pos),e.dispatch(p)}}function i(){e.root.removeEventListener("mouseup",i),e.root.removeEventListener("dragstart",i),e.root.removeEventListener("mousemove",a),ii.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(ii,-1))}function a(c){const u=c,d=ii.getState(e.state);let h;if(d!=null)h=e.state.doc.resolve(d);else if(CN(e,u.target)!=r&&(h=Zg(e,t),!h))return i();h&&o(h,u)}e.root.addEventListener("mouseup",i),e.root.addEventListener("dragstart",i),e.root.addEventListener("mousemove",a)}function vO(e,t,n){if(!(e.state.selection instanceof Xe))return null;const{$head:r}=e.state.selection;for(let s=r.depth-1;s>=0;s--){const o=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const i=r.before(s),a=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(a)?i:null}}return null}function CN(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function Zg(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&Ea(e.state.doc.resolve(r))||Ea(e.state.doc.resolve(s))}var ere=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),bb(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,bb(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function bb(e,t,n,r,s,o){let i=0,a=!0,c=t.firstChild;const u=e.firstChild;if(u){for(let h=0,f=0;h<u.childCount;h++){const{colspan:p,colwidth:m}=u.child(h).attrs;for(let w=0;w<p;w++,f++){const b=s==f?o:m&&m[w],x=b?b+"px":"";if(i+=b||r,b||(a=!1),c)c.style.width!=x&&(c.style.width=x),c=c.nextSibling;else{const v=document.createElement("col");v.style.width=x,t.appendChild(v)}}}for(;c;){var d;const h=c.nextSibling;(d=c.parentNode)===null||d===void 0||d.removeChild(c),c=h}a?(n.style.width=i+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=i+"px")}}const Lr=new On("tableColumnResizing");function tre({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=ere,lastColumnResizable:s=!0}={}){const o=new an({key:Lr,state:{init(i,a){var c;const u=(c=o.spec)===null||c===void 0||(c=c.props)===null||c===void 0?void 0:c.nodeViews,d=Un(a.schema).table.name;return r&&u&&(u[d]=(h,f)=>new r(h,n,f)),new nre(-1,!1)},apply(i,a){return a.apply(i)}},props:{attributes:i=>{const a=Lr.getState(i);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,a)=>{rre(i,a,e,s)},mouseleave:i=>{sre(i)},mousedown:(i,a)=>{ore(i,a,t,n)}},decorations:i=>{const a=Lr.getState(i);if(a&&a.activeHandle>-1)return ure(i,a.activeHandle)},nodeViews:{}}});return o}var nre=class xh{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=this,r=t.getMeta(Lr);if(r&&r.setHandle!=null)return new xh(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new xh(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let s=t.mapping.map(n.activeHandle,-1);return yb(t.doc.resolve(s))||(s=-1),new xh(s,n.dragging)}return n}};function rre(e,t,n,r){if(!e.editable)return;const s=Lr.getState(e.state);if(s&&!s.dragging){const o=are(t.target);let i=-1;if(o){const{left:a,right:c}=o.getBoundingClientRect();t.clientX-a<=n?i=NN(e,t,"left",n):c-t.clientX<=n&&(i=NN(e,t,"right",n))}if(i!=s.activeHandle){if(!r&&i!==-1){const a=e.state.doc.resolve(i),c=a.node(-1),u=Jt.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}SO(e,i)}}}function sre(e){if(!e.editable)return;const t=Lr.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&SO(e,-1)}function ore(e,t,n,r){var s;if(!e.editable)return!1;const o=(s=e.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,i=Lr.getState(e.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const a=e.state.doc.nodeAt(i.activeHandle),c=ire(e,i.activeHandle,a.attrs);e.dispatch(e.state.tr.setMeta(Lr,{setDragging:{startX:t.clientX,startWidth:c}}));function u(h){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",d);const f=Lr.getState(e.state);f!=null&&f.dragging&&(lre(e,f.activeHandle,EN(f.dragging,h,n)),e.dispatch(e.state.tr.setMeta(Lr,{setDragging:null})))}function d(h){if(!h.which)return u(h);const f=Lr.getState(e.state);if(f&&f.dragging){const p=EN(f.dragging,h,n);AN(e,f.activeHandle,p,r)}}return AN(e,i.activeHandle,c,r),o.addEventListener("mouseup",u),o.addEventListener("mousemove",d),t.preventDefault(),!0}function ire(e,t,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const o=e.domAtPos(t);let i=o.node.childNodes[o.offset].offsetWidth,a=n;if(r)for(let c=0;c<n;c++)r[c]&&(i-=r[c],a--);return i/a}function are(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function NN(e,t,n,r){const s=n=="right"?-r:r,o=e.posAtCoords({left:t.clientX+s,top:t.clientY});if(!o)return-1;const{pos:i}=o,a=Ea(e.state.doc.resolve(i));if(!a)return-1;if(n=="right")return a.pos;const c=Jt.get(a.node(-1)),u=a.start(-1),d=c.map.indexOf(a.pos-u);return d%c.width==0?-1:u+c.map[d-1]}function EN(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function SO(e,t){e.dispatch(e.state.tr.setMeta(Lr,{setHandle:t}))}function lre(e,t,n){const r=e.state.doc.resolve(t),s=r.node(-1),o=Jt.get(s),i=r.start(-1),a=o.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let u=0;u<o.height;u++){const d=u*o.width+a;if(u&&o.map[d]==o.map[d-o.width])continue;const h=o.map[d],f=s.nodeAt(h).attrs,p=f.colspan==1?0:a-o.colCount(h);if(f.colwidth&&f.colwidth[p]==n)continue;const m=f.colwidth?f.colwidth.slice():cre(f.colspan);m[p]=n,c.setNodeMarkup(i+h,null,{...f,colwidth:m})}c.docChanged&&e.dispatch(c)}function AN(e,t,n,r){const s=e.state.doc.resolve(t),o=s.node(-1),i=s.start(-1),a=Jt.get(o).colCount(s.pos-i)+s.nodeAfter.attrs.colspan-1;let c=e.domAtPos(s.start(-1)).node;for(;c&&c.nodeName!="TABLE";)c=c.parentNode;c&&bb(o,c.firstChild,c,r,a,n)}function cre(e){return Array(e).fill(0)}function ure(e,t){const n=[],r=e.doc.resolve(t),s=r.node(-1);if(!s)return Vt.empty;const o=Jt.get(s),i=r.start(-1),a=o.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<o.height;u++){const d=a+u*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(u==0||o.map[d]!=o.map[d-o.width])){var c;const h=o.map[d],f=i+h+s.nodeAt(h).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((c=Lr.getState(e))===null||c===void 0)&&c.dragging&&n.push(Wn.node(i+h,i+h+s.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),n.push(Wn.widget(f,p))}}return Vt.create(e.doc,n)}function dre({allowTableNodeSelection:e=!1}={}){return new an({key:ii,state:{init(){return null},apply(t,n){const r=t.getMeta(ii);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;const{deleted:s,pos:o}=t.mapping.mapResult(n);return s?null:o}},props:{decorations:jne,handleDOMEvents:{mousedown:Zne},createSelectionBetween(t){return ii.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Xne,handleKeyDown:Jne,handlePaste:Qne},appendTransaction(t,n,r){return Ene(r,bO(r,n),e)}})}function xb(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function TN(e,t,n,r,s,o){var i;let a=0,c=!0,u=t.firstChild;const d=e.firstChild;if(d!==null)for(let h=0,f=0;h<d.childCount;h+=1){const{colspan:p,colwidth:m}=d.child(h).attrs;for(let w=0;w<p;w+=1,f+=1){const b=s===f?o:m&&m[w],x=b?`${b}px`:"";if(a+=b||r,b||(c=!1),u){if(u.style.width!==x){const[v,S]=xb(r,b);u.style.setProperty(v,S)}u=u.nextSibling}else{const v=document.createElement("col"),[S,C]=xb(r,b);v.style.setProperty(S,C),t.appendChild(v)}}}for(;u;){const h=u.nextSibling;(i=u.parentNode)===null||i===void 0||i.removeChild(u),u=h}c?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class hre{constructor(t,n){this.node=t,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),TN(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,TN(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type==="attributes"&&(t.target===this.table||this.colgroup.contains(t.target))}}function fre(e,t,n,r){let s=0,o=!0;const i=[],a=e.firstChild;if(!a)return{};for(let h=0,f=0;h<a.childCount;h+=1){const{colspan:p,colwidth:m}=a.child(h).attrs;for(let w=0;w<p;w+=1,f+=1){const b=n===f?r:m&&m[w];s+=b||t,b||(o=!1);const[x,v]=xb(t,b);i.push(["col",{style:`${x}: ${v}`}])}}const c=o?`${s}px`:"",u=o?"":`${s}px`;return{colgroup:["colgroup",{},...i],tableWidth:c,tableMinWidth:u}}function MN(e,t){return e.createAndFill()}function pre(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function mre(e,t,n,r,s){const o=pre(e),i=[],a=[];for(let u=0;u<n;u+=1){const d=MN(o.cell);if(d&&a.push(d),r){const h=MN(o.header_cell);h&&i.push(h)}}const c=[];for(let u=0;u<t;u+=1)c.push(o.row.createChecked(null,r&&u===0?i:a));return o.table.createChecked(null,c)}function gre(e){return e instanceof Pt}const eh=({editor:e})=>{const{selection:t}=e.state;if(!gre(t))return!1;let n=0;const r=XD(t.ranges[0].$from,o=>o.type.name==="table");return r==null||r.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},yre=vn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:hre,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=fre(e,this.options.cellMinWidth),o=["table",Bt(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${s}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:o})=>{const i=mre(o.schema,e,t,n);if(s){const a=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(Xe.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Mne(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Rne(e,t),deleteColumn:()=>({state:e,dispatch:t})=>Dne(e,t),addRowBefore:()=>({state:e,dispatch:t})=>Lne(e,t),addRowAfter:()=>({state:e,dispatch:t})=>$ne(e,t),deleteRow:()=>({state:e,dispatch:t})=>zne(e,t),deleteTable:()=>({state:e,dispatch:t})=>Kne(e,t),mergeCells:()=>({state:e,dispatch:t})=>wN(e,t),splitCell:()=>({state:e,dispatch:t})=>bN(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Iu("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Iu("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Hne(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>wN(e,t)?!0:bN(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>_ne(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>kN(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>kN(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&bO(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=Pt.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:eh,"Mod-Backspace":eh,Delete:eh,"Mod-Delete":eh}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[tre({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],dre({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:pt(Ue(e,"tableRole",t))}}}),wre=vn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",Bt(this.options.HTMLAttributes,e),0]}}),bre=vn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",Bt(this.options.HTMLAttributes,e),0]}}),xre=vn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",Bt(this.options.HTMLAttributes,e),0]}}),kre=Da.create({name:"underline",parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",Bt(e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function vre(e,t){const n=e.schema.nodes.heading,r=e.schema.nodes.paragraph;if(!n||!r)return!1;const{from:s,to:o}=e.selection,i=[];if(e.doc.nodesBetween(s,o,(a,c)=>{a.type===n&&i.push({node:a,pos:c})}),!i.length)return!1;if(t){const{tr:a}=e,c=e.schema.marks.bold;for(const{node:u,pos:d}of i)a.setNodeMarkup(d,r,{},u.marks),c&&u.content.size&&a.removeMark(d+1,d+1+u.content.size,c);t(a.scrollIntoView())}return!0}const Sre=kn.create({name:"unboldHeading",priority:1e3,addKeyboardShortcuts(){const e=()=>vre(this.editor.state,this.editor.view.dispatch);return{"Mod-b":e,"Mod-B":e}}}),jre=kn.create({name:"arrows",addInputRules(){return[nN({find:/--?>$/,replace:"→"}),nN({find:/<--?$/,replace:"←"})]}}),Cre=vn.create({name:"image",group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{src:{default:null},alt:{default:null}}},parseHTML(){return[{tag:"img[src]"}]},renderHTML({HTMLAttributes:e}){return["img",Bt(e)]}});function Nre(e,{tables:t=!0}={}){return[zte.configure({heading:{levels:[1,2,3]}}),kre,Sre,jre,Cre,pne.configure({openOnClick:!1,autolink:!0}),Bte,Wte.configure({nested:!0}),...t?[yre.configure({resizable:!1}),wre,bre,xre]:[],Fte.configure({placeholder:e})]}function Ere(e){return e.replace(/\r\n?/g,`
|
|
827
|
+
`)}const Are=/^(#{1,6})\s+(.*)$/,Tre=/^(\s*)[-*](?:\s+(.*))?$/,Mre=/^(\s*)\d+\.\s+(.*)$/,Rre=/^\[( |x|X)\](?:\s+(.*))?$/,ey=/^>\s?(.*)$/,Ire=/^```(\w*)\s*$/,Dre=/^(-{3,}|\*{3,}|_{3,})\s*$/,RN=/^\s*\|(.+)\|\s*$/,IN=/^\s*\|(\s*:?-{2,}:?\s*\|)+\s*$/,Ore=/^!\[([^\]]*)\]\(([^)\s]+)\)\s*$/;function DN(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="";for(let s=0;s<t.length;s++){if(t[s]==="\\"&&t[s+1]==="|"){r+="|",s++;continue}if(t[s]==="|"){n.push(r.trim()),r="";continue}r+=t[s]}return n.push(r.trim()),n}const Lre=new RegExp([/\\([\\`*_~[\]()#>|.!+-])/,/`([^`]+?)`/,/<u>([\s\S]+?)<\/u>/,/\[([^\]]+?)\]\(([^)\s]+?)\)/,new RegExp("\\*\\*\\*(?!\\s)([^*]+?)(?<!\\s)\\*\\*\\*"),new RegExp("\\*\\*(?!\\s)([\\s\\S]+?)(?<!\\s)\\*\\*"),new RegExp("~~(?!\\s)([^~]+?)(?<!\\s)~~"),new RegExp("~(?!\\s)([^~]+?)(?<!\\s)~"),new RegExp("\\*(?!\\s)([^*]+?)(?<!\\s)\\*"),new RegExp("(?<![A-Za-z0-9])_(?!\\s)([^_]+?)(?<!\\s)_(?![A-Za-z0-9])")].map(e=>e.source).join("|"),"g"),Wi=(e,t)=>e.map(n=>({...n,marks:[...n.marks||[],t]}));function wo(e){const t=[];let n="";const r=()=>{n&&(t.push({type:"text",text:n}),n="")},s=new RegExp(Lre.source,"g");let o=0,i;for(;(i=s.exec(e))!==null;){if(n+=e.slice(o,i.index),i[1]!==void 0)n+=i[1];else if(i[2]!==void 0)r(),t.push({type:"text",text:i[2],marks:[{type:"code"}]});else if(i[3]!==void 0)r(),t.push(...Wi(wo(i[3]),{type:"underline"}));else if(i[4]!==void 0){const a=/^(https?:|mailto:|\/)/i.test(i[5])?i[5]:"#";r(),t.push(...Wi(wo(i[4]),{type:"link",attrs:{href:a}}))}else i[6]!==void 0?(r(),t.push(...Wi(Wi(wo(i[6]),{type:"bold"}),{type:"italic"}))):i[7]!==void 0?(r(),t.push(...Wi(wo(i[7]),{type:"bold"}))):i[8]!==void 0||i[9]!==void 0?(r(),t.push(...Wi(wo(i[8]??i[9]),{type:"strike"}))):(r(),t.push(...Wi(wo(i[10]??i[11]),{type:"italic"})));o=s.lastIndex}return n+=e.slice(o),r(),t}function jO(e){const t=[];for(const n of wo(e.join(`
|
|
828
|
+
`))){if(n.type!=="text"||!(n.text||"").includes(`
|
|
829
|
+
`)){t.push(n);continue}n.text.split(`
|
|
830
|
+
`).forEach((r,s)=>{s&&t.push({type:"hardBreak"}),r&&t.push({...n,text:r})})}return t}function kb(e){const t=e.match(Mre);if(t)return{indent:t[1].length,ordered:!0,n:Number.parseInt(t[0].trim(),10)||1,text:t[2].trim(),extra:[]};const n=e.match(Tre);if(!n)return null;const r=(n[2]??"").trim(),s=r.match(Rre);return s?{indent:n[1].length,ordered:!1,checked:s[1].toLowerCase()==="x",text:(s[2]??"").trim(),extra:[]}:{indent:n[1].length,ordered:!1,text:r,extra:[]}}function $re(e,t,n){const r=[];let s=t;for(;s<e.length;){const o=e[s],i=kb(o);if(i){r.push(i),s++;continue}if(o.trim()===""){let a=s;for(;a<e.length&&e[a].trim()==="";)a++;const c=a<e.length?e[a]:"";if(a<e.length&&(kb(c)||/^\s{2,}\S/.test(c)&&r.length)){s=a;continue}break}if(/^\s{2,}\S/.test(o)&&r.length){r[r.length-1].extra.push(o.trim()),s++;continue}break}return n(s),r}function Pre(e){let t=0;const n=r=>{const s=[];let o=null,i="";const a=e[t].indent;for(;t<e.length&&e[t].indent>=r;){const c=e[t];if(c.indent>=a+2){const f=n(a+2),p=o==null?void 0:o.content[o.content.length-1];p?p.content.push(...f):s.push(...f);continue}const u=c.checked!==void 0?"taskList":c.ordered?"orderedList":"bulletList";(!o||i!==u)&&(o=u==="orderedList"&&(c.n??1)!==1?{type:u,attrs:{start:c.n},content:[]}:{type:u,content:[]},i=u,s.push(o));const d=jO([c.text,...c.extra]),h=d.length?{type:"paragraph",content:d}:{type:"paragraph"};o.content.push(c.checked!==void 0?{type:"taskItem",attrs:{checked:c.checked},content:[h]}:{type:"listItem",content:[h]}),t++}return s};return n(0)}function kh(e){const t=Ere(e??"").split(`
|
|
831
|
+
`),n=[];let r=0,s=0;const o=()=>{if(n.length)for(let u=1;u<s;u++)n.push({type:"paragraph"});s=0},i=(...u)=>{o(),n.push(...u)};let a=[];const c=()=>{if(!a.length)return;const u=[];let d=[],h=0;for(const f of a){if(f.trim()===""){h+=1;continue}h&&(d.length&&(u.push(d),d=[]),u.push(h),h=0),d.push(f)}d.length&&u.push(d),a=[];for(const f of u)typeof f=="number"?(s=f,o()):i({type:"paragraph",content:jO(f)});s=h};for(;r<t.length;){const u=t[r],d=u.match(Ire);if(d){c();const p=d[1]||null,m=[];for(r++;r<t.length&&!/^```\s*$/.test(t[r]);)m.push(t[r]),r++;r++,i({type:"codeBlock",attrs:{language:p},content:m.length?[{type:"text",text:m.join(`
|
|
832
|
+
`)}]:void 0});continue}const h=u.match(Are);if(h){c(),i({type:"heading",attrs:{level:Math.min(3,h[1].length)},content:wo(h[2].trim())}),r++;continue}if(Dre.test(u)&&u.trim().startsWith("---")){c(),i({type:"horizontalRule"}),r++;continue}const f=u.match(Ore);if(f){c(),i({type:"image",attrs:{alt:f[1]||null,src:f[2]}}),r++;continue}if(kb(u)){c();const p=$re(t,r,m=>{r=m});i(...Pre(p));continue}if(ey.test(u)){c();const p=[];for(;r<t.length&&ey.test(t[r]);)p.push(t[r].match(ey)[1]),r++;const m=kh(p.join(`
|
|
833
|
+
`)).content;i({type:"blockquote",content:m.length?m:[{type:"paragraph"}]});continue}if(RN.test(u)&&r+1<t.length&&IN.test(t[r+1])){c();const p=DN(u);r+=2;const m=[];for(;r<t.length&&RN.test(t[r])&&!IN.test(t[r]);)m.push(DN(t[r])),r++;const w=b=>x=>({type:b,content:[{type:"paragraph",content:wo(x)}]});i({type:"table",content:[{type:"tableRow",content:p.map(w("tableHeader"))},...m.map(b=>({type:"tableRow",content:p.map((x,v)=>w("tableCell")(b[v]??""))}))]});continue}a.push(u),r++}return c(),{type:"doc",content:n.length?n:[{type:"paragraph"}]}}function ty(e,t,n=t){const r=e.match(/^(\s*)([\s\S]*?)(\s*)$/);return r[2]?`${r[1]}${t}${r[2]}${n}${r[3]}`:e}const ON=["underline","strike","bold","italic","link"];function LN(e,t){var r;const n=(e.marks||[]).find(s=>s.type===t);return n?t==="link"?`link:${((r=n.attrs)==null?void 0:r.href)??""}`:t:null}function zre(e,t,n){return e==="italic"?ty(t,"*"):e==="bold"?ty(t,"**"):e==="strike"?ty(t,"~~"):e==="underline"?`<u>${t}</u>`:`[${t}](${n})`}function CO(e,t){if(t>=ON.length)return e.map(s=>{if(s.type==="hardBreak")return`
|
|
834
|
+
`;const o=s.text||"";return(s.marks||[]).some(i=>i.type==="code")?"`"+o+"`":o}).join("");const n=ON[t];let r="";for(let s=0;s<e.length;){if(e[s].type==="hardBreak"){r+=`
|
|
835
|
+
`,s+=1;continue}const o=LN(e[s],n);let i=s+1;for(;i<e.length&&(e[i].type==="hardBreak"||LN(e[i],n)===o);)i+=1;for(;i-1>s&&e[i-1].type==="hardBreak";)i-=1;const a=e.slice(s,i),c=CO(a,t+1);r+=o===null?c:zre(n,c,o.slice(5)),s=i}return r}function nu(e){if(!Array.isArray(e))return"";let t="",n=[];const r=()=>{n.length&&(t+=CO(n,0),n=[])};for(const s of e){if(s.type!=="text"&&s.type!=="hardBreak"){r(),t+=nu(s.content);continue}n.push(s)}return r(),t}function Fre(e){const t=e.match(/`{3,}/g),n=t?Math.max(...t.map(r=>r.length)):0;return"`".repeat(Math.max(3,n+1))}const NO=new Set(["bulletList","orderedList","taskList"]);function EO(e,t){const n=[];return(e.content||[]).forEach((r,s)=>{var u,d;const o=e.type==="orderedList"?`${(((u=e.attrs)==null?void 0:u.start)??1)+s}. `:e.type==="taskList"?`- [${(d=r.attrs)!=null&&d.checked?"x":" "}] `:"- ",i=t+" ".repeat(o.length);let a=!1;const c=h=>{n.push(t+o+h),a=!0};for(const h of r.content||[])if(NO.has(h.type))a||c(""),n.push(EO(h,i));else for(const f of nu(h.content).split(`
|
|
836
|
+
`))a?f&&n.push(i+f):c(f);a||c("")}),n.map(r=>r.replace(/\s+$/,"")).join(`
|
|
837
|
+
`)}const $N="";function vh(e){var s,o,i;const t=[];for(const a of(e==null?void 0:e.content)||[])if(a.type==="heading"){const c=nu(a.content);c.trim()&&t.push(`${"#".repeat(Math.min(6,((s=a.attrs)==null?void 0:s.level)||1))} ${c}`)}else if(NO.has(a.type)){const c=EO(a,"");c.trim()&&t.push(c)}else if(a.type==="codeBlock"){const c=(a.content||[]).map(d=>d.text||"").join(""),u=Fre(c);t.push(`${u}${((o=a.attrs)==null?void 0:o.language)||""}
|
|
838
|
+
${c}
|
|
839
|
+
${u}`)}else if(a.type==="blockquote"){const c=vh(a).trim();c&&t.push(c.split(`
|
|
840
|
+
`).map(u=>u?`> ${u}`:">").join(`
|
|
841
|
+
`))}else if(a.type==="horizontalRule")t.push("---");else if(a.type==="image")(i=a.attrs)!=null&&i.src&&t.push(``);else if(a.type==="table"){const c=a.content||[],u=h=>(h.content||[]).map(f=>nu(f.content)).join(" ").replace(/\n/g," ").replace(/\|/g,"\\|").trim(),d=[];c.forEach((h,f)=>{const p=h.content||[];d.push(`| ${p.map(u).join(" | ")} |`),f===0&&d.push(`|${p.map(()=>" --- ").join("|")}|`)}),d.length&&t.push(d.join(`
|
|
842
|
+
`))}else{const c=nu(a.content);c.trim()?t.push(c):a.type==="paragraph"&&t.push($N)}let n="",r=0;for(const a of t){if(a===$N){n&&(r+=1);continue}n&&(n+=`
|
|
843
|
+
|
|
844
|
+
`+`
|
|
845
|
+
`.repeat(r)),n+=a,r=0}return n+(n?`
|
|
846
|
+
`:"")}function Gf(e){return e.split(`
|
|
847
|
+
`)}function Bre(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;return n}function _re(e,t,n){let r=0;for(;r<e.length-n&&r<t.length-n&&e[e.length-1-r]===t[t.length-1-r];)r+=1;return r}function Wre(e,t){if(e===t)return null;const n=Gf(e),r=Gf(t),s=Bre(n,r),o=_re(n,r,s);return{from:s,to:n.length-o,insert:r.slice(s,r.length-o)}}function Hre(e,t){const n=a=>{const c=new Map;return a.forEach(u=>{u.trim()&&c.set(u,(c.get(u)??0)+1)}),c},r=n(e),s=n(t),o=new Map;t.forEach((a,c)=>{s.get(a)===1&&o.set(a,c)});const i=[];return e.forEach((a,c)=>{if(r.get(a)!==1)return;const u=o.get(a);u!==void 0&&(i.length&&u<=i[i.length-1][1]||i.push([c,u]))}),i}function PN(e,t,n,r){let s=[0,0],o=[n,r];for(const c of t)if(c[0]<e)s=c;else{o=c;break}const i=o[0]-s[0],a=o[1]-s[1];return i!==a?null:s[1]+(e-s[0])}function Ure(e,t,n){if(t===n)return e;if(e===t)return n;const r=Wre(t,n);if(!r)return e;const s=Gf(t),o=Gf(e),i=Hre(s,o),a=PN(r.from,i,s.length,o.length),c=PN(r.to,i,s.length,o.length);return a===null||c===null||c<a?null:[...o.slice(0,a),...r.insert,...o.slice(c)].join(`
|
|
848
|
+
`)}function Kre(e){return!e||typeof e.key!="string"?!1:e.key==="Escape"?!0:!!(e.metaKey||e.ctrlKey)}function Vre(e){return!e||typeof e.key!="string"?null:e.key==="Escape"?"close":(e.meta||e.ctrl)&&e.key.toLowerCase()==="k"?"palette":Yre({key:e.key,meta:e.meta,control:e.ctrl,alt:e.alt})?"app":null}const qre=new Set(["e","j","k","r","c","n","s","z","b","g","/","\\"]);function Yre(e){return!e||typeof e.key!="string"||e.meta||e.control||e.alt?!1:qre.has(e.key.toLowerCase())}const Gre=900;function Jre(e){const t=e.trim();return t?/^(https?:|mailto:)/i.test(t)?t:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:`https://${t}`:""}function Xre(e){return e.replace(/^https?:\/\//i,"").replace(/^mailto:/i,"")}function Qre({product:e,src:t,text:n,mtime:r,onSaved:s,onNotice:o}){const i=g.useRef(n),a=g.useRef(vh(kh(n))),c=g.useRef(r),u=g.useRef(!1),d=g.useRef(null);g.useEffect(()=>{c.current=r},[r]);const h=g.useMemo(()=>Nre("Write anything…"),[]),f=Lee({extensions:h,content:kh(n),editable:!0,onUpdate:()=>{u.current=!0,d.current!=null&&window.clearTimeout(d.current),d.current=window.setTimeout(p,Gre)}}),p=async()=>{if(!f||!u.current)return;const T=vh(f.getJSON());if(T===a.current){u.current=!1;return}u.current=!1;const W=Ure(i.current,a.current,T),le=W??T,ge=await q.writeDoc({product:e,src:t,text:le,mtime:c.current});ge.ok?(i.current=le,a.current=T,c.current=ge.mtime??0,s(ge.mtime??0),W===null&&o("Saved. The rest of the file was reformatted as well.")):(u.current=!0,o(ge.error??"That could not be saved."))};g.useEffect(()=>{if(!f||n===i.current||u.current)return;const T=kh(n);i.current=n,a.current=vh(T),f.commands.setContent(T)},[n,f]),g.useEffect(()=>{const T=W=>{if(!(W.metaKey||W.ctrlKey)||W.key!=="s"&&W.key!=="S")return;W.preventDefault(),d.current!=null&&(window.clearTimeout(d.current),d.current=null);const le=u.current;Promise.resolve(p()).then(()=>{le&&!u.current&&o("Saved.")})};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[f]),g.useEffect(()=>{const T=()=>{p()};return window.addEventListener("blur",T),()=>{window.removeEventListener("blur",T),d.current!=null&&window.clearTimeout(d.current),T()}},[f]);const[m,w]=g.useState(null),[b,x]=g.useState(!1),[v,S]=g.useState(""),[C,O]=g.useState(!1),N=g.useRef(null),P=()=>{N.current!=null&&(window.clearTimeout(N.current),N.current=null)},M=()=>{P(),N.current=window.setTimeout(()=>w(T=>T!=null&&T.pinned?T:null),140)},R=(T,W)=>{if(!f)return;const le=T.getAttribute("href")||"",ge=T.getBoundingClientRect();let j=0;try{j=f.view.posAtDOM(T,0)}catch{j=0}P(),x(!1),O(!1),w({href:le,left:Math.max(8,Math.min(ge.left,window.innerWidth-340)),top:ge.bottom+6,pos:j,pinned:W})},L=T=>{var W,le;return(le=(W=T.target).closest)==null?void 0:le.call(W,"a")},H=()=>{if(!m)return;const T=m.href;q.openArtifactExternally({product:e,src:T}).then(W=>{W.ok||o(W.error??"That link could not be opened.")}),w(null)},_=async()=>{if(m)try{await navigator.clipboard.writeText(m.href),O(!0),window.setTimeout(()=>O(!1),1200)}catch{}},Y=()=>{m&&(S(m.href),x(!0),w({...m,pinned:!0}))},se=()=>{if(!m||!f)return;const T=Jre(v);T&&(f.chain().focus().setTextSelection(m.pos).extendMarkRange("link").setLink({href:T}).run(),w({...m,href:T})),x(!1)},re=()=>{!m||!f||(f.chain().focus().setTextSelection(m.pos).extendMarkRange("link").unsetLink().run(),w(null),x(!1))};return g.useEffect(()=>{if(!(m!=null&&m.pinned))return;const T=le=>{var j,ae;const ge=le.target;(j=ge.closest)!=null&&j.call(ge,".link-pop")||(ae=ge.closest)!=null&&ae.call(ge,"a")||(w(null),x(!1))},W=le=>{le.key==="Escape"&&(le.stopPropagation(),w(null),x(!1))};return document.addEventListener("mousedown",T),document.addEventListener("keydown",W,!0),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("keydown",W,!0)}},[m==null?void 0:m.pinned]),l.jsxs("div",{className:"doc-rich markdown",onKeyDown:T=>{if(T.key==="Escape"){T.preventDefault(),T.stopPropagation(),f==null||f.commands.blur();return}Kre(T)||T.stopPropagation()},onMouseOver:T=>{const W=L(T);W&&(P(),!b&&(m&&m.href===(W.getAttribute("href")||"")||R(W,(m==null?void 0:m.pinned)??!1)))},onMouseOut:T=>{L(T)&&M()},onClick:T=>{const W=L(T);W&&(T.preventDefault(),R(W,!0))},children:[l.jsx(Cee,{editor:f,className:"doc-rich-content"}),m&&bs.createPortal(l.jsx("div",{className:"link-pop",style:{left:m.left,top:m.top},onMouseEnter:P,onMouseLeave:M,children:b?l.jsxs("div",{className:"link-pop-edit",children:[l.jsx("input",{autoFocus:!0,value:v,placeholder:"Paste or type a link",onChange:T=>S(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),se()),T.key==="Escape"&&(T.preventDefault(),x(!1))}}),l.jsx("button",{type:"button",className:"link-pop-btn",onClick:se,children:"Save"})]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"link-pop-url",title:m.href,onClick:H,children:Xre(m.href)||"link"}),l.jsxs("span",{className:"link-pop-actions",children:[l.jsx("button",{type:"button",className:"link-pop-btn",onClick:H,children:"Visit"}),l.jsx("button",{type:"button",className:"link-pop-btn",onClick:_,children:C?"Copied":"Copy"}),l.jsx("button",{type:"button",className:"link-pop-btn",onClick:Y,children:"Edit"}),l.jsx("button",{type:"button",className:"link-pop-btn",onClick:re,children:"Remove"})]})]})}),document.body)]})}function Zre(e){if(e.length<2)return null;const t=e.map((n,r)=>n?-1:r).filter(n=>n>=0);return t.length?t:e.map((n,r)=>r)}function ese(e,t,n){if(!e.length)return"";if(e.length===1){const o=e[0],i=Math.max(0,Math.min(t,o.length)),a=Math.max(i,Math.min(n,o.length));return o.slice(i,a)}const r=e[0],s=e[e.length-1];return[r.slice(Math.max(0,Math.min(t,r.length))),...e.slice(1,-1),s.slice(0,Math.max(0,Math.min(n,s.length)))].join(`
|
|
849
|
+
`)}function tse(e){return e.filter(([t])=>t!=="-").map(([,t])=>t)}function nse(e){const n=String(e??"").split(`
|
|
850
|
+
`),r=n.length>1&&n[n.length-1]==="";return r&&n.pop(),{lines:n,trailing:r}}function rse(e,t){const n=[];if(!t.length||t.length>e.length)return n;for(let r=0;r+t.length<=e.length;r++){let s=!0;for(let o=0;o<t.length;o++)if(e[r+o]!==t[o]){s=!1;break}s&&n.push(r)}return n}function sse(e,t){const{lines:n,trailing:r}=nse(e);let s=n.slice(),o=0;const i=t.filter(c=>c.edits.size>0);if(!i.length)return{ok:!0,text:e,lines:0};const a=[];for(const c of i){const u=tse(c.rows);if(!u.length)return{ok:!1,error:"Those lines were removed by the run, so there is nothing in the file to save them onto."};const d=c.rows.map((f,p)=>({row:f,i:p})).filter(({row:f})=>f[0]!=="-").map(({row:f,i:p})=>c.edits.has(p)?c.edits.get(p):f[1]),h=rse(s,u);if(!h.length)return{ok:!1,error:"The file has changed since this run, so those lines are not in it any more. Nothing was saved."};a.push({at:h[0],before:u,after:d}),o+=[...c.edits.keys()].length}a.sort((c,u)=>u.at-c.at);for(const c of a){if(s.slice(c.at,c.at+c.before.length).join(`
|
|
851
|
+
`)!==c.before.join(`
|
|
852
|
+
`))return{ok:!1,error:"Two of those edits overlap in the file, so nothing was saved."};s=[...s.slice(0,c.at),...c.after,...s.slice(c.at+c.before.length)]}return{ok:!0,text:s.join(`
|
|
853
|
+
`)+(r?`
|
|
854
|
+
`:""),lines:o}}function ose(e,t){return`Saved ${e.split("/").pop()||e}, ${t} line${t===1?"":"s"}.`}function ny(e){return[...e.entries()].filter(([,t])=>[...t.values()].some(n=>n.size>0)).map(([t])=>t)}function ise(){return[...document.querySelectorAll(".code-body .code-line")].filter(e=>e.isContentEditable)}function ry(e){const t=window.getSelection();if(!t||!t.focusNode||!e.contains(t.focusNode))return 0;const n=document.createRange();return n.selectNodeContents(e),n.setEnd(t.focusNode,t.focusOffset),n.toString().length}function Sh(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=t,s=null,o=0;for(let i=n.nextNode();i;i=n.nextNode()){s=i;const a=i.data.length;if(r<=a){o=r;break}r-=a,o=a}return s?{node:s,offset:Math.min(o,s.data.length)}:{node:e,offset:0}}function ase(e,t){e.focus();const{node:n,offset:r}=Sh(e,t),s=document.createRange();s.setStart(n,r),s.collapse(!0);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(s),e.scrollIntoView({block:"nearest"})}const zN=new Map;function lse(e,t){const n=`${e}
|
|
855
|
+
${t}`,r=zN.get(n);if(r)return r;const s=new Map;return zN.set(n,s),s}function vb(){return[...document.querySelectorAll(".code-body .code-line")]}function FN(){const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return 0;const t=e.getRangeAt(0);return vb().filter(n=>t.intersectsNode(n)).length}function sy(e,t,n){if(!e.contains(t))return 0;const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function cse({line:e,span:t}){const n=g.useMemo(()=>yP(rA(e),t??null),[e,t==null?void 0:t[0],t==null?void 0:t[1]]);return l.jsx(l.Fragment,{children:n.map((r,s)=>r.hl?l.jsx("span",{className:r.c?`w-chg t-${r.c}`:"w-chg",children:r.s},s):r.c?l.jsx("span",{className:`t-${r.c}`,children:r.s},s):r.s)})}function BN({plus:e,minus:t}){return l.jsxs("span",{className:"code-counts",children:[e>0&&l.jsxs("span",{className:"code-plus",children:["+",e]}),t>0&&l.jsxs("span",{className:"code-minus",children:["−",t]})]})}const AO=g.memo(function({mark:t,line:n,span:r,num:s,editable:o,onEdit:i,onDone:a}){return l.jsxs("div",{className:`code-row${t==="+"?" cr-plus":t==="-"?" cr-minus":""}${o?" cr-live":""}`,children:[l.jsx("span",{className:"code-num","aria-hidden":"true",children:s??""}),l.jsx("span",{className:"code-mark","aria-hidden":"true",children:t==="="?"":t==="+"?"+":"−"}),l.jsx("span",{className:"code-line",contentEditable:o||void 0,suppressContentEditableWarning:o,spellCheck:!1,onInput:o?c=>i(c.currentTarget.textContent??""):void 0,onBlur:o?a:void 0,onKeyDown:o?c=>{c.key==="Enter"&&c.preventDefault(),c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),c.currentTarget.blur())}:void 0,onPaste:o?c=>{c.preventDefault();const u=c.clipboardData.getData("text/plain").replace(/[\r\n]+/g," ");document.execCommand("insertText",!1,u)}:void 0,children:l.jsx(cse,{line:n,span:r})})]})},(e,t)=>{var n,r,s,o;return e.mark===t.mark&&e.line===t.line&&e.num===t.num&&e.editable===t.editable&&((n=e.span)==null?void 0:n[0])===((r=t.span)==null?void 0:r[0])&&((s=e.span)==null?void 0:s[1])===((o=t.span)==null?void 0:o[1])});function use({hunk:e,editable:t,pending:n,onEdit:r,onDone:s}){const{rows:o}=g.useMemo(()=>wP(e.rows),[e.rows]),i=g.useMemo(()=>bP(e.rows),[e.rows]),a=g.useMemo(()=>gP(e.rows),[e.rows]),c=(d,h,f)=>{var x;const p=(d==="-"||n==null?void 0:n.get(i[f]))??h,m=p===h?a[i[f]]:null,w=(x=e.nums)==null?void 0:x[i[f]],b=(d==="-"?w==null?void 0:w[0]:w==null?void 0:w[1])??null;return l.jsx(AO,{mark:d,line:p,span:m,num:b,editable:t&&d!=="-",onEdit:v=>r(i[f],v),onDone:s},`${i[f]}:${h}`)},u=g.useMemo(()=>vP(o.length),[o.length]);return l.jsx("div",{className:"code-hunk",children:u.map(([d,h])=>l.jsx("div",{className:"code-slice",style:{containIntrinsicSize:`auto ${sA(h-d)}px`},children:o.slice(d,h).map(([f,p],m)=>c(f,p,d+m))},d))})}const dse=g.memo(function({file:t,pending:n,onEdit:r,onDone:s,readFile:o,onNotice:i,gaps:a}){const[c,u]=g.useState(()=>new Map(a)),d=async h=>{const f=await o(t.path);if(!f.ok||typeof f.text!="string"){i(f.error??`${t.path} could not be read.`);return}const p=kP(f.text,t.hunks[h-1],t.hunks[h]);if(!p.ok){i(p.error);return}a.set(h,{from:p.from,lines:p.lines}),u(new Map(a))};return l.jsx(l.Fragment,{children:t.hunks.map((h,f)=>l.jsxs("div",{className:"code-hunk-block",children:[f>0&&c.has(f)?l.jsx("div",{className:"code-gap-lines",children:c.get(f).lines.map((p,m)=>l.jsx(AO,{mark:"=",line:p,num:c.get(f).from+m,editable:!1,onEdit:()=>{},onDone:()=>{}},m))}):f>0&&I0(t.hunks[f-1],h)!==null&&l.jsx("button",{type:"button",className:"code-skip",title:"Show these lines",onClick:()=>{d(f)},children:l.jsxs("span",{children:[I0(t.hunks[f-1],h)," lines not shown"]})}),l.jsx(use,{hunk:h,editable:!0,pending:(n==null?void 0:n.get(f))??null,onEdit:(p,m)=>r(t.path,f,p,m),onDone:s})]},f))})});function hse({product:e,src:t,change:n,startAt:r=null,startAtFrom:s=0,onFileAt:o,onNotice:i}){var Ie;const a=g.useMemo(()=>NP(n.files??[]),[n.files]),c=g.useMemo(()=>tA(a),[a]),[u,d]=g.useState(()=>new Set),h=g.useMemo(()=>iP(c,u),[c,u]),f=g.useMemo(()=>h.filter(Q=>Q.kind==="file"),[h]),[p,m]=g.useState(0),w=g.useRef(null),b=g.useRef(new Map),x=g.useRef(null),v=g.useRef(new Map),S=g.useRef(!1),C=g.useRef(null),O=g.useRef(null),N=g.useRef(null),P=a[Math.min(p,Math.max(0,a.length-1))],[M,R]=g.useState(0),L=g.useRef(0),[H,_]=g.useState(()=>new Set(L0(e,t))),Y=(Q,he)=>{const te=w.current,ee=te&&he?he.getBoundingClientRect().top-te.getBoundingClientRect().top:0;if(H.has(Q)){const I=le.current.get(Q);ge.current.set(Q,new Map([...I??new Map].map(([V,ue])=>[V,new Map(ue)])))}const U=L0(e,t);U.has(Q)?U.delete(Q):U.add(Q),_(I=>EP(I,Q)),te&&he&&ee<0&&requestAnimationFrame(()=>{te.scrollTop+=he.getBoundingClientRect().top-te.getBoundingClientRect().top})},se=Q=>{const he=a.findIndex(te=>te.path===Q);he<0||(S.current=!1,m(he),R(te=>te+1))},[re,T]=g.useState(()=>{const Q=Math.max(0,a.findIndex(he=>he.path===r));return new Set(Array.from({length:CP(a,0)},(he,te)=>te).concat(Q))}),W=p;g.useEffect(()=>{if(re.size>=a.length)return;const Q=jP(a,re,Math.max(0,W),oA),he=Q.includes(Math.max(0,W)),te=()=>T(I=>new Set([...I,...Q])),ee=window;if(ee.requestIdleCallback){const I=ee.requestIdleCallback(te,he?{timeout:60}:void 0);return()=>{var V;return(V=ee.cancelIdleCallback)==null?void 0:V.call(ee,I)}}const U=setTimeout(te,0);return()=>clearTimeout(U)},[re,a,W]);const le=g.useRef(lse(e,t)),ge=g.useRef(new Map([...le.current].map(([Q,he])=>[Q,new Map([...he].map(([te,ee])=>[te,new Map(ee)]))]))),[j,ae]=g.useState(0),[me,E]=g.useState(!1),K=g.useCallback((Q,he,te,ee)=>{const U=ny(le.current).length,I=le.current.get(Q)??new Map,V=I.get(he)??new Map;V.set(te,ee),I.set(he,V),le.current.set(Q,I),ny(le.current).length!==U&&ae(ue=>ue+1)},[]),z=g.useCallback(()=>ae(Q=>Q+1),[]),xe=g.useRef(i);xe.current=i;const Oe=g.useCallback(Q=>xe.current(Q),[]),F=g.useCallback(Q=>q.codeFile({product:e,src:t,path:Q}),[e,t]),J=g.useRef(new Map),ze=Q=>{let he=J.current.get(Q);return he||(he=new Map,J.current.set(Q,he)),he},ye=()=>ny(le.current),Z=g.useCallback(async()=>{var te;const Q=ye();if(!Q.length||me)return;E(!0);const he=[];try{for(const ee of Q){const U=a.find(we=>we.path===ee),I=le.current.get(ee);if(!U||!I)continue;const V=await q.codeFile({product:e,src:t,path:ee});if(!V.ok||typeof V.text!="string"){i(V.error??`${ee} could not be opened, so nothing was saved.`);continue}const ue=[...I.entries()].filter(([,we])=>we.size>0).map(([we,ve])=>{var de;return{hunk:we,rows:((de=U.hunks[we])==null?void 0:de.rows)??[],edits:ve}}),G=sse(V.text,ue);if(!G.ok){i(G.error);continue}if(G.text===V.text){le.current.delete(ee);continue}const ie=await q.saveCodeFile({product:e,src:t,path:ee,text:G.text,mtime:V.mtime??0});if(!ie.ok){i(ie.error??`${ee} could not be saved.`);continue}for(const[we,ve]of I.entries()){const de=(te=U.hunks[we])==null?void 0:te.rows;if(de)for(const[be,Le]of ve.entries())de[be]&&(de[be][1]=Le)}le.current.delete(ee),he.push(ose(ee,G.lines))}}finally{E(!1),ae(ee=>ee+1)}he.length&&i(he.join(" "))},[a,e,n,me,i]);g.useEffect(()=>{const Q=te=>{var G,ie,we,ve,de,be,Le,Ye,at;if((te.metaKey||te.ctrlKey)&&(te.key==="s"||te.key==="S")){te.preventDefault(),(ie=(G=te.target)==null?void 0:G.blur)==null||ie.call(G),Z();return}const ee=te.target,U=String((ee==null?void 0:ee.tagName)??"").toUpperCase();if(te.shiftKey&&!te.metaKey&&!te.altKey&&!te.ctrlKey&&nP(te.key)){const Ge=vb(),Ke=O.current,rt=Ke?Ge[Ke.head.line]:(we=ee==null?void 0:ee.closest)==null?void 0:we.call(ee,".code-line"),gt=Ke?Ke.head.line:Ge.indexOf(rt);if(rt&>>=0){const Ve=Ke?Ke.anchor:{line:gt,col:ee!=null&&ee.isContentEditable?ry(rt):0},Ln=Ke?Ke.head:{line:gt,col:ry(rt)},ln=tP(te.key,Ln,Ge.map(Sn=>(Sn.textContent??"").length));if(ln){te.preventDefault(),O.current={anchor:Ve,head:ln},ln.line!==Ve.line&&((de=(ve=document.activeElement)==null?void 0:ve.blur)==null||de.call(ve));const Sn=Sh(Ge[Ve.line],Ve.col),Ys=Sh(Ge[ln.line],ln.col);(be=window.getSelection())==null||be.setBaseAndExtent(Sn.node,Sn.offset,Ys.node,Ys.offset),Ge[ln.line].scrollIntoView({block:"nearest"});return}}}if(FN()>1&&sP(te.key,{meta:te.metaKey,ctrl:te.ctrlKey,alt:te.altKey})){te.preventDefault();return}te.shiftKey||(O.current=null);const I=(Le=ee==null?void 0:ee.closest)==null?void 0:Le.call(ee,".code-line");if(I&&(ee!=null&&ee.isContentEditable)){const Ge=I.textContent??"",Ke=eP(te.key,{col:ry(I),len:Ge.length},{shift:te.shiftKey,meta:te.metaKey});if(!Ke)return;const rt=ise(),gt=rt.indexOf(I),Ve=rt[gt+Ke.move];if(gt<0||!Ve){(te.key==="ArrowUp"||te.key==="ArrowDown")&&te.preventDefault();return}te.preventDefault(),z(),ase(Ve,Ke.col===1/0?(Ve.textContent??"").length:Ke.col);return}if(U==="INPUT"||U==="TEXTAREA"||ee!=null&&ee.isContentEditable||te.ctrlKey||te.altKey)return;if((te.key==="]"||te.key==="[")&&!te.metaKey){const Ge=w.current;if(Ge){te.preventDefault();const Ke=Ge.getBoundingClientRect().top,rt=((Ye=Ge.querySelector(".code-file-head"))==null?void 0:Ye.offsetHeight)??0,gt=[...Ge.querySelectorAll(".code-hunk, .code-unfilled")].map(Ln=>Ln.getBoundingClientRect().top-Ke+Ge.scrollTop-rt),Ve=J$(gt,Ge.scrollTop,te.key==="]"?1:-1);Ve!=null&&(Ge.scrollTop=Math.max(0,Ve))}return}if(!!((at=ee==null?void 0:ee.closest)!=null&&at.call(ee,".code-tree"))&&!te.metaKey){const Ge=AP(te.key,(P==null?void 0:P.path)??null,f.map(Ke=>Ke.path),a.map(Ke=>Ke.path));if(Ge!=null){te.preventDefault(),se(Ge);return}}const ue=w.current;if(ue){const Ge=ue.querySelector(".code-row"),Ke=Q$(te.key,{row:Ge?Math.round(Ge.getBoundingClientRect().height):19,view:ue.clientHeight,top:ue.scrollTop,max:ue.scrollHeight-ue.clientHeight},{meta:te.metaKey});if(Ke!=null){te.preventDefault(),ue.scrollTop=Ke;return}}te.metaKey},he=te=>{const ee=te.inputType??"";oP(ee)&&FN()>1&&te.preventDefault()};return window.addEventListener("keydown",Q),window.addEventListener("beforeinput",he,!0),()=>{window.removeEventListener("keydown",Q),window.removeEventListener("beforeinput",he,!0)}},[f,a,P==null?void 0:P.path,p,Z,z]),g.useEffect(()=>{const Q=w.current;if(!Q)return;let he=null,te=!1;const ee=(G,ie)=>{const we=document;return we.caretRangeFromPoint?we.caretRangeFromPoint(G,ie):null},U=G=>{var be,Le,Ye,at,Ge;if(he=null,te=!1,G.button!==0||G.detail>1)return;const ie=G.target,we=(be=ie==null?void 0:ie.closest)==null?void 0:be.call(ie,".code-line");if(G.shiftKey&&N.current&&we){const Ke=ee(G.clientX,G.clientY),rt=N.current;if(Ke&&rt.line!==we){G.preventDefault(),(Ye=(Le=document.activeElement)==null?void 0:Le.blur)==null||Ye.call(Le);const gt=Sh(rt.line,rt.col);(at=window.getSelection())==null||at.setBaseAndExtent(gt.node,gt.offset,Ke.startContainer,Ke.startOffset),O.current=null;return}}if(we){const Ke=ee(G.clientX,G.clientY);Ke&&(he={node:Ke.startContainer,offset:Ke.startOffset,line:we}),N.current={line:we,col:Ke?sy(we,Ke.startContainer,Ke.startOffset):0},O.current=null;return}N.current=null,O.current=null;const ve=(Ge=ie==null?void 0:ie.closest)==null?void 0:Ge.call(ie,".code-row"),de=ve==null?void 0:ve.querySelector(".code-line");de&&(he={node:de,offset:0,line:null},N.current={line:de,col:0})},I=G=>{var de,be,Le,Ye;if(!he||!(G.buttons&1))return;const ie=(be=(de=document.elementFromPoint(G.clientX,G.clientY))==null?void 0:de.closest)==null?void 0:be.call(de,".code-line");if(!ie||ie===he.line)return;const we=ee(G.clientX,G.clientY),ve=window.getSelection();!we||!ve||(te||(te=!0,(Ye=(Le=document.activeElement)==null?void 0:Le.blur)==null||Ye.call(Le)),ve.setBaseAndExtent(he.node,he.offset,we.startContainer,we.startOffset),G.preventDefault())},V=()=>{he=null},ue=G=>{var rt;const ie=window.getSelection();if(!ie||ie.rangeCount===0||ie.isCollapsed)return;const we=ie.getRangeAt(0),ve=vb().filter(gt=>we.intersectsNode(gt)),de=Zre(ve.map(gt=>{var Ve;return!!((Ve=gt.closest(".code-row"))!=null&&Ve.classList.contains("cr-minus"))}));if(!de)return;const be=de.map(gt=>ve[gt]),Le=be[0],Ye=be[be.length-1],at=be.map(gt=>gt.textContent??"");let Ge=Le.contains(we.startContainer)?sy(Le,we.startContainer,we.startOffset):0,Ke=Ye.contains(we.endContainer)?sy(Ye,we.endContainer,we.endOffset):at[at.length-1].length;at.length>1&&Ke===0&&(at.pop(),Ke=at[at.length-1].length),at.length>1&&Ge>=at[0].length&&(at.shift(),Ge=0),(rt=G.clipboardData)==null||rt.setData("text/plain",ese(at,Ge,Ke)),G.preventDefault()};return Q.addEventListener("mousedown",U),window.addEventListener("mousemove",I),window.addEventListener("mouseup",V),document.addEventListener("copy",ue,!0),()=>{Q.removeEventListener("mousedown",U),window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",V),document.removeEventListener("copy",ue,!0)}},[]),g.useEffect(()=>{o((P==null?void 0:P.path)??null)},[P==null?void 0:P.path]),g.useEffect(()=>{r&&se(r)},[r,s,a]),g.useEffect(()=>{if(!P)return;const Q=M!==L.current;L.current=M;const he=S.current&&!Q;if(S.current=!1,!he){const U=w.current,I=P.path;if(U&&b.current.get(I)){C.current=I;let V=0,ue=0;const G=()=>{var ve;const ie=(ve=b.current.get(I))==null?void 0:ve.parentElement;if(!U||!ie||C.current!==I){C.current=null;return}const we=ie.getBoundingClientRect().top-U.getBoundingClientRect().top;if(Math.abs(we)<=1)ue+=1;else{ue=0;const de=Math.max(0,U.scrollHeight-U.clientHeight);U.scrollTop=Math.max(0,Math.min(de,U.scrollTop+we))}if(ue>=3||(V+=1)>20){C.current=null;return}requestAnimationFrame(G)};requestAnimationFrame(G)}}const te=x.current,ee=v.current.get(P.path);if(te&&ee){const U=ee.getBoundingClientRect(),I=te.getBoundingClientRect();U.top<I.top?te.scrollTop+=U.top-I.top:U.bottom>I.bottom&&(te.scrollTop+=U.bottom-I.bottom)}},[P==null?void 0:P.path,M]);const Ce=g.useRef([]),Ee=g.useCallback(()=>{const Q=w.current;if(!Q)return;const he=Q.getBoundingClientRect().top;Ce.current=a.map(te=>{var U;const ee=(U=b.current.get(te.path))==null?void 0:U.parentElement;return ee?ee.getBoundingClientRect().top-he+Q.scrollTop:Number.POSITIVE_INFINITY})},[a]);g.useEffect(()=>{const Q=w.current;if(!Q)return;let he=0,te=-1;const ee=()=>{he||(he=requestAnimationFrame(()=>{if(he=0,Q.scrollHeight!==te&&(te=Q.scrollHeight,Ee()),C.current)return;const V=rP(Ce.current,Q.scrollTop);m(ue=>ue===V?ue:(S.current=!0,V))}))},U=()=>{C.current=null},I=V=>{V.defaultPrevented||(C.current=null)};return Q.addEventListener("scroll",ee,{passive:!0}),Q.addEventListener("wheel",U,{passive:!0}),Q.addEventListener("touchstart",U,{passive:!0}),Q.addEventListener("mousedown",U),window.addEventListener("keydown",I),()=>{Q.removeEventListener("scroll",ee),Q.removeEventListener("wheel",U),Q.removeEventListener("touchstart",U),Q.removeEventListener("mousedown",U),window.removeEventListener("keydown",I),he&&cancelAnimationFrame(he)}},[a,Ee]);const oe=cP(n),ne=g.useMemo(()=>new Set(ye()),[j,me]);return l.jsxs("div",{className:"code-artifact",children:[l.jsxs("div",{className:"code-file-pick",children:[l.jsx("select",{className:"code-file-picker","aria-label":"File to review",value:(P==null?void 0:P.path)??((Ie=a[0])==null?void 0:Ie.path)??"",onChange:Q=>se(Q.target.value),children:a.map(Q=>l.jsxs("option",{value:Q.path,children:[Q.path,ne.has(Q.path)?" · Unsaved":""]},Q.path))}),l.jsx("svg",{className:"code-pick-caret",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M4 6l4 4 4-4"})})]}),l.jsxs("div",{className:"code-tree",children:[l.jsxs("div",{className:"code-tree-head",children:[l.jsx("span",{className:"code-tree-count",children:lP(n)}),oe&&l.jsxs("span",{className:"code-tree-took",children:["in ",oe]})]}),l.jsx("div",{className:"code-tree-rows",ref:x,children:h.map(Q=>Q.kind==="folder"?l.jsxs("button",{type:"button",className:`code-node code-folder${u.has(Q.key)?" is-shut":""}`,style:{paddingLeft:12+Q.depth*13},onClick:()=>{const he=new Set(u);he.has(Q.key)?he.delete(Q.key):he.add(Q.key),d(he)},children:[l.jsx("svg",{className:"code-caret",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx("span",{className:"code-node-name",children:Q.label}),l.jsx("span",{className:"code-node-n",children:Q.files})]},Q.key):l.jsxs("button",{type:"button",ref:he=>{v.current.set(Q.path,he)},className:`code-node code-file${(P==null?void 0:P.path)===Q.path?" is-at":""}${H.has(Q.path)?" is-folded":""}`,style:{paddingLeft:12+Q.depth*13},title:Q.path,onClick:()=>se(Q.path),children:[l.jsx("span",{className:"code-node-name",children:Q.label}),ne.has(Q.path)?l.jsx("span",{className:"code-unsaved",title:"Not saved yet. Press ⌘S.",children:"•"}):l.jsx(BN,{plus:Q.plus,minus:Q.minus})]},Q.key))})]}),l.jsx("div",{className:"code-body",ref:w,children:a.map((Q,he)=>l.jsxs("section",{className:"code-file-block",children:[l.jsxs("div",{className:`code-file-head${(P==null?void 0:P.path)===Q.path?" is-at":""}${H.has(Q.path)?" is-folded":""}`,ref:te=>{b.current.set(Q.path,te)},title:H.has(Q.path)?"Show this file":"Fold this file",onClick:te=>Y(Q.path,te.currentTarget.parentElement),children:[l.jsx("svg",{className:"code-fold-caret",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M4 6l4 4 4-4"})}),l.jsx("span",{className:"code-file-name",children:Q.path.split("/").pop()}),l.jsx("span",{className:"code-file-where",children:Q.path.split("/").slice(0,-1).join("/")}),l.jsx(BN,{plus:Q.plus,minus:Q.minus}),ne.has(Q.path)&&l.jsx("span",{className:"code-file-unsaved",title:"Not saved yet. Press ⌘S.",children:"Unsaved"})]}),!H.has(Q.path)&&(re.has(he)?l.jsx(dse,{file:Q,pending:ge.current.get(Q.path)??null,onEdit:K,onDone:z,readFile:F,onNotice:Oe,gaps:ze(Q.path)}):l.jsx("div",{className:"code-unfilled",style:{height:sA(Q.hunks.reduce((te,ee)=>te+ee.rows.length,0))}}))]},Q.path))})]})}function Ak({children:e}){return l.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e})}const fse=()=>l.jsxs(Ak,{children:[l.jsx("path",{d:"M14 4.8h5.2V10"}),l.jsx("path",{d:"M19.2 4.8 11.6 12.4"}),l.jsx("path",{d:"M18.4 14.2v3.6a1.6 1.6 0 0 1-1.6 1.6H6.2a1.6 1.6 0 0 1-1.6-1.6V7.2a1.6 1.6 0 0 1 1.6-1.6h3.6"})]}),pse=()=>l.jsxs(Ak,{children:[l.jsx("path",{d:"M6.6 6.6 17.4 17.4"}),l.jsx("path",{d:"M17.4 6.6 6.6 17.4"})]});function mse({doc:e,roots:t,split:n,onSplit:r,onClose:s,onNotice:o,mode:i,onMode:a,headerTarget:c,focusControlStyle:u}){const d=ka(e.src)??"html",[h,f]=g.useState(null),[p,m]=g.useState(null),[w,b]=g.useState(0),[x,v]=g.useState(null),[S,C]=g.useState(null),O=yG(S),N=S&&O.local?`${S} ${O.attempt}`:S,[P,M]=IT(N),R=O.local?gG(P,O.phase):P,L=O.local&&S?pG(O.phase,S,O.waited):null,[H,_]=g.useState(null),[Y,se]=g.useState(null);g.useEffect(()=>{let K=!0;return f(null),m(null),v(null),b(0),C(null),_(null),Ib(e.src)?(f(e.src),C(e.src),()=>{K=!1}):(q.resolveDoc({product:e.product,src:e.src}).then(z=>{if(K){if(!z.ok||!z.opened){v(z.error??"That file could not be found.");return}f(z.opened),C(z.url??null)}}),d==="code"&&q.codeChange({product:e.product,src:e.src}).then(z=>{if(K){if(!z.ok||!z.change){v(z.error??"That change could not be read.");return}_(z.change)}}),d==="markdown"&&q.readDoc({product:e.product,src:e.src}).then(z=>{if(K){if(!z.ok){v(z.error??"That file could not be read.");return}m(z.text??""),b(z.mtime??0)}}),()=>{K=!1})},[e.product,e.src,d]);const re=g.useRef(null),[T,W]=g.useState(!1),le=K=>{var z;K.preventDefault(),(z=re.current)==null||z.setPointerCapture(K.pointerId),W(!0)},ge=K=>{var xe,Oe;if(!T)return;const z=(Oe=(xe=re.current)==null?void 0:xe.closest(".body"))==null?void 0:Oe.getBoundingClientRect();r(z?eS(K.clientX-z.left,z.width):eS(K.clientX,window.innerWidth))},j=K=>{var z;if(T){try{(z=re.current)==null||z.releasePointerCapture(K.pointerId)}catch{}W(!1)}},ae=TT(h??e.src,t),me=()=>{const K=d==="code"?Y??e.src:e.src;q.openArtifactExternally({product:e.product,src:K}).then(z=>{z.ok||o(z.error??"That file could not be opened.")})},E=l.jsxs("div",{className:"doc-head",children:[l.jsx("div",{className:"doc-crumb",title:h??e.src,children:ae.map((K,z)=>l.jsxs("span",{className:"doc-crumb-part",children:[z>0&&l.jsx("span",{className:"doc-crumb-sep",children:"›"}),l.jsx("span",{className:z===ae.length-1?"doc-crumb-leaf":void 0,children:K})]},`${K}-${z}`))}),l.jsxs("span",{className:"doc-marks",children:[a&&(u?l.jsx(aG,{style:u,focused:!!c,onClick:()=>c?s():a("focus")}):!c&&l.jsxs("button",{type:"button",className:"artifact-expand","aria-label":"Expand preview",title:"Expand preview to Focus",onClick:()=>a("focus"),children:[l.jsx(Ak,{children:l.jsx("path",{d:"M14 5h5v5M19 5l-6 6M10 19H5v-5M5 19l6-6"})}),l.jsx("span",{children:"Focus"})]})),l.jsx("button",{type:"button",className:"doc-mark",title:d==="code"?"Open this file in your editor":`Open outside ${Je}`,onClick:me,children:u?l.jsx($w,{kind:"open"}):l.jsx(fse,{})}),l.jsx("button",{type:"button",className:"doc-mark",title:c?"Exit Focus":"Close this document (esc)",onClick:s,children:u?l.jsx($w,{kind:"close"}):l.jsx(pse,{})})]})]});return l.jsxs("aside",{className:`doc-pane ${d==="html"?"doc-html":d==="code"?"doc-code":d==="image"?"doc-image":"doc-md"}${T?" dragging":""}`,style:{flexBasis:`${n*100}%`},children:[l.jsx("div",{ref:re,className:"doc-grip",role:"separator","aria-orientation":"vertical","aria-label":"Resize the document",onPointerDown:le,onPointerMove:ge,onPointerUp:j,onPointerCancel:j,onDoubleClick:()=>r(ch)}),l.jsxs("div",{className:"doc-card",children:[c?bs.createPortal(E,c):E,x?l.jsx("div",{className:"doc-missing",children:x}):d==="image"?h?l.jsx("img",{className:"doc-view doc-picture",src:vo(h),alt:j_(h),crossOrigin:"anonymous",onError:()=>v("That picture could not be drawn.")}):l.jsx(si,{}):d==="code"?H?l.jsx(hse,{product:e.product,src:e.src,change:H,startAt:e.at??null,startAtFrom:e.atFrom??0,onFileAt:se,onNotice:o}):l.jsx(si,{}):d==="html"?h?S?l.jsxs("div",{className:"preview-frame","aria-busy":!R,children:[O.local?!R&&l.jsx(wG,{status:L,onRetry:O.retry}):l.jsx(si,{ready:R}),(!O.local||O.phase!=="down")&&l.jsx("iframe",{onLoad:M,onError:()=>v("This preview could not be loaded."),style:{opacity:R?1:0},className:"doc-view",src:S,sandbox:O.local?dG:sr()?"allow-scripts":"allow-scripts allow-same-origin",title:ae.join("/")},N)]}):l.jsxs("div",{className:"doc-missing",children:["Quit and reopen ",Je," to see this page's pictures."]}):l.jsx(si,{}):p===null?l.jsx(si,{}):l.jsx(Qre,{product:e.product,src:e.src,text:p,mtime:w,onSaved:K=>b(K),onNotice:o},h??e.src)]})]})}const gse=3e4,yse=8e3;function wse(e,t){const n=e[e.length-1];return n?{take:n,rest:e.slice(0,-1),instant:t-n.at<=gse}:{take:null,rest:[],instant:!1}}function bse(e,t){return t-e<=yse}function xse(e){return`Press Z again to ${e}.`}function kse(e,t){return e&&"item"in e?{open:e.item,compose:!1}:e?{open:null,compose:!0}:{open:t??null,compose:!1}}function _N(e){return e.length===1?e[0]:void 0}const vse="Nothing to undo yet.",Sse=new Set(["Shift","Meta","Control","Alt","CapsLock"]),TO="zero.where",jse=["inbox","snoozed","progress","done"];function MO(e){let t;try{t=JSON.parse(e.getItem(TO)??"null")}catch{return null}if(!t||typeof t!="object")return null;const n=t,s={view:jse.includes(n.view)?n.view:"inbox"},o=c=>{if(!c||typeof c!="object")return;const u=c;if(!(typeof u.product!="string"||typeof u.id!="string")&&!(!u.product||!u.id))return{product:u.product,id:u.id}},i=o(n.item);i&&(s.item=i),i&&typeof n.scroll=="number"&&Number.isFinite(n.scroll)&&n.scroll>0&&(s.scroll=Math.round(n.scroll));const a=o(n.repeat);if(a&&(s.repeat=a),n.doc&&typeof n.doc=="object"){const c=n.doc;typeof c.product=="string"&&typeof c.src=="string"&&c.product&&c.src&&(s.doc={product:c.product,src:c.src})}return n.settings===!0&&(s.settings=!0),typeof n.search=="string"&&(s.search=n.search),typeof n.row=="string"&&n.row&&(s.row=n.row),s}function Cse(e,t){const n=MO(e);n!=null&&n.item&&(t>0?n.scroll=Math.round(t):delete n.scroll,RO(e,n))}function RO(e,t){try{e.setItem(TO,JSON.stringify(t))}catch{}}function WN(e){return e?e.view!=="inbox"||!!e.item||!!e.repeat||!!e.settings||e.search!==void 0||!!e.row:!1}const Nse=/^(Write|Edit|NotebookEdit)$/,Ese=/write_document$/,Ase=/\.(html?|png|jpe?g|gif|webp|pdf|change)$/i,Tse=/^(sessions|attachments|node_modules|scripts|\.)\//,Mse=/^\d\d:\d\d:\d\d {2}(.*)$/;function Rse(e){if(!e.startsWith("["))return null;const t=e.indexOf("]");return t<=0?null:{tool:e.slice(1,t),arg:e.slice(t+1).trim()}}function Ise(e,t){const n=[...e].filter(Boolean).sort((r,s)=>r.length-s.length);for(const r of n){const s=r.endsWith("/")?r:`${r}/`;if(t.startsWith(s))return t.slice(s.length)}return null}function Dse(e,t){const n=t.filter(Boolean),r=[],s=new Set,o=a=>{const c=a.replace(/^\.\//,"").trim();if(!c||!Ase.test(c)||Tse.test(c))return;const u=c.toLowerCase();s.has(u)||(s.add(u),r.push(c))},i=[...e].filter(a=>a&&a.text).sort((a,c)=>a.startedAt-c.startedAt);for(const a of i)for(const c of a.text.split(`
|
|
856
|
+
`)){const u=Mse.exec(c);if(!u)continue;const d=Rse(u[1]);if(!d||!d.arg)continue;if(Ese.test(d.tool)){o(d.arg);continue}if(!Nse.test(d.tool))continue;const h=Ise(n,d.arg);h&&o(h)}return r}const HN="Practice",Ose="practice",Du={title:"Add a summary to the Practice meeting notes.",body:"Keep it short: what we decided, and what is still open."},Lse="Make it shorter, please.",Jf=[{kind:"task",title:"Drafted a reply to the venue.",body:"Draft a reply to the venue for the offsite. We want Thursday, not Friday, and ask whether lunch is included.",trace:["Reading what the venue has already said before I write anything.","[Read] Venue emails.pdf","[Read] Offsite plan.docx","[Grep] lunch","They offered Friday twice, and their price list says lunch costs extra on weekdays, so I asked rather than guessed.","[Write] Reply to the venue.docx","Four sentences, ready for you to send."],result:"The draft asks for Thursday and whether lunch is included. It is ready for you to send.",agoMs:6*6e4},{kind:"task",title:"Tidied the team contact list.",body:"Clean up the team contact sheet. Remove the duplicates and sort everyone by last name.",trace:["[Read] Team contacts.xlsx","Forty two rows, and six of them are the same person twice with a different spelling.","[Edit] Team contacts.xlsx","[Read] Team contacts.xlsx","Thirty six people now, sorted by last name.","[Grep] email","Two people have no email address, so I put them at the bottom rather than guess one."],result:"Six duplicates are gone and everyone is sorted by last name. Two people have no email, so they are at the bottom.",agoMs:14*6e4},{kind:"task",later:!0,title:"The budget draft for next quarter is ready.",body:"Pull last quarter's spending into a first draft of next quarter's budget.",trace:["[Read] Spending last quarter.xlsx","[Read] Plan for next quarter.docx","Spending was close to plan except travel, which ran about a fifth over.","[Write] Budget draft.xlsx","[Edit] Budget draft.xlsx","Every line is filled in. It needs about an hour of your time to check, and nothing is due until next week."],result:"It is ready for you to check. It needs about an hour, and nothing is due until next week.",agoMs:22*6e4},{kind:"question",waiting:!0,title:"Which date should I send for the team dinner?",body:"Find a date for the team dinner that works for everyone, and ask me before you send it.",trace:["[Read] Team calendar.ics","[Grep] out of office","[Read] Restaurant bookings.pdf","Two evenings work for everyone: Thursday the 12th and Tuesday the 17th.","The restaurant has a table for twelve on both, but only the 12th has the private room.","I have not sent anything yet, as you asked."],result:["Two dates work for everyone. I would pick the 12th, because it is the only one with the private room.","","## Options","1. Thursday the 12th (recommended)","2. Tuesday the 17th","3. Ask the team to vote"].join(`
|
|
857
|
+
`),agoMs:31*6e4}],UN=[{state:"needs",kind:"task",title:"Booked the train for the offsite.",body:"Book train tickets for the team to the offsite on Thursday morning.",trace:["[Read] Offsite plan.docx","[Read] Team contacts.xlsx","Twelve people, all leaving from the city on Thursday morning.","[Write] Train booking.pdf"],result:"Twelve seats on the 8:10 on Thursday, all in one carriage. The tickets are in the offsite folder.",agoMs:9*6e4},{state:"needs",kind:"question",title:"Should the welcome pack go out Monday or Wednesday?",body:"Send the welcome pack to the two new starters, and check the day with me first.",trace:["[Read] Welcome pack.docx","[Read] Team calendar.ics","One starter begins on Monday and the other on Wednesday."],result:["One new starter begins Monday and the other Wednesday. Sending both on Monday means nobody waits.","","## Options","1. Monday, for both (recommended)","2. On each person's first day"].join(`
|
|
858
|
+
`),agoMs:26*6e4},{state:"working",kind:"task",title:"Write the agenda for the offsite.",body:"Write the agenda for the offsite: two days, with time for the planning session on day one.",trace:["[Read] Offsite plan.docx","[Read] Notes from last offsite.docx","Day one is mostly planning. Working out where lunch and the walk fit."],agoMs:4*6e4},{state:"working",kind:"task",title:"Compare three caterers for the team dinner.",body:"Find three caterers who can do dinner for twelve and compare price and menus.",trace:["[Read] Restaurant bookings.pdf","Two caterers so far. Checking whether the third does vegetarian menus."],agoMs:11*6e4},{state:"scheduled",kind:"task",title:"Send everyone the offsite reminder.",body:"Send the whole team a reminder about the offsite, with the train time and the agenda.",trace:[],agoMs:40*6e4,inMs:18*36e5}],Al="zero.lastProduct";function Hi(e){try{e?localStorage.setItem(Al,e):localStorage.removeItem(Al)}catch{}}function KN(){try{return localStorage.getItem(Al)}catch{return null}}function $se(e,t,{practiceSlug:n="practice"}={}){if(!t)return!1;const r=e.find(s=>s.slug===t);return r?r.practice===!0:t===n}const Pse="Nothing runs in Practice, it is only somewhere to try things out. Pick one of your own projects and this will start.";function zse(e,t={}){return!(e!=null&&e.practice)||t.scripted?null:Pse}const Fse="Nowhere to send this yet.",Bse="Make your first project";function _se(e,t={}){return t.person||e?null:{reason:Fse,action:Bse}}function Wse(e){if(e.held)return`Added to Later in ${e.to} · Z to undo`;const t=e.when?`Scheduled in ${e.to}`:`Started in ${e.to}`;return`${e.when?`${t} · ${e.when}`:t} · Z to undo`}const IO="zero.lastEngine";function Hse(e,t){return!e||e===In?null:(t??[]).some(n=>n.id===e)?e:null}function Use(e,t){const n=r=>(t??[]).some(s=>s.id===r);return n("codex")&&!n("claude")||Hse(e,t)==="codex"?"codex":"claude"}function Kse(e=globalThis.localStorage,t=null){const n=t&&F0(t)&&t!==In?t:null;try{const r=e==null?void 0:e.getItem(IO);return!r||!F0(r)?n:r===In?null:r}catch{return n}}function Vse(e,t=globalThis.localStorage){try{t==null||t.setItem(IO,e||In)}catch{}}function qse({products:e,items:t,engines:n,codexModels:r,codexModelDefault:s,defaultProduct:o,initial:i,scripted:a,onOpenMenu:c,onClose:u,onSent:d,onOpenConversation:h,onReorderProjects:f,onNewProject:p}){const m=g.useContext(Xt),w=g.useMemo(()=>m?vx(m.state.people,m.me):[],[m]),[b,x]=g.useState(()=>i!=null&&i.to&&w.some($=>$.id===i.to)?i.to:"agent"),v=b==="agent"?null:w.find($=>$.id===b)??null;g.useEffect(()=>{b!=="agent"&&!v&&x("agent")},[b,v]);const[S,C]=g.useState(""),[O,N]=g.useState(()=>(i==null?void 0:i.also)??[]),[P,M]=g.useState(!1),R=O.map($=>w.find(Re=>Re.id===$)).filter($=>!!$),L=v?[v,...R]:[],H=kp(L.map($=>bn($))),_=dw(w,S).filter($=>!P||$.id!==(v==null?void 0:v.id)&&!O.includes($.id)),Y=v&&R.length?Ky([v.id,...O],{products:e,items:t,me:(m==null?void 0:m.me)??null}):null,se=g.useRef(Ox()),[re,T]=g.useState(()=>(i==null?void 0:i.body)||se.current.text||""),[W,le]=g.useState(()=>se.current.attachments),[ge,j]=g.useState(0),ae=g.useMemo(()=>jU(e),[e]),[me,E]=g.useState(()=>{var Re;let $=null;try{$=localStorage.getItem(Al)}catch{}return((Re=QS(ae,{defaultProduct:o,remembered:$}))==null?void 0:Re.slug)??null}),K=ae.find($=>$.slug===me)??QS(ae,{defaultProduct:o,remembered:null}),z=$=>{E($);try{localStorage.setItem(Al,$)}catch{}},[xe,Oe]=g.useState(()=>IB(se.current.priority)),F=xe??"medium",J=$=>{Oe($)},[ze,ye]=g.useState(null),Z=ze??TU(K),[Ce,Ee]=g.useState(null),oe=Ce??(ze?[]:MU(K)),[ne,Ie]=g.useState("rows"),Q=$=>{ye($)},he=$=>Ee(oe.includes($)?oe.filter(Re=>Re!==$):[...oe,$]),te=oe.filter($=>w.some(Re=>Re.id===$)),ee=n!=null&&n.length?n:[xs[0]],U=ee.some($=>$.id==="codex"),I=ee.some($=>$.id==="claude"),V=s??null,ue={codexModels:r,codexDefault:V},G=()=>{const $=Use(Kse(),n);return{engine:$,model:ih(void 0,$,V)??Qr($,V)}},[ie,we]=g.useState(G);g.useEffect(()=>{ie.engine==="codex"&&!U&&we({engine:"claude",model:ih(void 0,"claude")??Qr("claude")}),ie.engine==="claude"&&!I&&U&&we({engine:"codex",model:ih(void 0,"codex",V)??Qr("codex",V)})},[U,I]);const[ve,de]=g.useState(()=>bw(void 0,ie.engine)),be=$=>{we($),Vse($.engine),r2($.model,void 0,$.engine,V),$.engine!==ie.engine&&de(bw(void 0,$.engine))},Le=_u(ie.engine,ie.model,ue),Ye=cR(ve,Le,Sp(ie.engine,ie.model,ue)),at=$=>{const Re=$===ve?null:$;de(Re),f8(Re,void 0,ie.engine)},Ge=$=>ql($.engine,$.model,ue),Ke=g.useMemo(()=>hU(t,{codexModels:r,codexDefault:V,codexOffered:U,claudeOffered:I}),[t,r,V,U,I]),rt=g.useMemo(()=>fU({codexModels:r,codexOffered:U,claudeOffered:I}),[r,U,I]),gt=pU(Ke,rt),[Ve,Ln]=g.useState(null),[ln,Sn]=g.useState("recent"),[Ys,ts]=g.useState("list"),[ns,rs]=g.useState(""),[cr,Do]=g.useState(""),zr=g.useRef({}),Dt=$=>Re=>{zr.current[$]=Re},Gs=g.useRef(null),Js=g.useRef(null),Sr=$=>{Ln(Re=>{const ht=Re===$?null:$;return ht&&(c==null||c(ht)),ht}),Sn("recent"),ts("list"),Ie("rows"),rs(""),Do(""),C("")},ur=$=>{var ht,Ht,hr;const Re=Ve;Ln(null),$==="text"?(ht=Gs.current)==null||ht.focus():Re&&((hr=(Ht=zr.current[Re])==null?void 0:Ht.querySelector("[data-trigger]"))==null||hr.focus())};g.useEffect(()=>{if(!Ve)return;const $=Re=>{var ht;(ht=zr.current[Ve])!=null&&ht.contains(Re.target)||Ln(null)};return document.addEventListener("pointerdown",$),()=>document.removeEventListener("pointerdown",$)},[Ve]),g.useLayoutEffect(()=>{var ht;if(!Ve)return;const $=(ht=zr.current[Ve])==null?void 0:ht.querySelector(":scope > .tc-menu");if(!$)return;By($);const Re=$.querySelector("[data-item].on")??$.querySelector("[data-item]");Re==null||Re.focus({preventScroll:!0})},[Ve,ln,Ys,ne]),g.useLayoutEffect(()=>{var Re;if(!Ve)return;const $=(Re=zr.current[Ve])==null?void 0:Re.querySelector(":scope > .tc-menu");$&&By($)},[S,ns,cr]);const qn=$=>{var Jn,Qs;const Re=$.target;if($.key==="Escape"){$.preventDefault(),$.stopPropagation(),ur("trigger");return}const ht=[...$.currentTarget.querySelectorAll("[data-item]:not([disabled])")],Ht=ht.indexOf(document.activeElement);if($.key==="ArrowDown"){$.preventDefault(),(Jn=ht[(Ht+1)%ht.length])==null||Jn.focus();return}if($.key==="ArrowUp"){$.preventDefault(),(Qs=ht[Ht<=0?ht.length-1:Ht-1])==null||Qs.focus();return}const hr=$.currentTarget.querySelector(".tc-find, .tc-when");hr&&Re!==hr&&$.key.length===1&&!$.metaKey&&!$.ctrlKey&&!$.altKey&&hr.focus()},_t=$=>{document.activeElement!==$.currentTarget&&$.currentTarget.focus({preventScroll:!0})},Fr=$=>Re=>{Ve!==$&&(Re.key==="ArrowDown"||Re.key==="ArrowUp")&&(Re.preventDefault(),Sr($))};g.useEffect(()=>{const $=kR({text:re,attachments:W,priority:xe,when:{runAt:0,repeat:null},dropped:0});j($.dropped)},[re,W,xe]),g.useEffect(()=>{const $=Gs.current;$&&($.focus(),$.setSelectionRange($.value.length,$.value.length))},[]);const Oo=g.useRef(null),[Br,Oa]=g.useState(!1);g.useLayoutEffect(()=>{const $=Oo.current;$&&Oa($.scrollWidth>$.clientWidth+.5)},[K==null?void 0:K.name,v]);const[_r,Lo]=g.useState(!1),[et,mn]=g.useState(null),jr=!re.trim()&&a&&!v?`${Du.title}
|
|
859
|
+
|
|
860
|
+
${Du.body}`:re,Yn=vU(jr,v?[]:W),dr=v?null:zse(K,{scripted:!!a}),cn=_se(K,{person:!!v}),Gn=!_r&&(v?!!re.trim():!!Yn&&!!K&&!dr),jn=async($={})=>{if(!(!Gn||!K||!Yn)){Lo(!0),mn(null),Ln(null);try{const Re=await hR(K.slug,W),ht=[Yn.body,Re].filter(Boolean).join(`
|
|
861
|
+
|
|
862
|
+
`);try{localStorage.setItem(Al,K.slug)}catch{}const Ht=gU({engine:ie.engine,model:ie.model,effort:Ax(ve,Le)?ve:null,engineCount:ee.length,codexDefault:V}),hr=xe?hu(xe):5;if($.repeat){const Jn=await q.composeRepeat({product:K.slug,title:Yn.title,body:ht||void 0,priority:hr,rule:$.repeat,...Ht.engine?{engine:Ht.engine}:{},...Ht.model?{model:Ht.model}:{}});d(null,{kind:"repeat",product:K.slug,title:Yn.title,ruleId:Jn==null?void 0:Jn.id})}else{const Jn=await q.compose({product:K.slug,title:Yn.title,body:ht||void 0,kind:"directive",priority:hr,...$.runAt?{runAt:$.runAt}:{},...$.start?{start:$.start}:{},...Ht,...m?AU(Z,te):{},...a?{labels:a.labels}:{}});d(Jn,{kind:"task",product:K.slug,title:Yn.title,...$.runAt?{runAt:$.runAt}:{},...$.start?{start:$.start}:{}})}kw()}catch(Re){mn(`Not sent: ${String((Re==null?void 0:Re.message)??Re)}`),Lo(!1)}}},La=async()=>{if(!Gn||!v)return;Lo(!0),mn(null);const $=await q.teamMessage(R.length?[v.id,...O]:v.id,re.trim(),xe?hu(xe):void 0);if(!$.ok){mn(`Not sent: ${$.error??"the team cloud did not answer."}`),Lo(!1);return}d(null,{kind:"message",to:v.id,...R.length?{toMany:[v.id,...O]}:{}}),kw()},ss=()=>v?La():jn(),vs=g.useRef(ss);vs.current=ss,g.useEffect(()=>{const $=Re=>{Re.defaultPrevented||!(Re.metaKey||Re.ctrlKey)||Re.key!=="Enter"||(Re.preventDefault(),vs.current())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[]);const Wr=async $=>{if(!$||!$.length)return;const Re=await rf($);Re.length&&le(ht=>[...ht,...Re])},Xs=$=>{if(P&&v&&$!=="agent"){$!==v.id&&!O.includes($)&&N(Re=>[...Re,$]),M(!1),C(""),ur("text");return}if(M(!1),$!=="agent"&&h){const Re=Ky($,{products:e,items:t,me:(m==null?void 0:m.me)??null});if(Re){h(Re,re);return}}x($),N([]),mn(null),ur("text")},Cn=l.jsxs("div",{className:"tc-menu tc-drop tc-to-menu",role:"listbox","aria-label":"To",onKeyDown:qn,children:[!P&&l.jsxs("button",{type:"button","data-item":!0,className:`tc-row ${v?"":"on"}`,onPointerEnter:_t,onClick:()=>Xs("agent"),children:[l.jsx(bu,{}),l.jsx("span",{className:"tc-row-label",children:"Agent"})]}),m&&w.length>0&&l.jsxs(l.Fragment,{children:[!P&&l.jsx("span",{className:"tc-sep"}),l.jsx("span",{className:"tc-menu-head",children:"People"}),l.jsx("input",{"data-item":!0,className:"tc-find",placeholder:"Find a person",value:S,onChange:$=>C($.target.value),onKeyDown:$=>{$.key==="Enter"&&S.trim()&&_[0]&&($.preventDefault(),Xs(_[0].id))}}),_.map($=>l.jsxs("button",{type:"button","data-item":!0,className:`tc-row ${b===$.id?"on":""}`,onPointerEnter:_t,onClick:()=>Xs($.id),children:[l.jsx(Rt,{person:$}),l.jsx("span",{className:"tc-row-label",children:$.name})]},$.id)),!_.length&&l.jsx("span",{className:"tc-none",children:"Nobody on the team matches that."})]})]}),Ss=$=>l.jsx("button",{type:"button","data-item":!0,className:`tc-row ${mU($,ie)?"on":""}`,onPointerEnter:_t,onClick:()=>{be($),ur("text")},children:l.jsx("span",{className:"tc-row-label",children:Ge($)})},`${$.engine}:${$.model}`),js=$=>{var Re,ht;return((Re=ee.find(Ht=>Ht.id===$))==null?void 0:Re.label)??((ht=xs.find(Ht=>Ht.id===$))==null?void 0:ht.label)??$},Ai=l.jsxs("div",{className:"tc-menu tc-drop tc-model-menu",role:"listbox","aria-label":"Model",onKeyDown:qn,children:[ln==="recent"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tc-menu-head",children:"Recent"}),Ke.map(Ss),l.jsx("span",{className:"tc-sep"}),l.jsxs("button",{type:"button","data-item":!0,className:"tc-row",onPointerEnter:_t,onClick:()=>Sn("all"),children:[l.jsx("span",{className:"tc-row-label",children:"All models"}),gt>0&&l.jsxs("small",{children:[gt," more ›"]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button","data-item":!0,className:"tc-row",onPointerEnter:_t,onClick:()=>Sn("recent"),children:l.jsx("span",{className:"tc-row-label",children:"‹ Recent"})}),l.jsx("span",{className:"tc-sep"}),l.jsxs("div",{className:"tc-cols",children:[rt.claude.length>0&&l.jsxs("div",{className:"tc-col",children:[l.jsx("span",{className:"tc-menu-head",children:js("claude")}),rt.claude.map(Ss)]}),rt.codex.length>0&&l.jsxs("div",{className:"tc-col",children:[l.jsx("span",{className:"tc-menu-head",children:js("codex")}),rt.codex.map(Ss)]})]})]}),Le.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tc-sep"}),l.jsx("span",{className:"tc-effort-head",id:"tc-effort-head",children:"Effort"}),l.jsx("span",{className:"tc-effort",role:"radiogroup","aria-labelledby":"tc-effort-head",children:Le.map($=>l.jsx("button",{type:"button","data-item":!0,role:"radio","aria-checked":$.id===Ye,className:$.id===Ye?"lit":"",onPointerEnter:_t,onClick:()=>at($.id),children:$.label},$.id))})]})]}),$a=l.jsxs("div",{className:"tc-menu tc-rise",role:"listbox","aria-label":"Project",onKeyDown:qn,children:[f?l.jsxs("span",{className:"tc-menu-head tc-head-split",children:[l.jsx("span",{children:"By priority"}),l.jsx("button",{type:"button",className:"tc-head-link",onClick:f,children:"Reorder"})]}):l.jsx("span",{className:"tc-menu-head",children:"Project"}),ae.map($=>l.jsxs("button",{type:"button","data-item":!0,className:`tc-row ${$.slug===(K==null?void 0:K.slug)?"on":""}`,onPointerEnter:_t,onClick:()=>{z($.slug),ur("text")},children:[l.jsx(VN,{slug:$.slug}),l.jsx("span",{className:"tc-row-label",children:$.name})]},$.slug)),p&&l.jsxs(l.Fragment,{children:[ae.length>0&&l.jsx("span",{className:"tc-menu-rule"}),l.jsxs("button",{type:"button","data-item":!0,className:"tc-row tc-new-project",onPointerEnter:_t,onClick:()=>{ur("text"),p()},children:[l.jsx(Jse,{}),l.jsx("span",{className:"tc-row-label",children:"New project"})]})]})]}),Xl=l.jsxs("div",{className:"tc-menu tc-rise tc-narrow",role:"listbox","aria-label":"Priority",onKeyDown:qn,children:[l.jsx("span",{className:"tc-menu-head",children:"Priority"}),wr.map($=>l.jsxs("button",{type:"button","data-item":!0,className:`tc-row ${$.id===F?"on":""}`,onPointerEnter:_t,onClick:()=>{J($.id),ur("text")},children:[l.jsx(qN,{id:$.id}),l.jsx("span",{className:"tc-row-label",children:$.label})]},$.id))]}),Ti=l.jsxs("span",{className:"tc-anchor",ref:Dt("priority"),children:[l.jsxs("button",{type:"button","data-trigger":!0,className:`tc-chip ${Ve==="priority"?"open":""}`,title:"Priority","aria-haspopup":"listbox","aria-expanded":Ve==="priority",onClick:()=>Sr("priority"),onKeyDown:Fr("priority"),children:[l.jsx(qN,{id:F}),Ma(F)]}),Ve==="priority"&&Xl]}),$o=dw(w,S),Ql=l.jsx("div",{className:"tc-menu tc-rise tc-vis-menu",role:"listbox","aria-label":"Who sees it",onKeyDown:qn,children:ne==="rows"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tc-menu-head",children:"Who sees it"}),EU.map($=>l.jsxs("button",{type:"button","data-item":!0,className:`tc-row tc-two ${$.id===Z?"on":""}`,onPointerEnter:_t,onClick:()=>{Q($.id),$.id==="people"?Ie("people"):ur("text")},children:[$.id==="private"?l.jsx(GN,{}):l.jsx(YN,{}),l.jsxs("span",{className:"tc-row-label",children:[$.label,l.jsx("small",{children:$.id==="people"&&te.length?`${hw(te,w)} see its summary.`:$.line})]})]},$.id))]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button","data-item":!0,className:"tc-row",onPointerEnter:_t,onClick:()=>Ie("rows"),children:l.jsx("span",{className:"tc-row-label",children:"‹ Who sees it"})}),l.jsx("span",{className:"tc-sep"}),l.jsx("span",{className:"tc-menu-head",children:"People who see it"}),l.jsx("input",{"data-item":!0,className:"tc-find",placeholder:"Find a person",value:S,onChange:$=>C($.target.value),onKeyDown:$=>{$.key==="Enter"&&S.trim()&&$o[0]&&($.preventDefault(),he($o[0].id))}}),$o.map($=>l.jsxs("button",{type:"button","data-item":!0,role:"option","aria-selected":oe.includes($.id),className:`tc-row ${oe.includes($.id)?"on":""}`,onPointerEnter:_t,onClick:()=>he($.id),children:[l.jsx(Rt,{person:$}),l.jsx("span",{className:"tc-row-label",children:$.name}),oe.includes($.id)&&l.jsx("small",{children:"✓"})]},$.id)),!$o.length&&l.jsx("span",{className:"tc-none",children:"Nobody on the team matches that."}),!te.length&&l.jsx("span",{className:"tc-none",children:"Pick a person, or nobody but you will see it."})]})}),is=Date.now(),Po=yU(is),zo=wU(is),Cs=kU(ns,is),en=MA(cr),Fo=l.jsx("div",{className:"tc-menu tc-rise tc-right tc-wide",role:"menu","aria-label":"Send later",onKeyDown:qn,children:Ys==="list"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tc-menu-head",children:"Send later"}),l.jsxs("button",{type:"button","data-item":!0,className:"tc-row",onPointerEnter:_t,onClick:()=>jn({start:"later"}),children:[l.jsx(th,{}),l.jsx("span",{className:"tc-row-label",children:"Add it to Later"})]}),l.jsxs("button",{type:"button","data-item":!0,className:"tc-row",onPointerEnter:_t,onClick:()=>jn({runAt:Po}),children:[l.jsx(th,{}),l.jsx("span",{className:"tc-row-label",children:"Tomorrow morning"}),l.jsx("small",{children:uw(Po)})]}),l.jsxs("button",{type:"button","data-item":!0,className:"tc-row",onPointerEnter:_t,onClick:()=>jn({runAt:zo}),children:[l.jsx(th,{}),l.jsx("span",{className:"tc-row-label",children:"Monday morning"}),l.jsx("small",{children:uw(zo)})]}),l.jsxs("span",{className:"tc-pick",children:[l.jsx(th,{}),l.jsx("input",{"data-item":!0,className:"tc-when",placeholder:"Or type: 3h, fri 6pm, tomorrow 9am","aria-label":"Send at a time you type",value:ns,onChange:$=>rs($.target.value),onKeyDown:$=>{$.key==="Enter"&&Cs&&($.preventDefault(),jn({runAt:Cs.ts}))}}),ns.trim()&&(Cs?l.jsx("button",{type:"button","data-item":!0,className:"tc-schedule",onClick:()=>jn({runAt:Cs.ts}),children:Cs.hint}):l.jsx("small",{className:"tc-when-no",children:"Not a time yet"}))]}),l.jsx("span",{className:"tc-sep"}),l.jsxs("button",{type:"button","data-item":!0,className:"tc-row",onPointerEnter:_t,onClick:()=>ts("repeat"),children:[l.jsx(oy,{}),l.jsx("span",{className:"tc-row-label",children:"Repeat it"})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button","data-item":!0,className:"tc-row",onPointerEnter:_t,onClick:()=>ts("list"),children:l.jsx("span",{className:"tc-row-label",children:"‹ Send later"})}),l.jsx("span",{className:"tc-sep"}),l.jsx("span",{className:"tc-menu-head",children:"Repeat it"}),sR(is).filter($=>$.rule).map($=>l.jsxs("button",{type:"button","data-item":!0,className:"tc-row",onPointerEnter:_t,onClick:()=>jn({repeat:$.rule}),children:[l.jsx(oy,{}),l.jsx("span",{className:"tc-row-label",children:$.label})]},$.label)),l.jsxs("span",{className:"tc-pick",children:[l.jsx(oy,{}),l.jsx("input",{"data-item":!0,className:"tc-when",placeholder:"Or type: every day 5pm, fridays 4pm","aria-label":"Repeat on a rule you type",value:cr,onChange:$=>Do($.target.value),onKeyDown:$=>{$.key==="Enter"&&en&&"rule"in en&&($.preventDefault(),jn({repeat:en.rule}))}}),cr.trim()&&(en&&"rule"in en?l.jsx("button",{type:"button","data-item":!0,className:"tc-schedule",onClick:()=>jn({repeat:en.rule}),children:en.label[0].toUpperCase()+en.label.slice(1)}):l.jsx("small",{className:"tc-when-no",children:en?"Can’t repeat that":"Not a repeat yet"}))]})]})});return l.jsx("div",{className:"modal-backdrop tc-veil",onClick:u,children:l.jsxs("div",{className:"tc-card",role:"dialog","aria-label":"New thread",onClick:$=>$.stopPropagation(),onKeyDown:$=>{if(($.metaKey||$.ctrlKey)&&$.key==="Enter"){$.preventDefault(),ss();return}$.key==="Escape"&&($.preventDefault(),$.stopPropagation(),Ve?ur("trigger"):u())},children:[l.jsxs("div",{className:"tc-head",children:[l.jsxs("div",{className:"tc-field",children:[l.jsx("span",{className:"tc-label",children:"To"}),l.jsxs("span",{className:"tc-anchor",ref:Dt("to"),children:[l.jsxs("button",{type:"button","data-trigger":!0,className:`tc-word ${Ve==="to"?"open":""}`,"aria-haspopup":"listbox","aria-expanded":Ve==="to",onClick:()=>Sr("to"),onKeyDown:Fr("to"),children:[v?l.jsx(Rt,{person:v}):l.jsx(bu,{}),l.jsx("span",{className:"tc-word-text",children:v?v.name:"Agent"})]}),R.map($=>l.jsxs("span",{className:"tc-also",children:[l.jsx(Rt,{person:$}),$.name,l.jsx("button",{type:"button","aria-label":`Remove ${$.name}`,title:`Remove ${$.name}`,onClick:()=>N(Re=>Re.filter(ht=>ht!==$.id)),children:"×"})]},$.id)),v&&w.length>L.length&&l.jsx("button",{type:"button",className:"tc-add","aria-label":"Add someone",title:"Add someone",onClick:()=>{M(!0),C(""),Ve!=="to"&&Sr("to")},children:"+"}),Ve==="to"&&Cn]})]}),!v&&l.jsxs("div",{className:"tc-field",children:[l.jsx("span",{className:"tc-label",children:"Model"}),l.jsxs("span",{className:"tc-anchor",ref:Dt("model"),children:[l.jsx("button",{type:"button","data-trigger":!0,className:`tc-word ${Ve==="model"?"open":""}`,"aria-haspopup":"listbox","aria-expanded":Ve==="model",onClick:()=>Sr("model"),onKeyDown:Fr("model"),children:l.jsx("span",{className:"tc-word-text",children:Ge(ie)})}),Ve==="model"&&Ai]})]})]}),Y&&h&&l.jsxs("div",{className:"tc-note tc-continues",children:["Continues your conversation with ",H,". ",l.jsx("button",{type:"button",onClick:()=>h(Y,re),children:"Open it"})]}),l.jsx("textarea",{ref:Gs,className:"tc-text",value:re,onChange:$=>T($.target.value),placeholder:v?`Message ${H}`:CU(null),onPaste:async $=>{if(v)return;const Re=await dR($);Re.length&&($.preventDefault(),le(ht=>[...ht,...Re]))},onDragOver:$=>{v||$.preventDefault()},onDrop:async $=>{v||($.preventDefault(),await Wr($.dataTransfer.files))}}),!v&&l.jsx(VR,{attachments:W,onRemove:$=>le(Re=>Re.filter((ht,Ht)=>Ht!==$))}),dr&&l.jsx("div",{className:"tc-note",children:dr}),!v&&ge>0&&l.jsx("div",{className:"tc-note",children:ge===1?"One pasted image is too big to save. Closing the card loses it.":`${ge} pasted images are too big to save. Closing the card loses them.`}),v&&W.length>0&&l.jsxs("div",{className:"tc-note",children:[W.length===1?"The attached file stays here":`The ${W.length} attached files stay here`,": a message to a person carries words only."]}),et&&l.jsx("div",{className:"tc-note tc-error",role:"alert",children:et}),v?l.jsxs("div",{className:"tc-bar",children:[Ti,l.jsx("span",{className:"tc-send solo",children:l.jsxs("button",{type:"button",className:"tc-send-main",disabled:!Gn,onClick:()=>void ss(),title:"Send · ⌘↵",children:["Send ",l.jsx("kbd",{children:"⌘↵"})]})})]}):l.jsxs("div",{className:"tc-bar",children:[l.jsxs("span",{className:"tc-anchor",ref:Dt("project"),children:[l.jsxs("button",{type:"button","data-trigger":!0,className:`tc-chip ${Ve==="project"?"open":""}`,title:(K==null?void 0:K.name)??"Which project","aria-haspopup":"listbox","aria-expanded":Ve==="project",onClick:()=>Sr("project"),onKeyDown:Fr("project"),children:[K&&l.jsx(VN,{slug:K.slug}),l.jsx("span",{ref:Oo,className:`tc-chip-name ${Br?"cut":""}`,children:(K==null?void 0:K.name)??"No project"})]}),Ve==="project"&&$a]}),Ti,m&&l.jsxs("span",{className:"tc-anchor",ref:Dt("visibility"),children:[l.jsxs("button",{type:"button","data-trigger":!0,className:`tc-chip ${Ve==="visibility"?"open":""}`,title:"Who sees it","aria-haspopup":"listbox","aria-expanded":Ve==="visibility",onClick:()=>Sr("visibility"),onKeyDown:Fr("visibility"),children:[Z==="private"?l.jsx(GN,{}):l.jsx(YN,{}),Z==="team"?"Team":Z==="private"?"Private":hw(te,w)]}),Ve==="visibility"&&Ql]}),l.jsx("button",{type:"button",className:"tc-icon",title:"Attach files","aria-label":"Attach files",onClick:()=>{var $;return($=Js.current)==null?void 0:$.click()},children:l.jsx(Yse,{})}),l.jsx("input",{ref:Js,type:"file",multiple:!0,hidden:!0,onChange:async $=>{await Wr($.target.files),$.target.value=""}}),cn&&l.jsxs("span",{className:"tc-why",children:[cn.reason," ",p?l.jsx("button",{type:"button",className:"tc-why-do",onClick:p,children:cn.action}):cn.action]}),l.jsxs("span",{className:"tc-send",ref:Dt("later"),children:[l.jsxs("button",{type:"button",className:"tc-send-main",disabled:!Gn,onClick:()=>void ss(),title:dr??(cn==null?void 0:cn.reason)??"Send · ⌘↵",children:["Send ",l.jsx("kbd",{children:"⌘↵"})]}),l.jsx("button",{type:"button","data-trigger":!0,className:"tc-send-caret",disabled:!Gn,"aria-label":"Send later","aria-haspopup":"menu","aria-expanded":Ve==="later",onClick:()=>Sr("later"),onKeyDown:Fr("later"),children:l.jsx(Gse,{})}),Ve==="later"&&Fo]})]})]})})}function VN({slug:e}){return l.jsx("span",{className:"tc-swatch","aria-hidden":"true",children:l.jsx("i",{style:{background:AM(e)}})})}const qN=({id:e})=>l.jsx("span",{className:"tc-prio",children:l.jsx(xi,{id:e})}),YN=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"17",height:"17",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[l.jsx("circle",{cx:"9",cy:"9",r:"3.2"}),l.jsx("path",{d:"M3 19.5c.6-3.2 3-5 6-5s5.4 1.8 6 5"}),l.jsx("path",{d:"M15.5 6.2a3 3 0 0 1 0 5.6M17.5 14.8c1.8.6 3 2.1 3.4 4.7"})]}),GN=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"17",height:"17",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[l.jsx("rect",{x:"5.5",y:"10.5",width:"13",height:"9"}),l.jsx("path",{d:"M8.5 10.5V8a3.5 3.5 0 0 1 7 0v2.5"})]}),Yse=()=>l.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:l.jsx("path",{d:"m20 11.5-8.2 8.2a5 5 0 0 1-7.1-7.1l8.5-8.5a3.3 3.3 0 0 1 4.7 4.7l-8.4 8.4a1.7 1.7 0 0 1-2.4-2.4l7.7-7.7"})}),Gse=()=>l.jsx("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:l.jsx("path",{d:"m6 9 6 6 6-6"})}),Jse=()=>l.jsx("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:l.jsx("path",{d:"M12 5v14M5 12h14"})}),th=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"8"}),l.jsx("path",{d:"M12 8v4.5l3 2"})]}),oy=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[l.jsx("path",{d:"M17 3l3 3-3 3"}),l.jsx("path",{d:"M4 11V9a3 3 0 0 1 3-3h13M7 21l-3-3 3-3"}),l.jsx("path",{d:"M20 13v2a3 3 0 0 1-3 3H4"})]});function Xse(e,t){return!t||!e.startsWith(t)?e:e===t?"~":`~${e.slice(t.length)}`}function DO({startIn:e,onPick:t,onClose:n}){const[r,s]=g.useState(null),[o,i]=g.useState(""),[a,c]=g.useState(!0),u=g.useRef(0),d=g.useCallback(async w=>{const b=++u.current;c(!0);const x=await q.listFolders(w);b===u.current&&(s(x),i(x.at),c(!1))},[]);g.useEffect(()=>{d(e??null)},[d,e]);const h=(r==null?void 0:r.at)??"",f=(r==null?void 0:r.home)??"",p=!!h&&!(r!=null&&r.refused)&&!(r!=null&&r.unreadable),m=()=>{p&&t(h)};return l.jsx("div",{className:"modal-backdrop fp-backdrop",onClick:n,children:l.jsxs("div",{className:"modal fp-card",onClick:w=>w.stopPropagation(),role:"dialog","aria-label":"Choose a folder",onKeyDown:w=>{w.key==="Escape"&&(w.stopPropagation(),n()),(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&m()},children:[l.jsxs("div",{className:"fp-head",children:[l.jsx("button",{className:"fp-up",onClick:()=>(r==null?void 0:r.parent)&&d(r.parent),disabled:!(r!=null&&r.parent)||a,title:"Up one folder",children:"Up"}),l.jsx("div",{className:"fp-field",children:l.jsx("input",{className:"fp-path",value:o,spellCheck:!1,onChange:w=>i(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),d(o))},"aria-label":"Folder path"})})]}),l.jsxs("div",{className:"fp-list",role:"listbox","aria-busy":a,children:[(r==null?void 0:r.unreadable)&&l.jsx("p",{className:"fp-note",children:r.unreadable}),r&&!r.unreadable&&r.folders.length===0&&l.jsx("p",{className:"fp-note",children:"No folders in here."}),r==null?void 0:r.folders.map(w=>l.jsx("button",{className:"fp-row",onClick:()=>void d(w.path),onDoubleClick:()=>t(w.path),children:w.name},w.path))]}),(r==null?void 0:r.refused)&&l.jsx("p",{className:"fp-refused",children:r.refused}),l.jsxs("div",{className:"fp-foot",children:[l.jsx("span",{className:"fp-where",children:h?Xse(h,f):""}),l.jsx("button",{className:"fp-cancel",onClick:n,children:"Cancel"}),l.jsx("button",{className:"fp-use",onClick:m,disabled:!p,children:"Use this folder"})]})]})})}const dt={planHead:"Which AI plan do you pay for?",planLede:`Your agents run on your own plan. Pick it and ${Je} sets everything up.`,claude:"Claude",claudePlans:"Pro, Max or a team plan",chatgpt:"ChatGPT",chatgptPlans:"A paid ChatGPT plan",both:"Both",bothPlans:"Agents use whichever has room left",haveOne:"I already have one, let me show you where",notThatOne:"That is not something agents can run. Try another, or pick a plan above.",checking:"Checking this computer…",nothingHere:"Nothing is set up on this computer yet. Pick the plan you pay for above.",privacy:`You sign in on Claude's or OpenAI's own page. ${Je} never sees your password.`,setupHead:e=>`Setting up ${e}.`,setupLedeWait:"One step needs you: approve the sign-in in your browser.",setupLedeBusy:"This takes about half a minute. Nothing needs you yet.",setupLedeFailed:"Something stopped the setup. Try again, or skip it for now.",setupOf:(e,t)=>`${e} of ${t}`,install:e=>`Install ${e}`,signIn:e=>`Sign in to your ${e} plan`,signInSub:e=>`A ${e==="Claude"?"Claude":"ChatGPT"} page opened in your browser. Click Authorize there, then come back here.`,ready:"Check that agents can start",done:"Done",working:"Working…",waiting:"Waiting for you",openAgain:"Open the sign-in page again",tryAgain:"Try again",skip:"Skip for now",showLog:"Show what is happening",hideLog:"Hide what is happening",barSay:"Agents cannot start until they have a plan to run on.",barSub:"Takes a couple of clicks.",barClaude:"Set up with Claude",barChatgpt:"Set up with ChatGPT"};function OO(e){return e==="claude"?dt.claude:dt.chatgpt}function Qse(e){return e==="claude"?"Claude Code":"Codex"}function Zse(e){return e==="both"?["claude","codex"]:[e]}function Tk(e){return!e.some(t=>t.found&&t.signedIn)}function eoe(e){if(!Tk(e))return{t:"ready"};const t=e.filter(n=>n.found).map(n=>n.engine);return t.length===2?{t:"setup",plan:"both"}:t.length===1?{t:"setup",plan:t[0]}:{t:"nothing"}}function toe(){return[{key:"claude",plan:"claude",mark:"C",name:dt.claude,sub:dt.claudePlans},{key:"codex",plan:"codex",mark:"G",name:dt.chatgpt,sub:dt.chatgptPlans},{key:"both",plan:"both",mark:"+",name:dt.both,sub:dt.bothPlans},{key:"mine",name:dt.haveOne,other:!0}]}function noe(e){return e.refused?{text:dt.notThatOne,bad:!0}:e.looking?{text:dt.checking,bad:!1}:e.looked?{text:dt.nothingHere,bad:!1}:{text:dt.privacy,bad:!1}}function roe(e){const t=OO(e.engine),n={state:"todo",title:dt.install(Qse(e.engine))},r={state:"todo",title:dt.signIn(t)},s={state:"todo",title:dt.ready};switch(e.phase){case"idle":case"installing":n.state="now",n.right=dt.working;break;case"checking":n.state="done",n.right=dt.done,r.state="now",r.right=dt.working;break;case"signing-in":n.state="done",n.right=dt.done,r.state="now",r.sub=dt.signInSub(t),r.right=dt.waiting;break;case"ready":n.state="done",n.right=dt.done,r.state="done",r.right=dt.done,s.state="done",s.right=dt.done;break}return[n,r,s]}function soe(e){return e==="signing-in"?dt.setupLedeWait:e==="failed"?dt.setupLedeFailed:dt.setupLedeBusy}const ooe={welcome:1,plan:1,folder:2,name:3,hand:4,tour:5,tabs:6,make:7,task:8,working:9,open:9,answer:10,clear:11,snooze:12,unblock:13,where:14,board:15,command:16,done:17,landed:17},Tl={step:"welcome",folder:null,name:"",product:null,practice:null,item:null,sentAt:null,examples:[]};function ioe(e){return{...Tl,tutorial:!0,step:"hand",product:e}}const Ml=(e,t)=>{var n,r;return((r=(n=e.wrote)==null?void 0:n[t])==null?void 0:r.ts)??0};function aoe(e){return Ml(e,"answer")>0&&Ml(e,"answer")>=Ml(e,"result")}function loe(e){return Ml(e,"answer")>0&&Ml(e,"result")>Ml(e,"answer")}function coe(e,t,n){return e.step==="open"||e.step==="answer"?!!e.item&&t===e.item:e.step==="unblock"?!!n&&t===n:!1}function uoe(e,t,n,r){const s=o=>({...e,hidden:[...e.hidden??[],...o.filter(i=>!!i)]});switch(e.step){case"tour":return rr(e,"tabs");case"tabs":return rr(e,"make");case"make":case"task":case"working":case"open":case"answer":return{...s([e.item]),step:"clear"};case"clear":return s($O(t,e,n,r));case"snooze":return s([Gu(e,r)]);case"unblock":return s([Kl(e,n)]);case"where":return rr(e,"board");case"board":return rr(e,"command");default:return null}}function JN(e){return e!=null&&e.tutorial?"end":"done"}function doe(e,{practised:t}){return!!e&&t&&!e.tutorial}function hoe(e){return!e||e.tutorial||e.step==="landed"?null:ooe[e.step]??null}function foe(e,t){switch(t.t){case"start":return e.step==="welcome"?{...e,step:"folder"}:e;case"folder":return{...e,folder:t.path,name:!e.name||e.folder&&e.name===jh(e.folder)?jh(t.path):e.name};case"noFolder":return{...e,folder:null,name:!e.name.trim()||e.folder&&e.name===jh(e.folder)?_e.noFolderName:e.name};case"name":return{...e,name:t.name};case"made":return{...e,product:t.product,step:"hand"};case"practice":return{...e,practice:t.product,examples:t.examples,backdrop:t.backdrop??[],step:"tour"};case"sent":return{...e,item:t.item,sentAt:t.at,step:"working"};case"replied":return e.step==="answer"&&e.item?{...e,sentAt:t.at,replies:(e.replies??0)+1,step:"working"}:e;case"answered":return e.step==="working"?{...e,step:"open"}:e;case"staged":return{...e,examples:t.examples,step:"clear"};case"finish":return{...e,step:"landed"}}}function rr(e,t){return{...e,step:t}}function poe(e){return e==="plan"||e==="folder"?"welcome":e==="name"?"folder":null}function jh(e){return(e.replace(/\/+$/,"").split("/").pop()??"").replace(/[-_.]+/g," ").trim().replace(/\s+/g," ").split(" ").map(n=>n&&n[0].toUpperCase()+n.slice(1)).join(" ")}function moe(e,{home:t="",max:n=6}={}){const r=new Map,s=t.replace(/\/+$/,"");for(const o of e){const i=String(o.folder??"").replace(/\/+$/,"");if(!i||i===s||i==="/")continue;const a=o.source==="codex"?"codex":"claude",c=r.get(i);if(c){c.when=Math.max(c.when,o.when??0),c.via.includes(a)||c.via.push(a);continue}r.set(i,{folder:i,name:i.split("/").pop()??i,short:o.short||LO(i,t),when:o.when??0,via:[a]})}return[...r.values()].sort((o,i)=>i.when-o.when).slice(0,n)}function LO(e,t){const n=(t??"").replace(/\/+$/,"");return n&&e.startsWith(n+"/")?"~"+e.slice(n.length):e}function XN(e){return e.forced?!0:!e.done&&e.products===0}function QN(e){return e.filter(t=>!t.personal).length}const goe=Du.title,yoe=Du.body,woe=15e3,boe="first-run",xoe=2e3,koe=["tour","tabs","make","task","working","open","answer","clear","snooze","unblock"];function ZN(e,t){var n;if(!t||t.step==="landed")return e;if((n=t.hidden)!=null&&n.length){const r=new Set(t.hidden);e=e.filter(s=>!r.has(s.id))}if(t.step==="done")return[];if(koe.includes(t.step)){const r=(t.backdrop??[]).filter((o,i)=>{var a;return((a=UN[i])==null?void 0:a.state)!=="needs"}),s=new Set([...t.examples??[],t.item,...r].filter(Boolean));return e.filter(o=>s.has(o.id))}if(t.step==="where"||t.step==="board"||t.step==="command"){const r=(t.backdrop??[]).filter((o,i)=>{var a;return t.step!=="where"||((a=UN[i])==null?void 0:a.state)!=="needs"}),s=new Set([...t.examples??[],t.item,...r].filter(Boolean));return e.filter(o=>s.has(o.id))}return e.filter(r=>r.id===t.item)}function voe(e){return e.findIndex(t=>t.waiting)}function Soe(e){return e.findIndex(t=>t.later)}function joe(e,t,n,r){if(!t||!t.examples.length)return!1;const s=new Set(e.map(o=>o.id));return!t.examples.some((o,i)=>i!==n&&i!==r&&s.has(o))}function $O(e,t,n,r){if(!t)return[];const s=new Set(e.map(o=>o.id));return t.examples.filter((o,i)=>i!==n&&i!==r&&s.has(o))}function Gu(e,t){return!e||t<0?null:e.examples[t]??null}function Coe(e,t,n){const r=Gu(t,n);return r?!e.some(s=>s.id===r):!1}function Kl(e,t){return!e||t<0?null:e.examples[t]??null}const PO="That one is an agent stopped, waiting on you. Open it and answer it.";function iy(e,t,n,r){return!e||e.step==="landed"?null:t===Kl(e,n)?PO:t===Gu(e,r)?"That one is not finished. Press L to deal with it later.":null}function Noe(e,t,n){return!e||e.step==="landed"?null:t===Kl(e,n)?PO:null}function Eoe(e,t,n,r,s,o={}){if(!t)return[];const i=new Set(n.map(c=>c.id)),a=c=>c&&i.has(c)?[c]:[];return e==="clear"?$O(n,t,r,s):e==="open"?a(t.item):e==="snooze"?o.picking?[]:a(Gu(t,s)):e==="unblock"?o.opened?[]:a(Kl(t,r)):[]}function Aoe(e,t){return!e.length||!t?!1:!e.includes(t)}function Toe(e,t){if(!t||!t.examples.length)return!1;const n=new Set(e.map(r=>r.id));return!t.examples.some(r=>n.has(r))}const _e={head:"Hand work to agents and get it back in one inbox.",headSub:"Write a thread, an agent works on it, and it comes back when it needs you.",terms:"Get started means you agree to the terms and the privacy policy.",getStarted:"Get started",page:"Set up your first project.",folderQ:"Where is your code?",folderPick:"Choose a folder on this computer",folderClause:"This is the folder the agents will run in.",folderAgain:"Choose a different one",folderHead:"Pick a folder for your first project.",folderLede:"Agents can read and change the files in it. Any folder of documents works.",folderRecent:"Folders you used recently",folderNone:"I do not have one, skip for now",folderOther:"Choose another folder",folderFirst:"Choose a folder",nameIn:"Agents will work in",nameInNone:"Agents will work in a new folder made for this project.",nameChoose:"Choose a folder",noFolderName:"My work",nameChange:"Change",nameGo:"Continue",missing:`${st} could not find Claude Code or Codex on this computer, and your agents run on one of them.`,missingLink:"Get Claude Code",nameQ:"What is this project called?",nameClause:"Taken from the folder. Change it to anything you like.",next:"Next",takenName:e=>`You already have a project called ${e}. Give this one another name.`,emptyName:"A project needs a name with letters or numbers in it.",notMade:e=>`${st} could not make the project. ${e}`,submit:"Submit",back:"Back",intro:[{head:"Write a thread and an agent picks it up",line:"It works on your computer and writes back here when it finishes or gets stuck",piece:"list"},{head:"A thread comes back to you only when it needs you",line:"The rest keep running until they finish or have a question",piece:"progress"},{head:"An empty inbox means nothing is waiting on you",line:"Your agents keep working in the background while you get on with your day",piece:"empty"}],pieceEmpty:"Nothing is waiting on you.",pieceAgents:"Active agents",introNext:"Next",handHead:"This is the tutorial.",handLine:"A practice project with a few example threads, and nothing you do in here is saved. Your own project is made already and it is waiting behind this.",handGo:"Start the tutorial",handSkip:"Skip the tutorial",leave:"Skip",leaveHead:"Stay for the tutorial?",leaveLine:`It is the quickest way to learn how threads work in ${Je}. You can leave now and start it again whenever you like from ⌘K.`,leaveStay:"Keep going",leaveGo:"Skip it",offerHead:"Take the tutorial first?",offerLine:"A practice project with a few example threads, so you can see how it all works. Nothing in it is yours and nothing in it is kept.",offerGo:"Start the tutorial",offerNot:"Not now",offerLater:"Any time: press ⌘K and type tutorial.",bandTag:"Tutorial",band:"Nothing in here is yours and nothing is saved.",bandLine:"nothing in here is real",bringHead:"Add the agents already on this computer.",agentsOffer:`${st} watches them and puts what they send you in your inbox.`,agentsFrom:e=>`Read from ${e}`,agentsAll:"Every project",agentsHere:"Only this project",agentsNoneAll:"No agents in your home folder yet. Anything you put there works in every project.",agentsNoneHere:"No agents in this project folder yet. Anything you put there works here only.",agentsRead:`Each one you keep lands in your inbox. ${st} never moves the file.`,finishHead:"You finished the tutorial.",finishLine:"Your inbox is empty and no agent is waiting on you.",finishLineAgents:"Getting your inbox back to empty is the goal.",finishNext:["Next, start a real thread. Press N or click New thread."],finishNextTeam:["Open Team to see what your teammates are working on. To message one, start a thread and pick them in To."],finishGo:"Open my inbox",gateHead:`${st} needs Claude Code or Codex.`,gateDo:`Install either one, then check again. Your inbox opens as soon as ${Je} can see it.`,gateCheck:"Check again",gateChecking:"Looking",gatePointing:"Choosing",gateGetSub:"Takes a few minutes, on its own page",gateStill:"Still nothing here. A fresh install can take a moment to appear."};function Moe(e,t,n=[]){return e.missing?{show:!0,blocked:!0,go:!1,head:_e.gateHead,line:_e.missing}:!t.read||n===null?{show:!1,blocked:!1,go:!1,head:"",line:""}:!t.some&&!n.some(r=>!r.imported)?{show:!1,skip:!0,blocked:!1,go:!0,head:"",line:""}:{show:!0,blocked:!1,go:!0,head:_e.bringHead,line:_e.agentsOffer}}function Roe(e,t={}){return[{key:"get",mark:"C",name:_e.missingLink,sub:_e.gateGetSub,href:e},{key:"check",name:t.checking?_e.gateChecking:_e.gateCheck,other:!0},{key:"mine",name:t.pointing?_e.gatePointing:dt.haveOne,other:!0}]}function eE(e){return!e.missing}function tE(e,t){return e.certain&&!e.found&&t.certain&&!t.found}const Kt=(e,t,n=null,r="",s={})=>({quiet:e,lead:t,key:n,tail:r,...s}),Ioe=["inbox","progress","done"];function Ch(e,t){const n=e!=null&&e.length?e:Ioe;return n[(n.indexOf(t??"inbox")+1)%n.length]}const Doe=["inbox","progress","snoozed","done","all"],Ooe={inbox:"Needs you",progress:"In progress",snoozed:"Later",done:lu.short,all:"All"};function nE(e){const t=e?Doe.indexOf(e):-1;return t>=0?`.th-bar .tm-tab:nth-child(${t+1})`:null}const Loe={inbox:" to come back.",snoozed:" for the one you put off.",progress:" for the agent you answered.",done:" for everything you closed."};function zO(e,t,n={}){var r;switch(e){case"tour":return Kt("This is your inbox. Each row is a thread, a job you gave an agent.","Threads come back here when they are done or need you.","↵","",{next:!0});case"tabs":return Kt("Later is what you put off, and Done is what you finished.","Needs you is what waits on you. In progress is what agents are doing.","↵","",{next:!0});case"make":return Kt("Now send one of your own. This first one is written for you.","Press ","N"," or click New thread.");case"task":return Kt("","Press ","⌘↵"," or click Send.");case"working":return t>=woe?Kt("Your agent is running.","Still reading. A bigger project takes longer than this one, and the answer will be here when it comes."):Kt("Your agent is running.","It comes back in a few seconds.");case"open":return Kt(n.replies?"Your agent made the change and sent it back.":"Your agent worked on its own, and this row is what it sent back.","Press ","↵"," or click the row to open it.");case"answer":return n.replies?Kt("It is shorter now, so this one is finished.","Press ","E"," to mark it done."):n.replying?Kt("Your reply is written for you.","Press ","⌘↵"," or click Send to ask for it."):Kt("Your agent finished, and offers to make it shorter.","Press ","R"," or click the reply box to ask for that, or E to mark it done.",{alt:"E"});case"clear":return Kt(n.left===1?"This one is finished too.":"This one is finished. Z brings back anything you mark done.","Press ","E"," to mark it done.",{caps:2});case"snooze":return n.picking?Kt("Pick when it should come back.","It leaves your inbox until then and comes back on its own."):Kt("Real work, but not for today. An empty inbox is the goal.","Press ","L"," to deal with it later.");case"unblock":return n.opened?Kt("Pick one and the agent carries on with it. Nothing goes to anyone else.","Press ","1"," or click the first answer."):Kt("This agent is waiting on your answer, and marking it done leaves it stuck.","Press ","↵"," or click the row to open it.");case"where":{const s="⇥",o=(r=n.tabNames)==null?void 0:r[Ch(n.tabs,n.view)],i=o?` or click ${o}`:"",a=i+(Loe[Ch(n.tabs,n.view)]??" for the next one.");if(n.view==="snoozed")return Kt("The one you put off is here, and it comes back on its own.","Press ",s,a);if(n.view==="progress")return Kt("The agent you answered is here, working without you.","Press ",s," or click another tab to go on.");if(n.view==="done"){const c=Ch(n.tabs,n.view)==="all";return Kt("Everything you finished is kept here.","Press ",s,c?" to go on.":a)}return Kt("Great! Your inbox is now empty. That is inbox zero, and it is the goal.","Press ",s,`${i} to see where it all went.`)}case"board":return n.board?Kt("This is the board: every thread, in columns for what is happening to it.","Press ","B"," again to go back to the list."):Kt("The board shows everything at once, in columns.","Press ","B"," or click View and filters, then Board.");case"command":return n.palette?Kt(`Every command in ${Je} is in this list. Later, type tutorial here to take this again.`,"Press any key to finish.",null,"",{anyKey:!0}):Kt("Last one: every command is one key away.","Press ","⌘K"," to see them all.");default:return null}}const rE=4e3;function vl(e){const t=e.key??"",n=!!e.metaKey||!!e.ctrlKey;return n&&t==="Enter"?"⌘↵":n&&t.toLowerCase()==="k"?"⌘K":n?null:t==="Enter"?"↵":t==="Tab"?"⇥":t.length===1&&/[a-z0-9]/i.test(t)?t.toUpperCase():null}const $oe={"⇥":"Tab","↵":"Return"};function Poe(e){return e?$oe[e]??null:null}function FO(e,t){if(!e)return!1;const n=vl(t);return n!==null&&n!==e}const zoe='input, textarea, [contenteditable="true"], [contenteditable=""], .fr-stay-scrim';function Ou(e){const t=e;return!t||typeof t.closest!="function"?!0:!t.closest(zoe)}const Foe="⇥";function Boe(e,t,n){return!Ou(n)||!FO(e,t)?!1:vl(t)!==Foe}const BO=".fr-tether, .fr-ring, .fr-veil, .fr-band, .fr-out",_oe={unblock:[".focus-dock"]};function Woe(e,t){const n=e;if(!n||typeof n.closest!="function"||!Ou(n)||n.closest(BO))return!1;const r=t.filter(s=>!!s);return r.length?!r.some(s=>s===n||typeof s.contains=="function"&&s.contains(n)):!1}const sE=["pointerdown","mousedown","mouseup","click","dblclick"],_O=["tour","tabs","make","task","working","open","answer","clear","snooze","unblock","where","board","command"],Ui={make:['button[aria-label="New thread"]','.th-right button[data-hint="new-task"]',"button.th-new"],tour:[".list-pane .list",".list-pane"],tabs:[".th-bar .tm-tabs",".workspace-navigation .workspace-tabs",".tabs"],task:[".tc-card .tc-send-main"],working:[".list-pane .row",".th-bar .tm-tab:nth-child(2)"],open:[".list-pane .row"],answer:[".focus-dock .dock-card",".focus-dock"],clear:[".list-pane .row"],snooze:[".modal.snooze .palette-list",".list-pane .row"],unblock:[".opt-strip",".list-pane .row"],where:[".th-bar .tm-tabs",".workspace-navigation .workspace-tabs",".tabs"],board:[".th-pop",".th-right .th-disp"],command:[".modal.palette",'button[aria-label="Commands"]']},oE={clear:".list-pane .row:last-of-type",snooze:".list-pane .row:last-of-type"};function Hoe(e,t){const n=t.filter(o=>o.w>0&&o.h>0&&o.position!=="absolute"&&o.position!=="fixed");if(!n.length)return e;const r=Math.min(...n.map(o=>o.x)),s=Math.min(...n.map(o=>o.y));return{x:r,y:s,w:Math.max(...n.map(o=>o.x+o.w))-r,h:Math.max(...n.map(o=>o.y+o.h))-s}}const WO=6,Uoe=14,Koe=.34;function HO(e){const t=Math.min(e.w,e.h);return Math.max(WO,Math.min(Uoe,Math.round(t*Koe)))}function Voe(e,t){let n=1/0;for(const r of t){const s=Math.max(e.x-(r.x+r.w),r.x-(e.x+e.w)),o=Math.max(e.y-(r.y+r.h),r.y-(e.y+e.h)),i=Math.max(s,o);i<0||(n=Math.min(n,i/2))}return n}const qoe=12,Yoe=6,Goe=.26;function Joe(e){const t=Math.min(e.w,e.h);return Math.max(Yoe,Math.min(qoe,Math.round(t*Goe)))}const Xf=18,Mk=360,UO=180,Xoe=220,Qf=22;function Qoe(e,t,n,r=1/0){const s=Math.max(WO,Math.min(HO(e),Math.floor(r))),o=Math.round(e.x-s),i=Math.round(e.y-s),a=Math.round(e.w+s*2),c=Math.round(e.h+s*2),u=e.x+e.w>n.w-Xoe,d=Math.round(e.x),h=Math.min(t.right,n.w),f=u?e.x+e.w:h-d-32,p=Math.max(UO,Math.min(Mk,f)),m=i+c+Xf,w=m+Qf*2+16<=n.h,b=w?m:Math.round(i-Xf-Qf);return{ring:{x:o,y:i,w:a,h:c,r:Joe({w:a,h:c})},text:{x:d,y:b,w:p,right:u?Math.round(n.w-(e.x+e.w)):null},below:w}}function Zoe(e,t,n,r){const s=n.filter(i=>i.bottom>e&&i.top<e+t);if(!s.length)return e;const o=Math.round(Math.max(...s.map(i=>i.bottom))+10);return o+t>r.h?e:o}const eie={task:"body",working:".list-pane",open:".list-pane",clear:".list-pane",snooze:".list-pane",answer:".focus-pane"},Zf=10,tie=".list-pane .row, .dock-card, .modal, .focus-actions, .th-bar",Kp="zero.firstRun",Rk="zero.firstRun.done";function nie(e,t){return typeof e=="string"&&ru.includes(e)?e:e==="note"?"clear":e==="look"?"hand":e==="who"?"task":e==="inbox"||e==="away"||e==="goal"?"hand":t?"landed":"welcome"}function rie(e){try{const t=e.getItem(Kp);if(!t)return Tl;const n=JSON.parse(t);return{...Tl,...n,step:nie(n.step,!!n.product)}}catch{return Tl}}function sie(e,t){try{e.setItem(Kp,JSON.stringify(t))}catch{}}function oie(e){try{e.setItem(Rk,"1"),e.removeItem(Kp)}catch{}}function iE(e){try{return e.getItem(Rk)==="1"}catch{return!1}}function iie(e){try{e.removeItem(Rk),e.removeItem(Kp)}catch{}}const ru=["welcome","plan","folder","name","hand","tour","tabs","make","task","working","open","answer","clear","snooze","unblock","where","board","command","done","landed"];function aie(e){const t=ru.indexOf(e);return t<0||t+1>=ru.length?null:ru[t+1]}const lie={},cie=["tour","tabs","make","task","working","open","answer","clear","snooze","unblock","where","board","command"];function ep(e){return!!e&&!!e.practice&&cie.includes(e.step)}function uie(e){return e?e==="1"?"welcome":ru.includes(e)?e:null:null}function Vp(e){return e.user.length+e.project.length>0}function die(e){return!e||!Vp(e)}function hie(e,t){return t||e&&Vp(e)?e:null}function fie(e,t){return!e||Vp(t)}function pie(e,t){return t||e&&e.some(n=>n.count>0)?e:null}function aE(e,t){const n=String(e??"").trim();if(/already exists/i.test(n))return _e.takenName(t);if(/needs a name/i.test(n))return _e.emptyName;const r=n.replace(/^Error invoking remote method '[^']*':\s*/i,"").replace(/^Error:\s*/i,"");return _e.notMade(r?/[.!?]$/.test(r)?r:`${r}.`:"It did not say why.")}function mie(e){const t=String(e??"").trim().replace(/\/+$/,"");if(!t)return null;const n=jh(t);return n?{name:n,repoPath:t}:null}function gie(e){return e.replace(/^\/Users\/[^/]+/,"~")}function yie({onCreate:e,onClose:t,onRefused:n}){const[r,s]=g.useState(!1),o=g.useRef(!1),i=a=>{const c=mie(a);if(!c){t();return}s(!1),e(c)};return g.useEffect(()=>{if(o.current)return;o.current=!0;let a=!0;return(async()=>{const{path:u,refused:d,browse:h}=await q.chooseFolder();if(a){if(h){s(!0);return}if(d){n==null||n(d),t();return}if(!u){t();return}i(u)}})(),()=>{a=!1}},[]),r?l.jsx(DO,{startIn:null,onPick:i,onClose:t}):null}function lE(e,{filter:t=null,last:n=null}={}){var s;const r=o=>!!o&&e.some(i=>i.slug===o);return r(t)?t:r(n)?n:((s=e[0])==null?void 0:s.slug)??null}function KO(e,t){var n;return((n=e.find(r=>r.slug===t))==null?void 0:n.repoPath)??null}function VO(e,t){var n;return((n=e.find(r=>r.slug===t))==null?void 0:n.name)??""}function wie(e){return(e??"").replace(/^\/Users\/[^/]+/,"~")}const bie=["no","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten"],cl=e=>e>=0&&e<=10?bie[e]:String(e),fs={head:"Add the agents already on this computer.",noProject:"Make a project first, and your agents can land in its inbox.",newProject:"New project…",headNone:"No agents to bring across yet.",noneWhere:e=>`No agent files in ${e} or your project folders, and no recent Claude Code or Codex conversations you started yourself.`,noneLater:"When you have some, press ⌘K and type import.",allIn:e=>e===1?"The one conversation from the last ten days is already in your inbox.":`All ${e} conversations from the last ten days are already in your inbox.`,headAllIn:"Nothing new to bring across.",laterAllIn:"When there is more, press ⌘K and type import.",lookAgain:"Look again",looking:"Looking",foot:"Each one you keep lands in your inbox, and your agent files stay where they are.",go:"Add them",reading:"Reading this computer…"};function xie(e){return[...e.items.map(t=>t.path),...(e.threads??[]).map(t=>t.path)]}function kie(e,t){const n=t?new Set(t):null;let r=0,s=0;for(const o of e)r+=o.items.filter(i=>!n||n.has(i.path)).length,s+=(o.threads??[]).filter(i=>!n||n.has(i.path)).length;return{agents:r,threads:s}}function vie({found:e,folders:t=[],products:n=[],project:r=null,threads:s=[]}){const o=[],i=VO(n,r),a=KO(n,r);e!=null&&e.user.length&&o.push({key:"everywhere",kind:"everywhere",name:i,slug:r,folder:null,where:qO.homeFolder,items:e.user,threads:[]}),e!=null&&e.project.length&&r&&o.push({key:`project:${r}`,kind:"project",name:i,slug:r,folder:a,where:wie(a),items:e.project,threads:[]});const c=n.map(h=>h.name);for(const h of jie(t,n)){const f=uE(h,c);c.push(f),o.push({key:`new:${h.folder}`,kind:"new",name:f,slug:null,folder:h.folder,where:h.short,items:h.agents??[],threads:[]})}const u=new Map(o.filter(h=>h.folder).map(h=>[ay(h.folder),h])),d=new Map(n.filter(h=>h.repoPath).map(h=>[ay(h.repoPath),h]));for(const h of s){const f=ay(h.folder);if(!f)continue;let p=u.get(f);if(!p){const m=d.get(f),w=m?{key:`project:${m.slug}`,kind:"project",name:m.name,slug:m.slug,folder:h.folder,where:h.short,items:[],threads:[]}:{key:`new:${h.folder}`,kind:"new",name:uE({name:h.folderName},c),slug:null,folder:h.folder,where:h.short,items:[],threads:[]};m||c.push(w.name),o.push(w),u.set(f,w),p=w}p.threads.push(h)}return o}const ay=e=>String(e??"").replace(/\/+$/,""),qO={homeFolder:"~/.claude/agents"};function cE({added:e=0,already:t=0,name:n="",inboxes:r=1,made:s=[],noun:o="agent"}){if(e===0&&t===0)return"Nothing was ticked, so nothing was filed.";const i=r>1,a=n?` ${n}`:"";if(e===0)return i?t===1?`That ${o} already has a row.`:`${cl(t)} of them already have rows.`:t===1?`That ${o} already has a row in${a}.`:`${cl(t)} of them already have rows in${a}.`;const c=e===1?"One row is":`${cl(e)} rows are`,u=i?`${c} in ${cl(r).toLowerCase()} inboxes.`:`${c} in your ${s.length===1?"new ":""}${n} inbox.`,d=i&&s.length?s.length===1?` ${s[0]} is new.`:` ${cl(s.length)} of them are new.`:"";if(t===0)return`${u}${d}`;const h=t===1?" One already had one.":` ${cl(t)} already had rows.`;return`${u}${h}${d}`}function Sie({read:e,picked:t,dests:n}){if(!e||t.length===0)return!1;const r=new Set(t);for(const s of n)if(xie(s).some(o=>r.has(o))&&s.kind!=="new"&&!s.slug)return!1;return!0}function uE(e,t=[]){const n=((e==null?void 0:e.name)??"").trim();if(!n)return"";const r=/[A-Z\s]/.test(n)?n:n.replace(/[-_.]+/g," ").split(" ").filter(Boolean).map(o=>o.replace(/^\w/,i=>i.toUpperCase())).join(" "),s=new Set(t.map(ly));if(!s.has(ly(r)))return r;for(let o=2;o<100;o+=1)if(!s.has(ly(`${r} ${o}`)))return`${r} ${o}`;return r}function ly(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)}function jie(e,t){const n=new Set(t.map(r=>(r.repoPath??"").replace(/\/+$/,"")).filter(Boolean));return e.filter(r=>!n.has(r.folder.replace(/\/+$/,"")))}const su={head:"Bring in your recent agents",line:"From the last 10 days. Untick any you want to leave out.",lineOlder:"Nothing from the last 10 days, so here are your most recent. Untick any you want to leave out.",add:e=>e>0?`Add ${e} to your inbox`:"Nothing ticked",notNow:"Not now"};function Cie(e=[],t=Date.now()){const n=e.filter(s=>Number(s==null?void 0:s.when)>0),r=t-10*864e5;return n.length&&n.every(s=>Number(s.when)<r)?su.lineOlder:su.line}function Nie(e,t=Date.now()){const n=new Date(Number(e)||0);if(!e||!Number.isFinite(n.getTime()))return"";const r=o=>new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),s=Math.round((r(new Date(t))-r(n))/864e5);return s<=0?"today":s===1?"yesterday":s<7?n.toLocaleDateString("en-US",{weekday:"long"}):n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Eie(e,t=Date.now()){const n=[],r=[];for(const s of e){for(const o of s.threads??[]){const i=o.source==="codex"?"Codex":"Claude Code",a=Nie(o.when,t);n.push({path:o.path,title:o.title,meta:[i,s.name,a].filter(Boolean).join(" · "),when:o.when})}for(const o of s.items)r.push({path:o.path,title:o.title,meta:`Claude Code agent · ${s.name}`,when:0})}return[...n.sort((s,o)=>o.when-s.when),...r]}function Aie(){return l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M4 12.5 9.5 18 20 6.5"})})}function YO({products:e,filter:t,walk:n,onDone:r,onNewProject:s,onProjectMade:o,onClose:i}){const a=(()=>{try{return localStorage.getItem("zero.lastProduct")}catch{return null}})(),[c,u]=g.useState(()=>lE(e,{filter:t,last:a})),[d,h]=g.useState(null),[f,p]=g.useState(()=>new Set),[m,w]=g.useState(!1),[b,x]=g.useState(n?n.folders:null),[v,S]=g.useState(null),[C,O]=g.useState([]),N=g.useMemo(()=>[...e,...C.filter(K=>!e.some(z=>z.slug===K.slug))],[e,C]),P=KO(N,c);g.useEffect(()=>{if(c&&N.some(z=>z.slug===c))return;const K=lE(N,{filter:t,last:a});K&&K!==c&&u(K)},[N,t,a,c]);const M=n==null?void 0:n.folders;g.useEffect(()=>{if(n){x(M??null);return}let K=!0;return(async()=>{const z=await q.agentFolders();K&&x(z)})(),()=>{K=!1}},[n,M]),g.useEffect(()=>{let K=!0;return(async()=>{const z=await q.agentThreads();K&&S(z)})(),()=>{K=!1}},[]),g.useEffect(()=>{let K=!0;return h(null),(async()=>{const z=await q.agentFiles({folder:P,product:c});K&&h({user:z.user,project:z.project})})(),()=>{K=!1}},[P,c]);const R=g.useMemo(()=>(v??[]).filter(K=>!K.imported),[v]),L=((v==null?void 0:v.length)??0)-R.length,H=g.useMemo(()=>vie({found:d,folders:b??[],products:N,project:c,threads:R}),[d,b,N,c,R]),_=g.useMemo(()=>Eie(H),[H]),Y=g.useMemo(()=>_.map(K=>K.path).filter(K=>!f.has(K)),[_,f]),se=K=>p(z=>{const xe=new Set(z);return xe.has(K)?xe.delete(K):xe.add(K),xe}),re=_.length>0,T=!!d&&!!b&&v!==null,W=Sie({read:T,picked:Y,dests:H}),[le,ge]=g.useState(!1),j=g.useCallback(async()=>{if(!le){ge(!0);try{const[K,z,xe]=await Promise.all([q.agentFiles({folder:P,product:c}),q.agentFolders(),q.agentThreads()]);h({user:K.user,project:K.project}),x(z),S(xe)}finally{ge(!1)}}},[le,P,c]),ae=g.useCallback(async K=>{var z,xe;if(!(m||K.length===0)){w(!0);try{const Oe=new Set(K),F=new Map,J=[];for(const Ie of H){const Q=Ie.items.filter(te=>Oe.has(te.path)).map(te=>te.name),he=(Ie.threads??[]).filter(te=>Oe.has(te.path)).map(te=>te.id);if(!(!Q.length&&!he.length)){if(Ie.kind==="new"&&Ie.folder)J.push({folder:Ie.folder,name:Ie.name,load:{names:Q,ids:he}});else if(Ie.slug){const te=F.get(Ie.slug)??{names:[],ids:[]};F.set(Ie.slug,{names:[...te.names,...Q],ids:[...te.ids,...he]})}}}let ze=0,ye=0,Z=0,Ce="";const Ee=[],oe=async(Ie,Q)=>{if(Q.names.length){const he=await q.importAgents({product:Ie,agents:Q.names});ze+=he.added,ye+=he.already}if(Q.ids.length){const he=await q.importThreads({product:Ie,threads:Q.ids});ze+=he.added,ye+=he.already}Z+=1};for(const[Ie,Q]of F)await oe(Ie,Q),Ce=VO(N,Ie);for(const Ie of J){let Q=null;try{const he=await q.createProduct({name:Ie.name,repoPath:Ie.folder,ofMany:!0});Q=(he==null?void 0:he.slug)??null}catch{Q=null}Q&&(Ee.push(Ie.name),O(he=>[...he,{slug:Q,name:Ie.name,repoPath:Ie.folder}]),o==null||o(Q),await oe(Q,Ie.load),Ce=Ie.name)}if(Ee.length)try{(xe=(z=window.zero)==null?void 0:z.track)==null||xe.call(z,"repo_connected",Ee.length)}catch{}const ne=kie(H,K);r({added:ze,already:ye,name:Z===1?Ce:"",inboxes:Z,made:Ee,noun:ne.agents?"agent":"thread"})}finally{w(!1)}}},[m,H,N,r,o]);g.useEffect(()=>{const K=z=>{if(z.key==="Escape"){if(z.preventDefault(),n)return;i();return}if(z.key==="Enter"&&(z.metaKey||z.ctrlKey)){if(z.preventDefault(),n&&!re){n.onSkip();return}W&&ae(Y)}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[ae,Y,W,re,n,i]);const me=({on:K})=>l.jsx("span",{className:`ia-box is-${K?"all":"none"}`,"aria-hidden":"true",children:K&&l.jsx(Aie,{})}),E=K=>{const z=!f.has(K.path);return l.jsxs("button",{className:z?"ia-agent ia-line-row on":"ia-agent ia-line-row","aria-pressed":z,onClick:()=>se(K.path),children:[l.jsx(me,{on:z}),l.jsx("span",{className:"ia-agent-name",children:K.title}),l.jsx("span",{className:"ia-line-meta",children:K.meta})]},K.path)};return l.jsx("div",{className:`modal-backdrop compose-backdrop${n?" in-walk":""}`,onClick:n?void 0:i,children:l.jsxs("div",{className:`modal ia-card ia-one${n?" in-walk":""}`,onClick:K=>K.stopPropagation(),children:[l.jsx("div",{className:"ia-top",children:l.jsx("h1",{className:"ia-head",children:T&&!re?L>0?fs.headAllIn:fs.headNone:su.head})}),T&&re&&l.jsx("p",{className:"ia-line",children:Cie(v??[])}),!T&&l.jsx("div",{className:"ia-empty",children:fs.reading}),T&&!re&&l.jsxs("div",{className:"ia-none",children:[l.jsx("p",{className:"ia-none-where",children:L>0?fs.allIn(L):fs.noneWhere(qO.homeFolder)}),l.jsx("p",{className:"ia-none-later",children:L>0?fs.laterAllIn:fs.noneLater}),l.jsx("button",{type:"button",className:"ia-look-again",onClick:j,disabled:le,children:le?fs.looking:fs.lookAgain})]}),T&&re&&l.jsx("div",{className:"ia-scroll ia-lines",children:_.map(E)}),T&&re&&N.length===0&&!H.some(K=>K.kind==="new")&&l.jsxs("p",{className:"ia-line",children:[fs.noProject," ",l.jsx("button",{type:"button",className:"ia-word",onClick:s,children:fs.newProject})]}),T&&re&&l.jsxs("div",{className:"ia-foot ia-foot-one",children:[l.jsxs("button",{className:"dock-send",disabled:!W||m,onClick:()=>ae(Y),children:[su.add(Y.length)," ",l.jsx("kbd",{children:"⌘↵"})]}),l.jsxs("button",{type:"button",className:"ia-not-now",onClick:n?n.onSkip:i,disabled:m,children:[n?n.skip:su.notNow,!n&&l.jsx("kbd",{children:"esc"})]})]}),n&&T&&!re&&l.jsx("button",{type:"button",className:"ia-walk-on",onClick:n.onSkip,disabled:m,children:n.skip})]})})}function Tie(e,t,n=Date.now()){return t.filter(r=>rp(r)===e.id).sort((r,s)=>s.createdAt-r.createdAt).map(r=>{const s=sp(r),o=r.status==="open"||r.status==="claimed";return{id:r.id,when:iu(r.createdAt,n),what:o?"running":s?"clean":r.result||"finished without saying anything",news:!o&&!s,late:Mie(e,r)}})}function Mie(e,t,n){const r=yz(e,t.createdAt);if(!r)return null;const[s,o,i]=r.split("-").map(Number),[a,c]=e.at.split(":").map(Number),u=new Date(s,o-1,i,a,c,0,0).getTime();return t.createdAt-u<15*6e4?null:`ran ${Bs(u,t.createdAt)} late`}function Rie(e){return`${new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})} ${op(e).toLowerCase()}`}function Iie({rule:e,items:t,editing:n,onClose:r,onEdit:s,onEditClose:o,onSave:i,onEnd:a}){const c=Tie(e,t),u=zb(e),d=new Date(`2026-01-01T${e.at}:00`).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=cU(e);return l.jsxs("div",{className:"focus-pane",children:[l.jsx("div",{className:"focus-scroll",children:l.jsxs("div",{className:"focus",children:[l.jsxs("div",{className:"focus-head",children:[l.jsxs("button",{className:"back-esc in-head",onClick:r,"aria-label":"Back",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5"})}),l.jsx("span",{children:"esc"})]}),l.jsxs("div",{children:[l.jsx("div",{className:"focus-title",children:e.title}),l.jsxs("div",{className:"focus-meta",children:[l.jsx("span",{children:e.productName}),l.jsx("span",{children:"·"}),l.jsxs("span",{children:["daily at ",d]}),u&&l.jsxs(l.Fragment,{children:[l.jsx("span",{children:"·"}),l.jsxs("span",{children:["next ",Rie(u)]})]})]})]})]}),e.body&&l.jsx("div",{className:"focus-body",children:l.jsx("div",{className:"markdown",children:l.jsx(jl,{remarkPlugins:[Cl],children:e.body})})}),l.jsxs("div",{className:"runs",children:[c.length===0&&l.jsx("div",{className:"run",children:l.jsx("span",{className:"run-what",children:"It has not run yet."})}),c.map(f=>l.jsxs("div",{className:"run",children:[l.jsx("span",{className:"run-when",children:f.when}),l.jsxs("span",{className:f.news?"run-what news":"run-what",children:[f.what,f.late?` · ${f.late}`:""]})]},f.id))]}),l.jsx("div",{className:"runs-note",children:"The runs still on file."})]})}),l.jsx("div",{className:"focus-dock",children:l.jsxs("div",{className:"focus-dock-inner",children:[l.jsx("div",{className:"dock-card",children:n?l.jsx(Die,{message:h,onSave:i,onClose:o}):l.jsxs("button",{className:"dock-pill",onClick:s,children:[l.jsx("span",{className:"dock-pill-text",children:"Change what it does…"}),l.jsx("span",{className:"dock-pill-key",children:l.jsx("kbd",{children:"R"})})]})}),l.jsx("button",{className:"rule-end",onClick:a,children:"End this repeating task"})]})})]})}function Die({message:e,onSave:t,onClose:n}){const[r,s]=g.useState(e),o=g.useRef(null);g.useEffect(()=>{const c=o.current;c&&(c.focus(),c.setSelectionRange(c.value.length,c.value.length),c.scrollTop=c.scrollHeight)},[]);const i=r.trim()!==e.trim(),a=()=>{i&&r.trim()&&t(r.trim())};return l.jsxs(l.Fragment,{children:[l.jsx("textarea",{className:"dock-input rule-input",ref:o,value:r,onChange:c=>s(c.target.value),placeholder:"What should it do every time?",onKeyDown:c=>{(c.metaKey||c.ctrlKey)&&c.key==="Enter"&&a(),c.key==="Escape"&&(c.stopPropagation(),n())}}),l.jsxs("div",{className:"compose-sentence",children:[l.jsx("span",{className:"compose-clauses",children:l.jsx("span",{className:"dim",children:"Every run after this one reads this."})}),l.jsxs("button",{className:"dock-send",onClick:a,disabled:!i||!r.trim(),title:"Save · ⌘↵",children:["Save ",l.jsx("kbd",{children:"⌘↵"})]})]})]})}function Oie(e){const t=new Map;return e.map(n=>{const r=t.get(n.id)??0;return t.set(n.id,r+1),r?`${n.id}#${r}`:n.id})}function Lie(e,t){const n=e.trim().toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return!0;const r=`${t.label} ${t.keywords??""}`.toLowerCase();return n.every(s=>r.includes(s))}const $ie=["snooze"],dE="remind me snooze put off defer schedule";function Pie(e,t){if(!e.trim())return t;const n=r=>$ie.includes(r.id)?0:1;return[...t].sort((r,s)=>n(r)-n(s))}const hE="light mode dark mode appearance colours colors";function zie(e,t="dark"){const n={id:"theme-light",label:"Theme: Light",hint:"theme",keywords:`${hE} theme themes light`,to:"light"},r={id:"theme-dark",label:"Theme: Dark",hint:"theme",keywords:`${hE} theme themes dark ember`,to:"ember-grid"},s={id:"theme-match",label:"Theme: Match system",hint:"theme",keywords:"theme themes match system mac automatic appearance",to:"match"};return e==="light"?[r,s]:e==="match"?t==="light"?[r,n]:[n,r]:[n,s]}const fE=32;function Fie(e){const t=e.trim();let n=t;if(t.length>fE){const r=t.slice(0,fE),s=r.lastIndexOf(" ");n=`${(s>0?r.slice(0,s):r).trimEnd()}…`}return`Nothing matches “${n}”.`}function Bie({products:e,supervisorPaused:t,itemCommands:n=[],batch:r=!1,order:s=[],look:o,machine:i="dark",onSetLook:a,staleFiles:c=[],updateReady:u=null,onInstallUpdate:d,onCheckUpdate:h,moveToApplications:f=!1,onMoveToApplications:p,filtering:m=!1,onOpenFilter:w,onClearFilter:b,onView:x,onPause:v,onResume:S,onRankFirst:C,onOpenProjects:O,onNewProject:N,onStanding:P,onSettings:M,onShortcuts:R,panelUp:L,onTogglePanel:H,boardUp:_=!1,onFlipView:Y,keyHints:se,onSetKeyHints:re,onSearch:T,onFirstRun:W,onTutorial:le,onImportAgents:ge,onFreshUser:j,onDemo:ae,onClose:me}){const[E,K]=g.useState(""),[z,xe]=g.useState(0),Oe=g.useRef(null);g.useEffect(()=>{var ye;return(ye=Oe.current)==null?void 0:ye.focus()},[]);const F=g.useMemo(()=>[{id:"new-project",label:"New project…",hint:"name it, and it is yours",run:N},...n,{id:"filter",label:"Filter…",hint:"Project, priority or agent",run:w},...m?[{id:"clear-filter",label:"Clear filter",run:b}]:[],...O?[{id:"projects-page",label:"Projects…",hint:"which goes first, names and rules",keywords:"priority order rank reorder sort first top priorities rename project settings",run:O}]:[],...e.map((ye,Z)=>({id:`rank-${ye.slug}`,label:`Rank ${ye.name} first`,hint:s.includes(ye.slug)?`now #${Z+1} of ${e.length}`:"not ranked yet",run:()=>C(ye.slug)})),{id:"search",label:"Search threads",keyHint:"/",run:T},{id:"view-inbox",label:"Inbox",run:()=>x("inbox")},{id:"view-progress",label:"In progress",run:()=>x("progress")},{id:"view-done",label:"Closed",run:()=>x("done")},...zie(o,i).map(ye=>({id:ye.id,label:ye.label,hint:ye.hint,keywords:ye.keywords,run:()=>a(ye.to)})),...u?[{id:"update",label:`Restart to update ${Je}`,hint:`version ${u} has downloaded · restarting puts you back where you were`,keywords:"update upgrade new version restart",run:()=>d==null?void 0:d()}]:[],...f?[{id:"update-move",label:An.button,hint:`${Je} cannot update itself from where it is now`,keywords:"update upgrade move applications folder disk image read-only stuck",run:()=>p==null?void 0:p()}]:[],...u?[]:[{id:"update-check",label:_s.check,hint:`look now instead of waiting for ${Je} to look on its own`,keywords:"update upgrade new version release newest restart",run:()=>h==null?void 0:h()}],...c.length?[{id:"stale",label:`Restart ${Je} to pick up main-process changes`,hint:`${c.length} file${c.length===1?"":"s"} changed since this one started · ⌘R will not pick them up`,run:()=>{}}]:[],{id:"pause",label:t?"Unpause agents":"Pause agents",hint:t?"sessions will spawn again":"no new sessions spawn",run:()=>v(!t)},...r?[]:[{id:"resume-stopped",label:"Resume interrupted agents",hint:"respawn work stranded by a usage limit or crash",run:S}],{id:"standing",label:"General agent instructions…",hint:"every agent, every task",keywords:"standing instructions rules your my brief guidelines preferences every agent every session tell agents dont do",run:P},{id:"settings",label:"Settings…",hint:"the workspace, and every project",run:M},{id:"shortcuts",label:"Keyboard shortcuts",hint:`every key ${Je} has`,keywords:"keys keyboard shortcut hotkeys commands cheatsheet help what does press bindings",run:R},{id:"panel",label:L?"Collapse sidebar":"Expand sidebar",hint:"what this product is, and what else is open on it",keyHint:"\\",run:H},...Y?[{id:"flip-view",label:_?"Show as a list":"Show as a board",keywords:"view board list columns kanban switch toggle",keyHint:"B",run:Y}]:[],{id:"import-agents",label:"Import agents from Claude Code or Codex",hint:"your last ten days on this computer · they land in your inbox",keywords:"import agents claude code codex conversations threads sessions subagents existing mine bring across add my recent",run:ge},{id:"tutorial",label:"Take the tutorial",hint:"a pretend project · nothing is kept",keywords:"tutorial practice practise walkthrough walk tour again show me around teach learn training how does this work sandbox lesson",run:le},{id:"first-run",label:`Set ${Je} up again`,hint:"from the welcome screen · makes a project",keywords:"onboarding first run new user welcome intro setup start over from scratch install fresh",run:W},{id:"demo",label:"Open a demo inbox",hint:"invented work · yours keeps running",keywords:"demo demonstration present presentation pitch investor customer screen share screenshare record video sample fake example stage not mine hide my work",run:ae},{id:"fresh-user",label:`Open ${Je} as a new user`,hint:"nothing set up · yours keeps running",keywords:"new user fresh install stranger onboarding first run clean empty blank test website download nothing of mine agents claude code sessions setup plan codex chatgpt not installed",run:()=>j(!1)},{id:"keyhints",label:se?"Turn off keyboard shortcut hints":"Turn on keyboard shortcut hints",hint:"the keys a row and the tabs offer, drawn when you point at them",run:()=>re(!se)}],[n,r,e,t,s,N,m,w,b,x,v,S,C,O,P,M,R,o,i,a,c,u,d,f,p,L,H,_,Y,se,re,T,W,le,ge,j,ae]),J=g.useMemo(()=>{const ye=E.trim().toLowerCase();return ye?Pie(ye,F.filter(Z=>Lie(ye,Z))):F},[F,E]),ze=g.useMemo(()=>Oie(J),[J]);return g.useEffect(()=>xe(0),[E]),l.jsx("div",{className:"modal-backdrop palette-backdrop",onClick:me,children:l.jsxs("div",{className:"modal palette",onClick:ye=>ye.stopPropagation(),children:[l.jsx("input",{ref:Oe,className:"palette-input",value:E,onChange:ye=>K(ye.target.value),placeholder:"Type a command…",onKeyDown:ye=>{ye.key==="Escape"&&me(),ye.key==="ArrowDown"&&(ye.preventDefault(),xe(Z=>Math.max(0,Math.min(Z+1,J.length-1)))),ye.key==="ArrowUp"&&(ye.preventDefault(),xe(Z=>Math.max(0,Z-1))),ye.key==="Enter"&&J[z]&&J[z].run()}}),l.jsxs("div",{className:"palette-list",children:[J.length===0&&l.jsx("div",{className:"palette-empty",children:Fie(E)}),J.map((ye,Z)=>l.jsxs("div",{className:`palette-item ${Z===z?"selected":""}`,onClick:ye.run,onMouseEnter:()=>xe(Z),children:[l.jsx("span",{children:ye.label}),ye.keyHint?l.jsx("span",{className:"palette-key",children:ye.keyHint}):ye.hint&&l.jsx("span",{className:"palette-hint",children:ye.hint})]},ze[Z]))]})]})})}const cy=`quit and reopen ${Je} to edit these`,_ie=e=>/No handler registered/i.test(e),GO={sentence:"General agent instructions. Every agent reads them before your task, on every project.",placeholder:"Don't hand me summary .md files. Put the answer on the work item.",reader:()=>{var e;return(e=window.zero)==null?void 0:e.standingRead},writer:()=>{var e;return(e=window.zero)==null?void 0:e.standingWrite}};function Wie({kind:e=GO,onClose:t}){const[n,r]=g.useState(null),[s,o]=g.useState("idle"),[i,a]=g.useState(null),c=g.useRef(null),u=g.useRef(null),d=g.useRef(null);g.useEffect(()=>{const w=e.reader();if(!w){r(""),o("failed"),a(cy);return}w().then(b=>{r((b==null?void 0:b.text)??""),b!=null&&b.error&&(o("failed"),a(b.error))}).catch(()=>{r(""),o("failed"),a(cy)})},[]),g.useEffect(()=>{if(n===null)return;const w=c.current;w&&(w.focus(),w.setSelectionRange(0,0),w.scrollTop=0)},[n!==null]);const h=async w=>{o("saving");try{const b=e.writer();if(!b)throw new Error("this window cannot reach the instructions file");const x=await b({text:w});if(x&&x.ok===!1)throw new Error(x.error||"could not save");d.current=null,o("saved"),a(null)}catch(b){const x=String((b==null?void 0:b.message)??b);o("failed"),a(_ie(x)?cy:x)}},f=w=>{r(w),d.current=w,o("saving"),u.current&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>h(w),400)},p=()=>{u.current&&window.clearTimeout(u.current),d.current!==null?h(d.current).finally(t):t()},m=s==="failed"?i??"not saved":s==="saving"?"saving…":s==="saved"?"saved":e.sentence;return l.jsx("div",{className:"modal-backdrop compose-backdrop",onClick:p,children:l.jsxs("div",{className:"modal compose rules-card",onClick:w=>w.stopPropagation(),children:[l.jsx("textarea",{ref:c,className:"rules-text",spellCheck:!1,value:n??"",placeholder:n===null?"loading…":e.placeholder,disabled:n===null,onChange:w=>f(w.target.value),onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),p()),w.stopPropagation()}}),l.jsxs("div",{className:"rules-sentence",children:[l.jsx("span",{className:"rules-clauses",children:m}),l.jsxs("button",{type:"button",className:"dock-send",onClick:p,children:["Done ",l.jsx("kbd",{children:"esc"})]})]})]})})}const Hie=`- The first line is the thing to do or answer, in bold.
|
|
863
|
+
- Steps are a numbered list of five or fewer, and the first one is small.
|
|
864
|
+
- No recap, no preamble, no closing offer.
|
|
865
|
+
- Work in progress says where it is in one clause.
|
|
866
|
+
- Time is given in units, or not at all.
|
|
867
|
+
`,Uie=`# How to work
|
|
868
|
+
|
|
869
|
+
<!-- store-tools:start -->
|
|
870
|
+
You are a worker session in {{name}}, the founder's agent inbox. You were spawned
|
|
871
|
+
for exactly one work item (above), you do that work, you write your state back,
|
|
872
|
+
and you end. There is no long-lived you: anything you do not write into the
|
|
873
|
+
work item or the product's documents is gone when you exit. Sessions are
|
|
874
|
+
cattle; the store is the truth.
|
|
875
|
+
<!-- store-tools:end -->
|
|
876
|
+
<!-- no-store-tools:start -->
|
|
877
|
+
You are a worker session in {{name}}, the founder's agent inbox. You were spawned
|
|
878
|
+
for exactly one work item (above), you do that work, and you end. There is no
|
|
879
|
+
long-lived you.
|
|
880
|
+
|
|
881
|
+
THIS INSTALL GIVES YOU NO TOOLS FOR THE INBOX ITSELF. You cannot claim this
|
|
882
|
+
item, check in on it, file another one, set its status or close it, and nothing
|
|
883
|
+
you attempt that way will work. Do not go looking for those tools and do not
|
|
884
|
+
hand-edit the inbox's own files to fake them.
|
|
885
|
+
|
|
886
|
+
Two things of yours reach the founder, and only two. The plain sentences you say
|
|
887
|
+
as you go, which the app puts on the row while you are working. And YOUR LAST
|
|
888
|
+
MESSAGE, which the app writes onto the row as the result the second you exit,
|
|
889
|
+
and which parks the row in their inbox for them to read and reply to. So your last
|
|
890
|
+
message is not a sign-off. It is the whole of what they get, and the rules for
|
|
891
|
+
writing it are at the end of this brief.
|
|
892
|
+
<!-- no-store-tools:end -->
|
|
893
|
+
|
|
894
|
+
The founder is building several products at once through this inbox. Their
|
|
895
|
+
attention is the scarcest resource in the system, scarcer than your tokens.
|
|
896
|
+
Everything below follows from that.
|
|
897
|
+
|
|
898
|
+
The person you work for may be anyone on a team. Call them "you", their
|
|
899
|
+
name or "they", never "she", "he" or "the founder".
|
|
900
|
+
|
|
901
|
+
## The store
|
|
902
|
+
|
|
903
|
+
<!-- store-tools:start -->
|
|
904
|
+
The product's docs directory holds its documents and work items; use the store
|
|
905
|
+
tools, not the files. Make a document only when plain Claude Code would; the
|
|
906
|
+
answer is the message.
|
|
907
|
+
|
|
908
|
+
Keep the thread's summary current. Whenever you leave a note or finish, also
|
|
909
|
+
pass \`problem\` and \`progress\` to update_work_item, in plain words, for a
|
|
910
|
+
teammate who will read nothing else. \`problem\` is shown as CONTEXT: a few
|
|
911
|
+
sentences, 45 words at most, that bring the thread back to someone who has
|
|
912
|
+
forgotten it, what was asked, what was found and the facts needed to decide.
|
|
913
|
+
\`progress\` is shown as DONE: the steps taken so far, one per line, oldest first
|
|
914
|
+
and newest last, six lines at most of 15 words each; send the whole list each
|
|
915
|
+
time. A longer one is refused. Leave \`solution\` out; it is no longer shown. If
|
|
916
|
+
it waits on another thread, pass that thread's id in \`blockedBy\`. The person may have edited the summary; read it
|
|
917
|
+
before you rewrite it, and keep what they said unless it is no longer true.
|
|
918
|
+
<!-- store-tools:end -->
|
|
919
|
+
<!-- no-store-tools:start -->
|
|
920
|
+
The product's docs directory holds its documents; edit them with your ordinary
|
|
921
|
+
tools, and make one only when plain Claude Code would. Its work items are NOT
|
|
922
|
+
yours to edit: the app owns that file, and your last message is how this row
|
|
923
|
+
gets written.
|
|
924
|
+
<!-- no-store-tools:end -->
|
|
925
|
+
|
|
926
|
+
The product's documents are your context; read what you need before acting.
|
|
927
|
+
A decision recorded there holds unless the founder has said otherwise since.
|
|
928
|
+
|
|
929
|
+
## Altitude
|
|
930
|
+
|
|
931
|
+
<!-- store-tools:start -->
|
|
932
|
+
A founder directive is not always a product task. It can be spoken at the
|
|
933
|
+
level of the work system itself: priorities, what to scrap, how to operate
|
|
934
|
+
(close everything that does not serve X, stop pursuing Y). Execute those
|
|
935
|
+
directly: close the obsolete items yourself with a one-line reason each, file
|
|
936
|
+
one review summarizing what you closed and kept and why, and treat the stated
|
|
937
|
+
priorities as the newest grounding for everything after.
|
|
938
|
+
<!-- store-tools:end -->
|
|
939
|
+
<!-- no-store-tools:start -->
|
|
940
|
+
A founder directive is not always a product task. It can be spoken at the
|
|
941
|
+
level of the work system itself: priorities, what to scrap, how to operate
|
|
942
|
+
(close everything that does not serve X, stop pursuing Y). Treat those as the
|
|
943
|
+
newest grounding for everything after. You cannot close anybody's rows, so
|
|
944
|
+
name the ones you believe are dead in your last message, one line of reason
|
|
945
|
+
each, and let them clear them.
|
|
946
|
+
<!-- no-store-tools:end -->
|
|
947
|
+
|
|
948
|
+
## The ask sets the size of the run
|
|
949
|
+
|
|
950
|
+
EVERYTHING BELOW DESCRIBES THE BIGGEST KIND OF RUN, and most rows are not
|
|
951
|
+
that. Its length is not an instruction to make your row bigger than it was. A
|
|
952
|
+
row that asks a question wants an answer, not a project: read it, answer it,
|
|
953
|
+
stop.
|
|
954
|
+
|
|
955
|
+
So on anything general, read this PDF, what does this code do, find me X, you
|
|
956
|
+
are a good general assistant first and this brief is scaffolding around that.
|
|
957
|
+
If following a rule here would make your answer worse than a plain Claude Code
|
|
958
|
+
session's, you are misapplying it. Answer well, then apply what actually fits.
|
|
959
|
+
|
|
960
|
+
## Doing the work
|
|
961
|
+
|
|
962
|
+
<!-- store-tools:start -->
|
|
963
|
+
- Claim your item first (claim_work_item with your item id). If the claim is
|
|
964
|
+
refused, someone else has it: end immediately, reporting nothing.
|
|
965
|
+
- Leave priority alone on anything you file. The app decides what runs next
|
|
966
|
+
from the founder's own order over their products, and their tag on an item is
|
|
967
|
+
the only one that changes it.
|
|
968
|
+
- Actions outside your standing grants do not silently fail any more: the
|
|
969
|
+
permission system asks the founder LIVE (an approval card in their inbox app)
|
|
970
|
+
and blocks you until they answer, up to 15 minutes. Spend these asks like
|
|
971
|
+
interruptions, because they are: exhaust what your grants already allow,
|
|
972
|
+
batch the gated part into as few commands as possible, and if they deny
|
|
973
|
+
or the ask times out, do not retry it; finish what you can and file the
|
|
974
|
+
remainder as a review with the exact commands.
|
|
975
|
+
- EVERYTHING YOU FILE IS A PROPOSAL: nothing you create runs until the founder
|
|
976
|
+
approves it from the inbox, so write it for them to decide rather than as a
|
|
977
|
+
note to another agent.
|
|
978
|
+
- Code changes happen in the product's repo (your cwd), on a branch, committed
|
|
979
|
+
as you go. Name the branch the way this repo already names branches; read a
|
|
980
|
+
few with \`git branch\` and follow them. Never commit to main; the founder
|
|
981
|
+
reviews through the inbox.
|
|
982
|
+
- YOUR CWD IS ALREADY YOUR OWN FOLDER, one per task on its own branch. Do not
|
|
983
|
+
make a second one or delete this one. Your branch keeps the commits.
|
|
984
|
+
- CHANGE A FILE WITH THE EDITING TOOL, NEVER WITH sed OR A HEREDOC. Your own
|
|
985
|
+
harness instructions tell you the opposite and they are wrong here, so this
|
|
986
|
+
line overrules them. Two reasons, and the second one is the one that gets
|
|
987
|
+
forgotten. The card the founder and their users open to read what you changed
|
|
988
|
+
now reads the repository as well, so a file you rewrite with a shell command
|
|
989
|
+
does reach it, but ONLY if your work is in a checkout: on a product with no
|
|
990
|
+
repository the conversation is the only reading there is. And the sentence
|
|
991
|
+
you wrote just before a change, which is what makes the change readable by
|
|
992
|
+
someone who is not you, exists nowhere else at all. Reading and searching
|
|
993
|
+
with the shell stays right and stays faster. Writing does not.
|
|
994
|
+
- NAME EACH STEP IN A SENTENCE THEY WOULD USE, out loud, before you take it.
|
|
995
|
+
One plain line, no jargon and no tool names: "Now the IPC handlers and the
|
|
996
|
+
bridge", not "Running Edit on main/ipc.mjs". Those sentences are what they
|
|
997
|
+
actually read about your run: the app shows the newest while you work and keeps
|
|
998
|
+
the rest as the record, everything you typed folded behind them. A session that
|
|
999
|
+
narrates nothing leaves a thread saying it did nothing.
|
|
1000
|
+
THEIR WORDS AND NOT OURS, here and in every message: never "work item", "row",
|
|
1001
|
+
"claim" or "the founder". Say this task, this thread, picked it up, you.
|
|
1002
|
+
- When the work is done, set the status if it needs setting, then END WITH YOUR
|
|
1003
|
+
ANSWER AS YOUR LAST MESSAGE: what changed and how you verified it, shaped by
|
|
1004
|
+
the rules at the foot of this brief. The app writes that message onto the row
|
|
1005
|
+
as its result the moment you exit. Do not pass \`result\` for this row yourself;
|
|
1006
|
+
the answer said twice is the fault this replaces.
|
|
1007
|
+
- ANSWERING THEM IS NOT CLOSING THEIR ROW. A request is answered by returning
|
|
1008
|
+
what was asked for, and a row is closed only when they ask for it to be
|
|
1009
|
+
closed or say they are done with it. So on a row they wrote (labelled
|
|
1010
|
+
\`founder\`), answer and leave the status alone: the row stays open and
|
|
1011
|
+
reaches them as an answer. Set it done only when they have asked you to, and
|
|
1012
|
+
then pass their exact words asking for it as \`closeBecause\`; the store leaves
|
|
1013
|
+
the row open without them. Rows an agent filed are still yours to close,
|
|
1014
|
+
except that a thread they are talking on is theirs to end: if their reply was
|
|
1015
|
+
a request for information, or the work it points at is still ahead of you,
|
|
1016
|
+
leave it open or blocked.
|
|
1017
|
+
- If you set status blocked, say what would unblock it, and when that is the
|
|
1018
|
+
founder's to do, file it as a child work item (parent: this item id) so their
|
|
1019
|
+
row can take them straight to it.
|
|
1020
|
+
<!-- store-tools:end -->
|
|
1021
|
+
<!-- no-store-tools:start -->
|
|
1022
|
+
- There is nothing to claim and nothing to release. The app gave this row to
|
|
1023
|
+
you alone before it started you, and it takes it back when you exit.
|
|
1024
|
+
- Actions outside your standing grants do not silently fail any more: the
|
|
1025
|
+
permission system asks the founder LIVE (an approval card in their inbox app)
|
|
1026
|
+
and blocks you until they answer, up to 15 minutes. Spend these asks like
|
|
1027
|
+
interruptions, because they are: exhaust what your grants already allow,
|
|
1028
|
+
batch the gated part into as few commands as possible, and if they deny
|
|
1029
|
+
or the ask times out, do not retry it; finish what you can and say what is
|
|
1030
|
+
left in your last message, with the exact commands.
|
|
1031
|
+
- You cannot file work, so nothing you find becomes a task by itself. Anything
|
|
1032
|
+
worth doing next goes in your last message, in one sentence, as something they
|
|
1033
|
+
can say yes to. Their attention is the gate here on purpose.
|
|
1034
|
+
- Code changes happen in the product's repo (your cwd), on a branch, committed
|
|
1035
|
+
as you go. Name the branch the way this repo already names branches; read a
|
|
1036
|
+
few with \`git branch\` and follow them. Never commit to main; the founder
|
|
1037
|
+
reviews through the inbox.
|
|
1038
|
+
- YOUR CWD IS ALREADY YOUR OWN FOLDER, one per task on its own branch. Do not
|
|
1039
|
+
make a second one or delete this one. Your branch keeps the commits.
|
|
1040
|
+
- NAME EACH STEP IN A SENTENCE THEY WOULD USE, out loud, before you take it.
|
|
1041
|
+
One plain line, no jargon and no tool names: "Now the IPC handlers and the
|
|
1042
|
+
bridge", not "Running Edit on main/ipc.mjs". Those sentences are what they
|
|
1043
|
+
actually read about your run, and the only progress they see before you finish,
|
|
1044
|
+
so say one before every real step.
|
|
1045
|
+
THEIR WORDS AND NOT OURS, here and in every message: never "work item", "row",
|
|
1046
|
+
"claim" or "the founder". Say this task, this thread, picked it up, you.
|
|
1047
|
+
- When the work is done, STOP AND WRITE THE LAST MESSAGE. That message is the
|
|
1048
|
+
result: what changed and how you verified it, in two or three sentences,
|
|
1049
|
+
shaped by the rules at the foot of this brief. The app lands it on the row and
|
|
1050
|
+
puts the row in their inbox. There is no other way to report and no second
|
|
1051
|
+
chance at it.
|
|
1052
|
+
- If something stopped you, the first line of your last message says what
|
|
1053
|
+
stopped you and what would undo it. The row reaches them either way, so a
|
|
1054
|
+
blocker they can act on is worth more than a partial job dressed up as a
|
|
1055
|
+
finished one. Their reply comes back to a fresh session on this same row, with
|
|
1056
|
+
everything said here in front of it.
|
|
1057
|
+
<!-- no-store-tools:end -->
|
|
1058
|
+
|
|
1059
|
+
<!-- subagent-rule:start -->
|
|
1060
|
+
## One row, or several
|
|
1061
|
+
|
|
1062
|
+
Split work into separate work items when each piece needs its own answer from
|
|
1063
|
+
the founder or its own session. Keep helpers inside one item when their work
|
|
1064
|
+
combines into a single result.
|
|
1065
|
+
|
|
1066
|
+
Twenty issues off one call are twenty rows. A research task fanned across ten
|
|
1067
|
+
subagents that merge into one document is one row, however many subagents it
|
|
1068
|
+
takes. Spawning a subagent is not by itself a reason to file anything.
|
|
1069
|
+
<!-- subagent-rule:end -->
|
|
1070
|
+
|
|
1071
|
+
## Honesty
|
|
1072
|
+
|
|
1073
|
+
Report what actually happened. A test you did not run is not "passing"; a
|
|
1074
|
+
thing you could not do is stated as such, with what you tried. A fabricated
|
|
1075
|
+
result in this system poisons the founder's view of their own company, which
|
|
1076
|
+
is the worst failure available to you.
|
|
1077
|
+
|
|
1078
|
+
<!-- repeat-rules:start -->
|
|
1079
|
+
## If this item is one run of a repeating task
|
|
1080
|
+
|
|
1081
|
+
Its body says so at the top, and its labels carry \`repeat:<id>\`. It runs again
|
|
1082
|
+
tomorrow whatever happens here, so this run does not have to carry the future:
|
|
1083
|
+
finish the day's work, not the whole standing job.
|
|
1084
|
+
|
|
1085
|
+
<!-- store-tools:start -->
|
|
1086
|
+
Finish one of two ways.
|
|
1087
|
+
|
|
1088
|
+
Nothing they need to know: update the item with \`status: "done"\` and labels
|
|
1089
|
+
\`["founder", "repeat:<id>", "clean"]\` IN THE SAME CALL, sending all three
|
|
1090
|
+
because labels replace the array rather than merging, and end on one short
|
|
1091
|
+
line. That is what clean means. Finishing quietly is the ordinary case for a
|
|
1092
|
+
task that runs every morning, and it is why they can leave one running.
|
|
1093
|
+
|
|
1094
|
+
Anything they should see: finish normally, with a last message saying what you found,
|
|
1095
|
+
and do NOT set the clean label. It reaches their inbox, which is the entire point
|
|
1096
|
+
of running this daily. Anything that deserves its own life gets filed as its
|
|
1097
|
+
own item, the ordinary way.
|
|
1098
|
+
|
|
1099
|
+
The clean label is the only thing in {{name}} that makes finishing hide a row,
|
|
1100
|
+
so it is required to hide and never to show. If you are unsure which of the
|
|
1101
|
+
two this is, it is the second one.
|
|
1102
|
+
<!-- store-tools:end -->
|
|
1103
|
+
<!-- no-store-tools:start -->
|
|
1104
|
+
The clean label is the only thing in {{name}} that makes finishing hide a row,
|
|
1105
|
+
and setting a label is one of the things you cannot do here. So there is no
|
|
1106
|
+
quiet finish available to you: your last message reaches them every morning
|
|
1107
|
+
whatever it says. On a run with nothing in it, say that in one line and stop.
|
|
1108
|
+
One line costs them a second to read and tells them the job is still alive.
|
|
1109
|
+
<!-- no-store-tools:end -->
|
|
1110
|
+
<!-- repeat-rules:end -->
|
|
1111
|
+
`,JO={adhd:Hie,system:Uie},Ao="every";function Kie(e){return[{id:Ao,label:"Every project"},...e.map(t=>({id:t.slug,label:t.name}))]}function Vie(e,t){return!e||e===Ao?Ao:t.some(n=>n.slug===e)?e:Ao}function qie(e,t){var n;return e===Ao?"every project":((n=t.find(r=>r.slug===e))==null?void 0:n.name)??"every project"}function Yie(e){return e.trim()===""}const Gie={id:"rules",label:"General agent instructions",defaultText:""},pE={id:"adhd",label:"ADHD mode",defaultText:JO.adhd},Jie={id:"system",label:"System prompt",description:`${st}’s task-brief template for project work. Keep the template placeholders for task context. Personal tasks use your message directly. The coding provider’s own system instructions are managed by that provider.`,defaultText:JO.system},mE=new Map,Nh=()=>new URLSearchParams(location.search).has("fixtures")||!window.zero;function XO(e){const[t,n]=g.useState(null),[r,s]=g.useState(e.defaultText),[o,i]=g.useState(""),[a,c]=g.useState(!1),u=g.useRef(null),d=g.useRef(null),h=g.useRef(Promise.resolve()),f=v=>{u.current=null,h.current=h.current.then(async()=>{var S;try{if(Nh())mE.set(e.id,v);else{if(!((S=window.zero)!=null&&S.instructionWrite))throw new Error(`Reopen ${Je} to save instructions.`);const C=await window.zero.instructionWrite(e.id,v);if(!C.ok)throw new Error(C.error||"Could not save")}i(Nh()?"Saved in this preview":"Saved"),c(!1)}catch(C){i(String(C.message)),c(!0)}})};g.useEffect(()=>{var S;let v=!0;return Nh()?(n(mE.get(e.id)??e.defaultText),i("Preview edits stay in this browser session.")):(S=window.zero)!=null&&S.instructionRead?window.zero.instructionRead(e.id).then(C=>{v&&(C.error?i(C.error):(n(C.text),s(C.defaultText)))}).catch(C=>i(C.message)):i(`Reopen ${Je} to edit instructions.`),()=>{v=!1,d.current&&clearTimeout(d.current),u.current!==null&&f(u.current)}},[e.id]);const p=v=>{n(v),u.current=v,i("Saving…"),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>f(v),400)},[m,w]=g.useState(null);return{text:t,status:o,edit:p,restore:{section:e,defaultText:r,pick:(v,S)=>{t!==null&&w({text:t,label:S}),p(v)}},undo:a?null:m,undoRestore:()=>{m&&(p(m.text),w(null))}}}function Xie(e,t){const[n,r]=g.useState(e.instructions),[s,o]=g.useState(""),i=g.useRef(null),a=g.useRef(null),c=g.useRef(e.instructions);c.current=e.instructions,g.useEffect(()=>{r(c.current),o(""),a.current=null},[e.slug]);const u=g.useCallback(async h=>{const f=await q.writeProjectInstructions(e.slug,h);f.ok?(a.current=null,o("Saved"),t()):o(f.error??"Could not save")},[e.slug,t]);return g.useEffect(()=>()=>{i.current&&window.clearTimeout(i.current),a.current!==null&&u(a.current)},[e.slug]),{text:n,status:s,edit:h=>{r(h),a.current=h,o("Saving…"),i.current&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>void u(h),400)}}}function gE(e,t=Date.now()){const n=new Date(e),r=n.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),s=i=>{const a=new Date(i);return a.setHours(0,0,0,0),a.getTime()},o=Math.round((s(t)-s(e))/864e5);return o===0?`Today at ${r}`:o===1?`Yesterday at ${r}`:o<7?`${n.toLocaleDateString(void 0,{weekday:"long"})} at ${r}`:`${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})} at ${r}`}const Sb=e=>e===0?"an empty page":`${e.toLocaleString()} characters`;function QO(){const[e,t]=g.useState(!1),n=g.useRef(null);return g.useEffect(()=>{if(!e)return;const r=o=>{var i;(i=n.current)!=null&&i.contains(o.target)||t(!1)},s=o=>{o.key==="Escape"&&(o.stopPropagation(),t(!1))};return document.addEventListener("mousedown",r),document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",s,!0)}},[e]),{open:e,setOpen:t,wrap:n}}function Qie({section:e,text:t,defaultText:n,onPick:r}){const{open:s,setOpen:o,wrap:i}=QO(),[a,c]=g.useState(null),[u,d]=g.useState("");g.useEffect(()=>{var p;if(!s)return;let f=!0;return d(""),Nh()||!((p=window.zero)!=null&&p.instructionHistory)?c([]):window.zero.instructionHistory(e.id).then(m=>{f&&(m.error&&d(m.error),c(m.versions??[]))}).catch(m=>{f&&(d(String(m.message)),c([]))}),()=>{f=!1}},[s,e.id]);const h=async(f,p)=>{var m;o(!1);try{if(!((m=window.zero)!=null&&m.instructionVersion))throw new Error(`Reopen ${Je} to restore a version.`);const w=await window.zero.instructionVersion(e.id,f);if(w.error)throw new Error(w.error);r(w.text,p)}catch(w){d(String(w.message))}};return l.jsxs("div",{className:"instruction-restore",ref:i,children:[l.jsx("button",{type:"button",className:"instruction-restore-link","aria-expanded":s,"aria-haspopup":"menu",disabled:t===null,onClick:()=>o(f=>!f),children:"Restore"}),s&&l.jsxs("div",{className:"instruction-restore-menu",role:"menu","aria-label":`Restore ${e.label}`,children:[a===null&&l.jsx("div",{className:"instruction-restore-empty",children:"Looking for earlier versions…"}),(a==null?void 0:a.length)===0&&l.jsx("div",{className:"instruction-restore-empty",children:"No earlier versions of yours yet. One is kept each time you come back to this box."}),a==null?void 0:a.map(f=>l.jsxs("button",{type:"button",role:"menuitem",onClick:()=>void h(f.ts,gE(f.ts)),children:[l.jsx("span",{children:gE(f.ts)}),l.jsx("span",{className:"instruction-restore-size",children:Sb(f.chars)})]},f.ts)),l.jsxs("button",{type:"button",role:"menuitem",className:"instruction-restore-original",disabled:t===n,onClick:()=>{o(!1),r(n,"the original")},children:[l.jsx("span",{children:"The original"}),l.jsx("span",{className:"instruction-restore-size",children:Sb(n.length)})]}),u&&l.jsx("div",{className:"instruction-restore-empty",children:u})]})]})}function Zie(){const[e,t]=g.useState(null);return g.useEffect(()=>{let r=!0;return q.settings().then(s=>{r&&s.ok&&t(!!s.workspace.adhdMode)}),()=>{r=!1}},[]),[e,async r=>{const s=await q.setWorkspaceSetting({key:"adhdMode",value:r});s.ok&&t(!!s.workspace.adhdMode)}]}function Ik({id:e,label:t,writing:n,description:r,head:s,hidden:o}){const{text:i,status:a,edit:c,restore:u,undo:d,undoRestore:h}=n,[f,p]=g.useState(!1),m=g.useRef(!1);g.useEffect(()=>{i!==null&&!m.current&&(m.current=!0,p(Yie(i)))},[i]);const w=g.useRef(null);return g.useEffect(()=>{var b;f&&i!==null&&((b=w.current)==null||b.focus({preventScroll:!0}))},[f]),l.jsxs("section",{className:"instr-part",id:`instr-${e}`,children:[l.jsxs("div",{className:"instr-part-head",children:[t&&l.jsx("h2",{children:t}),l.jsxs("div",{className:"instr-part-tools",children:[f&&u&&l.jsx(Qie,{section:u.section,text:i,defaultText:u.defaultText,onPick:u.pick}),!o&&l.jsx("button",{type:"button",className:"instr-edit","aria-pressed":f,disabled:i===null,onClick:()=>p(b=>!b),children:f?"Done":"Edit"}),s]})]}),r&&l.jsx("p",{className:"instr-part-desc",children:r}),!o&&(f?l.jsxs(l.Fragment,{children:[l.jsx("textarea",{ref:w,"aria-label":t??"Instructions",spellCheck:!1,disabled:i===null,value:i??"",onChange:b=>c(b.target.value),onKeyDown:b=>{b.stopPropagation(),b.key==="Escape"&&p(!1)},placeholder:"Write your instructions here…"}),l.jsx("div",{className:"instruction-save",role:"status",children:d?l.jsxs(l.Fragment,{children:["Restored ",d.label.toLowerCase(),". ",l.jsx("button",{type:"button",className:"instruction-undo",onClick:h,children:"Undo"})]}):a})]}):l.jsx("div",{className:"instr-md",children:l.jsx(jl,{remarkPlugins:[Cl],children:i??""})}))]})}function yE({section:e}){const t=XO(e);return l.jsx(Ik,{id:e.id,label:e.label,writing:t,description:e.description})}function eae(){const e=XO(pE),[t,n]=Zie(),r=t===null?null:l.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"ADHD mode",className:`set-sw ${t?"on":""}`,onClick:()=>void n(!t)});return l.jsx(Ik,{id:"adhd",label:pE.label,writing:e,head:r,hidden:!t})}function tae({project:e,onSaved:t}){const n=Xie(e,t);return l.jsx(Ik,{id:"project",writing:n},e.slug)}function nae({scope:e,projects:t,onScope:n}){const{open:r,setOpen:s,wrap:o}=QO();return l.jsxs("h1",{className:"instr-lead",children:["Instructions for ",l.jsxs("span",{className:"instr-scope",ref:o,children:[l.jsxs("button",{type:"button",className:"instr-scope-word","aria-haspopup":"menu","aria-expanded":r,onClick:()=>s(i=>!i),children:[qie(e,t),l.jsx("svg",{className:"instr-scope-arrow",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M4 6l4 4 4-4"})})]}),r&&l.jsx("div",{className:"instr-scope-menu",role:"menu","aria-label":"Instructions for",children:Kie(t).map((i,a)=>l.jsxs(g.Fragment,{children:[a===1&&l.jsx("hr",{}),l.jsx("button",{type:"button",role:"menuitemradio","aria-checked":i.id===e,onClick:()=>{s(!1),n(i.id)},children:i.label})]},i.id))})]})]})}function rae({projects:e=[],scope:t=Ao,onScope:n,onSaved:r=()=>{}}){const[s,o]=g.useState(t);g.useEffect(()=>o(t),[t]);const i=Vie(s,e),a=h=>{o(h),n==null||n(h)},c=e.find(h=>h.slug===i),[u,d]=g.useState(!1);return l.jsxs("div",{className:"set-inner instructions-page",children:[l.jsx(nae,{scope:i,projects:e,onScope:a}),l.jsx("div",{className:"instr-body",children:l.jsxs("div",{children:[l.jsx("div",{className:"instr-card",children:i===Ao?l.jsxs(l.Fragment,{children:[l.jsx(yE,{section:Gie}),l.jsx(eae,{})]}):c&&l.jsx(tae,{project:c,onSaved:r})}),i===Ao&&l.jsxs("div",{className:"instruction-advanced",children:[l.jsx("button",{className:"instruction-advanced-toggle","aria-expanded":u,onClick:()=>d(h=>!h),children:u?"Hide advanced":"Advanced"}),u&&l.jsx("div",{className:"instr-card instr-card-ours",children:l.jsx(yE,{section:Jie})})]})]})})]})}function Dk(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function sae(e){if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};const t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>e(t.matches?"dark":"light");return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}function Eh(e){return e==="light"||e==="dark"?e:e==="match"?Dk():"dark"}function ZO(e){return e==="light"||e==="dark"||e==="match"?e:"dark"}const ba="zero.theme";function jb(e,t=document.documentElement){t.setAttribute("data-theme",e)}const Ju=[{id:"ember-grid",name:"Dark",note:"The launch film’s look. A warm dark grey, a faint dot grid, square corners and one orange."}],Fs="zero.skin";function Dc(e){return Ju.some(t=>t.id===e)?e:"none"}function oae(e,t){return t==="none"?e:t}const iae=[{id:"light",name:"Light"},{id:"ember-grid",name:"Dark"},{id:"match",name:"Match system"}],aae=["frost-haze","slate-haze","peach-haze","peach-haze-2"];function lae(e){const t=e.getItem(ba),n=e.getItem(Fs),r=s=>{const o=Lu(s);t!==o.theme&&e.setItem(ba,o.theme),n!==o.skin&&e.setItem(Fs,String(o.skin))};if(t===null&&n===null)return r(Ok);if(n&&aae.includes(n))return r("light");if(n&&n!=="none")return r("ember-grid");if(t==="light")return r("light");if(t==="match")return r("match");r("ember-grid")}function Cb(e,t,n){return e==="match"?n==="dark"?Ok:"none":t}function Lu(e){var t;return e==="light"?{theme:"light",skin:"none"}:e==="dark"?{theme:"dark",skin:"none"}:e==="match"?{theme:"match",skin:"none"}:{theme:(t=Ju.find(n=>n.id===e))!=null&&t.light?"light":"dark",skin:e}}function Nb(e,t=document.documentElement){e==="none"?t.removeAttribute("data-skin"):t.setAttribute("data-skin",e)}function wE(e,t=document.documentElement){e==="soft"?t.setAttribute("data-skin-detail","soft"):t.removeAttribute("data-skin-detail")}function bE(e){return e==="soft"?"soft":"sharp"}const ml="zero.skin.tune",di={panelOpacity:{min:0,max:1,step:.01},backgroundBlur:{min:0,max:80,step:1},blur:{min:0,max:80,step:1},dim:{min:0,max:.85,step:.01}},yr={lake:{blur:8,backgroundBlur:5,dim:.63},ice:{blur:2,dim:.85},"ice-river":{blur:2,dim:.735},"lake-harbour":{blur:2,dim:.68},"pixel-ridge":{blur:4,backgroundBlur:6,dim:.77},"pixel-orbit":{blur:0,backgroundBlur:5,dim:.2},"woodblock-sea":{blur:4,backgroundBlur:12,dim:.84},"riso-hills":{blur:2,backgroundBlur:3,dim:.85},"gouache-valley":{blur:4,backgroundBlur:5,dim:.75},"vector-dunes":{blur:2,dim:.775},"watercolour-mist":{blur:2,backgroundBlur:4,dim:.85},"orbit-rings":{blur:2,dim:0},"moon-pines":{blur:2,dim:0},"cel-dusk":{blur:2,dim:0},"pixel-harbour":{blur:2,dim:0},"lino-coast":{blur:2,dim:.85},"valley-haze":{blur:2,dim:0},"frost-haze":{blur:2,dim:0},"slate-haze":{blur:2,dim:0},"orbital-glass":{blur:30,dim:.3,backgroundBlur:24,panelOpacity:.16},"peach-haze-2":{blur:0,dim:.35,backgroundBlur:0,panelOpacity:.2},"ember-grid":{blur:0,dim:0}},cae=(e,t,n)=>e<t?t:e>n?n:e;function Ah(e,t){const n=yr[t]??yr.lake;let r;try{r=e?JSON.parse(e):null}catch{return n}const s=r==null?void 0:r[t];if(!s||typeof s!="object")return n;const o=(i,a,c)=>typeof i=="number"&&Number.isFinite(i)?cae(i,c.min,c.max):a;return{...s.backgroundBlur!==void 0||n.backgroundBlur!==void 0?{backgroundBlur:s.backgroundBlur===void 0?n.backgroundBlur:o(s.backgroundBlur,0,di.backgroundBlur)}:{},...n.panelOpacity!==void 0?{panelOpacity:o(s.panelOpacity,n.panelOpacity,di.panelOpacity)}:{},blur:o(s.blur,n.blur,di.blur),dim:o(s.dim,n.dim,di.dim)}}function uae(e,t,n){let r={};try{const s=e?JSON.parse(e):null;s&&typeof s=="object"&&(r=s)}catch{}return JSON.stringify({...r,[t]:n})}function Th(e,t=document.documentElement){t.style.setProperty("--skin-panel-opacity",e.panelOpacity===void 0?"":String(e.panelOpacity)),t.style.setProperty("--skin-background-blur",`${e.backgroundBlur??0}px`),t.style.setProperty("--skin-blur",`${e.blur}px`),t.style.setProperty("--skin-dim",String(e.dim))}const Ok="ember-grid";function dae(e,t){if(e.getItem(t)!==null||e.getItem(Fs)!==null)return null;const n=Lu(Ok);return e.setItem(t,n.theme),e.setItem(Fs,String(n.skin)),n}function hae(){return l.jsxs("svg",{className:"match-mark",width:"13",height:"13",viewBox:"0 0 12 12","aria-hidden":"true",children:[l.jsx("circle",{cx:"6",cy:"6",r:"5.2",fill:"none",stroke:"currentColor",strokeWidth:"1.1"}),l.jsx("path",{d:"M6 0.8 A5.2 5.2 0 0 1 6 11.2 Z",fill:"currentColor"})]})}function Lk({src:e,name:t,slug:n,size:r=24}){if(e)return l.jsx("img",{className:"product-mark",src:e,alt:"",width:r,height:r,"aria-hidden":"true"});const s=Math.max(8,Math.round(r*.46));return l.jsx("span",{className:"product-mark product-swatch",style:{width:r,height:r},"aria-hidden":"true",title:t,children:l.jsx("i",{style:{width:s,height:s,background:AM(n??t)}})})}const fae=[{label:"In your inbox",keys:[{keys:["J","↓"],join:"or",what:"Move down the list."},{keys:["K","↑"],join:"or",what:"Move up the list."},{keys:["←","→"],what:"Move to the next column on the board."},{keys:["↵"],what:"Open the task you are on."},{keys:["⇥"],what:"Move to the next tab along the top."},{keys:["B"],what:"Switch between the list and the board."},{keys:["esc"],what:"Go back one step: a file, then the task, then the list."}]},{label:"In a task you have opened",keys:[{keys:["R"],what:"Write back to the agent."},{keys:["⌘↵"],what:"Send what you have typed."},{keys:["↑","↓"],what:"Move through the options an agent has offered."},{keys:["↵"],what:"Send the option you have selected."},{keys:["1","9"],join:"to",what:"Pick an option by its number."},{keys:["⌘J"],what:"Show or hide this task’s terminal."},{keys:["S"],what:"Show or hide the summary."}]},{label:"Closing, scheduling and undoing",keys:[{keys:["E"],what:"Close the task and take it out of your inbox."},{keys:["L"],what:"Later: put the task off until a time you pick."},{keys:["Z"],what:"Undo the last thing you did."},{keys:["O"],what:"Open the task you just sent or answered, while its note is on screen."},{keys:["⌘A"],what:"Tick every task in the list. Press it again to untick."}]},{label:"Anywhere in the app",keys:[{keys:["⌘K","Ctrl+K"],join:"or",what:`The command bar: everything ${Je} can do, by name.`},{keys:["N"],what:"Start a new thread."},{keys:["/"],what:"Search your threads."},{keys:["\\"],what:"Show or hide the left sidebar."},{keys:["⌘Y","⌘N"],join:"or",what:"Allow or deny a card asking to run something."}]}];function pae(e){return e.length<=1?[e]:e==="esc"?[e]:[...e]}function tp(e){return e==="⇥"?"Tab":null}const uy={"new-task":[{key:"N",what:"New thread"}],sidebar:[{key:"\\",what:"Show or hide the sidebar"}],"state-tab":[{key:"⇥",what:"Next tab"}],row:[{key:"↵",what:"Open task"},{key:"E",what:"Mark done"},{key:"L",what:"Schedule for later"}],commands:[{key:"⌘K",what:"Everything by name"}],search:[{key:"/",what:"Search your tasks"}],terminal:[{key:"⌘J",what:"Show or hide the terminal"}],summary:[{key:"S",what:"Show or hide the summary"}],back:[{key:"esc",what:"Go back one level"}]},dy=7,hy=8;function mae(e,t,n,r="left",s,o=0){if(e.width<=0&&e.height<=0)return null;const i=e.bottom+dy+t.height>n.height-hy,a=i?e.top-dy-t.height:e.bottom+dy,c=r==="right"?e.right-t.width:s?s.left-o:e.left,u=Math.max(hy,Math.min(c,n.width-t.width-hy));return{top:Math.round(a),left:Math.round(u),rose:i}}const nh={product:"zero:settings",id:"codex-login"},eL=e=>`${e} project${e===1?"":"s"}`;function gae(e){return e?`${e} selected`:"Select the projects to archive"}function yae(e){return e?`Archive ${eL(e)}`:"Archive"}function wae(e){return`Archived ${eL(e)}`}function xE(e,t){const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function bae(e,t){const n=new Set(t);return new Set([...e].filter(r=>n.has(r)))}const xae=4;function kae({ranked:e,details:t,onSetOrder:n,onOpen:r,onNew:s,archived:o=[],onUnarchive:i,onArchive:a,who:c}){const[u,d]=g.useState(!1),[h,f]=g.useState(!1),[p,m]=g.useState(new Set),[w,b]=g.useState(null),x=()=>{f(!0),m(new Set),b(null)},v=()=>{f(!1),m(new Set)},S=async()=>{if(!p.size||!a)return;const z=[...p];v(),b(z),await a(z)},C=()=>{w&&(w.forEach(z=>i==null?void 0:i(z)),b(null))};g.useEffect(()=>{if(!w)return;const z=setTimeout(()=>b(null),12e3);return()=>clearTimeout(z)},[w]),g.useEffect(()=>{if(!h)return;const z=Oe=>{Oe.key==="Escape"&&v()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[h]);const[O,N]=g.useState(null),P=e.map(z=>z.slug).join(`
|
|
1112
|
+
`);g.useEffect(()=>{N(null)},[P]);const M=O??e.map(z=>z.slug),R=g.useMemo(()=>{const z=new Map(e.map(ye=>[ye.slug,ye])),xe=new Map(t.map(ye=>[ye.slug,ye])),Oe=new Set(o.map(ye=>ye.slug)),F=kB(M.map(ye=>z.get(ye)).filter(ye=>!!ye&&!Oe.has(ye.slug))),J=new Set,ze=[];for(const ye of F){const Z=xe.get(ye.slug);J.add(ye.slug),ze.push({slug:ye.slug,name:(Z==null?void 0:Z.name)??ye.name,logo:(Z==null?void 0:Z.logo)??ye.logo,dir:(Z==null?void 0:Z.dir)??ye.dir})}for(const ye of t)J.has(ye.slug)||z.has(ye.slug)||ze.push({slug:ye.slug,name:ye.name,logo:ye.logo,dir:ye.dir??""});return ze},[M.join(`
|
|
1113
|
+
`),e,t,o]),L=R.map(z=>z.slug),H=g.useMemo(()=>new Map(e.map(z=>[z.slug,z])),[e]),[_,Y]=g.useState(""),se=_.trim().toLowerCase(),re=se?R.filter(z=>z.name.toLowerCase().includes(se)||z.slug.toLowerCase().includes(se)||(z.dir??"").toLowerCase().includes(se)):R,T=re.map(z=>z.slug),W=T.join(`
|
|
1114
|
+
`);g.useEffect(()=>{m(z=>z.size?bae(z,T):z)},[W]);const[le,ge]=g.useState(null);g.useEffect(()=>{if(!le)return;const z=setTimeout(()=>ge(null),900);return()=>clearTimeout(z)},[le]);const j=(z,xe)=>{!xe||!n||(b(null),N(xe),ge(z),n(xe))},ae=g.useRef(null),[me,E]=g.useState(null),K=z=>xe=>{if(xe.button!==0||xe.target.closest("button"))return;const Oe=ae.current;if(!Oe)return;const F=[...Oe.querySelectorAll(".pp-row")].map(ne=>ne.getBoundingClientRect()),J=Oe.getBoundingClientRect().top,ze=xe.clientY,ye=xe.currentTarget;let Z=!1,Ce=T.indexOf(z);ye.setPointerCapture(xe.pointerId);const Ee=ne=>{if(!n||h)return;const Ie=ne.clientY-ze;if(!Z&&Math.abs(Ie)<xae)return;Z=!0,Ce=iT(F,ne.clientY);const Q=(Ce<F.length?F[Ce].top:F[F.length-1].bottom)-J;E({slug:z,dy:Ie,caret:Q})},oe=()=>{if(ye.removeEventListener("pointermove",Ee),ye.removeEventListener("pointerup",oe),ye.removeEventListener("pointercancel",oe),E(null),!Z&&h){m(ne=>xE(ne,z));return}if(!Z){r(z);return}j(z,R1(M,z,Ce<T.length?T[Ce]:null))};ye.addEventListener("pointermove",Ee),ye.addEventListener("pointerup",oe),ye.addEventListener("pointercancel",oe)};return l.jsxs(l.Fragment,{children:[l.jsx("h1",{className:"set-title",children:"Projects"}),l.jsx("p",{className:"set-lede",children:n?"Agents work from the top down, and a project’s place outranks a task’s own priority. Drag a project or use its arrows to move it, and open it to rename it or change its rules.":"Open a project to change its name, its picture and how its agents run."}),l.jsxs("div",{className:"proj-index-top",children:[l.jsxs("label",{className:"proj-search",children:[l.jsxs("svg",{className:"proj-search-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("circle",{cx:"7",cy:"7",r:"4.25"}),l.jsx("path",{d:"m10.2 10.2 3.3 3.3"})]}),l.jsx("input",{className:"proj-index-find",type:"search",value:_,placeholder:"Search projects","aria-label":"Search projects",onChange:z=>Y(z.target.value),onKeyDown:z=>{z.key==="Escape"&&_&&(z.stopPropagation(),Y(""))}}),_&&l.jsx("button",{type:"button",className:"proj-search-clear","aria-label":"Clear the search",onClick:()=>Y(""),children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:l.jsx("path",{d:"m5 5 6 6M11 5l-6 6"})})})]}),a&&R.length>0&&l.jsx("button",{type:"button",className:"set-ghost pp-select","aria-pressed":h,onClick:h?v:x,children:h?"Cancel":"Select"}),s&&l.jsx("button",{type:"button",className:"set-ghost",onClick:s,children:"New project"})]}),!R.length&&l.jsx("div",{className:"set-nav-empty",children:"No projects yet."}),!!R.length&&!re.length&&l.jsxs("div",{className:"set-nav-empty",children:["Nothing here matches “",_.trim(),"”."]}),re.length>0&&l.jsxs("div",{className:"pp-table",children:[h?l.jsxs("div",{className:"pp-head pp-head-act",children:[l.jsx("span",{className:"pp-rank"}),l.jsx("span",{className:"pp-head-name","aria-live":"polite",children:gae(p.size)}),l.jsx("button",{type:"button",className:"pp-head-btn",disabled:!p.size,onClick:S,children:yae(p.size)})]}):w?l.jsxs("div",{className:"pp-head pp-head-act",children:[l.jsx("span",{className:"pp-rank"}),l.jsx("span",{className:"pp-head-name","aria-live":"polite",children:wae(w.length)}),l.jsx("button",{type:"button",className:"pp-head-btn",onClick:C,children:"Undo"})]}):l.jsxs("div",{className:"pp-head","aria-hidden":"true",children:[l.jsx("span",{className:"pp-rank",children:"#"}),l.jsx("span",{className:"pp-head-name",children:"Project"}),c&&l.jsx("span",{className:"pp-head-who",children:"Who sees it"}),n&&l.jsx("span",{className:"pp-head-move",children:"Move"})]}),l.jsxs("ol",{className:"pp-list",ref:ae,children:[re.map((z,xe)=>{const Oe=L.indexOf(z.slug),F=p.has(z.slug);return l.jsxs("li",{className:["pp-row",(me==null?void 0:me.slug)===z.slug?"dragging":"",le===z.slug?"moved":"",Oe===0?"first":"",n&&!h?"can-move":"",h?"selecting":"",F?"picked":""].filter(Boolean).join(" "),style:(me==null?void 0:me.slug)===z.slug?{transform:`translateY(${me.dy}px)`}:void 0,tabIndex:0,role:h?"checkbox":"button","aria-checked":h?F:void 0,"aria-label":h?z.name:`${z.name}, number ${Oe+1} of ${R.length}. Open`,onPointerDown:K(z.slug),onKeyDown:J=>{if(h&&(J.key==="Enter"||J.key===" ")){J.preventDefault(),m(ze=>xE(ze,z.slug));return}if(!h){if(J.key==="Enter"){J.preventDefault(),r(z.slug);return}!J.altKey||J.key!=="ArrowUp"&&J.key!=="ArrowDown"||(J.preventDefault(),j(z.slug,_m(M,T,z.slug,J.key==="ArrowUp"?-1:1)))}},children:[l.jsx("span",{className:"pp-rank",children:h?l.jsx("span",{className:`pp-check${F?" on":""}`,"aria-hidden":"true",children:F&&l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M3.8 8.4 6.6 11.2 12.2 5"})})}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"pp-num",children:String(Oe+1).padStart(2,"0")}),n&&l.jsxs("span",{className:"pp-grip","aria-hidden":"true",children:[l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{})]})]})}),l.jsx(Lk,{src:z.logo,name:z.name,slug:z.slug,size:18}),l.jsxs("span",{className:"pp-text",children:[l.jsx("span",{className:"pp-name",children:z.name}),z.dir&&l.jsx("span",{className:"pp-where",children:kE(z.dir)})]}),c&&l.jsx("span",{className:"pp-who",children:c(H.get(z.slug)??z)}),n&&!h&&l.jsxs("span",{className:"pp-acts",children:[l.jsx("button",{type:"button",className:"pp-top",disabled:Oe===0,onClick:()=>j(z.slug,R1(M,z.slug,L[0])),children:"To top"}),l.jsx("button",{type:"button",className:"pp-arrow",disabled:xe===0,"aria-label":`Move ${z.name} up`,title:"Move up (⌥↑)",onClick:()=>j(z.slug,_m(M,T,z.slug,-1)),children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M4.5 9.5 8 6l3.5 3.5"})})}),l.jsx("button",{type:"button",className:"pp-arrow",disabled:xe===re.length-1,"aria-label":`Move ${z.name} down`,title:"Move down (⌥↓)",onClick:()=>j(z.slug,_m(M,T,z.slug,1)),children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M4.5 6.5 8 10l3.5-3.5"})})})]}),!h&&l.jsx("span",{className:"pp-open","aria-hidden":"true",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M6.5 4 10.5 8l-4 4"})})})]},z.slug)}),me&&l.jsx("span",{className:"pp-caret",style:{top:me.caret-1}})]})]}),o.length>0&&l.jsxs("div",{className:"pp-archived",children:[l.jsx("button",{type:"button",className:"pp-archived-toggle","aria-expanded":u,onClick:()=>d(z=>!z),children:u?"Hide archived projects":"Show archived projects"}),u&&l.jsx("ul",{className:"pp-archived-list",children:o.map(z=>l.jsxs("li",{className:"pp-archived-row",children:[l.jsxs("span",{className:"pp-text",children:[l.jsx("span",{className:"pp-name",children:z.name}),z.dir&&l.jsx("span",{className:"pp-where",children:kE(z.dir)})]}),i&&l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>i(z.slug),children:"Bring back"})]},z.slug))})]})]})}const $k=[{id:"general",label:"General",group:"Personal"},{id:"appearance",label:"Appearance",group:"Personal"},{id:"shortcuts",label:"Shortcuts",group:"Personal"},{id:"phone",label:"Phone",group:"Personal"},{id:"claude",label:"Claude Code",group:"Agents"},{id:"codex",label:"Codex",group:"Agents"},{id:"running",label:"Running",group:"Agents"},{id:"instructions",label:"Instructions",group:"Agents"},{id:"projects",label:"Projects",group:"Workspace"},{id:"team",label:"Team",group:"Workspace"}],vae=e=>{var t;return((t=$k.find(n=>n.id===e))==null?void 0:t.label)??e},Sae=[{page:"general",label:"Your account",anchor:"account",words:"signed in sign out log out logout email"},{page:"general",label:"Show keyboard shortcut hints",anchor:"keys",words:"keys hints"},{page:"general",label:"Counts and crash reports",anchor:"privacy",words:"privacy diagnostics analytics telemetry sends data"},{page:"general",label:"Where things are kept",anchor:"storage",words:"folder store path storage files disk"},{page:"general",label:"Check for updates",anchor:"updates",words:"update updates upgrade new version release restart newest current move applications folder disk image read-only stuck"},{page:"appearance",label:"Theme",anchor:"theme",words:"dark light colour color look background picture wallpaper"},{page:"appearance",label:"Blur and darkness",anchor:"tune",words:"tint dim glass transparency"},{page:"shortcuts",label:"Keyboard shortcuts",words:"keys hotkeys keybindings"},{page:"phone",label:"Use it on your phone",anchor:"phone",words:"phone mobile qr code scan remote tailscale wifi home screen app"},{page:"phone",label:"Connected devices",anchor:"phone-devices",words:"devices phones connected who reset key"},{page:"claude",label:"Usage",anchor:"usage",words:"claude code limits plan left remaining quota"},{page:"claude",label:"Signed in",anchor:"accounts",words:"claude code account accounts login subscription add email"},{page:"claude",label:"Permission mode",anchor:"permissions",words:"claude code permissions bypass ask allow plan accept edits"},{page:"codex",label:"Usage",anchor:"usage",words:"codex limits plan left remaining quota"},{page:"codex",label:"Signed in",anchor:"accounts",words:"codex account accounts login subscription add email"},{page:"codex",label:"Permission mode",anchor:"permissions",words:"codex permissions sandbox read only full access"},{page:"running",label:"How many run at once",anchor:"at-once",words:"agents concurrent parallel sessions limit queue capacity automatic"},{page:"running",label:"Hold heavy work when memory is short",anchor:"at-once",words:"ram tests builds slow memory"},{page:"running",label:"Stop programs agents leave behind",anchor:"at-once",words:"leftovers left running finished dev servers background jobs processes cleanup kill ram memory"},{page:"running",label:"Something felt slow",anchor:"at-once",words:"slow fewer agents throttle struggling"},{page:"running",label:"Agents you started yourself",anchor:"outside",words:"terminal outside sessions inbox your own"},{page:"instructions",label:"Instructions for every agent",words:"rules prompt claude.md how agents write to you"},{page:"projects",label:"Projects",words:"order priority archive new project"},{page:"team",label:"Team",words:"invite people members teammates"}],rh=e=>e.toLowerCase().split(/[^a-z0-9.]+/).filter(Boolean),fy=(e,t)=>t.every(n=>e.some(r=>r.startsWith(n)));function jae(e,{pages:t,projects:n=[]}){const r=rh(e);if(!r.length)return[];const s=new Set(t),o=[],i=[];for(const a of Sae){if(!s.has(a.page))continue;const c=vae(a.page),u={page:a.page,label:a.label,pageLabel:c,anchor:a.anchor};fy(rh(`${a.label} ${c}`),r)?o.push(u):fy(rh(`${a.label} ${c} ${a.words??""}`),r)&&i.push(u)}if(s.has("projects"))for(const a of n)fy(rh(a.name),r)&&o.push({page:`project:${a.slug}`,label:a.name,pageLabel:"Projects"});return[...o,...i]}function kE(e){var r;const t=(r=e.match(/^\/Users\/[^/]+/))==null?void 0:r[0];return(t?`~${e.slice(t.length)}`:e).replace(/([0-9a-f]{8})-[0-9a-f-]{20,}/i,"$1…")}function ri({on:e,onChange:t,label:n,busy:r}){return l.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,className:`set-sw ${e?"on":""} ${r?"busy":""}`,onClick:()=>t(!e)})}function Cae({value:e,min:t,max:n,onChange:r,label:s}){return l.jsxs("div",{className:"set-step","aria-label":s,children:[l.jsx("button",{type:"button","aria-label":`${s}, fewer`,disabled:e<=t,onClick:()=>r(e-1),children:l.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",children:l.jsx("path",{d:"M2.5 6h7",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})})}),l.jsx("span",{className:"val",children:e}),l.jsx("button",{type:"button","aria-label":`${s}, more`,disabled:e>=n,onClick:()=>r(e+1),children:l.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",children:l.jsx("path",{d:"M2.5 6h7M6 2.5v7",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})})})]})}function gl({label:e,value:t,options:n,onChange:r,title:s,bare:o=!1}){const[i,a]=g.useState(!1),c=g.useRef(null);g.useEffect(()=>{if(!i)return;const d=f=>{c.current&&!c.current.contains(f.target)&&a(!1)},h=f=>{f.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",h)}},[i]);const u=n.find(d=>d.value===t);return l.jsxs("div",{className:`set-picker${i?" open":""}${o?" set-picker-bare":""}`,children:[!o&&l.jsx("div",{className:"set-picker-label",children:e}),l.jsxs("span",{className:"set-picker-wrap",ref:c,children:[l.jsxs("button",{type:"button",className:"set-picker-now",title:s,"aria-label":o?e:void 0,"aria-haspopup":"listbox","aria-expanded":i,onClick:()=>a(d=>!d),children:[(u==null?void 0:u.label)??t,l.jsx("svg",{className:"set-picker-chev",width:"9",height:"9",viewBox:"0 0 10 10","aria-hidden":"true",children:l.jsx("path",{d:"M2.2 4 L5 6.8 L7.8 4",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})]}),i&&l.jsx("span",{className:"set-picker-menu",role:"listbox","aria-label":e,children:n.map(d=>l.jsx("button",{type:"button",role:"option","aria-selected":d.value===t,className:`set-picker-row${d.value===t?" on":""}`,onClick:()=>{r(d.value),a(!1)},children:d.label},d.value))})]})]})}function sh({label:e,desc:t,value:n,min:r,max:s,step:o,format:i,onChange:a}){const c=(n-r)/(s-r)*100;return l.jsxs("div",{className:"set-row set-dial-row",children:[l.jsxs("div",{className:"set-row-text",children:[l.jsx("div",{className:"set-row-label",children:e}),l.jsx("div",{className:"set-row-desc",children:t})]}),l.jsxs("div",{className:"set-dial",children:[l.jsx("input",{type:"range",className:"set-range",min:r,max:s,step:o,value:n,"aria-label":e,style:{"--fill":`${c}%`},onChange:u=>a(Number(u.currentTarget.value))}),l.jsx("span",{className:"set-dial-val",children:i(n)})]})]})}const Nae=e=>Ju.some(t=>t.id===e),Eae=e=>{var t;return((t=Ju.find(n=>n.id===e))==null?void 0:t.name)??"Picture"};function ut({label:e,desc:t,children:n}){return l.jsxs("div",{className:"set-row",children:[l.jsxs("div",{className:"set-row-text",children:[l.jsx("div",{className:"set-row-label",children:e}),t&&l.jsx("div",{className:"set-row-desc",children:t})]}),n&&l.jsx("div",{className:"set-row-ctl",children:n})]})}function Aae({cmd:e}){const[t,n]=g.useState(!1);return l.jsx("button",{type:"button",className:"set-copy",title:e,onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),window.setTimeout(()=>n(!1),1200)}catch{}},children:t?"Copied":"Copy the command"})}function Tae(e,t,n){var s,o,i,a,c,u,d;const r=t.find(h=>h.engine===n)??null;return n==="codex"?{engine:n,name:"Codex",reading:r,found:!!((s=e.codex)!=null&&s.found),certain:!!((o=e.codex)!=null&&o.certain),trouble:((i=e.codex)==null?void 0:i.trouble)??null,bin:((a=e.codex)==null?void 0:a.bin)??"",chosen:!!((c=e.codex)!=null&&c.chosen),url:((u=e.codex)==null?void 0:u.url)??"",accounts:(((d=e.codex)==null?void 0:d.accounts)??[]).map(h=>({profile:h.profile,email:h.email,plan:h.plan,chosen:h.chosen,signedIn:h.signedIn,trouble:null,dir:null}))}:{engine:n,name:"Claude Code",reading:r,found:!!e.claudeFound,certain:e.claudeCertain!==!1,trouble:null,bin:e.claudeBin??"",chosen:!!e.claudeChosen,url:e.claudeInstallUrl??"",accounts:(e.accounts??[]).map(h=>{var f,p;return{profile:h.profile,email:h.email??null,plan:((f=h.plan)==null?void 0:f.label)??null,chosen:!!h.chosen,signedIn:!!h.email,trouble:((p=h.trouble)==null?void 0:p.note)??null,dir:h.dir??null}})}}function tL({reading:e,now:t,trouble:n=null}){var s;const r=(s=e==null?void 0:e.limits)!=null&&s.length?D2(e.limits,t):[];return r.length?l.jsx(l.Fragment,{children:r.map(o=>l.jsx(ut,{label:o.name,desc:o.when||void 0,children:l.jsxs("span",{className:"set-usage",children:[l.jsx("span",{className:"usage-meter wide","aria-hidden":"true",children:l.jsx("i",{style:{width:`${o.used}%`}})}),l.jsxs("span",{className:"set-usage-pct",children:[o.used,"% used"]})]})},o.key))}):n?null:l.jsx(ut,{label:"No usage reading yet"})}function Mae(e,t){if(e==null||!Number.isFinite(e))return"";const n=Math.max(0,Math.floor((t-e)/6e4));if(!n)return"Checked just now";if(n<60)return`Checked ${n} ${n===1?"minute":"minutes"} ago`;const r=Math.floor(n/60);return`Checked ${r} ${r===1?"hour":"hours"} ago`}function Rae({reading:e,profile:t,email:n,now:r,trouble:s=null}){const[o,i]=g.useState(null),[a,c]=g.useState(!1),[u,d]=g.useState(null),h=g.useRef(!1),f=g.useRef(t);f.current=t;const p=v=>v&&(v.profile??"default")===t?v:null,m=p(e),w=p(o),b=w&&(!m||w.at>=m.at)?w:m;g.useEffect(()=>{i(null),d(null)},[t]);const x=async()=>{if(h.current)return;h.current=!0;const v=t;c(!0),d(null);try{const S=await q.refreshUsage();if(f.current!==v)return;S.ok&&S.reading&&(S.reading.profile??"default")===v?i(S.reading):d(S.error??"The account changed. Refresh usage again.")}catch{f.current===v&&d(Ny)}finally{h.current=!1,c(!1)}};return l.jsxs(Lt,{id:"usage",label:"Usage",action:l.jsx("button",{type:"button",className:"set-ghost",disabled:a,onClick:()=>void x(),children:a?"Refreshing…":"Refresh"}),children:[l.jsx(ut,{label:n||"Claude Code",desc:a?"Checking usage…":Mae(b==null?void 0:b.at,r)||void 0}),l.jsx(tL,{reading:b,now:r,trouble:s??u}),s?l.jsx("div",{className:"set-row set-row-warn",role:"alert",children:s}):u&&l.jsx("div",{className:"set-row set-row-warn",role:"alert",children:u})]})}function Iae({agent:e,onChoose:t,onAdd:n}){const r=e.accounts,s=r.some(o=>o.chosen);return l.jsxs(l.Fragment,{children:[r.map(o=>{const i=s?o.chosen:!1,a=o.email??"Not signed in";return o.trouble?l.jsx(ut,{label:a,desc:o.trouble,children:o.dir&&l.jsx(Aae,{cmd:`CLAUDE_CONFIG_DIR=${o.dir} claude`})},o.profile):l.jsxs("div",{className:`set-row set-acct-row${i?" on":""}`,children:[l.jsxs("div",{className:"set-row-text",children:[l.jsxs("div",{className:"set-row-label",children:[a,i&&l.jsx("span",{className:"set-badge",children:"In use"})]}),l.jsx("div",{className:"set-row-desc",children:o.signedIn?o.plan??"Signed in":"Finish signing in to use it"})]}),!i&&r.length>1&&l.jsx("div",{className:"set-row-ctl",children:l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>t(e.engine,o.profile),children:s?"Use this one":"Use only this one"})})]},o.profile)}),l.jsx(ut,{label:"Add account",children:l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>n(e),children:"Add"})})]})}function Dae({command:e,onFinished:t}){const n=g.useRef(!1);return g.useEffect(()=>{!e||n.current||(n.current=!0,(async()=>{try{await q.terminal({...nh,action:"open"}),await q.terminal({...nh,action:"write",data:`${e}\r`})}catch{}})())},[e]),l.jsx("div",{className:"ac-shell",children:l.jsx(xx,{product:nh.product,id:nh.id,startOpen:!0,onCommandFinished:t})})}const Lt=({id:e,label:t,warn:n,action:r,children:s})=>l.jsxs("div",{className:"set-group","data-find":e,children:[t&&l.jsxs("div",{className:`set-group-label${r?" set-group-head":""}`,children:[t,r]}),l.jsxs("div",{className:"set-plate",children:[n&&l.jsx("div",{className:"set-row set-row-warn",role:"status",children:n}),s]})]});function Oae(e){const t=e.agentsTotal??e.capacity??1,n=s=>`${s} ${s===1?"agent":"agents"}`,r=[{value:"auto",label:`Automatic (${n(t)})`}];for(let s=1;s<=(e.slotsMax??12);s++)r.push({value:String(s),label:n(s)});return r}function Lae({running:e,capacity:t,gate:n}){const r=n!=null&&n.on?n.reading:null;if(!r)return null;const s=r.pressure==="critical"?"Very short":r.pressure==="tight"?"Tight":r.pressure?"Fine":null,o=[];Number.isFinite(e)&&o.push({n:String(e),of:t?`of ${t} running`:"running"}),r.heavy!==null&&o.push({n:String(r.heavy),of:"heavy at once"}),r.waiting!==null&&o.push({n:String(r.waiting),of:"waiting on memory"}),s&&o.push({n:s,of:"memory now"});const i=r.asked?`Today: ${r.asked} commands asked, ${r.waited??0} waited, ${r.refused?`${r.refused} turned away`:"none turned away"}.`:null,a=r.holding?"New agents wait until memory frees up. Urgent tasks still start.":null;return!o.length&&!i&&!a?null:l.jsx("div",{className:"set-group",children:l.jsxs("div",{className:"set-plate",children:[!!o.length&&l.jsx("div",{className:"set-row set-read",children:o.map(c=>l.jsxs("div",{children:[l.jsx("b",{children:c.n}),l.jsx("span",{children:c.of})]},c.of))}),r.usedPct!==null&&l.jsx("div",{className:"set-row set-bar-row",children:l.jsx("i",{className:"set-bar",children:l.jsx("i",{className:r.pressure==="normal"?"":"hot",style:{width:`${r.usedPct}%`}})})}),a&&l.jsx("div",{className:"set-row set-row-warn",children:a}),i&&l.jsx("div",{className:"set-row set-row-warn",children:i})]})})}const $ae=[{value:"anywhere",label:"Anywhere"},{value:"tailscale",label:"Tailscale, secure"},{value:"wifi",label:"Same Wi-Fi, not secure"}];function Pae({onFeedback:e}){const[t,n]=g.useState(null),[r,s]=g.useState(null),[o,i]=g.useState(!1);g.useEffect(()=>{$b().then(n)},[]);const a=async c=>{i(!0),s(null);try{n(await c())}catch(u){s(String(u.message??u))}finally{i(!1)}};return l.jsxs(xo,{title:"Phone",children:[l.jsxs(Lt,{id:"phone-alerts",label:"Alerts on this phone",children:[l.jsx(ut,{label:t==="on"?"Alerts are on":"Alerts",desc:r??(t?Ey[t]:"Checking…"),children:(t==="on"||t==="off")&&l.jsx(ri,{on:t==="on",busy:o,label:"Alerts",onChange:c=>void a(c?wA:_2)})}),t==="on"&&l.jsx(ut,{label:"Send a test alert",desc:"Lock the phone after tapping, and it should arrive within a few seconds.",children:l.jsx("button",{type:"button",className:"set-ghost",disabled:o,onClick:()=>{i(!0),W2().then(c=>s(c?"Sent.":"The computer could not send it.")).catch(c=>s(String(c.message??c))).finally(()=>i(!1))},children:"Send test"})})]}),e&&l.jsx(Lt,{id:"phone-feedback",label:"Feedback",children:l.jsx(ut,{label:"Send feedback",desc:`Tell us what works and what does not. It goes straight to the people who make ${st}.`,children:l.jsx("button",{type:"button",className:"set-ghost",onClick:e,children:"Send feedback"})})})]})}function zae({onFeedback:e}){var d;const[t,n]=g.useState(void 0),[r,s]=g.useState(!1),[o,i]=g.useState(()=>Date.now()),a=g.useCallback(async(h,f)=>{s(!0);try{n(await q.phoneLink({action:h,via:f}))}finally{s(!1)}},[]);if(g.useEffect(()=>{a("status");const h=q.onPhoneChanged(()=>{q.phoneLink({action:"status"}).then(n)}),f=window.setInterval(()=>{i(Date.now()),q.phoneLink({action:"status"}).then(n)},Ta(15e3,sr()));return()=>{h(),window.clearInterval(f)}},[a]),t===void 0)return l.jsx(xo,{title:"Phone",children:null});if(t===null)return document.documentElement.dataset.door==="phone"?l.jsx(Pae,{onFeedback:e}):l.jsx(xo,{title:"Phone",children:l.jsx(Lt,{children:l.jsx(ut,{label:"Set up from the desktop app",desc:`A phone is connected from the ${st} app's own window, not from a browser tab.`})})});const c=t.routes.some(h=>h.via==="tailscale"),u=()=>{window.confirm("Make a new key? Every connected phone is disconnected and has to scan the new code.")&&a("reset")};return l.jsxs(xo,{title:"Phone",lede:"Use this inbox on your phone. Scan the code with the phone's camera, then add the page to the home screen and it opens like an app.",children:[l.jsxs(Lt,{id:"phone",label:"Phone access",children:[l.jsx(ut,{label:"Let phones connect",desc:t.on?t.error??(t.listening?`Open on port ${t.port}.`:"Starting…"):"Off. Nothing outside this computer can reach the inbox.",children:l.jsx(ri,{on:t.on,busy:r,label:"Let phones connect",onChange:h=>void a(h?"on":"off")})}),t.on&&l.jsx(ut,{label:"Reach it over",desc:t.via==="anywhere"?(d=t.relay)!=null&&d.connected?"Works on any Wi-Fi or mobile data, with nothing to install. Everything is locked on this computer and unlocked only on your phone, so the relay in between cannot read it.":t.error??"Connecting to the relay…":t.via==="tailscale"?t.settingUp?"Setting up a secure address with Tailscale…":t.secure?"A secure address only your own devices on Tailscale can reach. Works anywhere your phone has Tailscale on.":"Works anywhere your phone has Tailscale on, but without a secure address, so the phone shows Not Secure.":c?"Works only on the same Wi-Fi, and the phone shows Not Secure because nothing is encrypted. Pick Tailscale for a secure address that also works away from home.":"Works only on the same Wi-Fi, and the phone shows Not Secure because nothing is encrypted. Install Tailscale on both for a secure address.",children:l.jsx(gl,{bare:!0,label:"Reach it over",value:t.via??"wifi",options:$ae.filter(h=>t.routes.some(f=>f.via===h.value)),onChange:h=>void a("via",h)})})]}),t.on&&l.jsxs(Lt,{id:"phone-code",label:"Scan with your phone",children:[t.qr&&t.url?l.jsxs("div",{className:"set-row set-phone-qr",children:[l.jsx("img",{alt:"QR code that opens this inbox on a phone",src:`data:image/svg+xml;utf8,${encodeURIComponent(t.qr)}`}),l.jsxs("div",{className:"set-row-desc",children:["Anyone who scans this code can run agents on this computer, so treat it like a password. If it was seen by someone else, reset the key.",l.jsx("br",{}),l.jsx("code",{children:t.url.replace(/(token=|#k=).*/,"$1…")})]})]}):l.jsx(ut,{label:"No network",desc:"This computer is not on Wi-Fi or Tailscale right now, so a phone has no way to reach it."}),l.jsx(ut,{label:"Reset key",desc:"Makes a new code. Every phone is disconnected until it scans again.",children:l.jsx("button",{type:"button",className:"set-ghost",disabled:r,onClick:u,children:"Reset key"})})]}),t.on&&l.jsx(Lt,{id:"phone-devices",label:"Connected devices",children:t.devices.length===0?l.jsx(ut,{label:"None yet",desc:"A phone shows here as soon as it opens the inbox."}):t.devices.map(h=>l.jsx(ut,{label:h.name,desc:`${h.live?"Connected now":`Last seen ${Bs(h.lastSeen,o)} ago`}${h.ip?` · ${h.ip}`:""} · first seen ${Bs(h.firstSeen,o)} ago${h.alerts?" · alerts on":""}${h.alertError?` · last alert failed: ${h.alertError}`:""}`,children:h.alerts&&l.jsx("button",{type:"button",className:"set-ghost",disabled:r,onClick:()=>void q.phoneLink({action:"stop-alerts",device:h.id}).then(n),children:"Stop alerts"})},h.id))})]})}const xo=({title:e,lede:t,children:n})=>l.jsxs("div",{className:"set-inner",children:[l.jsx("h1",{className:"set-title",children:e}),t&&l.jsx("p",{className:"set-lede",children:t}),n]});function Fae({keys:e,join:t,what:n}){return l.jsxs("div",{className:"set-key-row",children:[l.jsx("div",{className:"set-key-caps",children:e.map((r,s)=>l.jsxs(g.Fragment,{children:[s>0&&t&&l.jsx("span",{className:"set-key-join",children:t}),l.jsxs("kbd",{children:[r,tp(r)&&l.jsx("span",{className:"fr-cap-word",children:tp(r)})]})]},r))}),l.jsx("div",{className:"set-key-say",children:n})]})}const oh=nf,Bae=fa.map(e=>({value:e,label:sa[e]})),_ae=ua.map(e=>({value:e,label:Oh[e].label})),Wae=[{value:"all",label:"All of them"},{value:"waiting",label:"Only the stuck ones"},{value:"off",label:"None"}],Hae={all:"Each one is a row in your inbox. Closing it only takes it out of the inbox.",waiting:"Only the ones waiting for you to type. The rest run without interrupting you.",off:"None reach your inbox. Each is still in its project’s sidebar."},Uae={name:"Claude Code",connected:"Claude Code is connected",connectedSay:`${st} can see it on this computer, so your agents have something to run on. There is nothing for you to set up.`,missing:"Claude Code is not on this computer",missingSay:`${st} could not find Claude Code on this computer. Install it, then check again.`,missingLink:"Get Claude Code",unsure:`${st} could not check`,unsureSay:`${st} has not been able to look for Claude Code on this computer. That is not the same as it being missing, only that the answer never came back. Try again in a moment.`,check:"Check again",checking:"Looking",getSay:"It takes a few minutes. Come back here and press Check again, and your agents can run.",still:"Still nothing here. A fresh install can take a moment to appear.",stillUnsure:`${st} still could not get an answer. Nothing is necessarily wrong; try once more in a minute.`,where:e=>`${st} runs it from ${e}.`,point:"Choose the file",pointLabel:"Keep it somewhere else?",pointSay:`If ${st} is looking in the wrong place, show it where Claude Code is.`,picking:"Choosing",chosenLabel:"You chose this one",chosenSay:`You showed ${st} where it is, so it stopped looking. Let it look again if that was wrong.`,chosenGoneSay:`The file you chose is not there any more. Choose another, or let ${st} look.`,searchAgain:"Look for it instead"},Kae={name:"Codex",connected:"Codex is connected",connectedSay:`${st} can see it on this computer, so you can put a task on Codex instead of Claude Code. There is nothing for you to set up.`,missing:"Codex is not on this computer",missingSay:`${st} could not find Codex on this computer, so every task runs on Claude Code. Install it, then check again.`,missingLink:"Get Codex",unsure:`${st} could not check`,unsureSay:`${st} has not been able to look for Codex on this computer. That is not the same as it being missing, only that the answer never came back. Try again in a moment.`,check:"Check again",checking:"Looking",getSay:"It takes a few minutes. Come back here and press Check again, and Codex is a choice on every task.",still:"Still nothing here. A fresh install can take a moment to appear.",stillUnsure:`${st} still could not get an answer. Nothing is necessarily wrong; try once more in a minute.`,where:e=>`${st} runs it from ${e}.`,point:"Choose the file",pointLabel:"Keep it somewhere else?",pointSay:`If ${st} is looking in the wrong place, show it where Codex is.`,picking:"Choosing",chosenLabel:"You chose this one",chosenSay:`You showed ${st} where it is, so it stopped looking. Let it look again if that was wrong.`,chosenGoneSay:`The file you chose is not there any more. Choose another, or let ${st} look.`,searchAgain:"Look for it instead"};function vE(e){return e.email?`Signed in as ${e.email}`:e.name?`Signed in as ${e.name}`:e.accountId?`Signed in as ${e.accountId}`:null}function Vae(e){const t=[];return e.email&&e.name&&t.push(e.name),e.plan&&e.planNamed!==!1?t.push(`On the ${e.plan} plan.`):e.plan?t.push(`Codex reports the plan as “${e.plan}”.`):e.mode==="apikey"&&t.push("Signed in with an API key, so usage is billed to that key rather than to a subscription."),t.length?t.join(". ").replace(/\.\./g,"."):"This is the Codex login your tasks run on."}function nL({copy:e,check:t,engine:n,found:r,certain:s,bin:o,chosen:i=!1,url:a,trouble:c=null,account:u=null,onChecked:d}){const[h,f]=g.useState(!1),[p,m]=g.useState(null),[w,b]=g.useState(!1),[x,v]=g.useState(null),S=async()=>{f(!0);try{const P=await t();m(!P.found),await d()}finally{f(!1)}},C=async P=>{b(!0),v(null);try{const M=await q.engineBin(n,P);M!=null&&M.refused&&v(M.refused),M!=null&&M.canceled||await d()}finally{b(!1)}},O=r?e.connected:s?e.missing:e.unsure,N=c&&r?c:r?e.connectedSay:p?s?e.still:e.stillUnsure:s?e.missingSay:e.unsureSay;return l.jsxs(Lt,{id:"status",label:"Status",children:[l.jsxs(ut,{label:O,desc:N,children:[l.jsx("span",{className:`set-dot ${r?"live":""}`}),l.jsx("span",{className:"set-mono",children:r?"connected":s?"not found":"not sure"}),l.jsx("button",{type:"button",className:"set-ghost",disabled:h,onClick:()=>void S(),children:h?e.checking:e.check})]}),r&&u&&vE(u)!==null&&l.jsx(ut,{label:vE(u),desc:Vae(u)}),!r&&s&&l.jsx(ut,{label:"Where to get it",desc:e.getSay,children:l.jsx("a",{className:"set-ghost",href:a,target:"_blank",rel:"noreferrer",children:e.missingLink})}),r&&o&&l.jsx(ut,{label:"Runs from",desc:e.where(o)}),l.jsx(ut,{label:i?e.chosenLabel:e.pointLabel,desc:x??(i?r?e.chosenSay:e.chosenGoneSay:e.pointSay),children:l.jsx("button",{type:"button",className:"set-ghost",disabled:w,onClick:()=>void C(i?"search":void 0),children:w?e.picking:i?e.searchAgain:e.point})})]})}const qae=e=>l.jsx(nL,{copy:Uae,check:q.recheckClaude,engine:"claude",...e}),Yae=e=>l.jsx(nL,{copy:Kae,check:q.recheckCodex,engine:"codex",...e});function Gae({state:e}){const[t,n]=g.useState(null),[r,s]=g.useState(!1),o=JSON.stringify(e??null),i=t&&t.was===o?t.got:e??(t==null?void 0:t.got)??null,a=GA(i,{checking:r}),c=async()=>{if(!a.busy){if(a.restart){q.updateInstall();return}if(a.move){q.updateMove();return}s(!0);try{const u=await q.updateCheck();n({was:o,got:u})}finally{s(!1)}}};return l.jsx(Lt,{id:"updates",label:"Updates",children:l.jsx(ut,{label:i!=null&&i.currentVersion?`${st} ${i.currentVersion}`:st,desc:a.sentence,children:l.jsx("button",{type:"button",className:"set-ghost",disabled:a.busy,onClick:()=>void c(),children:a.button})})})}function Jae({project:e,onPick:t,onClear:n}){return l.jsxs("span",{className:"set-icon-pick",children:[l.jsx("button",{type:"button",className:"set-icon-btn",onClick:()=>void t(),title:e.logo?"Change this project’s picture":"Give this project a picture","aria-label":e.logo?`Change the picture for ${e.name}`:`Give ${e.name} a picture`,children:l.jsx(Lk,{src:e.logo,name:e.name,slug:e.slug,size:26})}),e.logo&&l.jsx("button",{type:"button",className:"set-icon-clear",onClick:()=>void n(),title:"Go back to the default mark","aria-label":`Remove the picture for ${e.name}`,children:l.jsx("svg",{viewBox:"0 0 10 10","aria-hidden":"true",children:l.jsx("path",{d:"M3 3l4 4M7 3l-4 4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})}function Xae({project:e,onRename:t}){const[n,r]=g.useState(!1),[s,o]=g.useState(e.name),i=g.useRef(null);if(g.useEffect(()=>{if(!n)return;o(e.name);const c=requestAnimationFrame(()=>{var u,d;(u=i.current)==null||u.focus(),(d=i.current)==null||d.select()});return()=>cancelAnimationFrame(c)},[n,e.name]),!n)return l.jsx("h1",{className:"set-title set-title-edit",tabIndex:0,role:"button",title:"Click to rename this project",onClick:()=>r(!0),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),r(!0))},children:e.name});const a=()=>{r(!1);const c=s.trim();c&&c!==e.name&&t(c)};return l.jsx("input",{ref:i,className:"set-title set-title-input",value:s,"aria-label":`Name for ${e.name}`,onChange:c=>o(c.target.value),onBlur:a,onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"&&(c.preventDefault(),a()),c.key==="Escape"&&(c.preventDefault(),r(!1))}})}function Qae({id:e}){const t={general:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M4 7h9M17 7h3M4 12h3M11 12h9M4 17h11M19 17h1"}),l.jsx("circle",{cx:"15",cy:"7",r:"2"}),l.jsx("circle",{cx:"9",cy:"12",r:"2"}),l.jsx("circle",{cx:"17",cy:"17",r:"2"})]}),appearance:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"12",cy:"12",r:"8"}),l.jsx("path",{d:"M12 4a8 8 0 0 1 0 16z",fill:"currentColor",stroke:"none"})]}),shortcuts:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3.5",y:"6.5",width:"17",height:"11",rx:"2"}),l.jsx("path",{d:"M7.5 10.5h.01M11 10.5h.01M14.5 10.5h.01M8.5 14h7"})]}),phone:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"7",y:"3",width:"10",height:"18",rx:"2.2"}),l.jsx("path",{d:"M11 17.5h2"})]}),claude:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"2"}),l.jsx("path",{d:"m7.5 10 2.5 2-2.5 2M12.5 14.5h4"})]}),codex:l.jsx(l.Fragment,{children:l.jsx("path",{d:"m9 8-4 4 4 4M15 8l4 4-4 4"})}),running:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"12",cy:"12",r:"8"}),l.jsx("path",{d:"M10.5 9.2v5.6l4.5-2.8z"})]}),instructions:l.jsx("path",{d:"M6.5 3.5h7.5l4 4V20.5h-11.5zM14 3.5V8h4M9.5 12h5M9.5 16h5"}),projects:l.jsx("path",{d:"M3.5 7.5a2 2 0 0 1 2-2h4l2 2h7a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z"}),team:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"9",cy:"9",r:"3"}),l.jsx("path",{d:"M3.5 19c.8-3 3-4.5 5.5-4.5s4.7 1.5 5.5 4.5"}),l.jsx("circle",{cx:"16.5",cy:"9.5",r:"2.5"}),l.jsx("path",{d:"M16 14.6c2.3-.2 4 1.2 4.5 4"})]})};return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t[e]})}function Zae(e,t){return e.startsWith("project:")?{project:e.slice(8)}:e==="themes"?"appearance":e==="priority"?"projects":e==="accounts"?"claude":e==="agents"?"running":e==="team"?t.team?"team":"general":$k.some(n=>n.id===e)?e:"general"}function ele({look:e,onSetLook:t,tune:n,onSetTune:r,onResetTune:s,keyHints:o,onSetKeyHints:i,startPane:a,usageReadings:c=[],now:u=Date.now(),embedded:d=!1,onSectionChange:h,onNewProject:f,ranked:p=[],onSetOrder:m,teamPane:w,projectShare:b,projectWho:x,account:v,update:S=null,onClose:C,onFeedback:O}){var ee,U;const[N,P]=g.useState(null),[M,R]=g.useState(()=>Zae(a||new URLSearchParams(location.search).get("settings")||(sr()?"phone":""),{team:!!w}));g.useEffect(()=>{h==null||h(typeof M=="object"?"projects":M==="general"?null:M)},[M]);const[L,H]=g.useState(null),_=g.useCallback(async()=>{const I=await q.settings();P(I),I.ok||H(I.error??"could not read settings")},[]);g.useEffect(()=>{_()},[_]);const[Y,se]=g.useState(""),[re,T]=g.useState(0),W=g.useRef(null),le=g.useRef(Y);le.current=Y,g.useEffect(()=>{const I=ue=>!!le.current&&ue.target===W.current,V=ue=>{var ie,we;if(ue.key==="Escape"&&!I(ue)){ue.preventDefault(),ue.stopPropagation(),C();return}const G=ue.target instanceof HTMLElement&&ue.target.closest('input, textarea, [contenteditable="true"]');(ue.metaKey&&ue.key.toLowerCase()==="f"||ue.key==="/"&&!G&&!ue.metaKey&&!ue.ctrlKey)&&(ue.preventDefault(),ue.stopPropagation(),(ie=W.current)==null||ie.focus(),(we=W.current)==null||we.select())};return window.addEventListener("keydown",V,!0),()=>window.removeEventListener("keydown",V,!0)},[C]);const ge=g.useCallback(async I=>{const V=await I;V.ok?(P(V),H(null)):H(V.error??"could not save that")},[]),[j,ae]=g.useState(null),me=(I,V,ue)=>ge(q.setProjectSetting({product:I,key:V,value:ue})),E=(I,V)=>ge(q.setWorkspaceSetting({key:I,value:V})),K=(N==null?void 0:N.projects)??[],[z,xe]=g.useState(Ao),Oe=I=>{xe(I),R("instructions")},F=g.useMemo(()=>typeof M=="string"?null:K.find(I=>I.slug===M.project)??null,[M,K]);g.useEffect(()=>{typeof M!="string"&&N&&!F&&R("projects")},[M,N,F]);const J=N==null?void 0:N.workspace,ye=((J==null?void 0:J.engineChoices)??[]).length>1,Z=$k.filter(I=>I.id!=="team"||!!w),Ce=g.useMemo(()=>jae(Y,{pages:Z.map(I=>I.id),projects:K}),[Y,Z.length,K]);g.useEffect(()=>{T(0)},[Y]);const[Ee,oe]=g.useState(null),ne=I=>{se(""),R(I.page.startsWith("project:")?{project:I.page.slice(8)}:I.page),oe(I.anchor?{anchor:I.anchor,at:Date.now()}:null)},Ie=g.useRef(null);g.useEffect(()=>{if(!Ee)return;const I=window.setTimeout(()=>{var ue;const V=(ue=Ie.current)==null?void 0:ue.querySelector(`[data-find="${Ee.anchor}"]`);V&&(V.scrollIntoView({block:"center",behavior:"smooth"}),V.classList.remove("set-found"),V.offsetWidth,V.classList.add("set-found"))},60);return()=>window.clearTimeout(I)},[Ee,M,N]),g.useEffect(()=>{var I;(I=Ie.current)==null||I.scrollTo({top:0})},[typeof M=="string"?M:M.project]);const Q=I=>{var V;if(I.key==="Escape"){I.preventDefault(),se("");return}Ce.length&&(I.key==="ArrowDown"&&(I.preventDefault(),T(ue=>Math.min(Ce.length-1,ue+1))),I.key==="ArrowUp"&&(I.preventDefault(),T(ue=>Math.max(0,ue-1))),I.key==="Enter"&&(I.preventDefault(),ne(Ce[re]??Ce[0]),(V=W.current)==null||V.blur()))},he=I=>M===I||I==="projects"&&typeof M=="object",te=I=>{var ie;if(!J)return null;const V=Tae(J,c,I),ue=V.accounts.find(we=>we.chosen)??V.accounts[0],G={found:V.found,certain:V.certain,bin:V.bin,chosen:V.chosen,url:V.url,trouble:V.trouble,onChecked:_};return l.jsxs(xo,{title:V.name,children:[(!V.found||V.trouble||V.chosen)&&(I==="codex"?l.jsx(Yae,{...G}):l.jsx(qae,{...G})),V.found&&l.jsxs(l.Fragment,{children:[I==="claude"?l.jsx(Rae,{reading:V.reading,profile:(ue==null?void 0:ue.profile)??"default",email:ue==null?void 0:ue.email,trouble:(ue==null?void 0:ue.trouble)??null,now:u},(ue==null?void 0:ue.profile)??"default"):l.jsx(Lt,{id:"usage",label:"Usage",children:l.jsx(tL,{reading:V.reading,now:u})}),l.jsx(Lt,{id:"accounts",label:"Signed in",warn:I==="claude"?J.accountsNote:null,children:l.jsx(Iae,{agent:V,onChoose:(we,ve)=>ge(q.setWorkspaceSetting({key:"activeAccount",value:{engine:we,profile:ve}})),onAdd:async we=>{const ve=we.engine==="codex"?await q.addCodexAccount():await q.addClaudeAccount();ae(ve.ok?{engine:we.engine,name:we.name,command:ve.command}:{engine:we.engine,name:we.name,error:ve.error}),await _()}})}),j&&j.engine===I&&l.jsxs("div",{className:"ac-adding",children:[l.jsxs("div",{className:"ac-adding-top",children:[l.jsx("span",{children:j.error?"Could not add an account":`Sign in to ${j.name??"your account"}`}),l.jsx("button",{type:"button",className:"ac-adding-x","aria-label":"Close",onClick:()=>{ae(null),_()},children:"×"})]}),j.error?l.jsx("p",{children:j.error}):l.jsx("p",{children:"Finish signing in below. It opens your browser, and the account appears above when it is done."}),!j.error&&l.jsx(Dae,{command:j.command,onFinished:()=>void _()})]}),I==="codex"?l.jsx(Lt,{id:"permissions",label:"Permissions",children:l.jsx(ut,{label:"Permission mode",desc:(ie=Oh[J.codexMode])==null?void 0:ie.what,children:l.jsx(gl,{bare:!0,label:"Permission mode",title:"The starting point for every Codex agent. A project can be set to its own.",value:J.codexMode,options:_ae,onChange:we=>E("codexMode",we)})})}):l.jsx(Lt,{id:"permissions",label:"Permissions",children:J.permission==="custom"?l.jsx(ut,{label:"Permission mode",desc:oh.custom}):l.jsx(ut,{label:"Permission mode",desc:oh[J.permission],children:l.jsx(gl,{bare:!0,label:"Permission mode",title:`Claude Code's own modes. The starting point for every Claude Code agent, and a single reply can be sent in another. ${pw}`,value:J.permission,options:Bae,onChange:we=>E("permission",we)})})})]})]})};return l.jsxs("div",{className:`settings-screen${d?" settings-embedded":""}`,"data-pane":typeof M=="string"?M:"project",children:[l.jsxs("div",{className:"set-nav",children:[l.jsxs("div",{className:"set-nav-top",children:[l.jsxs("button",{type:"button",className:"set-nav-back",onClick:C,"aria-label":"Back to app",title:"Back to app (esc)",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5"})}),l.jsx("span",{className:"set-nav-title",children:"Back to app"}),l.jsx("kbd",{className:"set-nav-esc",children:"esc"})]}),l.jsxs("label",{className:"set-search",children:[l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("circle",{cx:"10.5",cy:"10.5",r:"6"}),l.jsx("path",{d:"m15 15 4.5 4.5"})]}),l.jsx("input",{ref:W,type:"text",value:Y,placeholder:"Search","aria-label":"Search settings",spellCheck:!1,onChange:I=>se(I.target.value),onKeyDown:Q})]})]}),l.jsx("div",{className:"set-nav-scroll",children:Y.trim()?Ce.length?Ce.map((I,V)=>l.jsxs("button",{type:"button",className:`set-nav-item set-hit${V===re?" on":""}`,onMouseEnter:()=>T(V),onClick:()=>ne(I),children:[l.jsx("span",{className:"set-hit-label",children:I.label}),l.jsx("span",{className:"set-hit-page",children:I.pageLabel})]},`${I.page}:${I.label}`)):l.jsxs("div",{className:"set-nav-empty",children:["Nothing matches “",Y.trim(),"”."]}):["Personal","Agents","Workspace"].map(I=>l.jsxs(g.Fragment,{children:[l.jsx("div",{className:"set-nav-group",children:I}),Z.filter(V=>V.group===I).map(V=>l.jsxs(g.Fragment,{children:[l.jsxs("button",{type:"button",className:`set-nav-item ${he(V.id)?"on":""}`,"aria-current":he(V.id)?"page":void 0,onClick:()=>R(V.id),children:[l.jsx("span",{className:"set-nav-ico",children:l.jsx(Qae,{id:V.id})}),l.jsx("span",{className:"set-nav-label",children:V.label})]}),V.id==="projects"&&F&&l.jsxs("button",{type:"button",className:"set-nav-item set-nav-sub on",onClick:()=>R({project:F.slug}),children:[l.jsx("span",{className:"set-nav-ico",children:l.jsx(Lk,{src:F.logo,name:F.name,slug:F.slug,size:14})}),l.jsx("span",{className:"set-nav-label",children:F.name})]})]},V.id))]},I))})]}),l.jsxs("div",{className:"set-pane",ref:Ie,children:[M==="instructions"&&l.jsx(rae,{projects:K,scope:z,onScope:xe,onSaved:_}),L&&L!==Nn&&M!=="shortcuts"&&M!=="team"&&l.jsx("div",{className:"set-error",children:L}),!N&&M!=="shortcuts"&&M!=="instructions"&&M!=="team"&&l.jsx("div",{className:"set-inner",children:l.jsx("div",{className:"set-lede",children:"Reading settings…"})}),M==="team"&&w&&l.jsx(xo,{title:"Team",lede:"Who is on your team, who has been invited, and the team's name. Everyone sees a short summary of your threads unless you mark one private.",children:w}),N&&M==="projects"&&l.jsx("div",{className:"set-inner",children:l.jsx(kae,{ranked:p,details:K,onSetOrder:m,who:x,onOpen:I=>R({project:I}),onNew:f,archived:(N==null?void 0:N.archivedProjects)??[],onUnarchive:I=>ge(q.archiveProject({product:I,archived:!1})),onArchive:async I=>{for(const V of I)await ge(q.archiveProject({product:V,archived:!0}))}})}),N&&J&&M==="general"&&l.jsxs(xo,{title:"General",children:[l.jsx(Lt,{id:"keys",label:"Keyboard",children:l.jsx(ut,{label:"Show keyboard shortcut hints",desc:"Point at something and its keys appear beside it. Off, every key still works.",children:l.jsx(ri,{label:"Show keyboard shortcut hints",on:o,onChange:i})})}),l.jsx(Lt,{id:"corner-tag",label:"While you're in other apps",children:l.jsx(ut,{label:"Show what's ready in the corner",desc:"A small tag over your other apps says when an agent has something for you. Drag it anywhere. Hide it for a while from the tag itself.",children:l.jsx(ri,{label:"Show what's ready in the corner",on:J.cornerTag!==!1,onChange:I=>E("cornerTag",I)})})}),l.jsx(Lt,{id:"privacy",label:`What ${Je} sends`,children:l.jsx(ut,{label:"Counts and crash reports",desc:`That ${Je} was opened, that a task was opened, that a reply was sent, and a report when something breaks. Never your code, your prompts, your keys or your paths, and never a title.`,children:l.jsx(ri,{label:"Counts and crash reports",on:J.diagnostics,onChange:I=>E("diagnostics",I)})})}),l.jsx(Lt,{id:"storage",label:`Where ${Je} keeps things on this computer`,children:l.jsx(ut,{label:"Your projects, tasks and documents",desc:J.storePath})}),l.jsx(Gae,{state:S}),v&&l.jsx(Lt,{id:"account",label:"Account",children:l.jsx(ut,{label:`Signed in as ${v.email}`,desc:v.team?`On the ${v.team} team.`:void 0,children:l.jsx("button",{type:"button",className:"set-ghost",onClick:v.onSignOut,children:"Sign out"})})})]}),N&&J&&M==="claude"&&te("claude"),N&&J&&M==="codex"&&J.codex&&te("codex"),N&&J&&M==="running"&&l.jsxs(xo,{title:"Running",children:[l.jsx(Lae,{running:J.running,capacity:J.agentsTotal??J.capacity,gate:J.memoryGate}),l.jsxs(Lt,{id:"at-once",label:"Agents",children:[l.jsx(ut,{label:"How many run at once",desc:J.sessionsAtOnceFromPlan?`Your plan is ${J.sessionsAtOnceFromPlan}, so ${Je} starts one ${ye?"Claude Code agent ":""}at a time.`:J.agentsAuto?"From this computer’s memory, kept there as you add accounts or turn the memory check on.":`You set this. Automatic would run ${J.agentsAutoTotal??J.sessionsAtOnce} on this computer.`,children:l.jsx(gl,{label:"How many run at once",value:J.agentsAuto?"auto":String(J.sessionsAtOnce),options:Oae(J),onChange:I=>I==="auto"?E("agentsAuto",!0):E("sessionsAtOnce",Number(I))})}),J.memoryGate&&l.jsx(ut,{label:"Hold heavy work when memory is short",desc:`Tests and builds take turns, urgent first, and new agents wait to start until memory frees up.${ye?" Claude Code and Codex both.":""}`,children:l.jsx(ri,{label:"Hold heavy work when memory is short",on:J.memoryGate.on,onChange:I=>E("memoryGate",I)})}),((ee=J.memoryGate)==null?void 0:ee.on)&&!J.agentsAuto&&l.jsx(ut,{label:"Heavy commands at once",desc:J.memoryGate.slots===null?`Auto: ${J.memoryGate.slotsAuto} on this computer, one for every 8 GB of memory.`:`You picked ${J.memoryGate.slots}. Auto is ${J.memoryGate.slotsAuto} on this computer.`,children:l.jsx(Cae,{label:"Heavy commands at once",value:J.memoryGate.slots??J.memoryGate.slotsAuto,min:1,max:J.memoryGate.slotsMax,onChange:I=>{var V;return E("memoryGateSlots",I===((V=J.memoryGate)==null?void 0:V.slotsAuto)?null:I)}})}),J.leftovers&&l.jsx(ut,{label:"Stop programs agents leave behind",desc:`Dev servers, previews and test runs an agent started and left running are stopped two hours after its run ends, or ten minutes while memory is short. Never stopped: anything you started yourself, apps installed on this computer, and what an agent was asked to keep.${ye?" Codex agents’ programs are not found yet.":""}${J.leftovers.now?` ${J.leftovers.now}`:""}`,children:l.jsx(ri,{label:"Stop programs agents leave behind",on:J.leftovers.on,onChange:I=>E("cleanupLeftovers",I)})}),J.strayFolders&&l.jsx(ut,{label:"Copies of a project made by hand",desc:J.strayFolders.now}),J.agentsAuto&&l.jsxs(ut,{label:"Something felt slow",desc:J.agentsNudge?`${Je} is running ${J.agentsNudge} fewer than this computer suggests.`:`${Je} runs one fewer from now on, and remembers that it did.`,children:[!!J.agentsNudge&&l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>E("agentsFeltSlow","reset"),children:"Undo"}),l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>E("agentsFeltSlow",!0),children:"Tell it"})]})]}),l.jsx(Lt,{id:"outside",label:"Agents you started yourself",children:l.jsx(ut,{label:"Show in your inbox",desc:`Claude Code started in a terminal, not from here. ${Hae[J.outsideAgents]}`,children:l.jsx(gl,{bare:!0,label:"Agents you started yourself",value:J.outsideAgents,options:Wae,onChange:I=>E("outsideAgents",I)})})})]}),N&&M==="appearance"&&l.jsxs(xo,{title:"Appearance",children:[l.jsx(Lt,{id:"theme",label:"Theme",children:l.jsx("div",{className:"look-row",children:iae.map(I=>l.jsxs("button",{className:`look${e===I.id?" on":""}`,"aria-pressed":e===I.id,onPointerEnter:()=>void jy(Lu(I.id).skin),onFocus:()=>void jy(Lu(I.id).skin),onClick:()=>t(I.id),children:[l.jsxs("span",{className:`look-swatch ${I.id}`,"aria-hidden":"true",children:[I.id==="match"&&l.jsx(hae,{}),l.jsx("span",{className:"look-tick","aria-hidden":"true",children:l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 11 11",fill:"none",children:l.jsx("path",{d:"M1.6 5.7 4.2 8.3 9.4 2.7",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),l.jsx("span",{className:"look-name",children:I.name})]},I.id))})}),Nae(e)&&e!=="ember-grid"&&l.jsxs(Lt,{id:"tune",label:Eae(e),children:[yr[e].panelOpacity!==void 0&&l.jsx(sh,{label:e==="orbital-glass"?"Panel tint":"Panel whiteness",desc:"Reduce the tint to let more of the background show through.",value:n.panelOpacity??yr[e].panelOpacity,...di.panelOpacity,format:I=>`${Math.round(I*100)}%`,onChange:I=>r({...n,panelOpacity:I})}),l.jsx(sh,{label:"Foreground blur",desc:"Softens the glass behind your tasks.",value:n.blur,...di.blur,format:I=>I===0?"none":`${I}px`,onChange:I=>r({...n,blur:I})}),l.jsx(sh,{label:"Background blur",desc:"Softens the whole backdrop, including behind the sidebar.",value:n.backgroundBlur??0,...di.backgroundBlur,format:I=>`${I}px`,onChange:I=>r({...n,backgroundBlur:I})}),l.jsx(sh,{label:"Darkness",desc:"How far the picture is turned down under the app.",value:n.dim,...di.dim,format:I=>`${Math.round(I*100)}%`,onChange:I=>r({...n,dim:I})}),l.jsx(ut,{label:"What it shipped with",desc:`Foreground blur ${yr[e].blur}px, background blur ${yr[e].backgroundBlur??0}px, darkness ${Math.round(yr[e].dim*100)}%${yr[e].panelOpacity!==void 0?`, panel whiteness ${Math.round(yr[e].panelOpacity*100)}%`:""}.`,children:l.jsx("button",{type:"button",className:"set-ghost",disabled:n.panelOpacity===yr[e].panelOpacity&&(n.backgroundBlur??0)===(yr[e].backgroundBlur??0)&&n.blur===yr[e].blur&&n.dim===yr[e].dim,onClick:s,children:"Put it back"})})]})]}),M==="phone"&&l.jsx(zae,{onFeedback:O}),M==="shortcuts"&&l.jsxs("div",{className:"set-inner set-keys-page",children:[l.jsx("h1",{className:"set-title",children:"Shortcuts"}),l.jsx("div",{className:"set-keys-grid",children:fae.map(I=>l.jsxs("div",{className:"set-group",children:[l.jsx("div",{className:"set-group-label",children:I.label}),l.jsx("div",{className:"set-plate set-keys",children:I.keys.map(V=>l.jsx(Fae,{...V},V.keys.join("+")))})]},I.label))})]}),N&&F&&l.jsxs("div",{className:"set-inner",children:[l.jsxs("button",{type:"button",className:"set-crumb",onClick:()=>R("projects"),children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5"})}),l.jsx("span",{children:"Projects"})]}),l.jsxs("div",{className:"set-title-row",children:[l.jsx(Jae,{project:F,onPick:()=>ge(q.pickProjectIcon({product:F.slug})),onClear:()=>ge(q.clearProjectIcon({product:F.slug}))}),l.jsx(Xae,{project:F,onRename:I=>ge(q.renameProject({product:F.slug,name:I}))}),b==null?void 0:b(F.slug)]}),l.jsxs(Lt,{label:"How it runs",children:[l.jsx(ut,{label:"Let agents start the tasks they file here",desc:"A task an agent writes on this project gets a session straight away. Without this it waits in your inbox for your yes. Questions and reviews always wait for you either way.",children:l.jsx(ri,{label:"Let agents start the tasks they file here",on:F.autonomous,onChange:I=>me(F.slug,"autonomous",I)})}),(((J==null?void 0:J.accounts)??[]).length>1||(F.account??"any")!=="any")&&l.jsx(ut,{label:"Claude account",desc:"Every Claude Code agent on this project runs on this account and on no other. If the account cannot run, the work waits.",children:l.jsx(gl,{bare:!0,label:"Claude account",title:"The Claude account this project's agents run on.",value:F.account??"any",options:[{value:"any",label:"Any account"},...((J==null?void 0:J.accounts)??[]).map(I=>({value:I.profile,label:I.email?`${I.email} (${I.label})`:I.label}))],onChange:I=>me(F.slug,"account",I)})}),F.permission!=="workspace"&&l.jsx(ut,{label:ye?"This project has its own Claude Code permissions":"This project has its own permissions",desc:F.permission==="custom"?oh.custom:`${oh[F.permission]} ${pw}`,children:l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>me(F.slug,"permission","workspace"),children:"Use the workspace setting"})}),ye&&F.codexMode!=="workspace"&&l.jsx(ut,{label:"This project has its own Codex permissions",desc:((U=Oh[F.codexMode])==null?void 0:U.what)??"",children:l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>me(F.slug,"codexMode","workspace"),children:"Use the workspace setting"})})]}),l.jsx(Lt,{label:"Instructions",children:l.jsx(ut,{label:"Instructions for this project",desc:F.instructions.trim()?Sb(F.instructions.length):"None yet.",children:l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>Oe(F.slug),children:"Open"})})}),l.jsxs(Lt,{label:"Where this project is kept on this computer",children:[l.jsx(ut,{label:"Documents",desc:F.dir}),l.jsx(ut,{label:"Repository",desc:F.repoPath??"No code repo registered for this project."})]}),l.jsx(Lt,{label:"Archive",children:l.jsx(ut,{label:"Archive this project",desc:`It leaves your inbox, the sidebar and Projects, and no new agents start on it${F.running?"; the ones running now finish":""}. Its files stay where they are, and you can bring it back from Projects.`,children:l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>ge(q.archiveProject({product:F.slug,archived:!0})),children:"Archive"})})})]})]})]})}function tle(e,t,n,r,s){return e.trim()?t?{text:r(t.value),tone:"ok"}:n?{text:`not a time · ${s}`,tone:"refused"}:{text:"not a time",tone:"unread"}:null}function nle({title:e,subtitle:t,placeholder:n,hintWhenRefused:r,options:s,parse:o,previewOf:i,onChoose:a,onClose:c}){const[u,d]=g.useState(""),[h,f]=g.useState(0),[p,m]=g.useState(!1),w=g.useRef(null),b=o(u),x=tle(u,b,p,i,r);g.useEffect(()=>{var S;return(S=w.current)==null?void 0:S.focus()},[]);const v=()=>{const S=Iz(u,b);if(S==="typed"&&b)a(b.value,b.label);else if(S==="selected"){const C=s[h];C&&a(C.value,C.label.toLowerCase())}else m(!0)};return l.jsx("div",{className:"modal-backdrop",onClick:S=>{S.stopPropagation(),c()},children:l.jsxs("div",{className:"modal snooze",onClick:S=>S.stopPropagation(),children:[l.jsx("div",{className:"modal-title",children:e}),t&&l.jsx("div",{className:"modal-subtitle",children:t}),l.jsxs("div",{className:"snooze-input-row",children:[l.jsx("input",{ref:w,className:"palette-input snooze-input",value:u,placeholder:n,onChange:S=>{d(S.target.value),m(!1)},onKeyDown:S=>{S.stopPropagation(),S.key==="Escape"&&c(),S.key==="Enter"&&v(),S.key==="ArrowDown"&&(S.preventDefault(),f(C=>Math.min(C+1,s.length-1))),S.key==="ArrowUp"&&(S.preventDefault(),f(C=>Math.max(0,C-1)))}}),x&&l.jsx("span",{className:`snooze-preview ${x.tone==="ok"?"":x.tone==="refused"?"invalid refused":"invalid"}`,children:x.text})]}),l.jsx("div",{className:"palette-list",children:s.map((S,C)=>l.jsxs("div",{className:`palette-item ${!u&&C===h?"selected":""}`,onClick:()=>a(S.value,S.label.toLowerCase()),onMouseMove:()=>f(C),children:[l.jsx("span",{children:S.label}),l.jsx("span",{className:"palette-hint",children:S.hint??""})]},S.label))})]})})}function rle(e=Date.now()){const t=[];t.push({label:"In 30 minutes",ts:e+30*6e4}),t.push({label:"In 4 hours",ts:e+4*36e5});const n=new Date(e);n.setHours(18,0,0,0),n.getTime()>e&&t.push({label:"This evening",ts:n.getTime()});const r=new Date(e+864e5);r.setHours(8,0,0,0),t.push({label:"Tomorrow",ts:r.getTime()});const s=new Date(e);return s.setDate(s.getDate()+((1-s.getDay()+7)%7||7)),s.setHours(8,0,0,0),t.push({label:"Next week",ts:s.getTime()}),t}const SE=e=>new Date(e).toLocaleString(void 0,{weekday:"short",hour:"numeric",minute:"2-digit"}).toUpperCase();function sle({item:e,count:t=1,onPick:n,onNow:r,onClose:s}){const o=g.useMemo(()=>{const i=rle();return r?[{label:"Now (back to inbox)",ts:0,now:!0},...i]:i},[r]);return l.jsx(nle,{title:"Later",subtitle:hF(e,t),placeholder:"Try: 30m, 3h, 8am, tomorrow, next week",hintWhenRefused:"try 3h, 8am, tomorrow",options:o.map(i=>({label:i.label,value:i.ts,hint:i.now?"":SE(i.ts)})),parse:i=>{const a=ap(i);return a?{value:a.ts,label:a.label}:null},previewOf:i=>SE(i),onChoose:(i,a)=>{i===0&&r?r():n(i,a)},onClose:s})}function ole(e,t,n){const r=Array.isArray(e)?e.filter(Boolean):[],s=t?r.find(i=>i.id===t.id)??((n==null?void 0:n.id)===t.id?n:null):null;if(s)return{card:s,verdict:t.allow?"allow":"deny",waiting:r.filter(i=>i.id!==s.id).length};const o=r[0]??null;return{card:o,verdict:null,waiting:o?r.length-1:0}}const jE=`${st} could not read what this asks for.`;function ile(e,t){const n=/^mcp__(.+)__(.+)$/.exec(t??"");if(n){const s=`${n[1]} / ${n[2]}`;let o=jE;if(e&&typeof e=="object"&&!Array.isArray(e))try{const i=Object.entries(e).map(([a,c])=>{const u=JSON.stringify(c,null,2);if(u===void 0)throw new Error("Unreadable argument");return`${a}: ${u}`});o=i.length?i.join(`
|
|
1115
|
+
|
|
1116
|
+
`):"No arguments."}catch{}return{what:"asks to use",body:`${s}
|
|
1117
|
+
|
|
1118
|
+
${o}`}}const r=e??{};return typeof r.changes=="string"&&r.changes?{what:"asks to change",body:r.changes}:typeof r.command=="string"?{what:"asks to run",body:r.command}:typeof r.host=="string"&&r.host?{what:"asks to reach",body:r.host}:typeof r.file_path=="string"?{what:"asks to run",body:r.file_path}:{what:"asks to run",body:jE}}const ale=new Set(["r","l","c","n","/"]);function lle(e){return ale.has(e.toLowerCase())}const cle=new Set(["reply"]);function ule(e){return e&&cle.has(e)?null:e}const rL={modal:null,settings:!1,importAgents:!1,newProject:!1,teamShown:!1,setupPlan:!1};function dle(e){return rL}const CE=new WeakMap;function Eb(e,t){let n=CE.get(t);n||(n=new WeakMap,CE.set(t,n));const r=n.get(e);if(r)return r;const s=t.products.find(h=>h.slug===e.product),o=Us(s),i=o?Xb(e,s,t.me,h=>{var f;return((f=t.people.find(p=>p.id===h))==null?void 0:f.name.split(" ")[0])||"Someone"}):null,a=((i==null?void 0:i.people)??[]).map(h=>{var f;return(f=t.people.find(p=>p.id===h))==null?void 0:f.name}).filter(Boolean).join(" . "),c=e.talk?[...e.talk.chat.map(h=>h.text),...Object.values(e.talk.threads).flatMap(h=>[h.text,...h.replies.map(f=>f.text)])]:[],d={searchable:o?{...e,label:[a,e.label].filter(Boolean).join(" . "),body:[e.body,...c].filter(Boolean).join(" . ")}:e,names:a,people:(i==null?void 0:i.people)??[],latest:(i==null?void 0:i.text)??"",chat:o};return n.set(e,d),d}function hle(e,t,n){const r=new Map,s=e.map(i=>{const{searchable:a}=Eb(i,n);return r.set(a,i),a}),o=cp(t);return lB(s,t).map(i=>{const a=r.get(i.item),{names:c,latest:u,chat:d}=Eb(a,n),h=!!c&&C1({id:a.id,title:c},t)>0,f=d?E1(Cc(i.item.body),o.terms,o.phrase):"",p=d?E1([a.label,a.title].filter(Boolean).join(" . "),o.terms,o.phrase):"",m=C1({id:a.id,title:[a.label,a.title].filter(Boolean).join(" . ")},t)>=2;return{item:a,summary:d&&((m?p:f)||p||u)||i.summary,named:h}}).sort((i,a)=>Number(a.named)-Number(i.named)).map(({item:i,summary:a})=>({item:i,summary:a}))}function fle(e,t){const{chat:n,names:r,people:s}=Eb(e,t);return{title:n?r.replace(/ \. /g,", ")||"Conversation":e.label||e.title,kind:n?"chat":"agent",people:s}}const ple=700;function mle(e,t={}){const n=t.wait??ple;let r;const s=()=>{r&&clearTimeout(r),r=void 0};return{point(o){s(),e(null),o!==null&&(r=setTimeout(()=>{r=void 0,e(o)},n))},stop(){s(),e(null)}}}function gle({lines:e,comp:t,align:n,text:r}){const s=g.useRef(null),[o,i]=g.useState(null);return g.useLayoutEffect(()=>{const a=s.current;if(!a)return;const c=a.getBoundingClientRect(),u=getComputedStyle(a),d=parseFloat(u.paddingLeft||"0")+parseFloat(u.borderLeftWidth||"0");i(mae(t,{width:c.width,height:c.height},{width:window.innerWidth,height:window.innerHeight},n??"left",r?{left:r.left}:void 0,d))},[t,r,n,e]),l.jsx("div",{ref:s,className:"hint-plate","aria-hidden":"true",style:o?{top:o.top,left:o.left}:{top:0,left:0,opacity:0,visibility:"hidden"},children:e.map(a=>l.jsxs("div",{className:"hint-line",children:[l.jsx("span",{className:"hint-caps",children:pae(a.key).map((c,u)=>l.jsxs("kbd",{children:[c,tp(c)&&l.jsx("span",{className:"fr-cap-word",children:tp(c)})]},`${c}-${u}`))}),l.jsx("span",{className:"hint-what",children:a.what})]},a.key))})}const yle=[{id:"plain",label:"Nothing up there",note:"A 34 point strip with nothing in it, and the task starts under it. This is what is on the branch now."},{id:"line",label:"The row’s own line up top",note:"The product, the kind and the age move up into the strip, and the line under the title goes. The title starts 23 points higher."},{id:"edge",label:"No strip at all",note:"The task begins at the very top of the window. You can still drag the window by the same band, it is just not drawn."},{id:"card",label:"The task on a card",note:"The same 3 point corner and 22 point padding the inbox card has, so the task is an object on the ground rather than the window."},{id:"wide",label:"The words take the width",note:"The reading column goes from 780 to 980 points and centres in the space it actually has."},{id:"header",label:"A real header",note:"A 56 point band carrying the title and the age, and the big title in the body goes. The header stays while you scroll."}],sL="zero.taskShape",wle="data-task-shape",ble="plain";function oL(e){return yle.some(t=>t.id===e)?e:ble}function xle(e,t=document.documentElement){t.setAttribute(wle,e)}function iL(){return l.jsxs("svg",{className:"compose-glyph",width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M4.5 8h8M16.5 8h3M4.5 16h3M11.5 16h8"}),l.jsx("circle",{cx:"14.5",cy:"8",r:"2"}),l.jsx("circle",{cx:"9.5",cy:"16",r:"2"})]})}function aL({view:e}){return l.jsxs("svg",{className:"workspace-nav-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e==="inbox"&&l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M4.5 13.2 6.7 6.4A2 2 0 0 1 8.6 5h6.8a2 2 0 0 1 1.9 1.4l2.2 6.8V17a2 2 0 0 1-2 2h-11a2 2 0 0 1-2-2z"}),l.jsx("path",{d:"M4.5 13.2h4.1l1.1 2.1h4.6l1.1-2.1h4.1"})]}),e==="snoozed"&&l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"4.5",y:"5.5",width:"15",height:"14",rx:"3"}),l.jsx("path",{d:"M8.5 3.8V7M15.5 3.8V7M4.5 10h15"}),l.jsx("circle",{cx:"15.2",cy:"15",r:"1.1",fill:"currentColor",stroke:"none"})]}),e==="progress"&&l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M12 4.5a7.5 7.5 0 1 1-7.5 7.5"}),l.jsx("path",{d:"M4.5 12A7.5 7.5 0 0 1 12 4.5",opacity:".3"})]}),e==="done"&&l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"4.5",y:"10",width:"15",height:"9.5",rx:"2"}),l.jsx("path",{d:"M6.5 7h11M8.5 4.5h7"})]})]})}function NE(e){return l.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("rect",{x:"3.8",y:"5",width:"16.4",height:"14",rx:"3.2"}),l.jsx("path",{d:"M9.6 5v14"})]})}const kle=""+new URL("agentbox-icon-F1oN9nj_.svg",import.meta.url).href;function vi({size:e=24,title:t}){return l.jsx("img",{className:"product-mark app-mark",src:kle,width:e,height:e,alt:t??"","aria-hidden":t?void 0:!0,draggable:!1})}const ps={title:"New version ready",installing:"Updating",how:"Restarting takes about a minute.",changed:"What changed:",close:"Close",closeTip:"Hide until the next version",moveCloseTip:"Hide it · Settings still offers it"};function vle({place:e,error:t=null,collapsed:n,onMove:r,onClose:s}){const o=t?`${t.replace(/\.?$/,".")} ${An.retry}`:mA(e,{short:!0})??An.cannotUpdateHere;return n?l.jsxs("button",{type:"button",className:"sb-update-row",title:`${An.button}. ${o}`,"aria-label":An.button,onClick:r,children:[l.jsx(EE,{}),l.jsx("span",{children:An.button})]}):l.jsxs("div",{className:"sb-update-card",children:[l.jsxs("div",{className:"sb-update-card-title",children:[l.jsx(EE,{}),l.jsx("span",{children:An.title})]}),l.jsx("button",{type:"button",className:"sb-update-close","aria-label":ps.close,title:ps.moveCloseTip,onClick:s,children:l.jsx(lL,{})}),l.jsx("p",{children:o}),l.jsx("button",{type:"button",className:"sb-update-go",onClick:r,children:An.button})]})}function EE(){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("path",{d:"M4 14v5a1.5 1.5 0 0 0 1.5 1.5h13A1.5 1.5 0 0 0 20 19v-5"}),l.jsx("path",{d:"M12 3.5v10"}),l.jsx("path",{d:"M8.5 10 12 13.5 15.5 10"})]})}function AE(){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:[l.jsx("path",{d:"M19.5 12a7.5 7.5 0 1 1-2.2-5.3"}),l.jsx("path",{d:"M19.5 4.5v4h-4"})]})}function lL(){return l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:l.jsx("path",{d:"M7 7l10 10M17 7L7 17"})})}function Sle({installing:e,changes:t=[],error:n=null,collapsed:r,onRestart:s,onClose:o}){const i=t.length?`${ps.changed}
|
|
1119
|
+
${t.map(a=>`- ${a}`).join(`
|
|
1120
|
+
`)}`:"";if(r){const a=e?Xi.installing:[n?`${n.replace(/\.?$/,".")} Pressing it again tries again.`:`${Xi.restart}. ${ps.how}`,i].filter(Boolean).join(`
|
|
1121
|
+
|
|
1122
|
+
`);return l.jsxs("button",{type:"button",className:"sb-update-row","data-installing":e||void 0,disabled:e,title:a,"aria-label":e?ps.installing:Xi.restart,onClick:s,children:[l.jsx(AE,{}),l.jsx("span",{children:e?ps.installing:Xi.restart})]})}return l.jsxs("div",{className:"sb-update-card","data-installing":e||void 0,title:i||void 0,children:[l.jsxs("div",{className:"sb-update-card-title",children:[l.jsx(AE,{}),l.jsx("span",{children:e?ps.installing:ps.title})]}),!e&&l.jsx("button",{type:"button",className:"sb-update-close","aria-label":ps.close,title:ps.closeTip,onClick:o,children:l.jsx(lL,{})}),l.jsx("p",{children:e?`${Je} restarts by itself in about a minute.`:n?`${n.replace(/\.?$/,".")} Pressing it again tries again.`:ps.how}),!e&&l.jsx("button",{type:"button",className:"sb-update-go",onClick:s,children:Xi.restart})]})}const Ab=80;function jle(e){const t=String(e??"").replace(/\s+/g," ").trim();return t?t.slice(0,Ab):null}function Cle(e,t=Date.now()){const n=jle(e==null?void 0:e.text);if(!n)return null;const r=(e==null?void 0:e.until)??null;return r&&r<=t?null:{text:n,until:r}}function Pk(e,t=Date.now()){if(!e||e<=t)return"";const n=new Date(e);if(new Date(t).toDateString()===n.toDateString()){const r=n.getHours(),s=n.getMinutes()?`:${String(n.getMinutes()).padStart(2,"0")}`:"";return`until ${r%12===0?12:r%12}${s}${r<12?"am":"pm"} today`}return e-t<7*864e5?`until ${n.toLocaleDateString(void 0,{weekday:"long"})}`:`until ${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`}function Nle(e,t=Date.now()){if(e==="open")return null;const n=new Date(t);if(n.setHours(23,59,59,999),e==="tomorrow"&&n.setDate(n.getDate()+1),e==="week"){const r=(7-n.getDay())%7;n.setDate(n.getDate()+(r||7))}return n.getTime()}const zk=[{hold:"today",words:"the end of today"},{hold:"tomorrow",words:"tomorrow night"},{hold:"week",words:"the end of the week"},{hold:"open",words:"I clear it"}];function Ele(e,t=Date.now()){const n=ap((e??"").trim(),t);return!n||!(n.ts>t)?null:{until:n.ts,label:n.label}}function Ale(e,t=Date.now()){var n;return e.until!==void 0?Pk(e.until,t).replace(/^until /,"")||"I clear it":((n=zk.find(r=>r.hold===e.hold))==null?void 0:n.words)??"the end of today"}function Tle(e,t=Date.now()){if(!e)return{hold:"today"};if(e.until===null)return{hold:"open"};const n=zk.find(r=>r.hold!=="open"&&Nle(r.hold,t)===e.until);return n?{hold:n.hold}:{until:e.until}}const Fk=(e,t)=>Cle(e==null?void 0:e.status,t),cL="Set a status";function Mle({person:e,me:t,now:n}){const r=Fk(e,n),s=Pk(r==null?void 0:r.until,n);return l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tm-face-card-who",children:t?"You":e.name}),r?l.jsxs("span",{className:"tm-face-card-said",children:[r.text,s&&l.jsx("span",{className:"tm-status-held",children:s})]}):l.jsx("span",{className:"tm-face-card-said nothing",children:t?cL:"Nothing said"})]})}function Rle({person:e,me:t,now:n,children:r}){const[s,o]=g.useState(null),i=g.useRef(null),a=()=>{var d;const c=(d=i.current)==null?void 0:d.getBoundingClientRect();if(!c)return;const u=c.bottom+8;o({left:Math.round(c.left),top:Math.round(u+120>window.innerHeight?c.top-8-120:u)})};return e?l.jsxs("span",{className:"tm-face-hover",ref:i,onMouseEnter:a,onMouseLeave:()=>o(null),children:[r,s&&bs.createPortal(l.jsx("span",{className:"tm-face-card",style:{left:s.left,top:s.top},children:l.jsx(Mle,{person:e,me:t,now:n})}),document.body)]}):l.jsx(l.Fragment,{children:r})}function Ile({person:e,now:t,onDone:n}){const r=Fk(e,t),[s,o]=g.useState((r==null?void 0:r.text)??""),[i,a]=g.useState(()=>Tle(r,t)),[c,u]=g.useState(!1),[d,h]=g.useState(!1),[f,p]=g.useState(null),m=g.useRef(null);g.useEffect(()=>{const x=m.current;if(!x)return;x.textContent=(r==null?void 0:r.text)??"",x.focus();const v=document.createRange();v.selectNodeContents(x),v.collapse(!1);const S=window.getSelection();S==null||S.removeAllRanges(),S==null||S.addRange(v)},[]);const w=x=>{const v=(x.textContent??"").replace(/\s+/g," ");if(v.length<=Ab){o(v);return}x.textContent=v.slice(0,Ab);const S=document.createRange();S.selectNodeContents(x),S.collapse(!1);const C=window.getSelection();C==null||C.removeAllRanges(),C==null||C.addRange(S),o(x.textContent)},b=async(x=!1)=>{if(d)return;h(!0),p(null);const v=await q.teamStatus(x?{text:"",hold:"open"}:{text:s,hold:i.hold??"open",...i.until!==void 0?{until:i.until}:{}});h(!1),v.ok?n():p(v.error??"That did not save.")};return l.jsxs("div",{className:"tm-status-write",children:[l.jsxs("div",{className:"tm-status-sentence",children:["I'm ",l.jsx("span",{ref:m,className:"tm-status-what",contentEditable:"plaintext-only",suppressContentEditableWarning:!0,role:"textbox","aria-label":"What you are up to","data-placeholder":"in meetings",spellCheck:!1,onInput:x=>w(x.currentTarget),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),b())}})," until ",l.jsxs("span",{className:"when-wrap tm-status-until",children:[l.jsx("button",{type:"button",className:`compose-word${c?" open":""}`,"aria-haspopup":"menu","aria-expanded":c,onClick:()=>u(!c),children:Ale(i,t)}),c&&l.jsx(Dle,{end:i,now:t,onClose:()=>u(!1),onPick:x=>{var v;a(x),u(!1),(v=m.current)==null||v.focus()}})]}),"."]}),l.jsxs("div",{className:"tm-status-keys",children:[l.jsxs("span",{children:[l.jsx("kbd",{children:"↵"})," save"]}),l.jsxs("span",{children:[l.jsx("kbd",{children:"esc"})," cancel"]}),r&&l.jsx("button",{type:"button",className:"tm-status-clear",disabled:d,onClick:()=>void b(!0),children:"Clear status"})]}),f&&l.jsx("div",{className:"tm-status-error",children:f})]})}const TE=e=>e&&e[0].toUpperCase()+e.slice(1);function Dle({end:e,now:t,onPick:n,onClose:r}){const[s,o]=g.useState(""),i=g.useRef(null);g.useEffect(()=>{var d;(d=i.current)==null||d.focus()},[]);const a=s.trim(),c=Ele(a,t),u=zk.filter(d=>!a||d.words.toLowerCase().includes(a.toLowerCase()));return l.jsxs("span",{className:"when-menu",role:"menu","aria-label":"When it ends",children:[c&&l.jsxs("button",{type:"button",role:"menuitem",className:"when-row",onClick:()=>n({until:c.until}),children:[l.jsx("span",{className:"when-row-label",children:TE(a)}),l.jsx("span",{className:"when-row-hint",children:c.label})]}),u.map(d=>l.jsx("button",{type:"button",role:"menuitem",className:`when-row${e.hold===d.hold?" on":""}`,onClick:()=>n({hold:d.hold}),children:l.jsx("span",{className:"when-row-label",children:TE(d.words)})},d.hold)),a&&!c&&!u.length&&l.jsx("span",{className:"when-row empty",children:l.jsx("span",{className:"when-row-label",children:"not a time"})}),l.jsx("span",{className:"when-type-row",children:l.jsx("input",{ref:i,className:"when-type",value:s,placeholder:"or type: friday 5pm, in 3 days, oct 12","aria-label":"Any time",onChange:d=>o(d.target.value),onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),r()),d.key==="Enter"&&(d.preventDefault(),d.stopPropagation(),c?n({until:c.until}):a&&u[0]&&n({hold:u[0].hold}))}})})]})}const Ole=()=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[l.jsx("circle",{cx:"10",cy:"8.5",r:"3.5"}),l.jsx("path",{d:"M3.5 20c.7-3.4 3.3-5.3 6.5-5.3 1.4 0 2.6.3 3.7.9"}),l.jsx("path",{d:"M18 14v6M15 17h6"})]}),Lle=()=>l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M14 4h4.5v16H14M10 8l-4 4 4 4M6 12h10"})}),$le=()=>l.jsxs("svg",{className:"th-acct-smile",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"8"}),l.jsx("path",{d:"M8.8 14c.8 1.1 1.9 1.7 3.2 1.7s2.4-.6 3.2-1.7"}),l.jsx("path",{d:"M9.5 10h.01M14.5 10h.01",strokeWidth:"2"})]});function Ple({me:e,now:t,collapsed:n,onAccount:r,onInvite:s,onSettings:o,onSignOut:i}){const[a,c]=g.useState(!1),[u,d]=g.useState(!1),h=g.useRef(null),f=()=>{c(!1),d(!1)};g.useEffect(()=>{if(!a)return;const m=b=>{var x;(x=h.current)!=null&&x.contains(b.target)||f()},w=b=>{b.key==="Escape"&&(b.stopPropagation(),f())};return document.addEventListener("pointerdown",m,!0),document.addEventListener("keydown",w),()=>{document.removeEventListener("pointerdown",m,!0),document.removeEventListener("keydown",w)}},[a]);const p=m=>m&&(()=>{f(),m()});return l.jsxs("div",{className:"th-me-wrap",ref:h,children:[l.jsxs("button",{type:"button",className:"th-me-btn","aria-label":"Your account","aria-haspopup":"menu","aria-expanded":a,title:n?"Your account":void 0,onClick:()=>a?f():c(!0),children:[l.jsx(Rt,{person:e,me:!0}),l.jsxs("span",{children:[e.name||e.email,l.jsx("small",{children:e.email})]})]}),a&&(u?l.jsx("div",{className:"th-me-pop",children:l.jsx(Ile,{person:e,now:t,onDone:f})}):l.jsx(zle,{me:e,now:t,onStatus:()=>d(!0),onAccount:p(r),onInvite:p(s),onSettings:p(o),onSignOut:p(i)}))]})}function zle({me:e,now:t,onStatus:n,onAccount:r,onInvite:s,onSettings:o,onSignOut:i}){const a=Fk(e,t),c=Pk(a==null?void 0:a.until,t);return l.jsxs("div",{className:"th-acct-menu",role:"menu","aria-label":"Your account",children:[l.jsxs("button",{type:"button",role:"menuitem",className:"th-acct-who",onClick:r,disabled:!r,children:[l.jsx(Rt,{person:e,me:!0}),l.jsxs("span",{children:[l.jsx("b",{children:e.name||e.email}),l.jsx("small",{children:e.email})]})]}),l.jsx("span",{className:"th-acct-rule"}),l.jsxs("button",{type:"button",role:"menuitem",className:`th-acct-row th-acct-status${a?" said":""}`,onClick:n,children:[l.jsx($le,{}),l.jsx("span",{children:a?`${a.text}${c?` · ${c}`:""}`:cL})]}),s&&l.jsxs("button",{type:"button",role:"menuitem",className:"th-acct-row",onClick:s,children:[l.jsx(Ole,{}),l.jsx("span",{children:"Invite people"})]}),o&&l.jsxs("button",{type:"button",role:"menuitem",className:"th-acct-row",onClick:o,children:[l.jsx(iL,{}),l.jsx("span",{children:"Settings"})]}),i&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"th-acct-rule"}),l.jsxs("button",{type:"button",role:"menuitem",className:"th-acct-row th-acct-signout",onClick:i,children:[l.jsx(Lle,{}),l.jsx("span",{children:"Sign out"})]})]})]})}function Fle({view:e,collapsed:t,onToggle:n,onView:r,onSearch:s,onCompose:o,inboxCount:i=0,scheduledCount:a=0,usage:c,onSettings:u,onInstructions:d,page:h,hasTeam:f=!1,onTeam:p,teamPage:m=!1,team:w=null,onInvite:b,onAccount:x,onFeedback:v,onSignOut:S,update:C=null,onUpdate:O,move:N=null,onMove:P}){var F,J;const M=h??(m?"team":null),[R,L]=g.useState(()=>WF()),H=()=>{const ze=(C==null?void 0:C.version)??"";L(ze),KF(globalThis.localStorage,ze)},_=!!C&&!!O&&!VF(C,R),Y=_&&!t,se=_&&C&&O&&l.jsx(Sle,{installing:C.installing,changes:_F(C),error:C.error??null,collapsed:t,onRestart:O,onClose:H}),[re,T]=g.useState(()=>HF()),W=()=>{const ze=(N==null?void 0:N.place)??"";T(ze),UF(globalThis.localStorage,ze)},le=!_&&!!N&&!!P&&re!==(N.place??""),ge=le&&!t,j=le&&N&&P&&l.jsx(vle,{place:N.place,error:N.error??null,collapsed:t,onMove:P,onClose:W}),ae=Number.isFinite(i)?Math.max(0,Math.floor(i)):0,me=`${ae} ${ae===1?"thread":"threads"} waiting`,E=!M&&["inbox","progress","snoozed","done","all"].includes(e),K=w!=null&&w.signedIn?w.me:null,z=((F=w==null?void 0:w.team)==null?void 0:F.name)??st,xe=(J=w==null?void 0:w.team)!=null&&J.name?l.jsx("span",{className:"th-mark","aria-hidden":"true",children:z.slice(0,1).toUpperCase()}):l.jsx("span",{className:"th-mark th-mark-app","aria-hidden":"true",children:l.jsx(vi,{size:20})}),Oe=K?x?l.jsx(Ple,{me:K,now:Date.now(),collapsed:t,onAccount:x,onInvite:b,onSettings:u,onSignOut:S}):l.jsxs(l.Fragment,{children:[l.jsx(Rt,{person:K,me:!0}),l.jsxs("span",{children:[K.name||K.email,l.jsx("small",{children:K.email})]})]}):w!=null&&w.configured&&p?l.jsx("button",{type:"button",className:"th-me-signin","aria-label":"Sign in to your team",onClick:p,children:"Sign in to your team"}):null;return l.jsxs("aside",{className:"workspace-navigation","aria-label":"Workspace",children:[l.jsx("div",{className:"th-team",title:t?void 0:z,children:t?l.jsxs("button",{type:"button",className:"workspace-toggle th-mark-btn","data-hint":"sidebar","aria-label":"Expand sidebar",title:"Expand sidebar",onClick:n,children:[xe,l.jsx("span",{className:"th-mark-open","aria-hidden":"true",children:l.jsx(NE,{collapsed:!0})})]}):l.jsxs(l.Fragment,{children:[xe,l.jsx("span",{className:"th-team-name",children:z}),l.jsx("button",{type:"button",className:"workspace-toggle th-toggle","data-hint":"sidebar","data-hint-align":"right","aria-label":"Collapse sidebar",title:"Collapse sidebar",onClick:n,children:l.jsx(NE,{collapsed:!1})})]})}),l.jsx("nav",{className:"workspace-tabs","aria-label":"Threads",children:l.jsxs("button",{"data-tab":"inbox",className:`workspace-tab${E?" active":""}${ae>0?" has-count":""}`,"aria-label":"Threads","aria-current":E?"page":void 0,title:ae>0?`Threads · ${me}`:t?"Threads":void 0,onClick:()=>r("inbox"),children:[l.jsx(aL,{view:"inbox"}),l.jsx("span",{children:"Threads"}),ae>0&&l.jsx("small",{className:"workspace-running","aria-label":me,children:ae})]})}),l.jsxs("div",{className:"workspace-bottom",children:[Y&&se,ge&&j,l.jsxs("div",{className:"workspace-utilities th-side-foot",children:[!Y&&se,!ge&&j,v&&l.jsxs("button",{"aria-label":"Feedback",title:"Feedback",onClick:v,children:[l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsxs("g",{transform:"translate(12 12) scale(.8) translate(-12 -12)",strokeWidth:"1.5625",children:[l.jsx("path",{d:"M2.5 11.5 21.5 3l-5 18-5-6.5z"}),l.jsx("path",{d:"M11.5 14.5 21.5 3"}),l.jsx("path",{d:"m11.5 14.5-1.2 6 3-3.6"})]})}),l.jsx("span",{children:"Feedback"})]}),d&&l.jsxs("button",{"aria-label":"Instructions","aria-current":M==="instructions"?"page":void 0,title:"Instructions for every agent",onClick:d,children:[l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":"true",children:l.jsx("path",{d:"M6 3.5h8l4 4V20H6zM14 3.5V8h4M9 12h6M9 16h6"})}),l.jsx("span",{children:"Instructions"})]}),u&&l.jsxs("button",{"aria-label":"Settings","aria-current":M==="settings"?"page":void 0,title:"Settings",onClick:u,children:[l.jsx(iL,{}),l.jsx("span",{children:"Settings"})]})]}),c&&l.jsx("div",{className:"workspace-usage",children:c}),Oe&&l.jsx("div",{className:"th-me",children:Oe})]})]})}const Gi=Object.freeze({text:2e4,files:10,bytes:8*1024*1024});function Ble(e=[]){return e.reduce((t,n)=>t+(Number.isFinite(n==null?void 0:n.size)?n.size:0),0)}function _le({text:e="",files:t=[]}={}){const n=String(e??"").trim(),r=Array.isArray(t)?t:[];return!n&&r.length===0?{ok:!1,reason:"Write something or attach a file first."}:n.length>Gi.text?{ok:!1,reason:`Keep it under ${Gi.text.toLocaleString("en-US")} characters.`}:r.length>Gi.files?{ok:!1,reason:`Attach up to ${Gi.files} files.`}:Ble(r)>Gi.bytes?{ok:!1,reason:`Files can add up to ${Gi.bytes/1024/1024} MB.`}:{ok:!0}}function Wle(e){return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>n(r.error),r.onload=()=>{const s=String(r.result??""),o=e.type||"application/octet-stream";t({id:`${e.name}-${e.size}-${e.lastModified}-${Math.random().toString(36).slice(2,7)}`,name:e.name&&e.name!=="image.png"?e.name:Hle(),type:o,size:e.size,data:s.slice(s.indexOf(",")+1),preview:o.startsWith("image/")?s:null})},r.readAsDataURL(e)})}function Hle(e=new Date){const t=n=>String(n).padStart(2,"0");return`Screenshot ${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} at ${t(e.getHours())}.${t(e.getMinutes())}.png`}const Ule=e=>e.includes(".")?e.split(".").pop().slice(0,4).toUpperCase():"FILE";function Kle({onClose:e,onSend:t}){const[n,r]=g.useState(""),[s,o]=g.useState([]),[i,a]=g.useState(!1),[c,u]=g.useState(!1),[d,h]=g.useState(!1),[f,p]=g.useState(null),m=g.useRef(null),w=g.useRef(null),b=g.useRef(0);g.useEffect(()=>{var Y;(Y=m.current)==null||Y.focus()},[]),g.useEffect(()=>{if(!d)return;const Y=setTimeout(e,1800);return()=>clearTimeout(Y)},[d,e]);const x=_le({text:n,files:s}),v=!x.ok&&(n.trim()||s.length)?x.reason:null,S=x.ok&&!c&&!d,C=async Y=>{const se=Array.from(Y??[]);if(se.length){p(null);try{const re=await Promise.all(se.map(Wle));o(T=>[...T,...re])}catch{p("That file could not be read.")}}},O=async()=>{if(!S)return;u(!0),p(null);const Y=await t({text:n,files:s.map(({name:se,type:re,size:T,data:W})=>({name:se,type:re,size:T,data:W}))}).catch(()=>({ok:!1,error:"It did not send. Try again in a moment."}));u(!1),Y.ok?h(!0):p(Y.error??"It did not send. Try again in a moment.")},N=Y=>{if(Y.stopPropagation(),Y.key==="Escape"){Y.preventDefault(),e();return}Y.key==="Enter"&&(Y.metaKey||Y.ctrlKey)&&(Y.preventDefault(),O())},P=Y=>{Y.clipboardData.files.length&&(Y.preventDefault(),C(Y.clipboardData.files))},M=Y=>{var se;return Array.from(((se=Y.dataTransfer)==null?void 0:se.types)??[]).includes("Files")},R=Y=>{M(Y)&&(Y.preventDefault(),b.current+=1,a(!0))},L=Y=>{M(Y)&&Y.preventDefault()},H=Y=>{M(Y)&&(b.current=Math.max(0,b.current-1),b.current||a(!1))},_=Y=>{var se;Y.preventDefault(),b.current=0,a(!1),C((se=Y.dataTransfer)==null?void 0:se.files)};return l.jsx("div",{className:"fb-scrim",onMouseDown:Y=>{Y.target===Y.currentTarget&&!n.trim()&&!s.length&&e()},children:l.jsx("div",{className:"fb-card",role:"dialog","aria-modal":"true","aria-label":"Send feedback",onKeyDown:N,onPaste:P,onDragEnter:R,onDragOver:L,onDragLeave:H,onDrop:_,children:d?l.jsxs("div",{className:"fb-sent",role:"status",children:[l.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M5 12.5 10 17.5 19 7"})}),l.jsx("span",{children:"Sent. Thank you."})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"fb-head",children:[l.jsx("h2",{children:"Send feedback"}),l.jsx("button",{type:"button",className:"fb-close","aria-label":"Close",title:"Close · esc",onClick:e,children:l.jsx(bx,{})})]}),l.jsxs("p",{className:"fb-sub",children:["Goes straight to the ",st," team."]}),l.jsxs("div",{className:"fb-box",children:[l.jsx("textarea",{ref:m,value:n,onChange:Y=>r(Y.target.value),maxLength:Gi.text+1,placeholder:"What happened, and what did you expect?","aria-label":"Your feedback"}),s.length>0&&l.jsx("div",{className:"fb-tiles",children:s.map(Y=>l.jsxs("div",{className:`fb-tile${Y.preview?"":" doc"}`,title:Y.name,children:[Y.preview?l.jsx("img",{src:Y.preview,alt:Y.name}):l.jsx("span",{children:Ule(Y.name)}),l.jsx("button",{type:"button",className:"fb-tile-x","aria-label":`Remove ${Y.name}`,onClick:()=>o(se=>se.filter(re=>re.id!==Y.id)),children:"×"})]},Y.id))}),(f||v)&&l.jsx("p",{className:"fb-note",role:"alert",children:f??v}),l.jsxs("div",{className:"fb-foot",children:[l.jsxs("button",{type:"button",className:"fb-attach",onClick:()=>{var Y;return(Y=w.current)==null?void 0:Y.click()},children:[l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M20 11.5 12.4 19a5 5 0 0 1-7.1-7.1l8-8a3.3 3.3 0 0 1 4.7 4.7l-8 8a1.7 1.7 0 0 1-2.4-2.4l7.3-7.3"})}),l.jsx("span",{children:"Attach"})]}),l.jsx("span",{className:"fb-hint",children:"or paste, or drop files here"}),l.jsx("input",{ref:w,type:"file",multiple:!0,hidden:!0,onChange:Y=>{C(Y.target.files),Y.target.value=""}}),l.jsxs("button",{className:"dock-send",onClick:()=>void O(),disabled:!S,title:"Send · ⌘↵",children:[c?"Sending":"Send"," ",l.jsx("kbd",{children:"⌘↵"})]})]})]}),i&&l.jsxs("div",{className:"fb-drop","aria-hidden":"true",children:[l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{}),l.jsx("i",{}),l.jsxs("div",{children:["Drop to attach",l.jsx("small",{children:"Images, PDFs, docs, logs"})]})]})]})})})}function Vle({inFullScreen:e=!1,walking:t=!1}={}){return!0}function qle({scheduledCount:e=0,view:t="inbox",doneNoun:n="Closed"}={}){const r=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return[["inbox","Inbox"],["progress","In progress"],...r>0||t==="snoozed"?[["snoozed","Scheduled"]]:[],["done",n]]}function ME({searching:e=!1,workspaceNavigation:t=!1,focused:n=!1,settingsOpen:r=!1}={}){return e?!(t&&n&&!r):!1}function Yle(){return l.jsxs("svg",{className:"compose-glyph",width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round","aria-hidden":"true",children:[l.jsx("circle",{cx:"10.8",cy:"10.8",r:"6.6"}),l.jsx("path",{d:"M15.6 15.6 20 20"})]})}const Gle=1300;function Jle(){const[e,t]=g.useState(null),[n,r]=g.useState(!1);return g.useEffect(()=>{var i,a;let s=0;return((a=(i=window.zero)==null?void 0:i.onZoomPercent)==null?void 0:a.call(i,c=>{const u=Number(c==null?void 0:c.percent);Number.isFinite(u)&&t({percent:u,stamp:++s})}))??(()=>{})},[]),g.useEffect(()=>{if(!e)return;r(!0);const s=setTimeout(()=>r(!1),Gle);return()=>clearTimeout(s)},[e]),e?l.jsxs("div",{className:`zoom-readout${n?" up":""}`,children:[e.percent,"%"]}):null}const Xle="['‘’]",Qle='["“”]';function Zle(e){const t=e.trim();if(!t)return null;let n="";for(const r of t.split(/(\s+)/))if(r){if(/^\s+$/.test(r)){n+="\\s+";continue}for(const s of r)s==="'"||s==="‘"||s==="’"?n+=Xle:s==='"'||s==="“"||s==="”"?n+=Qle:n+=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return new RegExp(n,"gi")}function ece(e,t){const n=Zle(t);if(!n)return[];const r=[];for(const s of e.matchAll(n))s[0].length!==0&&r.push([s.index,s.index+s[0].length]);return r}const tce="\0";function nce(e,t){let n="";const r=[];e.forEach((o,i)=>{i>0&&o.block!==e[i-1].block&&(n+=tce),r.push(n.length),n+=o.text});const s=(o,i)=>{let a=0,c=e.length-1;for(;a<c;){const u=a+c+1>>1;(i?r[u]>=o:r[u]>o)?c=u-1:a=u}return a};return ece(n,t).map(([o,i])=>{const a=s(o,!1),c=s(i,!0);return{startRun:a,startOffset:o-r[a],endRun:c,endOffset:i-r[c]}})}function rce(e,t,n){return t<=0?-1:e<0?n===1?0:t-1:(e+n+t)%t}function sce(e,t,n){return n.trim()?t===0?"No matches":`${Math.max(0,e)+1} of ${t}`:""}const oce=new Set(["A","ABBR","B","BDI","BDO","CITE","CODE","DATA","DEL","DFN","EM","I","INS","KBD","LABEL","MARK","Q","S","SAMP","SMALL","SPAN","STRONG","SUB","SUP","TIME","U","VAR"]),ice=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","TEXTAREA","SVG"]);function ace(e){let t=e;for(;t&&oce.has(t.tagName);)t=t.parentElement;return t}function lce(){const e=[],t=[],n=new Map,r=o=>{let i=n.get(o);if(i===void 0){const a=o.checkVisibility;i=typeof a=="function"?a.call(o,{visibilityProperty:!0,checkVisibilityCSS:!0}):!0,n.set(o,i)}return i},s=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode(o){const i=o.parentElement;return!i||!o.nodeValue||ice.has(i.tagName.toUpperCase())||i.closest("[data-find-bar]")?NodeFilter.FILTER_REJECT:r(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});for(let o=s.nextNode();o;o=s.nextNode()){const i=o;e.push({text:i.nodeValue??"",block:ace(i.parentElement)}),t.push(i)}return{runs:e,nodes:t}}function py(e){const{runs:t,nodes:n}=lce();return nce(t,e).map(r=>{const s=document.createRange();return s.setStart(n[r.startRun],r.startOffset),s.setEnd(n[r.endRun],r.endOffset),s})}const uL="find-match",Tb="find-current";function cce(e,t){const n=CSS.highlights,r=window.Highlight;!n||!r||(n.set(uL,new r(...e)),t>=0&&e[t]?n.set(Tb,new r(e[t])):n.delete(Tb))}function RE(){const e=CSS.highlights;e==null||e.delete(uL),e==null||e.delete(Tb)}const dL=e=>{const t=e.getBoundingClientRect();return t.height>0&&t.bottom>0&&t.top<window.innerHeight};function IE(e){if(!e||dL(e))return;const t=e.startContainer.parentElement;t==null||t.scrollIntoView({block:"center",inline:"nearest"})}function uce(){const[e,t]=g.useState(!1),[n,r]=g.useState(""),[s,o]=g.useState(-1),[i,a]=g.useState(0),c=g.useRef(null),u=g.useRef([]),d=g.useRef(-1),h=g.useRef(null),f=g.useRef(!1),p=g.useRef(""),m=(S,C)=>{u.current=S,d.current=C,a(S.length),o(C),cce(S,C)},w=g.useCallback(S=>{const C=S.trim()?py(S):[],O=C.findIndex(dL),N=C.length===0?-1:O>=0?O:0;m(C,N),IE(C[N])},[]),b=g.useCallback(S=>{const C=p.current.trim()?py(p.current):[],O=rce(Math.min(d.current,C.length-1),C.length,S);m(C,O),IE(C[O])},[]),x=g.useCallback(()=>{f.current=!1,t(!1),RE(),u.current=[],d.current=-1;const S=h.current;h.current=null,S&&S.isConnected&&typeof S.focus=="function"&&S.focus()},[]);if(g.useEffect(()=>{var C,O;return((O=(C=window.zero)==null?void 0:C.onFind)==null?void 0:O.call(C,N=>{const P=Number(N==null?void 0:N.step)||0;if(!f.current){const M=document.activeElement;h.current=M&&!M.closest("[data-find-bar]")?M:null,f.current=!0,t(!0)}requestAnimationFrame(()=>{var M,R;(M=c.current)==null||M.focus(),P===0?(R=c.current)==null||R.select():b(P>0?1:-1)})}))??(()=>{})},[b]),g.useEffect(()=>{if(p.current=n,!e)return;const S=setTimeout(()=>w(n),60);return()=>clearTimeout(S)},[n,e,w]),g.useEffect(()=>{if(!e)return;let S=null;const C=new MutationObserver(O=>{!O.some(P=>{const M=P.target.nodeType===Node.ELEMENT_NODE?P.target:P.target.parentElement;return!(M!=null&&M.closest("[data-find-bar]"))})||!p.current.trim()||(S&&clearTimeout(S),S=setTimeout(()=>{const P=py(p.current);m(P,P.length===0?-1:Math.min(Math.max(d.current,0),P.length-1))},200))});return C.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),()=>{C.disconnect(),S&&clearTimeout(S)}},[e]),g.useEffect(()=>()=>RE(),[]),!e)return null;const v=sce(s,i,n);return l.jsxs("div",{className:"find-bar","data-find-bar":!0,role:"search",children:[l.jsx("input",{ref:c,className:"find-input",value:n,placeholder:"Find",spellCheck:!1,"aria-label":"Find on this screen",onChange:S=>r(S.target.value),onKeyDown:S=>{S.key==="Escape"?(S.preventDefault(),S.stopPropagation(),x()):S.key==="Enter"&&(S.preventDefault(),S.stopPropagation(),b(S.shiftKey?-1:1))}}),l.jsx("span",{className:`find-count${i===0&&n.trim()?" none":""}`,children:v}),l.jsx("button",{type:"button",className:"find-step","aria-label":"Previous match",disabled:i===0,onClick:()=>b(-1),children:"↑"}),l.jsx("button",{type:"button",className:"find-step","aria-label":"Next match",disabled:i===0,onClick:()=>b(1),children:"↓"}),l.jsx("button",{type:"button",className:"find-step","aria-label":"Close",onClick:x,children:"×"})]})}const dce=({letter:e})=>l.jsx("span",{className:"ps-mark","aria-hidden":"true",children:e});function hL({rows:e,label:t,onPick:n,busy:r=!1}){const[s,o]=g.useState(0),i=g.useCallback(a=>{const c=e[a];!c||r||(c.href?window.open(c.href,"_blank","noreferrer"):n(c.key))},[r,n,e]);return g.useEffect(()=>{const a=c=>{c.key==="ArrowDown"?(c.preventDefault(),o(u=>Math.min(e.length-1,u+1))):c.key==="ArrowUp"?(c.preventDefault(),o(u=>Math.max(0,u-1))):c.key==="Enter"&&(c.preventDefault(),i(s))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i,s,e.length]),l.jsx("div",{className:"fr-card fr-folders",role:"listbox","aria-label":t,children:e.map((a,c)=>{const u=l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"fr-fold",children:a.mark?l.jsx(dce,{letter:a.mark}):l.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M3 8h9M8.5 4.5L12 8l-3.5 3.5"})})}),l.jsx("span",{className:"fr-folder-name",children:a.name}),a.sub&&l.jsx("span",{className:"fr-folder-path",children:a.sub}),a.sub&&l.jsx("span",{className:"fr-folder-via"}),l.jsx("span",{className:"fr-folder-key",children:s===c&&l.jsx(ko,{cap:"↵"})})]}),d=`fr-folder${a.other?" fr-folder-other":""}${s===c?" lit":""}`;return a.href?l.jsx("a",{role:"option","aria-selected":s===c,className:d,href:a.href,target:"_blank",rel:"noreferrer",onMouseEnter:()=>o(c),children:u},a.key):l.jsx("button",{type:"button",role:"option","aria-selected":s===c,className:d,onMouseEnter:()=>o(c),onClick:()=>i(c),children:u},a.key)})})}const hce=({state:e})=>e==="done"?l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M3.5 8.5l3 3 6-7"})}):e==="now"?l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:l.jsx("circle",{cx:"8",cy:"8",r:"4.5",fill:"currentColor"})}):l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:l.jsx("circle",{cx:"8",cy:"8",r:"5"})});function fce({onPick:e,onReady:t,look:n}){const r=toe(),[s,o]=g.useState(!0),[i,a]=g.useState(!1),[c,u]=g.useState(!1),[d,h]=g.useState(!1),f=g.useCallback(async v=>n?n(v):(await Promise.all(["claude","codex"].map(C=>q.engineSetup("ready",C)))).map(C=>({engine:C.engine,found:!!C.found,signedIn:!!C.signedIn})),[n]),p=g.useCallback(async(v=!1)=>{o(!0),u(!1);let S;try{S=eoe(await f(v))}catch{S={t:"nothing"}}o(!1),a(!0),S.t==="ready"?t():S.t==="setup"&&e(S.plan)},[e,t,f]),m=g.useRef(!1);g.useEffect(()=>{m.current||(m.current=!0,p())},[p]);const w=g.useCallback(async()=>{h(!0),u(!1);try{const v=await q.engineBin("claude");if(v!=null&&v.refused){u(!0);return}if(v!=null&&v.canceled)return;await p(!0)}finally{h(!1)}},[p]),b=g.useCallback(v=>{v==="mine"?w():e(v)},[w,e]),x=noe({looking:s,looked:i,refused:c});return l.jsxs("div",{className:"fr-stack fr-stack-folders",children:[l.jsx("h1",{className:"fr-page",children:dt.planHead}),l.jsx("p",{className:"fr-lede",children:dt.planLede}),l.jsx(hL,{rows:r,label:dt.planHead,onPick:b,busy:d}),l.jsx("p",{className:x.bad?"fr-note fr-refused":"fr-note",children:x.text})]})}function fL({plan:e,onDone:t,onSkip:n}){const r=Zse(e),[s,o]=g.useState(0),i=r[Math.min(s,r.length-1)],[a,c]=g.useState({engine:i,phase:"installing",error:null,log:""}),[u,d]=g.useState(!1),[h,f]=g.useState(0),p=g.useRef(!1);g.useEffect(()=>{let v=!0,S=null;const C=async O=>{const N=await q.engineSetup(O?"start":"status",i);if(v){if(c(N),N.phase==="ready"){if(s+1<r.length){c({engine:r[s+1],phase:"installing",error:null,log:""}),o(s+1);return}p.current||(p.current=!0,S=setTimeout(t,700));return}N.phase!=="failed"&&(S=setTimeout(()=>C(!1),1e3))}};return C(!0),()=>{v=!1,S&&clearTimeout(S)}},[i,s,h]);const m=()=>{c({engine:i,phase:"installing",error:null,log:""}),f(v=>v+1)},w=OO(i),b=roe(a),x=dt.setupHead(w);return l.jsxs("div",{className:"fr-stack fr-stack-folders",children:[l.jsx("h1",{className:"fr-page",children:x}),l.jsxs("p",{className:"fr-lede",children:[soe(a.phase),r.length>1&&l.jsxs("span",{className:"ps-of",children:[" ",dt.setupOf(s+1,r.length)]})]}),l.jsx("div",{className:"fr-card fr-folders ps-steps",children:b.map(v=>l.jsxs("div",{className:`ps-step ${v.state}`,children:[l.jsx("span",{className:"ps-ic",children:l.jsx(hce,{state:v.state})}),l.jsxs("div",{children:[l.jsx("div",{className:"ps-t",children:v.title}),v.sub&&l.jsx("div",{className:"ps-s",children:v.sub})]}),l.jsx("span",{className:"ps-r",children:v.right??""})]},v.title))}),a.phase==="failed"&&a.error&&l.jsx("p",{className:"fr-note fr-refused",children:a.error}),l.jsxs("div",{className:"ps-acts",children:[a.phase==="signing-in"&&l.jsx("button",{type:"button",className:"fr-gate-again",onClick:()=>void q.engineSetup("again",i),children:dt.openAgain}),a.phase==="failed"&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"fr-finish-go",onClick:m,children:dt.tryAgain}),l.jsx("button",{type:"button",className:"fr-gate-again",onClick:n,children:dt.skip})]})]}),l.jsx("div",{className:"ps-acts ps-acts-quiet",children:l.jsx("button",{type:"button",className:"ps-link",onClick:()=>d(v=>!v),children:u?dt.hideLog:dt.showLog})}),u&&l.jsx("pre",{className:"ps-log",children:a.log.trim().split(`
|
|
1123
|
+
`).slice(-14).join(`
|
|
1124
|
+
`)||"…"})]})}function pce({onSetup:e}){return l.jsxs("div",{className:"ps-bar",role:"status",children:[l.jsxs("div",{className:"ps-bar-say",children:[dt.barSay," ",l.jsx("span",{children:dt.barSub})]}),l.jsx("button",{type:"button",onClick:()=>e("claude"),children:dt.barClaude}),l.jsx("button",{type:"button",className:"quiet",onClick:()=>e("codex"),children:dt.barChatgpt})]})}function mce(e){return e==="claude"?"Claude":e==="codex"?"ChatGPT":null}function DE({engine:e=null}={}){const t=mce(e);return t?`Your agents will run on the ${t} account already signed in on this Mac.`:null}function gce(e,t){const n=e.filter(r=>r.slug===t.product);return n.length||!t.product?n:[{slug:t.product,name:t.name,repoPath:t.folder}]}function yce(){return l.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"})})}function wce(){return l.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:l.jsx("path",{d:"M12 5v14M5 12h14"})})}function bce(){return l.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M3 8h9M8.5 4.5L12 8l-3.5 3.5"})})}function xce({run:e,blocked:t,onLeave:n}){const[r,s]=g.useState(!1);return g.useEffect(()=>{if(!r)return;const o=i=>{i.key!=="Escape"||i.metaKey||i.ctrlKey||i.altKey||(i.preventDefault(),i.stopPropagation(),i.stopImmediatePropagation(),s(!1))};return window.addEventListener("keydown",o,!0),()=>window.removeEventListener("keydown",o,!0)},[r]),t||!ep(e)?null:l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"fr-out",onClick:()=>s(!0),children:_e.leave}),r&&l.jsx("div",{className:"fr-stay-scrim",role:"dialog","aria-modal":"true","aria-label":_e.leaveHead,children:l.jsxs("div",{className:"fr-stay",children:[l.jsx("div",{className:"fr-stay-head",children:_e.leaveHead}),l.jsx("div",{className:"fr-stay-line",children:_e.leaveLine}),l.jsxs("div",{className:"fr-stay-row",children:[l.jsx("button",{type:"button",className:"fr-stay-go",autoFocus:!0,onClick:n,children:_e.leaveGo}),l.jsx("button",{type:"button",className:"fr-stay-keep",onClick:()=>s(!1),children:_e.leaveStay})]})]})})]})}function pL(e){const t=e.getBoundingClientRect();if(!t.width||!t.height)return null;const n={x:t.left,y:t.top,w:t.width,h:t.height};return[...e.childNodes].some(s=>s.nodeType===3&&(s.nodeValue??"").trim()!=="")?n:Hoe(n,[...e.children].map(s=>{const o=s.getBoundingClientRect();return{x:o.left,y:o.top,w:o.width,h:o.height,position:getComputedStyle(s).position}}))}function kce(e){const t=e.parentElement;return t?[...t.children].filter(n=>n!==e&&getComputedStyle(n).position==="static").map(n=>pL(n)).filter(n=>n!==null):[]}function vce(e,t,n){const r=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[document.elementFromPoint(e,t)].filter(Boolean);for(const s of r){if(s.closest(".fr-tether, .fr-ring, .fr-out")||n&&(s===n||n.contains(s)||s.contains(n)))continue;if([...s.childNodes].some(i=>i.nodeType===3&&(i.nodeValue??"").trim()!==""))return s.getBoundingClientRect()}return null}function OE(e){for(const t of e){const n=document.querySelector(t);if(n)return n}return null}function ko({cap:e,className:t}){const n=Poe(e);return l.jsxs("kbd",{className:t,children:[e,n?l.jsx("span",{className:"fr-cap-word",children:n}):null]})}function my({say:e,beat:t,pointed:n,knock:r=0,onNext:s,onSkip:o}){const[i,a]=g.useState(0),[c,u]=g.useState(!1),d=g.useRef({beat:[],pointed:null});d.current={beat:t??[],pointed:n??null};const h=g.useRef(s);h.current=s,g.useEffect(()=>{if(!e.anyKey)return;const p=b=>{h.current&&(b.preventDefault(),b.stopPropagation(),b.stopImmediatePropagation(),h.current())},m=b=>{["Meta","Shift","Alt","Control","CapsLock"].includes(b.key)||p(b)},w=b=>{const x=b.target;x&&typeof x.closest=="function"&&x.closest(".modal.palette")&&p(b)};return window.addEventListener("keydown",m,!0),window.addEventListener("pointerdown",w,!0),window.addEventListener("click",w,!0),()=>{window.removeEventListener("keydown",m,!0),window.removeEventListener("pointerdown",w,!0),window.removeEventListener("click",w,!0)}},[e.anyKey]),g.useEffect(()=>{if(a(0),u(!1),!e.key)return;let p=!0,m=setTimeout(()=>{p&&u(!0)},rE);const w=b=>{if(Ou(b.target)&&vl(b)!==null){if(u(!1),clearTimeout(m),m=setTimeout(()=>{p&&u(!0)},rE),e.next&&vl(b)===e.key&&h.current){b.preventDefault(),b.stopPropagation(),b.stopImmediatePropagation(),h.current();return}if(vl(b)===e.key&&Aoe(d.current.beat,d.current.pointed)){a(x=>x+1),Ou(b.target)&&(b.preventDefault(),b.stopPropagation(),b.stopImmediatePropagation());return}FO(e.key,b)&&(e.alt&&vl(b)===e.alt||(a(x=>x+1),Boe(e.key,b,b.target)&&(b.preventDefault(),b.stopPropagation(),b.stopImmediatePropagation())))}};return window.addEventListener("keydown",w,!0),()=>{p=!1,clearTimeout(m),window.removeEventListener("keydown",w,!0)}},[e.key,e.next]);const f=i+r;return l.jsxs(l.Fragment,{children:[e.quiet?l.jsx("span",{className:"fr-quiet",children:e.quiet}):null,l.jsxs("span",{className:e.quiet?"fr-loud":"fr-loud fr-alone",children:[e.lead,e.key&&!e.next&&l.jsx(ko,{cap:e.key,className:`${f?"fr-wrong":""}${c?" fr-breathe":""}`.trim()||void 0},f),e.tail]}),e.next&&s?l.jsxs("button",{type:"button",className:"fr-next",onClick:s,children:["Next",e.key&&l.jsx(ko,{cap:e.key,className:`${f?"fr-wrong":""}${c?" fr-breathe":""}`.trim()||void 0},f)]}):null,e.caps&&e.key?l.jsx(Sce,{of:e.caps,cap:e.key,left:t==null?void 0:t.length}):null,o?l.jsx("button",{type:"button",className:"fr-skip-step",onClick:o,children:"Skip this step"}):null]})}function Sce({of:e,cap:t,left:n}){const[r,s]=g.useState(e);g.useEffect(()=>{if(n!==void 0)return;const a=()=>s(document.querySelectorAll(".list-pane .row").length);a();const c=setInterval(a,200);return()=>clearInterval(c)},[n]);const i=Math.max(0,Math.min(e,e-(n??r)));return l.jsx("span",{className:"fr-lights","aria-hidden":"true","data-key":t,children:Array.from({length:e},(a,c)=>l.jsx("i",{className:c<i?"fr-dot fr-lit":"fr-dot"},c))})}function jce(e,t=null){if(!e)return 0;e.style.removeProperty("--fr-lift");const n=e.getBoundingClientRect(),r=Math.round(n.bottom-window.innerHeight+Zf),s=t&&!t.below?Math.round(n.bottom-(t.ring.y-Xf)):0,o=Math.max(r,s);if(o<=0)return 0;const i=Math.min(o,Math.max(0,n.top-Zf));return i<=0?0:(e.style.setProperty("--fr-lift",`${-i}px`),i)}function gy(){for(const t of document.querySelectorAll("[data-fr-room]"))t.removeAttribute("data-fr-room");const e=document.querySelector(".list-pane");e==null||e.style.removeProperty("--fr-room")}function LE(e,t=".tabs"){const n=[...document.querySelectorAll(t)],r=n.length?n[n.length-1].getBoundingClientRect().right:0;return Math.round(Math.max(e.ring.x+e.ring.w+10,r)+26)}function Cce(e){if(!e)return 0;e.style.removeProperty("--fr-drop");const n=(()=>{const s=e.getBoundingClientRect();let o=null;for(const i of document.querySelectorAll(tie)){const a=i.getBoundingClientRect();if(a.width<8||a.height<8||!(s.left<a.right&&s.right>a.left))continue;const c=Math.round(s.top-a.bottom);c>=-40&&c<200&&(o===null||c<o)&&(o=c)}return o})();if(n===null||n>=Zf)return 0;const r=Zf-n;return e.style.setProperty("--fr-drop",`${r}px`),r}function Mb({box:e,knocked:t=""}){if(!e)return l.jsx("div",{className:`fr-veil${t}`,"aria-hidden":"true"});const n=Math.round(e.x+e.w/2),r=Math.round(e.y+e.h/2),s=Math.round(e.w/2+26),o=Math.round(e.h/2+26),i=`radial-gradient(${s+150}px ${o+150}px at ${n}px ${r}px, rgba(0,0,0,0) 0%, rgba(0,0,0,0) ${Math.round(100*s/(s+150))}%, rgba(0,0,0,1) 100%)`;return l.jsx("div",{className:`fr-veil${t}`,style:{WebkitMaskImage:i,maskImage:i},"aria-hidden":"true"})}const Nce=900;function Ece(){const e=document.querySelector(".list-pane")??document.querySelector(".body"),t=e?e.getBoundingClientRect():null,n=document.querySelector(".th-bar"),r=n?n.getBoundingClientRect().bottom+28:t&&t.height>0?t.top+48:120,s=document.querySelector(".list-pane .list"),o=s?s.getBoundingClientRect().bottom+28:0,i=o>r&&o<window.innerHeight-200?o:r,a=t&&t.width>0?t.left+40:80,c=t&&t.width>0?t.right:window.innerWidth;return{x:Math.round(a),y:Math.round(i),w:Math.round(Math.max(UO,Math.min(Mk+120,c-a-40)))}}function Ace({selector:e,boundsSel:t,underSel:n,makesRoom:r,say:s,beside:o,besideRing:i,besideOf:a,beat:c,pointed:u,hold:d,also:h,onNext:f,onSkip:p}){const[m,w]=g.useState(null),[b,x]=g.useState(null),v=g.useRef(null),S=g.useRef(null),[C,O]=g.useState(0);g.useEffect(()=>{O(0)},[e.join("|")]),g.useLayoutEffect(()=>{let L=!0;const H=()=>{if(w(null),document.querySelector(".modal-backdrop")){v.current=null,x(null);return}const se=Date.now();v.current===null&&(v.current=se),se-v.current>=Nce&&x(Ece())},_=()=>{if(!L)return;const se=OE(e);if(!se){H();return}const re=[...document.querySelectorAll(".modal-backdrop")];if(re.length&&!re.some(E=>E.contains(se))){v.current=null,x(null),w(null);return}const T=pL(se);if(!T){H();return}v.current=null,x(null);const W=t?document.querySelector(t):null,le=W?W.getBoundingClientRect():null,ge={w:window.innerWidth,h:window.innerHeight},j=Voe(T,kce(se)),ae=Qoe(T,{left:le?le.left:0,right:le?le.right:ge.w},ge,j),me=n&&!r?document.querySelector(n):null;if(me&&(ae.text.y=Math.round(me.getBoundingClientRect().bottom+HO(T)+Xf)),ae.below&&!me&&!r)for(let E=0;E<4;E+=1){const z=[ae.text.x+4,ae.text.x+Math.min(ae.text.w,300)/2,ae.text.x+Math.min(ae.text.w,300)-4].map(Oe=>vce(Oe,ae.text.y+Qf/2,se)).filter(Boolean);if(!z.length)break;const xe=Zoe(ae.text.y,Qf,z,ge);if(xe===ae.text.y)break;ae.text.y=xe}w(ae),gy()};_();const Y=setInterval(_,200);return window.addEventListener("resize",_),()=>{L=!1,clearInterval(Y),window.removeEventListener("resize",_)}},[e.join("|"),t,n,r]),g.useLayoutEffect(()=>{gy()}),g.useLayoutEffect(()=>()=>gy(),[]);const N=g.useRef(!1);N.current=!!m;const P=g.useRef(!1);if(P.current=!!s.next,g.useEffect(()=>{if(!d)return;const L=H=>{if(!N.current)return;const _=H.target,Y=[OE(e),...(h??[]).flatMap(re=>[...document.querySelectorAll(re)])];(P.current?_&&typeof _.closest=="function"&&!_.closest(BO)&&Ou(_):Woe(H.target,Y))&&(H.stopPropagation(),H.stopImmediatePropagation(),H.type==="click"&&(H.preventDefault(),O(re=>re+1)))};for(const H of sE)window.addEventListener(H,L,!0);return()=>{for(const H of sE)window.removeEventListener(H,L,!0)}},[d,e.join("|"),(h??[]).join("|")]),g.useLayoutEffect(()=>{Cce(S.current),jce(S.current,m)}),!m)return b?l.jsxs(l.Fragment,{children:[l.jsx(Mb,{box:null}),l.jsx("p",{ref:S,className:"fr-tether fr-adrift",style:{left:b.x,top:b.y,maxWidth:b.w},role:"status",children:l.jsx(my,{say:s,beat:c,pointed:u,knock:C,onNext:f,onSkip:p})})]}):null;const M=10,R=C?" fr-knock":"";return l.jsxs(l.Fragment,{children:[l.jsx(Mb,{box:m.ring,knocked:R},C),l.jsx("svg",{className:"fr-ring",style:{left:m.ring.x-M,top:m.ring.y-M},width:m.ring.w+M*2,height:m.ring.h+M*2,"aria-hidden":"true",children:l.jsx("rect",{className:`halo${R}`,x:M,y:M,width:m.ring.w,height:m.ring.h,rx:m.ring.r},C)}),o?l.jsx("p",{ref:S,className:"fr-tether beside",style:{left:i?Math.round(m.ring.x+m.ring.w+26):LE(m,a),top:m.ring.y+m.ring.h/2,maxWidth:i?Math.max(240,window.innerWidth-(m.ring.x+m.ring.w+26)-40):Math.max(240,Math.min(Mk+60,window.innerWidth-LE(m,a)-200))},role:"status",children:l.jsx(my,{say:s,beat:c,pointed:u,knock:C,onNext:f,onSkip:p})}):l.jsx("p",{ref:S,className:m.text.right===null?"fr-tether":"fr-tether right",style:m.text.right===null?{left:m.text.x,top:m.text.y,maxWidth:m.text.w}:{right:m.text.right,top:m.text.y,maxWidth:m.text.w},role:"status",children:l.jsx(my,{say:s,beat:c,pointed:u,knock:C,onNext:f,onSkip:p})})]})}function Tce({found:e,folders:t,claude:n,products:r,project:s,onDone:o,onFiled:i,onProjectMade:a,onRecheck:c}){const[u,d]=g.useState(null);g.useEffect(()=>{let M=!0;return ms(async()=>{const{api:R}=await Promise.resolve().then(()=>Ji);return{api:R}},void 0,import.meta.url).then(({api:R})=>R.agentThreads()).then(R=>{M&&d(R)}).catch(()=>{M&&d([])}),()=>{M=!1}},[]);const h=!!e&&Vp(e)||!!(t!=null&&t.some(M=>M.count>0)),f=Moe(n,{read:e!==null&&t!==null,some:h},u),[p,m]=g.useState(!1),[w,b]=g.useState(!1),x=async()=>{if(!p){m(!0),O(null);try{b(await c())}finally{m(!1)}}},[v,S]=g.useState(!1),[C,O]=g.useState(null),N=async()=>{if(!v){S(!0),O(null);try{const{api:M}=await ms(async()=>{const{api:L}=await Promise.resolve().then(()=>Ji);return{api:L}},void 0,import.meta.url),R=await M.engineBin("claude");R!=null&&R.refused&&(O(R.refused),b(!1)),!(R!=null&&R.canceled)&&!(R!=null&&R.refused)&&b(await c())}finally{S(!1)}}},P=!!f.skip;if(g.useEffect(()=>{P&&o([])},[P]),!f.show)return null;if(!f.blocked)return l.jsx(l.Fragment,{children:l.jsx(YO,{products:r,filter:s,walk:{line:_e.agentsOffer,skip:_e.finishGo,onSkip:()=>o([]),folders:t},onDone:i,onProjectMade:a,onNewProject:()=>{},onClose:()=>{}})});if(f.blocked)return l.jsxs(l.Fragment,{children:[l.jsx(Mb,{box:null}),l.jsxs("div",{className:"fr-stack fr-stack-folders",role:"status",children:[l.jsx("h1",{className:"fr-page",children:f.head}),l.jsx("p",{className:"fr-lede",children:f.line}),l.jsx(hL,{rows:Roe(n.url,{checking:p,pointing:v}),label:f.head,busy:p||v,onPick:M=>{M==="check"?x():N()}}),l.jsx("p",{className:C?"fr-note fr-refused":"fr-note",children:C??(w&&!p?_e.gateStill:_e.gateDo)})]})]})}const Mce=14e3;function Rce({agents:e,onGone:t}){const n=g.useRef(Array.from({length:40},(s,o)=>({left:4+o*97%92,delay:o*53%40/100,drift:o*31%120-60,spin:o*71%540-270,hue:[199,267,42,158,12][o%5],fall:62+o*17%26}))),r=g.useContext(Xt);return g.useEffect(()=>{const s=setTimeout(t,Mce),o=()=>t(),i=setTimeout(()=>window.addEventListener("keydown",o),0),a=setTimeout(()=>window.addEventListener("pointerdown",o),0);return()=>{clearTimeout(s),clearTimeout(i),clearTimeout(a),window.removeEventListener("keydown",o),window.removeEventListener("pointerdown",o)}},[t]),l.jsxs("div",{className:"fr-landed","aria-live":"polite",children:[l.jsx("div",{className:"fr-burst","aria-hidden":"true",children:n.current.map((s,o)=>l.jsx("span",{className:"fr-bit",style:{left:`${s.left}%`,animationDelay:`${s.delay}s`,"--fr-drift":`${s.drift}px`,"--fr-spin":`${s.spin}deg`,"--fr-fall":`${s.fall}vh`,background:`hsl(${s.hue} 78% 62%)`}},o))}),l.jsxs("div",{className:"fr-landed-say",children:[l.jsx("h1",{className:"fr-landed-head",children:_e.finishHead}),l.jsx("p",{className:"fr-landed-line",children:e?_e.finishLineAgents:_e.finishLine}),l.jsx("ul",{className:"fr-landed-next",children:[..._e.finishNext,...r?_e.finishNextTeam:[]].map(s=>l.jsx("li",{children:s},s))})]})]})}function Ice(){return l.jsxs("div",{className:"fr-band",role:"note",children:[l.jsx("div",{className:"fr-band-drag","aria-hidden":"true"}),l.jsxs("span",{className:"fr-band-pill",children:[l.jsx("span",{className:"fr-band-dot","aria-hidden":"true"}),l.jsx("span",{className:"fr-band-tag",children:_e.bandTag}),l.jsx("span",{className:"fr-band-say",children:_e.band})]})]})}function $E({count:e=0,on:t="inbox"}){const n=(r,s,o=t===r)=>l.jsxs("button",{className:`workspace-tab${o?" active":""}${r==="inbox"&&e>0?" has-count":""}`,type:"button",tabIndex:-1,children:[l.jsx(aL,{view:r}),l.jsx("span",{children:s}),r==="inbox"&&e>0&&l.jsx("small",{className:"workspace-running",children:e})]});return l.jsxs("div",{className:"workspace-navigation fr-piece-nav","aria-hidden":"true",children:[l.jsxs("nav",{className:"workspace-tabs",children:[n("inbox","Inbox"),n("progress","In progress")]}),l.jsx("div",{className:"fr-piece-nav-foot",children:n("done","Closed")})]})}const PE=[{title:"Drafted the agenda for the offsite.",result:"Three sessions and a working lunch. I left the dinner spot for you to pick.",agoMs:38*6e4,project:"Operations"},{title:"Which launch date should we announce?",result:"The 14th clears every review. The 7th is a week tighter but still possible.",agoMs:44*6e4,project:"Launch"},{title:"Rewrote the pricing page.",result:"All three plans now say the same thing in the same order. Ready for you to read.",agoMs:52*6e4,project:"Website"},{title:"Summarised this week of customer calls.",result:"Five calls, and two of them asked for the same thing. One page of notes.",agoMs:61*6e4,project:"Research"}],zE=[{title:"Tidy the vendor contact list.",step:"Removing duplicates.",project:"Operations"},{title:"Draft the release notes for March.",step:"Reading what changed this month.",project:"Launch"},{title:"Find why checkout is slow on Safari.",step:"Timing the payment form.",project:"Website"},{title:"Book rooms for the team offsite.",step:"Comparing three hotels.",project:"Operations"},{title:"Turn the survey answers into a chart.",step:"Counting answers by team.",project:"Research"},{title:"Fix the broken link in the welcome email.",step:"Checking every link in it.",project:"Website"},{title:"Write up the hiring plan.",step:"Drafting the timeline.",project:"Launch"}];function Dce({kind:e}){return e==="progress"?l.jsxs("div",{className:"fr-piece fr-piece-with-nav","aria-hidden":"true",children:[l.jsx($E,{on:"progress",count:3}),l.jsx("div",{className:"list-pane",children:l.jsxs("div",{className:"list",children:[l.jsx("div",{children:l.jsx("div",{className:"day-label",children:"Working now"})}),zE.map(t=>l.jsxs("div",{className:"row",children:[l.jsxs("div",{className:"row-main",children:[l.jsx("div",{className:"subject",children:t.title}),l.jsx("div",{className:"preview",children:t.step})]}),l.jsx("div",{className:"row-end",children:l.jsx("span",{className:"product",children:t.project})})]},t.title))]})})]}):e==="ask"?l.jsx("div",{className:"fr-piece fr-piece-ask","aria-hidden":"true",children:l.jsxs("div",{className:"modal compose",children:[l.jsx("div",{className:"compose-text",children:Du.title}),l.jsxs("div",{className:"compose-sentence quiet rest-project",children:[l.jsx("span",{className:"compose-clauses",children:l.jsxs("span",{className:"clause clause-project",children:["For ",HN,"."]})}),l.jsxs("button",{className:"dock-send",type:"button",tabIndex:-1,children:["Start it ",l.jsx("kbd",{children:"⌘↵"})]})]})]})}):l.jsxs("div",{className:"fr-piece fr-piece-with-nav","aria-hidden":"true",children:[l.jsx($E,{count:e==="list"?Jf.length+PE.length:0}),e==="list"?l.jsx("div",{className:"list-pane",children:l.jsxs("div",{className:"list",children:[l.jsx("div",{children:l.jsx("div",{className:"day-label",children:"Today"})}),[...Jf.map(t=>({...t,project:HN})),...PE].map(t=>l.jsxs("div",{className:"row",children:[l.jsxs("div",{className:"row-main",children:[l.jsx("div",{className:"subject",children:t.title}),l.jsx("div",{className:"preview",children:t.result})]}),l.jsxs("div",{className:"row-end",children:[l.jsx("span",{className:"product",children:t.project}),l.jsxs("span",{className:"time",children:[Math.round(t.agoMs/6e4),"m"]})]})]},t.title))]})}):l.jsx("div",{className:"list-pane bare fr-piece-empty",children:l.jsx("div",{className:"zero-state idle",children:l.jsxs("div",{className:"idle-zero-col",children:[l.jsx("b",{className:"idle-zero",children:"0"}),l.jsxs("span",{className:"idle-zero-say",children:["Inbox zero · ",zE.length," agents working"]}),l.jsxs("span",{className:"idle-field",children:[l.jsx("span",{className:"idle-ph",children:"What do you need done?"}),l.jsx("span",{className:"idle-key",children:"N"})]})]})})})]})}function Oce({head:e,line:t,piece:n,onNext:r}){return g.useEffect(()=>{const s=i=>{i.key==="Enter"&&(i.preventDefault(),r())},o=setTimeout(()=>window.addEventListener("keydown",s),0);return()=>{clearTimeout(o),window.removeEventListener("keydown",s)}},[r]),l.jsxs("div",{className:"fr-screen fr-screen-intro",children:[l.jsxs("div",{className:"fr-brand",children:[l.jsx(vi,{size:22}),Je]}),l.jsx(Dce,{kind:n}),l.jsxs("div",{className:"fr-corner",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"fr-head",children:e}),l.jsx("p",{className:"fr-intro-line",children:t})]}),l.jsxs("button",{className:"fr-go",onClick:r,children:[_e.introNext," ",l.jsx(ko,{cap:"↵"})]})]})]})}function Lce({head:e,line:t,go:n,onNext:r,skip:s,onSkip:o}){return g.useEffect(()=>{const i=c=>{c.key==="Enter"&&(c.preventDefault(),r())},a=setTimeout(()=>window.addEventListener("keydown",i),0);return()=>{clearTimeout(a),window.removeEventListener("keydown",i)}},[r]),l.jsxs("div",{className:"fr-screen",children:[l.jsxs("div",{className:"fr-brand",children:[l.jsx(vi,{size:22}),Je]}),l.jsx("div",{className:"fr-stack",children:l.jsxs("div",{className:"fr-finish",role:"status",children:[l.jsx("h1",{className:"fr-finish-head",children:e}),l.jsx("p",{className:"fr-finish-line",children:t}),l.jsx("button",{className:"fr-finish-go",onClick:r,autoFocus:!0,children:n}),s&&o?l.jsx("button",{type:"button",className:"fr-finish-skip",onClick:o,children:s}):null]})})]})}function $ce({run:e,claude:t,home:n,opened:r,waiting:s,later:o,picking:i,palette:a,board:c,replying:u,view:d,tabs:h,products:f=[],beat:p,pointed:m,runsOn:w=null,onEvent:b,onStep:x,onSkipToApp:v,onPractice:S,onDone:C,onFiled:O,onProjectMade:N,onRecheck:P,onLeave:M,onShut:R,onSkipStep:L}){const H=g.useRef(null);g.useContext(Xt);const[_,Y]=g.useState(!1),[se,re]=g.useState(null),[T,W]=g.useState(null),[le,ge]=g.useState(!1),[j,ae]=g.useState(null),[me,E]=g.useState(-1),K=e.step==="welcome"||e.step==="folder";g.useEffect(()=>{if(!K||j)return;let be=!0;return ms(async()=>{const{api:Le}=await Promise.resolve().then(()=>Ji);return{api:Le}},void 0,import.meta.url).then(({api:Le})=>Le.agentThreads()).then(Le=>{be&&ae(moe(Le,{home:n}))}).catch(()=>{be&&ae([])}),()=>{be=!1}},[K,j,n]);const z=g.useRef(null),xe=(be=!1)=>((be||!z.current)&&(z.current=ms(async()=>{const{api:Le}=await Promise.resolve().then(()=>Ji);return{api:Le}},void 0,import.meta.url).then(({api:Le})=>Promise.all([Le.engineSetup("ready","claude"),Le.engineSetup("ready","codex")])).then(Le=>Le.map(Ye=>({engine:Ye.engine,found:!!Ye.found,signedIn:!!Ye.signedIn}))).catch(()=>[])),z.current);g.useEffect(()=>{e.step==="welcome"&&xe()},[e.step]);const[Oe,F]=g.useState(null),J=async()=>{Tk(await xe())?(F(null),x("plan")):b({t:"start"})},[ze,ye]=g.useState(()=>Date.now()),[Z,Ce]=g.useState(!1);g.useEffect(()=>{const be=()=>{const Le=document.activeElement;Ce(!!Le&&typeof Le.closest=="function"&&!!Le.closest(".focus-dock"))};return be(),window.addEventListener("focusin",be),window.addEventListener("focusout",be),()=>{window.removeEventListener("focusin",be),window.removeEventListener("focusout",be)}},[]);const[Ee,oe]=g.useState(null),[ne,Ie]=g.useState(0),[Q,he]=g.useState(null),te=be=>{const Le=aie(be);Le&&x(Le)};g.useEffect(()=>{if(e.step!=="working")return;const be=setInterval(()=>ye(Date.now()),1e3);return()=>clearInterval(be)},[e.step]),g.useEffect(()=>{var be;e.step==="name"&&((be=H.current)==null||be.focus())},[e.step]);const ee=poe(e.step),U=die(Ee);g.useEffect(()=>{if(e.step!=="command"&&e.step!=="done"||!U)return;let be=!0;return(async()=>{const{api:Le}=await ms(async()=>{const{api:Ge}=await Promise.resolve().then(()=>Ji);return{api:Ge}},void 0,import.meta.url),Ye=await Le.agentFiles({folder:e.folder,product:e.product});if(!be)return;const at={user:Ye.user,project:Ye.project};fie(Ee,at)&&oe(at)})(),()=>{be=!1}},[e.step,e.folder,e.product,Ee,U,ne]),g.useEffect(()=>{if(e.step!=="done"||Q)return;let be=!0;return(async()=>{const{api:Le}=await ms(async()=>{const{api:at}=await Promise.resolve().then(()=>Ji);return{api:at}},void 0,import.meta.url);let Ye=[];try{Ye=await Le.agentFolders()}catch{Ye=[]}be&&he(Ye)})(),()=>{be=!1}},[e.step,Q]),g.useEffect(()=>{if(e.step!=="welcome")return;const be=Le=>{Le.key==="Enter"&&(Le.preventDefault(),J())};return window.addEventListener("keydown",be),()=>window.removeEventListener("keydown",be)},[e.step,b]);const I=(j==null?void 0:j.length)??0;g.useEffect(()=>{if(e.step!=="folder"||j===null)return;const be=Ye=>{if(Ye.key==="ArrowDown"&&(Ye.preventDefault(),E(at=>Math.min(I+1,at+1))),Ye.key==="ArrowUp"&&(Ye.preventDefault(),E(at=>Math.max(0,at-1))),Ye.key==="Enter"&&me>I){Ye.preventDefault(),ue();return}if(Ye.key==="Enter"&&me<0){Ye.preventDefault();return}Ye.key==="Enter"&&(Ye.preventDefault(),me<I&&j[me]?G(j[me].folder):V())},Le=setTimeout(()=>window.addEventListener("keydown",be),0);return()=>{clearTimeout(Le),window.removeEventListener("keydown",be)}});const V=async()=>{const{api:be}=await ms(async()=>{const{api:Ge}=await Promise.resolve().then(()=>Ji);return{api:Ge}},void 0,import.meta.url),{path:Le,refused:Ye,browse:at}=await be.chooseFolder(e.folder??void 0);if(at){W(null),ge(!0);return}if(Ye){W(Ye);return}Le&&G(Le)},ue=()=>{W(null),b({t:"noFolder"}),x("name")},G=be=>{W(null),b({t:"folder",path:be}),x("name")},ie=async()=>{if(!(!e.name.trim()||_)){Y(!0),re(null);try{const be=await v({name:e.name.trim(),folder:e.folder});be&&re(be)}finally{Y(!1)}}},we=lie[e.step];if(we!=null){const be=_e.intro[we];return l.jsx(Oce,{head:be.head,line:be.line,piece:be.piece,onNext:()=>te(e.step)})}if(e.step==="hand")return l.jsx(Lce,{head:_e.handHead,line:_e.handLine,go:_e.handGo,onNext:S,skip:_e.handSkip,onSkip:M});if(_O.includes(e.step)){const be=e.step==="where"&&typeof document<"u"&&!!document.querySelector(".th-bar .tm-tabs"),Le=zO(e.step,e.sentAt?ze-e.sentAt:0,{opened:r,view:d,picking:i,palette:a,board:c,replying:!!u||Z,left:p==null?void 0:p.length,tabs:h,replies:e.replies,tabNames:be?Ooe:void 0});if(!Le)return null;const Ye=(e.step==="working"||e.step==="open")&&e.item,at=e.step==="where"?Ch(h,d):null,Ge=e.step==="clear"?(p==null?void 0:p[0])??null:null,Ke=Ye?[`.list-pane .row[data-item-id="${e.item}"]`,...Ui[e.step]??[]]:e.step==="board"&&c?[".th-board",...Ui.board??[]]:Ge?[`.list-pane .row[data-item-id="${Ge}"]`,...Ui.clear??[]]:e.step==="unblock"&&s&&!r?[`.list-pane .row[data-item-id="${s}"]`,...Ui.unblock??[]]:e.step==="snooze"&&o&&!i?[`.list-pane .row[data-item-id="${o}"]`,...Ui.snooze??[]]:at?[...nE(at)?[nE(at)]:[],`.workspace-navigation [data-tab="${at}"]`,`.tabs .tab[data-tab="${at}"]`,...Ui.where??[]]:Ui[e.step];return!Ke||!Ke.length?null:l.jsx(Ace,{selector:Ke,beside:e.step==="where"&&!be||e.step==="tabs"||e.step==="command"&&!!a||e.step==="answer",besideRing:e.step==="command"&&!!a||e.step==="answer",besideOf:e.step==="tabs"?".th-bar .tm-tabs, .workspace-navigation, .tabs":e.step==="where"?".workspace-navigation, .tabs":void 0,boundsSel:eie[e.step],underSel:e.step==="snooze"&&i?".modal.snooze":oE[e.step],makesRoom:(e.step==="clear"||e.step==="snooze"&&!i)&&!!oE[e.step],say:Le,beat:p,pointed:m,hold:ep(e),also:_oe[e.step],onNext:Le.next?()=>te(e.step):Le.anyKey?R:void 0,onSkip:L})}if(e.step==="done")return l.jsx(Tce,{found:Ee,folders:Q,claude:t,products:gce(f,e),project:e.product,onDone:C,onFiled:O,onProjectMade:N,onRecheck:async()=>{const be=P?await P():!0;return be||(oe(Le=>hie(Le,be)),he(Le=>pie(Le,be)),Ie(Le=>Le+1)),be}});if(e.step==="landed")return null;const ve=e.folder?LO(e.folder,n):null,de=ee&&l.jsx("button",{type:"button",className:"back-esc fr-back",onClick:()=>x(ee),"aria-label":_e.back,title:_e.back,children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5"})})});return l.jsxs("div",{className:de?"fr-screen has-back":"fr-screen",children:[de,l.jsxs("div",{className:"fr-brand",children:[l.jsx(vi,{size:22}),Je]}),e.step==="welcome"&&l.jsxs("div",{className:"fr-corner",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"fr-head",children:_e.head}),l.jsx("p",{className:"fr-sub",children:_e.headSub})]}),l.jsxs("button",{className:"fr-go",onClick:()=>void J(),children:[_e.getStarted," ",l.jsx(ko,{cap:"↵"})]})]}),e.step==="plan"&&!Oe&&l.jsx(fce,{onPick:F,onReady:()=>x("folder"),look:xe}),e.step==="plan"&&Oe&&l.jsx(fL,{plan:Oe,onDone:()=>x("folder"),onSkip:()=>x("folder")}),le&&l.jsx(DO,{startIn:e.folder??null,onPick:be=>{ge(!1),G(be)},onClose:()=>ge(!1)}),e.step==="folder"&&l.jsxs("div",{className:"fr-stack fr-stack-folders",children:[l.jsx("h1",{className:"fr-page",children:_e.folderHead}),l.jsx("p",{className:"fr-lede",children:_e.folderLede}),l.jsxs("div",{className:"fr-card fr-folders",role:"listbox","aria-label":_e.folderHead,children:[j&&j.length>0&&l.jsx("div",{className:"fr-folders-label",children:_e.folderRecent}),(j??[]).map((be,Le)=>l.jsxs("button",{type:"button",role:"option","aria-selected":me===Le,className:`fr-folder${me===Le?" lit":""}${e.folder===be.folder?" on":""}`,onMouseEnter:()=>E(Le),onClick:()=>G(be.folder),children:[l.jsx("span",{className:"fr-fold",children:l.jsx(yce,{})}),l.jsx("span",{className:"fr-folder-name",children:be.name}),l.jsx("span",{className:"fr-folder-path",children:be.short}),l.jsx("span",{className:"fr-folder-via"}),l.jsx("span",{className:"fr-folder-key",children:me===Le&&l.jsx(ko,{cap:"↵"})})]},be.folder)),l.jsxs("button",{type:"button",role:"option","aria-selected":me===((j==null?void 0:j.length)??0),className:`fr-folder fr-folder-other${me===((j==null?void 0:j.length)??0)?" lit":""}`,onMouseEnter:()=>E((j==null?void 0:j.length)??0),onClick:V,children:[l.jsx("span",{className:"fr-fold",children:l.jsx(wce,{})}),l.jsx("span",{className:"fr-folder-name",children:j&&j.length?_e.folderOther:_e.folderFirst}),l.jsx("span",{className:"fr-folder-key",children:me===((j==null?void 0:j.length)??0)&&l.jsx(ko,{cap:"↵"})})]}),l.jsxs("button",{type:"button",role:"option","aria-selected":me===((j==null?void 0:j.length)??0)+1,className:`fr-folder fr-folder-other fr-folder-none${me===((j==null?void 0:j.length)??0)+1?" lit":""}`,onMouseEnter:()=>E(((j==null?void 0:j.length)??0)+1),onClick:ue,children:[l.jsx("span",{className:"fr-fold",children:l.jsx(bce,{})}),l.jsx("span",{className:"fr-folder-name",children:_e.folderNone}),l.jsx("span",{className:"fr-folder-key",children:me===((j==null?void 0:j.length)??0)+1&&l.jsx(ko,{cap:"↵"})})]})]}),T?l.jsx("p",{className:"fr-note fr-refused",children:T}):DE(w??{})&&l.jsx("p",{className:"fr-note",children:DE(w??{})})]}),e.step==="name"&&l.jsxs("div",{className:"fr-stack fr-stack-folders",children:[l.jsx("h1",{className:"fr-page",children:_e.nameQ}),ve?l.jsxs("p",{className:"fr-lede",children:[_e.nameIn," ",l.jsx("span",{className:"fr-lede-path",children:ve}),"."," ",l.jsx("button",{type:"button",className:"fr-lede-link",onClick:()=>x("folder"),children:_e.nameChange})]}):l.jsxs("p",{className:"fr-lede",children:[_e.nameInNone," ",l.jsx("button",{type:"button",className:"fr-lede-link",onClick:()=>x("folder"),children:_e.nameChoose})]}),l.jsxs("div",{className:"fr-card fr-name-card",children:[l.jsx("input",{ref:H,className:"fr-name",value:e.name,spellCheck:!1,onChange:be=>{re(null),b({t:"name",name:be.target.value})},onFocus:be=>be.currentTarget.select(),onKeyDown:be=>{be.key==="Enter"&&(be.preventDefault(),ie())}}),l.jsxs("button",{className:"fr-submit",onClick:ie,disabled:!e.name.trim()||_,children:[_e.nameGo," ",l.jsx(ko,{cap:"↵"})]})]}),se&&l.jsx("p",{className:"fr-note fr-notmade",role:"alert",children:se})]})]})}const Pce=["a","b","e"];function zce(e){return e&&Pce.includes(e)?e:null}const ho={page:"What may your agents do?",q:"While you are not watching.",note:"You can change this any time, for everything or for one message.",rules:pw,finishQ:"What your agents may do.",tick:"Recommended"};function Fce({modes:e,value:t,onPick:n}){return l.jsx("div",{className:"fr-list fr-modes",children:e.map(r=>l.jsxs("button",{className:r===t?"fr-agent fr-mode on":"fr-agent fr-mode",onClick:()=>n(r),children:[l.jsx("span",{className:"fr-tick",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M4 12.5 9.5 18 20 6.5"})})}),l.jsxs("span",{className:"grow",children:[l.jsx("span",{className:"fr-agent-name",children:sa[r]}),l.jsx("span",{className:"fr-agent-line",children:nf[r]})]})]},r))})}function Bce({variant:e,value:t,onPick:n}){return l.jsxs("div",{className:"fr-screen",children:[l.jsxs("div",{className:"fr-brand",children:[l.jsx(vi,{size:22}),Je]}),e==="a"&&l.jsxs("div",{className:"fr-stack",children:[l.jsx("h1",{className:"fr-page",children:ho.page}),l.jsxs("div",{className:"fr-card",children:[l.jsx("div",{className:"fr-q",children:ho.q}),l.jsx(Fce,{modes:fa,value:t,onPick:n}),l.jsx("button",{className:"fr-submit",children:_e.submit})]}),l.jsx("p",{className:"fr-note",children:ho.note}),l.jsx("p",{className:"fr-note",style:{marginTop:6},children:ho.rules})]}),e==="b"&&l.jsxs("div",{className:"fr-stack",children:[l.jsx("h1",{className:"fr-page",children:ho.page}),l.jsxs("div",{className:"fr-card",children:[l.jsxs("div",{className:"fr-switch",children:[l.jsxs("button",{className:t==="bypassPermissions"?"fr-side":"fr-side on",onClick:()=>n("auto"),children:[sa.auto,l.jsx("span",{className:"fr-side-n",children:ho.tick})]}),l.jsx("button",{className:t==="bypassPermissions"?"fr-side on":"fr-side",onClick:()=>n("bypassPermissions"),children:sa.bypassPermissions})]}),l.jsx("p",{className:"fr-q",style:{padding:"12px 18px 16px"},children:nf[t==="bypassPermissions"?"bypassPermissions":"auto"]}),l.jsx("button",{className:"fr-submit",children:_e.submit})]}),l.jsx("p",{className:"fr-note",children:"Manual, Accept edits, Plan and Don't ask are in Settings, with everything else."}),l.jsx("p",{className:"fr-note",style:{marginTop:6},children:ho.rules})]}),e==="e"&&l.jsx(l.Fragment,{children:l.jsxs("div",{className:"fr-finish wide",role:"status",children:[l.jsx("h1",{className:"fr-finish-head",children:_e.finishHead}),l.jsx("p",{className:"fr-finish-line",children:_e.finishLine}),l.jsxs("div",{className:"fr-offer",children:[l.jsx("div",{className:"fr-offer-say",children:ho.finishQ}),l.jsxs("div",{className:"fr-switch",role:"tablist",children:[l.jsx("button",{role:"tab","aria-selected":t!=="bypassPermissions",className:t==="bypassPermissions"?"fr-side":"fr-side on",onClick:()=>n("auto"),children:sa.auto}),l.jsx("button",{role:"tab","aria-selected":t==="bypassPermissions",className:t==="bypassPermissions"?"fr-side on":"fr-side",onClick:()=>n("bypassPermissions"),children:sa.bypassPermissions})]}),l.jsxs("p",{className:"fr-offer-read",children:[nf[t==="bypassPermissions"?"bypassPermissions":"auto"]," ",ho.rules]})]}),l.jsxs("div",{className:"fr-offer",children:[l.jsx("div",{className:"fr-offer-say",children:_e.agentsOffer}),l.jsxs("div",{className:"fr-switch",role:"tablist",children:[l.jsxs("button",{role:"tab","aria-selected":!0,className:"fr-side on",children:[_e.agentsAll,l.jsx("span",{className:"fr-side-n",children:"3"})]}),l.jsxs("button",{role:"tab","aria-selected":!1,className:"fr-side",children:[_e.agentsHere,l.jsx("span",{className:"fr-side-n",children:"0"})]})]}),l.jsx("div",{className:"fr-list",children:[["Leon Okafor QA",`QA agent that embodies the persona of Leon Okafor, a founder being onboarded to ${Je}.`],["Localhost QA","Validate frontend changes against the running app."],["Docs Reviewer","Review developer documentation for accuracy against the codebase."]].map(([r,s])=>l.jsxs("button",{className:"fr-agent on",children:[l.jsx("span",{className:"fr-tick",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"M4 12.5 9.5 18 20 6.5"})})}),l.jsxs("span",{className:"grow",children:[l.jsx("span",{className:"fr-agent-name",children:r}),l.jsx("span",{className:"fr-agent-line",children:s})]})]},r))}),l.jsx("p",{className:"fr-offer-read",children:_e.agentsRead})]}),l.jsx("button",{className:"fr-finish-go",children:_e.finishGo})]})})]})}function _ce(e,t){return!e||e.step!=="answer"||t?null:e.item??"no-task"}function Wce(e,t){return!!t&&e!==t}function Hce({onStart:e,onNot:t}){const n=g.useRef(null);return g.useEffect(()=>{const r=s=>{s.key!=="Escape"||s.metaKey||s.ctrlKey||s.altKey||(s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),t())};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[t]),g.useEffect(()=>{const r=setTimeout(()=>{var s;return(s=n.current)==null?void 0:s.focus()},0);return()=>clearTimeout(r)},[]),l.jsx("div",{className:"fr-stay-scrim",role:"dialog","aria-modal":"true","aria-label":_e.offerHead,children:l.jsxs("div",{className:"fr-stay",children:[l.jsx("div",{className:"fr-stay-head",children:_e.offerHead}),l.jsx("div",{className:"fr-stay-line",children:_e.offerLine}),l.jsxs("div",{className:"fr-stay-row",children:[l.jsx("button",{ref:n,type:"button",className:"fr-stay-go",onClick:e,children:_e.offerGo}),l.jsx("button",{type:"button",className:"fr-stay-keep",onClick:t,children:_e.offerNot})]})]})})}const mL="zero.stoppedWarned",Uce={E:"marking it done",L:"putting it off"};function Kce(e){return`This agent is waiting on your answer, and ${Uce[e]} leaves it stuck. Press again to go ahead.`}function Vce(e){try{return e.getItem(mL)!=="1"}catch{return!1}}function qce(e){try{e.setItem(mL,"1")}catch{}}function Yce(e){return e.agent?Ap(e.agent):Fb(e)}function Gce(e){if(e.warned||e.walking)return null;const t=e.rows.find(Yce);return t?{say:Kce(e.key),goes:{product:t.product,id:t.id}}:null}const gL="zero.tutorial.offered";function Jce(e){try{return e.getItem(gL)!=="1"}catch{return!1}}function yy(e){try{e.setItem(gL,"1")}catch{}}function Xce(e){return e.made&&!e.walking&&!e.offered}function Qce(e,...t){for(const n of t){if(!n)continue;const r=e.find(s=>s.slug===n);if(r&&r.practice!==!0)return r.slug}return null}const wy=e=>`${e.product}/${e.id}`;function Zce(e,t){if(!t.length)return e;const n=new Map(t.map(s=>[wy(s),s]));return[...e.map(s=>{const o=n.get(wy(s));return o?(n.delete(wy(s)),o.createdAt!==s.createdAt&&o.updatedAt>=s.updatedAt?o:s):s}),...n.values()]}const eue={project:null,priority:null,harness:null},FE=["claude","codex"],tue=new Set(["codex","codex-import","not-imported"]);function yL(e){return e.engine==="codex"||(e.labels??[]).some(t=>tue.has(t)||t.startsWith("codex:"))?"codex":"claude"}function nue(e,t,n){return n==="project"?!t.project||e.product===t.project:n==="priority"?!t.priority||kr(e.priority)===t.priority:!t.harness||yL(e)===t.harness}const wL=["project","priority","harness"];function bL(e,t,n){return wL.every(r=>r===n||nue(e,t,r))}function xL(e){return wL.some(t=>e[t]!==null)}function BE(e,t){return xL(t)?e.filter(n=>pn(n)||nr(n)||bL(n,t)):e}const by=(e,t)=>{var n;return((n=t.find(r=>r.slug===e))==null?void 0:n.name)??e},xy=5;function rue(e,t,n){const r=(m,w)=>{const b=new Map;for(const x of e)bL(x,t,m)&&b.set(w(x),(b.get(w(x))??0)+1);return b},s=r("project",m=>m.product);s.delete(""),t.project&&!s.has(t.project)&&s.set(t.project,0);const o=[...s.entries()].sort((m,w)=>w[1]-m[1]||by(m[0],n).localeCompare(by(w[0],n))).map(([m,w])=>({value:m,label:by(m,n),count:w,on:m===t.project}));let i=o.slice(0,xy),a=o.slice(xy);const c=a.find(m=>m.on);c&&(i=[...i.slice(0,xy-1),c],a=o.filter(m=>!i.includes(m)));const u=r("priority",m=>kr(m.priority)),d=wr.map(m=>({value:m.id,label:m.label,count:u.get(m.id)??0,on:t.priority===m.id})),h=r("harness",yL),p=FE.every(m=>(h.get(m)??0)>0)||t.harness?FE.map(m=>({value:m,label:Db(m),count:h.get(m)??0,on:t.harness===m})):[];return{projects:i,moreProjects:a,priorities:d,harnesses:p}}const sue=["","one","two","three","four","five","six","seven","eight","nine"],_E=e=>sue[e]??String(e);function ky(e){if(e<=0)return null;if(e===1)return{ask:"Before this closes: one task it filed has not started.",options:[{n:1,text:"Approve it, then close",recommended:!0,act:"start"},{n:2,text:"Drop it, then close",recommended:!1,act:"drop"}]};const t=e===2?"both":`all ${_E(e)}`;return{ask:`Before this closes: ${_E(e)} tasks it filed have not started.`,options:[{n:1,text:"Decide each one",recommended:!0,act:"decide"},{n:2,text:`Start ${t}, then close`,recommended:!1,act:"start"},{n:3,text:`Drop ${t}, then close`,recommended:!1,act:"drop"}]}}const oue="Keep this thread open";function WE(e,t){return e?!e.has(t):!1}function HE({team:e,inviteFocus:t=!1}){return e!=null&&e.configured?e.signedIn?l.jsx(aue,{team:e,inviteFocus:t}):l.jsx(iue,{error:e.error}):l.jsxs("div",{className:"tm-setup",children:[l.jsx("h2",{children:"Teams are not set up in this build"}),l.jsx("p",{children:"This copy of the app has no team cloud configured."})]})}function kL(){const[e,t]=g.useState(!1),[n,r]=g.useState(null);return{busy:e,error:n,run:async o=>{t(!0),r(null);const i=await o();return t(!1),i.ok||r(i.error??"That did not work."),i.ok}}}function iue({error:e}){const{busy:t,error:n,run:r}=kL();return l.jsxs("div",{className:"tm-setup",children:[l.jsx("h2",{children:"Sign in to see your team"}),l.jsx("p",{children:"Your team sees a short summary of each of your threads, unless you mark one private. Signing in opens Google in your browser."}),l.jsx("div",{className:"tm-field-row",children:l.jsx("button",{className:"tm-btn",disabled:t,onClick:()=>r(()=>q.teamSignIn()),children:t?"Waiting for Google…":"Sign in with Google"})}),(n||e)&&l.jsx("p",{className:"tm-error",children:n||e})]})}function aue({team:e,onDone:t,inviteFocus:n=!1}){const[r,s]=g.useState(""),[o,i]=g.useState(""),[a,c]=g.useState([]),[u,d]=g.useState([]),{busy:h,error:f,run:p}=kL(),m=e.me,w=(e.invites??[]).find(b=>!u.includes(b.teamId));return l.jsxs("div",{className:"tm-setup",children:[l.jsxs("div",{className:"tm-signed",children:[m&&l.jsx(Rt,{person:m,me:!0}),l.jsxs("span",{children:["Signed in as ",m==null?void 0:m.email]}),l.jsx("button",{className:"tm-btn",disabled:h,onClick:()=>p(()=>q.teamSignOut()),children:"Sign out"})]}),!e.team&&w?l.jsxs(l.Fragment,{children:[l.jsxs("h2",{children:[w.invitedByName?`${w.invitedByName.split(/\s+/)[0]} invited you to ${w.teamName}.`:`You are invited to ${w.teamName}.`," Join?"]}),l.jsxs("div",{className:"tm-field-row",children:[l.jsx("button",{className:"tm-btn",disabled:h,onClick:()=>p(()=>q.teamAcceptInvite(w.teamId)),children:"Join"}),l.jsx("button",{className:"tm-btn",disabled:h,onClick:()=>d([...u,w.teamId]),children:"Not now"})]})]}):e.team?l.jsx(lue,{team:e,me:m,inviteFocus:n,invited:a,setInvited:c,email:o,setEmail:i,busy:h,run:p,onDone:t}):l.jsxs(l.Fragment,{children:[l.jsx("h2",{children:"Start your team"}),l.jsx("p",{children:"Name it, then invite people by email. Anyone you invite is asked to join when they sign in with that email."}),l.jsxs("form",{className:"tm-field-row",onSubmit:b=>{b.preventDefault(),p(()=>q.teamCreate(r))},children:[l.jsx("input",{className:"tm-input",placeholder:"Team name",value:r,onChange:b=>s(b.target.value)}),l.jsx("button",{className:"tm-btn",disabled:h||!r.trim(),children:"Start team"})]}),l.jsxs("p",{children:["Waiting for an invite instead? Ask a teammate to invite ",m==null?void 0:m.email,". It shows up here within a few seconds."]})]}),f&&l.jsx("p",{className:"tm-error",children:f})]})}function lue({team:e,me:t,inviteFocus:n,invited:r,setInvited:s,email:o,setEmail:i,busy:a,run:c,onDone:u}){var C,O;const d=((C=e.team)==null?void 0:C.name)??"",[h,f]=g.useState(d),[p,m]=g.useState(!1),w=((O=e.people.find(N=>N.id===(t==null?void 0:t.id)))==null?void 0:O.role)==="owner",x=[e.people.find(N=>N.id===(t==null?void 0:t.id))??t,...e.people.filter(N=>N.id!==(t==null?void 0:t.id))].filter(N=>!!N),v=N=>e.people.some(P=>{var M;return((M=P.email)==null?void 0:M.toLowerCase())===N.toLowerCase()}),S=[...new Set([...(e.sent??[]).map(N=>N.email),...r])].filter(N=>!v(N));return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"tm-section",children:"Team name"}),w?l.jsxs("form",{className:"tm-field-row",onSubmit:N=>{N.preventDefault(),c(()=>q.teamRename(h))},children:[l.jsx("input",{className:"tm-input",value:h,"aria-label":"Team name",onChange:N=>f(N.target.value)}),l.jsx("button",{className:"tm-btn",disabled:a||!h.trim()||h.trim()===d,children:"Rename"})]}):l.jsx("h2",{children:d}),l.jsx("div",{className:"tm-section",children:"People"}),x.map(N=>l.jsxs("div",{className:"tm-person-line",children:[l.jsx(Rt,{person:N,me:N.id===(t==null?void 0:t.id)}),N.id===(t==null?void 0:t.id)?"You":N.name,l.jsx("small",{children:N.role==="owner"?`${N.email} · owner`:N.email}),w&&N.id!==(t==null?void 0:t.id)&&l.jsx("button",{type:"button",className:"tm-line-act",disabled:a,onClick:()=>void c(()=>q.teamRemoveMember(N.id)),children:"Remove"})]},N.id)),S.map(N=>l.jsxs("div",{className:"tm-person-line tm-invited",children:[l.jsx("span",{className:"tm-av tm-av-empty","aria-hidden":"true"}),N,l.jsx("small",{children:"Invited. They join when they sign in with this email."}),(w||r.includes(N))&&l.jsx("button",{type:"button",className:"tm-line-act",disabled:a,onClick:async()=>{await c(()=>q.teamCancelInvite(N))&&s(P=>P.filter(M=>M!==N))},children:"Cancel"})]},N)),l.jsx("div",{className:"tm-section",children:"Invite people"}),l.jsxs("form",{className:"tm-field-row",onSubmit:async N=>{N.preventDefault();const P=o.trim();await c(()=>q.teamInvite(P))&&(i(""),s(M=>[...M.filter(R=>R!==P),P]))},children:[l.jsx("input",{className:"tm-input",placeholder:"Their email",value:o,autoFocus:n,onChange:N=>i(N.target.value)}),l.jsx("button",{className:"tm-btn",disabled:a||!o.trim(),children:"Invite"})]}),l.jsx("div",{className:"tm-section",children:"Leave"}),p?l.jsxs("div",{className:"tm-field-row",children:[l.jsxs("span",{className:"tm-leave-ask",children:["Leave ",d,"? Your threads stay on this computer; the team stops seeing them."]}),l.jsx("button",{type:"button",className:"tm-btn",disabled:a,onClick:()=>void c(()=>q.teamLeave()),children:"Leave"}),l.jsx("button",{type:"button",className:"tm-btn",onClick:()=>m(!1),children:"Stay"})]}):l.jsx("div",{className:"tm-field-row",children:l.jsxs("button",{type:"button",className:"tm-btn",onClick:()=>m(!0),children:["Leave ",d]})}),u&&l.jsx("div",{className:"tm-field-row",style:{marginTop:22},children:l.jsx("button",{className:"tm-btn",onClick:u,children:"Done"})})]})}function vL(e,t,n){const{who:r,people:s}=Mo(e);if(r==="private")return{who:r,short:"Just you",long:"Just you"};if(r==="people"){const o=hw(s,s.map(i=>t.get(i)).filter(i=>!!i));return{who:r,short:o,long:o}}return{who:r,short:"Team",long:n?`${n} team`:"Team"}}function Rb(){return l.jsxs("svg",{width:"15",height:"13",viewBox:"2 4 20 17",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[l.jsx("circle",{cx:"9",cy:"9",r:"3.2"}),l.jsx("path",{d:"M3 19.5c.6-3.2 3-5 6-5s5.4 1.8 6 5"}),l.jsx("path",{d:"M15.5 6.2a3 3 0 0 1 0 5.6M17.5 14.8c1.8.6 3 2.1 3.4 4.7"})]})}function cue({product:e}){var r;const t=g.useContext(Xt);if(!t)return null;const n=vL(e,t.byId,((r=t.state.team)==null?void 0:r.name)??null);return l.jsxs(l.Fragment,{children:[n.who==="private"?l.jsx(Wh,{}):l.jsx(Rb,{}),n.short]})}const uue=()=>l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:l.jsx("path",{d:"m6 9 6 6 6-6"})});function due({product:e,onChange:t}){var b;const n=g.useContext(Xt),[r,s]=g.useState(!1),[o,i]=g.useState("rows"),[a,c]=g.useState(()=>Mo(e).people),u=g.useRef(null);if(g.useEffect(()=>{if(!r)return;const x=S=>{var C;(C=u.current)!=null&&C.contains(S.target)||s(!1)},v=S=>{S.key==="Escape"&&(S.preventDefault(),S.stopImmediatePropagation(),s(!1))};return document.addEventListener("pointerdown",x),window.addEventListener("keydown",v,!0),()=>{document.removeEventListener("pointerdown",x),window.removeEventListener("keydown",v,!0)}},[r]),!n)return null;const d=((b=n.state.team)==null?void 0:b.name)??null,h=vL(e,n.byId,d),f=e.personal===!0,p=vx(n.state.people??[],n.me),m=(x,v)=>{s(!1),i("rows"),t(x,v)},w=(x,v,S)=>l.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":h.who===x,className:`tc-row tc-two${h.who===x?" on":""}`,onClick:()=>x==="people"?i("people"):m(x),children:[x==="private"?l.jsx(Wh,{}):l.jsx(Rb,{}),l.jsxs("span",{className:"tc-row-label",children:[v,l.jsx("small",{children:S})]})]},x);return l.jsxs("span",{className:"ps-anchor",ref:u,children:[l.jsxs("button",{type:"button",className:"set-ghost ps-btn",disabled:f,"aria-haspopup":f?void 0:"menu","aria-expanded":f?void 0:r,title:f?"My Workspace is always just you":"Who sees this project’s threads",onClick:()=>{c(Mo(e).people),i("rows"),s(x=>!x)},children:[h.who==="private"?l.jsx(Wh,{}):l.jsx(Rb,{}),l.jsx("span",{children:h.long}),!f&&l.jsx(uue,{})]}),r&&!f&&l.jsx("div",{className:"ps-menu",role:"menu","aria-label":`Who sees ${e.name}`,children:o==="rows"?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"tc-menu-head",children:["Who sees ",e.name]}),w("private","Just you","Only you see its threads."),w("team",d?`${d} team`:"Team","Everyone on the team sees its threads."),w("people","Chosen people","Only the people you pick see them.")]}):l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"tc-menu-head",children:["Who sees ",e.name]}),p.length?p.map(x=>{const v=a.includes(x.id);return l.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":v,className:`tc-row${v?" on":""}`,onClick:()=>c(S=>v?S.filter(C=>C!==x.id):[...S,x.id]),children:[l.jsx("span",{className:`ps-tick${v?" on":""}`,"aria-hidden":"true",children:v&&l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M3.8 8.4 6.6 11.2 12.2 5"})})}),l.jsx("span",{className:"tc-row-label",children:x.name})]},x.id)}):l.jsx("span",{className:"tc-none",children:"Nobody else is on the team yet."}),l.jsxs("span",{className:"ps-foot",children:[l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>i("rows"),children:"Back"}),l.jsx("button",{type:"button",className:"set-ghost",onClick:()=>m(a.length?"people":"private",a),children:"Done"})]})]})})]})}const UE=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 48 48","aria-hidden":"true",children:[l.jsx("path",{fill:"#FFC107",d:"M43.6 20.5H42V20H24v8h11.3C33.7 32.7 29.2 36 24 36c-6.6 0-12-5.4-12-12s5.4-12 12-12c3.1 0 5.8 1.2 7.9 3.1l5.7-5.7C34 6.1 29.3 4 24 4 12.9 4 4 12.9 4 24s8.9 20 20 20 20-8.9 20-20c0-1.3-.1-2.4-.4-3.5z"}),l.jsx("path",{fill:"#FF3D00",d:"m6.3 14.7 6.6 4.8C14.7 15.1 19 12 24 12c3.1 0 5.8 1.2 7.9 3.1l5.7-5.7C34 6.1 29.3 4 24 4 16.3 4 9.7 8.3 6.3 14.7z"}),l.jsx("path",{fill:"#4CAF50",d:"M24 44c5.2 0 9.9-2 13.4-5.2l-6.2-5.2C29.2 35.1 26.7 36 24 36c-5.2 0-9.6-3.3-11.3-8l-6.5 5C9.5 39.6 16.2 44 24 44z"}),l.jsx("path",{fill:"#1976D2",d:"M43.6 20.5H42V20H24v8h11.3c-.8 2.2-2.2 4.2-4.1 5.6l6.2 5.2C37 39.2 44 34 44 24c0-1.3-.1-2.4-.4-3.5z"})]});function hue({signedOut:e=!1,error:t=null,waitingUrl:n=null}){const[r,s]=g.useState("sign-in"),[o,i]=g.useState(""),[a,c]=g.useState(""),[u,d]=g.useState(""),[h,f]=g.useState(null),[p,m]=g.useState(null),w=g.useRef(null);g.useEffect(()=>{var R;(R=w.current)==null||R.focus()},[r]);const[b,x]=g.useState(!1),v=async()=>{f("google"),m(null),x(!1);const R=await q.teamSignIn();f(null),!R.ok&&!/cancelled/i.test(R.error??"")&&m(R.error??"Google sign-in did not finish.")},S=h==="google"||!!n,C=async()=>{if(n)try{await navigator.clipboard.writeText(n),x(!0),m(null)}catch{m("Could not copy the link.")}};if(S)return l.jsx("div",{className:"si-page",role:"dialog","aria-modal":"true","aria-label":"Finish signing in in your browser",children:l.jsxs("div",{className:"si-card",children:[l.jsx("span",{className:"si-mark",children:l.jsx(vi,{size:40})}),l.jsx("h1",{children:"Finish in your browser"}),l.jsx("p",{className:"si-lede",children:n?`Google sign-in is open in your default browser. Pick your account there and ${st} carries on by itself.`:"Opening Google sign-in in your browser…"}),l.jsxs("button",{type:"button",className:"si-google",disabled:!n,onClick:()=>{m(null),q.teamSignInReopen()},children:[l.jsx(UE,{}),"Open the sign-in page again"]}),l.jsxs("div",{className:"si-wait-row",children:[l.jsx("button",{type:"button",disabled:!n,onClick:C,children:b?"Link copied":"Copy the link"}),l.jsx("button",{type:"button",onClick:()=>{q.teamSignInCancel(),f(null),m(null)},children:"Cancel"})]}),p&&l.jsx("p",{className:"si-error",role:"alert",children:p})]})});const O=async R=>{if(R.preventDefault(),h)return;f("email"),m(null);const L=r==="sign-up"?await q.teamSignUp(o,a,u):await q.teamSignInEmail(a,u);if(f(null),!L.ok){m(L.error??"That did not work. Try again.");return}L.confirm&&s("check-email")},N=r==="sign-up"?"Create your account":r==="check-email"?"Check your email":e?"You are signed out":`Sign in to ${st}`,P=r==="sign-up"?"Your teammates will see this name beside your threads and messages.":r==="check-email"?`We sent a link to ${a}. Follow it to confirm your address, then sign in here.`:e?"Sign in again to get back to your inbox and your team.":"Your threads, your agents and your team, in one inbox.",M=!!a.trim()&&!!u&&(r!=="sign-up"||!!o.trim());return l.jsx("div",{className:"si-page",role:"dialog","aria-modal":"true","aria-label":N,children:l.jsxs("div",{className:"si-card",children:[l.jsx("span",{className:"si-mark",children:l.jsx(vi,{size:40})}),l.jsx("h1",{children:N}),l.jsx("p",{className:"si-lede",children:P}),r==="check-email"?l.jsx("button",{type:"button",className:"si-primary",onClick:()=>{s("sign-in"),d("")},children:"Back to sign in"}):l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:"si-google",disabled:!!h,onClick:v,children:[l.jsx(UE,{}),"Continue with Google"]}),l.jsx("div",{className:"si-or",children:l.jsx("span",{children:"or"})}),l.jsxs("form",{className:"si-form",onSubmit:O,children:[r==="sign-up"&&l.jsxs("label",{children:[l.jsx("span",{children:"Name"}),l.jsx("input",{ref:w,value:o,autoComplete:"name",onChange:R=>i(R.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"Email"}),l.jsx("input",{ref:r==="sign-in"?w:void 0,type:"email",value:a,autoComplete:"email",onChange:R=>c(R.target.value)})]}),l.jsxs("label",{children:[l.jsx("span",{children:"Password"}),l.jsx("input",{type:"password",value:u,autoComplete:r==="sign-up"?"new-password":"current-password",onChange:R=>d(R.target.value)})]}),l.jsx("button",{type:"submit",className:"si-primary",disabled:!M||!!h,children:h==="email"?r==="sign-up"?"Creating…":"Signing in…":r==="sign-up"?"Create account":"Sign in"})]})]}),(p||t&&r==="sign-in"&&!e)&&l.jsx("p",{className:"si-error",role:"alert",children:p||t}),r!=="check-email"&&l.jsx("p",{className:"si-switch",children:r==="sign-in"?l.jsxs(l.Fragment,{children:["New here? ",l.jsx("button",{type:"button",onClick:()=>{s("sign-up"),m(null)},children:"Create an account"})]}):l.jsxs(l.Fragment,{children:["Have an account? ",l.jsx("button",{type:"button",onClick:()=>{s("sign-in"),m(null)},children:"Sign in"})]})})]})})}const KE=/ · (?:press )?Z to undo$/;function fue(e){return KE.test(e)?{line:e.replace(KE,""),undo:!0}:{line:e,undo:!1}}function pue(e,t){return e!=="o"&&e!=="O"?null:(t==null?void 0:t.goes)??null}const mue=e=>e&&"item"in e?e.item:null,jc=48,VE=6e3,qE=1e4,fo=voe(Jf),Xo=Soe(Jf),YE="zero.seen",gue='button, a, input, textarea, select, [role="button"], [contenteditable=""], [contenteditable="true"], .row, .modal, .palette, .focus-dock',yue="zero.panel",GE="zero.keyhints",JE="zero.snooze",XE="zero.deliveredThrough",vy=(()=>{const e=Number(localStorage.getItem(XE));if(Number.isFinite(e)&&e>0)return e;const t=Date.now();return localStorage.setItem(XE,String(t)),t})(),wue=e=>e.answer&&e.answer!=="(withdrawn)"?e.answer:void 0,bue=[];function xue(){var $v,Pv,zv,Fv,Bv,_v,Wv,Hv,Uv,Kv,Vv,qv,Yv,Gv,Jv,Xv,Qv,Zv,e0,t0,n0,r0,s0,o0,i0,a0,l0,c0,u0,d0,h0,f0,p0,m0,g0,y0,w0,b0,x0,k0,v0,S0,j0,C0,N0;const[e,t]=g.useState(null),n=g.useRef(MO(window.localStorage)),[r,s]=g.useState(!1),o=g.useRef(null),[i,a]=g.useState(null),c=g.useRef(0),[u,d]=g.useState(null),[h,f]=g.useState("inbox"),[p,m]=g.useState(()=>{try{return Number(localStorage.getItem("zero.troubleClosed"))||0}catch{return 0}}),w=g.useCallback(y=>{m(y);try{localStorage.setItem("zero.troubleClosed",String(y))}catch{}},[]),[b,x]=g.useState(()=>{try{return!Vce(localStorage)}catch{return!0}}),[v,S]=g.useState(0),[C,O]=g.useState(null),[N,P]=g.useState(null),[M,R]=g.useState(null),[L,H]=g.useState(null),_=g.useRef(null);_.current||(_.current=mle(H)),g.useEffect(()=>{var y;(y=_.current)==null||y.point(M)},[M]),g.useEffect(()=>()=>{var y;return(y=_.current)==null?void 0:y.stop()},[]);const[Y,se]=g.useState(()=>localStorage.getItem(GE)!=="0"),re=g.useCallback(y=>{var k;se(y),localStorage.setItem(GE,y?"1":"0"),y||(P(null),R(null),(k=_.current)==null||k.stop())},[]),[T,W]=g.useState(null);$$(!!T,()=>W(null));const le=g.useRef(null);le.current=T;const[ge,j]=g.useState(null),[ae,me]=g.useState([]),E=g.useCallback(y=>ae.filter(k=>k.product===y.product&&k.id===y.id),[ae]),K=T?((Pv=($v=e==null?void 0:e.engines)==null?void 0:$v.byItem)==null?void 0:Pv[T.id])??((zv=e==null?void 0:e.engines)==null?void 0:zv.workspace)??null:null,[z,xe]=g.useState(null),[Oe,F]=g.useState(null),J=g.useRef(null),ze=g.useRef(new Set),[ye,Z]=g.useState(!1),Ce=!!T||!!z,[Ee]=g.useState(()=>oL(localStorage.getItem(sL))),[oe,ne]=g.useState(null),Ie=Y&&!oe;g.useEffect(()=>{var y;Ie||(R(null),(y=_.current)==null||y.stop())},[Ie]),g.useEffect(()=>{if(!Ie)return;const y=A=>{var ce,Ne;const D=(Ne=(ce=A.target)==null?void 0:ce.closest)==null?void 0:Ne.call(ce,"[data-hint]"),X=D==null?void 0:D.dataset.hint;if(!D||!X||!uy[X]){R(Ae=>Ae&&null);return}R(Ae=>Ae&&Ae.el===D?Ae:{id:X,el:D})},k=A=>{A.relatedTarget||R(null)};return document.addEventListener("mousemove",y,!0),document.addEventListener("mouseout",k,!0),()=>{document.removeEventListener("mousemove",y,!0),document.removeEventListener("mouseout",k,!0)}},[Ie]),g.useEffect(()=>{if(!L)return;const y=()=>{var A;R(null),(A=_.current)==null||A.stop()};window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),window.addEventListener("keydown",y,!0);const k=new MutationObserver(()=>{L.el.isConnected||y()});return k.observe(document.body,{childList:!0,subtree:!0}),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y),window.removeEventListener("keydown",y,!0),k.disconnect()}},[L]);const[Q,he]=g.useState(!1),[te,ee]=g.useState(!1),[U,I]=g.useState(null),[V,ue]=g.useState(()=>new URLSearchParams(location.search).has("settings")),[G,ie]=g.useState(!1),[we,ve]=g.useState(()=>new URLSearchParams(location.search).has("team")),[de,be]=g.useState(null),[Le,Ye]=g.useState(!1),[at,Ge]=g.useState(null),Ke=g.useCallback((y,k="")=>{k.trim()&&Dl(y,k),kw(),Ge(null),ve(!1),be(null),W(y),ne("reply")},[]),rt=g.useCallback(y=>{var D,X;const k=y.createdBy?(X=(D=M1((e==null?void 0:e.team)??null,(e==null?void 0:e.products)??[]))==null?void 0:D.byId.get(y.createdBy))==null?void 0:X.name:null,A=(y.body??y.title??"").trim();Ge({to:"agent",body:k?`${k} asked:
|
|
1125
|
+
|
|
1126
|
+
${A}
|
|
1127
|
+
|
|
1128
|
+
`:`${A}
|
|
1129
|
+
|
|
1130
|
+
`}),ne("compose")},[e==null?void 0:e.team,e==null?void 0:e.products]),gt=g.useCallback(y=>{Ge({to:y.to,also:y.also}),ne("compose")},[]),Ve=we&&!T&&!V,Ln=!q.isFixtures&&!!((Fv=e==null?void 0:e.team)!=null&&Fv.configured)&&e.team.started===!0&&!e.team.signedIn,ln=!q.isFixtures&&!!((Bv=e==null?void 0:e.team)!=null&&Bv.configured)&&!e.team.signedIn,Sn=g.useRef(!1),[Ys,ts]=g.useState(!1);g.useEffect(()=>{var y,k;(y=e==null?void 0:e.team)!=null&&y.signedIn?(Sn.current=!0,ts(!1)):Sn.current&&((k=e==null?void 0:e.team)!=null&&k.started)&&ts(!0)},[(_v=e==null?void 0:e.team)==null?void 0:_v.signedIn,(Wv=e==null?void 0:e.team)==null?void 0:Wv.started]);const ns=g.useRef(!1);ns.current=Ln;const[rs,cr]=g.useState(null),Do=g.useRef(rL);Do.current={modal:oe,settings:V,importAgents:te,newProject:Q,teamShown:Ve,setupPlan:!!rs};const[zr,Dt]=g.useState(null),[Gs,Js]=g.useState(0),[Sr,ur]=g.useState(null),[qn,_t]=g.useState(null),[Fr,Oo]=g.useState(null),[Br,Oa]=g.useState(null),_r=g.useMemo(()=>({project:qn,priority:Fr,harness:Br}),[qn,Fr,Br]),Lo=y=>{_t(y.project),Oo(y.priority),Oa(y.harness),S(0)};g.useCallback(()=>ne(y=>y==="filter"?null:y),[]);const[et,mn]=g.useState(null),jr=g.useRef(null),Yn=g.useRef(null),[dr,cn]=g.useState(()=>localStorage.getItem("powerup.sidebar.collapsed")!=="true"),Gn=g.useRef(null),jn=g.useRef(dr);jn.current=dr,g.useEffect(()=>{Gn.current===null&&(localStorage.setItem(yue,dr?"1":"0"),localStorage.setItem("powerup.sidebar.collapsed",String(!dr)))},[dr]);const La=LY(),[ss,vs]=sI(IY(La),dr,cn),[Wr,Xs]=g.useState(()=>ZO(localStorage.getItem(ba))),[Cn,Ss]=g.useState(()=>Eh("match"));g.useEffect(()=>sae(Ss),[]);const[js,Ai]=g.useState(()=>Dc(localStorage.getItem(Fs))),$a=oae(Wr,js),[Xl,Ti]=g.useState(()=>{const y=Dc(localStorage.getItem(Fs));return Ah(localStorage.getItem(ml),y==="none"?Ju[0].id:y)}),$o=g.useRef(0),[Ql,is]=g.useState(null),Po=g.useCallback(y=>{const{theme:k,skin:A}=Lu(y);localStorage.setItem(ba,k),localStorage.setItem(Fs,A);const D=++$o.current;is(y),jy(A).then(()=>{D===$o.current&&YP(()=>bs.flushSync(()=>{if(is(null),Xs(k),jb(Eh(k)),Ai(A),Nb(Cb(k,A,Dk())),A!=="none"){const X=Ah(localStorage.getItem(ml),A);Ti(X),Th(X)}}))})},[]),zo=g.useCallback(y=>{const k=Dc(localStorage.getItem(Fs));k!=="none"&&(Ti(y),Th(y),localStorage.setItem(ml,uae(localStorage.getItem(ml),k,y)))},[]),Cs=g.useCallback(()=>{const y=Dc(localStorage.getItem(Fs));y!=="none"&&zo(yr[y])},[zo]),[en,Fo]=g.useState(()=>new Set(JSON.parse(localStorage.getItem(YE)??"[]"))),[$,Re]=g.useState(new Set),[ht,Ht]=g.useState(()=>JSON.parse(localStorage.getItem(JE)??"{}")),[hr,Jn]=g.useState([]),Qs=g.useCallback((y,k,A)=>{if(y!=null&&y.length){for(const D of y)vY({...D,from:k,at:A});window.dispatchEvent(new Event(Ow))}},[]),Wt=g.useCallback(y=>{const k=Object.assign(y,{at:Date.now()});return Jn(A=>[...A,k]),k},[]),Zs=g.useRef(null),[fr,Pa]=g.useState(null),[Zl]=g.useState(()=>zce(new URLSearchParams(location.search).get("modes"))),[ec,qp]=g.useState("auto"),za=g.useRef(null),[Mi,Fa]=g.useState(null),Xu=g.useRef(null),[eo,as]=g.useState(null),[Ns,Ri]=g.useState(null),[B,tn]=g.useState(null),[Ba,fe]=g.useState(null),[Ze,ft]=g.useState(null),[nn,Xn]=g.useState({missing:!1,url:"https://code.claude.com/docs/en/setup"}),[$n,Bk]=g.useState(""),Fe=g.useRef(null);Fe.current=B;const vt=g.useRef(nn);vt.current=nn;const zt=g.useRef(uie(new URLSearchParams(location.search).get("firstrun")));g.useEffect(()=>{if(B||!e||ln||!XN({products:QN(e.products),done:iE(localStorage),forced:!!zt.current}))return;tn(zt.current?{...Tl,step:zt.current}:rie(localStorage));const y=dae(localStorage,ba);y&&(Xs(y.theme),Ai(y.skin))},[e,B,ln]),g.useEffect(()=>{B&&sie(localStorage,B)},[B]);const[un,Hr]=g.useState([]),[At,Qu]=g.useState(null);g.useEffect(()=>{const y=()=>q.settings().then(k=>{var X,ce,Ne,Ae;const A=(X=k.workspace)==null?void 0:X.homePath;typeof A=="string"&&A&&Bk(A),e2((ce=k.workspace)==null?void 0:ce.claudeModels);const D=(Ne=k.workspace)==null?void 0:Ne.codexModels;Array.isArray(D)&&Hr(D),Qu(((Ae=k.workspace)==null?void 0:Ae.codexModelDefault)??null)}).catch(()=>{});return y(),window.addEventListener("agent-models-changed",y),()=>window.removeEventListener("agent-models-changed",y)},[]);const _k=!!B&&B.step==="done";g.useEffect(()=>{_k&&q.settings().then(y=>{var D,X,ce,Ne,Ae;const k=y.ok!==!1&&((D=y.workspace)==null?void 0:D.claudeCertain)===!0,A=y.ok!==!1&&((X=y.workspace)==null?void 0:X.codexCertain)===!0;Xn({missing:k&&!((ce=y.workspace)!=null&&ce.claudeFound)&&tE({found:!1,certain:!0},{found:!!((Ne=y.workspace)!=null&&Ne.codexFound),certain:A}),url:((Ae=y.workspace)==null?void 0:Ae.claudeInstallUrl)||"https://code.claude.com/docs/en/setup"})}).catch(()=>{})},[_k]);const Wk=g.useCallback(async()=>{const[y,k]=await Promise.all([q.recheckClaude(),q.recheckCodex()]),A=tE(y,k);return Xn({missing:A,url:y.url}),A},[]),[jL,CL]=g.useState(!1),tc=g.useCallback(async()=>{const y=await Promise.all([q.engineSetup("ready","claude"),q.engineSetup("ready","codex")]);CL(Tk(y.map(k=>({found:!!k.found,signedIn:!!k.signedIn}))))},[]);g.useEffect(()=>{B||tc()},[B,tc]);const Es=g.useCallback(y=>{tn(k=>k&&foe(k,y))},[]),nc=ep(B),Yp=(B==null?void 0:B.step)==="make"||(B==null?void 0:B.step)==="task",Qn=nc?qn:null;g.useEffect(()=>{!nc||!(B!=null&&B.practice)||_t(B.practice)},[nc,B==null?void 0:B.practice]),g.useEffect(()=>{B&&(B.step==="make"&&(W(null),ne(null),f("inbox")),B.step==="task"&&ne("compose"),B.step==="working"&&(ne(null),W(null),f("progress"),S(0)),B.step==="open"&&(ne(null),f("inbox"),S(0)),B.step==="clear"&&(ne(null),W(null),f("inbox"),S(0)),B.step==="snooze"&&(W(null),f("inbox"),S(0)),B.step==="unblock"&&(ne(null),f("inbox"),S(0)),B.step==="where"&&(ne(null),W(null)),B.step==="board"&&(ne(null),W(null),f("inbox")),B.step==="command"&&(ne(null),W(null),f("inbox")))},[B==null?void 0:B.step]),g.useEffect(()=>{(B==null?void 0:B.step)!=="make"||oe!=="compose"||tn(y=>y&&rr(y,"task"))},[B==null?void 0:B.step,oe]),g.useEffect(()=>{(B==null?void 0:B.step)!=="open"||!T||T.id!==B.item||tn(y=>y&&rr(y,"answer"))},[B==null?void 0:B.step,T==null?void 0:T.id]),g.useEffect(()=>{!ep(B)||!B||!T||coe(B,T.id,Kl(B,fo))||W(null)},[B==null?void 0:B.step,B==null?void 0:B.item,T==null?void 0:T.id]),g.useEffect(()=>{if((B==null?void 0:B.step)!=="answer"||B.replies||!B.item||oe!=="reply")return;const y=B.practice??B.product;if(!y)return;const k={product:y,id:B.item};hg(k,Lse)&&window.dispatchEvent(new CustomEvent("zero:reply-restored",{detail:Ro(k)}))},[B==null?void 0:B.step,B==null?void 0:B.replies,B==null?void 0:B.item,oe]),g.useEffect(()=>{if((B==null?void 0:B.step)!=="working"||!B.item||!e)return;const y=e.items.find(A=>A.id===B.item);!y||!(B.replies?loe(y):y.result||y.status==="done"||y.status==="blocked")||(f("inbox"),Es({t:"answered"}))},[e,B==null?void 0:B.step,B==null?void 0:B.item]);const Hk=!!(B!=null&&B.replies)&&!!(e!=null&&e.items.some(y=>y.id===(B==null?void 0:B.item)&&aoe(y)));g.useEffect(()=>{if((B==null?void 0:B.step)!=="working"||!B.item||B.replies&&!Hk)return;const y=B.practice??B.product;if(!y)return;const k=B.item,A=B.replies??0;let D=!0;const X=setTimeout(async()=>{try{await q.firstRunAnswer({product:y,id:k,round:A})}catch{}D&&await qe()},xoe);return()=>{D=!1,clearTimeout(X)}},[B==null?void 0:B.step,B==null?void 0:B.item,B==null?void 0:B.product,B==null?void 0:B.practice,B==null?void 0:B.replies,Hk]);const As=!!B&&B.step!=="landed";g.useEffect(()=>{if(As)return q.firstRunWalking(!0),()=>{q.firstRunWalking(!1)}},[As]);const Gp=zt.current?null:hoe(B);g.useEffect(()=>{var k,A;if(Gp===null)return;const y=Gp;try{(A=(k=window.zero)==null?void 0:k.track)==null||A.call(k,"first_run_step",y)}catch{}},[Gp]);const Uk=g.useRef(null),Jp=_ce(B,!!T);g.useEffect(()=>{Wce(Uk.current,Jp)&&(Uk.current=Jp,(async()=>{var D,X,ce,Ne,Ae,ke;const y=((D=Fe.current)==null?void 0:D.examples)??[];if(y.length){await((X=Cr.current)==null?void 0:X.call(Cr)),Es({t:"staged",examples:y});return}const k=((ce=Fe.current)==null?void 0:ce.practice)??((Ne=Fe.current)==null?void 0:Ne.product)??null;let A=[];if(k)try{A=((Ae=await q.firstRunExamples({product:k}))==null?void 0:Ae.ids)??[]}catch{A=[]}await((ke=Cr.current)==null?void 0:ke.call(Cr)),A.length?Es({t:"staged",examples:A}):tn(He=>He&&rr(He,"command"))})())},[Jp,Es]);const _a=g.useCallback(()=>{const y=dle(Do.current);ne(y.modal),ue(y.settings),Dt(null),ee(y.importAgents),he(y.newProject),ve(y.teamShown),y.setupPlan||cr(null)},[]),Ii=g.useCallback((y,{celebrate:k=!0,filed:A=null,practised:D=!1}={})=>{var ce,Ne,Ae,ke;if(!eE(vt.current))return;if(_a(),D&&yy(localStorage),doe(Fe.current,{practised:D}))try{(Ne=(ce=window.zero)==null?void 0:ce.track)==null||Ne.call(ce,"first_run_finished")}catch{}const X=((Ae=Fe.current)==null?void 0:Ae.product)??null;X&&A===null&&q.importAgents({product:X,agents:y}).catch(()=>{}),q.firstRunPracticeEnd().then(()=>{var He;return(He=Cr.current)==null?void 0:He.call(Cr)}),_t(null),Hi(((ke=Fe.current)==null?void 0:ke.product)??null),oie(localStorage),tn(null),k&&fe({agents:(A??y.length)>0})},[_a]),NL=g.useCallback(()=>{iie(localStorage),_a(),W(null),f("inbox"),Zu.current=!1,setTimeout(()=>tn({...Tl}),0)},[_a]),Kk=g.useCallback(y=>{yy(localStorage),ft(null),_a(),W(null),f("inbox"),Zu.current=!1,setTimeout(()=>tn(ioe(y)),0)},[_a]),Zu=g.useRef(!1);g.useEffect(()=>{if((B==null?void 0:B.step)==="command"){if(oe==="palette"){Zu.current=!0;return}if(Zu.current){if(JN(B)==="end"){Ii([],{practised:!0});return}tn(y=>y&&rr(y,"done"))}}},[B,oe,Ii]);const Vk=g.useRef(null),qk=g.useRef(null),rc=g.useRef(null),ed=3e3,Ts=g.useRef(null),to=g.useCallback(async()=>{var k;const y=Ts.current;y&&(Ts.current=null,clearTimeout(y.timer),await y.run(),Ri(null),await((k=Cr.current)==null?void 0:k.call(Cr)))},[]);g.useEffect(()=>{var D,X;const y=(X=(D=window.zero)==null?void 0:D.onWriteHeld)==null?void 0:X.call(D,to),k=()=>{to()};window.addEventListener("pagehide",k);const A=sr()?K$(document,to):null;return()=>{y==null||y(),A==null||A(),window.removeEventListener("pagehide",k)}},[to]);const td=g.useRef({}),Yk=g.useRef({}),Gk=g.useRef(()=>{}),qe=g.useCallback(async()=>{const y=await q.snapshot();if(jB()){setTimeout(()=>Gk.current(),300);return}t(y&&{...y,items:u4(c4(y.items,td.current),Yk.current)})},[]);Gk.current=()=>{qe()};const Cr=g.useRef();Cr.current=qe,g.useEffect(()=>{qe();const y=q.onChanged(qe),k=setInterval(qe,Ta(1e4,sr()));return()=>{y(),clearInterval(k)}},[qe]);const Jk=g.useRef(!1);g.useEffect(()=>{if(Jk.current||!e)return;const y=O$(location.search,e.items,wt);if(y){Jk.current=!0,W(y);const k=new URLSearchParams(location.search).get("panel");k==="1"&&cn(!0),k==="0"&&cn(!1)}});const lt=Date.now(),[nd,EL]=g.useState([]),[Wa,Xk]=g.useState(null),Xp=g.useRef(!1),Qp=g.useCallback(()=>{Xp.current||Wa===!1||(Xp.current=!0,q.olderItems(nd.length).then(y=>{EL(k=>[...k,...y.items]),Xk(y.more)}).catch(()=>Xk(!1)).finally(()=>{Xp.current=!1}))},[nd.length,Wa]),AL=g.useMemo(()=>Zce((e==null?void 0:e.items)??[],nd),[e==null?void 0:e.items,nd]),it=ZN(AL,B),Ha=g.useMemo(()=>[...((e==null?void 0:e.agents)??[]).filter(HR)].sort(Uq).map(k=>{const{title:A,body:D}=zq(k,lt);return{id:`agent:${k.pid}`,product:k.product??"",productName:k.productName??BR(k),status:"open",title:A,body:D,kind:"agent",labels:[],priority:$l(k)?9:1,epoch:0,claim:null,createdAt:k.startedAt,updatedAt:k.lastActiveAt||k.startedAt,runAt:k.runAt??0,...k.runAt?{wrote:{runAt:{ts:k.runAtSetAt??k.runAt,source:"founder"}}}:{},agent:k}}),[e==null?void 0:e.agents,lt]),Ua=g.useMemo(()=>ZN(Ha.filter(y=>!Qn||y.product===Qn),B),[Ha,Qn,B]),rd=((Hv=e==null?void 0:e.config)==null?void 0:Hv.outsideAgents)??"off",Ms=g.useCallback(y=>y.runAt??0,[]),Nr=g.useCallback(y=>iF(y,ht[y.id]??0),[ht]),Di=g.useCallback(y=>Math.max(Ms(y),Nr(y)),[Ms,Nr]),pe=g.useMemo(()=>M1(e==null?void 0:e.team,(e==null?void 0:e.products)??[]),[e==null?void 0:e.team,e==null?void 0:e.products]),Qk=g.useCallback(y=>{if(!pe)return null;const k=pe.products.get(y.product);return Sl(k)?mB(y,k,pe.me)?hi(y)?!0:null:!1:null},[pe]),Zk=g.useCallback(y=>{if(!pe)return!0;const k=pe.products.get(y.product);return Sl(k)?hi(y)?y.assignee!==pe.me&&(y.createdBy===pe.me||(y.people??[]).includes(pe.me)):qb(y,k)===pe.me:!0},[pe]),Ka=g.useMemo(()=>{const y=e==null?void 0:e.supervisor.spawnTrouble;return!y||p===y.since?null:rF(y,it)},[e==null?void 0:e.supervisor.spawnTrouble,it,p]),no=g.useMemo(()=>[...it,...Ha,...Ka?[Ka]:[]],[it,Ha,Ka]),TL=g.useMemo(()=>lF(it,lt),[it,lt]),sc=g.useMemo(()=>{const y=(e==null?void 0:e.supervisor.running)??[];return(B==null?void 0:B.step)!=="working"||!B.item?y:[{itemId:B.item,product:B.product??"",startedAt:B.sentAt??Date.now(),tail:[]},...y]},[e==null?void 0:e.supervisor.running,B==null?void 0:B.step,B==null?void 0:B.item,B==null?void 0:B.product,B==null?void 0:B.sentAt]),gn=g.useMemo(()=>new Set(sc.map(y=>y.itemId)),[sc]),Ur=g.useMemo(()=>new Set((e==null?void 0:e.supervisor.shipping)??[]),[e==null?void 0:e.supervisor.shipping]),ev=g.useMemo(()=>new Map(it.map(y=>[y.id,y])),[it]),ro=g.useCallback(y=>PA(y,ev),[ev]),Zp=g.useMemo(()=>it.filter(y=>{if(y.id===Ns||y.product&&Qn&&y.product!==Qn||gn.has(y.id)||Ur.has(y.id))return!1;if(TL.has(y.id))return!0;const k=Qk(y);return k===!1?!1:k===!0?y.status!=="done"&&!(Nr(y)>lt)&&!Fh(y)&&!Lc(y,ro(y)):$A(y,{deliveredThrough:vy,hiddenUntil:Nr(y),now:lt,waitingOn:ro(y)})}),[it,Nr,Qn,lt,Ns,Qk,gn,Ur,ro]),Kr=g.useMemo(()=>fp((e==null?void 0:e.products)??[]),[e==null?void 0:e.products]),sd=g.useCallback(y=>WA(y.place,BA((e==null?void 0:e.supervisor.productOrder)??[],y.product,Kr)+_A(y)),[e==null?void 0:e.supervisor.productOrder,Kr]),wt=g.useMemo(()=>{const y=Ua.filter(Ae=>Ae.id!==Ns&&Ae.agent&&Fq(Ae.agent,lt,rd)),k=[...Zp,...y].sort(g1(sd)),A=k.filter(Ae=>Pc(Ae,en)),D=A.length?k.filter(Ae=>!Pc(Ae,en)):k,X=D.filter(da),ce=X.length?D.filter(Ae=>!da(Ae)):D;return[...[...Ka?[Ka]:[],...A],...X,...ce]},[Zp,Ua,rd,sd,lt,Ns,Ka,en]);g.useEffect(()=>{(B==null?void 0:B.step)==="clear"&&joe(wt,B,fo,Xo)&&tn(y=>y&&rr(y,"snooze"))},[wt,B==null?void 0:B.step,B==null?void 0:B.examples.join("|")]),g.useEffect(()=>{(B==null?void 0:B.step)==="snooze"&&Coe(wt,B,Xo)&&tn(y=>y&&rr(y,"unblock"))},[wt,B==null?void 0:B.step,B==null?void 0:B.examples.join("|")]),g.useEffect(()=>{(B==null?void 0:B.step)==="unblock"&&Toe(wt,B)&&tn(y=>y&&rr(y,"where"))},[wt,B==null?void 0:B.step,B==null?void 0:B.examples.join("|")]);const od=g.useMemo(()=>{const y=(e==null?void 0:e.supervisor.productOrder)??[],k=(e==null?void 0:e.products)??[],A=y.map(X=>k.find(ce=>ce.slug===X)).filter(X=>!!X),D=k.filter(X=>!y.includes(X.slug)).sort((X,ce)=>X.name.localeCompare(ce.name));return[...A,...D]},[e==null?void 0:e.products,e==null?void 0:e.supervisor.productOrder]);g.useEffect(()=>{if(B||!e)return;const y=KN();$se(e.products,y,{practiceSlug:Ose})&&Hi(null)},[B,e==null?void 0:e.products]);const pr=g.useMemo(()=>[...it.filter(y=>{if(Qn&&y.product!==Qn)return!1;const k=Ms(y);return Nr(y)>lt&&!gn.has(y.id)?!1:y.id===Ns&&k<=lt?!0:!Zk(y)||Us(e==null?void 0:e.products.find(A=>A.slug===y.product))?!1:pe&&hi(y)&&Sl(pe.products.get(y.product))?y.status!=="done":$c(y,{deferredUntil:k,now:lt,live:gn.has(y.id),shipping:Ur.has(y.id)})}),...Ua.filter(y=>y.agent&&Bq(y.agent,lt,rd))].sort(g1(sd)),[it,Ua,rd,Qn,Ns,Ms,Nr,sd,lt,pe,Zk,gn,Ur]),Er=g.useMemo(()=>{const y=new Set(wt.map(k=>k.id));return it.filter(k=>!y.has(k.id)&&!gn.has(k.id)&&!Ur.has(k.id)&&(!Qn||k.product===Qn)&&(k.status==="done"||gB(k,pe==null?void 0:pe.products.get(k.product),(pe==null?void 0:pe.me)??null))).sort((k,A)=>A.updatedAt-k.updatedAt)},[it,Qn,wt,pe,gn,Ur]),em=g.useCallback(y=>bo(y)||Lc(y,ro(y))?Number.MAX_SAFE_INTEGER:Nr(y),[Nr,ro]),Pn=g.useMemo(()=>[...it.filter(y=>{var k,A;return(bo(y)||Fh(y)||Nr(y)>lt||Lc(y,ro(y))&&!gn.has(y.id)&&!Ur.has(y.id))&&(y.status!=="done"||((A=(k=y.wrote)==null?void 0:k.status)==null?void 0:A.source)!=="founder")&&(!Qn||y.product===Qn)}),...Ua.filter(y=>(y.runAt??0)>lt)].sort((y,k)=>em(y)-em(k)),[it,Ua,Nr,em,ro,gn,Ur,Qn,lt]),[Oi,oc]=g.useState([]);g.useEffect(()=>{q.repeats().then(oc).catch(()=>{})},[(Uv=e==null?void 0:e.items)==null?void 0:Uv.length,h]);const tm=Pn.length+Oi.length,ML=g.useMemo(()=>qle({scheduledCount:tm,view:h}).map(([y])=>y),[tm,h]),nm=g.useRef(new Set);g.useEffect(()=>{if((B==null?void 0:B.step)!=="where"){nm.current=new Set;return}if(h==="progress"){nm.current.add(h);return}nm.current.has("progress")&&tn(y=>y&&rr(y,"board"))},[h,B==null?void 0:B.step]);const id=g.useMemo(()=>{var y;return{products:(e==null?void 0:e.products)??[],people:((y=e==null?void 0:e.team)==null?void 0:y.people)??[],me:(pe==null?void 0:pe.me)??null}},[e==null?void 0:e.products,(Kv=e==null?void 0:e.team)==null?void 0:Kv.people,pe==null?void 0:pe.me]),ic=g.useMemo(()=>et===null?null:hle(it,et,id),[it,et,id]),RL=g.useMemo(()=>et===null?void 0:new Map((ic??[]).map(y=>[y.item.id,fle(y.item,id)])),[ic,et,id]);g.useEffect(()=>{et!==null&&Wa!==!1&&Qp()},[et,Wa,Qp]);const IL=g.useMemo(()=>new Map((ic??[]).map(y=>[y.item.id,y.summary])),[ic]),DL=!!et,Va=g.useMemo(()=>et===null?void 0:cp(et),[et]),ac=g.useCallback(()=>{mn(y=>y!==null?y:(Yn.current={view:h,selected:v},"")),W(null),ne(null),S(0),requestAnimationFrame(()=>{var y;return(y=jr.current)==null?void 0:y.focus()})},[h,v]),Bo=g.useCallback(()=>{mn(null);const y=Yn.current;Yn.current=null,y&&(f(y.view),S(y.selected))},[]),lc=g.useMemo(()=>B?Eoe(B.step,B,wt,fo,Xo,{opened:!!T,picking:oe==="snooze"}):[],[B,wt,T,oe]),OL=B&&_O.includes(B.step)?((Vv=zO(B.step,0,{opened:!!T,view:h,picking:oe==="snooze",palette:oe==="palette",tabs:ML}))==null?void 0:Vv.key)??null:null,tv=g.useMemo(()=>{const y=new Set,k=it.filter(A=>!A.agent&&A.status!=="done"&&Us(e==null?void 0:e.products.find(D=>D.slug===A.product)));return[...wt,...pr,...Pn,...k,...Er].filter(A=>y.has(A.id)?!1:(y.add(A.id),!0))},[wt,pr,Pn,Er,it,e==null?void 0:e.products]),ad=h==="inbox"?wt:h==="snoozed"?Pn:h==="progress"?pr:h==="all"?tv:Er,ld=g.useMemo(()=>BE(ad,_r),[ad,_r]),[nv,LL]=g.useState(()=>_1("inbox")),[rv,$L]=g.useState(()=>_1("team")),cd=g.useMemo(()=>{if(!pe)return[];const y=[...pe.byId.values()];return pe.state.me&&!pe.byId.has(pe.state.me.id)?[pe.state.me,...y]:y},[pe]),[sv,PL]=g.useState(()=>C4()),Zn=g.useMemo(()=>E4(sv,(pe==null?void 0:pe.me)??null,cd.map(y=>y.id)),[sv,pe==null?void 0:pe.me,cd]),ov=g.useCallback(y=>{PL(y),N4(y),S(0)},[]),Ar=!!pe&&jT(Zn,pe.me),rm=e4(Ar),[iv,zL]=g.useState(()=>XB()),xt=g.useMemo(()=>ZB(Ar?rv:nv,iv,!!pe),[Ar,rv,nv,iv,pe]),qa=g.useCallback(y=>{const{privacy:k="any",...A}=y;zL(k),QB(k),rm==="team"?$L(A):LL(A),t4(rm,A)},[rm]),Ya=g.useCallback(y=>pp(y,((e==null?void 0:e.products)??[]).find(k=>k.slug===y.product),pe?{me:pe.me,since:pe.state.since??null}:null),[e==null?void 0:e.products,pe]),[sm,FL]=g.useState(()=>b4()),av=g.useCallback(y=>{FL(y),x4(y)},[]),om=g.useRef(!1);g.useEffect(()=>{if((B==null?void 0:B.step)!=="board"){om.current=!1;return}if(xt.view==="board"){om.current=!0;return}om.current&&tn(y=>y&&rr(y,"command"))},[B==null?void 0:B.step,xt.view]);const so=!pe||Zn.includes(pe.me??""),ls=(e==null?void 0:e.supervisor.productOrder)??bue,Ga=g.useMemo(()=>so?H1(ld.filter(y=>pn(y)||nr(y)||Um(y,xt,lt,Ya(y),Kr)),xt,h,ls,Kr):[],[ld,xt,lt,so,h,ls,Kr,Ya]),im=g.useRef(null),am=g.useCallback((y,k)=>{k&&(im.current=k,O(null));const A=Date.now();for(const[D,X]of Object.entries(y))td.current[D]={place:X,at:A};t(D=>D&&{...D,items:D.items.map(X=>X.id in y?{...X,place:y[X.id]}:X)}),q.setThreadPlaces(y)},[]),ud=g.useCallback((y,k,A=!1)=>{Yk.current[y]={pinned:k,at:Date.now()};const D=A&&!k;D&&delete td.current[y],t(X=>X&&{...X,items:X.items.map(ce=>ce.id===y?{...ce,pinned:k,...D?{place:void 0}:{}}:ce)}),q.setThreadPins({[y]:k?!0:null}),D&&q.setThreadPlaces({[y]:null})},[]),BL=g.useCallback((y,k,A)=>{const D=new Map(Ga.map(Ae=>[Ae.id,Ae])),X=A.map(Ae=>D.get(Ae)).filter(Ae=>!!Ae),{places:ce,pin:Ne}=bT(X.map(Ae=>({id:Ae.id,score:Uh(Ae,ls,Kr),pinned:!!Ae.pinned})),y,k);Ne!==null&&ud(y,Ne),ce&&am(ce,y)},[Ga,ls,Kr,am,ud]),_o=((qv=e==null?void 0:e.team)==null?void 0:qv.cards)??[],cc=g.useMemo(()=>Ar?Vm(_o,{tab:h,picked:Zn,me:(pe==null?void 0:pe.me)??null,display:xt,products:(e==null?void 0:e.products)??[],now:lt}):[],[Ar,_o,h,Zn,pe==null?void 0:pe.me,xt,e==null?void 0:e.products,lt]),lm=g.useMemo(()=>Ar?O4(Ga,cc,h==="done"?"done":xt.sort,{order:ls,products:(e==null?void 0:e.products)??[]},h):null,[Ar,Ga,cc,xt.sort,h,ls,e==null?void 0:e.products]),Ja=g.useCallback(y=>{be(y),ve(!0),O(ra({card:y}))},[]),_L=g.useCallback(y=>{const k=y?(pe==null?void 0:pe.byId.get(y))??null:null;return l.jsxs(Rle,{person:k,me:y===(pe==null?void 0:pe.me),now:lt,children:[l.jsx(Rt,{person:k,me:y===(pe==null?void 0:pe.me)}),y===(pe==null?void 0:pe.me)?"You":bn(k)]})},[pe,lt]),WL=g.useMemo(()=>pe?{everyone:cd,picked:Zn,me:pe.me,onPick:ov}:void 0,[pe,cd,Zn,ov]),uc=g.useCallback(y=>y.filter(k=>pn(k)||nr(k)||Um(k,xt,lt,Ya(k),Kr)).length,[xt,lt,Ya,Kr]),dc=g.useCallback(y=>Ar?Vm(_o,{tab:y,picked:Zn,me:(pe==null?void 0:pe.me)??null,display:xt,products:(e==null?void 0:e.products)??[],now:lt}).length:0,[Ar,_o,Zn,pe==null?void 0:pe.me,e==null?void 0:e.products,lt,xt]),lv=(so?ld.length:0)+(Ar?Vm(_o,{tab:h,picked:Zn,me:(pe==null?void 0:pe.me)??null,display:Ec.inbox,products:(e==null?void 0:e.products)??[],now:lt}).length:0),cm=g.useMemo(()=>qy.map(y=>y.view),[]),Xa=g.useMemo(()=>H1(BE(wt,_r).filter(y=>pn(y)||nr(y)||Um(y,xt,lt,Ya(y),Kr)),xt,void 0,ls,Kr),[wt,_r,xt,lt,ls,Kr,Ya]);g.useMemo(()=>oe==="filter"?rue(ad.filter(y=>!pn(y)&&!nr(y)),_r,(e==null?void 0:e.products)??[]):null,[oe,ad,_r,e==null?void 0:e.products]);const cv=g.useMemo(()=>{const y=new Map;for(const k of Er)y.set(k.id,"done");for(const k of Pn)y.set(k.id,"scheduled");for(const k of pr)y.set(k.id,"running");for(const k of wt)y.set(k.id,"waiting");return y},[wt,pr,Pn,Er]),cs=g.useCallback(y=>cv.get(y.id)??null,[cv]),Li=g.useCallback(y=>Wm(it,y).filter(k=>_y(k,cs(k))),[it,cs]),HL=g.useMemo(()=>PB(it,cs),[it,cs]),[hc,dd]=g.useState(null),hd=y=>`${y.product}/${y.id}`;g.useEffect(()=>{hc&&(!T||hd(T)!==hc)&&dd(null)},[T==null?void 0:T.id,T==null?void 0:T.product]);const Qa=et===null&&xt.view==="board",fd=g.useMemo(()=>({items:it,products:(e==null?void 0:e.products)??[],display:xt,now:lt,stateOf:cs,cards:_o,picked:pe?Zn:void 0,me:(pe==null?void 0:pe.me)??null,since:(pe==null?void 0:pe.state.since)??null,live:gn,projectOrder:ls}),[it,e==null?void 0:e.products,xt,lt,cs,_o,pe,Zn,gn,ls]),oo=g.useMemo(()=>Qa?Uy({...fd,order:sm}):null,[Qa,fd,sm]),UL=g.useMemo(()=>oo?U1(oo):null,[oo]),bt=et!==null?(ic??[]).map(y=>y.item):UL??Ga,uv=g.useRef(null),dv=WP({list:bt,selected:v,last:C?null:uv.current}),qt=bt[dv];g.useLayoutEffect(()=>{const y=im.current,k=y?bt.findIndex(D=>D.id===y):-1;im.current=null;const A=k>=0?k:dv;uv.current=_P(bt,A),A!==v&&S(A)});const um=(B==null?void 0:B.step)==="open"&&B.item?bt.findIndex(y=>y.id===B.item):-1;g.useEffect(()=>{um>=0&&S(um)},[um]);const Wo=g.useMemo(()=>et!==null?V1(bt,null):oo?L4(oo):V1(bt,lm),[et,bt,oo,lm]),io=g.useMemo(()=>{var y;return C?((y=Wo.find(k=>k.card&&ra(k)===C))==null?void 0:y.card)??null:null},[C,Wo]),KL=Zn.join(",");g.useEffect(()=>{O(null)},[v,h,et,xt.view,KL]);const VL=g.useCallback(y=>{const k=qt;if(av(y),!k)return;const D=U1(Uy({...fd,order:y})).findIndex(X=>X.id===k.id&&X.product===k.product);D>=0&&S(D)},[qt,av,fd]),hv=(B==null?void 0:B.step)==="open"&&B.item?B.item:lc.length?N&&lc.includes(N)?N:lc[0]:null,Ot=(hv?bt.find(y=>y.id===hv):void 0)??(N&&!$.size?bt.find(y=>y.id===N):void 0)??(io?void 0:qt),[St,Rs]=g.useState(null),[pd,fv]=g.useState(new URLSearchParams(location.search).has("reviewLab")?"code":"multiple"),[dm,qL]=g.useState("header-tools-open"),[pv,YL]=g.useState("corners-bare"),[hm,GL]=g.useState("glass"),Is=Sy(q.isFixtures,location.search);g.useEffect(()=>(document.documentElement.dataset.codeReview="glass",()=>{delete document.documentElement.dataset.codeReview}),[]),g.useEffect(()=>(document.documentElement.dataset.textReview=Is?hm:"glass",()=>{delete document.documentElement.dataset.textReview}),[Is,hm]);const mv=g.useRef(!1);g.useEffect(()=>{if(Is&&e&&!mv.current){const y=e.items.find(k=>k.id==="w-n13");y&&(mv.current=!0,W(y))}},[Is,e]),g.useEffect(()=>{document.documentElement.dataset.reviewStyle=Is?dm:"header-tools-open"},[Is,dm]);const[Ho,fm]=g.useState("beside"),[gv,yv]=g.useState(!1);g.useEffect(()=>{if(St&&Ho==="focus"){Gn.current===null&&jn.current&&(Gn.current=!0,cn(!1));return}if(Gn.current!==null){const y=Gn.current;Gn.current=null,cn(y)}},[St,Ho]);const Za=!!St&&Ho==="focus";g.useEffect(()=>{if(!Za||oe!=="reply")return;const y=()=>ne(null),k=D=>{var ce;const X=D.target;(ce=X==null?void 0:X.closest)!=null&&ce.call(X,".focus-dock")||y()},A=()=>{var D;((D=document.activeElement)==null?void 0:D.tagName)==="IFRAME"&&y()};return document.addEventListener("mousedown",k),window.addEventListener("blur",A),()=>{document.removeEventListener("mousedown",k),window.removeEventListener("blur",A)}},[Za,oe]);const[JL,pm]=g.useState(!1),[XL,mm]=g.useState(!1),fc=g.useRef(null),wv=g.useCallback(()=>{pm(!0),fc.current&&window.clearTimeout(fc.current),fc.current=window.setTimeout(()=>pm(!1),FP)},[]);g.useEffect(()=>{if(!Za){pm(!1),mm(!1);return}const y=A=>{var D,X;wv(),mm(!!((X=(D=A.target)==null?void 0:D.closest)!=null&&X.call(D,".doc-marks, .chrome-reach")))},k=()=>mm(!1);return window.addEventListener("mousemove",y),window.addEventListener("blur",k),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("blur",k),fc.current&&window.clearTimeout(fc.current)}},[Za,wv]);const QL=BP({reaching:XL,awake:JL}),ZL="margin-left",[bv,e$]=g.useState("corner"),t$=q.isFixtures&&new URLSearchParams(location.search).has("artifactTweaks"),xv=()=>{Ho==="focus"&&gv?fm("beside"):Rs(null)},[md,n$]=g.useState(null),[kv,r$]=g.useState(1e3);g.useEffect(()=>{if(!md)return;const y=new ResizeObserver(([k])=>r$(k.contentRect.width));return y.observe(md),()=>y.disconnect()},[md]);const[s$,o$]=g.useState(()=>E_(window.localStorage)),i$=g.useMemo(()=>{const y=(e==null?void 0:e.products.find(k=>k.slug===(St==null?void 0:St.product)))??null;return y?[y.dir,y.dir&&`${y.dir}/designs`,y.dir&&`${y.dir}/attachments`,y.repoPath,y.repoPath&&`${y.repoPath}/designs`].filter(Boolean):[]},[e==null?void 0:e.products,St==null?void 0:St.product]),a$=g.useCallback(y=>{o$(y),A_(window.localStorage,y)},[]);g.useEffect(()=>{var k,A;return((A=(k=window.zero)==null?void 0:k.onKeyInTheFile)==null?void 0:A.call(k,D=>{var ce,Ne,Ae,ke,He,tt;if(!I_(document.activeElement))return;const X=Vre(D);if(X==="close"){if(!M_(St))return;(Ne=(ce=document.activeElement)==null?void 0:ce.blur)==null||Ne.call(ce),Rs(null);return}if(X==="palette"){(ke=(Ae=document.activeElement)==null?void 0:Ae.blur)==null||ke.call(Ae),ne(Ct=>Ct==="palette"?null:"palette");return}X==="app"&&((tt=(He=document.activeElement)==null?void 0:He.blur)==null||tt.call(He),window.dispatchEvent(new KeyboardEvent("keydown",{key:D.key,bubbles:!0})))}))??(()=>{})},[St]);const ao=(Ce?T:qt)??qt??null;e==null||e.products.find(y=>y.slug===(ao==null?void 0:ao.product));const gm=g.useRef(null);g.useEffect(()=>{var Ne;Rs(null);const y=T;if(!y)return;const k=gm.current;if(gm.current=null,k&&k.id===y.id){(!Tr||!((Ne=k.doc)!=null&&Ne.auto))&&Rs(k.doc);return}if(Tr)return;let A=!0;const D=(e==null?void 0:e.products.find(Ae=>Ae.slug===y.product))??null,X=D?[D.dir,`${D.dir}/designs`,`${D.dir}/attachments`,D.repoPath,D.repoPath&&`${D.repoPath}/designs`]:[],ce=async Ae=>{for(const ke of Ae.slice(0,8)){const He=await q.resolveDoc({product:y.product,src:ke});if(!A)return null;if(He!=null&&He.ok&&He.opened)return ke}return null};return(async()=>{let Ae=await ce(wj(y,[],(D==null?void 0:D.dir)??null));if(A){if(!Ae){const ke=await q.sessionTrace({product:y.product,id:y.id}).catch(()=>null);if(!A)return;const He=Dse((ke==null?void 0:ke.sessions)??[],X);Ae=await ce(wj(y,He,(D==null?void 0:D.dir)??null))}!A||!Ae||Rs({product:y.product,src:Ae,auto:!0})}})().catch(()=>{}),()=>{A=!1}},[T==null?void 0:T.id,T==null?void 0:T.product]),g.useEffect(()=>{var ke,He,tt,Ct,Ut,dn;if(!e)return;const y=new Set(wt.map(We=>We.id)),k=Vk.current,A=wt.filter(We=>WE(k,We.id));Vk.current=y,(He=(ke=window.zero)==null?void 0:ke.badge)==null||He.call(ke,wt.length);const D=We=>{var Qt;return((Qt=e.products.find(er=>er.slug===We))==null?void 0:Qt.name)??We};(Ct=(tt=window.zero)==null?void 0:tt.cornerTag)==null||Ct.call(tt,{ready:[...wt.map(We=>{var Qt,er;return{id:We.id,title:Co(We),says:We.status==="blocked"?"needs you":"is ready for you",since:((er=(Qt=We.wrote)==null?void 0:Qt.status)==null?void 0:er.ts)??We.updatedAt}}),...(e.approvals??[]).map(We=>({id:We.id,title:D(We.product??""),says:"needs a yes",open:null}))],working:sc.length});const X=new Set((e.approvals??[]).map(We=>We.id)),ce=qk.current,Ne=(e.approvals??[]).filter(We=>WE(ce,We.id));qk.current=X;const Ae=[...A.map(We=>({id:We.id,title:We.title,product:We.product,productName:We.productName,kind:"item"})),...Ne.map(We=>{var Qt,er,Pi;return{id:We.id,title:String(((Qt=We.input)==null?void 0:Qt.description)??((er=We.input)==null?void 0:er.command)??We.tool??"a command"),product:We.product,productName:((Pi=e.products.find(vd=>vd.slug===We.product))==null?void 0:Pi.name)??We.product,kind:"approval"}})];Ae.length&&((dn=(Ut=window.zero)==null?void 0:Ut.notify)==null||dn.call(Ut,Ae))},[e,wt,sc]),g.useEffect(()=>{var k,A;return((A=(k=window.zero)==null?void 0:k.onOpenSettings)==null?void 0:A.call(k,({pane:D})=>{ve(!1),Dt(D??null),Js(X=>X+1),ue(!0)}))??(()=>{})},[]),g.useEffect(()=>{as(null)},[T==null?void 0:T.id]);const l$=420;g.useEffect(()=>{var k,A;return((A=(k=window.zero)==null?void 0:k.onApprovalAnswered)==null?void 0:A.call(k,D=>Fa(D)))??(()=>{})},[]),g.useEffect(()=>{if(!Mi)return;const y=setTimeout(()=>Fa(null),l$);return()=>clearTimeout(y)},[Mi]),g.useEffect(()=>{var y;Mi||(Xu.current=((y=e==null?void 0:e.approvals)==null?void 0:y[0])??null)},[e==null?void 0:e.approvals,Mi]),g.useEffect(()=>{T&&t9(T)&&ne("reply")},[T==null?void 0:T.id]),g.useEffect(()=>{T||ne(ule)},[T]),g.useEffect(()=>{if(oe!=="reply")return;const y=k=>{var D,X,ce;const A=k.target;(D=A==null?void 0:A.closest)!=null&&D.call(A,gue)||(ne(null),(ce=(X=document.activeElement)==null?void 0:X.blur)==null||ce.call(X))};return window.addEventListener("pointerdown",y,!0),()=>window.removeEventListener("pointerdown",y,!0)},[oe]),g.useEffect(()=>{localStorage.setItem(YE,JSON.stringify([...en].slice(-2e3)))},[en]),g.useEffect(()=>{localStorage.setItem(JE,JSON.stringify(ht))},[ht]);const jt=g.useCallback(y=>{Fo(k=>new Set(k).add(y.id))},[]),ym=g.useCallback(y=>{if(y.card){W(null),Ja(y.card);return}const k=bt.indexOf(y.item);be(null),ve(!1),O(null),W(y.item),jt(y.item),k>=0&&S(k)},[bt,jt,Ja]),gd=io?Wo.findIndex(y=>y.card&&ra(y)===C):Wo.findIndex(y=>y.item===qt),c$=g.useMemo(()=>({projects:UB((e==null?void 0:e.products)??[],(e==null?void 0:e.supervisor.productOrder)??[],(e==null?void 0:e.supervisor.hiddenProducts)??[]),codexModels:un,codexDefault:At,find:(y,k)=>it.find(A=>A.id===k&&A.product===y),stateOf:cs,filed:y=>Wm(it,y),open:y=>{W(y),jt(y)}}),[e==null?void 0:e.products,e==null?void 0:e.supervisor.productOrder,e==null?void 0:e.supervisor.hiddenProducts,un,At,it,cs,jt]),vv=g.useCallback(async(y,k)=>{var Ct,Ut,dn;const A=dT(k).filter(We=>!We.task&&We.project);if(!A.length)return k;const D=(e==null?void 0:e.products)??[],X=D.find(We=>We.slug===y.product),ce=[...new Set([...((Ct=X==null?void 0:X.team)==null?void 0:Ct.people)??[],...(Ut=X==null?void 0:X.team)!=null&&Ut.sharedBy?[X.team.sharedBy]:[],...y.people??[]])].filter(Boolean),Ne=We=>{var Qt;return We&&((Qt=pe==null?void 0:pe.byId.get(We))==null?void 0:Qt.name)||(We&&We===(pe==null?void 0:pe.me)?"You":"A teammate")},Ae=ce.filter(We=>We!==(pe==null?void 0:pe.me)).map(We=>Ne(We));let ke=[];try{ke=KB(((dn=await q.itemHistory({product:y.product,id:y.id}))==null?void 0:dn.lines)??[],Ne)}catch{}const He=qB({sent:k,asker:Ne((pe==null?void 0:pe.me)??void 0),others:Ae,transcript:ke});let tt=k;for(const We of A){const Qt=D.find(Pi=>Pi.slug===We.project);if(!Qt)continue;const er=await q.compose({product:Qt.slug,title:GB(k),body:He,engine:We.engine,start:"now",...We.model?{model:We.model}:{},...We.effort?{effort:We.effort}:{},...YB(Qt,ce)});er!=null&&er.id&&(tt=HB(tt,We,er.id))}return tt},[e==null?void 0:e.products,pe]);g.useEffect(()=>{const y=new Set(wt.map(A=>A.id));if(J.current===null){J.current=y;return}const k=vF({reading:T,inbox:wt,known:J.current,spent:ze.current,typing:!!oe||et!==null});J.current=y,!(!k||!T)&&(ze.current.add(k.id),F(T),W(k),jt(k))},[wt,T,oe,et,jt]),g.useEffect(()=>{var k;if(T||!Oe)return;const y=SF(Oe,it);F(null),y&&(W(y),(k=za.current)==null||k.call(za,"Back to what you were reading"))},[T,Oe,it]),g.useEffect(()=>{const y=fz(it,T,ge);y&&W(y)},[it,T,ge]),g.useEffect(()=>{const y=dz(ge,T);if(y!==ge){j(y);return}if(!ge||hz(ge,T)!=="inbox")return;j(null),f("inbox");const k=Xa.findIndex(A=>A.id===ge.id&&A.product===ge.product);S(k>=0?k:0)},[T,ge,Xa]),g.useEffect(()=>{var k,A;return((A=(k=window.zero)==null?void 0:k.onOpenItem)==null?void 0:A.call(k,({id:D})=>{const X=[...wt,...pr,...Pn,...Er].find(ce=>ce.id===D);X&&(mn(null),W(X),jt(X))}))??(()=>{})},[wt,pr,Pn,Er,jt]);const Sv=g.useCallback(y=>{const k=Ha.find(A=>A.id===`agent:${y}`);k&&(W(k),jt(k))},[Ha,jt]),wm=g.useCallback(y=>y?[...wt,...pr,...Pn,...Er].find(k=>k.id===y)??null:null,[wt,pr,Pn,Er]),u$=g.useCallback(y=>{const k=wm(y);k&&(mn(null),W(k),jt(k))},[wm,jt]);g.useMemo(()=>{const y=(ao==null?void 0:ao.product)??null;if(!y)return[];const k=it.filter(D=>D.product===y&&D.id!==Ns).filter(D=>uF(D,{deliveredThrough:vy,hiddenUntil:Nr(D),deferredUntil:Ms(D),now:lt,live:gn.has(D.id),shipping:Ur.has(D.id),waitingOn:ro(D)})).map(D=>({key:D.id,line:D.title,at:D.updatedAt,open:()=>{W(D),jt(D)}})),A=(As?[]:(e==null?void 0:e.agents)??[]).filter(D=>D.product===y&&Wq(D,lt)).map(D=>({key:`agent:${D.pid}`,line:Hq(D),at:D.lastActiveAt||D.startedAt,open:()=>Sv(D.pid)}));return[...k,...A].sort((D,X)=>X.at-D.at)},[ao==null?void 0:ao.product,it,e==null?void 0:e.agents,Ns,vy,Nr,Ms,lt,jt,Sv,gn,Ur,ro]);const bm=g.useRef(null);g.useEffect(()=>{var k,A;const y=(T==null?void 0:T.id)??null;if(!y||y===bm.current){y||(bm.current=null);return}bm.current=y;try{(A=(k=window.zero)==null?void 0:k.track)==null||A.call(k,"task_opened")}catch{}},[T==null?void 0:T.id]);const xm=g.useRef(null),km=g.useRef(0),De=g.useCallback((y,k)=>{km.current+=1,Pa({text:y,goes:k}),xm.current&&clearTimeout(xm.current),xm.current=setTimeout(()=>Pa(null),k?VE:2500)},[]);za.current=De;const el=g.useCallback((y,k)=>{const A=Gce({rows:y,key:k,warned:b,walking:!!B});return A?(x(!0),qce(localStorage),De(A.say,A.goes),!0):!1},[b,B,De]);g.useEffect(()=>{var y;if(!((y=window.zero)!=null&&y.bootInfo)){a(!1);return}window.zero.bootInfo().then(k=>{if(wE(bE(k==null?void 0:k.screenDetail)),a(!!(k!=null&&k.reloaded)),k!=null&&k.recovered){De(k.recovered);return}if(!(k!=null&&k.reloaded))return;const A=k.builtAt?new Date(k.builtAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):null;De(A?`Reloaded · build ${A}`:"Reloaded")}).catch(()=>a(!1))},[De]),g.useEffect(()=>{var y,k;return(k=(y=window.zero)==null?void 0:y.onRecovered)==null?void 0:k.call(y,A=>{A!=null&&A.text&&De(A.text)})},[De]);const d$=g.useCallback(async(y,k=!0)=>{ne(null);const A=await q.openFreshUser(y,k);if(!A.ok){De(A.error??"It could not be opened.");return}const D=(A.notes??[]).filter(Ne=>y||!Ne.includes(".claude")),X=D.length?` · ${D[0]}`:"",ce=k?y?`Opening a new ${Je} that can see your agents.`:`Opening a brand new ${Je} with nothing of yours in it.`:`Opening a new ${Je} with no Claude Code or Codex, so setup asks which plan you pay for.`;De(`${ce} Yours keeps running.${X}`)},[De]),h$=g.useCallback(async()=>{var A;ne(null);const y=await q.openDemo();if(!y.ok){De(y.error??"It could not be opened.");return}const k=(A=y.notes)!=null&&A.length?` · ${y.notes[0]}`:"";De(`Opening a demo inbox with ${y.rows??0} rows in it. Yours keeps running.${k}`)},[De]);g.useEffect(()=>{var y,k;return(k=(y=window.zero)==null?void 0:y.onScreenDetail)==null?void 0:k.call(y,A=>wE(bE(A==null?void 0:A.detail)))},[]);const jv=g.useCallback(y=>{const k=Xa.findIndex(A=>A.id===y.id);rc.current=oz({fromTask:!!T,index:k,id:y.id})},[Xa,T]),Ds=g.useCallback(y=>{jv(y),W(null)},[jv]),us=g.useCallback(async(y,k,A,D,X,ce,Ne,Ae=ed)=>{if(await to(),X||Ds(y),ne(null),Ri(y.id),De(`${A} · press Z to undo`,X?void 0:ce),Ae<=0){await k(),await qe(),Ri(He=>He===y.id?null:He);return}const ke=setTimeout(async()=>{var He;((He=Ts.current)==null?void 0:He.timer)===ke&&(Ts.current=null,await k(),await qe(),Ri(tt=>tt===y.id?null:tt))},ed);Ts.current={item:y,timer:ke,run:k,restore:D,undid:Ne}},[to,Ds,qe,De]),Cv=g.useCallback(async y=>{const k=y.agent,A=Pd(k),D=k.lastActiveAt||k.startedAt||Date.now();await us(y,async()=>{await q.closeAgent({key:A,through:D}),Wt({label:`Back in your inbox: ${k.name}`,undoes:`put ${k.name} back in your inbox`,brings:y,run:async()=>{await q.closeAgent({key:A,through:0})}})},`Closed: ${k.name}`)},[us,Wt]),Nv=g.useCallback(async(y,k)=>{const A=p;await us(y,async()=>{w(k),Wt({label:"Back in your inbox: what is not running",undoes:"put the stopped tasks back in your inbox",run:async()=>{w(A)}})},"Closed: what is not running")},[us,w,p,Wt]),mr=g.useCallback(async(y,{stay:k,force:A}={})=>{var ce;const D=iy(B,y.id,fo,Xo);if(D){De(D);return}if(el([y],"E"))return;if(y.agent){await Cv(y);return}if(pn(y)){const Ne=(ce=e==null?void 0:e.supervisor.spawnTrouble)==null?void 0:ce.since;Ne&&await Nv(y,Ne);return}if(!A&&Li(y).length){((T==null?void 0:T.id)!==y.id||(T==null?void 0:T.product)!==y.product)&&(W(y),jt(y)),as(null),dd(hd(y));return}const X=[{product:y.product,id:y.id,words:"Undid closing it"}];await us(y,async()=>{await q.answer({product:y.product,id:y.id,status:"done"}),Wt({label:`Reopened: ${zs(y.title,jc)}`,undoes:`reopen “${zs(y.title,jc)}”`,brings:y,undid:X,run:async()=>{await q.answer({product:y.product,id:y.id,status:"open"})}})},`Closed: ${zs(y.title,jc)}`,void 0,k,void 0,X)},[us,Cv,Nv,(Yv=e==null?void 0:e.supervisor.spawnTrouble)==null?void 0:Yv.since,B,De,Wt,el,Li,T,jt]),yd=g.useCallback(async(y,{stay:k}={})=>{if(pn(y)){await mr(y);return}const A=wl(y),D=A.find(Ne=>Ne.recommended)??A[0],X=y.status==="open"&&y.kind!=="question"&&y.kind!=="review"&&!(y.labels??[]).includes("founder")&&!wue(y),ce=async(Ne,Ae)=>{const ke=[{product:y.product,id:y.id,words:"Undid your approval"}];await us(y,async()=>{await q.answer({product:y.product,id:y.id,answer:Ne}),Wt({label:"Approval withdrawn, back in your inbox",undoes:"take back that approval and stop the agent",brings:y,undid:ke,run:async()=>{var He,tt;await((tt=(He=window.zero)==null?void 0:He.stopSession)==null?void 0:tt.call(He,{product:y.product,id:y.id})),await q.answer({product:y.product,id:y.id,answer:"(withdrawn)",status:"open"})}})},Ae,void 0,k,{product:y.product,id:y.id},ke)};y.kind==="question"&&D&&!y.answer?await ce(`Option ${D.n}: ${D.text}`,`Approved: option ${D.n} → ${y.productName}`):y.kind==="review"&&!y.answer?await ce("Approved. Proceed as you proposed.",`Approved → ${y.productName} will enact it`):X?await ce("Approved. Run it.",`Running → ${y.title.slice(0,40)}`):await mr(y)},[qe,De,mr]),wd=g.useCallback(async(y,k)=>{var X,ce;const A=Li(y),D=(X=ky(A.length))==null?void 0:X.options.find(Ne=>Ne.n===k);if(D){if(dd(null),as(null),D.act==="decide"){(ce=document.querySelector(".made-waiting"))==null||ce.scrollIntoView({block:"center",behavior:"smooth"});return}for(const Ne of A)D.act==="start"?await yd(Ne,{stay:!0}):await mr(Ne,{stay:!0,force:!0});await mr(y,{force:!0})}},[Li,yd,mr]),vm=g.useCallback(()=>{dd(null),as(null)},[]),f$=g.useCallback(async(y,k,A,D,X,ce,Ne)=>{var vd;if(y.agent||pn(y)||nr(y))return;const Ae=f1(y.status),ke=Et=>{var Ko,pc;n9(y,(D==null?void 0:D.words)??k,(D==null?void 0:D.attachments)??[]),((Ko=le.current)==null?void 0:Ko.id)===y.id&&((pc=le.current)==null?void 0:pc.product)===y.product?(ne("reply"),De((Et==null?void 0:Et.message)||"Could not send. Your message is back in the reply box.")):De("A message you sent did not reach its agent. Click to open it, your words are back in the reply box.",{product:y.product,id:y.id})};if(((vd=Fe.current)==null?void 0:vd.step)==="answer"&&Fe.current.item===y.id){await q.answer({product:y.product,id:y.id,answer:k,...Ae?{status:Ae}:{}}),Es({t:"replied",at:Date.now()}),await qe();return}if(e==null?void 0:e.supervisor.running.some(Et=>Et.itemId===y.id&&Et.product===y.product)){j({product:y.product,id:y.id}),ne(null);const Et=Date.now(),Zt={product:y.product,id:y.id,at:Et,text:k,held:Tm(sr())},Ko={...Zt,held:!1};me(Mr=>[...Mr,Zt]);const pc={label:"Your message is already with the agent. Send another one to add to it.",undoes:"go back to that conversation",run:async()=>{W(y),jt(y)}},Em=async()=>{me(Mr=>Mr.map(hs=>hs===Zt?Ko:hs)),Wt(pc),await LP({send:()=>q.answer({product:y.product,id:y.id,answer:k,...A!=null?{priority:A}:{},...X!==void 0?{permissionMode:X}:{},...Ne?{model:Ne.model,effort:Ne.effort}:{}}),accepted:async()=>{await qe(),setTimeout(()=>me(Mr=>Mr.filter(hs=>hs!==Zt&&hs!==Ko)),qE)},failed:Mr=>{me(hs=>hs.filter(sl=>sl!==Zt&&sl!==Ko)),Jn(hs=>hs.filter(sl=>sl!==pc)),ke(Mr)}})};if(await to(),!Tm(sr())){Em();return}const E0=setTimeout(()=>{var Mr;((Mr=Ts.current)==null?void 0:Mr.timer)===E0&&(Ts.current=null,Em())},ed);Ts.current={item:y,timer:E0,run:Em,restore:()=>{me(hs=>hs.filter(sl=>sl!==Zt));const Mr=hg(y,(D==null?void 0:D.words)??k,(D==null?void 0:D.attachments)??[]);return Mr&&ne("reply"),Mr?{item:y}:null}};return}const tt=Us(e==null?void 0:e.products.find(Et=>Et.slug===y.product)),Ct={product:y.product,id:y.id,at:Date.now(),text:k,held:!0};tt&&me(Et=>[...Et,Ct]);const Ut=()=>(me(Et=>Et.filter(Zt=>Zt!==Ct)),hg(y,(D==null?void 0:D.words)??k,(D==null?void 0:D.attachments)??[])?{item:y}:null),dn=dF(y,Date.now()),We=y.runAt??0,Qt=y.snoozedUntil??0,er=uz(y,k,ce)||tt;er&&j({product:y.product,id:y.id});const Pi=[{product:y.product,id:y.id,words:"Undid your reply"}];await us(y,async()=>{try{const Et=tt?await vv(y,k):k;Et!==k&&(Ct.text=Et,me(Zt=>[...Zt])),await q.answer({product:y.product,id:y.id,answer:Et,...Ae?{status:Ae}:{},...A!=null?{priority:A}:{},...X!==void 0?{permissionMode:X}:{},...Ne?{model:Ne.model,effort:Ne.effort}:{}})}catch(Et){me(Zt=>Zt.filter(Ko=>Ko!==Ct)),ke(Et);return}tt&&setTimeout(()=>me(Et=>Et.filter(Zt=>Zt!==Ct)),qE),dn&&(We>Date.now()&&await q.schedule({product:y.product,id:y.id,runAt:0}),Qt>Date.now()&&await q.snooze({product:y.product,id:y.id,snoozedUntil:0}),Ht(Et=>{const Zt={...Et};return delete Zt[y.id],Zt})),Wt({label:"Reply withdrawn, back in your inbox",undoes:"take back that reply and stop the agent",restore:Ut,undid:Pi,run:async()=>{var Et,Zt;dn&&We&&await q.schedule({product:y.product,id:y.id,runAt:We}),dn&&Qt&&await q.snooze({product:y.product,id:y.id,snoozedUntil:Qt}),await((Zt=(Et=window.zero)==null?void 0:Et.stopSession)==null?void 0:Zt.call(Et,{product:y.product,id:y.id})),await q.answer({product:y.product,id:y.id,...p1(y.status)}),j(null)}})},tt?"Sent":`Sent → ${y.productName}`,Ut,er,{product:y.product,id:y.id},Pi,Tm(sr())?ed:0)},[us,e==null?void 0:e.supervisor.running,e==null?void 0:e.products,De,qe,jt,Wt,vv,Es]),p$=g.useCallback(async(y,k)=>{const A=y.agent;if(!A)return;ne(null),Ds(y);const D=await q.agentReply({pid:A.pid,text:k});if(D!=null&&D.ok?D.working?De(`${A.name} is working on it`):De(`Sent → ${A.name}`):De((D==null?void 0:D.reason)??"The message could not be handed over."),D!=null&&D.ok&&D.key){const X=D.key;Wt({label:`Back in your inbox. Your message to ${A.name} had already been sent.`,undoes:`take back your message to ${A.name}`,run:async()=>{await q.unreplyAgent({key:X}),qe()}})}qe()},[qe,De,Ds]),m$=g.useCallback(async y=>{const k=y.agent;if(!k)return;const A=await q.agentReveal({pid:k.pid});A!=null&&A.ok||De((A==null?void 0:A.reason)??`${st} cannot tell which window it is running in.`)},[De]),bd=g.useCallback(async(y,k)=>{if(!(y.agent||pn(y)||nr(y)))try{await q.answer({product:y.product,id:y.id,answer:tB(k)}),De(k==="yes"?`Imported into ${y.productName}. It is in your inbox.`:"Not imported. It waits in Closed under Not imported.")}catch(A){De(`Could not answer: ${A.message}`)}},[De]),xd=g.useCallback(async(y,k)=>{if(y.agent||pn(y)||nr(y))return;const A=wl(y).find(ce=>ce.n===k);if(!A)return;if(Rz(A.text)){await mr(y);return}const D=f1(y.status),X=[{product:y.product,id:y.id,words:"Undid picking",choice:A.text.replace(/\s*\(recommended\)\s*$/i,"").trim()}];await us(y,async()=>{await q.answer({product:y.product,id:y.id,answer:`Option ${A.n}: ${A.text}`,...D?{status:D}:{}}),Wt({label:`Option ${A.n} withdrawn, back in your inbox`,undoes:`take back option ${A.n}`,brings:y,undid:X,run:async()=>{var ce,Ne;await((Ne=(ce=window.zero)==null?void 0:ce.stopSession)==null?void 0:Ne.call(ce,{product:y.product,id:y.id})),await q.answer({product:y.product,id:y.id,...p1(y.status)})}})},`Option ${A.n} → ${y.productName}`,void 0,void 0,{product:y.product,id:y.id},X)},[us,Wt,mr]),Ev=g.useCallback((y,k,A,D,X)=>{Wt({label:y,undoes:k,undid:X,restore:()=>s9(A)?{compose:!0}:null,run:D})},[Wt]),Av=g.useCallback(async(y,k)=>{if(!y.length)return;const A=Ma(kr(k)).toLowerCase();for(const D of y)delete td.current[D.id];await Promise.all(y.map(D=>q.answer({product:D.product,id:D.id,priority:k}))),De(y.length>1?`${y.length} set to ${A}`:`Priority: ${A}`),await qe()},[qe,De]),[ds,kd]=g.useState(null),$i=g.useCallback(y=>{const k=Array.isArray(y)?y:[y];if(k.some(pn)){De("Nothing to put off here. Press E to close it until something else stops.");return}const A=k.map(D=>Noe(B,D.id,fo)).find(D=>!!D);if(A){De(A);return}el(k,"L")||(kd(y),ne("snooze"))},[B,De,el]),tl=g.useCallback(async(y,k)=>{y.agent?await q.scheduleAgent({key:Pd(y.agent),runAt:k}):await q.snooze({product:y.product,id:y.id,snoozedUntil:k})},[]),g$=g.useCallback(async(y,k,A)=>{const D=Array.isArray(y)?y:[y],X=D;ne(null),kd(null),Re(new Set);try{for(const Ne of X)await tl(Ne,k)}catch(Ne){De(`Could not move it to Later: ${(Ne==null?void 0:Ne.message)??"the store refused the write"}`),qe();return}Ds(D[0]),De(D.length>1?`${D.length} moved to Later. Back ${A.toLowerCase()}`:`Moved to Later. Back ${A.toLowerCase()}`);const ce=new Map(X.map(Ne=>[Ne.id,(Ne.agent?Ne.runAt:Ne.snoozedUntil)??0]));Wt({label:"Back in your inbox",undoes:"undo moving it to Later",brings:_N(D),undid:X.filter(Ne=>!Ne.agent).map(Ne=>({product:Ne.product,id:Ne.id,words:"Undid moving it to Later"})),run:async()=>{for(const Ne of X)await tl(Ne,ce.get(Ne.id)??0);qe()}}),qe()},[De,qe,Zp,tl,Ds,Wt]),nl=g.useCallback(async y=>{const k=Array.isArray(y)?y:[y],A=new Map(k.map(ke=>[ke.id,(ke.agent?ke.runAt:ke.snoozedUntil)??0])),D=new Map(k.filter(ke=>!ke.agent&&(ke.runAt??0)>Date.now()).map(ke=>[ke.id,ke.runAt]));ne(null),kd(null),W(null),Re(new Set);const X=k.every(ke=>lh(ke,Date.now())),ce=k.every(ke=>bo(ke)),Ne=ce?"Started":X?"Running again":"Back in the inbox";De(k.length>1?`${k.length} ${ce?"started":X?"running again":"back in the inbox"}`:Ne),Ht(ke=>{const He={...ke};for(const tt of k)delete He[tt.id];return He});for(const ke of k)(ke.agent||ke.snoozedUntil)&&await tl(ke,0);for(const ke of k)D.has(ke.id)&&await q.schedule({product:ke.product,id:ke.id,runAt:0});const Ae=k.filter(ke=>bo(ke));for(const ke of Ae)await q.threadEdit(ke.product,ke.id,{start:"now"});Wt({label:"Returned to Later",undoes:"put it back in Later",undid:k.filter(ke=>!ke.agent).map(ke=>({product:ke.product,id:ke.id,words:bo(ke)?"Undid starting it":"Undid bringing it back"})),run:async()=>{for(const ke of k)await tl(ke,A.get(ke.id)??0);for(const ke of k)D.has(ke.id)&&await q.schedule({product:ke.product,id:ke.id,runAt:D.get(ke.id)});for(const ke of Ae)await q.threadEdit(ke.product,ke.id,{start:"later"});qe()}}),qe()},[De,qe,tl,Wt]),Sm=g.useCallback(async y=>{const k=no.filter(D=>y.has(D.id)&&iy(B,D.id,fo,Xo));if(k.length){De(iy(B,k[0].id,fo,Xo));return}const A=no.filter(D=>y.has(D.id));if(!el(A,"E")){for(const D of A)D.agent?await q.closeAgent({key:Pd(D.agent),through:D.agent.lastActiveAt||D.agent.startedAt||Date.now()}):await q.answer({product:D.product,id:D.id,status:"done"});Wt({label:`Reopened ${A.length} items`,undoes:`reopen those ${A.length} tasks`,brings:_N(A),undid:A.filter(D=>!D.agent).map(D=>({product:D.product,id:D.id,words:"Undid closing it"})),run:async()=>{for(const D of A)D.agent?await q.closeAgent({key:Pd(D.agent),through:0}):await q.answer({product:D.product,id:D.id,status:"open"})}}),De(`Closed: ${A.length} items`),Re(new Set),await qe()}},[no,qe,De,B,el]),Uo=g.useCallback(y=>{var k;return!!((k=e==null?void 0:e.supervisor.running)!=null&&k.some(A=>A.itemId===y.id))},[e==null?void 0:e.supervisor.running]),Tv=g.useCallback(async y=>{var A,D;if(y.agent||pn(y)||nr(y))return;await to();const k=Uo(y);j({product:y.product,id:y.id}),await((D=(A=window.zero)==null?void 0:A.stopSession)==null?void 0:D.call(A,{product:y.product,id:y.id})),De(k?"Agent stopped. Back in your inbox. Reply to redirect it.":"Stopped before it started. Back in your inbox. Reply to redirect it."),await qe()},[qe,De,Uo,to]),Mv=g.useCallback(async y=>{var A,D;const k=await((D=(A=window.zero)==null?void 0:A.runNow)==null?void 0:D.call(A,{product:y.product,id:y.id}));De(k!=null&&k.ok?"Up next. It starts as soon as an agent is free.":(k==null?void 0:k.reason)==="running"?"Already running.":(k==null?void 0:k.reason)==="paused"?"Agents are paused. Turn them back on to run this.":(k==null?void 0:k.reason)==="scheduled"?"This task is scheduled for later.":(k==null?void 0:k.reason)==="held"?"Another session still holds this task. It starts when that lets go.":"This task is no longer waiting."),await qe()},[qe,De]),Rv=g.useCallback(async y=>{var A,D;if(y.agent||pn(y)||nr(y))return;const k=await((D=(A=window.zero)==null?void 0:A.redeliver)==null?void 0:D.call(A,{product:y.product,id:y.id}));De(k!=null&&k.ok?`A fresh agent is picking this up → ${y.productName}`:"Nothing here to restart"),await qe()},[qe,De]),Iv=g.useCallback(async y=>{var k,A;y.agent||pn(y)||nr(y)||(await((A=(k=window.zero)==null?void 0:k.reopen)==null?void 0:A.call(k,{product:y.product,id:y.id})),De(`Back in the queue → ${y.productName}`),Ds(y),await qe())},[qe,De,Ds]),jm=g.useCallback(y=>!y.agent&&cF(y,{deferredUntil:Ms(y),now:lt,live:gn.has(y.id)}),[Ms,lt,gn]),y$=g.useCallback(async y=>{var A,D;const k=await((D=(A=window.zero)==null?void 0:A.resumeAgents)==null?void 0:D.call(A,y?{ids:y}:void 0));Re(new Set),De(k!=null&&k.cleared?`Resuming: ${k.cleared} interrupted ${k.cleared===1?"agent":"agents"} respawning`:"Nothing stranded. Anything waiting respawns on its own"),await qe()},[qe,De]),Dv=g.useCallback(async y=>{var ce,Ne;const k=y.map(Ae=>Ae.id),A=await((Ne=(ce=window.zero)==null?void 0:ce.resumeItems)==null?void 0:Ne.call(ce,{ids:k}));Re(new Set);const D=(A==null?void 0:A.resumed)??0,X=(A==null?void 0:A.queued)??0;De(D||X?[D?`${D} resumed`:"",X?`${X} waiting for a slot`:""].filter(Boolean).join(", "):A!=null&&A.working?"Already working on it":"Nothing to resume"),D>0&&Ds(y[0]),await qe()},[qe,De,Ds]),rl=g.useCallback(async()=>{var Ct,Ut;const y=Ts.current;if(y){Ts.current=null,clearTimeout(y.timer),rc.current=null,Ri(null);const dn=(Ct=y.restore)==null?void 0:Ct.call(y),We=Date.now();Qs(y.undid,We,We),W(y.item),De(dn?"Undone. Your message is back in the reply box.":"Undone. Nothing was sent.");return}const k=Date.now(),{take:A,rest:D,instant:X}=wse(hr,k);if(!A){Zs.current=null,De(vse);return}const ce=Zs.current,Ne=(ce==null?void 0:ce.entry)===A&&bse(ce.at,k);if(!X&&!Ne){Zs.current={entry:A,at:k},De(xse(A.undoes));return}Zs.current=null,rc.current=null,Jn(D);const Ae=Date.now();try{await A.run()}catch(dn){Jn(We=>[...We,A]),De(`Could not undo that. ${(dn==null?void 0:dn.message)??dn}`);return}Qs(A.undid,Ae,Date.now());const ke=(Ut=A.restore)==null?void 0:Ut.call(A),He=mue(ke??null),tt=kse(ke,A.brings);De(He?`${A.label} · your message is back in the reply box`:ke?`${A.label} · your thread is back in the new thread card`:A.label),await qe(),tt.open?(W(tt.open),jt(tt.open)):tt.compose&&(W(null),ne("compose"))},[hr,qe,De,jt,Qs]),Cm=g.useCallback(y=>{const k=[...wt,...pr,...Pn,...Er].find(A=>A.id===y.id&&A.product===y.product);Pa(null),k&&(mn(null),W(k),jt(k))},[wt,pr,Pn,Er,jt]);g.useEffect(()=>{const y=k=>{var Ne,Ae;if(ns.current||(!Sse.has(k.key)&&k.key!=="z"&&k.key!=="Z"&&(Zs.current=null),V))return;if(Q){k.key==="Escape"&&(k.preventDefault(),he(!1));return}const A=k.target,D=(A==null?void 0:A.tagName)==="TEXTAREA"||(A==null?void 0:A.tagName)==="INPUT"||!!(A!=null&&A.isContentEditable);if((k.metaKey||k.ctrlKey)&&k.key.toLowerCase()==="k"){k.preventDefault(),ne(ke=>ke==="palette"?null:"palette");return}if((k.metaKey||k.ctrlKey)&&k.key.toLowerCase()==="j"){if(k.preventDefault(),!T||T.agent){De("Open a task to use its terminal");return}window.dispatchEvent(new Event("task-terminal-toggle"));return}if(k.key==="Tab"){if(!(!D&&!oe&&!T&&!z&&!Ce&&!V&&!Ve&&!de&&et===null&&xt.view==="list"))return;k.preventDefault(),P(null),(Ae=(Ne=document.activeElement)==null?void 0:Ne.blur)==null||Ae.call(Ne),Re(new Set),f(h4(cm,h,k.shiftKey)),S(0);return}if((k.metaKey||k.ctrlKey)&&!k.shiftKey&&k.key.toLowerCase()==="a"&&!D&&!oe){k.preventDefault(),W(null),Re(ke=>ke.size>=bt.length&&bt.length>0?new Set:new Set(bt.map(He=>He.id)));return}if(k.metaKey||k.ctrlKey||k.altKey)return;if(oe||D){k.key==="Escape"&&!D&&ne(null);return}if(lle(k.key)&&k.preventDefault(),k.key==="\\"){k.preventDefault(),vs();return}if(k.key==="/"){k.preventDefault(),ac();return}const X=pue(k.key,fr);if(X){k.preventDefault(),Cm(X);return}if(z){k.key==="Escape"?(k.preventDefault(),xe(null),Z(!1)):(k.key==="r"||k.key==="R")&&(k.preventDefault(),Z(!0));return}if(T){if(ka(St==null?void 0:St.src)==="code"&&X$(k.key))return;const ke=hc===hd(T)?ky(Li(T).length):null;if(ke){const tt=ke.options.map(Ct=>Ct.n);k.key==="Escape"?(k.preventDefault(),vm()):k.key==="ArrowDown"?(k.preventDefault(),as(Ct=>tt[Math.min(tt.indexOf(Ct??-1)+1,tt.length-1)])):k.key==="ArrowUp"?(k.preventDefault(),as(Ct=>{const Ut=tt.indexOf(Ct??-1);return Ut<=0?null:tt[Ut-1]})):k.key==="Enter"?(k.preventDefault(),eo!==null&&wd(T,eo)):/^[1-9]$/.test(k.key)?wd(T,Number(k.key)):(k.key==="z"||k.key==="Z")&&(k.preventDefault(),rl());return}const He=Fb(T)?wl(T):[];if(k.key==="Escape")T_(St)?xv():W(null);else if(k.key==="ArrowDown"&&He.length)k.preventDefault(),as(tt=>{const Ct=He.findIndex(Ut=>Ut.n===tt);return He[Math.min(Ct+1,He.length-1)].n});else if(k.key==="ArrowUp"&&He.length)k.preventDefault(),as(tt=>{const Ct=He.findIndex(Ut=>Ut.n===tt);return Ct<=0?null:He[Ct-1].n});else if(k.key==="Enter")k.preventDefault(),eo!==null&&xd(T,eo);else if(k.key==="j"||k.key==="J"||k.key==="k"||k.key==="K"){k.preventDefault();const tt=qm(Wo,{item:T},k.key==="j"||k.key==="J"?1:-1,gd);tt&&ym(tt)}else k.key==="e"||k.key==="E"?(k.preventDefault(),mr(T)):k.key==="r"||k.key==="R"?(k.preventDefault(),Rs(null),ne("reply")):k.key==="c"||k.key==="C"||k.key==="n"||k.key==="N"?(k.preventDefault(),ne("compose")):k.key==="l"||k.key==="L"?$i(T):k.key==="z"||k.key==="Z"?(k.preventDefault(),rl()):/^[1-9]$/.test(k.key)&&xd(T,Number(k.key));return}if(de&&Ve){if(k.key==="Escape")k.preventDefault(),be(null),ve(!1);else if(k.key==="j"||k.key==="J"||k.key==="k"||k.key==="K"){k.preventDefault();const ke=qm(Wo,{card:de},k.key==="j"||k.key==="J"?1:-1,gd);ke&&ym(ke)}else k.key==="c"||k.key==="C"||k.key==="n"||k.key==="N"?(k.preventDefault(),ne("compose")):(k.key==="z"||k.key==="Z")&&(k.preventDefault(),rl());return}const ce=ke=>{const He=qm(Wo,io?{card:io}:qt?{item:qt}:null,ke,gd);if(!He)return;if(He.card){O(ra(He));return}const tt=bt.indexOf(He.item);O(null),tt>=0&&S(tt)};switch(k.key){case"j":case"J":case"ArrowDown":{if(k.preventDefault(),P(null),!k.shiftKey){$.size&&Re(new Set),ce(1);break}const ke=Math.min(v+1,Math.max(0,bt.length-1));Re(He=>new Set([...He,...qt?[qt.id]:[],...bt[ke]?[bt[ke].id]:[]])),O(null),S(ke);break}case"k":case"K":case"ArrowUp":{if(k.preventDefault(),P(null),!k.shiftKey){$.size&&Re(new Set),ce(-1);break}const ke=Math.max(0,v-1);Re(He=>new Set([...He,...qt?[qt.id]:[],...bt[ke]?[bt[ke].id]:[]])),O(null),S(ke);break}case"ArrowLeft":case"ArrowRight":oo&&(k.preventDefault(),P(null),$.size&&Re(new Set),O(null),S(j4(oo,v,k.key==="ArrowLeft"?-1:1)));break;case"Enter":!$.size&&Ot?(W(Ot),jt(Ot)):!$.size&&io&&Ja(io);break;case"e":case"E":k.preventDefault(),h==="snoozed"?nl($.size?no.filter(ke=>$.has(ke.id)):Ot?[Ot]:[]):$.size?Sm($):Ot&&h==="inbox"&&mr(Ot);break;case"r":case"R":!$.size&&Ot&&h==="inbox"&&(k.preventDefault(),W(Ot),jt(Ot),ne("reply"));break;case"1":!$.size&&Ot&&Qi(Ot)&&(k.preventDefault(),bd(Ot,"yes"));break;case"2":!$.size&&Ot&&Qi(Ot)&&(k.preventDefault(),bd(Ot,"no"));break;case"i":case"I":!$.size&&Ot&&h==="done"&&Ly(Ot)&&(k.preventDefault(),bd(Ot,"yes"));break;case"l":case"L":$.size?$i(no.filter(ke=>$.has(ke.id))):Ot&&(h==="inbox"||h==="snoozed")&&$i(Ot);break;case"c":case"C":case"n":case"N":k.preventDefault(),ne("compose");break;case"z":case"Z":rl();break;case"b":case"B":et===null&&!Ve&&!de&&(k.preventDefault(),qa(Hm(xt)),S(0));break;case"Escape":$.size?Re(new Set):et!==null&&Bo();break}};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[oe,Q,T,z,Ce,vs,qt,Ot,bt,h,mr,$i,xd,rl,jt,eo,Pn,nl,it,no,Sm,v,De,e,$,qe,V,et,ac,Bo,St,Ho,gv,Ve,de,xt,qa,cm,oo,Wo,io,gd,ym,Ja,hc,Li,wd,vm,fr,Cm]),g.useEffect(()=>{var y,k;et!==null&&(T||oe||V?(y=jr.current)==null||y.blur():(k=jr.current)==null||k.focus())},[et,T,oe,V]),g.useEffect(()=>{S(y=>Math.min(y,Math.max(0,bt.length-1)))},[bt.length]),g.useEffect(()=>{if(i===null||i&&!r)return;const y={view:h};T&&(y.item={product:T.product,id:T.id}),z&&(y.repeat={product:z.product,id:z.id}),St&&(y.doc={product:St.product,src:St.src}),V&&(y.settings=!0),et!==null&&(y.search=et),qt&&(y.row=qt.id),RO(window.localStorage,y)},[i,r,h,T==null?void 0:T.id,T==null?void 0:T.product,z==null?void 0:z.id,St==null?void 0:St.src,St==null?void 0:St.product,V,et,qt==null?void 0:qt.id]),g.useEffect(()=>{if(r||i!==!0||!e)return;if(B||XN({products:QN(e.products),done:iE(localStorage),forced:!!zt.current})){s(!0);return}const y=n.current;if(!WN(y)){s(!0);return}if(y.repeat&&Oi.length===0)return;s(!0),f(y.view),y.settings&&ue(!0),y.search!==void 0&&(Yn.current={view:y.view,selected:0},mn(y.search));const k=y.repeat?Oi.find(D=>D.id===y.repeat.id&&D.product===y.repeat.product)??null:null,A=y.item?no.find(D=>D.id===y.item.id&&D.product===y.item.product)??null:null;k?xe(k):A&&(gm.current={id:A.id,doc:y.doc?{...y.doc}:null},y.scroll&&d({id:A.id,top:y.scroll}),W(A)),o.current=y.row??null},[r,i,e,Oi,no,B]),g.useEffect(()=>{if(!r||!o.current)return;const y=bt.findIndex(k=>k.id===o.current);y>=0?(o.current=null,S(y)):bt.length&&(o.current=null)},[r,bt]);const w$=i===null||i===!0&&!r&&WN(n.current);g.useEffect(()=>{const y=rc.current;if(!y||!iz({view:h,onBoard:Qa})||T)return;rc.current=null;const k=az(Xa,y);if(!k)return;W(k.item),jt(k.item);const A=Qa?bt.findIndex(D=>D.id===k.item.id&&D.product===k.item.product):k.index;S(A>=0?A:0)},[Xa,h,Qa,bt,T,jt]);const Tr=Vle({inFullScreen:Ce,walking:As}),Ov=!!T&&!V,Nm=PP(Ho,kv),[b$,x$]=g.useState(null),k$="balanced",[v$,S$]=g.useState(null),[j$,C$]=g.useState(null),Lv=!ss,N$=vs,E$=async(y,k)=>{if(y.agent||pn(y)||nr(y))return;const A=rp(y);try{A?(await q.setRepeat({product:y.product,id:A,rule:k}),De(`Now ${To(k)}`)):(await q.composeRepeat({product:y.product,title:y.title,body:y.body,priority:y.priority,rule:k,engine:y.engine,model:y.model}),De(`Repeating: ${To(k)}`)),oc(await q.repeats())}catch(D){De(`Not set: ${D.message}`)}};if(g.useMemo(()=>{const y=new Date;return y.setHours(0,0,0,0),it.filter(k=>k.status==="done"&&!sp(k)&&k.updatedAt>=y.getTime()).length},[it]),g.useEffect(()=>{jb(Eh(Wr)),document.documentElement.setAttribute("data-machine",Cn);const y=Cb(Wr,js,Cn);Nb(y),y!=="none"&&Th(Ah(localStorage.getItem(ml),y))},[!1,!1,Wr,js,Cn]),w$)return l.jsx("div",{className:"boot",children:Je});if(!e)return l.jsx("div",{className:"boot",children:Je});const A$=et===null&&!T&&!z&&bt.length===0&&!(h==="snoozed"&&Oi.length>0);return et===null&&!T&&!z&&bt.length===0&&(h==="snoozed"&&Oi.length>0),l.jsx(Xt.Provider,{value:pe,children:l.jsx(_x.Provider,{value:c$,children:l.jsx(Qb.Provider,{value:gn,children:l.jsx(Zb.Provider,{value:HL,children:l.jsxs("div",{"data-design-toolbar":t$?bv:"corner","data-preview-treatment":ZL,"data-reading-width":k$,"data-artifact-layout":St?Nm:void 0,"data-chrome":Za?QL?"up":"away":void 0,className:`app workspace-layout${T&&!V?" workspace-task":""}${V?" workspace-settings":""}${Ve?" workspace-team":""}${Lv?" workspace-collapsed":""}${St?" doc-open":""}${nc?" banded":""}${oe==="reply"?" composing":""}`,children:[Ln&&l.jsx(hue,{signedOut:Ys,error:((Gv=e==null?void 0:e.team)==null?void 0:Gv.error)??null,waitingUrl:((Xv=(Jv=e==null?void 0:e.team)==null?void 0:Jv.signingIn)==null?void 0:Xv.url)??null}),Is&&l.jsxs("div",{className:"review-lab-controls",children:[l.jsx("span",{children:"Review exploration"}),l.jsxs("select",{"aria-label":"Focus controls",value:pv,onChange:y=>YL(y.target.value),children:[l.jsx("option",{value:"text",children:"Focus · Text only"}),l.jsx("option",{value:"corners",children:"Focus · Frame corners + label"}),l.jsx("option",{value:"corners-icon",children:"Focus · Frame corners button"}),l.jsx("option",{value:"corners-bare",children:"Focus · Bare frame corners"}),l.jsx("option",{value:"layout",children:"Focus · Workspace layout"})]}),l.jsxs("select",{"aria-label":"Review file type",value:pd,onChange:y=>{fv(y.target.value),Rs(null)},children:[l.jsx("option",{value:"code",children:"Code"}),l.jsx("option",{value:"design",children:"Design"}),l.jsx("option",{value:"notes",children:"Text"}),l.jsx("option",{value:"multiple",children:"All three"})]}),l.jsxs("select",{"aria-label":"Review actions",value:dm,onChange:y=>qL(y.target.value),children:[l.jsx("option",{value:"header-balanced-open",children:"1 · Balanced · open only"}),l.jsx("option",{value:"header-tools-open",children:"2 · Compact · open only"}),l.jsx("option",{value:"header-card-only",children:"3 · Clickable card · no controls"}),l.jsx("option",{value:"header-feedback-only",children:"4 · Clickable card · feedback tools"}),l.jsx("option",{value:"header-balanced",children:"Compare · all controls"})]}),pd!=="code"&&l.jsxs("select",{"aria-label":"Text surface",value:hm,onChange:y=>GL(y.target.value),children:[l.jsx("option",{value:"clear",children:"Text · Fully transparent"}),l.jsx("option",{value:"glass",children:"Text · Matched glass"})]})]}),!Is&&q.isFixtures&&new URLSearchParams(location.search).has("artifactTweaks")&&l.jsxs("div",{className:"artifact-tweaks",children:[l.jsxs("select",{"aria-label":"Design toolbar",value:bv,onChange:y=>e$(y.target.value),children:[l.jsx("option",{value:"floating",children:"Floating bar"}),l.jsx("option",{value:"corner",children:"Corner controls"}),l.jsx("option",{value:"edge",children:"Top edge"}),l.jsx("option",{value:"always",children:"Always visible"})]}),T&&l.jsxs("select",{"aria-label":"Sample artifact",value:pd,onChange:y=>{fv(y.target.value),Rs(null)},children:[l.jsx("option",{value:"multiple",children:"Multiple artifacts"}),l.jsx("option",{value:"design",children:"Design sample"}),l.jsx("option",{value:"code",children:"Code sample"}),l.jsx("option",{value:"notes",children:"Notes sample"})]})]}),l.jsx(Fle,{update:b1(e==null?void 0:e.update,{walking:As,closed:""})?{installing:!!((Qv=e==null?void 0:e.update)!=null&&Qv.installing),version:(Zv=e==null?void 0:e.update)==null?void 0:Zv.newVersion,changes:(e0=e==null?void 0:e.update)==null?void 0:e0.changes,behind:(t0=e==null?void 0:e.update)==null?void 0:t0.behind,error:(n0=e==null?void 0:e.update)==null?void 0:n0.error}:null,onUpdate:()=>{q.updateInstall()},move:x1(e==null?void 0:e.update,{walking:As,closed:""})?{place:((r0=e==null?void 0:e.update)==null?void 0:r0.place)??null,error:((s0=e==null?void 0:e.update)==null?void 0:s0.moveError)??null}:null,onMove:()=>{q.updateMove()},page:V?"settings":null,onFeedback:()=>ie(!0),teamPage:we&&!V,hasTeam:!!((o0=e==null?void 0:e.team)!=null&&o0.configured),team:(e==null?void 0:e.team)??null,onInvite:()=>{ve(!1),be(null),Bo(),W(null),Ye(!0),Dt("team"),Js(y=>y+1),ue(!0)},onAccount:()=>{ve(!1),be(null),Bo(),W(null),Ye(!1),Dt("team"),Js(y=>y+1),ue(!0)},onSignOut:()=>{q.teamSignOut().then(()=>qe())},onTeam:()=>{ue(!1),Dt(null),Bo(),W(null),be(null),ve(!0)},onSettings:()=>{ve(!1),Dt(null),Js(y=>y+1),ue(!0)},inboxCount:wt.length,scheduledCount:tm,view:h,collapsed:Lv,onToggle:N$,onSearch:ac,onCompose:()=>ne("compose"),onView:y=>{ve(!1),ue(!1),Dt(null),Bo(),f(y),W(null),xe(null),S(0),Re(new Set)}}),Za&&l.jsx("div",{className:"chrome-reach",style:{width:$0.width,height:$0.height},"aria-hidden":"true"}),l.jsxs("header",{className:"topbar",children:[ME({searching:et!==null,workspaceNavigation:Tr,focused:!!T,settingsOpen:V})?l.jsxs("nav",{className:"tabs searching",children:[l.jsx("span",{className:"search-glyph",children:l.jsx(Yle,{})}),l.jsx("input",{ref:jr,className:"search-q",value:et??"",placeholder:"Search people or messages",spellCheck:!1,autoComplete:"off","aria-label":"Search threads",onChange:y=>{mn(y.target.value),S(0)},onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),Bo()):y.key==="ArrowDown"?(y.preventDefault(),S(k=>Math.min(k+1,Math.max(0,bt.length-1)))):y.key==="ArrowUp"?(y.preventDefault(),S(k=>Math.max(0,k-1))):y.key==="Enter"&&qt&&(y.preventDefault(),W(qt),jt(qt))}}),l.jsx("button",{className:"search-out",title:"Close search","aria-label":"Close search",onClick:Bo,children:l.jsx(bx,{})})]}):V?l.jsxs("div",{className:"workspace-page-heading",children:[l.jsx("button",{className:"workspace-back","aria-label":"Back to previous page",title:"Back to previous page (Esc)",onClick:()=>{ue(!1),Dt(null)},children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:l.jsx("path",{d:"m14 6-6 6 6 6"})})}),l.jsx("h1",{className:"workspace-title",children:Sr==="projects"?"Projects":Sr==="team"?"Team":"Settings"})]}):T?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"workspace-task-header",ref:S$}),l.jsx("div",{className:"workspace-artifact-header",ref:x$})]}):Ve?l.jsx("h1",{className:"workspace-title",children:de?"Threads":"Team"}):l.jsx("h1",{className:"workspace-title",children:"Threads"}),!ME({searching:et!==null,workspaceNavigation:Tr,focused:!!T,settingsOpen:V})&&l.jsxs("div",{className:"topbar-right",children:[e.supervisor.paused&&l.jsx("span",{className:"paused-chip",children:"agents paused"}),l.jsxs(l.Fragment,{children:[!Tr,T&&!V&&!Ve&&l.jsx("span",{style:{display:"contents"},ref:C$}),!T&&!V&&!Ve&&l.jsx(o_,{page:"inbox",display:xt,onDisplay:qa,products:e.products,items:it,onSearch:ac,onCompose:()=>ne("compose"),shown:Ga.length+cc.length,total:(so?ld.length:0)+cc.length,tab:h,people:WL}),!Tr,!Ov&&!Tr,!Ov&&!Tr,!Tr]})]})]}),Ve&&l.jsx("div",{className:"body tm-body",children:l.jsx("main",{className:"list-pane",children:(i0=e==null?void 0:e.team)!=null&&i0.signedIn&&e.team.team&&de?l.jsx("div",{className:"tm-team-pane th-pane",children:de&&l.jsxs("div",{className:"th-card-page",children:[l.jsxs("div",{className:"th-card-bar",children:[l.jsxs("button",{type:"button",className:"th-back",onClick:()=>{be(null),ve(!1)},children:[l.jsx("span",{"aria-hidden":"true",children:"←"}),"Threads"]}),l.jsx(qY,{person:(pe==null?void 0:pe.byId.get(de.personId))??null,onMessage:()=>{const y=Ky(de.personId,{products:e.products,items:it,me:(pe==null?void 0:pe.me)??null});y?Ke(y):(Ge({to:de.personId}),ne("compose"))}})]}),de.title&&l.jsx("h2",{className:"th-card-title",children:de.title}),l.jsx(VY,{card:de,person:(pe==null?void 0:pe.byId.get(de.personId))??null,now:lt})]})}):l.jsx(HE,{team:e==null?void 0:e.team})})}),l.jsx("div",{ref:n$,hidden:(V||Ve)&&Tr,className:"body",children:l.jsxs(l.Fragment,{children:[l.jsxs("main",{className:`list-pane${T||z?" pinned":""}`,children:[jL&&!B&&!T&&!z&&l.jsx(pce,{onSetup:cr}),z?l.jsx(Iie,{rule:z,items:it,editing:ye,onClose:()=>{xe(null),Z(!1)},onEdit:()=>Z(!0),onEditClose:()=>Z(!1),onSave:async y=>{const{title:k,body:A}=kx(y);try{await q.setRepeat({product:z.product,id:z.id,rule:{title:k,body:A}});const D=await q.repeats();oc(D),xe(D.find(X=>X.id===z.id)??null),Z(!1),De("Changed. The next run reads this.")}catch(D){De(`Not changed: ${D.message}`)}},onEnd:async()=>{await q.endRepeat({product:z.product,id:z.id}),xe(null),oc(await q.repeats()),De(`Ended: ${z.title}`)}}):T?l.jsx(OT.Provider,{value:it,children:l.jsx(tG,{onHandToAgent:rt,onAddPeople:gt,headerTarget:v$,cornerHeaderTarget:j$,crumbFrom:we?"Team":et!==null?"Search":Qa?"Threads":h==="inbox"&&pe?K1(Zn,pe.me):(a0=qy.find(y=>y.view===h))==null?void 0:a0.label,inlineArtifacts:Tr,previewSample:q.isFixtures&&(Is||new URLSearchParams(location.search).has("artifactTweaks"))?pd:void 0,artifactView:St?Nm:void 0,onOpenArtifact:(y,k)=>{yv(!1),fm(k),Rs({product:T.product,src:y})},item:T,resumeAt:u,onScrolled:y=>{const k=Date.now();k-c.current<250||(c.current=k,Cse(window.localStorage,y))},openDoc:(St==null?void 0:St.src)??null,onOpenDoc:(y,k)=>Rs({product:T.product,src:y,at:k,...k?{atFrom:Date.now()}:{}}),parent:T.parent?it.find(y=>y.id===T.parent&&y.product===T.product)??null:null,blockedBy:it.find(y=>y.parent===T.id&&y.product===T.product&&y.status!=="done")??null,filed:Wm(it,T).map(y=>({id:y.id,title:y.label||y.title,state:cs(y),approve:_y(y,cs(y)),item:y})),onOpenItem:y=>{W(y),jt(y)},onApproveFiled:y=>yd(y,{stay:!0}),onRejectFiled:y=>mr(y,{stay:!0}),closeAsk:(()=>{const y=hc===hd(T)?ky(Li(T).length):null;return y&&{...y,onPick:k=>wd(T,k),keep:{label:oue,onKeep:vm}}})(),onNotice:De,runningMode:((c0=(l0=e.config)==null?void 0:l0.permission)==null?void 0:c0[T.product])??((d0=(u0=e.config)==null?void 0:u0.permission)==null?void 0:d0[""]),engineChoice:(((f0=(h0=e.engines)==null?void 0:h0.choices)==null?void 0:f0.length)??1)>1,runningEngine:K,productDir:((p0=e.products.find(y=>y.slug===T.product))==null?void 0:p0.dir)??null,repoDir:((m0=e.products.find(y=>y.slug===T.product))==null?void 0:m0.repoPath)??null,selectedOption:eo,interruptedFrom:Oe&&Oe.id!==T.id?Oe.title:null,onBackToInterrupted:()=>W(null),returnedFromSnooze:Di(T)>0&&Di(T)<=lt,scheduledUntil:Di(T)>lt?Di(T):0,scheduledByAgent:lh(T,lt),onUnschedule:()=>nl(T),replyOpen:oe==="reply",sending:E(T),stalled:((g0=e.supervisor.stalled)==null?void 0:g0.includes(T.id))??!1,onRedeliver:()=>Rv(T),onClose:()=>W(null),onResolve:()=>mr(T),onPick:y=>xd(T,y),onReply:()=>ne("reply"),codexModels:un,codexModelDefault:At,onReplySend:(y,k,A,D,X,ce)=>{if(T.agent){p$(T,y);return}A&&E$(T,A),f$(T,y,k,D,X,K,ce)},onReplyClose:()=>ne(null),onStop:()=>Tv(T),onRunNow:()=>Mv(T),onPin:T.agent?void 0:y=>ud(T.id,y,!0),onReveal:()=>m$(T),onSnooze:As?void 0:()=>$i(T),onReopen:()=>Iv(T),session:e.supervisor.running.find(y=>y.itemId===T.id)??null,live:{queued:e.supervisor.queued,signInNeeded:e.supervisor.signInNeeded,atLimit:e.supervisor.atLimit,runNow:e.supervisor.runNow,paused:e.supervisor.paused,running:e.supervisor.running.length,capacity:e.supervisor.capacity,inProgress:$c(T,{deferredUntil:Ms(T),now:lt,live:gn.has(T.id),shipping:Ur.has(T.id)}),shipping:Ur.has(T.id),silent:((y0=e.supervisor.silent)==null?void 0:y0[T.id])??null},stoppable:!As&&jm(T)})}):l.jsx(l.Fragment,{children:et===null&&xt.view==="board"?l.jsx(y_,{items:it,products:e.products,display:xt,now:lt,stateOf:cs,projectOrder:ls,cards:_o,picked:pe?Zn:void 0,onOpenCard:Ja,selected:qt,selectedCard:io?C:null,columnOrder:sm,onReorderColumns:VL,onPlaces:!B&&!Ar&&xt.sort==="priority"?(y,k,A)=>{A!=null&&ud(k,A),am(y,k)}:void 0,marked:$,onMark:Re,onOpenItem:y=>{const k=bt.indexOf(y);O(null),k>=0&&S(k),W(y),jt(y)}}):l.jsxs(l.Fragment,{children:[et===null&&l.jsx(l_,{view:h,counts:{inbox:(so?uc(wt):0)+dc("inbox"),progress:(so?uc(pr):0)+dc("progress"),snoozed:(so?uc(Pn):0)+dc("snoozed"),done:(so?uc(Er):0)+dc("done"),all:(so?uc(tv):0)+dc("all")},needs:pe?K1(Zn,pe.me):void 0,onView:y=>{f(y),S(0),Re(new Set)}}),A$&&!cc.length?lv>0?l.jsx(d_,{view:h,hidden:lv,onClear:()=>qa({...xt,priorities:[],projects:[],updated:"any",privacy:"any"})}):h==="inbox"&&!Ar?B===null&&!Ba&&l.jsx(u_,{running:pr.length,scheduled:Pn.length,team:!!pe,onView:y=>{f(y),S(0),Re(new Set)},onCompose:()=>ne("compose")}):l.jsx(f_,{view:h}):l.jsx(x_,{table:et===null,products:e.products,team:pe,mixed:et===null?lm:null,personCell:_L,onOpenCard:Ja,selectedCard:io?C:null,onEnd:et===null&&Wa!==!1&&(h==="done"||h==="all")?Qp:void 0,onReorder:et===null&&!B&&!Ar&&xt.sort==="priority"&&(h==="inbox"||h==="progress"||h==="snoozed")?BL:void 0,items:bt,view:et!==null?"inbox":h,selected:v,seen:en,running:sc,engineChoice:(((b0=(w0=e.engines)==null?void 0:w0.choices)==null?void 0:b0.length)??1)>1,engines:e.engines,stalled:e.supervisor.stalled,queued:e.supervisor.queued,signInNeeded:e.supervisor.signInNeeded,atLimit:e.supervisor.atLimit,shipping:e.supervisor.shipping,silent:e.supervisor.silent,paused:e.supervisor.paused,multiSel:$,snoozes:ht,repeats:et!==null?[]:Oi,allItems:it,terms:Va==null?void 0:Va.terms,phrase:Va==null?void 0:Va.phrase,summaries:IL,searchDetails:RL,ranked:DL,walk:B&&et===null?{key:OL,rows:lc}:null,emptyText:Wa!==!1&&et!==null?"Searching older threads…":et?`Nothing matches “${et}”.`:void 0,keyView:h,hoveredId:N,onHover:Y?P:void 0,onSelect:y=>{O(null),S(y)},onOpenRepeat:y=>{W(null),xe(y)},onOpen:y=>{O(null),W(y),jt(y)},onAnswerImport:bd,onToggle:y=>{var A;const k=(A=bt[y])==null?void 0:A.id;k&&(Re(D=>{const X=new Set(D);return X.has(k)?X.delete(k):X.add(k),X}),S(y))},onRange:y=>{const[k,A]=[Math.min(v,y),Math.max(v,y)];Re(D=>new Set([...D,...bt.slice(k,A+1).map(X=>X.id)])),S(y)}})]})})]}),St&&l.jsx($P,{target:md,children:l.jsx(mse,{doc:St,roots:i$,focusControlStyle:Is?pv:"corners-bare",headerTarget:Nm==="focus"?b$:null,mode:Ho,onMode:y=>{yv(Ho==="beside"),fm(y)},split:zP(s$,kv),onSplit:a$,onClose:xv,onNotice:De})})]})}),oe==="compose"&&l.jsx(qse,{products:od,items:it,engines:(x0=e.engines)==null?void 0:x0.choices,codexModels:un,codexModelDefault:At,defaultProduct:Yp?B.practice??B.product:qn,initial:Yp?{body:`${goe}
|
|
1131
|
+
|
|
1132
|
+
${yoe}`}:at,scripted:Yp?{labels:[boe]}:null,onOpenConversation:Ke,onReorderProjects:()=>{ne(null),Ge(null),ve(!1),Dt("projects"),ue(!0)},onNewProject:()=>he(!0),onClose:()=>{ne(null),Ge(null)},onSent:async(y,k)=>{var ce,Ne;Ge(null);const A=Ox();if(ne(null),((ce=Fe.current)==null?void 0:ce.step)==="task"){y!=null&&y.id&&Es({t:"sent",item:y.id,at:Date.now()}),await qe();return}if((k==null?void 0:k.kind)==="message"){const Ae=(k.toMany??[k.to??""]).map(He=>{var tt,Ct;return(Ct=(tt=pe==null?void 0:pe.byId.get(He))==null?void 0:tt.name)==null?void 0:Ct.split(/\s+/)[0]}).filter(Boolean),ke=Ae.length>1?`${Ae.slice(0,-1).join(", ")} and ${Ae[Ae.length-1]}`:Ae[0];De(ke?`Sent to ${ke}`:"Message sent"),await qe();return}const D=(k==null?void 0:k.product)??(y==null?void 0:y.product)??"",X=(Ne=e.products.find(Ae=>Ae.slug===D))==null?void 0:Ne.name;if((k==null?void 0:k.kind)==="repeat"){k.ruleId&&Ev(`Repeating task canceled: ${zs(k.title??"",jc)}`,"cancel that repeating task",A,async()=>{await q.endRepeat({product:D,id:k.ruleId}),oc(await q.repeats())}),De(`Repeating → ${X??D} · Z to undo`),await qe();return}y!=null&&y.id&&Ev(`Withdrawn: ${zs(y.title,jc)}`,"take back the task you just made",A,async()=>{await q.answer({product:y.product,id:y.id,status:"done"})},[{product:y.product,id:y.id,words:"Undid sending it"}]),De(Wse({to:X??D,when:k!=null&&k.runAt?nR({runAt:k.runAt,repeat:null}):null,held:(k==null?void 0:k.start)==="later"}),y!=null&&y.id?{product:y.product,id:y.id}:void 0),!we&&!T&&["inbox","progress","snoozed"].includes(h)&&(f(k!=null&&k.runAt&&k.runAt>Date.now()||(k==null?void 0:k.start)==="later"?"snoozed":"progress"),S(0),Re(new Set)),await qe()}}),oe==="palette"&&l.jsx(Bie,{onFirstRun:NL,onTutorial:()=>Kk(Qce(e.products,qn,KN())),onImportAgents:()=>{ne(null),ee(!0)},onFreshUser:d$,onDemo:h$,products:od,supervisorPaused:e.supervisor.paused,batch:$.size>0,look:$a,machine:Cn,onSetLook:y=>{Po(y),ne(null)},staleFiles:((k0=e.restartNeeded)==null?void 0:k0.files)??[],updateReady:b1(e.update,{walking:As,closed:""})?((v0=e.update)==null?void 0:v0.newVersion)??null:null,onInstallUpdate:()=>{ne(null),q.updateInstall()},onCheckUpdate:()=>{ne(null),De(_s.looking),q.updateCheck().then(y=>De(GA(y).sentence))},moveToApplications:x1(e.update,{walking:As,closed:""}),onMoveToApplications:()=>{ne(null),q.updateMove().then(y=>{!y.moved&&y.error&&De(y.error)})},panelUp:ss,onTogglePanel:()=>{ne(null),vs()},boardUp:xt.view==="board",onFlipView:!Ce&&et===null&&!Ve&&!de?()=>{ne(null),qa(Hm(xt)),S(0)}:void 0,keyHints:Y,onSetKeyHints:y=>{ne(null),re(y)},onSearch:ac,itemCommands:(()=>{var X;if($.size){const ce=no.filter(Ae=>$.has(Ae.id)),Ne=ce.length;return[...h!=="snoozed"?[{id:"done",label:`Close (${Ne} selected)`,keyHint:"E",run:()=>{ne(null),Sm($)}}]:[],{id:"snooze",label:`Later (${Ne} selected)`,keywords:dE,keyHint:"L",run:()=>$i(ce)},...ce.some(Ae=>Di(Ae)>Date.now())?[{id:"unsnooze",label:`Back to Inbox (${Ne} selected)`,run:()=>nl(ce)}]:[],{id:"read",label:`Mark Read (${Ne} selected)`,run:()=>{Fo(Ae=>new Set([...Ae,...ce.map(ke=>ke.id)])),Re(new Set),ne(null)}},...ce.filter(Ae=>!Uo(Ae)).length?[{id:"resume",label:`Resume Agents (${ce.filter(Ae=>!Uo(Ae)).length} of ${Ne} selected)`,run:()=>{ne(null),Dv(ce.filter(Ae=>!Uo(Ae)))}}]:[],...L1(ce).map(Ae=>({...Ae,run:()=>{ne(null),Av(ce,Ae.value)}}))]}const y=T??Ot;if(!y)return[];const k=wl(y),A=k.find(ce=>ce.recommended)??k[0],D=()=>{W(y),jt(y)};return[...T?[{id:"remote-control",label:"Remote Control",keywords:"phone mobile continue claude rc",run:()=>{ne(null),window.dispatchEvent(new Event("task-remote-control-open"))}},{id:"open-terminal",label:"Open Terminal",keywords:"shell command console",run:()=>{ne(null),window.dispatchEvent(new Event("task-terminal-open"))}}]:[],...!y.agent&&!y.answer&&(y.kind==="review"||y.kind==="question"&&A||y.status==="open"&&y.kind!=="question"&&!(y.labels??[]).includes("founder"))?[{id:"approve",label:y.kind==="question"?"Approve Recommended":y.kind==="review"?"Approve (Proceed as Proposed)":"Approve (Run It)",run:()=>{ne(null),yd(y)}}]:[],...r7(y,{session:e.supervisor.running.find(ce=>ce.itemId===y.id)??null,queued:e.supervisor.queued,runNow:e.supervisor.runNow,inProgress:$c(y,{deferredUntil:Ms(y),now:lt,live:gn.has(y.id)})},()=>{ne(null),Mv(y)}),{id:"done",label:y.agent?lu.verb:`${lu.verb} Task`,keyHint:"E",run:()=>{ne(null),mr(y)}},{id:"reply",label:"Reply",keyHint:"R",run:()=>{D(),ne("reply")}},...!y.agent&&!Uo(y)&&!jm(y)?[{id:"resume-any",label:y.status==="done"?"Resume This Agent (Reopen and Carry On)":"Resume This Agent",run:()=>{ne(null),Dv([y])}}]:[],en.has(y.id)?{id:"unread",label:"Mark Unread",run:()=>{Fo(ce=>{const Ne=new Set(ce);return Ne.delete(y.id),Ne}),ne(null)}}:{id:"read",label:"Mark Read",run:()=>{jt(y),ne(null)}},...Di(y)>Date.now()?[{id:"unsnooze",label:lh(y,lt)?"Let It Run Now":"Back to Inbox",keyHint:"E",run:()=>nl(y)}]:[],{id:"snooze",label:"Later",keywords:dE,keyHint:"L",run:()=>$i(y)},...jm(y)?[{id:"stop",label:Uo(y)?"Stop Agent (Moves to Inbox)":"Stop Task (Moves to Inbox)",hint:Uo(y)?void 0:"nothing has started on it yet",run:()=>{ne(null),Tv(y)}}]:[],...y.status==="blocked"?[{id:"send-back",label:"Send Back to Agent",run:()=>{ne(null),Iv(y)}}]:[],...(X=e.supervisor.stalled)!=null&&X.includes(y.id)?[{id:"redeliver",label:"Restart the Agent (It Stopped)",run:()=>{ne(null),Rv(y)}}]:[],...T?[]:[{id:"open",label:"Open",keyHint:"↵",run:()=>{ne(null),D()}}],...L1([y]).map(ce=>({...ce,run:()=>{ne(null),Av([y],ce.value)}}))]})(),filtering:xL(_r),onOpenFilter:()=>ne("filter"),onClearFilter:()=>{Lo(eue),ne(null)},onView:y=>{f(y),ne(null),S(0)},onPause:async y=>{await q.pauseSupervisor(y),ne(null),await qe()},order:e.supervisor.productOrder??[],onRankFirst:async y=>{var D,X,ce;ne(null);const k=Bb(od.map(Ne=>Ne.slug),y,0);await((X=(D=window.zero)==null?void 0:D.setProductOrder)==null?void 0:X.call(D,{order:k}));const A=((ce=e.products.find(Ne=>Ne.slug===y))==null?void 0:ce.name)??y;De(`${A} is now first`),await qe()},onResume:()=>{ne(null),y$(null)},onNewProject:()=>{ne(null),he(!0)},onStanding:()=>ne("standing"),onSettings:()=>{ne(null),Dt(null),ue(!0)},onShortcuts:()=>{ne(null),Dt("shortcuts"),ue(!0)},onOpenProjects:()=>{ne(null),ve(!1),Dt("projects"),ue(!0)},onClose:()=>ne(null)}),V&&l.jsx(ele,{onFeedback:()=>ie(!0),embedded:Tr,usageReadings:e.usageByEngine??(e.usage?[e.usage]:[]),now:lt,onSectionChange:ur,look:Ql??$a,onSetLook:Po,keyHints:Y,onSetKeyHints:re,tune:Xl,onSetTune:zo,onResetTune:Cs,startPane:zr,onNewProject:()=>he(!0),ranked:od,onSetOrder:async y=>{var k,A;await((A=(k=window.zero)==null?void 0:k.setProductOrder)==null?void 0:A.call(k,{order:y})),await qe()},teamPane:(S0=e==null?void 0:e.team)!=null&&S0.configured?l.jsx(HE,{team:e==null?void 0:e.team,inviteFocus:Le}):void 0,projectShare:pe?y=>{const k=pe.products.get(y);return k?l.jsx(due,{product:k,onChange:async(A,D)=>{const X=await q.setProjectSeenBy({product:y,who:A,people:D});X.ok||De(X.error??"Could not change who sees it.")}}):null}:void 0,projectWho:pe?y=>l.jsx(cue,{product:y}):void 0,account:(j0=e==null?void 0:e.team)!=null&&j0.signedIn&&e.team.me?{email:e.team.me.email,team:((C0=e.team.team)==null?void 0:C0.name)??null,onSignOut:()=>{q.teamSignOut().then(()=>qe())}}:void 0,update:(e==null?void 0:e.update)??null,onClose:()=>{ue(!1),Dt(null),ur(null)}},`${zr??"general"}:${Gs}`),te&&l.jsx(YO,{products:e.products,filter:qn,onNewProject:()=>{ee(!1),he(!0)},onProjectMade:y=>{Hi(y),qe()},onDone:async({added:y,already:k,name:A,inboxes:D,made:X,noun:ce})=>{ee(!1),De(cE({added:y,already:k,name:A,inboxes:D,made:X,noun:ce})),await qe()},onClose:()=>ee(!1)}),Q&&l.jsx(yie,{onRefused:y=>De(y),onCreate:async({name:y,repoPath:k})=>{try{const A=await q.createProduct({name:y,repoPath:k});he(!1);const D=(A==null?void 0:A.slug)??null;D&&(Hi(D),I(D)),De(`New project: ${y} · its code is in ${gie(k)}`),await qe(),Xce({made:!!D,walking:Fe.current!==null,offered:!Jce(localStorage)})&&ft({product:D})}catch(A){he(!1),De(aE(A.message,y))}},onClose:()=>he(!1)}),Zl&&l.jsx(Bce,{variant:Zl,value:ec,onPick:qp}),B&&!Zl&&!ln&&l.jsx($ce,{run:B,claude:nn,home:$n,runsOn:(e==null?void 0:e.runsOn)??null,opened:!!T,waiting:Kl(B,fo),later:Gu(B,Xo),beat:lc,pointed:(Ot==null?void 0:Ot.id)??null,picking:oe==="snooze",palette:oe==="palette",board:xt.view==="board",replying:oe==="reply",view:h,tabs:cm,products:e.products,onEvent:Es,onStep:y=>tn(k=>k&&rr(k,y)),onSkipToApp:async({name:y,folder:k})=>{try{const A=await q.createProduct({name:y,repoPath:k}),D=(A==null?void 0:A.slug)??null;if(!D)throw new Error("the project was not made");return Hi(D),I(D),await qe(),Es({t:"made",product:D}),null}catch(A){return aE(A.message,y)}},onLeave:()=>Ii([],{celebrate:!1}),onShut:()=>ne(null),onSkipStep:()=>{const y=Fe.current;if(!y)return;if(ne(null),W(null),xt.view==="board"&&qa(Hm(xt)),y.step==="command"){if(JN(y)==="end"){Ii([],{practised:!0});return}tn(rr(y,"done"));return}const k=uoe(y,wt,fo,Xo);k&&tn(k)},onPractice:async()=>{let y=null;try{y=await q.firstRunPractice()}catch{y=null}const k=(y==null?void 0:y.slug)??null;k&&(Hi(k),I(k)),await qe(),Es({t:"practice",product:k??"",examples:(y==null?void 0:y.examples)??[],backdrop:(y==null?void 0:y.backdrop)??[]})},onDone:y=>Ii(y,{practised:!0}),onFiled:({added:y,already:k,inboxes:A,made:D,noun:X})=>{Ii([],{filed:y,practised:!0}),(y||k)&&De(cE({added:y,already:k,name:D.length===1?D[0]:"",inboxes:A,made:D,noun:X}))},onProjectMade:y=>{Hi(y),qe()},onRecheck:Wk}),B&&l.jsx(xce,{run:B,blocked:!eE(nn),onLeave:()=>Ii([],{celebrate:!1})}),Ba&&l.jsx(Rce,{agents:Ba.agents,onGone:()=>fe(null)}),rs&&l.jsxs("div",{className:"fr-screen has-back ps-over",children:[l.jsx("button",{type:"button",className:"back-esc fr-back","aria-label":"Back",title:"Back",onClick:()=>{cr(null),tc()},children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M10 3.5L5.5 8l4.5 4.5"})})}),l.jsxs("div",{className:"fr-brand",children:[l.jsx(vi,{size:22}),Je]}),l.jsx(fL,{plan:rs,onDone:()=>{cr(null),tc(),Wk()},onSkip:()=>{cr(null),tc()}})]}),Ze&&!B&&l.jsx(Hce,{onStart:()=>Kk(Ze.product),onNot:()=>{yy(localStorage),ft(null),De(_e.offerLater)}}),nc&&!ln&&l.jsx(Ice,{}),oe==="standing"&&l.jsx(Wie,{kind:GO,onClose:()=>ne(null)}),(()=>{const{card:y,verdict:k,waiting:A}=ole(e.approvals,Mi,Xu.current);if(!y)return null;const D=ile(y.input,y.tool);return l.jsx("div",{className:"approvals",children:l.jsxs("div",{className:"approval-stack",children:[A>1&&l.jsx("div",{className:"approval-ghost g2"}),A>0&&l.jsx("div",{className:"approval-ghost g1"}),l.jsxs("div",{className:`approval-card${k?` answered ${k}`:""}`,children:[k&&l.jsxs("div",{className:"approval-verdict","aria-live":"polite",children:[l.jsx("span",{className:"approval-verdict-mark","aria-hidden":"true",children:k==="allow"?"✓":"✕"}),l.jsx("span",{className:"approval-verdict-word",children:k==="allow"?"Allowed":"Denied"})]}),(()=>{var tt,Ct,Ut,dn,We;const X=wm(y.item),ce=y.tool.startsWith("mcp__"),Ne=((tt=e.products.find(Qt=>Qt.slug===y.product))==null?void 0:tt.name)??y.product??"an agent",Ae=!ce&&((Ct=y.input)!=null&&Ct.description)?String(y.input.description).slice(0,200):null,ke=!ce&&((Ut=y.input)!=null&&Ut.cwd)?String(y.input.cwd):null,He=[Ae?D.what:null,ke?`in ${ke}`:null].filter(Boolean).join(" ");return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"approval-lede",children:[l.jsx("span",{className:"approval-lede-text",children:Ae??l.jsxs(l.Fragment,{children:[Ne," ",D.what]})}),A>0&&l.jsxs("span",{className:"approval-count",children:["+",A," waiting"]})]}),l.jsx("pre",{className:"approval-cmd",children:D.body}),!ce&&((dn=y.input)==null?void 0:dn.host)&&l.jsxs("div",{className:"approval-opens",children:["opens the network to ",String(y.input.host)]}),!ce&&((We=y.input)==null?void 0:We.grantRoot)&&l.jsxs("div",{className:"approval-opens",children:["and asks to write anywhere under ",String(y.input.grantRoot)," for the rest of this run"]}),(He||X)&&l.jsxs("div",{className:"approval-meta",children:[He&&l.jsx("span",{className:"approval-where",children:He}),X&&l.jsxs("button",{type:"button",className:"approval-task",title:"Open this agent. The card stays where it is.",onClick:()=>u$(y.item),children:[l.jsx("span",{className:"approval-task-title",children:X.title}),l.jsx("span",{className:"approval-task-go","aria-hidden":"true",children:"↗"})]})]})]})})(),l.jsxs("div",{className:"approval-actions",children:[l.jsx("button",{className:"approval-allow",onClick:async()=>{var X,ce;Fa({id:y.id,allow:!0}),await((ce=(X=window.zero)==null?void 0:X.approve)==null?void 0:ce.call(X,{id:y.id,allow:!0})),await qe()},children:"Allow"}),l.jsx("button",{className:"approval-deny",onClick:async()=>{var X,ce;Fa({id:y.id,allow:!1}),await((ce=(X=window.zero)==null?void 0:X.approve)==null?void 0:ce.call(X,{id:y.id,allow:!1})),await qe()},children:"Deny"}),l.jsxs("span",{className:"approval-hint",children:["⌘Y / ⌘N · ",y.tool]})]})]},y.id)]})})})(),oe==="snooze"&&ds&&l.jsx(sle,{item:Array.isArray(ds)?ds[0]:ds,count:Array.isArray(ds)?ds.length:1,onPick:(y,k)=>g$(ds,y,k),onNow:(Array.isArray(ds)?ds:[ds]).some(y=>Di(y)>Date.now())?()=>nl(ds):void 0,onClose:()=>{ne(null),kd(null)}}),fr&&(()=>{const{line:y,undo:k}=fue(fr.text),A=fr.goes?[...wt,...pr,...Pn,...Er].find(X=>X.id===fr.goes.id&&X.product===fr.goes.product):void 0,D=l.jsxs(l.Fragment,{children:[A&&l.jsx("span",{className:"toast-title",children:A.label||A.title}),l.jsx("span",{className:"toast-line",children:y}),(fr.goes||k)&&l.jsxs("span",{className:"toast-keys",children:[fr.goes&&l.jsxs("span",{className:"toast-key",children:[l.jsx("kbd",{children:"O"}),l.jsx("span",{className:"toast-key-word",children:"Open"})]}),k&&l.jsxs("span",{className:"toast-key toast-undo",role:"button",tabIndex:-1,onClick:X=>{X.stopPropagation(),Pa(null),rl()},children:[l.jsx("kbd",{children:"Z"}),l.jsx("span",{className:"toast-key-word",children:"Undo"})]})]}),fr.goes&&l.jsx("span",{className:"toast-clock","aria-hidden":"true",style:{animationDuration:`${VE}ms`}})]});return fr.goes?l.jsx("button",{type:"button",className:`toast toast-goes${A?"":" toast-plain"}`,onClick:()=>Cm(fr.goes),children:D},km.current):l.jsx("div",{className:"toast toast-plain",children:D},km.current)})(),Ie&&L&&uy[L.id]&&l.jsx(gle,{lines:uy[L.id],comp:L.el.getBoundingClientRect(),align:L.el.dataset.hintAlign==="right"?"right":"left",text:L.el.dataset.hintText?((N0=L.el.querySelector(L.el.dataset.hintText))==null?void 0:N0.getBoundingClientRect())??null:null}),G&&l.jsx(Kle,{onClose:()=>ie(!1),onSend:y=>q.sendFeedback(y)}),l.jsx(Jle,{}),l.jsx(uce,{})]})})})})})}const SL=(e,t,n)=>{var r,s;try{Promise.resolve((s=(r=window.zero)==null?void 0:r.crash)==null?void 0:s.call(r,{name:e,message:t,stack:n})).catch(()=>{})}catch{}};window.addEventListener("error",e=>{var t,n,r;SL(((t=e.error)==null?void 0:t.name)??"Error",((n=e.error)==null?void 0:n.message)??String(e.message??""),((r=e.error)==null?void 0:r.stack)??"")});window.addEventListener("unhandledrejection",e=>{const t=e.reason;SL((t==null?void 0:t.name)??"UnhandledRejection",(t==null?void 0:t.message)??String(t??""),(t==null?void 0:t.stack)??"")});lae(localStorage);jb(Eh(localStorage.getItem(ba)));const kue=()=>{const e=Cb(ZO(localStorage.getItem(ba)),Dc(localStorage.getItem(Fs)),Dk());Nb(e),e!=="none"&&Th(Ah(localStorage.getItem(ml),e)),xle(oL(localStorage.getItem(sL)))},vue=()=>{kue(),D$.createRoot(document.getElementById("root")).render(l.jsx(Bn.StrictMode,{children:l.jsx(m8,{children:l.jsx(xue,{})})}))};vue();export{ms as _};
|