@clawos-dev/clawd 0.2.698 → 0.2.699

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.
@@ -912,7 +912,7 @@ Minimum version required to store current data is: `+i+`.
912
912
  `;return typeof r=="function"&&r(null,f),f};const c4e=k3e,gE=uY,CY=SY,u4e=kY;function PM(e,t,n,r,s){const i=[].slice.call(arguments,1),o=i.length,l=typeof i[o-1]=="function";if(!l&&!c4e())throw new Error("Callback required as last argument");if(l){if(o<2)throw new Error("Too few arguments provided");o===2?(s=n,n=t,t=r=void 0):o===3&&(t.getContext&&typeof s>"u"?(s=r,r=void 0):(s=r,r=n,n=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(n=t,t=r=void 0):o===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(c,u){try{const d=gE.create(n,r);c(e(d,t,r))}catch(d){u(d)}})}try{const c=gE.create(n,r);s(null,e(c,t,r))}catch(c){s(c)}}Zu.create=gE.create;Zu.toCanvas=PM.bind(null,CY.render);Zu.toDataURL=PM.bind(null,CY.renderToDataURL);Zu.toString=PM.bind(null,function(e,t,n){return u4e.render(e,n)});const xs=oU,d4e=aU,NY=p.forwardRef(({className:e,...t},n)=>a.jsx(eT,{ref:n,className:Q("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));NY.displayName=eT.displayName;const ts=p.forwardRef(({className:e,children:t,...n},r)=>a.jsxs(d4e,{children:[a.jsx(NY,{}),a.jsxs(tT,{ref:r,className:Q("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,a.jsxs(lU,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[a.jsx(Yt,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ts.displayName=tT.displayName;const Ls=({className:e,...t})=>a.jsx("div",{className:Q("flex flex-col space-y-1.5 text-left",e),...t});Ls.displayName="DialogHeader";const Ja=({className:e,...t})=>a.jsx("div",{className:Q("flex flex-row justify-end gap-2",e),...t});Ja.displayName="DialogFooter";const ns=p.forwardRef(({className:e,...t},n)=>a.jsx(nT,{ref:n,className:Q("text-lg font-semibold leading-none text-text-100",e),...t}));ns.displayName=nT.displayName;const zi=p.forwardRef(({className:e,...t},n)=>a.jsx(rT,{ref:n,className:Q("text-sm text-text-300",e),...t}));zi.displayName=rT.displayName;function h4e({persona:e,open:t,onClose:n,onDelete:r,embedded:s,onLoadPersonality:i,onSavePersonality:o,onLoadPersonalityLocal:l,onSavePersonalityLocal:c,hasPersonalityLocal:u=!1,onDirtyChange:d,initialPersonality:h,onShareCapability:f,readOnly:m=!1,larkBot:g}){const[x,b]=p.useState(!1),[y,v]=p.useState(!1),w=x||y,_=K.useRef(d);p.useEffect(()=>{_.current=d}),p.useEffect(()=>{var k;(k=_.current)==null||k.call(_,w)},[w]);const S=()=>{w&&!window.confirm("修改未保存,确定关闭?")||n()};return t?a.jsxs(a.Fragment,{children:[!s&&a.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:S,"aria-hidden":"true"}),a.jsxs("aside",{className:s?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[a.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(jw,{className:"h-4 w-4 text-text-300"}),a.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),a.jsx("button",{type:"button",onClick:S,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:a.jsx(Yt,{className:"h-4 w-4"})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[a.jsxs("header",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?a.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[a.jsx(V5,{className:"h-3 w-3"})," 公开"]}):a.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[a.jsx(Rhe,{className:"h-3 w-3"})," 已关闭"]})]}),a.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[f?a.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[a.jsx(Ew,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?a.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:a.jsx(gs,{className:"h-4 w-4"})}):null]})]}),a.jsx("hr",{className:"border-border"}),g?a.jsxs(a.Fragment,{children:[a.jsx(jY,{...g}),a.jsx("hr",{className:"border-border"})]}):null,i?a.jsxs(a.Fragment,{children:[a.jsx(tL,{onLoad:i,...o&&!e.personalityManaged?{onSave:o}:{},onDirtyChange:b,initialPersonality:h,readOnly:m||!!e.personalityManaged,title:e.personalityManaged?"内置人格":"人格 (Personality)",hint:e.personalityManaged?m?"这个 persona 自带的人格,随 clawd 版本更新。":"这个 persona 自带的人格,随 clawd 版本更新——在这里改不会保留,要加自己的规则请写下面的「你的补充」。":void 0,testIdPrefix:"persona-personality"}),(e.personalityManaged||u)&&l?a.jsx(tL,{onLoad:l,...c?{onSave:c}:{},onDirtyChange:v,readOnly:m,title:m?"补充设定":"你的补充",hint:m?"这个 persona 的补充设定,由它的主人维护。与内置人格叠加生效。":"写入 <persona-dir>/.clawd/personality.local.md,不会被更新覆盖。与内置人格叠加生效,冲突时以你写的为准;对 owner 和访客会话都生效,要区分对象请在正文里写明。只对新启动的会话生效。",placeholder:"例:回答一律先给结论,再展开。",testIdPrefix:"persona-personality-local"}):null,a.jsx("hr",{className:"border-border"})]}):null,a.jsx(m4e,{settings:e.sandboxSettings??null}),a.jsx("hr",{className:"border-border"}),a.jsx(g4e,{skills:e.skills??[]}),a.jsx("hr",{className:"border-border"}),a.jsx(x4e,{plugins:e.plugins??[]})]})]})]}):null}function eL({qrUrl:e,busy:t,onCancel:n,title:r="扫码关联飞书 Bot",hint:s="用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}){const[i,o]=p.useState(null);return p.useEffect(()=>{let l=!1;return Zu.toDataURL(e,{width:240,margin:1}).then(c=>{l||o(c)}).catch(()=>{l||o(null)}),()=>{l=!0}},[e]),a.jsx(xs,{open:!0,onOpenChange:l=>l||n==null?void 0:n(),children:a.jsxs(ts,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:l=>l.preventDefault(),onEscapeKeyDown:l=>l.preventDefault(),children:[a.jsx(Ls,{children:a.jsx(ns,{children:r})}),a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i?a.jsx("img",{src:i,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):a.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),a.jsx("span",{className:"text-center text-[12px] text-text-300",children:s}),n?a.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const f4e={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},p4e=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function jY({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:s,onUpgrade:i,runtime:o="local"}){const[l,c]=p.useState(!1),[u,d]=p.useState(null),[h,f]=p.useState(""),[m,g]=p.useState(""),[x,b]=p.useState(null),y=C=>{C&&(c(!0),d(null),C().catch(j=>d(j instanceof Error?j.message:String(j))).finally(()=>c(!1)))},v=()=>{b(null),y(t)},w=!l&&!!h&&!!m,_=()=>{!w||!r||y(()=>r({appId:h,appSecret:m}))},S=fi(_),k=a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(ea,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?a.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[k,e.state==="unbound"||e.state==="provisioning"?a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"text-[11px] text-text-400",children:["关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它,",o==="cloud"?"云 Persona 在云端处理消息,回复自动发回去。":"推理跑在你本机,回复自动发回去。"]}),t?a.jsx("button",{type:"button",disabled:l||e.state==="provisioning",onClick:v,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!x?a.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[a.jsx("span",{className:"text-[11px] text-error",children:f4e[e.errorReason]}),a.jsxs("div",{className:"flex gap-1.5",children:[p4e.has(e.errorReason)&&t?a.jsx("button",{type:"button",disabled:l,onClick:v,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,a.jsx("button",{type:"button",onClick:()=>b(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?a.jsx(eL,{qrUrl:e.qrUrl,busy:l,onCancel:n?()=>y(n):void 0}):null,r&&e.state==="unbound"?a.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[a.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),a.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[a.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),a.jsx("input",{value:h,onChange:C=>f(C.target.value),...S,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),a.jsx("input",{value:m,onChange:C=>g(C.target.value),...S,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),a.jsx("button",{type:"button",disabled:!w,onClick:_,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:l?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?a.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="bound"&&e.needsUpgrade?a.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-warning/30 bg-warning-dim px-2 py-1.5","data-testid":"lark-bot-upgrade-notice",children:[a.jsx("span",{className:"text-[11px] text-warning",children:"这个 bot 的权限配置有更新,扫码重新授权后生效。在此之前,新增能力对它不起作用。"}),i?a.jsx("button",{type:"button",disabled:l,onClick:()=>y(i),className:"self-start rounded border border-warning/30 bg-warning/10 px-2 py-1 text-[11px] text-warning hover:bg-warning/20 disabled:opacity-50","data-testid":"lark-bot-upgrade",children:"更新授权"}):null]}):null,e.state==="bound"&&e.upgradeQrUrl?a.jsx(eL,{qrUrl:e.upgradeQrUrl,busy:l,onCancel:n?()=>y(n):void 0,title:"扫码更新授权",hint:"用手机飞书扫码,确认页会列出将要添加的权限。期间 bot 照常服务,不会中断。"}):null,e.state==="broken"?a.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,a.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[a.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?a.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),a.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?a.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(C=>a.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",C.chatName??C.chatId]},C.chatId))}):a.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),s?a.jsx("button",{type:"button",disabled:l,onClick:()=>y(s),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,u?a.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:u}):null]}):a.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[k,a.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function m4e({settings:e}){var t,n,r,s,i,o,l,c,u,d,h,f,m;return a.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[a.jsxs("header",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),a.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?a.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):a.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[a.jsx(M0,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),a.jsx(M0,{label:"沙箱启用",value:vC((n=e.sandbox)==null?void 0:n.enabled)}),a.jsx(M0,{label:"沙箱内自动放行 Bash",value:vC((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),a.jsx(M0,{label:"允许非沙箱命令",value:vC((s=e.sandbox)==null?void 0:s.allowUnsandboxedCommands)}),a.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[a.jsx(Op,{label:"沙箱外命令",paths:(i=e.sandbox)==null?void 0:i.excludedCommands}),a.jsx(Op,{label:"允许读取",paths:(l=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:l.allowRead}),a.jsx(Op,{label:"拒绝读取",paths:(u=(c=e.sandbox)==null?void 0:c.filesystem)==null?void 0:u.denyRead}),a.jsx(Op,{label:"允许写入",paths:(h=(d=e.sandbox)==null?void 0:d.filesystem)==null?void 0:h.allowWrite}),a.jsx(Op,{label:"拒绝写入",paths:(m=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:m.denyWrite})]})]})]})}function vC(e){return e===!0?"是":e===!1?"否":"—"}function M0({label:e,value:t}){return a.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[a.jsx("span",{className:"text-text-300",children:e}),a.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Op({label:e,paths:t}){const n=!t||t.length===0;return a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?a.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):a.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,s)=>a.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${s}-${r}`))})]})}function g4e({skills:e}){return a.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[a.jsxs("header",{className:"flex flex-col gap-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),a.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),a.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",a.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?a.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):a.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>a.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[a.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?a.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):a.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function x4e({plugins:e}){return a.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[a.jsxs("header",{className:"flex flex-col gap-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),a.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),a.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",a.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",a.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?a.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):a.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>a.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:a.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function tL({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:s=!1,title:i,hint:o,placeholder:l,testIdPrefix:c}){const u=r!==void 0,[d,h]=p.useState(u),[f,m]=p.useState(u?r:""),[g,x]=p.useState(u?r:""),[b,y]=p.useState(null),[v,w]=p.useState(!1),[_,S]=p.useState(null),k=K.useRef(e),C=K.useRef(t),j=K.useRef(n);K.useEffect(()=>{k.current=e,C.current=t,j.current=n});const T=K.useCallback(()=>{h(!1),y(null),k.current().then(O=>{m(O),x(O),h(!0)}).catch(O=>{y(O instanceof Error?O.message:String(O))})},[]);K.useEffect(()=>{u||T()},[u,T]);const E=!s&&d&&g!==f;K.useEffect(()=>{s||j.current(E)},[E,s]);const I=()=>{C.current&&(w(!0),S(null),C.current(g).then(()=>{m(g),w(!1)}).catch(O=>{S(O instanceof Error?O.message:String(O)),w(!1)}))},R=()=>{x(f),S(null)},P=fi(()=>{!E||v||I()},()=>{!E||v||R()});return a.jsxs("section",{className:"flex flex-col gap-2","data-testid":`${c}-section`,children:[a.jsx("span",{className:"text-[12px] font-medium text-text-200",children:i}),b?a.jsxs("div",{"data-testid":`${c}-load-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[a.jsxs("span",{children:["加载失败:",b]}),a.jsx("button",{type:"button",onClick:T,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,_?a.jsxs("div",{"data-testid":`${c}-save-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",_]}):null,a.jsx("textarea",{"data-testid":`${c}-textarea`,value:g,onChange:O=>x(O.target.value),...P,readOnly:s,disabled:!s&&(!d||v),placeholder:d?l??"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),o?a.jsx("p",{className:"text-[10px] text-text-400",children:o}):s?null:a.jsx("p",{className:"text-[10px] text-text-400",children:"写入人格文件。修改只对新启动的会话生效。"}),d&&E?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:R,disabled:v,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),a.jsx("button",{type:"button",onClick:I,disabled:v,"data-testid":`${c}-save-btn`,className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:v?"保存中…":"保存"})]}):null]})}function Qu(){const e=Un();return p.useMemo(()=>new Wt(e),[e])}function EY(e){return{personaId:e.personaId,label:e.label,model:e.model,effort:e.effort,serviceTier:e.serviceTier,tool:e.tool,...e.size!==void 0?{size:e.size}:{},...e.cpu!==void 0?{cpu:e.cpu}:{},...e.taskConcurrency!==void 0?{taskConcurrency:e.taskConcurrency}:{},...e.cloudEngine?{cloudEngine:e.cloudEngine}:{},public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt,...e.cloud?{cloud:e.cloud}:{}}}function v_(){const e=zs(),t=Qu(),n=ca("personas")??[],r=p.useMemo(()=>n.map(i=>EY(i)),[n]),s=p.useCallback(async()=>{const i=await t.personaList();e.setData("personas",()=>i.personas??[])},[t,e]);return{personas:r,raw:n,loaded:ca("personas")!==void 0,refresh:s}}function DM(e){const{raw:t}=v_(),n=zs(),r=Qu(),s=e?t.find(l=>l.personaId===e)??null:null,i=s?EY(s):null,o=p.useCallback(async l=>{if(!e)return;(l==null?void 0:l.personaId)===e&&n.setData("personas",u=>{const d=u??[];return d.some(h=>h.personaId===e)?d.map(h=>h.personaId===e?l:h):[...d,l]});const c=await r.personaList();n.setData("personas",()=>c.personas??[])},[e,r,n]);return{persona:i,raw:s,loaded:!!i,refresh:o}}function v4e(e){const t=Qu(),n=zs(),r=e?`persona-detail/${e}`:"",s=ca(r),i=p.useCallback(async()=>{const o={personality:"",personalityLocal:"",personalityManaged:!1,skills:[],plugins:[],sandboxSettings:null,codexSandbox:null};if(!e)return o;let l=null;try{l=await t.personaGet(e)}catch(u){Pe("personas","personaGet failed → empty detail",{personaId:e,err:u}),l=null}const c=l?{personality:l.personality??"",personalityLocal:l.personalityLocal??"",personalityManaged:l.personalityManaged??!1,skills:l.skills??[],plugins:l.plugins??[],sandboxSettings:l.sandboxSettings??null,codexSandbox:l.codexSandbox??null}:o;return n.setData(r,()=>c),c},[t,n,e,r]);return p.useEffect(()=>{e&&i()},[e,i]),{personality:(s==null?void 0:s.personality)??"",personalityLocal:(s==null?void 0:s.personalityLocal)??"",personalityManaged:(s==null?void 0:s.personalityManaged)??!1,skills:(s==null?void 0:s.skills)??[],plugins:(s==null?void 0:s.plugins)??[],sandboxSettings:(s==null?void 0:s.sandboxSettings)??null,codexSandbox:(s==null?void 0:s.codexSandbox)??null,loaded:s!==void 0,refresh:i}}function OM(){const e=zs(),t=Qu();return p.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function y4e(){const e=Qu(),t=OM();return p.useCallback(async n=>{const r=await e.personaCreate(n);return await t(),r},[e,t])}function b4e(){const e=Qu(),t=OM();return p.useCallback(async(n,r)=>{const s=await e.personaUpdate(n,r);return await t(),s},[e,t])}function IY(){const e=Qu(),t=OM();return p.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const w4e={state:"unbound",groups:[]};function TY(e,t,n="local"){const[r,s]=p.useState(null),i=h=>`${n==="cloud"?"cloud:":""}larkBot:${h}`;p.useEffect(()=>{if(!e)return;let h=!1,f=0,m=!1;s(null);const g=async()=>{const v=++f;m=!0;try{const w=await e.request(i("status"),{personaId:t});if(h||v!==f)return;s(_=>n==="cloud"&&(_!=null&&_.upgradeQrUrl)&&w.state==="bound"&&w.needsUpgrade!==!1?{...w,upgradeQrUrl:_.upgradeQrUrl}:w.state==="unbound"&&!w.errorReason&&(_==null?void 0:_.state)==="unbound"&&_.errorReason?{...w,errorReason:_.errorReason}:w)}catch{!h&&v===f&&s(w=>w??w4e)}finally{v===f&&(m=!1)}};g();const x=e.on("larkBot:state",v=>{const w=v;if(w.personaId!==t)return;const{personaId:_,...S}=w;++f,m=!1,s(S)}),b=e.on("daemon:connected",()=>{g()}),y=n==="cloud"?setInterval(()=>{m||g()},5e3):null;return()=>{h=!0,y&&clearInterval(y),x(),b()}},[e,t,n]);const o=p.useCallback(async()=>{e&&await e.request(i("provision"),{personaId:t})},[e,t,n]),l=p.useCallback(async()=>{e&&await e.request(i("provisionCancel"),{personaId:t})},[e,t,n]),c=p.useCallback(async h=>{e&&await e.request(i("bindManual"),{personaId:t,...h})},[e,t,n]),u=p.useCallback(async()=>{e&&await e.request(i("upgrade"),{personaId:t})},[e,t,n]),d=p.useCallback(async()=>{e&&await e.request(i("unbind"),{personaId:t})},[e,t,n]);return{status:r,provision:o,cancelProvision:l,bindManual:c,unbind:d,upgrade:u}}function MY(e,t="owner"){var C;const{persona:n}=DM(e),r=v4e(e),s=b4e(),i=IY(),{httpBaseUrl:o}=bx(),l=Un(),c=TY(t==="guest"?null:l,e),{capabilities:u}=ni((n==null?void 0:n.tool)??"claude"),d=p.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),h=p.useCallback((j,T)=>{s(e,T).catch(E=>{Pe("persona",`${j} failed`,E)})},[s,e]),f=p.useCallback(j=>h("togglePublic",{public:j}),[h]),m=p.useCallback(async j=>{await s(e,{codexSandbox:{network:j}}),await r.refresh()},[s,e,r]),g=p.useCallback(j=>h("changeTool",{tool:j}),[h]),x=p.useCallback(j=>h("changeModel",{model:j}),[h]),b=p.useCallback(j=>h("changeEffort",{effort:j}),[h]),y=p.useCallback(j=>h("toggleFastMode",{serviceTier:j?pg.fast:pg.standard}),[h]),v=p.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(i(e).catch(j=>{Pe("persona","delete failed",j)}),!0),[n,i,e]),w=p.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),_=p.useCallback(async j=>{await s(e,{personality:j}),await r.refresh()},[s,e,r]),S=p.useCallback(async()=>r.loaded?r.personalityLocal:(await r.refresh()).personalityLocal,[r]),k=p.useCallback(async j=>{await s(e,{personalityLocal:j}),await r.refresh()},[s,e,r]);return{persona:n,detail:r,configSchema:(u==null?void 0:u.configSchema)??[],larkBot:c,guestShareUrl:d,changeTool:g,changeModel:x,changeEffort:b,toggleFastMode:y,togglePublic:f,guestNetwork:((C=r.codexSandbox)==null?void 0:C.network)??!1,toggleGuestNetwork:m,remove:v,loadPersonality:w,savePersonality:_,loadPersonalityLocal:S,savePersonalityLocal:k}}function RY({personaId:e,open:t,onClose:n,api:r,embedded:s,onDirtyChange:i,onShareCapability:o,viewerRole:l="owner"}){const c=MY(e,l),{persona:u,detail:d}=c,h=p.useCallback(()=>{c.remove()&&n()},[c,n]);if(!u)return null;const f=l==="guest";return a.jsx(h4e,{embedded:s,persona:{...u,skills:d.skills,plugins:d.plugins,sandboxSettings:d.sandboxSettings,personalityManaged:d.personalityManaged},open:t,onClose:n,onLoadPersonality:c.loadPersonality,onLoadPersonalityLocal:c.loadPersonalityLocal,hasPersonalityLocal:d.personalityLocal!=="",onDirtyChange:i,readOnly:f,...f?{}:{onTogglePublic:c.togglePublic,guestShareUrl:c.guestShareUrl,onChangeTool:c.changeTool,onChangeModel:c.changeModel,onChangeEffort:c.changeEffort,configSchema:c.configSchema,onDelete:h,onSavePersonality:c.savePersonality,onSavePersonalityLocal:c.savePersonalityLocal,larkBot:{status:c.larkBot.status,onProvision:c.larkBot.provision,onCancelProvision:c.larkBot.cancelProvision,onBindManual:c.larkBot.bindManual,onUnbind:c.larkBot.unbind,onUpgrade:c.larkBot.upgrade},...o?{onShareCapability:o}:{}}})}const _4e={resolve:()=>{}},PY=p.createContext(_4e);function S4e(){return p.useContext(PY)}const k4e={...Qa,h1:({node:e,...t})=>a.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>a.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>a.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>a.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>a.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>a.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>a.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>a.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>a.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>a.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>a.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?a.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):a.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>a.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>a.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>a.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>a.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>a.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>a.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>a.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>a.jsx("em",{...t,className:"italic"})};function C4e(e){const t=e.split("/");return t[t.length-1]||e}function DY({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[s,i]=p.useState(null),[o,l]=p.useState(null),[c,u]=p.useState(!1);return p.useEffect(()=>{if(!e)return;let d=!1;return u(!0),l(null),i(null),(async()=>{try{const h=await t(e);if(d)return;i(h)}catch(h){if(d)return;l(h.message||String(h))}finally{d||u(!1)}})(),()=>{d=!0}},[e,t]),a.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?a.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[a.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:C4e(e)}),a.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,a.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:c?a.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?a.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):s!==null?a.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:a.jsx(Tu,{remarkPlugins:[Gh],components:k4e,children:s})}):null})]})}function N4e({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:s}){return e?a.jsx("div",{"data-testid":"md-preview-drawer",className:`${c_} z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl`,children:a.jsx(DY,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:a.jsxs(a.Fragment,{children:[s?a.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:s,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:a.jsx(wH,{className:"h-4 w-4"})}):null,a.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:a.jsx(Yt,{className:"h-4 w-4"})})]})})}):null}const nL=4;function j4e({children:e,onHeightChange:t}){const n=p.useRef(null),[r,s]=p.useState(0);return p.useEffect(()=>{const i=n.current;if(!i)return;const o=()=>s(i.offsetHeight>0?i.offsetHeight+nL*2:0);if(o(),typeof ResizeObserver>"u")return;const l=new ResizeObserver(o);return l.observe(i),()=>l.disconnect()},[]),p.useEffect(()=>{t==null||t(r)},[r,t]),a.jsx("div",{"data-testid":"chat-floating-dock","data-height":r,className:"relative z-20 h-0 shrink-0",children:a.jsx("div",{ref:n,className:"absolute left-4 right-4 flex flex-col items-end gap-1",style:{bottom:nL},children:e})})}function E4e(e,t,n,r,s,i){const o=mx(),[l,c]=p.useState(null),[u,d]=p.useState(s??null),[h,f]=p.useState(!1),[m,g]=p.useState(!1),[x,b]=p.useState(null),y=p.useRef({api:e,sessionId:t,enabled:n,epoch:0,read:null,again:!1,mutating:!1}),v=p.useRef({api:e,sessionId:t,enabled:n});v.current={api:e,sessionId:t,enabled:n};const w=p.useRef(t),_=p.useRef(async()=>{}),S=j=>{if(j.workspace!==void 0&&c(j.workspace),j.binding!==void 0)d(j.binding);else if(j.workspace){const{workspaceId:T,repoId:E,owner:I,name:R,sourceBranch:P,defaultBranch:O}=j.workspace;d({workspaceId:T,repoId:E,owner:I,name:R,sourceBranch:P,defaultBranch:O})}},k=p.useCallback(async()=>{const j=y.current;if(!n||j.sessionId!==t||j.api!==e)return;if(j.mutating){j.again=!0;return}if(j.read)return j.again=!0,j.read;const T=j.epoch;f(!0);const E=(async()=>{try{const I=await e.cloudWorkspace({sessionId:t,action:"status"});y.current===j&&j.epoch===T&&v.current.sessionId===t&&(S(I),b(null))}catch(I){y.current===j&&j.epoch===T&&b(I.message)}finally{y.current===j&&(j.read=null,f(!1),j.again&&!j.mutating&&(j.again=!1,_.current()))}})();return j.read=E,E},[e,t,n]);_.current=k;const C=p.useCallback(async(j,T)=>{const E=y.current;if(!n||E.sessionId!==t)throw new Error("Cloud workspace unavailable");const I=j.action==="bind",R=["repositories","branches"].includes(j.action);if(I&&E.mutating)throw new Error("工作区操作正在进行");I&&(E.mutating=!0,E.epoch++,E.again=!1,g(!0),b(null));try{const P=await(T?e.cloudWorkspace({...j,sessionId:t},{requestId:T}):e.cloudWorkspace({...j,sessionId:t}));return y.current===E&&v.current.sessionId===t&&(S(P),R||b(null)),P}catch(P){throw y.current===E&&!R&&b(P.message),P}finally{I&&y.current===E&&(E.mutating=!1,g(!1),(j.action==="bind"||E.again)&&(E.again=!1,_.current()))}},[e,t,n]);return p.useEffect(()=>{const j={api:e,sessionId:t,enabled:n,epoch:0,read:null,again:!1,mutating:!1};return y.current=j,w.current!==t&&(w.current=t,c(null),d(s??null)),b(null),g(!1),f(!1),n&&_.current(),()=>{j.epoch++,y.current===j&&(y.current={...j,enabled:!1,again:!1})}},[e,t,n]),p.useEffect(()=>{if(!n||!r)return;const j=r.on("session:event",E=>{var R;const I=E;I.sessionId===t&&((R=I.event)==null?void 0:R.kind)==="session_init"&&_.current()}),T=r.on("daemon:connected",()=>{_.current()});return()=>{j(),T()}},[r,t,n]),p.useEffect(()=>{if(!(!r||!n))return r.on("cloud:workspace:timing",j=>{const T=j;if(T.sessionId===t)try{o==null||o.push({level:"info",msg:"cloud.workspace.transport."+T.phase,sessionId:t,meta:T})}catch{}})},[r,n,o,t]),{sessionId:t,workspace:l,binding:u,branchIntent:i,loading:h,busy:m,error:x,refresh:k,run:C}}function I4e(e,t,n=()=>performance.now(),r){const s="workspace-"+crypto.randomUUID(),i=n(),o=r!==void 0&&Number.isFinite(r)&&r>=0&&r<=i?r:i,l=Math.round(i-o);let c,u,d="ok",h=!1;const f=(g,x={})=>{try{t("cloud.workspace.ui."+g,{...e,hasSearch:e.searchLength>0,traceId:s,inputDelayMs:l,...x})}catch{}},m=g=>{if(h)return;h=!0;const x=n();f("finished",{outcome:g,durationMs:Math.round(x-o),waitMs:c===void 0?void 0:Math.round(c-o),requestMs:c===void 0||u===void 0?void 0:Math.round(u-c),commitMs:u===void 0?void 0:Math.round(x-u)})};return f("started"),{requestId:s,get done(){return h},request(){c=n(),f("requested",{waitMs:Math.round(c-o)})},response(g,x,b){u=n(),d=g,f("response",{outcome:d,ignored:x,count:b,requestMs:c===void 0?void 0:Math.round(u-c)})},commit(){u!==void 0&&m(d)},finish:m}}function y_(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n,s=Math.floor(r/6e4);if(s<1)return"just now";if(s<60)return`${s}m`;const i=Math.floor(s/60);if(i<24)return`${i}h`;const o=Math.floor(i/24);if(o<7)return`${o}d`;if(o<30)return`${Math.floor(o/7)}w`;const l=new Date(n),c=String(l.getMonth()+1).padStart(2,"0"),u=String(l.getDate()).padStart(2,"0");return`${c}/${u}`}function AM(e){const t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const s=Math.floor(r/60);if(s<24)return`${s}h ago`;const i=Math.floor(s/24);return i<7?`${i}d ago`:t.toLocaleDateString()}function T4e(e,t=Date.now()){const n=new Date(e).getTime();if(Number.isNaN(n))return"—";const r=Math.max(0,Math.floor((t-n)/1e3)),s=Math.floor(r/3600),i=Math.floor(r%3600/60),o=r%60,l=String(i).padStart(2,"0"),c=String(o).padStart(2,"0");return s>0?`${s}:${l}:${c}`:`${i}:${c}`}var b_="Popover",[OY]=ma(b_,[jf]),Ix=jf(),[M4e,Sc]=OY(b_),AY=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:o=!1}=e,l=Ix(t),c=p.useRef(null),[u,d]=p.useState(!1),[h,f]=Wu({prop:r,defaultProp:s??!1,onChange:i,caller:b_});return a.jsx(Ww,{...l,children:a.jsx(M4e,{scope:t,contentId:wo(),triggerRef:c,open:h,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(m=>!m),[f]),hasCustomAnchor:u,onCustomAnchorAdd:p.useCallback(()=>d(!0),[]),onCustomAnchorRemove:p.useCallback(()=>d(!1),[]),modal:o,children:n})})};AY.displayName=b_;var $Y="PopoverAnchor",R4e=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Sc($Y,n),i=Ix(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=s;return p.useEffect(()=>(o(),()=>l()),[o,l]),a.jsx(Vw,{...i,...r,ref:t})});R4e.displayName=$Y;var LY="PopoverTrigger",BY=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Sc(LY,n),i=Ix(n),o=Gn(t,s.triggerRef),l=a.jsx(sn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":WY(s.open),...r,ref:o,onClick:it(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?l:a.jsx(Vw,{asChild:!0,...i,children:l})});BY.displayName=LY;var $M="PopoverPortal",[P4e,D4e]=OY($M,{forceMount:void 0}),FY=e=>{const{__scopePopover:t,forceMount:n,children:r,container:s}=e,i=Sc($M,t);return a.jsx(P4e,{scope:t,forceMount:n,children:a.jsx(Ki,{present:n||i.open,children:a.jsx(Mw,{asChild:!0,container:s,children:r})})})};FY.displayName=$M;var tf="PopoverContent",zY=p.forwardRef((e,t)=>{const n=D4e(tf,e.__scopePopover),{forceMount:r=n.forceMount,...s}=e,i=Sc(tf,e.__scopePopover);return a.jsx(Ki,{present:r||i.open,children:i.modal?a.jsx(A4e,{...s,ref:t}):a.jsx($4e,{...s,ref:t})})});zY.displayName=tf;var O4e=zh("PopoverContent.RemoveScroll"),A4e=p.forwardRef((e,t)=>{const n=Sc(tf,e.__scopePopover),r=p.useRef(null),s=Gn(t,r),i=p.useRef(!1);return p.useEffect(()=>{const o=r.current;if(o)return X5(o)},[]),a.jsx(Pw,{as:O4e,allowPinchZoom:!0,children:a.jsx(HY,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:it(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),i.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:it(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:it(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),$4e=p.forwardRef((e,t)=>{const n=Sc(tf,e.__scopePopover),r=p.useRef(!1),s=p.useRef(!1);return a.jsx(HY,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),HY=p.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:d,...h}=e,f=Sc(tf,n),m=Ix(n);return Y5(),a.jsx(Tw,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:a.jsx(ox,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),children:a.jsx(NT,{"data-state":WY(f.open),role:"dialog",id:f.contentId,...m,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),UY="PopoverClose",L4e=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Sc(UY,n);return a.jsx(sn.button,{type:"button",...r,ref:t,onClick:it(e.onClick,()=>s.onOpenChange(!1))})});L4e.displayName=UY;var B4e="PopoverArrow",F4e=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Ix(n);return a.jsx(jT,{...s,...r,ref:t})});F4e.displayName=B4e;function WY(e){return e?"open":"closed"}var Tx=AY,Mx=BY,z4e=FY,Df=zY;const w_=Tx,__=Mx,Rx=p.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},s)=>a.jsx(z4e,{children:a.jsx(Df,{ref:s,align:t,sideOffset:n,className:Q("z-50 w-72 rounded-md border border-border bg-elevated p-4 text-text-100 shadow-md outline-none",e),...r})}));Rx.displayName=Df.displayName;const La="flex w-full min-w-0 items-center gap-2.5 rounded-md px-1.5 py-1.5 text-left text-[13px] hover:bg-text-100/5 disabled:opacity-40";function rL({title:e,children:t,trailing:n}){const[r,s]=p.useState(!0);return a.jsxs("section",{className:"rounded-[22px] border border-border bg-bg-100 p-3.5 shadow-[0_2px_12px_rgba(0,0,0,0.06)]",children:[a.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center gap-1.5 py-0.5 text-[13px] text-text-400","aria-expanded":r,children:[e,a.jsx(Jt,{className:`h-3 w-3 text-text-400 ${r?"":"-rotate-90"}`})]}),n]}),r&&t]})}const H4e=6e4,VY=300;function qY({message:e,onRetry:t}){return a.jsxs("div",{role:"alert",className:"m-2 rounded-md bg-error/5 p-2 text-[11px] leading-relaxed text-error",children:[e,a.jsx("button",{className:"ml-2 underline",onClick:t,children:"重试"})]})}function KY(e,t,n){const r=mx(),s=p.useRef(null),i=p.useRef(void 0),o=u=>{i.current=u.timeStamp},l=(u,d,h)=>{var m;(m=s.current)==null||m.finish("superseded");const f=I4e({sessionId:e.sessionId,action:t,searchLength:u,page:d},(g,x)=>{r==null||r.push({level:"info",msg:g,sessionId:e.sessionId,meta:x})},void 0,h);return s.current=f,f};return p.useLayoutEffect(()=>{var u;n||(u=s.current)==null||u.commit()}),p.useEffect(()=>()=>{var u;(u=s.current)==null||u.finish("unmounted")},[]),{current:s,begin:l,open:(u,d)=>{const h=i.current;i.current=void 0,l(u,d,h)},captureOpen:o}}function GY({controller:e,compact:t=!1}){const{binding:n,run:r,busy:s}=e,[i,o]=p.useState(!1),[l,c]=p.useState(""),[u,d]=p.useState(""),[h,f]=p.useState([]),[m,g]=p.useState(1),[x,b]=p.useState(!1),[y,v]=p.useState(!1),[w,_]=p.useState(null),[S,k]=p.useState(0),C=KY(e,"repositories",y),j=p.useRef(!1),T=p.useRef(new Map);return p.useEffect(()=>{if(l===u)return;const E=setTimeout(()=>{d(l),g(1)},VY);return()=>clearTimeout(E)},[l,u]),p.useEffect(()=>{if(!i||n)return;const E=C.current.current&&!C.current.current.done?C.current.current:C.begin(u.length,m),I=u+"|"+m,R=L=>{b(L.hasMore),f(U=>m===1?L.repos:[...U,...L.repos])},P=T.current.get(I);_(null);const O=j.current;if(j.current=!1,P&&Date.now()-P.at<H4e&&!O){E.response("cache",!1,P.repos.length),R({...P,repos:[...P.repos]}),v(!1);return}let F=!1;return v(!0),E.request(),r({action:"repositories",page:m,search:u},E.requestId).then(L=>{var B;if(E.response("ok",F,((B=L.repositories)==null?void 0:B.length)??0),F)return;const U={at:Date.now(),repos:L.repositories??[],hasMore:L.hasMore??!1};T.current.set(I,U),R(U)}).catch(L=>{E.response("error",F),F||_(L.message)}).finally(()=>{F||v(!1)}),()=>{F=!0,E.finish("cancelled")}},[i,n,u,m,S,r]),n?a.jsxs("button",{className:t?"flex min-w-0 items-center gap-1.5 text-[11px] text-text-300 hover:text-text-100":La,title:n.owner+"/"+n.name,"aria-label":"在 GitHub 查看仓库",onClick:()=>window.open(`https://github.com/${n.owner}/${n.name}`,"_blank","noopener"),children:[a.jsx(fk,{className:"h-4 w-4 shrink-0 text-text-400"}),a.jsx("span",{className:"truncate",children:n.name}),!t&&a.jsx(Lr,{className:"ml-auto h-3 w-3 text-text-400"})]}):a.jsxs(w_,{open:i,onOpenChange:E=>{var I;E?C.open(u.length,m):(I=C.current.current)==null||I.finish("closed"),o(E),E||(g(1),c(""),d(""))},children:[a.jsx(__,{asChild:!0,children:a.jsxs("button",{disabled:s,onClickCapture:C.captureOpen,className:t?"flex items-center gap-1.5 text-[11px] text-text-300":La,"aria-label":"添加或选择仓库",children:[a.jsx(fk,{className:"h-4 w-4 text-text-400"}),a.jsx("span",{className:"flex-1",children:"添加 repo"}),!t&&a.jsx(ms,{className:"h-3.5 w-3.5 text-text-400"})]})}),a.jsxs(Rx,{align:"end",className:"w-[330px] p-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-border p-2",children:[a.jsx(ai,{className:"h-3.5 w-3.5 text-text-400"}),a.jsx("input",{autoFocus:!0,"aria-label":"搜索仓库",placeholder:"搜索 GitHub 仓库…",value:l,onChange:E=>{E.target.value!==l&&C.begin(E.target.value.length,1,E.timeStamp),c(E.target.value)},className:"w-full bg-transparent text-[12px] outline-none"})]}),a.jsxs("div",{className:"max-h-[340px] overflow-y-auto py-1",children:[h.map(E=>a.jsxs("button",{disabled:s,className:La,onClick:()=>{_(null),r({action:"bind",repoId:E.repoId,branch:E.defaultBranch}).then(()=>o(!1)).catch(I=>_(I.message))},children:[a.jsx(fk,{className:"h-4 w-4 shrink-0 text-text-400"}),a.jsxs("span",{className:"truncate text-[12px]",children:[E.owner,"/",E.name]})]},E.repoId)),w&&a.jsx(qY,{message:w,onRetry:()=>{C.begin(u.length,m),j.current=!0,k(E=>E+1)}}),!y&&!w&&!h.length&&a.jsx("p",{className:"p-3 text-[12px] text-text-400",children:"没有找到仓库"}),y&&a.jsxs("div",{className:"flex items-center gap-2 p-3 text-[12px] text-text-400",children:[a.jsx(st,{className:"h-3 w-3 animate-spin"}),"正在读取…"]}),x&&!y&&a.jsx("button",{className:La,onClick:E=>{C.begin(u.length,m+1,E.timeStamp),g(I=>I+1)},children:"加载更多"})]})]})]})}function YY({controller:e,compact:t=!1,disabled:n=!1}){const{binding:r,workspace:s,branchIntent:i,run:o,busy:l}=e,[c,u]=p.useState(!1),[d,h]=p.useState(""),[f,m]=p.useState(""),[g,x]=p.useState([]),[b,y]=p.useState(1),[v,w]=p.useState(),[_,S]=p.useState(),[k,C]=p.useState(!1),[j,T]=p.useState(!1),[E,I]=p.useState(null),[R,P]=p.useState(0),O=KY(e,"branches",j),F=d.trim();p.useEffect(()=>{if(F===f)return;if(!F){m("");return}const M=setTimeout(()=>m(F),VY);return()=>clearTimeout(M)},[F,f]),p.useEffect(()=>{if(!c||!r||F!==f)return;const M=O.current.current&&!O.current.current.done?O.current.current:O.begin(f.length,b);let V=!1;return I(null),T(!0),M.request(),o({action:"branches",repoId:r.repoId,...f?{search:f,...v?{cursor:v}:{}}:{page:b}},M.requestId).then(z=>{var $;M.response("ok",V,(($=z.branches)==null?void 0:$.length)??0),V||(x(q=>(f?!v:b===1)?z.branches??[]:[...q,...z.branches??[]]),C(!!(z.hasMore&&(!f||z.nextCursor))),S(z.nextCursor))}).catch(z=>{M.response("error",V),V||I(z.message)}).finally(()=>{V||T(!1)}),()=>{V=!0,M.finish("cancelled")}},[c,r==null?void 0:r.repoId,F,f,b,v,R,o]);const L=M=>{var V;M?O.open(f.length,b):(V=O.current.current)==null||V.finish("closed"),u(M),M||(h(""),m(""),x([]),y(1),w(void 0),S(void 0),C(!1),T(!1),I(null))},U=i??(s==null?void 0:s.actualBranch)??(s?"HEAD · "+s.head.slice(0,7):(r==null?void 0:r.sourceBranch)??"选择 branch"),B=[...new Set([...[...r?[r.defaultBranch]:[],...s!=null&&s.actualBranch?[s.actualBranch]:[],...(s==null?void 0:s.branches)??[]].filter(M=>M.toLowerCase().includes(F.toLowerCase())),...g])],D=M=>{const V=M===((s==null?void 0:s.actualBranch)??(r==null?void 0:r.sourceBranch));o(V?{action:"intend"}:{action:"intend",branch:M}).then(()=>{L(!1)}).catch(()=>{})};return a.jsxs(w_,{open:c,onOpenChange:L,children:[a.jsx(__,{asChild:!0,children:a.jsxs("button",{onClickCapture:O.captureOpen,className:t?"flex min-w-0 items-center gap-1.5 text-[11px] text-text-300 disabled:opacity-40":La,"aria-label":`选择分支,当前 ${U}`,disabled:l||n,children:[a.jsx(wu,{className:"h-3.5 w-3.5 shrink-0 text-text-400"}),a.jsx("span",{className:"truncate",children:U}),a.jsx(Jt,{className:"ml-auto h-3 w-3 shrink-0 text-text-400"})]})}),a.jsxs(Rx,{align:"end",className:"w-[280px] p-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-border p-2",children:[a.jsx(ai,{className:"h-3.5 w-3.5 text-text-400"}),a.jsx("input",{autoFocus:!0,"aria-label":"搜索分支",placeholder:"搜索分支…",value:d,maxLength:100,onChange:M=>{h(M.target.value),M.target.value.trim()!==F&&(O.begin(M.target.value.trim().length,1,M.timeStamp),x([]),y(1),w(void 0),S(void 0),C(!1),I(null),T(!0))},className:"w-full bg-transparent text-[12px] outline-none"})]}),a.jsxs("div",{className:"max-h-[300px] overflow-y-auto",children:[(F===f?B:[]).map(M=>a.jsxs("button",{className:La,onClick:()=>D(M),children:[a.jsx(wu,{className:"h-3.5 w-3.5 text-text-400"}),a.jsx("span",{className:"flex-1 truncate",children:M}),M===(r==null?void 0:r.defaultBranch)&&a.jsx("span",{className:"text-[10px] text-text-400",children:"默认"}),M===U&&a.jsx(Gt,{className:"h-3.5 w-3.5"})]},M)),E&&a.jsx(qY,{message:E,onRetry:()=>{O.begin(f.length,b),P(M=>M+1)}}),j&&a.jsxs("div",{role:"status",className:"flex items-center gap-2 p-3 text-[12px] text-text-400",children:[a.jsx(st,{className:"h-3 w-3 animate-spin"}),"正在读取…"]}),!j&&!E&&!B.length&&a.jsx("p",{className:"p-3 text-[12px] text-text-400",children:"没有找到分支"}),k&&a.jsx("button",{className:La,disabled:j||!!E,onClick:M=>{O.begin(f.length,b+1,M.timeStamp),T(!0),f?w(_):y(V=>V+1)},children:"加载更多分支"})]})]})]})}function U4e({controller:e,disabled:t=!1}){return a.jsxs("div",{"data-testid":"workspace-input-chip",className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-1 pb-2 text-text-300",children:[a.jsx("div",{className:"max-w-[200px] min-w-0",children:a.jsx(GY,{controller:e,compact:!0})}),e.binding&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"h-3 w-px bg-border"}),a.jsx("div",{className:"min-w-0 max-w-[230px]",children:a.jsx(YY,{controller:e,compact:!0,disabled:t},e.binding.repoId)})]}),e.loading&&a.jsx(st,{className:"h-3 w-3 shrink-0 animate-spin text-text-400"})]})}function W4e({controller:e,disabled:t=!1}){var x;const{binding:n,workspace:r,branchIntent:s,loading:i,busy:o,error:l,refresh:c,run:u}=e,[d,h]=p.useState(null),[f,m]=p.useState();p.useEffect(()=>{if(!d){m(void 0);return}let b=!1;return m(void 0),u({action:"diff",filePath:d}).then(y=>{b||m(y.diff)}).catch(()=>{}),()=>{b=!0}},[d,u]);const g=(x=r==null?void 0:r.files.find(b=>b.path===d))==null?void 0:x.comparison;return a.jsxs("div",{className:"space-y-3",children:[a.jsxs(rL,{title:"环境",trailing:a.jsx("button",{"aria-label":"刷新工作区",title:"刷新工作区",disabled:o||i,onClick:()=>void c(),className:"p-1 text-text-400 disabled:opacity-40",children:a.jsx(ko,{className:`h-3 w-3 ${i?"animate-spin":""}`})}),children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-1.5 py-1.5 text-[13px]",children:[a.jsx(Sw,{className:"h-4 w-4 text-text-400"}),a.jsx("span",{children:"云端"}),a.jsx("span",{className:"ml-auto text-[11px] text-text-400",children:n?"已关联":"待关联"})]}),a.jsx(GY,{controller:e}),n&&a.jsx(YY,{controller:e,disabled:t},n.repoId),s&&a.jsxs("p",{className:"mt-1 px-1.5 text-[11px] text-text-400",children:["将在下一条消息里让 agent 切换到 ",s]}),r&&a.jsxs("p",{className:"mt-1 px-1.5 text-[10px] text-text-400",children:["截至 ",y_(new Date(r.measuredAt).toISOString())," ·"," ",r.head.slice(0,7)]}),!n&&a.jsx("p",{className:"mt-2 px-1.5 text-[11px] leading-relaxed text-text-400",children:"关联仓库和分支,在这个会话的独立工作区里开发。"}),l&&a.jsxs("div",{role:"alert",className:"mt-2 rounded-md bg-error/5 p-2 text-[11px] leading-relaxed text-error",children:[l,a.jsx("button",{className:"ml-2 underline",onClick:()=>void c(),children:"重试读取"})]})]}),!!(r!=null&&r.files.length)&&a.jsxs(rL,{title:"Changes",trailing:a.jsxs("span",{className:"text-[10px] text-text-400",children:[r.totalFiles??r.files.length," 个文件"]}),children:[a.jsxs("button",{"aria-label":"查看全部改动",className:La,onClick:()=>h(r.files[0].path),children:[a.jsx(fhe,{className:"h-4 w-4 text-text-400"}),a.jsxs("span",{className:"tabular-nums text-success",children:["+",r.added]}),a.jsxs("span",{className:"tabular-nums text-error",children:["−",r.removed]}),a.jsx(uH,{className:"ml-auto h-3 w-3 text-text-400"})]}),a.jsx("div",{className:"mb-2",children:r.files.map(b=>a.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1.5 text-left text-[11px] hover:bg-text-100/5",onClick:()=>h(b.path),children:[a.jsx("span",{className:"w-4 shrink-0 text-[10px] text-text-400",children:b.status}),a.jsx("span",{title:b.path,className:"min-w-0 flex-1 truncate text-text-300",children:b.path.split("/").at(-1)}),a.jsxs("span",{className:"text-success",children:["+",b.added]}),a.jsxs("span",{className:"text-error",children:["−",b.removed]})]},b.path))}),r.filesTruncated&&a.jsx("p",{className:"mb-2 px-1 text-[11px] text-text-400",children:"仅展示前 200 个改动文件。"})]}),a.jsx(xs,{open:d!==null,onOpenChange:b=>{b||h(null)},children:a.jsxs(ts,{className:"flex h-[min(680px,84vh)] w-[min(1080px,94vw)] max-w-none flex-col gap-0 overflow-hidden p-0",children:[a.jsxs("div",{className:"border-b border-border px-5 py-4",children:[a.jsx(ns,{className:"text-[14px]",children:"代码改动"}),a.jsxs(zi,{className:"mt-2 text-[11px]",children:[(r==null?void 0:r.actualBranch)??"HEAD"," ·"," ",g==="index"?"暂存区相对当前提交的改动":g==="head"?"尚未提交的改动":"相对起始提交 "+(r==null?void 0:r.initialCommit.slice(0,7))+" 的累计改动"]})]}),a.jsxs("div",{className:"flex min-h-0 flex-1",children:[a.jsx("nav",{"aria-label":"改动文件",className:"w-[225px] shrink-0 overflow-auto border-r border-border bg-bg-50 p-2 max-[700px]:hidden",children:r==null?void 0:r.files.map(b=>a.jsx("button",{className:La+" text-[11px]",onClick:()=>h(b.path),children:a.jsx("span",{className:"truncate",children:b.path.split("/").at(-1)})},b.path))}),a.jsxs("div",{className:"min-w-0 flex-1 overflow-auto",children:[a.jsx("div",{className:"sticky top-0 border-b border-border bg-bg-50 px-4 py-3 font-mono text-[11px]",children:d}),f?f.binary?a.jsx("p",{className:"p-5 text-[12px] text-text-400",children:"二进制文件发生变化"}):f.notStored?a.jsx("p",{className:"p-5 text-[12px] text-text-400",children:"这个文件的补丁暂不可用(文件较多或体积较大时只保存部分补丁)。"}):a.jsxs("pre",{className:"min-w-fit py-2 font-mono text-[11px] leading-6",children:[f.patch.split(`
913
913
  `).map((b,y)=>a.jsx("div",{className:`px-4 ${b.startsWith("+")?"bg-success/8 text-success":b.startsWith("-")?"bg-error/8 text-error":"text-text-300"}`,children:b||" "},y)),f.truncated&&a.jsx("div",{className:"px-4 text-text-400",children:"Diff 较大,已截断显示。"})]}):a.jsx("div",{className:"p-5 text-[12px] text-text-400",children:l??"正在读取 diff…"})]})]})]})})]})}const V4e=250;function q4e(e){if(!e||!Number.isFinite(e))return null;const t=e/1e3;if(t<60)return`${t.toFixed(0)}s`;const n=Math.floor(t/60);return`${n}m${Math.round(t-n*60).toString().padStart(2,"0")}s`}function K4e({agents:e}){var c,u,d;const[t,n]=p.useState(!1),r=p.useRef(null);if(p.useEffect(()=>{if(!t)return;const h=f=>{const m=r.current;m&&f.target instanceof Node&&m.contains(f.target)||n(!1)};return window.addEventListener("pointerdown",h,!0),()=>window.removeEventListener("pointerdown",h,!0)},[t]),e.length===0)return null;const s=e.length===1?e[0]:null,i=s?s.description:`${e.length} 个后台任务`,o=s?q4e((u=(c=s.progress)==null?void 0:c.stats)==null?void 0:u.durationMs):null,l=s?(d=s.progress)==null?void 0:d.lastToolName:null;return a.jsxs("div",{ref:r,"data-testid":"running-agents-chip","data-agent-count":e.length,className:"relative",children:[t?a.jsx("div",{"data-testid":"running-agents-popover",className:"absolute bottom-full right-0 z-20 mb-1 w-[min(560px,80vw)]",children:a.jsx("div",{className:"min-w-0 overflow-y-auto rounded-lg border border-bg-200/60 bg-bg-100 px-2 py-1 shadow-lg",style:{maxHeight:V4e},children:e.map(h=>a.jsx(nG,{expandable:!1,description:h.description,input:h.input,output:h.output,...h.error!==void 0?{error:h.error}:{},pending:h.pending,notifications:h.notifications,...h.toolResultExtra?{toolResultExtra:h.toolResultExtra}:{},...h.progress?{progress:h.progress}:{}},h.toolUseId))})}):null,a.jsxs("button",{type:"button","data-testid":"running-agents-chip-toggle","aria-expanded":t,onClick:()=>n(h=>!h),className:Q("flex max-w-[min(560px,80vw)] min-w-0 items-center gap-2 rounded-full","border border-bg-200/60 bg-bg-100/95 px-3 py-1 text-[12px] shadow-md backdrop-blur","hover:bg-bg-200/95 transition-colors"),children:[a.jsx(st,{className:"w-3 h-3 shrink-0 animate-spin text-blue-400"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-text-200",children:i}),o?a.jsx("span",{className:"shrink-0 tabular-nums text-text-400",children:o}):null,l?a.jsxs("span",{className:"shrink-0 font-mono tabular-nums text-blue-400",children:["now:",l]}):null,a.jsx(dH,{className:Q("w-3.5 h-3.5 shrink-0 text-text-400 transition-transform",t&&"rotate-180")})]})]})}const G4e={closeTrailing:!1},Y4e={closeTrailing:!0};function X4e(e){return e?G4e:Y4e}function Z4e({session:e,api:t,onPromoteQuickAsk:n}){const r=rq(e.sessionId);return a.jsx(XY,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function Q4e({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:s="full",ephemeral:i,onPromote:o,hideHeader:l=!1,flatProcess:c=!1,lines:u,pendingPermissions:d,procAlive:h,rewindableUserMessageIds:f,onPermissionRespond:m,onPermissionInterrupt:g,onRewind:x,onFork:b,onQuickAsk:y,topSlot:v,codexHistory:w,realtimeQuestionAnswers:_,onSubmitQuestion:S,onCancelQuestion:k,liveQuestionToolUseIds:C,api:j,cwd:T,tool:E,cloudVolume:I,sessionKey:R,onSend:P,awaitingUser:O,queued:F,onDequeue:L,onAbort:U,onNewSession:B,onClearSession:D,configSlot:M,workspaceInput:V,workspaceInputDisabled:z,chatRootRef:$,chatBodyRef:q,drawers:X,xtermSlot:G,fileSharingScope:te,onShareFile:ae,onOpenInTab:Z,onPreviewMarkdown:J,onOpenFilePath:be,dispatchOrigin:oe}){const[ce,se]=p.useState(0),he=p.useMemo(()=>s==="full"?Xwe(Cq(u)):[],[u,s]),me=p.useMemo(()=>new Set(he.map(Te=>Te.toolUseId)),[he]);return a.jsx(qIe,{children:a.jsxs("div",{ref:$,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[l?null:a.jsx(U5e,{meta:e,...E?{tool:E}:{},...I?{cloudVolume:I}:{},connState:t,variant:s,...n!==void 0?{liveWorktreeRoot:n}:{},...s==="full"&&r?{onOpenConfig:r}:{},...s==="quickask"?{ephemeral:i??!1,...o?{onPromote:o}:{}}:{}}),a.jsx("div",{ref:q,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none",paddingBottom:ce},children:a.jsx(iG,{lines:u,forkByTurn:E==="codex",...m?{onPermissionRespond:m}:{},...g&&h?{onPermissionInterrupt:g}:{},topSlot:v,codexHistory:w,...x?{onRewind:x}:{},rewindableUserMessageIds:f,...b?{onFork:b}:{},...y?{onQuickAsk:y}:{},realtimeQuestionAnswers:_,onSubmitQuestion:S,...k?{onCancelQuestion:k}:{},liveQuestionToolUseIds:C,...te?{fileSharingScope:te}:{},...ae?{onShareFile:ae}:{},...Z?{onOpenInTab:Z}:{},...J?{onPreviewMarkdown:J}:{},...be?{onOpenFilePath:be}:{},...oe?{dispatchOrigin:oe}:{},...s==="full"&&!c?{turnCollapse:X4e(h)}:{},dockedAgentToolUseIds:me})}),G,a.jsx(j4e,{onHeightChange:se,children:a.jsx(K4e,{agents:he})}),e.larkChatName?a.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):a.jsx(pG,{meta:e,aboveSlot:V,disabled:z,...j?{api:j}:{},cwd:T,...E?{tool:E}:{},sessionKey:R,onSend:P,awaitingUser:O,...F?{queued:F}:{},...L?{onDequeue:L}:{},...U?{onAbort:U}:{},...B?{onNewSession:B}:{},...D?{onClearSession:D}:{},...M?{configSlot:M}:{}}),X]})})}function XY({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){var vr;const{session:s,api:i,liveGitBranch:o,liveWorktreeRoot:l,cloudVolume:c,onNewSession:u,onTurnEnd:d,onOpenConfig:h,onFork:f,onQuickAsk:m,viewerRole:g,onPromoteQuickAsk:x,configSlot:b,hideHeader:y,flatProcess:v}=t,{capabilities:w}=ni(s.tool||"claude"),_=(w==null?void 0:w.features)??yG(s.tool),[S,k]=p.useState(null),[C,j]=p.useState(null),T=bx(),E=!!i&&T.actionsLevel==="owner"&&_.fileSharing,I=DM(s.ownerPersonaId??null).persona,R=(I==null?void 0:I.label)??null,P=!!R&&!!s.ownerPersonaId,O=S4e(),F=p.useMemo(()=>({resolve:(ve,Qe)=>O.resolve(ve,Qe,s.sessionId),...O.onOpenSession?{onOpenSession:O.onOpenSession}:{}}),[O,s.sessionId]),L=p.useCallback((ve,Qe)=>{k({kind:ve,text:Qe}),setTimeout(()=>{k(He=>(He==null?void 0:He.text)===Qe?null:He)},2e3)},[]),U=Un(),B=Pb(s.tool)&&g!=="guest"&&!s.larkChatId&&!x,D=E4e(i,s.sessionId,B,U,s.cloudWorkspace,s.cloudBranchIntent),M=TU(),V=ZV(s.sessionId,s.toolSessionId),{events:z,pendingQuestions:$,clearQuestion:q,markQuestionSubmitted:X,status:G}=V,te=e.historyLoading,ae=nq(G);p.useEffect(()=>{Pe("chat-panel","sessionStatus",{sessionId:s.sessionId,sessionStatus:G,procAlive:ae})},[G,ae,s.sessionId]);const Z=e.lines,J=e.pendingPermissions,be=J[0]??null,oe=p.useMemo(()=>Gwe(z),[z]),[ce,se]=p.useState(null),[he,me]=p.useState(()=>new Set);Vwe(i,s.sessionId,s.toolSessionId,_.observe);const Te=p.useRef(s.sessionId);p.useEffect(()=>{if(Te.current=s.sessionId,!_.rewind){se(null);return}let ve=!1;return se(null),(async()=>{try{const Qe=await i.sessionRewindableMessageIds(s.sessionId);if(ve)return;se(new Set(Qe.userMessageIds))}catch{ve||se(null)}})(),()=>{ve=!0}},[i,s.sessionId,_.rewind]);const Ve=p.useCallback(()=>{const ve=s.sessionId;i.sessionRewindableMessageIds(ve).then(Qe=>{Te.current===ve&&se(new Set(Qe.userMessageIds))}).catch(()=>{})},[i,s.sessionId]),ge=p.useMemo(()=>{if(ce!==null){const Ht=new Set(ce);for(const ur of he)Ht.delete(ur);return Ht}const ve=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),Qe=new Set;let He=null;for(const Ht of Z)Ht.kind==="user-text"?He=Ht.uuid??null:He&&Ht.kind==="tool-call"&&ve.has(Ht.tool)&&!he.has(He)&&Qe.add(He);return Qe},[Z,he,ce]),Ne=p.useRef(d);Ne.current=d,qwe(s.sessionId,s.toolSessionId,()=>{Nt(null),me(new Set)});const Me=vG({sessionStatus:G}),Ue=p.useRef(null);p.useEffect(()=>{var He;const ve=Ue.current,Qe=(ve==null?void 0:ve.sid)===s.sessionId;Qe&&ve.phase===Me||(Ue.current={sid:s.sessionId,phase:Me},Pe("session-phase",Me,{sid:s.sessionId,phase:Me,prev:Qe?ve.phase:null,desc:iTe[Me]}),Qe&&ve.phase==="turn-running"&&Me!=="turn-running"&&((He=Ne.current)==null||He.call(Ne),Ve()))},[Me,s.sessionId,Ve]);const ut=p.useCallback(async()=>{const ve=await i.sessionInterrupt(s.sessionId).catch(()=>{});return(ve==null?void 0:ve.queued)??[]},[i,s.sessionId]),[Ct,Nt]=p.useState(null),ne=p.useCallback(ve=>{Nt(ve)},[]),[re,Ee]=p.useState(!1),Ae=p.useCallback(()=>{i.sessionStop(s.sessionId).catch(()=>{}),Ee(!1)},[i,s.sessionId]);p.useCallback(ve=>{i.pinSession(s.sessionId,ve).catch(Qe=>{Pe("chat-panel","pinSession failed",{err:Qe==null?void 0:Qe.message})})},[i,s.sessionId]);const et=x?"quickask":"full",{container:qe,workspaceContainer:tt,onCollapse:Pt,hostExtras:wt}=vM(),_e=p.useRef(0),Le=p.useRef(null);p.useEffect(()=>{const ve=Qe=>{if(Qe.key!=="Escape")return;if(!ae){_e.current=0;return}if(Qe.isComposing)return;const Ht=Qe.target;if(Ht&&Ht.closest("[data-cc-chat-root]")!==Le.current)return;const ur=Date.now();ur-_e.current<2e3?(_e.current=0,Ee(!0)):(_e.current=ur,ut())};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[ut,ae]);const dt=p.useRef(null),ot=p.useRef(null),dn=p.useRef(!!e.codexHistory);dn.current=!!e.codexHistory;const ke=p.useRef(!0),ie=p.useRef(void 0),De=p.useRef(0),rt=p.useRef(0),ht=p.useRef(void 0);p.useEffect(()=>{j(null)},[s.sessionId]),p.useEffect(()=>{const ve=dt.current;if(!ve)return;const Qe=150,He=Ht=>{dn.current||Date.now()<rt.current&&(Ht.preventDefault(),rt.current=Date.now()+Qe)};return ve.addEventListener("wheel",He,{passive:!1}),()=>ve.removeEventListener("wheel",He)},[]),p.useEffect(()=>{const ve=dt.current;if(!ve)return;const Qe=32,He=()=>{var ur;const Ht=ve.scrollHeight-ve.scrollTop-ve.clientHeight;ke.current=Ht<=Qe,e.codexHistory&&(ot.current=UA(ve)),ve.scrollTop<=24&&e.historyHasMore&&!e.historyLoadingOlder&&!e.historyError&&!te&&((ur=e.loadOlderHistory)==null||ur.call(e))};return ve.addEventListener("scroll",He,{passive:!0}),()=>ve.removeEventListener("scroll",He)},[e.codexHistory,e.historyHasMore,e.historyLoadingOlder,e.historyError,e.loadOlderHistory,te]),p.useLayoutEffect(()=>{var Qi;const ve=dt.current;if(!ve)return;const Qe=ht.current!==s.sessionId;Qe&&(ht.current=s.sessionId,ke.current=!0,ie.current=void 0,De.current=0,rt.current=0,ot.current=null);const He=ie.current,Ht=(Qi=Z[0])==null?void 0:Qi.seq;if(ie.current=Ht,e.codexHistory){!Qe&&ot.current&&!ke.current?d5e(ve,ot.current):ke.current&&(ve.scrollTop=ve.scrollHeight),ot.current=UA(ve),De.current=ve.scrollHeight-ve.scrollTop;return}!Qe&&He!==void 0&&Ht!==void 0&&Ht<He?(ve.scrollTop=ve.scrollHeight-De.current,rt.current=Date.now()+200):ke.current&&(ve.scrollTop=ve.scrollHeight),De.current=ve.scrollHeight-ve.scrollTop},[Z,be==null?void 0:be.requestId,s.sessionId]);const jt=p.useMemo(()=>{const ve={};for(const[Qe,He]of Object.entries($))He.submittedAnswers&&(ve[Qe]=He.submittedAnswers);return ve},[$]),Bt=p.useMemo(()=>new Set(Object.keys($)),[$]),hn=p.useCallback(async(ve,Qe)=>{try{await i.answerQuestion({sessionId:s.sessionId,toolUseId:ve,answers:Qe}),X(ve,Qe)}catch{}},[i,s.sessionId,X]),jn=p.useCallback(async ve=>{try{await i.cancelQuestion({sessionId:s.sessionId,toolUseId:ve}),q(ve)}catch{}},[i,s.sessionId,q]),Xn=p.useCallback(async(ve,Qe)=>{var He;if(be)try{await((He=e.respondPermission)==null?void 0:He.call(e,be.requestId,ve?"allow":"deny"))}catch{}},[e,be]),zt=p.useCallback(async()=>{const ve=s.sessionId;try{await i.sessionStop(ve)}catch{}e.clearSession?await e.clearSession():await i.sessionNew(ve)},[e,i,s.sessionId]),pe=e.meta.streamInProgress??!1,ct=p.useMemo(()=>{if(e.codexHistory)return a.jsxs("div",{className:"flex flex-col items-center gap-2 py-2 text-xs text-text-400","data-testid":"codex-history-top",children:[e.historySyncError?a.jsx("span",{children:e.historySyncError}):null,e.historyError?a.jsx("span",{"data-testid":"history-error",children:e.historyError}):null,te||e.historyLoadingOlder?a.jsx("span",{"data-testid":"history-loading",children:"正在加载历史…"}):e.historyHasMore?a.jsx("button",{type:"button",onClick:()=>{var Qe;return void((Qe=e.loadOlderHistory)==null?void 0:Qe.call(e))},children:e.historyError?"重试更早记录":"加载更早记录"}):e.historyLoaded&&!e.historyError&&!e.historySyncError?a.jsx("span",{children:"已加载全部轮次摘要"}):null,e.historyError||e.historySyncError?a.jsx("button",{type:"button",onClick:()=>{var Qe;return void((Qe=e.refreshHistory)==null?void 0:Qe.call(e))},children:"刷新历史"}):null]});const ve=e.historySyncError?a.jsxs("div",{className:"flex justify-center items-center gap-2 py-2 text-[12px] text-text-400","data-testid":"history-sync-error",children:[a.jsx("span",{children:e.historySyncError}),e.reloadFromCloud?a.jsx("button",{type:"button","data-testid":"history-sync-reload",disabled:pe,onClick:e.reloadFromCloud,className:"text-accent hover:underline cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 disabled:no-underline",children:"从云端重新加载"}):null]}):null;return e.historyError?a.jsxs(a.Fragment,{children:[ve,a.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]})]}):ve||(te&&Z.length===0?a.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:a.jsx(st,{className:"w-4 h-4 text-text-400 animate-spin"})}):null)},[te,Z.length,e.historyError,e.historySyncError,e.reloadFromCloud,pe,e.codexHistory,e.historyHasMore,e.historyLoaded,e.historyLoadingOlder,e.loadOlderHistory,e.refreshHistory]),on=e.meta,Xt=a.jsxs(a.Fragment,{children:[s.toolSessionId&&_.subagents?a.jsx(Q5e,{api:i,cwd:s.cwd,toolSessionId:s.toolSessionId,toolKind:s.tool??"claude"}):null,Ct&&_.rewind?a.jsx(eTe,{open:!0,onOpenChange:ve=>{ve||Nt(null)},api:i,sessionId:s.sessionId,userMessageId:Ct,lines:Z,procAlive:ae,onNoChanges:ve=>{me(Qe=>{if(Qe.has(ve))return Qe;const He=new Set(Qe);return He.add(ve),He})}}):null,re?a.jsx(J4e,{onConfirm:Ae,onCancel:()=>Ee(!1)}):null]}),lr={kind:"session",sessionId:s.sessionId},Zn=p.useCallback(async ve=>{if(i)try{await FO(i,U,s.sessionId,ve)}catch(Qe){const He=Qe.message;Pe("chat-panel","open-in-tab failed",{err:He}),L("err",`Open in tab 失败:${He}`)}},[i,U,s.sessionId,L]),[Ft,Dt]=p.useState(!1),[Fn,Qn]=p.useState(null),Us=p.useCallback(ve=>{if(r){r(ve);return}Qn(ve),Dt(!0)},[r]),Ec=p.useCallback(ve=>{if(!i)return;const Qe=async()=>{try{await i.attachmentGroupAdd(s.sessionId,ve)}catch(Ht){Pe("chat-panel","file-link groupAdd skipped",{err:Ht.message})}},He=Ht=>{const ur=Ht.message;Pe("chat-panel","file-link open failed",{err:ur}),L("err",`打开文件失败:${ur}`)};if(i_(ve)){Qe().then(()=>Us(ve),He);return}FO(i,U,s.sessionId,ve,60,Qe).catch(He)},[i,U,s.sessionId,Us,L]),cr=p.useCallback(async ve=>{if(!i)throw new Error("daemon api not ready");const Qe=await YT(i,U,s.sessionId,ve,60),He=await fetch(Qe);if(!He.ok)throw new Error(`fetch ${He.status} ${He.statusText}`);return await He.text()},[i,U,s.sessionId]),Ss=p.useCallback(async(ve,Qe)=>{if(i)try{const{url:He}=await i.attachmentSignUrl({sessionId:s.sessionId,relPath:ve,...Qe?{view:Qe}:{}}),Ht=await Dwe(He);L(Ht?"ok":"err",Ht?"分享链接已复制到剪贴板":"复制失败:请手动复制")}catch(He){const Ht=He.message;Pe("chat-panel","share-file failed",{err:Ht}),L("err",`生成分享链接失败:${Ht}`)}},[i,s.sessionId,L]),Zi=p.useCallback(()=>j(null),[]),Ws=C==="files"&&E&&i?{title:"Edited Files",onBack:Zi,content:a.jsx(y3e,{api:i,scope:lr,sessionId:s.sessionId,onShareFile:Ss,onOpenInTab:Zn,onPreviewMarkdown:Us})}:C==="cron"?{title:`定时任务${oe.length?` (${oe.length})`:""}`,onBack:Zi,content:a.jsx("div",{className:"p-3",children:a.jsx(sTe,{jobs:oe})})}:C==="persona"&&P&&i&&s.ownerPersonaId?{title:`Persona · ${R??""}`,onBack:Zi,content:a.jsx(RY,{personaId:s.ownerPersonaId,open:!0,onClose:Zi,api:i,embedded:!0,...g?{viewerRole:g}:{}},s.ownerPersonaId)}:null,wa=et==="full"?a.jsx(X5e,{session:s,meta:on,...B&&D.binding?{liveGitBranch:((vr=D.workspace)==null?void 0:vr.actualBranch)??null}:o!==void 0?{liveGitBranch:o}:{},...l!==void 0?{liveWorktreeRoot:l}:{},...P?{personaName:R}:{},...P?{onOpenPersona:()=>j("persona")}:{},...E?{onOpenFiles:()=>j("files")}:{},cronActiveCount:oe.length,onCronClick:()=>j("cron"),onForceStop:()=>Ee(!0),...Pb(s.tool)&&e.reloadFromCloud?{onReloadFromCloud:e.reloadFromCloud,reloadFromCloudDisabled:pe}:{},...g?{viewerRole:g}:{},...w!=null&&w.toolSessionIdLabel?{toolSessionIdLabel:w.toolSessionIdLabel}:{},drill:Ws,...Pt?{onCollapse:Pt}:{},...wt?{title:wt.title,leadingEntries:wt.leadingEntries}:{}}):null;return a.jsxs(a.Fragment,{children:[B&&tt?Zr.createPortal(a.jsx(W4e,{controller:D,disabled:on.streamInProgress}),tt):null,qe&&wa?Zr.createPortal(wa,qe):null,a.jsx(Q4e,{headerMeta:on,workspaceInput:B?a.jsx(U4e,{controller:D,disabled:on.streamInProgress}):void 0,workspaceInputDisabled:B&&D.busy,connState:e.connState,...l!==void 0?{liveWorktreeRoot:l}:{},...h?{onOpenConfig:h}:{},variant:et,...y||B?{hideHeader:!0}:{},...v?{flatProcess:v}:{},...et==="quickask"?{ephemeral:s.ephemeral!==!1,onPromote:()=>void(x==null?void 0:x(s.sessionId))}:{},lines:Z,pendingPermissions:J,procAlive:ae,rewindableUserMessageIds:ge,onPermissionRespond:Xn,onPermissionInterrupt:ut,onRewind:_.rewind?ne:void 0,...f&&_.fork?{onFork:f}:{},...n&&_.fork?{onQuickAsk:n}:m&&_.fork?{onQuickAsk:m}:{},topSlot:ct,codexHistory:e.codexHistory,realtimeQuestionAnswers:jt,onSubmitQuestion:hn,onCancelQuestion:jn,liveQuestionToolUseIds:Bt,api:i,cwd:s.cwd,...s.tool?{tool:s.tool}:{},...c?{cloudVolume:c}:{},sessionKey:s.sessionId,onSend:e.sendText,queued:e.queued,onDequeue:e.dequeue,awaitingUser:J.length>0||Object.values($).some(ve=>!ve.submittedAnswers),onAbort:ut,...u?{onNewSession:u}:{},onClearSession:zt,...b?{configSlot:b}:{},chatRootRef:Le,chatBodyRef:dt,drawers:Xt,xtermSlot:M==="tui"&&ae&&_.tui?a.jsx(v3e,{sessionId:s.sessionId,client:U},s.sessionId):null,fileSharingScope:lr,...i?{onShareFile:Ss}:{},...i?{onOpenInTab:Zn}:{},...i?{onPreviewMarkdown:Us}:{},...i?{onOpenFilePath:Ec}:{},dispatchOrigin:F}),i?a.jsx(N4e,{open:Ft,onOpenChange:Dt,relPath:Fn,loadMarkdown:cr,onShare:Fn?()=>void Ss(Fn,"md-rendered"):void 0}):null,S?a.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:S.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:S.text}):null]})}function J4e({onConfirm:e,onCancel:t}){return a.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:a.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[a.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[a.jsx(Sn,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),a.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),a.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function ePe(e){return e.split("/").pop()||e}function tPe({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:s,loadMarkdown:i,quickAskSession:o,onPromoteQuickAsk:l}){if(!Sq(e))return null;const c=[];e.quickAsk&&c.push({id:"quick-ask",label:"问一下",title:"问一下",icon:a.jsx(yg,{className:"w-3.5 h-3.5"})});for(const u of e.mds)c.push({id:{kind:"md",relPath:u},label:ePe(u),title:u,icon:a.jsx(aa,{className:"w-3.5 h-3.5"})});return a.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[a.jsx(li,{delayDuration:200,skipDelayDuration:100,children:a.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:c.map(u=>{const d=Wwe(e.active,u.id),h=u.id==="quick-ask"?"quick-ask":`md:${u.id.relPath}`;return a.jsxs(Gi,{children:[a.jsx(Yi,{asChild:!0,children:a.jsxs("div",{role:"tab","aria-selected":d,"data-tab-title":u.title,onClick:()=>n(u.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",d?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[u.icon,a.jsx("span",{className:"truncate",children:u.label}),a.jsx("button",{type:"button","aria-label":`关闭 ${u.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",d?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),u.id==="quick-ask"?r():s(u.id.relPath)},children:a.jsx(Yt,{className:"w-3 h-3"})}),d?a.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),a.jsx(hi,{side:"bottom",align:"start",className:"max-w-sm break-all",children:u.title})]},h)})})}),a.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?a.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:a.jsx(Z4e,{session:o,api:t,...l?{onPromoteQuickAsk:l}:{}})}):null,e.mds.map(u=>{const d=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===u;return a.jsx("div",{className:"absolute inset-0",style:{display:d?"block":"none"},children:a.jsx(DY,{relPath:u,loadMarkdown:i,showTitleBar:!1})},`md-body:${u}`)})]})]})}function nPe(e){const t=e instanceof Error?e.message:String(e);return t.length>200?`${t.slice(0,200)}…`:t}function rPe({state:e,extras:t}){const{api:n,session:r}=t,s=Un(),[i,o]=p.useState($we()),[l,c]=p.useState(null),u=r.ownerPersonaId!==Oi,d=p.useRef(i);d.current=i;const h=p.useRef(!1),f=p.useCallback(async j=>{const T=d.current.quickAsk;c(null);let E;try{E=await Iwe(n,r,j)}catch(I){Pe("quick-ask","fork failed",I),h.current||c(nPe(I));return}if(!E){h.current||c("这条会话还没准备好(没有可派生的对话记录),稍后再试");return}if(h.current){n.sessionDelete(E.sessionId).catch(()=>{});return}x0(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),o(I=>Lwe(I,{sessionId:E.sessionId}))},[n,r]),m=p.useCallback(async j=>{const T=d.current.quickAsk,E=(T==null?void 0:T.sessionId)===j;try{await Twe(n,{sessionId:j,stillEphemeral:E&&x0(T)})&&o(R=>zwe(R))}catch(I){Pe("quick-ask","promote failed",I)}},[n]),g=p.useCallback(j=>{o(T=>Bwe(T,j))},[]),x=p.useCallback(j=>{o(T=>Uwe(T,j))},[]),b=p.useCallback(()=>{const j=d.current.quickAsk;x0(j)&&n.sessionDelete(j.sessionId).catch(()=>{}),o(T=>Fwe(T))},[n]),y=p.useCallback(j=>{o(T=>Hwe(T,j))},[]);p.useEffect(()=>()=>{h.current=!0;const j=d.current.quickAsk;x0(j)&&n.sessionDelete(j.sessionId).catch(()=>{})},[]);const v=ca("sessions")??[],w=i.quickAsk?v.find(j=>j.sessionId===i.quickAsk.sessionId)??{sessionId:i.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,_=p.useCallback(async j=>{const T=await YT(n,s,r.sessionId,j,60),E=await fetch(T);if(!E.ok)throw new Error(`fetch ${E.status} ${E.statusText}`);return E.text()},[n,s,r.sessionId]),S=a.jsx(XY,{state:e,extras:t,onQuickAskInternal:f,onPreviewMdInternal:g}),{initialSize:k,setSize:C}=_q("chat-panel-right-slot-width",480);return a.jsxs(Jw,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[a.jsx(qh,{id:"chat",minSize:"400px",children:a.jsxs("div",{className:"relative flex flex-col min-w-0 min-h-0 h-full",children:[S,l?a.jsxs("div",{"data-testid":"quick-ask-error",className:"absolute bottom-24 left-1/2 z-10 -translate-x-1/2 max-w-[90%] rounded-md border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-300 shadow-lg",children:[a.jsxs("span",{className:"mr-2",children:["问一下没能打开:",l]}),a.jsx("button",{type:"button","aria-label":"关闭提示",onClick:()=>c(null),className:"text-text-400 hover:text-text-200 cursor-pointer",children:"✕"})]}):null]})}),Sq(i)?a.jsxs(a.Fragment,{children:[a.jsx(GT,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),a.jsx(qh,{id:"right-slot",defaultSize:`${k}px`,minSize:"360px",maxSize:"800px",onResize:j=>C(j.inPixels),children:a.jsx(tPe,{state:i,api:n,onSwitchTab:x,onCloseQuickAsk:b,onCloseMd:y,loadMarkdown:_,quickAskSession:w,...u?{onPromoteQuickAsk:m}:{}})})]}):null]})}function S_({extras:e}){const t=rq(e.session.sessionId,e.focused);return a.jsx(rPe,{state:t,extras:e})}const sPe=ZK("inline-flex items-center rounded-sm border px-2 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"border-transparent bg-accent text-accent-contrast",secondary:"border-transparent bg-bg-200 text-text-200",destructive:"border-transparent bg-destructive text-white",outline:"border-border bg-transparent text-text-200"}},defaultVariants:{variant:"default"}});function nc({className:e,variant:t,...n}){return a.jsx("span",{className:Q(sPe({variant:t}),e),...n})}const ar=p.forwardRef(({className:e,type:t,...n},r)=>a.jsx("input",{ref:r,type:t??"text",className:Q("flex h-9 w-full rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100","placeholder:text-text-400","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:border-accent","disabled:cursor-not-allowed disabled:opacity-50",e),...n}));ar.displayName="Input";function LM(e){const[t,n]=p.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>n(!t),"aria-expanded":t,className:"mt-1 inline-flex cursor-pointer items-center gap-1 text-xs text-text-500 hover:text-accent",children:[a.jsx(Jt,{className:`size-3 transition-transform ${t?"":"-rotate-90"}`}),"为什么列它 · ",e.evidence.file]}),t&&a.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[a.jsx("div",{className:"text-[13px] leading-snug text-text-300",children:e.evidence.reason}),a.jsx("pre",{className:"whitespace-pre-wrap rounded-md border border-border bg-bg-100 px-3 py-2 font-mono text-xs leading-relaxed text-text-300",children:e.evidence.quote})]})]})}function Px(e){return a.jsx("span",{className:`inline-flex shrink-0 items-center rounded-sm bg-warning-dim px-1.5 py-px text-[11px] font-medium leading-4 text-warning ${e.className??""}`,children:"必填"})}function xE(e){const[t,n]=p.useState({}),[r,s]=p.useState(!1),[i,o]=p.useState(null),l=e.presence!==void 0,c=m=>{var g,x;return(x=(g=e.presence)==null?void 0:g.find(b=>b.env===m))==null?void 0:x.setAt},u=l?e.secret.env.filter(m=>!c(m)):[],d=l&&u.length===0,h=Object.values(t).some(m=>m.length>0),f=async()=>{s(!0),o(null);try{const m=Object.fromEntries(Object.entries(t).filter(([,g])=>g.length>0));await e.onSubmitValues(m),n({})}catch(m){o(m instanceof Error?m.message:String(m))}finally{s(!1)}};return a.jsxs("div",{className:e.embedded?"px-4 py-3":"border-b border-border-card px-5 py-4 last:border-b-0",children:[!e.embedded&&a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:e.secret.name}),d?a.jsxs(nc,{variant:"secondary",className:"gap-1",children:[a.jsx(Gt,{className:"size-3"}),"已就绪"]}):l?a.jsxs(nc,{variant:"outline",children:["还差 ",u.length," 个值"]}):a.jsx(nc,{variant:"outline",children:"填没填查不到"})]}),!e.embedded&&e.evidence&&a.jsx(LM,{evidence:e.evidence}),a.jsxs("div",{className:e.embedded?"space-y-1.5":"mt-2.5 space-y-1.5",children:[e.secret.env.map(m=>{const g=c(m);return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"w-64 shrink-0 font-mono text-xs text-text-400",htmlFor:m,children:e.secret.name==="feishu"&&m==="LARKSUITE_CLI_APP_ID"?"App ID":e.secret.name==="feishu"&&m==="LARKSUITE_CLI_APP_SECRET"?"App Secret":m}),a.jsx(ar,{id:m,type:"password",autoComplete:"off",placeholder:g?"已填过,重填即覆盖":"粘贴值",value:t[m]??"",onChange:x=>n({...t,[m]:x.target.value})}),l?g?a.jsxs("span",{className:"w-24 shrink-0 text-xs text-text-400",children:["已填 · ",y_(new Date(g).toISOString())]}):a.jsx("span",{className:"w-24 shrink-0",children:a.jsx(Px,{})}):a.jsx("span",{className:"w-24 shrink-0 text-xs text-text-500",children:"未知"})]},m)}),a.jsxs("div",{className:"flex items-center gap-3 pt-0.5",children:[a.jsx(ze,{size:"sm",disabled:!h||r,onClick:()=>void f(),children:r?"写入中…":"写进仓库 Secrets"}),a.jsx("span",{className:"text-xs text-text-500",children:"直接写进仓库的 GitHub Secrets,不落本机"})]}),i&&a.jsx("div",{className:"text-xs text-error",children:i})]})]})}var k_="DropdownMenu",[iPe]=ma(k_,[Xw]),ss=Xw(),[oPe,ZY]=iPe(k_),QY=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:s,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,c=ss(t),u=p.useRef(null),[d,h]=Wu({prop:s,defaultProp:i??!1,onChange:o,caller:k_});return a.jsx(oPe,{scope:t,triggerId:wo(),triggerRef:u,contentId:wo(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(f=>!f),[h]),modal:l,children:a.jsx(xV,{...c,open:d,onOpenChange:h,dir:r,modal:l,children:n})})};QY.displayName=k_;var JY="DropdownMenuTrigger",eX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=e,i=ZY(JY,n),o=ss(n);return a.jsx(vV,{asChild:!0,...o,children:a.jsx(sn.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...s,ref:ix(t,i.triggerRef),onPointerDown:it(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:it(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});eX.displayName=JY;var aPe="DropdownMenuPortal",tX=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ss(t);return a.jsx(yV,{...r,...n})};tX.displayName=aPe;var nX="DropdownMenuContent",rX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ZY(nX,n),i=ss(n),o=p.useRef(!1);return a.jsx(bV,{id:s.contentId,"aria-labelledby":s.triggerId,...i,...r,ref:t,onCloseAutoFocus:it(e.onCloseAutoFocus,l=>{var c;o.current||(c=s.triggerRef.current)==null||c.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:it(e.onInteractOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!s.modal||d)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});rX.displayName=nX;var lPe="DropdownMenuGroup",cPe=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(wV,{...s,...r,ref:t})});cPe.displayName=lPe;var uPe="DropdownMenuLabel",sX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(_V,{...s,...r,ref:t})});sX.displayName=uPe;var dPe="DropdownMenuItem",iX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(SV,{...s,...r,ref:t})});iX.displayName=dPe;var hPe="DropdownMenuCheckboxItem",oX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(kV,{...s,...r,ref:t})});oX.displayName=hPe;var fPe="DropdownMenuRadioGroup",pPe=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(CV,{...s,...r,ref:t})});pPe.displayName=fPe;var mPe="DropdownMenuRadioItem",gPe=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(NV,{...s,...r,ref:t})});gPe.displayName=mPe;var xPe="DropdownMenuItemIndicator",aX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(jV,{...s,...r,ref:t})});aX.displayName=xPe;var vPe="DropdownMenuSeparator",lX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(EV,{...s,...r,ref:t})});lX.displayName=vPe;var yPe="DropdownMenuArrow",bPe=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(IV,{...s,...r,ref:t})});bPe.displayName=yPe;var wPe=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:s,defaultOpen:i}=e,o=ss(t),[l,c]=Wu({prop:r,defaultProp:i??!1,onChange:s,caller:"DropdownMenuSub"});return a.jsx($be,{...o,open:l,onOpenChange:c,children:n})},_Pe="DropdownMenuSubTrigger",cX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(TV,{...s,...r,ref:t})});cX.displayName=_Pe;var SPe="DropdownMenuSubContent",uX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ss(n);return a.jsx(MV,{...s,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});uX.displayName=SPe;var kPe=QY,CPe=eX,dX=tX,hX=rX,fX=sX,pX=iX,mX=oX,NPe=aX,gX=lX,jPe=wPe,xX=cX,vX=uX;const is=kPe,os=CPe,zr=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>a.jsx(dX,{children:a.jsx(hX,{ref:r,sideOffset:t,className:Q("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));zr.displayName=hX.displayName;const yX=jPe,BM=p.forwardRef(({className:e,...t},n)=>a.jsx(xX,{ref:n,className:Q("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));BM.displayName=xX.displayName;const FM=p.forwardRef(({className:e,...t},n)=>a.jsx(dX,{children:a.jsx(vX,{ref:n,className:Q("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));FM.displayName=vX.displayName;const Tt=p.forwardRef(({className:e,inset:t,...n},r)=>a.jsx(pX,{ref:r,className:Q("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Tt.displayName=pX.displayName;const vE=p.forwardRef(({className:e,children:t,checked:n,...r},s)=>a.jsxs(mX,{ref:s,checked:n,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(NPe,{children:a.jsx(Gt,{className:"h-3.5 w-3.5"})})}),t]}));vE.displayName=mX.displayName;const da=p.forwardRef(({className:e,...t},n)=>a.jsx(gX,{ref:n,className:Q("-mx-1 my-1 h-px bg-border",e),...t}));da.displayName=gX.displayName;const rc=p.forwardRef(({className:e,...t},n)=>a.jsx(fX,{ref:n,className:Q("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));rc.displayName=fX.displayName;function zM(e){let t;return e.map(n=>{const r=n.group&&n.group!==t?n.group:null;return n.group&&(t=n.group),{...n,groupHeading:r}})}function bX({testid:e,label:t,current:n,items:r,onSelect:s,needsAttention:i=!1,disabled:o=!1,align:l="end"}){return a.jsxs(is,{children:[a.jsx(os,{asChild:!0,children:a.jsx(Dx,{testid:e,label:t,needsAttention:i,disabled:o})}),a.jsx(zr,{align:l,className:"max-h-[420px] overflow-y-auto",children:zM(r).map((c,u)=>a.jsxs(K.Fragment,{children:[c.groupHeading?a.jsxs(a.Fragment,{children:[u>0?a.jsx(da,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:c.groupHeading})]}):null,a.jsxs(Tt,{onSelect:()=>s(c.value),children:[a.jsx(Gt,{className:Q("mr-2 h-3.5 w-3.5",n===c.value?"opacity-100":"opacity-0")}),a.jsx("span",{className:"flex-1",children:c.label}),c.description?a.jsx("span",{className:"ml-3 text-[11px] text-text-400",children:c.description}):null]})]},c.value||"default"))})]})}const Dx=K.forwardRef(function({testid:t,label:n,needsAttention:r=!1,disabled:s=!1,...i},o){return a.jsxs("button",{ref:o,type:"button",disabled:s,"data-testid":t,"data-needs-attention":r?"":void 0,className:Q("flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-50",r?"border-warning/30 bg-warning-dim text-warning hover:bg-warning/20":"border-border bg-bg-50 text-text-200 hover:bg-text-100/5 hover:text-text-100"),...i,children:[n,a.jsx(Jt,{className:Q("h-3 w-3",r?"text-warning":"text-text-400")})]})});function Yr(e){const t=e.tone==="accent"?"bg-accent-dim text-accent":e.tone==="warning"?"bg-warning-dim text-warning":"bg-bg-100 text-text-300";return a.jsxs("div",{className:"flex items-center gap-3 border-b border-border-card bg-bg-100/70 px-5 py-3.5",children:[a.jsx("span",{className:`flex size-8 shrink-0 items-center justify-center rounded-lg ${t}`,children:e.icon}),a.jsx("span",{className:"shrink-0 whitespace-nowrap text-lg font-semibold text-text-100",children:e.title}),e.count&&a.jsx("span",{className:"shrink-0 rounded-full border border-border px-2 py-0.5 text-xs text-text-300",children:e.count})]})}function wX({channel:e,saving:t=!1,onSave:n,onClose:r}){const s=p.useId(),[i,o]=p.useState((e==null?void 0:e.name)??""),[l,c]=p.useState((e==null?void 0:e.baseUrl)??""),[u,d]=p.useState(""),[h,f]=p.useState((e==null?void 0:e.remark)??""),[m,g]=p.useState(null),[x,b]=p.useState(!1),y=p.useRef(!1),v=t||x,w=async _=>{if(_.preventDefault(),y.current||t)return;g(null);const S=i.trim(),k=l.trim(),C=u.trim(),j=h.trim();if(!S){g("通道名称不能为空");return}if(!k){g("订阅地址不能为空");return}if(!k.startsWith("http://")&&!k.startsWith("https://")){g("订阅地址必须以 http:// 或 https:// 开头");return}if(!e&&!C){g("新建通道必须填写 API Key");return}y.current=!0,b(!0);try{await n({...e?{id:e.id}:{},name:S,baseUrl:k,...C?{apiKey:C}:{},...j||e?{remark:j}:{}}),r()}catch(T){g(T instanceof Error?T.message:String(T))}finally{y.current=!1,b(!1)}};return a.jsx(xs,{open:!0,onOpenChange:_=>{!_&&!y.current&&!t&&r()},children:a.jsx(ts,{className:"max-w-md","data-testid":"channel-modal",children:a.jsx("form",{onSubmit:w,children:a.jsxs("fieldset",{disabled:v,className:"space-y-4",children:[a.jsxs(Ls,{children:[a.jsx(ns,{children:e?"编辑订阅通道":"添加订阅通道"}),a.jsx(zi,{children:"配置模型代理通道的连接地址与凭据。地址将自动规范化为 /v1 格式。通道保存在账号中;第一个通道也会设为本机当前通道。"})]}),m&&a.jsx("div",{"data-testid":"modal-form-error",className:"rounded bg-error/10 border border-error/20 p-2 text-xs text-error",children:m}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsxs("label",{htmlFor:s+"-name",className:"block text-xs font-medium text-text-200 mb-1",children:["通道名称 ",a.jsx("span",{className:"text-error",children:"*"})]}),a.jsx(ar,{id:s+"-name",value:i,onChange:_=>o(_.target.value),placeholder:"例如:团队主力号池、备用代理","data-testid":"input-channel-name",autoFocus:!0})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:s+"-url",className:"block text-xs font-medium text-text-200 mb-1",children:["API 地址 ",a.jsx("span",{className:"text-error",children:"*"})]}),a.jsx(ar,{id:s+"-url",value:l,onChange:_=>c(_.target.value),placeholder:"例如:https://cpa.example.com/v1","data-testid":"input-channel-url",className:"font-mono text-xs"})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:s+"-key",className:"block text-xs font-medium text-text-200 mb-1",children:["API Key ",e?a.jsx("span",{className:"text-text-400 font-normal",children:"(留空保持不变)"}):a.jsx("span",{className:"text-error",children:"*"})]}),a.jsx(ar,{type:"password",id:s+"-key",value:u,onChange:_=>d(_.target.value),placeholder:e?`留空保持原有 Key (${e.keyMasked})`:"sk-...","data-testid":"input-channel-key",className:"font-mono text-xs"})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:s+"-remark",className:"block text-xs font-medium text-text-200 mb-1",children:["备注说明 ",a.jsx("span",{className:"text-text-400 font-normal",children:"(选填)"})]}),a.jsx(ar,{id:s+"-remark",value:h,onChange:_=>f(_.target.value),placeholder:"例如:技术部公用,月末额度重置","data-testid":"input-channel-remark"})]})]}),a.jsxs(Ja,{className:"mt-4",children:[a.jsx(ze,{type:"button",variant:"outline",size:"sm",onClick:r,disabled:v,children:"取消"}),a.jsx(ze,{type:"submit",size:"sm",disabled:v,"data-testid":"submit-channel-btn",children:v?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"size-3.5 mr-1.5 animate-spin"})," 保存中…"]}):"保存"})]})]})})})})}function _X(e){const[t,n]=p.useState(!1),[r,s]=p.useState(!1),[i,o]=p.useState(null),l=p.useRef(0),{channels:c=[],channelId:u,state:d}=e,h=u===null||u===void 0&&d==="platform",f=c.find(x=>x.id===u),m=(f==null?void 0:f.name)??(h?"平台默认":u?"订阅通道已移除,请重新选择":d==="own"?"已配置订阅":"选择订阅"),g=async()=>{if(!e.onRefreshChannels)return;const x=++l.current;s(!0),o(null);try{await e.onRefreshChannels()}catch(b){x===l.current&&o(b instanceof Error?b.message:String(b))}finally{x===l.current&&s(!1)}};return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"engine-auth-card",children:[a.jsx(Yr,{icon:a.jsx(H5,{className:"size-[18px]"}),title:"模型订阅"}),a.jsxs("div",{className:"space-y-2.5 px-5 py-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"订阅通道:"}),a.jsxs(is,{onOpenChange:x=>{x&&g()},children:[a.jsx(os,{asChild:!0,disabled:e.disabled,children:a.jsx(Dx,{disabled:e.disabled,testid:"deploy-subscription","aria-label":"选择订阅通道",label:m,needsAttention:!h&&!f&&d!=="own"})}),a.jsx(zr,{align:"start",className:"max-h-[420px] overflow-y-auto",children:r?a.jsx("div",{className:"px-2 py-1.5 text-xs text-text-400",children:"正在更新通道…"}):a.jsxs(a.Fragment,{children:[a.jsxs(Tt,{onSelect:()=>{h||e.onChange(null)},children:[a.jsx(Gt,{className:"mr-2 size-3.5 "+(h?"opacity-100":"opacity-0")}),"平台默认"]}),i?a.jsx(Tt,{onSelect:()=>void g(),children:"重试加载通道"}):c.map(x=>a.jsxs(Tt,{disabled:!x.hasKey,onSelect:()=>{x.id!==u&&e.onChange({channelId:x.id})},children:[a.jsx(Gt,{className:"mr-2 size-3.5 "+(x.id===u?"opacity-100":"opacity-0")}),a.jsx("span",{children:x.name}),x.remark&&a.jsx("span",{className:"ml-3 text-xs text-text-400",children:x.remark})]},x.id)),!i&&c.length===0&&a.jsx("div",{className:"px-2 py-1.5 text-xs text-text-400",children:"在设置 → 账号中添加订阅通道"})]})})]}),e.onAddChannel&&a.jsxs(ze,{type:"button",size:"sm",variant:"outline",disabled:e.disabled,onClick:()=>n(!0),children:[a.jsx(ms,{className:"size-3.5"}),"添加通道"]})]}),d==="partial"&&a.jsx("div",{className:"text-xs text-warning",children:"订阅凭据不完整,请选择订阅通道或平台默认后保存配置。"}),i&&a.jsx("div",{className:"text-xs text-error",children:i})]}),t&&e.onAddChannel&&a.jsx(wX,{onClose:()=>n(!1),onSave:async x=>{const b=await e.onAddChannel(x);e.onChange({channelId:b.id})}})]})}const HM=e=>!!e&&!e.error&&["main-pushed","dispatching","dispatched"].includes(e.phase)&&Date.now()-e.at<30*6e4,cn=e=>e.id??e.head;function kc(e){return e==null?void 0:e[e.length-1]}function ya(e){return e==null?void 0:e[e.length-1]}function sc(e){return(e==null?void 0:e.environment)==="production"?e.status==="completed"&&e.conclusion==="success"&&e.jobs.some(t=>t.key==="deploy"&&t.status==="done"):!!e&&e.status==="completed"&&wm.filter(t=>t!==mo||e.jobs.some(n=>n.key===mo)).every(t=>{var n;return((n=e.jobs.find(r=>r.key===t))==null?void 0:n.status)==="done"})}function sL(e){var r;const t=[...e.releases].reverse().find(s=>s.environment==="integration");if(t)return((r=e.promotions)==null?void 0:r.some(s=>s.releaseId===t.id&&s.phase==="completed"))===!0;const n=ya(e.releases);return n!==void 0&&Pu(n,e.run)&&sc(e.run)}function Ay(e){const t=[...e.releases].reverse().find(r=>r.environment==="integration")??ya(e.releases),n=kc(e.scans);return t&&n&&n.startedAt>t.at?e.releases.length:e.releases.some(r=>r.environment==="integration")?sL(e)?e.releases.length:Math.max(0,e.releases.length-1-[...e.releases].reverse().findIndex(r=>r.environment==="integration")):sL(e)?e.releases.length:Math.max(0,e.releases.length-1)}function SX(e,t){const n=kc(e.scans),r=[...e.releases].reverse().find(d=>d.environment==="integration")??ya(e.releases),s=r&&n&&n.startedAt>r.at,i=s?r:t>0?e.releases[t-1]:void 0,o=s?[]:e.releases.slice(t),l=new Set(o.map(d=>d.scanId)),c=i?e.scans.filter(d=>d.startedAt>i.at||l.has(d.id)):e.scans,u=[...o].reverse().find(d=>d.environment==="integration")??o[o.length-1];return{scans:c,releases:o,...u?{release:u}:{}}}function UM(e,t,n){if(n!==!1)return[...e].reverse().find(r=>{if(r.environment==="integration")return!1;const s=t[cn(r)];return s!=="loading"&&sc(s)})}function kX(e,t){const n=t[cn(e)];return n!==void 0&&n!=="loading"&&n.status!=="completed"}function m1(e,t){const n=kc(e);return!n||!t||n.startedAt>t.at||n.status==="scanning"?n:(e==null?void 0:e.find(r=>r.id===t.scanId))??n}function Dm(e,t){return e!==void 0&&t!==void 0&&e.startedAt<=t.at&&e.head!==void 0&&t.contentHead===e.head}function Pu(e,t){return e!==void 0&&t!==void 0&&t.headSha===e.head&&(!e.environment||!t.environment||e.environment===t.environment)&&(e.runId===void 0||e.runId===t.runId)&&(e.runAttempt===void 0||e.runAttempt===t.runAttempt)}function iL(e,t,n){var o,l;const{repo:r}=e,s=[];e.github&&e.github.status!=="authorized"&&s.push("还没关联 GitHub"),r&&!["main","integration"].includes(r.branch)&&s.push("当前分支不用于发布,请重新扫描");const i=c=>{var u,d,h;return(h=((d=(u=e.targets)==null?void 0:u.integration)==null?void 0:d.secrets)??e.secrets)==null?void 0:h.find(f=>f.env===c)};if((t==null?void 0:t.status)==="done"){s.push(...t.notes.filter(u=>u.startsWith(sce)));const c=t.manifest;for(const u of[...c.secrets,...bw(c)]){const d=u.env.filter(h=>{var f;return!((f=i(h))!=null&&f.setAt)});d.length>0&&s.push(`${d.join(" / ")} 还没填`)}for(const u of c.connectors)s.push(...f7(u));for(const u of c.packages)s.push(...p7(u))}return $b(((l=(o=e.targets)==null?void 0:o.integration)==null?void 0:l.secrets)??e.secrets)==="partial"&&s.push(wce),s.push(...CX(n)),s}function CX(e){return e?il(e.tool)?e.model?[]:[e.tool==="claude"?"还没选云上模型,在「引擎与模型」里选一个":"还没选模型,在「引擎与模型」里选一个"]:["云上只跑 Codex、pi 或 Claude,在「引擎与模型」里选一个"]:[]}const EPe={engine:"引擎",model:"模型",effort:"推理档位",size:"规格",cpu:"CPU",taskConcurrency:"任务并发"};function IPe(e,t){const n=r=>r===""?"未设置":String(r);return(D7(e,t)??[]).map(r=>`${EPe[r]}:${n(e[r])} → ${n(t[r])}`)}function NX(e){const{current:t,release:n}=e;if(!e.anchored||!n||!t)return{kind:"editing"};if(n.reconfigOf){const s=Pu(n,e.run)?e.run:void 0;if(!s||s.status!=="completed")return{kind:"applying"};if(!sc(s))return{kind:"failed"}}const r=D7(t,n.config);return r===null?{kind:"unknown"}:r.length===0?{kind:"synced"}:(n.workflowVersion??0)>=Tce?{kind:"pending",keys:r}:{kind:"needsRepublish",keys:r}}function TPe(e){switch(e.kind){case"pending":return"配置改过了,先「应用到测试环境」并确认再上线";case"needsRepublish":return"配置改过了,要先重新发一次测试环境(旧仓库不能只应用配置)";case"applying":return"正在把新配置应用到测试环境,等它跑完";case"failed":return"应用配置没通过,重新应用或改回原配置后再上线";default:return}}function WM(e,t){const n=e.unpublish;if(t!==void 0){const r=n&&n.runId!==t?n:void 0;return r?r.status!=="completed"?{kind:"unpublishing",runUrl:r.htmlUrl}:r.conclusion==="failure"?{kind:"failed",runUrl:r.htmlUrl}:e.online===!0?{kind:"unpublishing",runUrl:r.htmlUrl}:e.online===!1?{kind:"offline"}:{kind:"unknown"}:{kind:"unpublishing"}}return n&&n.status!=="completed"?{kind:"unpublishing",runUrl:n.htmlUrl}:e.online===!0?{kind:"online"}:e.online===!1?{kind:"offline"}:{kind:"unknown"}}function MPe(e){return e.releases.length>0&&(e.online===!0||e.unpublish!==void 0||sc(e.run))}const oL=1500,Ap=5e3,aL=e=>e instanceof Error&&e.message.startsWith("request timeout:"),Bc=e=>{var t;return((t=kc(e==null?void 0:e.scans))==null?void 0:t.status)==="scanning"},RPe=e=>{var s,i,o,l,c,u,d;if(!e)return!1;const t=(s=e.promotions)==null?void 0:s.at(-1),n=HM(t);return[(o=(i=e.targets)==null?void 0:i.integration)==null?void 0:o.run,...t?n?[(c=(l=e.targets)==null?void 0:l.production)==null?void 0:c.run]:[]:[(d=(u=e.targets)==null?void 0:u.production)==null?void 0:d.run,e.run]].some(h=>h&&h.status!=="completed")||n},PPe=(e,t)=>e!==null&&WM(e,t).kind==="unpublishing",lL=(e,t)=>{if(!e||e.personaId!==t.personaId)return t;const{repo:n,engineChannels:r,historyError:s,promotions:i,...o}=e;return{...o,...t}};function VM(e,t={}){const n=t.mode??"full",r=Un(),[s,i]=p.useState(null),[o,l]=p.useState(!0),[c,u]=p.useState(null),[d,h]=p.useState(n!=="staged"),f=p.useRef(n!=="staged"),[m,g]=p.useState(null),x=p.useCallback(se=>{f.current=se,h(se),g(null)},[]),[b,y]=p.useState(null),v=p.useRef(null),[w,_]=p.useState(!1),S=p.useRef(null),[k,C]=p.useState(null),j=p.useCallback(se=>{S.current=se,C(se)},[]),T=p.useRef(void 0),[E,I]=p.useState(void 0),R=p.useRef(e);R.current=e;const P=p.useRef(0),O=p.useRef(null),F=p.useRef(null),L=p.useRef(null);L.current=s;const U=p.useCallback(se=>{var ge,Ne,Me,Ue,ut,Ct,Nt,ne,re;if(se.personaId!==R.current)return;L.current=se,i(se);const he=S.current,me=((Ne=(ge=se.targets)==null?void 0:ge.integration)==null?void 0:Ne.run)??se.run,Te=he?(Me=me==null?void 0:me.jobs.find(Ee=>Ee.key===he.key))==null?void 0:Me.jobId:void 0;he&&he.phase!=="submitting"&&me&&(me.runId!==he.runId||me.headSha!==he.headSha||(me.runAttempt!==void 0?me.runAttempt>he.runAttempt:me.status!=="completed"||Te!==void 0&&Te!==he.jobId))&&j(null),((Ct=((ut=(Ue=se.targets)==null?void 0:Ue.integration)==null?void 0:ut.run)??se.run)==null?void 0:Ct.headSha)===v.current&&(v.current=null),_(v.current!==null),T.current!==void 0&&WM(se,T.current).kind==="offline"&&(T.current=void 0,I(void 0)),y(Bc(se)?oL:n==="local"||((Nt=S.current)==null?void 0:Nt.phase)==="submitting"?null:RPe(se)||((ne=S.current)==null?void 0:ne.phase)==="waiting"||v.current!==null||PPe(se,T.current)?Ap:null);const Ve=(re=se.promotions)==null?void 0:re.at(-1);u(Ve&&!["completed","failed"].includes(Ve.phase)&&Date.now()-Ve.at>=30*6e4?"本次上线等待已超过 30 分钟,已停止自动查询。请刷新核实原任务,或点发线上环境继续;不会直接重复发布。":null)},[j,n]),B=p.useCallback(async(se,he=!1)=>{if(!e)return;const me=F.current;if((me==null?void 0:me.personaId)===e&&me.client===r)return!he&&(me.kind==="full"||se==="local")?me.promise:(he&&++P.current,await me.promise,e!==R.current?void 0:B(se));const Te=++P.current;let Ve=!1;const ge=(async()=>{try{const Me=new Wt(r);if(se==="full"){const Ue=await Me.deployGet(e);Te===P.current&&e===R.current&&(U(Ue),x(!0))}else{const Ue=await Me.deployGetLocal(e);if(Te===P.current&&e===R.current){const ut=lL(L.current,Ue);Ve=n!=="local"&&Bc(L.current)&&!Bc(ut),U(ut)}}}catch(Me){if(Te===P.current&&e===R.current){const Ue=Me instanceof Error?Me.message:String(Me);u(Ue),se==="full"&&!f.current&&g(Ue)}}finally{Te===P.current&&e===R.current&&l(!1)}})(),Ne={personaId:e,client:r,kind:se,promise:ge};F.current=Ne;try{await ge}finally{F.current===Ne&&(F.current=null)}Ve&&e===R.current&&B("full")},[r,e,U,n,x]),D=p.useCallback((se=!1)=>B(n==="local"?"local":"full",se),[B,n]),M=p.useCallback(()=>{f.current||B("full",!0)},[B]);p.useEffect(()=>{if(i(null),l(!0),v.current=null,_(!1),j(null),O.current=null,T.current=void 0,I(void 0),L.current=null,x(n!=="staged"),n!=="staged"){D();return}(async()=>{var se;await B("local"),e===R.current&&((se=L.current)==null?void 0:se.personaId)===e&&!Bc(L.current)&&await B("full")})()},[D,B,j,n,e,x]),p.useEffect(()=>{if(b===null)return;const se=Date.now(),he=setInterval(()=>{var me;if(Date.now()-se>=30*6e4){y(null),((me=S.current)==null?void 0:me.phase)==="waiting"&&j({...S.current,phase:"unknown",error:"等待已超过 30 分钟,已停止自动查询。请刷新状态核实这次重试。"}),u("等待已超过 30 分钟,已停止自动查询。请刷新核实原任务。");return}B(n==="local"||Bc(L.current)?"local":"full")},b);return()=>clearInterval(he)},[b,B,j,n]);const V=p.useCallback(se=>{se.personaId===R.current&&(++P.current,l(!1),U(se))},[U]),z=p.useCallback(async se=>{if(!e)return;const he=await new Wt(r).deployScan(e,se);V(lL(L.current,he)),Bc(L.current)||M()},[r,e,V,M]),$=p.useCallback(async(se,he)=>{var Te;if(!e)return;const{scans:me}=await new Wt(r).deployPatch(e,se,he);e===R.current&&(++P.current,i(Ve=>(Ve==null?void 0:Ve.personaId)===e?{...Ve,scans:me}:Ve),e===R.current&&((Te=kc(me))==null?void 0:Te.status)==="scanning"?y(oL):M())},[r,e,M]),q=p.useCallback(async(se,he)=>{if(he!==R.current)return;if(!se.secrets){await D(!0);return}const{environment:me,secrets:Te,engineChannels:Ve}=se;++P.current,i(ge=>(ge==null?void 0:ge.personaId)!==he?ge:{...ge,...ge.targets?{targets:{...ge.targets,[me]:{...ge.targets[me],secrets:Te}}}:{},...me==="production"||!ge.targets?{secrets:Te}:{},...Ve?{engineChannels:Ve}:{}}),Bc(L.current)||M()},[D,M]),X=p.useCallback(async(se,he,me,Te="integration")=>{e&&await q(await new Wt(r).deployPutSecret(e,se,he,me,Te),e)},[r,e,q]),G=p.useCallback(async(se,he="integration")=>{var Te;if(!e)return;let me;try{me=await new Wt(r).deploySetEngineAuth(e,se,he)}catch(Ve){throw await D(!0),Ve}if(!((Te=L.current)!=null&&Te.repo)){await D(!0);return}await q(me,e)},[r,e,q,D]),te=p.useCallback(async se=>{if(!e)throw new Error("没有 persona");const he=await new Wt(r).deployRelease(e,se);return e!==R.current||(v.current=he.sha,T.current=void 0,I(void 0),await D(!0)),he},[r,e,D]),ae=p.useCallback(async se=>{if(!e)throw new Error("没有 persona");try{await new Wt(r).deployApplyConfig(e,se)}catch(he){if(!aL(he))throw he}e===R.current&&(y(Ap),await D(!0))},[r,e,D]),Z=p.useCallback(async se=>{var Ve,ge;if(!e||S.current&&S.current.phase!=="failed")return;const he=((ge=(Ve=s==null?void 0:s.targets)==null?void 0:Ve.integration)==null?void 0:ge.run)??(s==null?void 0:s.run),me=he==null?void 0:he.jobs.find(Ne=>Ne.jobId===se);if(!he||!me)throw new Error("这一步的状态已经改变,请刷新后重试");const Te={runId:he.runId,runAttempt:he.runAttempt??1,headSha:he.headSha,key:me.key,jobId:se,phase:"submitting"};++P.current,j(Te),y(null);try{const Ne=await new Wt(r).deployRerunJob(e,se,"integration");if(e!==R.current||S.current!==Te)return;j({...Te,phase:"waiting"}),V(Ne)}catch(Ne){throw e===R.current&&S.current===Te&&j({...Te,phase:"failed",error:Ne instanceof Error?Ne.message:String(Ne)}),Ne}},[r,e,s,V,j]),J=p.useCallback(async()=>{if(!e)return;const{before:se}=await new Wt(r).deployUnpublish(e);e===R.current&&(T.current=se,I(se),y(Ap),await D(!0))},[r,e,D]),be=p.useCallback(async se=>{e&&(await new Wt(r).deployConfirmTest(e,se),await D(!0))},[r,e,D]),oe=p.useCallback(async se=>{if(!e||O.current)return;const he={personaId:e};O.current=he,++P.current;try{const{promotion:me}=await new Wt(r).deployPromote(e,se);if(e!==R.current||O.current!==he)return;++P.current,i(Te=>(Te==null?void 0:Te.personaId)===e?{...Te,promotions:[...(Te.promotions??[]).filter(Ve=>Ve.id!==me.id),me]}:Te),y(HM(me)?Ap:null),D(!0)}catch(me){if(!aL(me))throw me;if(e!==R.current||O.current!==he)return;++P.current,y(Ap),D(!0)}finally{O.current===he&&(O.current=null)}},[r,e,D]),ce=p.useCallback(async se=>{if(!e)throw new Error("没有 persona");return new Wt(r).deployOpenTest(e,se)},[r,e]);return{state:s,remoteReady:d,remoteError:m,loading:o,error:c,confirmTest:be,promote:oe,openTest:ce,refresh:D,awaitingRun:w,retry:k,scan:z,patch:$,putSecret:X,setEngineAuth:G,release:te,rerunJob:Z,applyConfig:ae,unpublishFrom:E,unpublish:J}}const DPe=2e3,OPe=()=>{var t;if(typeof window>"u")return;const e=(t=window.location)==null?void 0:t.href;return e&&/^https?:\/\//.test(e)?e:void 0};function jX(){const e=Un(),[t,n]=p.useState(null),[r,s]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(f=>{n(f),o(null)},[]),c=p.useCallback(async()=>{try{l(await new Wt(e).githubAuthGet())}catch(f){o(f instanceof Error?f.message:String(f))}finally{s(!1)}},[e,l]);p.useEffect(()=>{c()},[c]);const u=(t==null?void 0:t.status)==="pending";p.useEffect(()=>{if(!u)return;const f=setInterval(()=>void c(),DPe);return()=>clearInterval(f)},[u,c]);const d=p.useCallback(async()=>{const f=await new Wt(e).githubAuthOauthStart(OPe());return l(f),f.status==="pending"?f.authUrl:void 0},[e,l]),h=p.useCallback(async f=>{l(await new Wt(e).githubAuthAuthorize(f))},[e,l]);return{status:t,loading:r,error:i,refresh:c,startOauth:d,authorize:h}}function APe(e,t){const[n,r]=p.useState(null);return p.useEffect(()=>{if(r(null),!t||!il(t))return;let s=!0;return e.engineStatus(t).then(i=>{s&&r(i.installed&&i.version?i.version:null)},()=>{s&&r(null)}),()=>{s=!1}},[e,t]),n}function $Pe(e,t={}){return{models:e,loading:!1,error:null,load:()=>{},...t}}const LPe=e=>e instanceof Error?e.message:String(e);function EX(e,t){const[n,r]=p.useState({key:e,loading:!1,error:null,data:t}),s=p.useRef(0),i=p.useCallback((l,c)=>{const u=++s.current;r(d=>({key:e,loading:!0,error:null,data:d.key===e?d.data:t})),l().then(d=>{s.current===u&&(c==null||c(d),r({key:e,loading:!1,error:null,data:d}))},d=>{s.current===u&&r(h=>({key:e,loading:!1,error:LPe(d),data:h.key===e?h.data:t}))})},[e]);return{...n.key===e?n:{loading:!1,error:null,data:t},run:i}}const IX=[];function _h(e){const t=Un(),n=p.useMemo(()=>new Wt(t),[t]),r=zs(),{capabilities:s}=ni(e),i=EX(e??"",null),{run:o}=i,l=p.useCallback(()=>{e&&o(()=>n.capabilitiesGet(e,{refresh:!0}),c=>{c&&r.setData(`capabilities/${e}`,()=>c)})},[n,r,e,o]);return{models:(s==null?void 0:s.models)??IX,loading:i.loading,error:i.error,load:l}}function BPe(e,t){const n=t?`${t.channelId??""}:${t.updatedAt??""}`:"",r=EX(n,IX),{run:s}=r,i=p.useRef(t);i.current=t;const o=p.useCallback(()=>{const l=i.current;l&&s(async()=>(await e.subscriptionChannelModels(l)).models.map(u=>({id:u.id,label:u.id,contextWindowSize:0,...u.ownedBy?{description:u.ownedBy}:{}})))},[e,s]);return{models:r.data,loading:r.loading,error:r.error,load:o}}const cL={done:{cls:"bg-success-dim text-success",icon:()=>a.jsx(Gt,{className:"size-4",strokeWidth:3})},running:{cls:"bg-accent-dim text-accent",icon:()=>a.jsx(st,{className:"size-4 animate-spin"})},failed:{cls:"bg-error text-white",icon:()=>a.jsx(Yt,{className:"size-4",strokeWidth:3})},waiting:{cls:"bg-warning-dim text-warning",icon:()=>a.jsx(F5,{className:"size-4"})},skipped:{cls:"bg-text-400/15 text-text-500",icon:()=>a.jsx(yfe,{className:"size-4"})},pending:{cls:"bg-text-400/15 text-text-400",icon:e=>a.jsx("span",{className:"text-xs font-medium tabular-nums",children:e+1})}},FPe={done:"text-text-100",running:"text-accent",failed:"text-error",waiting:"text-warning",skipped:"text-text-500",pending:"text-text-400"},zPe={done:"bg-success/40",running:"bg-accent/50",failed:"bg-error/60",waiting:"bg-warning/50",skipped:"bg-border",pending:"bg-border"},HPe={done:"已完成",running:"进行中",failed:"失败",waiting:"等待中",skipped:"已跳过",pending:"未开始"},UPe={done:"bg-success-dim text-success",running:"bg-accent-dim text-accent",failed:"bg-error-dim text-error",waiting:"bg-warning-dim text-warning",skipped:"bg-text-100-dim text-text-500",pending:"bg-text-100-dim text-text-400"};function g1(e){var n;const t=(...r)=>e.find(s=>r.includes(s.status));return(n=t("failed")??t("running")??t("waiting")??t("pending")??e[e.length-1])==null?void 0:n.key}function WPe(e){var n;const t=(...r)=>e.find(s=>r.includes(s.status));return(n=t("failed")??t("running")??t("waiting"))==null?void 0:n.key}function TX(e){const[t,n]=p.useState(null),r=e.activeKey??t??g1(e.stages),s=e.stages.find(i=>i.key===r)??e.stages[0];return a.jsxs("div",{className:"@container space-y-4",children:[a.jsx("div",{className:"overflow-x-auto pb-2",role:"region","aria-label":"发布进度",tabIndex:0,children:a.jsx("div",{className:"flex min-w-max items-start",children:e.stages.map((i,o)=>a.jsxs("div",{className:"relative min-w-[88px] flex-1",children:[o<e.stages.length-1&&a.jsx("div",{"aria-hidden":"true",className:`absolute left-[calc(50%+18px)] top-5 h-px w-[calc(100%-36px)] ${zPe[e.stages[o+1].status]}`}),a.jsxs("div",{className:"relative flex flex-col items-center",children:[a.jsxs("button",{onClick:()=>{var l;n(i.key),(l=e.onPick)==null||l.call(e,i.key)},"aria-current":i.key===r,"aria-label":i.label,"data-status":i.status,className:`flex w-full cursor-pointer flex-col items-center gap-2 rounded-lg border px-1 py-1.5 transition-colors ${i.key===r?"border-border bg-surface-page":"border-transparent hover:bg-text-100-dim/60"}`,children:[a.jsx("span",{className:`flex size-7 shrink-0 items-center justify-center rounded-full ${cL[i.status].cls} ${i.next&&i.status==="pending"?"ring-2 ring-accent/60 ring-offset-2 ring-offset-surface-card":""}`,children:cL[i.status].icon(o)}),a.jsx("span",{className:`whitespace-nowrap text-[12px] ${i.next&&i.status==="pending"?"text-accent":FPe[i.status]} ${i.key===r?"font-semibold":"font-medium"}`,children:i.label})]}),i.onRetry&&a.jsx("button",{onClick:i.onRetry,title:i.status==="failed"?"原样重跑这一段":"用最新流水线重新构建,后面的步骤会重新跑","aria-label":i.status==="failed"?`原样重跑「${i.label}」`:"重新构建并重跑后面的步骤",className:"mt-1 flex size-6 cursor-pointer items-center justify-center rounded-full text-text-400 transition-colors hover:bg-error-dim hover:text-error",children:a.jsx(wf,{className:"size-3.5"})})]})]},i.key))})}),s&&a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-page",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-border-card px-4 py-2.5",children:[a.jsx("span",{className:`rounded-full px-2 py-0.5 text-[11px] font-medium ${UPe[s.status]}`,children:HPe[s.status]}),a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:s.label}),s.meta&&a.jsx("span",{className:"ml-auto font-mono text-[11px] text-text-400",children:s.meta})]}),a.jsx("div",{className:"px-4 py-3 text-[13px] leading-relaxed text-text-200",children:s.detail??a.jsx("span",{className:"text-text-400",children:"这一段还没有可说的。"})})]})]})}function C_(e,t){return`${e.replace(/\/+$/,"")}/p/${t}/v1`}function VPe(e,t){return`${C_(e,t)}/chat/completions`}function qPe(e,t){return`${C_(e,t)}/tasks`}function yE(e){const t=e.entry==="task"?qPe(e.gatewayUrl,e.personaId):VPe(e.gatewayUrl,e.personaId),n=["# model:将 <model-id> 替换为该 persona 引擎可用的模型;Pi 可用 provider/model。","# 每轮单独选择模型;删除 model 字段使用发布默认模型,不沿用上一轮覆盖。",`curl ${t} \\`,` -H 'authorization: Bearer ${e.apiKey}' \\`," -H 'content-type: application/json' \\"," -d '{",' "model": "<model-id>",',` "messages": [{ "role": "user", "content": ${JSON.stringify(e.prompt)} }]`," }'"];return e.entry==="task"?n.join(`
914
914
  `):[...n,"","# 续聊:把上一条响应的 clawd.podId 和 clawd.threadId 填进下面两个请求头",`curl ${t} \\`,` -H 'authorization: Bearer ${e.apiKey}' \\`," -H 'content-type: application/json' \\"," -H 'X-Clawd-Pod: <podId>' \\"," -H 'X-Clawd-Thread: <threadId>' \\"," -d '{",' "model": "<model-id>",',' "messages": [{ "role": "user", "content": "继续" }]'," }'"].join(`
915
- `)}function KPe(e){const t=e.prompt??"hello";if(!e.gatewayUrl)return a.jsxs(yC,{children:["中心还没配调用地址(",a.jsx("code",{className:"font-mono",children:"PERSONA_CLOUD_GATEWAY_URL"}),"), 这里就给不出能跑的命令。persona 已经在云上了,派活不受影响。"]});if(e.apiKey===void 0)return a.jsx(yC,{children:"正在读你的调用 key…"});if(e.apiKey===null)return a.jsxs(yC,{children:["你还没有调用 key。去",e.onOpenSettings?a.jsx("button",{onClick:e.onOpenSettings,className:"mx-1 cursor-pointer text-accent hover:underline",children:"设置 → 账号"}):a.jsx("span",{className:"mx-1",children:"设置 → 账号"}),"生成一把,这里就会给出填好的命令。"]});const{gatewayUrl:n,apiKey:r,personaId:s}=e,i=C_(n,s),o=l=>yE({gatewayUrl:n,personaId:s,apiKey:r,prompt:t,entry:l});return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-text-400",children:"base_url"}),a.jsx("code",{className:"min-w-0 truncate font-mono text-text-200",children:i}),a.jsx(MX,{text:i,label:"复制"})]}),a.jsx(x1,{label:"chat curl",curl:o("chat")}),a.jsx(x1,{label:"task curl",curl:o("task")})]})}function x1(e){return a.jsxs("div",{className:"space-y-1 text-xs",children:[a.jsx("span",{className:"text-text-400",children:e.label}),a.jsxs("div",{className:"relative rounded-md border border-border bg-surface-page",children:[a.jsx("pre",{"data-testid":e.testId,className:"overflow-x-auto px-3 py-2.5 pr-24 font-mono text-[11px] leading-relaxed text-text-200",children:e.curl}),a.jsx("div",{className:"absolute right-2 top-2",children:a.jsx(MX,{text:e.curl,label:"复制 curl"})})]})]})}function yC(e){return a.jsx("div",{className:"text-[13px] leading-relaxed text-text-400",children:e.children})}function MX(e){const[t,n]=p.useState(!1),r=async()=>{try{await navigator.clipboard.writeText(e.text),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return a.jsxs("button",{onClick:()=>void r(),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-surface-card px-2 py-1 text-[11px] font-medium text-text-300 transition-colors hover:border-accent/50 hover:text-accent",children:[t?a.jsx(Gt,{className:"size-3 text-success"}):a.jsx(pa,{className:"size-3"}),t?"已复制":e.label]})}const GPe={build:"构建镜像",smoke:"云上试跑",deploy:"登记上线",[mo]:"自动验证"};function Ti(e){return a.jsxs("a",{href:e.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-[13px] text-accent hover:underline",children:[e.children,a.jsx(Lr,{className:"size-3"})]})}function YPe(e){return a.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-[13px]",children:e.rows.map(([t,n])=>a.jsxs("div",{className:"contents",children:[a.jsx("dt",{className:"text-text-400",children:t}),a.jsx("dd",{className:"min-w-0 truncate font-mono text-[12px] text-text-200",children:n})]},t))})}function v1(e){return a.jsx("div",{className:"text-xs text-text-400",children:e.children})}function y1(e,t){if(e===void 0||t===void 0)return;const n=Math.round((t-e)/1e3);if(!(n<0))return n<60?`${n}s`:`${Math.floor(n/60)}m${String(n%60).padStart(2,"0")}s`}function XPe(e){if(e.status!=="pending")return e.status==="waiting"?"等审批":e.status==="running"&&e.startedAt!==void 0?"进行中":y1(e.startedAt,e.completedAt)}function bC(e){return a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{children:"前面那一段挂了,这一段没有跑。云上跑的还是上一版。"}),a.jsxs("div",{className:"text-text-400",children:["修好重发之后,它会:",e.children]})]})}function wC(e){return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:e.what}),a.jsx(v1,{children:e.impact}),e.url&&a.jsx(Ti,{href:e.url,children:"看这一段的完整日志"})]})}function ZPe(e,t){const n=t.url,r=n?a.jsx(Ti,{href:n,children:t.status==="running"?"看实时日志":"看这一段的日志"}):null;if(e==="build")switch(t.status){case"pending":return a.jsx("div",{children:"会在 runner 上按清单把要装的东西装进底座镜像,构出一层 persona 镜像推到 ACR。镜像 tag 带 commit sha,不可变。"});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"正在按清单装东西,然后构镜像。"}),r]});case"done":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"镜像构出来了,清单里要装的都在、都报得出版本,persona 目录也在。已经推到 ACR。"}),r]});case"failed":return a.jsx(wC,{what:"构镜像这一步挂了。",url:n,impact:"云上跑的还是上一版,没被动过"});default:return a.jsx(bC,{children:"按清单装好东西、构出 persona 镜像推到 ACR。"})}if(e==="smoke")switch(t.status){case"pending":return a.jsxs("div",{children:["会拿刚构出来的镜像在集群上",a.jsx("b",{children:"临时登记一次"}),"、真起一个 Pod、投一句「只回复 ok」,验的是拉得到镜像、容器起得来、卷挂得上、codex 回得了话。验完就撤销。"]});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"临时登记好了,在等集群拉镜像、起 Pod。第一次拉几百 MB 的镜像会慢一些。"}),r]});case"done":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"集群拉到了镜像、容器起来了、codex 回了话。临时登记已经撤销,没有残留。"}),r]});case"failed":return a.jsx(wC,{what:"镜像在集群上没跑起来,或者跑起来了但没回话。",url:n,impact:"镜像构出来了,但没敢登记;云上跑的还是上一版"});default:return a.jsx(bC,{children:"拿新构出来的镜像在集群上临时起一次,验拉得到、起得来、回得了话。"})}switch(t.status){case"pending":return a.jsxs("div",{children:["会把这份镜像在 gateway 上登记成",a.jsx("b",{children:"正式"}),"。从这一刻起,别人派活过来起的就是这一版。同一台 gateway 上挂着别的 persona 不受影响,重新登记只覆盖自己那一行。"]});case"waiting":return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:["仓库给 ",a.jsx("code",{className:"font-mono",children:"production"})," 环境配了审核人,这一步停在这里等人点。批了才会登记成正式,云上现在跑的还是上一版。"]}),n&&a.jsx(Ti,{href:n,children:"去 GitHub 批准"})]});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"正在往 gateway 写这一版的登记(镜像地址 + 部署者提供的那几条凭据)。"}),r]});case"failed":return a.jsx(wC,{what:"gateway 没收下这次登记。",url:n,impact:"云上跑的还是上一版,没被动过"});case"done":return null;default:return a.jsx(bC,{children:"把这份镜像在 gateway 上登记成正式,别人派活过来就起这一版。"})}}function QPe(e,t,n){const r=n?"后来下线了,现在线上没有它。":t?"现在线上跑的就是它。":"后来被更新的发布覆盖了,线上跑的是标「线上」那条。";return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:["这一版在 gateway 上登记成了正式。",r]}),e.url&&a.jsx(Ti,{href:e.url,children:"看这一段的日志"})]})}const JPe=(e,t)=>()=>e(t);function En(e){return a.jsx("div",{className:"space-y-3",children:e.children})}function eDe(e){const t={key:"scan",label:"扫描"},{latest:n}=e;if(e.frozen){if(!n)return{...t,status:"done",meta:"记录已丢",detail:a.jsx("div",{children:"这次发布对应的扫描记录找不到了(可能是旧版 clawd 留下的)。"})};const s=y1(n.startedAt,n.finishedAt);return{...t,status:"done",...s?{meta:s}:{},detail:a.jsx("div",{children:"清单是这次扫描的,在下面的卡片里。"})}}if(e.starting)return{...t,status:"running",meta:"进行中",detail:a.jsxs(En,{children:[a.jsx("div",{children:e.repo?"正在把 persona 目录落存、起管家会话…":"正在建仓库、把 persona 提交进去、起管家会话…"}),e.actions]})};if(!n)return{...t,status:"pending",detail:a.jsxs(En,{children:[a.jsx("div",{children:"还没扫过。扫描会把 persona 整个读一遍,列出它挪到云上要预备什么:镜像里要装的东西、要连的连接器、要填的凭据。"}),e.actions]})};if(n.status==="scanning")return{...t,status:"running",meta:"进行中",detail:a.jsxs(En,{children:[a.jsx("div",{children:"管家在读 persona,清单在下面一条条长出来。右上角「管家分析中」能看它读了什么。"}),e.actions]})};if(n.status==="failed")return{...t,status:"failed",detail:a.jsxs(En,{children:[a.jsx("div",{children:n.error??"扫描没跑完。"}),a.jsx(v1,{children:"云上跑的还是上一版,没被动过。"}),e.actions]}),...e.onRescan?{onRetry:e.onRescan}:{}};const r=y1(n.startedAt,n.finishedAt);return ww(n,e.repo,e.lastRelease)?!e.anchored&&e.blockers.length>0?{...t,status:"waiting",meta:"等你处理",detail:a.jsxs(En,{children:[a.jsxs("div",{children:["扫完了,还差 ",a.jsxs("span",{className:"font-medium text-warning",children:[e.blockers.length," 项必填"]}),",填好就能发布。"]}),e.actions]})}:{...t,status:"done",...r?{meta:r}:{},detail:a.jsxs(En,{children:[a.jsx("div",{children:"清单是这一版扫的,在下面的卡片里。"}),e.actions]})}:{...t,status:"waiting",meta:"已过时",detail:a.jsxs(En,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-warning",children:"有未提交的改动"}),",最新这份清单是改动前扫的。要上云的话重新扫一遍。"]}),e.actions]})}}function _C(e){return a.jsx("ul",{className:"list-disc space-y-0.5 pl-5",children:e.lines.map(t=>a.jsx("li",{children:t},t))})}function tDe(e){const t={key:"config",label:"配置"},n=e.current&&e.tested?IPe(e.tested,e.current):[],r=e.runUrl?a.jsx(Ti,{href:e.runUrl,children:"在 GitHub 看应用配置的流水线"}):null;switch(e.phase.kind){case"editing":return e.blocker&&e.scanDone?{...t,status:"waiting",meta:"等你处理",detail:a.jsxs(En,{children:[a.jsx("div",{className:"text-warning",children:e.blocker}),e.actions]})}:{...t,status:e.scanDone?"done":"pending",detail:a.jsxs(En,{children:[a.jsx("div",{children:"引擎、模型和资源在下面定,随下一次「发测试环境」一起生效。发测试环境之后再改它们,不用重新扫描。"}),e.actions]})};case"synced":return{...t,status:"done",meta:"与测试一致",detail:a.jsxs(En,{children:[a.jsx("div",{children:"测试环境用的就是当前配置。之后改了引擎、模型或资源,回到这里「应用到测试环境」就行,不用重新扫描、重新构建。"}),e.actions]})};case"pending":return{...t,status:"waiting",meta:`改了 ${e.phase.keys.length} 项`,detail:a.jsxs(En,{children:[a.jsx("div",{children:"测试环境还是旧配置,已改:"}),a.jsx(_C,{lines:n}),a.jsx(v1,{children:"只重新登记并验证,不重新构建,几分钟;线上不受影响。应用并确认之前不能上线。"}),e.actions]})};case"needsRepublish":return{...t,status:"waiting",meta:"需重发",detail:a.jsxs(En,{children:[a.jsx("div",{children:"配置改了:"}),a.jsx(_C,{lines:n}),a.jsx("div",{children:"但这个仓库的发布流水线是旧版本,不认单独应用的配置。重新扫描、再发一次测试环境(会重新构建),之后就能直接应用配置了。"}),e.actions]})};case"applying":return{...t,status:"running",meta:"应用中",detail:a.jsxs(En,{children:[a.jsx("div",{children:"正在把新配置登记到测试环境,并重新验证真实对话(不重新构建)。"}),n.length>0&&a.jsx(_C,{lines:n}),r,e.actions]})};case"failed":return{...t,status:"failed",meta:"没通过",detail:a.jsxs(En,{children:[a.jsx("div",{className:"text-error",children:"应用配置没通过。"}),a.jsx(v1,{children:"测试环境里可能已经是新配置但没验证过,线上没有被动过。看日志找原因,改好配置后重新应用。"}),r,e.actions]})};case"unknown":return{...t,status:"done",meta:"无法比较",detail:a.jsxs(En,{children:[a.jsx("div",{children:"读不到测试环境当时用的配置,没法比较有没有改过。"}),e.actions]})}}}function nDe(e){const t={key:"push",label:"推送"};if(e.releasing)return{...t,status:"running",meta:"进行中",detail:a.jsxs(En,{children:[a.jsxs("div",{children:["正在把这次扫描的清单写进仓库、提交并推送到 ",a.jsx("code",{className:"font-mono",children:e.environment??"main"}),"…"]}),e.actions]})};if(!e.anchored||!e.released)return{...t,status:"pending",detail:a.jsx(En,{children:e.actions})};const n=e.released.head.slice(0,7);return{...t,status:"done",meta:n,detail:a.jsxs(En,{children:[e.run?a.jsxs(a.Fragment,{children:[e.released.reconfigOf?a.jsx("div",{children:"这一轮最近一次是「应用配置」:没有新的提交,复用上一次测试验证过的镜像,只换了配置。"}):a.jsxs("div",{children:["persona 目录和这次扫描的清单一起提交并推到了 ",a.jsx("code",{className:"font-mono",children:e.environment??"main"}),",下面这条流水线由这次推送触发。"]}),a.jsx(YPe,{rows:[["提交",n],["流水线",`#${e.run.runId}`]]}),a.jsx(Ti,{href:e.run.htmlUrl,children:"在 GitHub 看这次流水线"})]}):e.awaitingRun?a.jsx("div",{children:"提交推上去了,GitHub 那边还没把这次流水线列出来。通常几秒。"}):a.jsx("div",{children:"提交推上去了,但 GitHub 上没列出这一版的流水线:查不到 GitHub(没网 / 授权失效)、仓库的 Actions 没开、或者这条 run 已经被 GitHub 清掉了。刷新看看,或者去 GitHub 看。"}),e.actions]})}}const rDe={deploy:"应用配置后,会把新配置重新发到测试环境。",[mo]:"发到测试环境后,流水线会重新验证真实对话。",production:"新配置在测试环境验证通过后才能上线。"};function sDe(e,t){const n=t.kind;if(n!=="pending"&&n!=="applying"&&n!=="failed"&&n!=="needsRepublish")return;const r=d=>{d.status="pending",delete d.meta,delete d.onRetry,delete d.next;const h=rDe[d.key];h?d.detail=a.jsx("div",{children:h}):delete d.detail},s=e.findIndex(d=>d.key==="config");if(s<0)return;if(n==="needsRepublish"){for(const d of e.slice(s+1))r(d);return}const i=e.find(d=>d.key==="build"),o=e[s],l=e.filter(d=>d.key!=="scan"&&d.key!=="config"&&d.key!=="push"&&d.key!=="smoke"&&d.key!=="build"),c=i?[i.status!=="done"?i:{...i,status:"done",meta:"复用上次镜像",detail:a.jsx("div",{children:"只应用配置,不重新构建:用的是上一次测试验证过的镜像。"})}]:[];if(n==="pending")for(const d of l)r(d);else(n==="applying"||l.some(d=>d.status==="failed"))&&(o.status="done",o.meta="已提交");const u=l.findIndex(d=>d.status==="failed");if(u>=0)for(const d of l.slice(u+1))r(d);e.splice(0,e.length,e[0],...c,o,...l)}function RX(e){var y,v,w,_;const t=!!e.frozen,{released:n}=e,r=m1(e.scans,n),s=!!e.releasing&&!t,i=!!e.awaitingRun&&!t,o=t?n!==void 0:Dm(r,n),l=o&&!s&&Pu(n,e.run)?e.run:void 0,c=!t&&o&&e.retry&&e.retry.headSha===(n==null?void 0:n.head)&&(!e.run||e.run.runId===e.retry.runId)?e.retry:void 0,u=c?wm.indexOf(c.key):-1,d=[eDe({...r?{latest:r}:{},...e.repo?{repo:e.repo}:{},...e.lastRelease??n?{lastRelease:e.lastRelease??n}:{},blockers:e.blockers,starting:!!e.starting&&!t,anchored:o,frozen:t,...e.scanActions!==void 0&&!t?{actions:e.scanActions}:{},...e.onRescan&&!t?{onRescan:e.onRescan}:{}}),...e.config?[tDe({phase:e.config.phase,...e.config.current?{current:e.config.current}:{},...e.config.tested?{tested:e.config.tested}:{},...e.config.blocker?{blocker:e.config.blocker}:{},scanDone:!!r&&r.status==="done"&&ww(r,e.repo,e.lastRelease??n),...l!=null&&l.htmlUrl?{runUrl:l.htmlUrl}:{},...e.config.actions!==void 0?{actions:e.config.actions}:{}})]:[],nDe({...e.flow?{environment:"integration"}:{},...n?{released:n}:{},...l?{run:l}:{},releasing:s,anchored:o,awaitingRun:i,...e.releaseActions!==void 0?{actions:e.releaseActions}:{}})],h=!s&&o&&(l?l.status!=="completed":i),f=new Map((l==null?void 0:l.jobs.map(S=>[S.key,S]))??[]),m=!!e.flow&&(l==null?void 0:l.status)==="completed"&&!e.flow.confirmed&&!(n!=null&&n.reconfigOf);let g=!0;for(const S of wm){if(S===mo&&!e.flow&&!f.has(S))continue;const k=c&&wm.indexOf(S)>u,C=(c==null?void 0:c.key)===S,j=k?void 0:f.get(S),T=!c&&!j&&h&&g,E=!c&&h&&g&&((j==null?void 0:j.status)==="pending"||T&&(l==null?void 0:l.status)==="queued"),I=k?{status:"pending"}:C?{jobId:c.jobId,status:c.phase==="submitting"?"running":c.phase==="failed"?"failed":"waiting"}:j??{status:"pending"};g=g&&I.status==="done";const R=C?S==="build"?"等待构建开始":"等待这一步开始":"等待开始",P=C?c.phase==="submitting"?"正在重试":c.phase==="failed"?"重试请求失败":c.phase==="unknown"?"状态待确认":R:E?"排队中":T?R:XPe(I),O=C?a.jsxs(En,{children:[a.jsx("div",{children:c.phase==="submitting"?"正在提交重试请求,请不要重复点击。":c.phase==="failed"?"重试请求失败,请核实原因后重试。":c.phase==="unknown"?"暂时无法确认这次重试的状态。":"重试请求已返回,正在等待新一轮的执行状态。"}),c.error&&a.jsx("div",{className:"text-error",children:c.error}),(l==null?void 0:l.htmlUrl)&&a.jsx(Ti,{href:l.htmlUrl,children:"查看这次发布"}),c.phase==="unknown"&&e.onRefreshRetry&&a.jsx("button",{className:"text-accent hover:underline",onClick:e.onRefreshRetry,children:"刷新状态"})]}):E||T?a.jsxs(En,{children:[a.jsx("div",{children:E?"GitHub 已将这一步排队,等待开始执行。":"正在等待这一步的执行状态;尚未确认开始。"}),(l==null?void 0:l.htmlUrl)&&a.jsx(Ti,{href:l.htmlUrl,children:"查看这次发布"})]}):n!=null&&n.reconfigOf&&S==="build"&&I.status==="done"?a.jsxs(En,{children:[a.jsx("div",{children:"这次只应用配置,没有重新构建:用的是上一次测试验证过的镜像。"}),I.url&&a.jsx(Ti,{href:I.url,children:"看这一段的日志"})]}):e.flow&&S==="deploy"?a.jsxs(En,{children:[a.jsx("div",{children:I.status==="done"?"已发到测试环境,流水线接着自动验证真实对话。":"这一步会把本次版本发到测试环境。"}),I.url&&a.jsx(Ti,{href:I.url,children:"查看这一步的日志"})]}):S===mo?a.jsxs(En,{children:[a.jsx("div",{children:I.status==="running"?"流水线正在用测试账号验证真实对话,收到有效回复并正常结束才算通过。":I.status==="failed"?"自动对话验证失败,线上没有改动。查看日志后重试。":(y=e.flow)!=null&&y.confirmed?"测试通过,已收到有效回复并正常结束。上线将使用同一个版本。":I.status==="done"?"正在核对验证结果和测试环境版本;版本变化时需要重新发布测试。":(l==null?void 0:l.status)==="completed"?"这次发布没有通过自动对话验证,请重新扫描并发布测试环境。":"测试环境发布后,流水线会自动验证真实对话。"}),I.url&&a.jsx(Ti,{href:I.url,children:"查看这一步的日志"}),(v=e.flow)==null?void 0:v.testActions]}):S==="deploy"&&I.status==="done"&&t?QPe(I,e.live,!!e.offline):S==="deploy"&&I.status==="done"&&e.offline?a.jsx("div",{children:"这一版登记上线过,后来下线了:gateway 上已经没有它,别人看不到、用不了。重新扫描、发布就能再上线。"}):S==="deploy"&&I.status==="done"?a.jsx(KPe,{gatewayUrl:((w=e.cloud)==null?void 0:w.gatewayUrl)??null,personaId:e.personaId,apiKey:(_=e.cloud)==null?void 0:_.apiKey,...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{}}):ZPe(S,I);d.push({key:S,label:e.flow?{build:"构建",smoke:"自动试跑",deploy:"发测试环境",[mo]:"自动验证"}[S]:GPe[S],status:E||T||S===mo&&e.flow&&!c&&!e.flow.confirmed&&(I.status==="done"||(l==null?void 0:l.status)==="completed"&&!j)?"waiting":I.status,...P?{meta:P}:{},...O?{detail:O}:{},...(I.status==="failed"||m&&S==="build"&&I.status==="done")&&I.jobId!==void 0&&e.onRetry&&!t&&(!c||c.phase==="failed")?{onRetry:JPe(e.onRetry,I.jobId)}:{}})}if(e.flow){const{confirmed:S,promotion:k,productionActions:C,submissionError:j}=e.flow,T=!!e.flow.promoting&&!t,E=T?"正在提交上线":j?"上线请求失败":void 0,I=T?"正在核对测试版本并提交上线,请不要重复点击。":j?"上线请求失败,请核实原因后再继续。":(k==null?void 0:k.phase)==="completed"?"这一版已上线。":(k==null?void 0:k.phase)==="failed"?"上线失败,请查看原因后再继续。":k!=null&&k.error?"上线已暂停,请处理下面的问题后再继续。":(k==null?void 0:k.phase)==="main-pushed"?"已推送到线上分支,正在提交上线任务。":(k==null?void 0:k.phase)==="dispatching"?"正在向 GitHub 提交上线任务。":(k==null?void 0:k.phase)==="dispatched"?"上线任务已提交,正在等待执行结果。":(k==null?void 0:k.phase)==="prepared"?"正在准备上线已测试的版本。":S?"把已测试的提交推到线上分支,上线同一个版本。":"先等待自动对话验证通过。",R=e.repo&&(k!=null&&k.runId)?`${e.repo.url.replace(/\.git$/,"")}/actions/runs/${k.runId}`:void 0;d.push({key:"production",label:"发线上环境",status:T?"running":j?"failed":(k==null?void 0:k.phase)==="completed"?"done":(k==null?void 0:k.phase)==="failed"?"failed":k!=null&&k.error?"waiting":k?"running":"pending",...E?{meta:E}:{},detail:a.jsxs(En,{children:[a.jsx("div",{children:I}),!T&&(j||(k==null?void 0:k.error))&&a.jsx("div",{className:"text-error",children:j??(k==null?void 0:k.error)}),!T&&R&&a.jsx(Ti,{href:R,children:"查看上线进度"}),C]})})}e.config&&sDe(d,e.config.phase);const b=d.some(S=>S.status==="failed"||S.status==="running"||S.status==="waiting")?void 0:d.find(S=>S.status==="pending");return b&&(b.next=!0),d}function iDe(e,t,n){if(!e)return{kind:"missing"};const r=e.indexOf(":");if(r===-1)return{kind:"raw",text:e};const s=e.slice(0,r),i=e.slice(r+1);if(!i)return{kind:"raw",text:e};switch(s){case"npm":return{kind:"known",text:`npm i -g ${i}${t?`@${t}`:""}`};case"apt":return{kind:"known",text:`apt-get install -y ${i}`};case"pip":return{kind:"known",text:`pip install ${i}${t?`==${t}`:""}`};case"github":return n?{kind:"known",text:`从 GitHub release 拉二进制 · ${n.url.split("?")[0].split("/").pop()||n.url}`}:{kind:"known",text:`从 GitHub release 拉二进制 · ${i}${t?` v${t}`:""}`};default:return{kind:"raw",text:e}}}function oDe(e,t){if(e)return`= ${e}`;if(t)return`≥ ${t}`}function aDe(e){var r;if(!((r=e.from)!=null&&r.startsWith("apt:")))return;const t=e.localVersion?`(本机 ${e.localVersion})`:"",n=Xle.label;return e.name&&a7.includes(e.name)?{tone:"info",text:`云上底座自带,不从 ${n} 装${t}`}:e.aptMissing?{tone:"error",text:`${n} 没有这个包,云上装不了${t}`}:e.aptVersion?e.version?e.localVersion&&e.localVersion!==e.version?{tone:"warn",text:`云上装 ${n} 的 ${e.version},本机 ${e.localVersion}`}:{tone:"info",text:`云上装 ${n} 的 ${e.version}`}:{tone:e.min?"error":"warn",text:`云上是 ${n} 的 ${e.aptVersion}${e.min?`,不满足要求 ≥ ${e.min}`:",没按它钉版本"}${t}`}:{tone:"warn",text:`没查到 ${n} 里的版本,云上装它自带的${t}`}}function lDe(e,t){if(!t)return{tone:"warn",text:"本机未探到"};if(e!==t)return{tone:"error",text:`本机 ${t} ≠ 云上 ${e??"—"}`}}function cDe(e){const t=iDe(e.from,e.version,e.artifact);return a.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[a.jsx("span",{className:"shrink-0 text-text-500",children:"装法:"}),t.kind==="missing"?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-warning",children:"没查到"}),a.jsx("span",{className:"text-text-500",children:"· 见存疑项"})]}):a.jsx("code",{className:"rounded-sm border border-border bg-bg-100 px-1.5 py-0.5 text-text-400",children:t.text})]})}function PX(e){const t=oDe(e.version,e.min),n=aDe(e)??lDe(e.version,e.localVersion),r=e.blockers??[];return a.jsxs("div",{className:"border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:e.name}),r.length>0&&a.jsx(Px,{}),t&&a.jsx("span",{className:"font-mono text-xs text-text-400",children:t}),n&&a.jsx("span",{className:`text-xs ${n.tone==="error"?"text-error":n.tone==="warn"?"text-warning":"text-text-400"}`,children:n.text})]}),r.map(s=>a.jsx("div",{className:"mt-1 text-xs text-error",children:s},s)),a.jsx(cDe,{from:e.from,version:e.version,artifact:e.artifact}),e.evidence&&a.jsx(LM,{evidence:e.evidence})]})}const bE={none:{label:"不用账号",hint:e=>`${e} 是公开服务,不用登录就能用`},shared:{label:"发布者的账号",hint:e=>`用户用发布者的账号使用 ${e}:发布者在这一页填好自己的 key,所有人共用这一份`},personal:{label:"用户自己的账号",hint:e=>`用户用自己的账号使用 ${e}:每个用户第一次用时自己关联一次`}},$y={oauth:{label:"OAuth",hint:e=>`用户点链接跳到 ${e} 的授权页登录,不用碰 key`},fields:{label:"粘贴 API key",hint:()=>"用户把自己的 API key 粘进表单"}},DX=e=>e.runner==="cli"?w5(e)?"CLI · Lark App Bot":e.protocol==="lark-sidecar"?"CLI · 飞书 sidecar":"CLI":e.kind==="proxy"?"http MCP":"stdio MCP",uDe=e=>e.kind==="env"||e.fields.length>0?"fields":"oauth",dDe=/^[A-Z][A-Z0-9_]*$/;function hDe(e){const t=e.connector,[n,r]=p.useState(""),[s,i]=p.useState(null),o=t.name==="feishu"&&t.runner==="cli",l=w5(t),c=o,u=f7(t),d=!t.credentialSource,h=t.credentialSource==="personal"&&!t.auth,f=u.length>0&&!d&&!h,m=t.credentialSource==="personal",g=!o&&(t.credentialSource==="shared"||t.credentialSource==="personal"&&t.auth==="fields"),x=v=>{const{publisherUnionId:w,..._}=t;e.onChange({..._,kind:v==="bot"?"env":"proxy",protocol:v==="bot"?void 0:"lark-sidecar",credentialSource:v==="user"?"personal":"shared",auth:v==="bot"?"fields":"oauth",fields:v==="bot"?[...h7]:[]})},b=v=>{e.onChange({...t,credentialSource:v,...v==="personal"&&!t.auth?{auth:uDe(t)}:{}})},y=()=>{const v=n.trim();if(!dDe.test(v)){i("变量名只能是大写字母、数字、下划线,且以字母开头");return}t.fields.includes(v)||e.onChange({...t,fields:[...t.fields,v]}),r(""),i(null)};return a.jsxs("div",{className:"border-b border-border-card px-5 py-4 last:border-b-0","data-testid":`connector-row-${t.name}`,"data-required":u.length>0||void 0,children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:t.name}),a.jsx("span",{className:"rounded-sm bg-text-100-dim px-1.5 py-px text-[11px] text-text-400",children:DX(t)}),a.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-text-500",title:t.id,children:t.id})]}),e.evidence&&a.jsx(LM,{evidence:e.evidence}),a.jsx(li,{delayDuration:120,children:a.jsxs("div",{className:"mt-3 space-y-2",children:[o?a.jsx(Om,{label:"用谁的账号",name:"feishu-source",value:l?"bot":t.credentialSource==="shared"?"publisher":"user",options:[{value:"publisher",label:"发布者账号",hint:"所有使用者共用发布者的飞书 OAuth 权限;发布者需先关联飞书账号"},{value:"user",label:"用户自己的账号",hint:"每个使用者关联自己的飞书账号,使用本人权限"},{value:"bot",label:"Lark App Bot",hint:"发布者填写 App ID 和 App Secret,所有使用者共用这个应用的机器人身份"}],onPick:x}):a.jsx(Om,{label:"用谁的账号",required:d,name:`${t.name}-source`,value:t.credentialSource,options:u7.map(v=>({value:v,label:bE[v].label,hint:bE[v].hint(t.name)})),disabled:c,onPick:v=>b(v)}),m&&a.jsx(Om,{label:"关联方式",required:h,name:`${t.name}-auth`,value:t.auth,options:y5.filter(v=>t.kind==="proxy"||v==="fields").map(v=>({value:v,label:$y[v].label,hint:t.kind==="env"?`${$y[v].hint(t.name)}。进程型(stdio MCP / CLI)没有登录页,只有这一种`:$y[v].hint(t.name)})),disabled:c,onPick:v=>e.onChange({...t,auth:v})}),g&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"要填的变量:"}),f&&a.jsx(Px,{}),t.fields.map(v=>a.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-xs text-text-200",children:[v,a.jsx("button",{type:"button","aria-label":`去掉 ${v}`,className:"text-text-400 hover:text-error",onClick:()=>e.onChange({...t,fields:t.fields.filter(w=>w!==v)}),children:a.jsx(Yt,{className:"size-3"})})]},v)),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(ar,{"aria-label":`${t.name} 新增一个变量`,className:"h-7 w-44 font-mono text-xs",placeholder:"变量名,如 GH_TOKEN",value:n,onChange:v=>r(v.target.value.toUpperCase()),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),y())}}),a.jsx("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:y,children:"添加"})]}),s&&a.jsx("span",{className:"w-full text-xs text-error",children:s}),t.fields.length===0&&a.jsx("span",{className:"w-full text-xs text-text-500",children:t.runner==="cli"?"这个工具从哪个环境变量读凭据,查清楚填这里":"扫描没在 .mcp.json 里找到 ${VAR} 占位;它要什么就填什么"})]})]})}),o&&!l&&t.credentialSource==="shared"&&a.jsxs("div",{className:"mt-3 space-y-2 text-xs text-text-300",children:[a.jsx("p",{children:"所有使用者将使用你的飞书权限。请先关联发布者账号:"}),["integration","production"].map(v=>{var S;const w=(S=e.publisherAuth)==null?void 0:S[v],_=v==="integration"?"测试环境":"线上环境";return a.jsx("div",{children:w!=null&&w.connected?a.jsxs("span",{children:[_,":已关联"]}):w!=null&&w.authUrl?a.jsxs("a",{className:"text-accent underline",href:w.authUrl,target:"_blank",rel:"noopener noreferrer",children:["关联",_,"飞书账号"]}):a.jsxs("span",{children:[_,":",(w==null?void 0:w.error)??"请刷新授权状态"]})},v)}),a.jsx("button",{type:"button",className:"text-accent underline",onClick:e.onRefreshPublisherAuth,children:"刷新授权状态"})]}),e.secretCard&&(!o||l)&&a.jsx("div",{className:"mt-3 rounded-md border border-border-card bg-bg-50",children:e.secretCard})]})}function Om(e){return a.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"radiogroup","aria-label":e.label,children:[a.jsxs("span",{className:"w-20 shrink-0 text-xs text-text-400",children:[e.label,":"]}),e.required&&a.jsx(Px,{}),e.options.map(t=>{const n=t.value===e.value,r=a.jsx("button",{type:"button",role:"radio","aria-checked":n,disabled:e.disabled,"data-testid":`${e.name}-${t.value}`,onClick:()=>e.onPick(t.value),className:Q("rounded-full border px-2.5 py-0.5 text-xs transition-colors",n?"border-accent bg-accent text-accent-contrast":"border-border text-text-300 hover:border-accent/50 hover:text-accent",e.disabled&&"cursor-default opacity-70 hover:border-border hover:text-text-300"),children:t.label});return a.jsxs(Gi,{children:[a.jsx(Yi,{asChild:!0,children:r}),a.jsx(hi,{side:"top",className:"max-w-[360px]",children:t.hint})]},t.value)})]})}const nf=e=>new Date(e).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1});function fDe(e){const t=e.manifest,n=[t.packages.length?`镜像 ${t.packages.length}`:null,t.connectors.length?`连接器 ${t.connectors.length}`:null,t.secrets.length?`凭据 ${t.secrets.length}`:null,e.notes.length?`存疑项 ${e.notes.length}`:null].filter(r=>r!==null);return n.length?n.join(" · "):e.status==="scanning"?"…":"什么都不需要"}function pDe(e){const t=e.scans.map((l,c)=>({s:l,n:c+1})).reverse(),[n,r]=p.useState(!1),s=(l,c)=>{var u;return c===e.scans.length||((u=e.released)==null?void 0:u.scanId)===l.id||l.status==="scanning"||l.id===e.selectedId},i=n?t:t.filter(({s:l,n:c})=>s(l,c)),o=t.length-i.length;return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Yr,{icon:a.jsx(q5,{className:"size-[18px]"}),title:"扫描历史",count:`${e.scans.length} 次`}),a.jsxs("ul",{className:"divide-y divide-border-card","data-testid":"scan-history",children:[i.map(({s:l,n:c})=>{var g;const u=l.id===e.selectedId,d=c===e.scans.length,h=e.online!==!1&&((g=e.released)==null?void 0:g.scanId)===l.id,f=jce(l,e.released),m=(l.head??"").slice(0,7);return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>e.onSelect(l.id),"aria-current":u,"aria-label":`第 ${c} 次扫描`,className:`flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left text-[13px] transition-colors ${u?"bg-accent-dim/60":"hover:bg-text-100-dim/40"}`,children:[a.jsxs("span",{className:"w-8 shrink-0 font-mono text-xs text-text-400",children:["#",c]}),a.jsx("span",{className:"shrink-0 tabular-nums text-text-200",children:nf(l.startedAt)}),e.repo&&f&&m?a.jsxs("a",{href:`https://github.com/${$h(e.repo.url)}/commit/${l.head}`,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-accent hover:underline",children:[m,a.jsx(Lr,{className:"size-3"})]}):a.jsx("span",{className:"shrink-0 font-mono text-xs text-text-400",title:"还没推到 GitHub,发布之后才会有",children:m||"—"}),a.jsx("span",{className:"shrink-0 rounded-full bg-text-100-dim px-1.5 py-0.5 text-[11px] text-text-400",children:l.baseKind==="soft"?"软扫":"硬扫"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-text-300",children:fDe(l)}),d&&a.jsx("span",{className:"shrink-0 rounded-full bg-accent-dim px-1.5 py-0.5 text-[11px] font-medium text-accent",children:"最新"}),h&&a.jsx("span",{className:"shrink-0 rounded-full bg-success-dim px-1.5 py-0.5 text-[11px] font-medium text-success",children:"线上"}),a.jsx(mDe,{s:l})]})},l.id)}),o>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>r(!0),className:"flex w-full cursor-pointer items-center gap-1.5 px-4 py-2 text-xs text-text-400 hover:bg-text-100-dim/40 hover:text-text-200",children:[a.jsx(Jt,{className:"size-3.5"}),"还有 ",o," 次扫描"]})})]})]})}function mDe({s:e}){return e.status==="scanning"?a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-accent",children:[a.jsx(st,{className:"size-3 animate-spin"}),"进行中"]}):e.status==="failed"?a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-error",children:[a.jsx(Yt,{className:"size-3"}),"失败"]}):a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-text-400",children:[a.jsx(Gt,{className:"size-3 text-success"}),y1(e.startedAt,e.finishedAt)??"完成"]})}const $p={tiny:{label:"微",mem:"256 MB",hint:"纯对话、查资料"},small:{label:"小",mem:"512 MB",hint:"调 MCP、读写文件"},medium:{label:"中",mem:"1 GB",hint:"跑脚本、python / jq 这类"},large:{label:"大",mem:"2 GB",hint:"装依赖、构建、开浏览器"},xlarge:{label:"超大",mem:"4 GB",hint:"较大构建、内存密集任务"}},gDe=e=>e!==void 0&&S5.includes(e);function xDe(e){const t=p.useId(),n=e.taskConcurrency,r=e.size===void 0||e.size==="",s=r?Db:e.size,i=gDe(s),o=e.cpu===void 0,l=o?i?qN[s]:void 0:e.cpu,c=l!==void 0&&Ob.includes(l),u=!!e.disabled||!!e.saving;return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"resource-estimate",children:[a.jsx(Yr,{icon:a.jsx(U5,{className:"size-[18px]"}),title:"资源预估"}),a.jsxs("div",{className:"px-5 py-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-400",children:[a.jsx("span",{children:"内存:"}),a.jsx("span",{className:"text-text-300",children:"每 Pod 的内存预留与上限"}),r&&a.jsx("span",{children:"(没选过,按默认)"})]}),a.jsx("div",{className:"mt-2.5 grid grid-cols-2 gap-2 sm:grid-cols-5",role:"radiogroup","aria-label":"内存",children:S5.map(d=>{const h=d===s;return a.jsxs("button",{type:"button",role:"radio","aria-checked":h,"aria-label":`${$p[d].label} · ${$p[d].mem}`,disabled:u||!e.onChange,onClick:()=>{var f;h||(f=e.onChange)==null||f.call(e,d)},className:Q("rounded-md border px-3 py-2.5 text-left transition-colors",h?"border-accent bg-accent-dim":"border-border-card hover:border-accent/60"),children:[a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[a.jsx("span",{className:Q("text-base font-semibold",h?"text-accent":"text-text-100"),children:$p[d].label}),a.jsx("span",{className:"font-mono text-xs text-text-300",children:$p[d].mem}),d===Db&&a.jsx("span",{className:"ml-auto text-[11px] text-text-400",children:"默认"})]}),a.jsx("div",{className:"mt-0.5 text-xs text-text-400",children:$p[d].hint})]},d)})}),!i&&a.jsxs("div",{className:"mt-2 text-xs text-warning",children:["persona.json 里写的是 ",a.jsx("code",{className:"font-mono",children:s}),",不是支持的内存档,发布会被拒;点一档换掉"]}),a.jsxs("div",{className:"mt-5 border-t border-border-card pt-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-400",children:[a.jsx("span",{children:"CPU:"}),a.jsx("span",{className:"text-text-300",children:"每 Pod 的 CPU 预留与上限"})]}),a.jsx("div",{className:"mt-2.5 grid grid-cols-3 gap-2",role:"radiogroup","aria-label":"CPU",children:Ob.map(d=>{const h=d===l;return a.jsxs("button",{type:"button",role:"radio","aria-label":`${d} 核`,"aria-checked":h,disabled:u||!e.onChangeCpu,onClick:()=>{var f;(o||!h)&&((f=e.onChangeCpu)==null||f.call(e,d))},className:Q("rounded-md border px-3 py-2.5 text-left transition-colors",h?"border-accent bg-accent-dim":"border-border-card hover:border-accent/60"),children:[a.jsx("span",{className:Q("text-base font-semibold",h?"text-accent":"text-text-100"),children:d}),a.jsx("span",{className:"ml-1.5 text-xs text-text-300",children:"核"})]},d)})}),o&&c&&a.jsxs("div",{className:"mt-2 text-xs text-text-400",children:["未单独配置,暂按内存档位取 ",l," 核;点选任意 CPU 档位后独立配置(也可点当前档位),最后统一保存。"]}),!c&&a.jsx("div",{className:"mt-2 text-xs text-warning",children:o?"内存档位未知,无法确定默认 CPU;请选择 CPU 和内存后发布。":`CPU 配置 ${String(e.cpu)} 不在支持范围内,发布会被拒;请选择一档修复。`}),a.jsx("div",{role:"status",className:"mt-2 text-xs text-text-400",children:e.saving?"正在保存资源设置…":"在上方统一保存配置,再应用或发布到云上。预留不是独占物理核心。"}),e.error&&a.jsx("div",{role:"alert",className:"mt-2 text-xs text-error",children:e.error})]}),n&&a.jsxs("div",{className:"mt-5 border-t border-border-card pt-4",children:[a.jsx("label",{htmlFor:t,className:"text-sm font-medium text-text-100",children:"单 Pod 任务并发数"}),a.jsxs("div",{id:`${t}-hint`,className:"mt-1 text-xs leading-relaxed text-text-400",children:["每个 task Pod 最多同时运行的任务数,仅影响 task 调用。默认 4,随其他配置一起保存。",n.defaulted&&a.jsx("span",{children:"(未配置,按默认)"})]}),a.jsx("div",{className:"mt-2.5 flex items-center gap-2",children:a.jsx(ar,{id:t,inputMode:"numeric",className:"w-28",value:n.value,disabled:n.disabled,"aria-describedby":`${t}-hint${n.error?` ${t}-error`:""}`,"aria-invalid":!!n.error,onChange:d=>n.onChange(d.target.value)})}),n.error&&a.jsx("div",{id:`${t}-error`,role:"alert",className:"mt-2 text-xs text-error",children:n.error})]})]})]})}function Ox(e,t,n){var i;const r=n.find(o=>o.name==="effort"),s=e?t.find(o=>o.id===e):void 0;if(s!=null&&s.efforts&&s.efforts.length>0){const o=(i=r==null?void 0:r.options)==null?void 0:i.find(c=>c.value==="none");return{options:o?[o,...s.efforts.filter(c=>c.value!=="none")]:s.efforts,defaultValue:s.defaultEffort??""}}return{options:(r==null?void 0:r.options)??[],defaultValue:typeof(r==null?void 0:r.default)=="string"?r.default:""}}function OX(e,t){var r;const n=t.options.some(s=>s.value===e)?e:t.defaultValue;return{value:n,label:((r=t.options.find(s=>s.value===n))==null?void 0:r.label)??"默认"}}function N_(e,t,n){var c;if(!t)return((c=(e??[]).find(u=>u.id===""))==null?void 0:c.label)??"未指定";const r=t.toLowerCase(),s=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[u,d]of s){if(!r.includes(u))continue;const h=r.match(new RegExp(`${u}-(\\d+)(?:-(\\d+))?`));return h?h[2]?`${d} ${h[1]}.${h[2]}`:`${d} ${h[1]}`:d}const i=e??[],o=i.find(u=>u.id===t);if(o)return o.label;const l=i.find(u=>u.id&&t.toLowerCase().includes(u.id.toLowerCase()));return l?l.label:t}function vDe(e){return e.map(t=>({value:t.id,label:t.label,...t.description?{description:t.description}:{},...t.group?{group:t.group}:{}}))}function AX({testid:e,list:t,options:n,current:r,onSelect:s}){if(t.loading)return a.jsx(Tt,{disabled:!0,"data-testid":`${e}-loading`,className:"text-[12px] text-text-400",children:"正在读取最新模型…"});if(t.error)return a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":`${e}-error`,className:"px-2 py-1.5 text-[11px] text-warning",children:t.error}),a.jsx(Tt,{"data-testid":`${e}-retry`,className:"text-[12px]",onSelect:o=>{o.preventDefault(),t.load()},children:"重试"})]});const i=n??vDe(t.models);return i.length===0?a.jsx(Tt,{disabled:!0,"data-testid":`${e}-empty`,className:"text-[12px] text-text-400",children:"没有可选模型"}):a.jsx(a.Fragment,{children:zM(i).map((o,l)=>{const c=o.value===r;return a.jsxs(K.Fragment,{children:[o.groupHeading?a.jsxs(a.Fragment,{children:[l>0?a.jsx(da,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:o.groupHeading})]}):null,a.jsxs(Tt,{"data-testid":`${e}-option-${o.value||"default"}`,onSelect:()=>s(o.value),className:"items-start gap-2",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:Q("block text-[12px]",c?"font-medium text-text-100":"text-text-300"),children:o.label}),o.description?a.jsx("span",{className:"mt-0.5 block text-[11px] text-text-400",children:o.description}):null]}),c?a.jsx(Gt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent"}):null]})]},o.value||"default")})})}function j_({testid:e,list:t,options:n,current:r,onSelect:s,trigger:i,align:o="start",side:l,contentClassName:c}){const[u,d]=p.useState(!1),h=f=>{f&&!u&&t.load(),d(f)};return a.jsxs(is,{open:u,onOpenChange:h,children:[a.jsx(os,{asChild:!0,children:typeof i=="function"?i(()=>h(!0)):i}),a.jsx(zr,{align:o,...l?{side:l}:{},className:Q("max-h-[420px] w-[260px] overflow-y-auto",c),"data-testid":`${e}-menu`,children:a.jsx(AX,{testid:e,list:t,...n?{options:n}:{},current:r,onSelect:s})})]})}const yDe={codex:"Codex",pi:"pi",claude:"Claude"},bDe={codex:"Codex",pi:"pi",claude:"Claude Agent SDK"},ih="[1m]",wDe=e=>e.endsWith(ih)?e.slice(0,-ih.length):e;function _De(e){const[t,n]=p.useState(!1),r=il(e.tool),s=e.tool||"claude",i=s==="claude",o=i?wDe(e.model):e.model,l=i&&e.model.endsWith(ih),c=e.modelList.models,u=c.filter(g=>g.id!=="").map(g=>({value:g.id,label:g.label,...g.description?{description:g.description}:{},...g.group?{group:g.group}:{}})),d=!e.model,h=Ox(o,c,e.configSchema),{value:f,label:m}=OX(e.effort,h);return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"deploy-engine-card",children:[a.jsx(Yr,{icon:a.jsx(H5,{className:"size-[18px]"}),title:"引擎与模型"}),a.jsx(li,{delayDuration:120,children:a.jsxs("div",{className:"space-y-2.5 px-5 py-4",children:[a.jsx("div",{className:"text-xs text-text-400",children:i?"只影响云上:本机 Claude 的模型不变":"本地 persona 也会改变"}),a.jsx(Om,{label:"引擎",required:!r,name:"deploy-engine",value:r?s:void 0,options:T7.map(g=>({value:g,label:yDe[g],hint:`云上跑 ${bDe[g]} ${M7[g]}`})),onPick:g=>{g!==s&&e.onChange({tool:g})}}),!r&&a.jsxs("div",{className:"pl-[88px] text-xs text-warning",children:["现在是 ",s,",云上只跑 Codex、pi 或 Claude,选一个"]}),r&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"模型:"}),d&&a.jsx(Px,{}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[a.jsx(j_,{testid:"deploy-engine-model",list:e.modelList,options:u,current:o,onSelect:g=>{g!==o&&e.onChange({model:l?`${g}${ih}`:g})},trigger:a.jsx(Dx,{testid:"deploy-engine-model",label:d?"选一个模型":N_(c,o),needsAttention:d,disabled:e.allowManualModel})}),e.allowManualModel&&a.jsx("div",{className:"text-xs text-warning",children:"选择上方订阅通道即可读取模型;平台默认或旧订阅可在高级选项中指定模型 ID"}),e.allowManualModel&&a.jsxs("div",{className:"space-y-1",children:[a.jsx(ze,{size:"sm",variant:"ghost","aria-expanded":t,onClick:()=>n(g=>!g),children:"高级:指定模型 ID"}),t&&a.jsx(ar,{defaultValue:o,"aria-label":"云端模型 ID",placeholder:"模型 ID(高级)",onBlur:g=>{const x=g.target.value.trim();x&&x!==o&&e.onChange({model:l?x+ih:x})},onKeyDown:g=>{g.key==="Enter"&&g.currentTarget.blur()}},o)]})]})]}),r&&i&&!d&&a.jsx(Om,{label:"上下文",name:"deploy-engine-context",value:l?"1m":"default",options:[{value:"default",label:"默认",hint:"Claude 模型用它自己的窗口;号池里别的模型 Claude Code 不知道窗口多大,按 200K 用"},{value:"1m",label:"1M",hint:"模型 id 带 [1m]:Claude Code 按 1M 窗口用(模型本身和号池都要支持 1M,号池不报这个,要你自己确认)"}],onPick:g=>{g==="1m"!==l&&e.onChange({model:g==="1m"?`${o}${ih}`:o})}}),r&&!d&&h.options.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"推理强度:"}),a.jsx(bX,{align:"start",testid:"deploy-engine-effort",label:m,current:f,items:h.options.map(g=>({value:g.value,label:g.label})),onSelect:g=>{g!==f&&e.onChange({effort:g})}})]})]})})]})}function $X(e){const[t,n]=p.useState(""),[r,s]=p.useState(!1),[i,o]=p.useState(!1),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[h,f]=p.useState(null),{status:m}=e;if(!m)return null;const g=async()=>{if(!(!e.onAuthorize||t.trim().length===0)){c(!0),f(null);try{await e.onAuthorize(t.trim()),n(""),s(!1)}catch(v){f(v instanceof Error?v.message:String(v))}finally{c(!1)}}},x=async()=>{if(e.onStartOauth){d(!0),f(null);try{const v=await e.onStartOauth();v&&window.open(v,"_blank","noopener"),s(!1)}catch(v){f(v instanceof Error?v.message:String(v))}finally{d(!1)}}},b=e.onAuthorize&&a.jsxs("form",{className:"flex flex-wrap items-center gap-2",onSubmit:v=>{v.preventDefault(),g()},children:[a.jsx(ar,{type:"password",autoComplete:"off",placeholder:"ghp_… 或 github_pat_…","aria-label":"GitHub token",value:t,onChange:v=>n(v.target.value),className:"min-w-0 flex-1 font-mono text-xs",disabled:l||e.busy}),a.jsx(ze,{type:"submit",size:"sm",variant:"outline",disabled:l||e.busy||t.trim().length===0,children:l?"正在核对…":"用这个 token"}),a.jsxs("div",{className:"w-full text-xs text-text-400",children:["去 GitHub 建一个 classic personal access token,勾 ",a.jsx("code",{className:"font-mono",children:"repo"})," 和"," ",a.jsx("code",{className:"font-mono",children:"workflow"}),",账号要在 ",O7," 组织里。"]})]});if(m.status==="authorized"&&!r)return a.jsxs("div",{"data-testid":"github-account-card",className:"flex items-center gap-2 rounded-lg border border-border-card bg-surface-card px-4 py-2 text-xs text-text-300",children:[a.jsx(Gt,{className:"size-3.5 shrink-0 text-success"}),a.jsxs("span",{children:["GitHub 已关联 ",a.jsxs("span",{className:"font-mono text-text-100",children:["@",m.login]}),a.jsxs("span",{className:"text-text-400",children:[" · ",m.source==="git"?"来自本机 git 的凭据":"来自本机凭据表"]})]}),(e.onStartOauth||e.onAuthorize)&&a.jsx("button",{type:"button",onClick:()=>s(!0),className:"ml-auto cursor-pointer whitespace-nowrap text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"换一个"})]});if(m.status==="pending")return a.jsxs("div",{"data-testid":"github-account-card",className:"rounded-lg border border-border bg-surface-card",children:[a.jsxs("div",{className:"flex items-baseline gap-2 border-b border-border px-4 py-2.5",children:[a.jsx("span",{className:"self-center text-text-400",children:a.jsx(st,{className:"size-4 animate-spin"})}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:"等你在 GitHub 那页点「Authorize」"})]}),a.jsxs("div",{className:"space-y-2 px-4 py-3 text-[13px] leading-snug text-text-200",children:[a.jsx("div",{children:"已经在新标签页打开了 GitHub 的授权页。点同意之后会自动回到这里,这张卡会自己变绿。"}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsxs("a",{href:m.authUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-accent underline underline-offset-4",children:[a.jsx(Lr,{className:"size-3"}),"没打开的话点这里"]}),e.onAuthorize&&!i&&a.jsx("button",{type:"button",onClick:()=>o(!0),className:"cursor-pointer text-xs text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"或手动粘一个 token"})]}),i&&b,h&&a.jsx("div",{className:"text-xs text-error",children:h})]})]});const y=m.status==="invalid";return a.jsxs("div",{"data-testid":"github-account-card",className:`rounded-lg border bg-surface-card ${y?"border-error/40":m.status==="missing"?"border-warning/50":"border-border"}`,children:[a.jsxs("div",{className:"flex items-baseline gap-2 border-b border-border px-4 py-2.5",children:[a.jsx("span",{className:"self-center text-text-400",children:y?a.jsx(vg,{className:"size-4 text-error"}):a.jsx(gg,{className:"size-4"})}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:y?"GitHub 授权失效":m.status==="missing"?"先关联 GitHub":"换一个 GitHub 账号"})]}),a.jsxs("div",{className:"space-y-3 px-4 py-3",children:[y?a.jsx("div",{className:"text-[13px] leading-snug text-text-200",children:m.message}):a.jsxs("div",{className:"text-[13px] leading-snug text-text-200",children:["关联一次,app-builder 建仓推代码、persona 上云、PR 收件箱、persona 里的 git push 都用它。",m.status==="missing"&&" 本机 git 里没有 github.com 的凭据。","存在本机 git 里,clawd 不另存。"]}),e.onStartOauth&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsx(ze,{type:"button",size:"sm",onClick:()=>void x(),disabled:u||e.busy,children:u?"正在打开 GitHub…":"关联 GitHub"}),e.onAuthorize&&!i&&a.jsx("button",{type:"button",onClick:()=>o(!0),className:"cursor-pointer text-xs text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"或手动粘一个 token"})]}),(i||!e.onStartOauth)&&b,h&&a.jsx("div",{className:"text-xs text-error",children:h}),r&&!l&&!u&&a.jsx("button",{type:"button",onClick:()=>{s(!1),o(!1)},className:"cursor-pointer text-xs text-text-400 hover:text-accent",children:"算了,还用原来的"})]})]})}function uL(e){return a.jsxs("a",{href:e.href,target:"_blank",rel:"noreferrer",className:"inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-accent hover:underline",children:[e.children,a.jsx(Lr,{className:"size-3"})]})}function SDe(e){const[t,n]=p.useState(!1),{status:r}=e,s=()=>{var o;n(!1),(o=e.onUnpublish)==null||o.call(e)},i=(()=>{switch(r.kind){case"online":return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"size-2 shrink-0 rounded-full bg-success"}),a.jsxs("span",{className:"min-w-0 truncate",children:[a.jsx("span",{className:"text-text-100",children:"在线上"}),a.jsx("span",{className:"text-text-400",children:" · 别人能看到、能用"})]}),e.onUnpublish&&a.jsx(ze,{size:"sm",variant:"outline",className:"ml-auto h-7",disabled:e.busy,onClick:()=>n(!0),children:"下线"})]});case"unpublishing":return a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"size-3.5 shrink-0 animate-spin text-text-300"}),a.jsx("span",{className:"min-w-0 truncate text-text-100",children:"正在下线…"}),r.runUrl&&a.jsx("span",{className:"ml-auto",children:a.jsx(uL,{href:r.runUrl,children:"查看流水线"})})]});case"failed":return a.jsxs(a.Fragment,{children:[a.jsx(Sn,{className:"size-3.5 shrink-0 text-error"}),a.jsx("span",{className:"min-w-0 truncate text-text-100",children:"下线没成功"}),a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-3",children:[r.runUrl&&a.jsx(uL,{href:r.runUrl,children:"看日志"}),e.onUnpublish&&a.jsx(ze,{size:"sm",variant:"outline",className:"h-7",disabled:e.busy,onClick:()=>n(!0),children:"重试"})]})]});case"offline":return a.jsxs(a.Fragment,{children:[a.jsx(nhe,{className:"size-3.5 shrink-0 text-text-400"}),a.jsxs("span",{className:"min-w-0 truncate",children:[a.jsx("span",{className:"text-text-100",children:"已下线"}),a.jsx("span",{className:"text-text-400",children:" · 别人看不到、用不了。重新扫描、发布就能再上线"})]})]});case"unknown":return a.jsxs(a.Fragment,{children:[a.jsx(fH,{className:"size-3.5 shrink-0 text-text-400"}),a.jsx("span",{className:"min-w-0 truncate text-text-400",children:"查不到现在在不在线上"})]})}})();return a.jsxs("div",{"data-testid":"deploy-live-card",className:"rounded-lg border border-border-card bg-surface-card px-4 py-2 text-xs text-text-300",children:[a.jsx("div",{className:"flex min-h-7 items-center gap-2",children:i}),e.error&&a.jsx("div",{className:"mt-1 text-error",children:e.error}),a.jsx(xs,{open:t,onOpenChange:n,children:a.jsxs(ts,{children:[a.jsxs(Ls,{children:[a.jsx(ns,{children:"下线这个 persona?"}),a.jsx(zi,{children:"下线后别人看不到、也用不了它。正在进行的对话会继续到结束,聊天记录不会丢。以后重新扫描、发布就能再上线。"})]}),a.jsxs(Ja,{children:[a.jsx(ze,{variant:"outline",onClick:()=>n(!1),children:"取消"}),a.jsx(ze,{variant:"destructive",onClick:s,children:"确认下线"})]})]})})]})}function LX({test:e}){return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Yr,{icon:a.jsx(Gt,{className:"size-[18px]"}),title:"发布者验收",count:`${e.checks.length} 项必验`}),a.jsxs("div",{className:"space-y-2 px-5 py-4 text-[13px] text-text-300",children:[a.jsx("div",{className:"font-mono",children:e.entry}),a.jsx("div",{children:e.checks.join(" / ")}),a.jsxs("div",{className:"text-xs text-text-400",children:["测试环境候选镜像中执行 · 最长 ",e.timeoutSeconds," 秒 · 全部通过才可上线"]})]})]})}function kDe(e){var ke,ie,De,rt,ht,jt,Bt,hn,jn,Xn,zt;const t=e.state.targets?{...e.state,run:(ke=e.state.targets.integration)==null?void 0:ke.run,secrets:(ie=e.state.targets.integration)==null?void 0:ie.secrets}:e.state,{repo:n}=t,r=t.releases.find(pe=>{var ct;return pe.head===((ct=t.repo)==null?void 0:ct.head)})??ya(t.releases),s=SX(t,e.roundIdx??Ay(t)),i=e.starting?[]:s.scans,o=e.starting?void 0:s.release,l=((De=e.retry)==null?void 0:De.headSha)===(o==null?void 0:o.head)?e.retry:void 0,c=!!e.promoting&&!!o&&Dm(m1(i,o),o),u=e.busy||c||!!l&&l.phase!=="failed",d=kc(i),h=m1(i,o),f=!!e.starting,m=!!e.releasing,g=!!e.awaitingRun&&!!o,x=(d==null?void 0:d.status)==="scanning",b=t.run!==void 0&&t.run.status!=="completed",y=Dm(h,o),v=!t.github||t.github.status==="authorized",w=!e.engine||il(e.engine.tool),_=e.taskConcurrencyDraft??String(e.taskConcurrency??4),S=/^\d+$/.test(_.trim())&&Number.isSafeInteger(Number(_))&&Number(_)>0,k=e.onChangeTaskConcurrency&&!S?"请输入大于 0 的整数":void 0,C=e.resourceSaving?"正在保存配置,请等待保存完成":e.cpu!==void 0&&!Ob.includes(e.cpu)?"先在「资源预估」中修复 CPU 配置":void 0,j=e.configDirty?"配置有未保存的修改,请先保存配置":void 0,T=NX({current:e.currentConfig,release:o,run:t.run,anchored:y}),E=CX(e.engine)[0],I=C??k??j??E,[R,P]=p.useState(!1),[O,F]=p.useState(null),L=p.useRef(!1),U=async()=>{if(!(!e.onApplyConfig||!(o!=null&&o.id)||L.current)){L.current=!0,P(!0),F(null);try{await e.onApplyConfig(o.id)}catch(pe){F(pe instanceof Error?pe.message:String(pe))}finally{L.current=!1,P(!1)}}},[B,D]=p.useState(null),M=pe=>D({latestId:d==null?void 0:d.id,id:pe}),V=(B&&B.latestId===(d==null?void 0:d.id)?t.scans.find(pe=>pe.id===B.id):void 0)??h,z=V?t.scans.indexOf(V)+1:0,$=iL(t,h),q=iL(t,V),X=sD(V,n,r),G=I7(V,n,r),te=Dm(V,o),[ae,Z]=p.useState(null),J=ae?t.scans.find(pe=>pe.id===ae):void 0,be=`${(d==null?void 0:d.id)??""}-${(o==null?void 0:o.head)??""}`,[oe,ce]=p.useState(null),[se,he]=p.useState(x),me=v&&w&&!e.configDirty&&!e.resourceSaving&&!f&&!x&&!m&&!u&&!!e.onScan,Te=e.configDirty?"配置有未保存的修改,请先到「配置」保存":v?w?f?n?"正在落存、起管家会话…":"正在建仓库…":x?"管家在读 persona…":n?(d==null?void 0:d.status)==="done"&&!sD(d,n,r)?a.jsx("span",{className:"text-warning",children:"有未提交的改动,清单是改动前扫的"}):d?"再扫一遍会新增一条记录;发布默认用最新那次":"让管家读一遍 persona,列出它需要什么":`会先在 ${O7} 建一个私有仓库、把 persona 提交进去,再让管家读一遍它需要什么`:"云上只跑 Codex、pi 或 Claude,在「引擎与模型」里选一个":"先在上面那张卡里关联 GitHub",Ve=!!V&&V.status==="done"&&X&&q.length===0&&!x&&!f,ge=Ve,Ne=f||x?"等扫描结束":V?V.status==="failed"?"扫描失败了,重新扫描":X?q.length>0?`还差 ${q.length} 项,按下面标「必填」的那几行处理`:void 0:"有未提交的改动,先重新扫描":"先扫描",Me=a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"inline-flex",children:[a.jsxs(ze,{size:"sm",className:"rounded-r-none",onClick:()=>{var pe;return(pe=e.onScan)==null?void 0:pe.call(e)},disabled:!me,children:[f||x?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(Vfe,{className:"size-4"}),d?"重新扫描":"开始扫描"]}),a.jsxs(is,{children:[a.jsx(os,{asChild:!0,disabled:!me,children:a.jsx(ze,{size:"sm","aria-label":"选扫描方式",className:"rounded-l-none border-l border-accent-contrast/30 px-2",children:a.jsx(Jt,{className:"size-4"})})}),a.jsxs(zr,{align:"start",children:[a.jsx(Tt,{onSelect:()=>{var pe;return(pe=e.onScan)==null?void 0:pe.call(e,"soft")},children:a.jsxs("div",{children:[a.jsx("div",{children:"软扫"}),a.jsx("div",{className:"text-xs text-text-400",children:"只重看跟线上正跑那版有差别的部分;不成立会自动改硬扫"})]})}),a.jsx(Tt,{onSelect:()=>{var pe;return(pe=e.onScan)==null?void 0:pe.call(e,"hard")},children:a.jsxs("div",{children:[a.jsx("div",{children:"硬扫"}),a.jsx("div",{className:"text-xs text-text-400",children:"从零把 persona 整个读一遍"})]})})]})]})]}),a.jsxs(ze,{size:"sm",className:"shrink-0",disabled:!Ve,onClick:()=>ce({attempt:be,key:"config"}),title:Ve?"扫描这一段过了,去配置引擎、模型和资源":Ne,children:["下一步:配置 ",a.jsx(hD,{className:"size-4"})]})]}),a.jsx("div",{className:"text-xs text-text-400",children:Te}),e.scanError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.scanError})]}),Ue=i.filter(pe=>pe.status==="done"),ut=g?"刚推上去,等流水线跑起来":b?"上一次还在跑,等它走完":void 0,Ct=!!V&&V.status==="done"&&X&&q.length===0&&!ut&&!m&&!f&&!u&&!!e.onRelease&&!I&&!(G&&x),Nt=I??(m?"正在提交并推送…":Ue.length===0&&(V==null?void 0:V.status)!=="done"?"先扫描":!V||V.status!=="done"?"这次扫描没扫完,换一次":G&&x?"有一次扫描正在跑,等它扫完再回到旧版本":X?q.length>0?`还差 ${q.length} 项必填,回「扫描」段标「必填」的位置填`:ut||(te?"这一版已推到测试分支,继续查看测试结果":G?"会先把本机 persona 回到这次扫描时的内容,再推到测试分支,构建、自动试跑,再发到测试环境":"把这次扫描推到测试分支,构建、自动试跑,再发到测试环境"):"有未提交的改动,这次扫描之后内容变过;重新扫描,或在上面的扫描历史里换一次"),ne=Ice((rt=e.engine)==null?void 0:rt.tool,e.localEngineVersion),re=a.jsxs("div",{className:"space-y-3",children:[e.integrationLogin,ne&&a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-[13px] text-warning",role:"status",children:[a.jsx(Sn,{className:"mt-0.5 size-4 shrink-0"}),a.jsxs("div",{children:["本机 ",ne.tool," ",ne.local,",云上底座清单指定 ",ne.tool," ",ne.cloud,"。已发布 persona 的实际版本以其镜像为准;本机验过的行为不保证云上一样。"]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"text-text-400",children:"发布的扫描:"}),V&&V.status==="done"?a.jsx(CDe,{s:V,n:z,latest:V===d}):a.jsx("span",{className:"text-text-400",children:"—"}),a.jsx("span",{className:"text-xs text-text-400",children:"想发别的版本,在「扫描」段的扫描历史里点那一次"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsxs(ze,{size:"sm",onClick:()=>{var pe;!V||!Ct||(G?Z(V.id):(pe=e.onRelease)==null||pe.call(e,V.id))},disabled:!Ct,children:[m?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(vy,{className:"size-4"}),te?"查看测试发布":G?"回到这个版本并发测试环境":"发测试环境"]}),a.jsx("span",{className:"text-xs text-text-400",children:Nt}),e.releaseError&&a.jsx("div",{className:"w-full text-xs text-error",children:e.releaseError})]}),a.jsx(xs,{open:!!J,onOpenChange:pe=>{pe||Z(null)},children:a.jsxs(ts,{children:[a.jsxs(Ls,{children:[a.jsxs(ns,{children:["回到第 ",J?t.scans.indexOf(J)+1:0," 次扫描的版本?"]}),a.jsxs(zi,{children:["本机 persona 的文件会回到这次扫描时的样子(",((J==null?void 0:J.head)??"").slice(0,7),"),作为一个新提交,再推到测试分支。 没提交的改动会先自动保存;现在这一版仍留在 git 历史里(推送失败时这个回退提交会留在本机,重试即可)。引擎、模型和凭据用现在的设置,不跟着回去。"]})]}),a.jsxs(Ja,{children:[a.jsx(ze,{size:"sm",variant:"ghost",onClick:()=>Z(null),children:"取消"}),a.jsx(ze,{size:"sm",onClick:()=>{var ct;const pe=ae;Z(null),pe&&((ct=e.onRelease)==null||ct.call(e,pe))},children:"回到这个版本并发布"})]})]})}),y&&o&&n&&a.jsxs("div",{className:"text-xs text-text-400",children:["这一轮发的:第 ",t.scans.findIndex(pe=>pe.id===o.scanId)+1," 次扫描的清单 ·"," ",a.jsxs("a",{href:`https://github.com/${$h(n.url)}/commit/${o.head}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 font-mono text-accent hover:underline",children:[o.head.slice(0,7),a.jsx(Lr,{className:"size-3"})]})]})]}),Ee=R||T.kind==="applying",Ae=(T.kind==="pending"||T.kind==="failed")&&!!e.onApplyConfig&&!I&&!Ee&&!u&&!b&&!g&&!m&&!f,et=(ge||y)&&!I&&!f&&!m,qe=a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.onSaveConfig&&a.jsx(ze,{size:"sm",onClick:e.onSaveConfig,disabled:!e.configDirty||!S||!!e.resourceSaving||m||g||u||Ee,children:e.resourceSaving?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"size-4 animate-spin"}),"保存中…"]}):"保存配置"}),T.kind==="pending"||T.kind==="failed"||T.kind==="applying"?a.jsxs(ze,{size:"sm",onClick:()=>void U(),disabled:!Ae,children:[Ee?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(vy,{className:"size-4"}),T.kind==="applying"||R?"应用中":T.kind==="failed"?"重新应用":"应用到测试环境"]}):T.kind==="needsRepublish"?a.jsx(ze,{size:"sm",onClick:()=>ce({attempt:be,key:"scan"}),children:"去重新扫描"}):a.jsxs(ze,{size:"sm",disabled:!et,onClick:()=>ce({attempt:be,key:"push"}),title:et?void 0:I,children:["下一步:发测试环境 ",a.jsx(hD,{className:"size-4"})]}),I&&a.jsx("span",{className:"text-xs text-text-400",children:I})]}),e.configError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.configError}),O&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:O})]}),tt=RX({personaId:t.personaId,flow:{ready:!!(o!=null&&o.verified)&&Pu(o,t.run)&&sc(t.run)&&((jt=(ht=t.targets)==null?void 0:ht.integration)==null?void 0:jt.image)===o.verified.image,confirmed:Pu(o,t.run)&&sc(t.run)&&!!((Bt=o==null?void 0:o.verified)!=null&&Bt.verification.checks.includes("persona-dialogue"))&&((hn=t.run)==null?void 0:hn.jobs.some(pe=>pe.key===mo&&pe.status==="done"))===!0&&o.runId===t.run.runId&&o.runAttempt===t.run.runAttempt&&((Xn=(jn=t.targets)==null?void 0:jn.integration)==null?void 0:Xn.image)===((zt=o.verified)==null?void 0:zt.image),promotion:[...t.promotions??[]].reverse().find(pe=>pe.releaseId===(o==null?void 0:o.id)),testActions:e.testActions,productionActions:e.productionActions,promoting:c,submissionError:o&&!e.starting?e.productionError:void 0},...n?{repo:n}:{},scans:i,...o?{released:o}:{},...r?{lastRelease:r}:{},...t.run?{run:t.run}:{},blockers:$,starting:f,releasing:m,awaitingRun:g,...l?{retry:l}:{},...e.onRefreshRetry?{onRefreshRetry:e.onRefreshRetry}:{},...e.cloud?{cloud:e.cloud}:{},config:{phase:T,...e.currentConfig?{current:e.currentConfig}:{},...o!=null&&o.config?{tested:o.config}:{},...I?{blocker:I}:{},actions:qe},scanActions:Me,releaseActions:re,...e.onRetryJob?{onRetry:e.onRetryJob}:{},...e.onScan&&!u?{onRescan:()=>{var pe;return(pe=e.onScan)==null?void 0:pe.call(e)}}:{},...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{},offline:t.online===!1&&sc(t.run)}),Pt=p.useRef({attempt:be,key:g1(tt)??"scan"});Pt.current.attempt!==be&&(Pt.current={attempt:be,key:g1(tt)??"scan"});const wt=WPe(tt);wt&&(Pt.current.key=wt);const _e=oe&&oe.attempt===be?oe.key:Pt.current.key,Le=$b(t.secrets),dt=pe=>V==null?void 0:V.evidence.find(ct=>ct.target===pe),ot=V==null?void 0:V.manifest,dn=(()=>{if(!ot)return[];const pe=new Set(bw(ot).flatMap(ct=>ct.env));return ot.secrets.map(ct=>({...ct,env:ct.env.filter(on=>!pe.has(on))})).filter(ct=>ct.env.length>0)})();return a.jsxs("div",{className:"flex h-full overflow-hidden bg-surface-page text-text-100",children:[a.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 px-6 py-8",children:[a.jsx("div",{className:"sticky top-0 z-10 -mx-6 bg-surface-page/95 px-6 py-2 backdrop-blur",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Sw,{className:"size-5 text-accent"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-medium",children:"发布到云上"}),a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs text-text-400",children:[a.jsx("span",{className:"truncate",title:t.personaId,children:t.personaId}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx(NDe,{state:t,starting:f,scanBase:jDe(d)})]})]}),a.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.workPanel&&a.jsxs("button",{onClick:()=>he(pe=>!pe),"aria-expanded":se,className:"group inline-flex cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border border-accent/50 bg-accent-dim px-2.5 py-1 text-xs font-medium text-accent transition-colors hover:bg-accent hover:text-accent-contrast",children:[x?a.jsx(st,{className:"size-3 animate-spin"}):a.jsx(Gt,{className:"size-3"}),a.jsx("span",{children:x?"管家分析中":"管家的分析过程"}),a.jsx(Jt,{className:`size-3 transition-transform ${se?"-rotate-90":"rotate-90"}`})]})})]})}),a.jsx($X,{status:t.github,onAuthorize:e.onAuthorizeGithub,onStartOauth:e.onStartGithubOauth,busy:u}),e.live&&a.jsx(SDe,{status:e.live.status,busy:u,...e.live.error?{error:e.live.error}:{},...e.live.onUnpublish?{onUnpublish:e.live.onUnpublish}:{}}),a.jsxs(Id,{className:"border-accent/40",children:[a.jsx(Yr,{icon:a.jsx(vy,{className:"size-[18px]"}),title:"上云流程",tone:"accent"}),a.jsx("div",{className:"px-5 py-4",children:a.jsx(TX,{stages:tt,activeKey:_e,onPick:pe=>ce({attempt:be,key:pe})},be)})]}),_e==="scan"&&a.jsxs(a.Fragment,{children:[t.historyError&&a.jsx(Id,{className:"border-error/40",children:a.jsxs("div",{className:"px-4 py-3 text-[13px] leading-snug text-text-200",children:["扫描记录读不出来:",t.historyError,"。重新扫描会重建它。"]})}),!f&&t.scans.length>0&&a.jsx(pDe,{scans:t.scans,...n?{repo:n}:{},...r?{released:r}:{},...V?{selectedId:V.id}:{},...t.online!==void 0?{online:t.online}:{},onSelect:M}),ot&&V&&ot.packages.length>0&&a.jsxs(Id,{children:[a.jsx(Yr,{icon:a.jsx(kw,{className:"size-[18px]"}),title:"镜像",count:V.status==="scanning"?"还在长…":`${ot.packages.length} 项`}),ot.packages.map(pe=>a.jsx(PX,{name:pe.name,version:pe.version,min:pe.min,localVersion:pe.localVersion,from:pe.from,aptVersion:pe.aptVersion,aptMissing:pe.aptMissing,artifact:pe.artifact,evidence:dt(`package:${pe.name}`),blockers:p7(pe)},pe.name))]}),ot&&V&&ot.connectors.length>0&&a.jsxs(Id,{children:[a.jsx(Yr,{icon:a.jsx(Cw,{className:"size-[18px]"}),title:"连接器",count:`${ot.connectors.length} 个`}),ot.connectors.map(pe=>a.jsx(hDe,{connector:pe,publisherAuth:t.publisherFeishuAuth,onRefreshPublisherAuth:e.onRefreshPublisherAuth,evidence:dt(`connector:${pe.name}`),onChange:ct=>{var on;return(on=e.onPatchConnector)==null?void 0:on.call(e,V.id,ct)},...pe.credentialSource==="shared"&&pe.fields.length>0?{secretCard:a.jsx(xE,{embedded:!0,secret:{name:pe.name,env:pe.fields},presence:t.secrets?t.secrets.filter(ct=>pe.fields.includes(ct.env)):void 0,onSubmitValues:ct=>e.onPutSecret(V.id,pe.name,ct)})}:{}},pe.name))]}),ot&&V&&dn.length>0&&a.jsxs(Id,{children:[a.jsx(Yr,{icon:a.jsx(gg,{className:"size-[18px]"}),title:"凭据",count:`${dn.length} 条`}),dn.map(pe=>a.jsx(xE,{secret:pe,evidence:dt(`secret:${pe.name}`),presence:t.secrets?t.secrets.filter(ct=>pe.env.includes(ct.env)):void 0,onSubmitValues:ct=>e.onPutSecret(V.id,pe.name,ct)},pe.name))]}),(ot==null?void 0:ot.test)&&a.jsx(LX,{test:ot.test}),V&&V.notes.length>0&&a.jsxs(Id,{children:[a.jsx(Yr,{icon:a.jsx(Sn,{className:"size-[18px]"}),title:"存疑项",count:`${V.notes.length} 条`,tone:"warning"}),a.jsx("div",{className:"space-y-2 px-5 py-4",children:V.notes.map((pe,ct)=>a.jsxs("div",{className:"flex gap-2 text-[13px] leading-snug text-text-300",children:[a.jsx("span",{className:"shrink-0 text-warning",children:"•"}),pe]},ct))})]})]}),_e==="config"&&a.jsxs("fieldset",{className:"contents",disabled:!!e.resourceSaving||m||g||u||Ee,children:[e.onChangeEngineAuth&&a.jsx(_X,{...Le?{state:Le}:{},channels:e.channels,channelId:e.engineChannelId,onRefreshChannels:e.onRefreshChannels,onAddChannel:e.onAddChannel,onChange:e.onChangeEngineAuth}),e.engine&&e.engineEditor&&a.jsx(_De,{tool:e.engine.tool,model:e.engine.model,effort:e.engine.effort??"",...e.engineEditor}),(e.onChangeSize||e.onChangeCpu)&&a.jsx(xDe,{size:e.size,cpu:e.cpu,onChange:e.onChangeSize,onChangeCpu:e.onChangeCpu,saving:e.resourceSaving,disabled:m||g||u||Ee,taskConcurrency:e.onChangeTaskConcurrency?{value:_,defaulted:e.taskConcurrency===void 0,disabled:m||g||!!e.resourceSaving,error:S?null:"请输入大于 0 的整数",onChange:e.onChangeTaskConcurrency}:void 0}),e.scanError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.scanError})]})]})}),e.workPanel&&a.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${se?"w-[380px]":"w-0"}`,children:a.jsx("div",{className:"h-full w-[380px] border-l border-border bg-surface-card",children:e.workPanel})})]})}function CDe(e){return a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsxs("span",{children:["第 ",e.n," 次"]}),a.jsx("span",{className:"text-text-400",children:nf(e.s.startedAt)}),a.jsx("span",{className:"font-mono text-xs text-text-400",children:(e.s.head??"").slice(0,7)}),a.jsx("span",{className:"text-xs text-text-400",children:e.s.baseKind==="soft"?"软扫":"硬扫"}),e.latest&&a.jsx("span",{className:"rounded-full bg-text-100-dim px-1.5 text-[11px] text-text-400",children:"最新"})]})}function NDe(e){const{repo:t}=e.state;if(!t)return a.jsx("span",{children:e.starting?"正在建仓库…":"还没有仓库"});const n=t.dirty?"有未提交的改动":t.ahead>0?`有 ${t.ahead} 个提交没推`:"已同步";return a.jsxs(a.Fragment,{children:[a.jsx(wu,{className:"size-3 shrink-0"}),a.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",title:$h(t.url),className:"truncate hover:text-accent hover:underline",children:$h(t.url)}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",children:t.branch}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:`shrink-0 ${t.dirty||t.ahead>0?"text-warning":""}`,children:n}),e.scanBase&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",title:e.scanBase.title,children:e.scanBase.label})]})]})}function jDe(e){if(e)return e.baseKind==="soft"?{label:"软扫",title:"只重看了跟线上正跑那版有差别的部分"}:{label:"硬扫",title:"从零把 persona 整个读了一遍"}}const Id=p.forwardRef(function(t,n){return a.jsx("div",{ref:n,className:`rounded-lg border border-border-card bg-surface-card ${t.className??""}`,children:t.children})});function EDe(e){const t=ca("sessions"),n=t==null?void 0:t.find(r=>r.sessionId===e.sessionId);return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-4 py-2.5",children:[e.live?a.jsx(st,{className:"size-3.5 animate-spin text-accent"}):a.jsx(Gt,{className:"size-3.5 text-success"}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:"管家在读这个 persona"}),a.jsx("span",{className:"text-xs text-text-400",children:e.live?"进行中":"可以接着问它"})]}),a.jsx("div",{className:"min-h-0 flex-1",children:n?a.jsx(S_,{extras:{session:n,api:e.api,hideHeader:!0,flatProcess:!0}},n.sessionId):a.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-xs text-text-400",children:[a.jsx(st,{className:"size-3.5 animate-spin"}),"正在接上管家的会话"]})})]})}function IDe(e){var wa,vr,ve,Qe,He,Ht,ur,Qi,rv,nd,sv,Xf,iv,rd,ov,Ji,av,Zf,sd,lv,cv,uv,gi,Qf,id,Ic,od;const{state:t,remoteReady:n,remoteError:r,loading:s,error:i,refresh:o,awaitingRun:l,retry:c,scan:u,patch:d,putSecret:h,setEngineAuth:f,release:m,rerunJob:g,applyConfig:x,unpublishFrom:b,unpublish:y,promote:v,openTest:w}=VM(e.personaId,{mode:"staged"}),_=Un(),S=qV(_,"integration"),[k,C]=p.useState(null),[j,T]=p.useState(null),[E,I]=p.useState(!1),[R,P]=p.useState(null),[O,F]=p.useState(!1),L=p.useRef(null),U=p.useRef(null),[B,D]=p.useState(!1),[M,V]=p.useState({personaId:e.personaId,patch:{}}),z=M.personaId===e.personaId?M:void 0,[$,q]=p.useState(null);p.useEffect(()=>{L.current=null,U.current=null,D(!1),V({personaId:e.personaId,patch:{}}),q(null),F(!1),P(null)},[e.personaId]);const[X,G]=p.useState(!1),te=p.useRef(e.personaId),ae=p.useRef(null);te.current!==e.personaId&&(te.current=e.personaId,ae.current=null),t&&n&&ae.current===null&&(ae.current=Ay(t));const Z=t?SX(t,ae.current??Ay(t)):void 0,J=!X&&Dm(m1(Z==null?void 0:Z.scans,Z==null?void 0:Z.release),Z==null?void 0:Z.release)?Z==null?void 0:Z.release:void 0,be=((ve=(vr=(wa=t==null?void 0:t.targets)==null?void 0:wa.integration)==null?void 0:vr.run)==null?void 0:ve.status)==="completed"&&t.targets.integration.run.conclusion==="success"&&!!(J!=null&&J.verified)&&((He=(Qe=t==null?void 0:t.targets)==null?void 0:Qe.integration)==null?void 0:He.image)===J.verified.image&&((Qi=(ur=(Ht=t==null?void 0:t.targets)==null?void 0:Ht.integration)==null?void 0:ur.run)==null?void 0:Qi.runId)===J.runId&&((sv=(nd=(rv=t.targets)==null?void 0:rv.integration)==null?void 0:nd.run)==null?void 0:sv.runAttempt)===J.runAttempt,oe=be&&!!((Xf=J==null?void 0:J.verified)!=null&&Xf.verification.checks.includes("persona-dialogue"))&&((ov=(rd=(iv=t==null?void 0:t.targets)==null?void 0:iv.integration)==null?void 0:rd.run)==null?void 0:ov.jobs.some(ye=>ye.key===mo&&ye.status==="done")),ce=t==null?void 0:t.scans.find(ye=>ye.id===(J==null?void 0:J.scanId)),se=(av=(Ji=t==null?void 0:t.targets)==null?void 0:Ji.production)==null?void 0:av.secrets,he=!!ce&&!!se&&nce(ce.manifest).every(ye=>se.some(yt=>yt.env===ye&&yt.setAt))&&((z==null?void 0:z.productionChannelId)!==void 0||$b(se)!=="partial"),me=[...(t==null?void 0:t.promotions)??[]].reverse().find(ye=>ye.releaseId===(J==null?void 0:J.id)),Te=HM(me),Ve=(me==null?void 0:me.phase)==="completed";p.useEffect(()=>{let ye=!1;return C(null),J!=null&&J.id&&e.api.sessionList().then(({sessions:yt})=>{ye||C(yt.find(Vn=>{var eo;return Vn.testReleaseId===J.id&&Vn.cloudExpectedImage===((eo=J.verified)==null?void 0:eo.image)})??null)}).catch(()=>{}),()=>{ye=!0}},[e.api,J==null?void 0:J.id,(Zf=J==null?void 0:J.verified)==null?void 0:Zf.image]);const ge=async()=>{if(J!=null&&J.id){I(!0),T(null);try{const ye=await w(J.id),eo=(await e.api.sessionList()).sessions.find(dl=>dl.testReleaseId===J.id&&dl.cloudExpectedImage===ye.expectedImage&&dl.ownerPersonaId===ye.personaId)??await e.api.sessionCreate({ownerPersonaId:ye.personaId,label:"测试 · "+e.personaId});C(eo)}catch(ye){T(ye instanceof Error?ye.message:String(ye))}finally{I(!1)}}},Ne=async()=>{if(!(J!=null&&J.id)||L.current||Te||Ve||U.current)return;const ye={releaseId:J.id};L.current=ye,F(!0),P(null);try{if((z==null?void 0:z.productionChannelId)!==void 0){if(await f(z.productionChannelId===null?null:{channelId:z.productionChannelId},"production"),L.current!==ye)return;V(yt=>({...yt,productionChannelId:void 0}))}await v(J.id)}catch(yt){L.current===ye&&P({releaseId:ye.releaseId,message:yt instanceof Error?yt.message:String(yt)})}finally{L.current===ye&&(L.current=null,F(!1))}},{status:Me,startOauth:Ue,authorize:ut}=jX(),Ct=p.useCallback(async()=>{const ye=await Ue();return await o(),ye},[Ue,o]),Nt=p.useCallback(async ye=>{await ut(ye),await o()},[ut,o]),ne=(Me==null?void 0:Me.status)==="authorized";p.useEffect(()=>{ne&&o()},[ne,o]);const{persona:re,refresh:Ee}=DM(e.personaId),Ae=re?{...re,...z==null?void 0:z.patch}:void 0,et=Ae?R7(Ae):void 0,qe=(z==null?void 0:z.concurrency)??String((re==null?void 0:re.taskConcurrency)??4),tt=/^\d+$/.test(qe.trim())&&Number.isSafeInteger(Number(qe))&&Number(qe)>0,Pt=(z==null?void 0:z.concurrency)!==void 0&&(!tt||Number(qe)!==((re==null?void 0:re.taskConcurrency)??4)),wt=(z==null?void 0:z.channelId)!==void 0||Pt||Object.entries((z==null?void 0:z.patch)??{}).some(([ye,yt])=>JSON.stringify(yt)!==JSON.stringify(re==null?void 0:re[ye])),_e=re?Pce(re):void 0,Le=wt?"配置有未保存的修改,请先保存配置":TPe(NX({current:_e,release:Z==null?void 0:Z.release,run:((lv=(sd=t==null?void 0:t.targets)==null?void 0:sd.integration)==null?void 0:lv.run)??(t==null?void 0:t.run),anchored:!!J})),dt=(et==null?void 0:et.tool)==="claude",{capabilities:ot}=ni(et&&il(et.tool)?et.tool:null),dn=APe(e.api,et==null?void 0:et.tool),[ke,ie]=p.useState([]),De=p.useRef(0),rt=p.useCallback(async()=>{const ye=++De.current,yt=await e.api.subscriptionChannelGet();De.current===ye&&ie(yt.channels)},[e.api]);p.useEffect(()=>(rt().catch(()=>{}),()=>{De.current++}),[rt]);const ht=ke.find(ye=>ye.id===(z==null?void 0:z.channelId)),jt=async ye=>{const yt=await e.api.subscriptionChannelSave(ye);De.current++,ie(yt.channels);const Vn=[...yt.channels].reverse().find(eo=>eo.name===ye.name&&eo.baseUrl===_ce(ye.baseUrl));if(!Vn)throw new Error("通道已保存,请刷新列表后选择");return Vn},Bt=(z==null?void 0:z.channelId)===void 0?(cv=t==null?void 0:t.engineChannels)==null?void 0:cv.integration:z.channelId===null?null:{channelId:z.channelId,...ht?{updatedAt:ht.updatedAt}:{}},hn=BPe(e.api,Bt),[jn,Xn]=p.useState(!1),[zt,pe]=p.useState(!1),[ct,on]=p.useState(null),[Xt,lr]=p.useState(null),[Zn,Ft]=p.useState(null),Dt=ye=>ye instanceof Error?ye.message:String(ye),Fn=async ye=>{const yt=ae.current;t&&(ae.current=t.releases.length),G(!0),on(null),lr(null),T(null),P(null);try{await u(ye)}catch(Vn){ae.current=yt,on(Dt(Vn))}finally{G(!1)}},Qn=async ye=>{if(!U.current){Xn(!0),lr(null),Ft(null);try{await m(ye)}catch(yt){lr(Dt(yt))}finally{Xn(!1)}}},Us=async ye=>{var yt,Vn,eo,dl;lr(null);try{await g(ye)}catch(Jf){!((eo=(Vn=(yt=t==null?void 0:t.targets)==null?void 0:yt.integration)==null?void 0:Vn.run)!=null&&eo.jobs.some(Tc=>Tc.jobId===ye))&&!((dl=t==null?void 0:t.run)!=null&&dl.jobs.some(Tc=>Tc.jobId===ye))&&lr(Dt(Jf))}},Ec=async()=>{pe(!0),Ft(null);try{await y()}catch(ye){Ft(Dt(ye).replace(/^[A-Z_]+: /,""))}finally{pe(!1)}},cr=ye=>{te.current!==e.personaId||L.current||Te||U.current||jn||l||(q(null),V(yt=>({...yt.personaId===e.personaId?yt:{personaId:e.personaId,patch:{}},...ye})))},Ss=ye=>{const yt="tool"in ye?{tool:ye.tool,model:ye.tool===((re==null?void 0:re.tool)??"claude")?re==null?void 0:re.model:void 0,effort:ye.tool===((re==null?void 0:re.tool)??"claude")?re==null?void 0:re.effort:void 0}:dt?{cloudEngine:{...Ae==null?void 0:Ae.cloudEngine,...ye}}:ye;cr({patch:{...z==null?void 0:z.patch,...yt}})},Zi=async()=>{if(U.current||!wt||!tt)return;const ye={};U.current=ye,D(!0),q(null);try{if((z==null?void 0:z.channelId)!==void 0&&(await f(z.channelId===null?null:{channelId:z.channelId}),U.current!==ye))return;const yt={...z==null?void 0:z.patch,...Pt?{taskConcurrency:Number(qe)}:{}};if(Object.keys(yt).length>0){const Vn=await e.api.personaUpdate(e.personaId,yt);if(U.current!==ye)return;Ee(Vn).catch(()=>{})}V(Vn=>Vn===z?{personaId:e.personaId,patch:{},productionChannelId:Vn.productionChannelId}:Vn)}catch(yt){U.current===ye&&q(Dt(yt))}finally{U.current===ye&&(U.current=null,D(!1))}};if(s&&!t)return a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-text-400",children:[a.jsx(st,{className:"size-4 animate-spin"}),"正在打开"]});if(i&&!t)return a.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-error",children:i});if(!t)return null;const Ws=kc(t.scans);return a.jsx(kDe,{state:t,..._e?{currentConfig:_e}:{},onApplyConfig:x,integrationLogin:S.identity?a.jsxs("div",{className:"text-xs text-text-400",children:["测试环境 · 已登录 ",S.identity.displayName]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(ze,{size:"sm",onClick:()=>{S.login().then(ye=>window.open(ye,"_blank","noopener,noreferrer")).catch(ye=>T(ye instanceof Error?ye.message:String(ye)))},children:"用当前飞书账号登录测试环境"}),S.error&&a.jsx("div",{className:"text-error",children:S.error})]}),testActions:a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex flex-wrap gap-2",children:a.jsx(ze,{size:"sm",onClick:()=>void ge(),disabled:!be||E,children:"打开测试对话(可选)"})}),j&&a.jsx("div",{className:"text-error",children:j}),k&&k.testReleaseId===(J==null?void 0:J.id)&&a.jsx("div",{className:"h-[480px] overflow-hidden rounded-lg border border-border",children:a.jsx(S_,{extras:{session:k,api:e.api,hideHeader:!0}},k.sessionId)})]}),productionActions:a.jsxs("div",{className:"space-y-3",children:[ce&&a.jsxs("details",{children:[a.jsx("summary",{className:"cursor-pointer",children:"线上环境的凭据"}),a.jsxs("fieldset",{disabled:O||Te||B,children:[a.jsx("div",{className:"text-xs text-text-400",children:"在这里填写线上使用的账号。测试环境的账号单独保存。"}),[...ce.manifest.secrets,...bw(ce.manifest)].map(ye=>a.jsx(xE,{secret:ye,presence:se,onSubmitValues:yt=>h(ce.id,ye.name,yt,"production")},ye.name)),a.jsx(_X,{disabled:O||Te||B,state:se?$b(se):void 0,channels:ke,channelId:(z==null?void 0:z.productionChannelId)!==void 0?z.productionChannelId:((uv=t.engineChannels)==null?void 0:uv.production)===null?null:(Qf=(gi=t.engineChannels)==null?void 0:gi.production)==null?void 0:Qf.channelId,onRefreshChannels:rt,onAddChannel:jt,onChange:ye=>cr({productionChannelId:(ye==null?void 0:ye.channelId)??null})})]})]}),Le&&a.jsx("div",{className:"text-warning",children:Le}),!Le&&!he&&oe&&a.jsx("div",{className:"text-warning",children:"先填齐线上环境的凭据,再上线。"}),a.jsx(ze,{size:"sm",onClick:()=>void Ne(),disabled:!oe||!!Le||!he||O||Te||Ve||B,children:O?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"mr-1.5 size-3.5 animate-spin"}),"正在提交上线"]}):Te?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"mr-1.5 size-3.5 animate-spin"}),"正在上线"]}):Ve?"已上线":"上线"})]}),starting:X,releasing:jn,awaitingRun:l,retry:c,promoting:O,productionError:(R==null?void 0:R.releaseId)===(J==null?void 0:J.id)&&!Te&&!Ve?R==null?void 0:R.message:void 0,onRefreshRetry:()=>void o(),busy:zt||O||Te,scanError:ct??(!n&&r?`读不到线上状态(${r}),先只显示本机已知的内容;关掉再打开发布页可重试。`:null),releaseError:Xt,onScan:ye=>void Fn(ye),onRelease:ye=>void Qn(ye),onRetryJob:ye=>void Us(ye),onPutSecret:h,onChangeEngineAuth:ye=>cr({channelId:(ye==null?void 0:ye.channelId)??null}),engineChannelId:(z==null?void 0:z.channelId)!==void 0?z.channelId:((id=t.engineChannels)==null?void 0:id.integration)===null?null:(od=(Ic=t.engineChannels)==null?void 0:Ic.integration)==null?void 0:od.channelId,configDirty:wt,configError:$,onSaveConfig:()=>void Zi(),channels:ke,onRefreshChannels:rt,onAddChannel:jt,onRefreshPublisherAuth:()=>void o(),onPatchConnector:(ye,yt)=>{on(null),d(ye,{connector:yt}).then(()=>yt.protocol==="lark-sidecar"&&yt.credentialSource==="shared"?o():void 0).catch(Vn=>on(Dt(Vn)))},onAuthorizeGithub:Nt,onStartGithubOauth:Ct,...et?{engine:et}:{},localEngineVersion:dn,...(Ae==null?void 0:Ae.size)!==void 0?{size:Ae.size}:{},...(Ae==null?void 0:Ae.cpu)!==void 0?{cpu:Ae.cpu}:{},resourceSaving:B,onChangeSize:ye=>cr({patch:{...z==null?void 0:z.patch,size:ye}}),onChangeCpu:ye=>cr({patch:{...z==null?void 0:z.patch,cpu:ye}}),...re?{taskConcurrency:re.taskConcurrency,taskConcurrencyDraft:qe,onChangeTaskConcurrency:ye=>cr({concurrency:ye})}:{},engineEditor:{modelList:hn,...Bt?{}:{allowManualModel:!0},configSchema:(ot==null?void 0:ot.configSchema)??[],onChange:Ss},roundIdx:ae.current??Ay(t),...MPe(t)||b!==void 0?{live:{status:WM(t,b),error:Zn,onUnpublish:()=>void Ec()}}:{},...e.cloud?{cloud:e.cloud}:{},...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{},...Ws!=null&&Ws.scanSessionId?{workPanel:a.jsx(EDe,{api:e.api,sessionId:Ws.scanSessionId,live:Ws.status==="scanning"})}:{}},e.personaId)}function BX(e,t,n){const r=Un(),[s,i]=p.useState({}),o=p.useRef(0),l=p.useRef(new Set);return p.useEffect(()=>{o.current++,l.current=new Set,i({})},[e]),p.useEffect(()=>{if(!n||!e)return;const c=t.filter(h=>!l.current.has(cn(h)));if(c.length===0)return;for(const h of c)l.current.add(cn(h));i(h=>({...h,...Object.fromEntries(c.map(f=>[cn(f),"loading"]))}));const u=o.current,d=new Wt(r);for(const h of c)d.deployGet(e,h.id?{releaseId:h.id,environment:h.environment}:{releaseHead:h.head}).then(f=>u===o.current&&i(m=>({...m,[cn(h)]:f.run})),()=>u===o.current&&i(f=>({...f,[cn(h)]:void 0})))},[r,e,t,n]),s}function FX(e){const{slot:t}=e;return t==="loading"?a.jsx(st,{className:"size-3 animate-spin text-text-400","aria-label":"查流水线"}):t===void 0?a.jsx("span",{className:"text-text-400",children:"查不到"}):t.status!=="completed"?a.jsxs("span",{className:"inline-flex items-center gap-1 text-accent",children:[a.jsx(st,{className:"size-3 animate-spin"}),"进行中"]}):sc(t)?a.jsxs("span",{className:"inline-flex items-center gap-1 text-success",children:[a.jsx(Gt,{className:"size-3"}),"成功"]}):a.jsxs("span",{className:"inline-flex items-center gap-1 text-error",children:[a.jsx(Yt,{className:"size-3"}),"失败"]})}function TDe(e){const{releases:t,scans:n}=e,[r,s]=p.useState(!1),i=UM(t,e.runs,e.online),o=ya(t),l=m=>m===o||m===i||kX(m,e.runs)||cn(m)===e.selectedHead,c=t.map((m,g)=>({r:m,n:g+1})).reverse(),u=r?c:c.filter(({r:m})=>l(m)),d=c.length-u.length,h=e.repo?$h(e.repo.url):void 0,f=m=>n.find(g=>g.id===m.scanId);return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Yr,{icon:a.jsx(q5,{className:"size-[18px]"}),title:"发布历史",count:`${t.length} 次`}),a.jsxs("ul",{className:"divide-y divide-border-card","data-testid":"release-history",children:[u.map(({r:m,n:g})=>{const x=cn(m)===e.selectedHead,b=f(m);return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>e.onSelect(cn(m)),"aria-current":x,"aria-label":`第 ${g} 次发布`,className:`flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left text-[13px] transition-colors ${x?"bg-accent-dim/60":"hover:bg-text-100-dim/40"}`,children:[a.jsxs("span",{className:"w-8 shrink-0 font-mono text-xs text-text-400",children:["#",g]}),a.jsx("span",{className:"shrink-0 tabular-nums text-text-200",children:nf(m.at)}),h?a.jsxs("a",{href:`https://github.com/${h}/commit/${m.head}`,target:"_blank",rel:"noreferrer",onClick:y=>y.stopPropagation(),className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-accent hover:underline",children:[m.head.slice(0,7),a.jsx(Lr,{className:"size-3"})]}):a.jsx("span",{className:"shrink-0 font-mono text-xs text-text-400",children:m.head.slice(0,7)}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-text-400",children:b?`${b.baseKind==="soft"?"软扫":"硬扫"} · ${nf(b.startedAt)}`:"扫描记录已丢"}),m.environment&&a.jsx("span",{className:"shrink-0 text-xs text-text-400",children:m.environment==="integration"?"测试":"线上发布"}),i&&cn(i)===cn(m)&&a.jsx("span",{className:"shrink-0 rounded-full bg-success-dim px-1.5 py-0.5 text-[11px] font-medium text-success",children:"线上"}),a.jsx("span",{className:"w-28 shrink-0 text-right text-xs",children:a.jsx(FX,{slot:e.runs[cn(m)]})})]})},cn(m))}),d>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>s(!0),className:"flex w-full cursor-pointer items-center gap-1.5 px-4 py-2 text-xs text-text-400 hover:bg-text-100-dim/40 hover:text-text-200",children:[a.jsx(Jt,{className:"size-3.5"}),"还有 ",d," 次发布"]})})]})]})}function R0(e){return a.jsx("div",{className:"rounded-lg border border-border-card bg-surface-card",children:e.children})}function MDe(e){const{scan:t}=e,n=t.manifest,r=s=>t.evidence.find(i=>i.target===s);return a.jsxs(a.Fragment,{children:[n.packages.length>0&&a.jsxs(R0,{children:[a.jsx(Yr,{icon:a.jsx(kw,{className:"size-[18px]"}),title:"镜像",count:`${n.packages.length} 项`}),n.packages.map(s=>a.jsx(PX,{name:s.name,version:s.version,min:s.min,localVersion:s.localVersion,from:s.from,aptVersion:s.aptVersion,aptMissing:s.aptMissing,artifact:s.artifact,evidence:r(`package:${s.name}`)},s.name))]}),n.connectors.length>0&&a.jsxs(R0,{children:[a.jsx(Yr,{icon:a.jsx(Cw,{className:"size-[18px]"}),title:"连接器",count:`${n.connectors.length} 个`}),n.connectors.map(s=>a.jsxs("div",{className:"flex items-baseline gap-3 border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsx("span",{className:"text-[15px] font-semibold",children:s.name}),a.jsx("span",{className:"text-xs text-text-400",children:DX(s)}),a.jsxs("span",{className:"ml-auto text-xs text-text-300",children:[s.credentialSource?bE[s.credentialSource].label:"—",s.credentialSource==="personal"&&s.auth?` · ${$y[s.auth].label}`:"",s.fields.length>0&&(s.credentialSource==="shared"||s.auth==="fields")?` · ${s.fields.join(" / ")}`:""]})]},s.name))]}),n.secrets.length>0&&a.jsxs(R0,{children:[a.jsx(Yr,{icon:a.jsx(gg,{className:"size-[18px]"}),title:"凭据",count:`${n.secrets.length} 条`}),n.secrets.map(s=>a.jsxs("div",{className:"flex items-baseline gap-3 border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsx("span",{className:"text-[15px] font-semibold",children:s.name}),a.jsx("span",{className:"ml-auto font-mono text-xs text-text-300",children:s.env.join(" / ")})]},s.name))]}),n.test&&a.jsx(LX,{test:n.test}),t.notes.length>0&&a.jsxs(R0,{children:[a.jsx(Yr,{icon:a.jsx(Sn,{className:"size-[18px]"}),title:"存疑项",count:`${t.notes.length} 条`,tone:"warning"}),a.jsx("div",{className:"space-y-2 px-5 py-4",children:t.notes.map((s,i)=>a.jsxs("div",{className:"flex gap-2 text-[13px] leading-snug text-text-300",children:[a.jsx("span",{className:"shrink-0 text-warning",children:"•"}),s]},i))})]})]})}function RDe(e){const{state:t,runs:n}=e,{releases:r,scans:s,repo:i}=t,[o,l]=p.useState(e.initialHead??null),c=(o?r.find(w=>cn(w)===o):void 0)??ya(r),u=c?r.indexOf(c)+1:0,d=UM(r,n,t.online),h=i?$h(i.url):void 0,f=c?s.find(w=>w.id===c.scanId):void 0,m=c?n[cn(c)]:void 0,g=m==="loading"?void 0:m,x=c?RX({personaId:t.personaId,frozen:!0,live:d!==void 0&&cn(d)===cn(c),offline:t.online===!1,scans:f?[f]:[],released:c,...g?{run:g}:{},blockers:[]}):[],[b,y]=p.useState(null),v=b&&c&&b.head===cn(c)?b.key:g1(x)??"scan";return a.jsx("div",{className:"flex h-full overflow-hidden bg-surface-page text-text-100",children:a.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 px-6 py-8",children:[a.jsx("div",{className:"sticky top-0 z-10 -mx-6 bg-surface-page/95 px-6 py-2 backdrop-blur",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(q5,{className:"size-5 text-accent"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-medium",children:"发布历史"}),a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs text-text-400",children:[a.jsx("span",{className:"truncate",title:t.personaId,children:t.personaId}),h&&i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx(wu,{className:"size-3 shrink-0"}),a.jsx("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"truncate hover:text-accent hover:underline",children:h})]}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",children:"只读"})]})]})]})}),r.length===0&&a.jsx("div",{className:"rounded-lg border border-border-card bg-surface-card px-5 py-6 text-[13px] text-text-300",children:"还没发布过。去 persona 卡片上点「发布到云上」,从扫描开始。"}),r.length>0&&a.jsx(TDe,{releases:r,scans:s,runs:n,...i?{repo:i}:{},...c?{selectedHead:cn(c)}:{},...t.online!==void 0?{online:t.online}:{},onSelect:w=>{l(w),y(null)}}),c&&a.jsxs("div",{className:"rounded-lg border border-accent/40 bg-surface-card",children:[a.jsx(Yr,{icon:a.jsx(vy,{className:"size-[18px]"}),title:`第 ${u} 次发布`,count:nf(c.at),tone:"accent"}),a.jsx("div",{className:"px-5 py-4",children:a.jsx(TX,{stages:x,activeKey:v,onPick:w=>y({head:cn(c),key:w})},cn(c))})]}),f&&a.jsx(MDe,{scan:f})]})})})}function PDe(e){const{state:t,loading:n,error:r}=VM(e.personaId),s=(t==null?void 0:t.releases)??[],i=BX(e.personaId,s,t!==null);if(n&&!t)return a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-text-400",children:[a.jsx(st,{className:"size-4 animate-spin"}),"正在打开"]});if(r&&!t)return a.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-error",children:r});if(!t)return null;const o=ya(s),l=o&&Pu(o,t.run)?{...i,[cn(o)]:t.run}:i;return a.jsx(RDe,{state:t,runs:l,...e.initialHead?{initialHead:e.initialHead}:{}})}const SC=10*60*1e3,dL=["bg-rose-500","bg-orange-500","bg-amber-500","bg-lime-500","bg-emerald-500","bg-cyan-500","bg-blue-500","bg-violet-500","bg-fuchsia-500"];function DDe(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return dL[Math.abs(t)%dL.length]}function ODe(e){const t=e.trim();if(!t)return"?";const n=t.split(/\s+/);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():t.slice(0,2).toUpperCase()}function wE(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ADe(e){const t=new Date(e),n=new Date,r=t.toDateString()===n.toDateString(),s=new Date(n);s.setDate(s.getDate()-1);const i=t.toDateString()===s.toDateString();return r?`今天 ${wE(e)}`:i?`昨天 ${wE(e)}`:t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function $De(e){const t=[];let n;for(let r=0;r<e.length;r++){const s=e[r];(!n||s.createdAt-n.createdAt>=SC)&&t.push({kind:"divider",divider:s.createdAt});const i=!!n&&n.fromOwner===s.fromOwner&&s.createdAt-n.createdAt<SC,o=e[r+1],l=o&&o.fromOwner===s.fromOwner&&o.createdAt-s.createdAt<SC;t.push({kind:"bubble",msg:s,showAvatar:!i,isLast:!l}),n=s}return t}function LDe({thread:e,messages:t,selfDisplayName:n,onSend:r,readOnlyHint:s}){const[i,o]=p.useState(""),l=p.useRef(null),c=p.useRef(null),u=p.useMemo(()=>$De(t),[t]);p.useEffect(()=>{const m=c.current;m&&(m.scrollTop=m.scrollHeight)},[t.length]);const d=()=>{const m=l.current;m&&(m.style.height="auto",m.style.height=Math.min(m.scrollHeight,160)+"px")};p.useEffect(()=>{d()},[i]);const h=()=>{const m=i.trim();m&&(r==null||r(m),o(""),l.current&&(l.current.value=""))},f=fi(h);return a.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full bg-bg-100",children:[a.jsxs("header",{className:"px-4 py-3 border-b border-border bg-elevated flex items-center gap-3 shrink-0",children:[a.jsx(qM,{name:e.peerDisplayName,size:"md"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h2",{className:"text-sm font-semibold text-text-100 leading-tight",children:e.peerDisplayName}),a.jsx("p",{className:"text-[11px] text-text-400 mt-0.5 flex items-center gap-1.5",children:s?a.jsx("span",{children:"访客"}):e.peerOnline?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-emerald-500"}),a.jsx("span",{children:"在线"})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-text-400"}),a.jsx("span",{children:"离线"})]})})]}),a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("button",{className:"p-2 rounded text-text-400 hover:bg-bg-200 hover:text-text-100 transition-colors",children:a.jsx(che,{className:"h-4 w-4"})})})]}),a.jsx("div",{ref:c,className:"flex-1 overflow-auto px-4 py-3 flex flex-col gap-1",children:t.length===0?a.jsx(BDe,{peerName:e.peerDisplayName}):u.map((m,g)=>m.kind==="divider"?a.jsx("div",{className:"flex items-center justify-center my-3",children:a.jsx("span",{className:"text-[10px] text-text-400 bg-bg-100 px-2 py-0.5 rounded-full",children:ADe(m.divider)})},`d-${g}`):a.jsx(FDe,{msg:m.msg,peerName:e.peerDisplayName,selfName:n,showAvatar:m.showAvatar,isLast:m.isLast},m.msg.id))}),!e.peerOnline&&!s&&a.jsxs("div",{className:"px-4 py-1.5 bg-amber-50 border-t border-amber-100 text-[11px] text-amber-900 shrink-0",children:[e.peerDisplayName," 离线,发出的消息会标记为失败"]}),s?a.jsx("footer",{"data-testid":"dm-readonly-hint",className:"px-4 py-3 border-t border-border bg-elevated shrink-0 text-[12px] text-text-400 text-center",children:s}):a.jsxs("footer",{className:"px-4 py-3 border-t border-border bg-elevated shrink-0",children:[a.jsxs("div",{className:"flex items-end gap-2 rounded-lg border border-border bg-bg-50 focus-within:border-accent focus-within:ring-1 focus-within:ring-accent transition-colors px-3 py-2",children:[a.jsx("textarea",{ref:l,rows:1,placeholder:`给 ${e.peerDisplayName} 发消息...`,value:i,onChange:m=>o(m.target.value),...f,className:"flex-1 resize-none bg-transparent text-sm text-text-100 placeholder:text-text-400 focus:outline-none leading-relaxed py-0.5",style:{maxHeight:160}}),a.jsx(ze,{size:"sm",variant:i.trim()?"default":"ghost",disabled:!i.trim(),onClick:h,className:"h-8 w-8 p-0 shrink-0",children:a.jsx(Nw,{className:"h-4 w-4"})})]}),a.jsxs("p",{className:"text-[10px] text-text-400 mt-1.5 px-1",children:[a.jsx("kbd",{className:"font-mono",children:"Enter"})," 发送 · ",a.jsx("kbd",{className:"font-mono",children:"Shift"}),"+",a.jsx("kbd",{className:"font-mono",children:"Enter"})," 换行"]})]})]})}function BDe({peerName:e}){return a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-4 py-8",children:[a.jsx(qM,{name:e,size:"xl"}),a.jsx("p",{className:"text-sm text-text-200 mt-4",children:e}),a.jsx("p",{className:"text-xs text-text-400 mt-1",children:"这是你们之间的开始 — 打个招呼吧"})]})}function FDe({msg:e,peerName:t,selfName:n,showAvatar:r,isLast:s}){const i=e.fromOwner,o=i?n:t;return a.jsxs("div",{className:Q("group flex items-start gap-2",i?"flex-row-reverse":"flex-row",r?"mt-2":"mt-0.5"),children:[a.jsx("div",{className:"w-7 shrink-0",children:r&&o?a.jsx(qM,{name:o,size:"sm"}):null}),a.jsxs("div",{className:Q("flex flex-col max-w-[70%] min-w-0",i?"items-end":"items-start"),children:[a.jsxs("div",{className:Q("px-3 py-1.5 break-words",i?"bg-accent text-accent-contrast":"bg-bg-200 text-text-100",i?Q("rounded-2xl",s?"rounded-br-md":"rounded-br-2xl",r?"rounded-tr-2xl":"rounded-tr-md"):Q("rounded-2xl",s?"rounded-bl-md":"rounded-bl-2xl",r?"rounded-tl-2xl":"rounded-tl-md")),children:[e.personaOrigin&&a.jsx("span",{"data-testid":"dm-persona-origin",className:Q("block text-[10px] mb-0.5 opacity-80",i?"text-accent-contrast":"text-text-300"),children:`${e.personaOrigin} 助手代发`}),a.jsx("p",{className:"text-[13.5px] leading-relaxed whitespace-pre-wrap",children:e.text})]}),a.jsxs("div",{className:Q("flex items-center gap-1 px-1 mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity",i?"flex-row-reverse":""),children:[a.jsx("span",{className:"text-[10px] text-text-400",children:wE(e.createdAt)}),i&&a.jsx(zDe,{status:e.deliveryStatus})]})]})]})}function zDe({status:e}){return e==="sending"?a.jsx(F5,{className:"h-3 w-3 text-text-400"}):e==="sent"?a.jsx(Gt,{className:"h-3 w-3 text-text-400"}):e==="delivered"?a.jsx($de,{className:"h-3 w-3 text-text-400"}):e==="failed"?a.jsx(fa,{className:"h-3 w-3 text-destructive"}):null}function qM({name:e,size:t="sm"}){const n=t==="xl"?"h-16 w-16 text-xl":t==="md"?"h-9 w-9 text-sm":"h-7 w-7 text-[11px]";return a.jsx("div",{className:Q("rounded-full flex items-center justify-center text-white font-semibold shrink-0",DDe(e),n),children:ODe(e)})}const HDe="访客消息由 persona 代发,这里不能回复——请到对应会话里处理";function UDe(e,t,n){var s;const r=e.senderDeviceId===t;return{id:e.id,threadId:e.peerDeviceId,fromOwner:r,fromDisplayName:r?void 0:n,text:e.text,createdAt:e.createdAt,deliveryStatus:r?"delivered":void 0,personaOrigin:((s=e.origin)==null?void 0:s.kind)==="persona"?e.origin.personaId:void 0}}function WDe({contact:e,im:t,selfPrincipalId:n,selfDisplayName:r,readOnly:s}){const i=t.ensurePeerLoaded;p.useEffect(()=>{i(e.deviceId)},[e.deviceId,i]);const o=p.useRef(new Map),l=t.messagesByPeerDeviceId.get(e.deviceId)??[],c=l.length>0?l[l.length-1].createdAt:0;p.useEffect(()=>{c===0||(o.current.get(e.deviceId)??0)>=c||(o.current.set(e.deviceId,c),t.markRead(e.deviceId,c))},[e.deviceId,c,t]);const u=p.useMemo(()=>(t.messagesByPeerDeviceId.get(e.deviceId)??[]).map(m=>UDe(m,n,e.displayName)),[t.messagesByPeerDeviceId,e.deviceId,e.displayName,n]),d=t.statusByPeerDeviceId.get(e.deviceId)==="connected",h={threadId:e.deviceId,peerAlias:e.deviceId,peerDisplayName:e.displayName,lastMessageAt:u.length>0?u[u.length-1].createdAt:0,lastMessagePreview:u.length>0?u[u.length-1].text:"",unreadCount:0,peerOnline:d};return a.jsx(LDe,{thread:h,messages:u,selfDisplayName:r,onSend:s?void 0:f=>void t.sendMessage(e.deviceId,f),readOnlyHint:s?HDe:void 0})}function VDe({status:e,onRetry:t,topBanner:n}){if(e.kind==="starting")return a.jsxs("div",{"data-testid":"extension-iframe-starting",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-bg-50",children:[a.jsx(st,{className:"w-6 h-6 text-text-300 animate-spin"}),a.jsxs("div",{className:"text-[13px] text-text-200",children:["Starting ",e.name,"…"]}),a.jsx("div",{className:"text-[11px] text-text-400/80",children:"spawning child process"})]});if(e.kind==="error")return a.jsxs("div",{"data-testid":"extension-iframe-error",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-bg-50 px-8",children:[a.jsx(Sn,{className:"w-6 h-6 text-red-400"}),a.jsxs("div",{className:"text-[13px] text-text-100",children:["Failed to start ",e.name]}),a.jsx("div",{className:"text-[11px] text-text-400/90 max-w-md text-center font-mono",children:e.message}),a.jsxs("button",{type:"button",onClick:t,"data-testid":"extension-iframe-retry",className:Q("mt-1 flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[12px]","border border-border text-text-200 hover:text-text-100 hover:bg-text-100/5 transition-colors"),children:[a.jsx(wf,{className:"w-3.5 h-3.5"}),"Retry"]})]});const r=e.target.kind==="local"?`http://127.0.0.1:${e.target.port}/`:e.target.url;return a.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n,a.jsx("iframe",{"data-testid":"extension-iframe-running","data-target-kind":e.target.kind,title:e.name,src:r,className:"flex-1 w-full h-full border-0 bg-bg-50",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox"})]})}function qDe({state:e,onUpdate:t,onDismiss:n,onViewLogs:r}){if(e.kind==="idle")return null;const s=YDe(e.kind);return a.jsxs("div",{"data-testid":"update-available-banner","data-state":e.kind,className:Q("flex items-center gap-2 px-4 h-9 shrink-0 text-[12px] border-b",s.className),children:[a.jsx(s.Icon,{className:Q("w-3.5 h-3.5 shrink-0",s.iconClassName),"aria-hidden":!0}),a.jsx("span",{className:"truncate flex-1",children:KDe(e)}),GDe(e,{onUpdate:t,onDismiss:n,onViewLogs:r})]})}function KDe(e){switch(e.kind){case"available":return`${e.extName} 有新版 v${e.toVersion}(当前 v${e.fromVersion})`;case"updating":{const t={fetching:"拉取中",extracting:"应用中",restarting:"重启中"}[e.step];return`正在更新 ${e.extName} → v${e.toVersion}(${t}…)`}case"success":return`${e.extName} 已更新到 v${e.toVersion}`;case"failed-rollback":return`${e.extName} v${e.attemptedVersion} 启动失败,已回退到 v${e.rolledBackTo}`}}function GDe(e,{onUpdate:t,onDismiss:n,onViewLogs:r}){return e.kind==="available"?a.jsxs(a.Fragment,{children:[a.jsx(hL,{tone:"accent",onClick:t,testId:"update-banner-update",children:"更新"}),a.jsx(kC,{onClick:n})]}):e.kind==="success"?a.jsx(kC,{onClick:n}):e.kind==="failed-rollback"?a.jsxs(a.Fragment,{children:[r?a.jsx(hL,{tone:"error",onClick:r,testId:"update-banner-view-logs",children:"查看日志"}):null,a.jsx(kC,{onClick:n})]}):null}function hL({tone:e,onClick:t,testId:n,children:r}){const s=e==="accent"?"bg-accent/10 hover:bg-accent/20 text-accent border border-accent/30":"bg-error/10 hover:bg-error/20 text-error border border-error/30";return a.jsx("button",{type:"button",onClick:t,"data-testid":n,className:Q("inline-flex items-center gap-1 px-2 h-6 rounded-sm text-[11px] font-medium transition-colors",s),children:r})}function kC({onClick:e}){return a.jsx("button",{type:"button",onClick:e,"data-testid":"update-banner-dismiss",className:"inline-flex items-center justify-center w-5 h-5 text-text-400 hover:text-text-100 rounded-sm","aria-label":"dismiss",children:a.jsx(Yt,{className:"w-3 h-3"})})}function YDe(e){switch(e){case"available":return{Icon:hH,iconClassName:"",className:"bg-accent-dim text-accent border-accent/30"};case"updating":return{Icon:st,iconClassName:"animate-spin",className:"bg-warning-dim text-warning border-warning/30"};case"success":return{Icon:oi,iconClassName:"",className:"bg-success-dim text-success border-success/30"};case"failed-rollback":return{Icon:Sn,iconClassName:"",className:"bg-error-dim text-error border-error/30"}}}function XDe({client:e,extId:t,updateInfo:n,onApplyUpdate:r}){const[s,i]=p.useState({kind:"starting",name:t}),[o,l]=p.useState(null),[c,u]=p.useState(!1);p.useEffect(()=>{l(null),u(!1)},[t]);const d=p.useCallback(async()=>{let g=t;try{const b=(await e.request("extension.list",{})).extensions.find(y=>y.extId===t);b&&b.state!=="invalid"&&(g=b.manifest.name)}catch{}i({kind:"starting",name:g});try{const x=await e.request("extension.open",{extId:t});i({kind:"running",name:g,target:x})}catch(x){i({kind:"error",name:g,message:x.message})}},[e,t]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async()=>{if(!(!n||!r)){l({kind:"updating",extName:n.extName,toVersion:n.toVersion,step:"fetching"});try{const g=await r(n);g.kind==="updated"?(l({kind:"success",extName:n.extName,toVersion:g.installedVersion}),d()):l({kind:"failed-rollback",extName:n.extName,attemptedVersion:n.toVersion,rolledBackTo:g.rolledBackTo,reason:g.reason})}catch(g){l({kind:"failed-rollback",extName:n.extName,attemptedVersion:n.toVersion,rolledBackTo:n.fromVersion,reason:g.message})}}},[n,r,d]);let f={kind:"idle"};o?f=o:n&&!c&&(f={kind:"available",extName:n.extName,fromVersion:n.fromVersion,toVersion:n.toVersion});const m=f.kind==="idle"?null:a.jsx(qDe,{state:f,onUpdate:()=>void h(),onDismiss:()=>{l(null),u(!0)}});return a.jsx(VDe,{status:s,onRetry:()=>void d(),topBanner:m})}function ZDe(e){const t=new Map;return{observe(n,r){let s=t.get(n);s||(s={data:void 0,hasData:!1,listeners:new Set},t.set(n,s));const i=c=>r(c);s.listeners.add(i);const o=s.listeners.size===1;i(s.hasData?s.data:void 0),o&&e.onFirstObserver(n);let l=!1;return()=>{if(l)return;l=!0;const c=t.get(n);c&&(c.listeners.delete(i),c.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const s=t.get(n);if(!s)return;const i=s.hasData?s.data:void 0,o=r(i);s.data=o,s.hasData=!0;for(const l of s.listeners)l(o)}}}function QDe(){const e=[],t=new Map,n=r=>{for(const s of e)if(s.pattern.test(r))return s.source;return null};return{register(r,s){e.push({pattern:r,source:s})},activate(r){if(t.has(r))return;const s=n(r);if(!s)throw new Error(`no source registered for key: ${r}`);t.set(r,s.start(r))},deactivate(r){const s=t.get(r);s&&(t.delete(r),s())}}}function JDe(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of Y7)n.push(e.on(r,s=>t(r,s)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}const eOe=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:yG(e)});function tOe(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let s=!1;const i=async()=>{try{const l=await e.request("capabilities:get",{tool:r});if(s)return;t(n,()=>l)}catch{if(s)return;t(n,()=>eOe(r))}},o=e.onConnect(()=>{i()});return i(),()=>{s=!0,o()}}}}function nOe(e,t){return{start(n){let r=!1;const s=async()=>{try{const l=await e.request("session:list",void 0);if(r)return;t(n,()=>l.sessions??[])}catch{}},i=e.onFrame((l,c)=>{if(l==="session:info"){const u=c;if(u.chatId!==void 0)return;t(n,d=>[u,...(d??[]).filter(h=>h.sessionId!==u.sessionId)])}else if(l==="session:deleted"){const u=c;t(n,d=>(d??[]).filter(h=>h.sessionId!==u.sessionId))}}),o=e.onConnect(()=>{s()});return s(),()=>{r=!0,i(),o()}}}}const rOe="session/";function sOe(e){return{sid:e.slice(rOe.length)}}const iOe=new Set(A5);function zX(e){return iOe.has(e)}function fL(e){return zX(e)?e:"idle"}function oOe(e,t){return{start(n){const{sid:r}=sOe(n);let s=!1,i=-1;const o=f=>{t(n,m=>XV(m??Eg,f,r))},l=async f=>{const m=f==="baseline"?-1:i;try{const g=await e.request("session:events",{sessionId:r,afterSeq:m});if(s)return;const x=g.events??[],b=g.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:x,latestSeq:b}),i=b;else{const y=g.bufferStartSeq??0,v=b<m||y>m+1;o({type:v?"session:events":"session:events:append",sessionId:r,events:x,latestSeq:b}),i=Math.max(i,b)}}catch{}},c=async()=>{try{const f=await e.request("info");if(s)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(m=>({sessionId:m.sessionId,freshSpawn:m.freshSpawn,status:fL(m.status)}))})}catch{}},u=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}s||(await l(i<0?"baseline":"delta"),!s&&await c())},d=e.onFrame((f,m)=>{if(!s)if(f==="session:event"){const g=m;if(g.sessionId!==r)return;const x=g.event.seq;Pe("session-events","push session:event",{sid:r,kind:g.event.kind,seq:x,lastSeqBefore:i}),o({type:"session:event",sessionId:g.sessionId,event:g.event}),typeof x=="number"&&x>i&&(i=x)}else if(f==="session:status"){const g=m;if(g.sessionId!==r)return;if(!zX(g.status)){Pe("session-events","push session:status drop",{sid:r,status:g.status});return}Pe("session-events","push session:status",{sid:r,status:g.status}),o({type:"session:status",sessionId:g.sessionId,status:g.status})}else if(f==="session:cleared"){if(m.sessionId!==r)return;Pe("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),i=-1}else if(f==="session:queue"){const g=m;if(g.sessionId!==r)return;Pe("session-events","push session:queue",{sid:r,count:g.items.length}),o({type:"session:queue",sessionId:g.sessionId,items:g.items})}else if(f==="permission:request"){const g=m;if(g.sessionId!==r)return;o({type:"permission:request",sessionId:g.sessionId,requestId:g.requestId,tool:g.tool,input:g.input,...typeof g.toolUseId=="string"&&g.toolUseId?{toolUseId:g.toolUseId}:{}})}else if(f==="session:question"){const g=m;if(g.sessionId!==r)return;o({type:"session:question",sessionId:g.sessionId,toolUseId:g.toolUseId,requestId:g.requestId,questions:g.questions})}else if(f==="session:question:cleared"){const g=m;if(g.sessionId!==r)return;g.answers&&Object.keys(g.answers).length>0?o({type:"session:question:submitted",sessionId:g.sessionId,toolUseId:g.toolUseId,answers:g.answers}):o({type:"session:question:clear",sessionId:g.sessionId,toolUseId:g.toolUseId})}else if(f==="session:rewound"){const g=m;if(g.sessionId!==r)return;o({type:"session:rewound",sessionId:g.sessionId,userMessageId:g.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(m.runningSessions??[]).map(x=>({sessionId:x.sessionId,freshSpawn:x.freshSpawn,status:fL(x.status)}))})}),h=e.onConnect(()=>{u()});return e.isConnected&&u(),()=>{s=!0,d(),h(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const aOe=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function lOe(e,t){return{start(n){let r=!1;const s=async()=>{try{const l=await e.request("info",void 0);if(r)return;t(n,()=>l)}catch{}},i=e.onConnect(()=>{s()}),o=e.onFrame(l=>{aOe.has(l)&&s()});return s(),()=>{r=!0,i(),o()}}}}function cOe(){return{start(){return()=>{}}}}function uOe(e,t){return{start(n){let r=!1;const s=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},i=e.onConnect(()=>{s()});return s(),()=>{r=!0,i()}}}}function HX(e){const t=JDe(e),n=QDe();let r=null;const s=(o,l)=>{r==null||r.setData(o,l)};n.register(/^capabilities\//,tOe(t,s)),n.register(/^sessions$/,nOe(t,s)),n.register(/^session\//,oOe(t,s)),n.register(/^personas$/,uOe(t,s)),n.register(/^persona-detail\//,cOe()),n.register(/^daemon-info$/,lOe(t,s));const i=ZDe({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=i,{cache:i,channel:t}}function dOe({client:e,children:t}){const n=p.useMemo(()=>HX(e),[e]);return p.useEffect(()=>()=>{},[n]),a.jsx(fxe,{client:e,children:a.jsx(YV,{cache:n.cache,children:a.jsx(qK,{children:t})})})}function hOe(e,t){var g,x,b,y;const{models:n,modes:r,configSchema:s}=t,i=e.resolvedModel??e.model,o=Ox(i,n,s),l=o.options,c=l.some(v=>v.value===e.effort)?e.effort:o.defaultValue,u=e.effort===""&&e.resolvedEffort?((g=l.find(v=>v.value===e.resolvedEffort))==null?void 0:g.label)??e.resolvedEffort:((x=l.find(v=>v.value===c))==null?void 0:x.label)??null,d=((b=s.find(v=>v.name==="permissionMode"))==null?void 0:b.default)??"",h=r.some(v=>v.id===e.permissionMode)?e.permissionMode:d,m=h===d?null:((y=r.find(v=>v.id===h))==null?void 0:y.label)??null;return{modelLabel:N_(n,i),effortOptions:l,effortValue:c,effortLabel:u,modeValue:h,modeLabel:m,modeTone:m===null?null:h==="bypassPermissions"?"danger":"info"}}function UX({models:e,modelList:t,modes:n=[],configSchema:r=[],model:s,resolvedModel:i,resolvedEffort:o,effort:l,permissionMode:c,onPatch:u}){var b;const d=t??$Pe(e??[]),h=d.models,f=hOe({model:s,resolvedModel:i,resolvedEffort:o,effort:l,permissionMode:c},{models:h,modes:n,configSchema:r}),m=i??s,g=h.map(y=>{const v=y.id===""&&i?`${y.description?`${y.description};`:""}当前:${i}`:y.description;return{value:y.id,label:y.label,...v?{description:v}:{},...y.group?{group:y.group}:{}}}),x=n.map(y=>({value:y.id,label:y.label,...y.description?{description:y.description}:{}}));return a.jsxs(is,{children:[a.jsx(os,{asChild:!0,children:a.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[a.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:m||f.modelLabel}),f.effortLabel?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-500",children:"·"}),a.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:f.effortLabel})]}):null,f.modeLabel?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-500",children:"·"}),a.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":f.modeTone,className:Q("font-semibold",f.modeTone==="danger"?"text-red-400":"text-blue-400"),children:f.modeLabel})]}):null]})}),a.jsxs(zr,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[a.jsx(fOe,{list:d,current:s,currentLabel:f.modelLabel,options:g,onSelect:y=>u({model:y})}),a.jsx(pL,{testid:"session-config-effort",label:"Reasoning effort",current:f.effortValue,currentLabel:f.effortLabel??"—",options:f.effortOptions,onSelect:y=>u({effort:y})}),x.length>0?a.jsx(pL,{testid:"session-config-mode",label:"Permission mode",current:f.modeValue,currentLabel:((b=n.find(y=>y.id===f.modeValue))==null?void 0:b.label)??"—",currentTone:f.modeTone,options:x,onSelect:y=>u({permissionMode:y})}):null]})]})}function WX({label:e,currentLabel:t,currentTone:n}){return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"flex-1 text-text-200",children:e}),a.jsx("span",{className:Q("truncate max-w-[100px]",n==="danger"?"text-red-400 font-semibold":n==="info"?"text-blue-400 font-semibold":"text-text-400"),children:t}),a.jsx(Yn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]})}function fOe({list:e,current:t,currentLabel:n,options:r,onSelect:s}){const[i,o]=p.useState(!1),l=c=>{c&&!i&&e.load(),o(c)};return a.jsxs(yX,{open:i,onOpenChange:l,children:[a.jsx(BM,{"data-testid":"session-config-model",className:"gap-2 text-[12px]",children:a.jsx(WX,{label:"Model",currentLabel:n})}),a.jsx(FM,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:a.jsx(AX,{testid:"session-config-model",list:e,options:r,current:t,onSelect:s})})]})}function pL({testid:e,label:t,current:n,currentLabel:r,currentTone:s,options:i,onSelect:o}){const l=i.length===0;return a.jsxs(yX,{children:[a.jsx(BM,{"data-testid":e,disabled:l,className:"gap-2 text-[12px]",children:a.jsx(WX,{label:t,currentLabel:r,currentTone:s??null})}),a.jsx(FM,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:zM(i).map((c,u)=>{const d=c.value===n;return a.jsxs(K.Fragment,{children:[c.groupHeading?a.jsxs(a.Fragment,{children:[u>0?a.jsx(da,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:c.groupHeading})]}):null,a.jsxs(Tt,{"data-testid":`${e}-option-${c.value||"default"}`,onSelect:()=>o(c.value),className:"items-start gap-2",children:[a.jsxs("span",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:Q("block text-[12px]",d?"text-text-100 font-medium":"text-text-300"),children:c.label}),c.description?a.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:c.description}):null]}),d?a.jsx(Gt,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]})]},c.value||"default")})})]})}function pOe(e,t,n=0){const[r,s]=p.useState(null),[i,o]=p.useState(!1),l=p.useCallback(async()=>{if(!t){s(null);return}o(!0);try{const c=await e.getGitBranch(t);s(c.branch??null)}catch{s(null)}finally{o(!1)}},[e,t]);return p.useEffect(()=>{l()},[l,n]),{branch:r,loading:i,refresh:()=>void l()}}function mOe(e,t,n=0){const[r,s]=p.useState(null),[i,o]=p.useState(!1),l=p.useCallback(async()=>{if(!t){s(null);return}o(!0);try{const c=await e.getGitRoot(t);s(c.gitRoot??null)}catch{s(null)}finally{o(!1)}},[e,t]);return p.useEffect(()=>{l()},[l,n]),{worktreeRoot:r,loading:i,refresh:()=>void l()}}const gOe=5e3;function xOe(e,t,n=0){const[r,s]=p.useState(null);return p.useEffect(()=>{if(!t){s(null);return}let i=!1;const o=async()=>{try{const c=await e.cloudVolumeGet();i||s(c.volume??null)}catch{i||s(null)}},l=n>0?setTimeout(()=>void o(),gOe):null;return l||o(),()=>{i=!0,l&&clearTimeout(l)}},[e,t,n]),{volume:r}}const vOe=90;function yOe(e){return e.sizeBytes>0?Math.min(100,Math.max(0,Math.round(e.usedBytes/e.sizeBytes*100))):0}function mL(e){const t=e/1073741824;return t>=.1?`${t.toFixed(1)} GB`:`${Math.max(1,Math.round(e/1024**2))} MB`}function bOe({volume:e}){if(!e)return null;const t=yOe(e),n=t>=vOe?"warn":"ok",r=new Date(e.measuredAt).toLocaleString(),s=n==="ok"?"上一次任务结束时量的。":"盘快满了:在会话里说「清理一下云盘」,persona 会分析工作区里哪些能删、列给你确认后清掉。";return a.jsxs("span",{"data-testid":"chat-header-cloud-volume","data-tone":n,title:`云盘已用 ${mL(e.usedBytes)} / ${mL(e.sizeBytes)}(${r})。${s}`,className:Q("ml-1.5 inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded text-[11px] tabular-nums",n==="ok"&&"bg-text-100/10 text-text-400",n==="warn"&&"bg-warning-dim text-warning"),children:[a.jsx("span",{className:"relative inline-block w-8 h-1 rounded-full bg-current/20 overflow-hidden","aria-hidden":!0,children:a.jsx("span",{className:"absolute inset-y-0 left-0 rounded-full bg-current",style:{width:`${t}%`}})}),"云盘 ",t,"%"]})}function KM({api:e,session:t,focused:n,totalPanes:r,onFocus:s,onClose:i,onNewSession:o,onOpenConfig:l,onFork:c,onQuickAsk:u,className:d,viewerRole:h="owner",hideHeader:f}){const{capabilities:m}=ni(t.tool),g=_h(t.tool),[x,b]=p.useState(0),[y,v]=p.useState(n);K.useEffect(()=>{n&&v(!0)},[n]);const w=Pb(t.tool),_=w?void 0:t.cwd,{branch:S}=pOe(e,_,x),{worktreeRoot:k}=mOe(e,_,x),{volume:C}=xOe(e,w,x),j=r>1,T=E=>{e.sessionUpdate(t.sessionId,E).catch(I=>{console.error("[session-config] session:update failed",t.sessionId,I)})};return a.jsxs("div",{className:`group/pane relative flex-1 ${d??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${j?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:s,"data-testid":`session-pane-${t.sessionId}`,children:[a.jsx(Jw,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:a.jsx(qh,{id:"chat",minSize:"400px",children:a.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:(n||y)&&a.jsx(wOe,{api:e,session:t,focused:n,liveGitBranch:S,liveWorktreeRoot:k,...w&&C?{cloudVolume:a.jsx(bOe,{volume:C})}:{},onNewSession:o,onTurnEnd:()=>b(E=>E+1),onOpenConfig:l,onFork:c,onQuickAsk:u,viewerRole:h,hideHeader:f,configSlot:m?a.jsx(UX,{modelList:g,modes:m.permissionModes,configSchema:m.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:T}):null})})})}),j&&a.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),i()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:a.jsx(Yt,{className:"w-3.5 h-3.5"})})]})}function wOe({api:e,session:t,focused:n,liveGitBranch:r,liveWorktreeRoot:s,cloudVolume:i,onNewSession:o,onTurnEnd:l,onOpenConfig:c,onFork:u,onQuickAsk:d,viewerRole:h,configSlot:f,hideHeader:m}){return a.jsx(S_,{extras:{session:t,api:e,focused:n,...r!==void 0?{liveGitBranch:r}:{},...s!==void 0?{liveWorktreeRoot:s}:{},...i!==void 0?{cloudVolume:i}:{},onNewSession:o,onTurnEnd:l,onOpenConfig:c,...u?{onFork:g=>{u(g)}}:{},...d?{onQuickAsk:g=>{d(g)}}:{},...h?{viewerRole:h}:{},...f?{configSlot:f}:{},...m?{hideHeader:m}:{}}})}function _Oe({client:e,session:t,remoteSessions:n,hasLoadedForOwner:r,focused:s,totalPanes:i,onFocus:o,onClose:l,onMirrorOrphan:c,className:u}){const d=p.useMemo(()=>new Wt(e),[e]),h=t.originOwnerPrincipalId,f=t.sessionId,m=p.useMemo(()=>n.some(g=>g.sessionId===f),[n,f]);return p.useEffect(()=>{!r||!c||m||c(f,h)},[r,m,f,h,c]),a.jsx(dOe,{client:e,children:a.jsx(KM,{api:d,session:t,focused:s,totalPanes:i,onFocus:o,onClose:l,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest",...u!==void 0?{className:u}:{}})})}function SOe(){const e=Un(),[t,n]=p.useState([]),[r,s]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(async()=>{s(!0),o(null);try{const u=await new Wt(e).shiftList();n(u.shifts)}catch(c){o(c instanceof Error?c.message:String(c))}finally{s(!1)}},[e]);return p.useEffect(()=>{l()},[l]),{shifts:t,loading:r,error:i,refresh:l}}var mi={};Object.defineProperty(mi,"__esModule",{value:!0});class Ju extends Error{}class kOe extends Ju{constructor(t){super(`Invalid DateTime: ${t.toMessage()}`)}}class COe extends Ju{constructor(t){super(`Invalid Interval: ${t.toMessage()}`)}}class NOe extends Ju{constructor(t){super(`Invalid Duration: ${t.toMessage()}`)}}class oh extends Ju{}class VX extends Ju{constructor(t){super(`Invalid unit ${t}`)}}class Kr extends Ju{}class jl extends Ju{constructor(){super("Zone is an abstract class")}}const Oe="numeric",Io="short",ri="long",b1={year:Oe,month:Oe,day:Oe},qX={year:Oe,month:Io,day:Oe},jOe={year:Oe,month:Io,day:Oe,weekday:Io},KX={year:Oe,month:ri,day:Oe},GX={year:Oe,month:ri,day:Oe,weekday:ri},YX={hour:Oe,minute:Oe},XX={hour:Oe,minute:Oe,second:Oe},ZX={hour:Oe,minute:Oe,second:Oe,timeZoneName:Io},QX={hour:Oe,minute:Oe,second:Oe,timeZoneName:ri},JX={hour:Oe,minute:Oe,hourCycle:"h23"},eZ={hour:Oe,minute:Oe,second:Oe,hourCycle:"h23"},tZ={hour:Oe,minute:Oe,second:Oe,hourCycle:"h23",timeZoneName:Io},nZ={hour:Oe,minute:Oe,second:Oe,hourCycle:"h23",timeZoneName:ri},rZ={year:Oe,month:Oe,day:Oe,hour:Oe,minute:Oe},sZ={year:Oe,month:Oe,day:Oe,hour:Oe,minute:Oe,second:Oe},iZ={year:Oe,month:Io,day:Oe,hour:Oe,minute:Oe},oZ={year:Oe,month:Io,day:Oe,hour:Oe,minute:Oe,second:Oe},EOe={year:Oe,month:Io,day:Oe,weekday:Io,hour:Oe,minute:Oe},aZ={year:Oe,month:ri,day:Oe,hour:Oe,minute:Oe,timeZoneName:Io},lZ={year:Oe,month:ri,day:Oe,hour:Oe,minute:Oe,second:Oe,timeZoneName:Io},cZ={year:Oe,month:ri,day:Oe,weekday:ri,hour:Oe,minute:Oe,timeZoneName:ri},uZ={year:Oe,month:ri,day:Oe,weekday:ri,hour:Oe,minute:Oe,second:Oe,timeZoneName:ri};class Of{get type(){throw new jl}get name(){throw new jl}get ianaName(){return this.name}get isUniversal(){throw new jl}offsetName(t,n){throw new jl}formatOffset(t,n){throw new jl}offset(t){throw new jl}equals(t){throw new jl}get isValid(){throw new jl}}let CC=null;class Ax extends Of{static get instance(){return CC===null&&(CC=new Ax),CC}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return _Z(t,n,r)}formatOffset(t,n){return Am(this.offset(t),n)}offset(t){return-new Date(t).getTimezoneOffset()}equals(t){return t.type==="system"}get isValid(){return!0}}const _E=new Map;function IOe(e){let t=_E.get(e);return t===void 0&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),_E.set(e,t)),t}const TOe={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function MOe(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,s,i,o,l,c,u,d]=r;return[o,s,i,l,c,u,d]}function ROe(e,t){const n=e.formatToParts(t),r=[];for(let s=0;s<n.length;s++){const{type:i,value:o}=n[s],l=TOe[i];i==="era"?r[l]=o:ft(l)||(r[l]=parseInt(o,10))}return r}const NC=new Map;class ha extends Of{static create(t){let n=NC.get(t);return n===void 0&&NC.set(t,n=new ha(t)),n}static resetCache(){NC.clear(),_E.clear()}static isValidSpecifier(t){return this.isValidZone(t)}static isValidZone(t){if(!t)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=ha.isValidZone(t)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return _Z(t,n,r,this.name)}formatOffset(t,n){return Am(this.offset(t),n)}offset(t){if(!this.valid)return NaN;const n=new Date(t);if(isNaN(n))return NaN;const r=IOe(this.name);let[s,i,o,l,c,u,d]=r.formatToParts?ROe(r,n):MOe(r,n);l==="BC"&&(s=-Math.abs(s)+1);const f=I_({year:s,month:i,day:o,hour:c===24?0:c,minute:u,second:d,millisecond:0});let m=+n;const g=m%1e3;return m-=g>=0?g:1e3+g,(f-m)/(60*1e3)}equals(t){return t.type==="iana"&&t.name===this.name}get isValid(){return this.valid}}let gL={};function POe(e,t={}){const n=JSON.stringify([e,t]);let r=gL[n];return r||(r=new Intl.ListFormat(e,t),gL[n]=r),r}const SE=new Map;function kE(e,t={}){const n=JSON.stringify([e,t]);let r=SE.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),SE.set(n,r)),r}const CE=new Map;function DOe(e,t={}){const n=JSON.stringify([e,t]);let r=CE.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),CE.set(n,r)),r}const NE=new Map;function OOe(e,t={}){const{base:n,...r}=t,s=JSON.stringify([e,r]);let i=NE.get(s);return i===void 0&&(i=new Intl.RelativeTimeFormat(e,t),NE.set(s,i)),i}let sm=null;function AOe(){return sm||(sm=new Intl.DateTimeFormat().resolvedOptions().locale,sm)}const jE=new Map;function dZ(e){let t=jE.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),jE.set(e,t)),t}const EE=new Map;function $Oe(e){let t=EE.get(e);if(!t){const n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in t||(t={...hZ,...t}),EE.set(e,t)}return t}function LOe(e){const t=e.indexOf("-x-");t!==-1&&(e=e.substring(0,t));const n=e.indexOf("-u-");if(n===-1)return[e];{let r,s;try{r=kE(e).resolvedOptions(),s=e}catch{const c=e.substring(0,n);r=kE(c).resolvedOptions(),s=c}const{numberingSystem:i,calendar:o}=r;return[s,i,o]}}function BOe(e,t,n){return(n||t)&&(e.includes("-u-")||(e+="-u"),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`)),e}function FOe(e){const t=[];for(let n=1;n<=12;n++){const r=xt.utc(2009,n,1);t.push(e(r))}return t}function zOe(e){const t=[];for(let n=1;n<=7;n++){const r=xt.utc(2016,11,13+n);t.push(e(r))}return t}function P0(e,t,n,r){const s=e.listingMode();return s==="error"?null:s==="en"?n(t):r(t)}function HOe(e){return e.numberingSystem&&e.numberingSystem!=="latn"?!1:e.numberingSystem==="latn"||!e.locale||e.locale.startsWith("en")||dZ(e.locale).numberingSystem==="latn"}class UOe{constructor(t,n,r){this.padTo=r.padTo||0,this.floor=r.floor||!1;const{padTo:s,floor:i,...o}=r;if(!n||Object.keys(o).length>0){const l={useGrouping:!1,...r};r.padTo>0&&(l.minimumIntegerDigits=r.padTo),this.inf=DOe(t,l)}}format(t){if(this.inf){const n=this.floor?Math.floor(t):t;return this.inf.format(n)}else{const n=this.floor?Math.floor(t):QM(t,3);return nr(n,this.padTo)}}}class WOe{constructor(t,n,r){this.opts=r,this.originalZone=void 0;let s;if(this.opts.timeZone)this.dt=t;else if(t.zone.type==="fixed"){const o=-1*(t.offset/60),l=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;t.offset!==0&&ha.create(l).valid?(s=l,this.dt=t):(s="UTC",this.dt=t.offset===0?t:t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone)}else t.zone.type==="system"?this.dt=t:t.zone.type==="iana"?(this.dt=t,s=t.zone.name):(s="UTC",this.dt=t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone);const i={...this.opts};i.timeZone=i.timeZone||s,this.dtf=kE(n,i)}format(){return this.originalZone?this.formatToParts().map(({value:t})=>t).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const t=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?t.map(n=>{if(n.type==="timeZoneName"){const r=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...n,value:r}}else return n}):t}resolvedOptions(){return this.dtf.resolvedOptions()}}class VOe{constructor(t,n,r){this.opts={style:"long",...r},!n&&bZ()&&(this.rtf=OOe(t,r))}format(t,n){return this.rtf?this.rtf.format(t,n):hAe(n,t,this.opts.numeric,this.opts.style!=="long")}formatToParts(t,n){return this.rtf?this.rtf.formatToParts(t,n):[]}}const hZ={firstDay:1,minimalDays:4,weekend:[6,7]};class en{static fromOpts(t){return en.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,n,r,s,i=!1){const o=t||On.defaultLocale,l=o||(i?"en-US":AOe()),c=n||On.defaultNumberingSystem,u=r||On.defaultOutputCalendar,d=TE(s)||On.defaultWeekSettings;return new en(l,c,u,d,o)}static resetCache(){sm=null,SE.clear(),CE.clear(),NE.clear(),jE.clear(),EE.clear()}static fromObject({locale:t,numberingSystem:n,outputCalendar:r,weekSettings:s}={}){return en.create(t,n,r,s)}constructor(t,n,r,s,i){const[o,l,c]=LOe(t);this.locale=o,this.numberingSystem=n||l||null,this.outputCalendar=r||c||null,this.weekSettings=s,this.intl=BOe(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=HOe(this)),this.fastNumbersCached}listingMode(){const t=this.isEnglish(),n=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return t&&n?"en":"intl"}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:en.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,TE(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(t={}){return this.clone({...t,defaultToEN:!0})}redefaultToSystem(t={}){return this.clone({...t,defaultToEN:!1})}months(t,n=!1){return P0(this,t,CZ,()=>{const r=this.intl==="ja"||this.intl.startsWith("ja-");n&=!r;const s=n?{month:t,day:"numeric"}:{month:t},i=n?"format":"standalone";if(!this.monthsCache[i][t]){const o=r?l=>this.dtFormatter(l,s).format():l=>this.extract(l,s,"month");this.monthsCache[i][t]=FOe(o)}return this.monthsCache[i][t]})}weekdays(t,n=!1){return P0(this,t,EZ,()=>{const r=n?{weekday:t,year:"numeric",month:"long",day:"numeric"}:{weekday:t},s=n?"format":"standalone";return this.weekdaysCache[s][t]||(this.weekdaysCache[s][t]=zOe(i=>this.extract(i,r,"weekday"))),this.weekdaysCache[s][t]})}meridiems(){return P0(this,void 0,()=>IZ,()=>{if(!this.meridiemCache){const t={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[xt.utc(2016,11,13,9),xt.utc(2016,11,13,19)].map(n=>this.extract(n,t,"dayperiod"))}return this.meridiemCache})}eras(t){return P0(this,t,TZ,()=>{const n={era:t};return this.eraCache[t]||(this.eraCache[t]=[xt.utc(-40,1,1),xt.utc(2017,1,1)].map(r=>this.extract(r,n,"era"))),this.eraCache[t]})}extract(t,n,r){const s=this.dtFormatter(t,n),i=s.formatToParts(),o=i.find(l=>l.type.toLowerCase()===r);return o?o.value:null}numberFormatter(t={}){return new UOe(this.intl,t.forceSimple||this.fastNumbers,t)}dtFormatter(t,n={}){return new WOe(t,this.intl,n)}relFormatter(t={}){return new VOe(this.intl,this.isEnglish(),t)}listFormatter(t={}){return POe(this.intl,t)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||dZ(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:wZ()?$Oe(this.locale):hZ}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(t){return this.locale===t.locale&&this.numberingSystem===t.numberingSystem&&this.outputCalendar===t.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let jC=null;class Jr extends Of{static get utcInstance(){return jC===null&&(jC=new Jr(0)),jC}static instance(t){return t===0?Jr.utcInstance:new Jr(t)}static parseSpecifier(t){if(t){const n=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new Jr(T_(n[1],n[2]))}return null}constructor(t){super(),this.fixed=t}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Am(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Am(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(t,n){return Am(this.fixed,n)}get isUniversal(){return!0}offset(){return this.fixed}equals(t){return t.type==="fixed"&&t.fixed===this.fixed}get isValid(){return!0}}class fZ extends Of{constructor(t){super(),this.zoneName=t}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function Bl(e,t){if(ft(e)||e===null)return t;if(e instanceof Of)return e;if(ZOe(e)){const n=e.toLowerCase();return n==="default"?t:n==="local"||n==="system"?Ax.instance:n==="utc"||n==="gmt"?Jr.utcInstance:Jr.parseSpecifier(n)||ha.create(e)}else return ic(e)?Jr.instance(e):typeof e=="object"&&"offset"in e&&typeof e.offset=="function"?e:new fZ(e)}const GM={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},xL={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},qOe=GM.hanidec.replace(/[\[|\]]/g,"").split("");function KOe(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(e[n].search(GM.hanidec)!==-1)t+=qOe.indexOf(e[n]);else for(const s in xL){const[i,o]=xL[s];r>=i&&r<=o&&(t+=r-i)}}return parseInt(t,10)}else return t}const IE=new Map;function GOe(){IE.clear()}function io({numberingSystem:e},t=""){const n=e||"latn";let r=IE.get(n);r===void 0&&(r=new Map,IE.set(n,r));let s=r.get(t);return s===void 0&&(s=new RegExp(`${GM[n]}${t}`),r.set(t,s)),s}let vL=()=>Date.now(),yL="system",bL=null,wL=null,_L=null,SL=60,kL,CL=null;class On{static get now(){return vL}static set now(t){vL=t}static set defaultZone(t){yL=t}static get defaultZone(){return Bl(yL,Ax.instance)}static get defaultLocale(){return bL}static set defaultLocale(t){bL=t}static get defaultNumberingSystem(){return wL}static set defaultNumberingSystem(t){wL=t}static get defaultOutputCalendar(){return _L}static set defaultOutputCalendar(t){_L=t}static get defaultWeekSettings(){return CL}static set defaultWeekSettings(t){CL=TE(t)}static get twoDigitCutoffYear(){return SL}static set twoDigitCutoffYear(t){SL=t%100}static get throwOnInvalid(){return kL}static set throwOnInvalid(t){kL=t}static resetCaches(){en.resetCache(),ha.resetCache(),xt.resetCache(),GOe()}}class go{constructor(t,n){this.reason=t,this.explanation=n}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const pZ=[0,31,59,90,120,151,181,212,243,273,304,334],mZ=[0,31,60,91,121,152,182,213,244,274,305,335];function Ri(e,t){return new go("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function YM(e,t,n){const r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);const s=r.getUTCDay();return s===0?7:s}function gZ(e,t,n){return n+($x(e)?mZ:pZ)[t-1]}function xZ(e,t){const n=$x(e)?mZ:pZ,r=n.findIndex(i=>i<t),s=t-n[r];return{month:r+1,day:s}}function XM(e,t){return(e-t+7)%7+1}function w1(e,t=4,n=1){const{year:r,month:s,day:i}=e,o=gZ(r,s,i),l=XM(YM(r,s,i),n);let c=Math.floor((o-l+14-t)/7),u;return c<1?(u=r-1,c=Lg(u,t,n)):c>Lg(r,t,n)?(u=r+1,c=1):u=r,{weekYear:u,weekNumber:c,weekday:l,...M_(e)}}function NL(e,t=4,n=1){const{weekYear:r,weekNumber:s,weekday:i}=e,o=XM(YM(r,1,t),n),l=Sh(r);let c=s*7+i-o-7+t,u;c<1?(u=r-1,c+=Sh(u)):c>l?(u=r+1,c-=Sh(r)):u=r;const{month:d,day:h}=xZ(u,c);return{year:u,month:d,day:h,...M_(e)}}function EC(e){const{year:t,month:n,day:r}=e,s=gZ(t,n,r);return{year:t,ordinal:s,...M_(e)}}function jL(e){const{year:t,ordinal:n}=e,{month:r,day:s}=xZ(t,n);return{year:t,month:r,day:s,...M_(e)}}function EL(e,t){if(!ft(e.localWeekday)||!ft(e.localWeekNumber)||!ft(e.localWeekYear)){if(!ft(e.weekday)||!ft(e.weekNumber)||!ft(e.weekYear))throw new oh("Cannot mix locale-based week fields with ISO-based week fields");return ft(e.localWeekday)||(e.weekday=e.localWeekday),ft(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),ft(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function YOe(e,t=4,n=1){const r=E_(e.weekYear),s=Pi(e.weekNumber,1,Lg(e.weekYear,t,n)),i=Pi(e.weekday,1,7);return r?s?i?!1:Ri("weekday",e.weekday):Ri("week",e.weekNumber):Ri("weekYear",e.weekYear)}function XOe(e){const t=E_(e.year),n=Pi(e.ordinal,1,Sh(e.year));return t?n?!1:Ri("ordinal",e.ordinal):Ri("year",e.year)}function vZ(e){const t=E_(e.year),n=Pi(e.month,1,12),r=Pi(e.day,1,_1(e.year,e.month));return t?n?r?!1:Ri("day",e.day):Ri("month",e.month):Ri("year",e.year)}function yZ(e){const{hour:t,minute:n,second:r,millisecond:s}=e,i=Pi(t,0,23)||t===24&&n===0&&r===0&&s===0,o=Pi(n,0,59),l=Pi(r,0,59),c=Pi(s,0,999);return i?o?l?c?!1:Ri("millisecond",s):Ri("second",r):Ri("minute",n):Ri("hour",t)}function ft(e){return typeof e>"u"}function ic(e){return typeof e=="number"}function E_(e){return typeof e=="number"&&e%1===0}function ZOe(e){return typeof e=="string"}function QOe(e){return Object.prototype.toString.call(e)==="[object Date]"}function bZ(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function wZ(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function JOe(e){return Array.isArray(e)?e:[e]}function IL(e,t,n){if(e.length!==0)return e.reduce((r,s)=>{const i=[t(s),s];return r&&n(r[0],i[0])===r[0]?r:i},null)[1]}function eAe(e,t){return t.reduce((n,r)=>(n[r]=e[r],n),{})}function rf(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function TE(e){if(e==null)return null;if(typeof e!="object")throw new Kr("Week settings must be an object");if(!Pi(e.firstDay,1,7)||!Pi(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(t=>!Pi(t,1,7)))throw new Kr("Invalid week settings");return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Pi(e,t,n){return E_(e)&&e>=t&&e<=n}function tAe(e,t){return e-t*Math.floor(e/t)}function nr(e,t=2){const n=e<0;let r;return n?r="-"+(""+-e).padStart(t,"0"):r=(""+e).padStart(t,"0"),r}function Al(e){if(!(ft(e)||e===null||e===""))return parseInt(e,10)}function Fc(e){if(!(ft(e)||e===null||e===""))return parseFloat(e)}function ZM(e){if(!(ft(e)||e===null||e==="")){const t=parseFloat("0."+e)*1e3;return Math.floor(t)}}function QM(e,t,n="round"){const r=10**t;switch(n){case"expand":return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case"trunc":return Math.trunc(e*r)/r;case"round":return Math.round(e*r)/r;case"floor":return Math.floor(e*r)/r;case"ceil":return Math.ceil(e*r)/r;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function $x(e){return e%4===0&&(e%100!==0||e%400===0)}function Sh(e){return $x(e)?366:365}function _1(e,t){const n=tAe(t-1,12)+1,r=e+(t-n)/12;return n===2?$x(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function I_(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function TL(e,t,n){return-XM(YM(e,1,t),n)+t-1}function Lg(e,t=4,n=1){const r=TL(e,t,n),s=TL(e+1,t,n);return(Sh(e)-r+s)/7}function ME(e){return e>99?e:e>On.twoDigitCutoffYear?1900+e:2e3+e}function _Z(e,t,n,r=null){const s=new Date(e),i={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(i.timeZone=r);const o={timeZoneName:t,...i},l=new Intl.DateTimeFormat(n,o).formatToParts(s).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function T_(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);const r=parseInt(t,10)||0,s=n<0||Object.is(n,-0)?-r:r;return n*60+s}function SZ(e){const t=Number(e);if(typeof e=="boolean"||e===""||!Number.isFinite(t))throw new Kr(`Invalid unit value ${e}`);return t}function S1(e,t){const n={};for(const r in e)if(rf(e,r)){const s=e[r];if(s==null)continue;n[t(r)]=SZ(s)}return n}function Am(e,t){const n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),s=e>=0?"+":"-";switch(t){case"short":return`${s}${nr(n,2)}:${nr(r,2)}`;case"narrow":return`${s}${n}${r>0?`:${r}`:""}`;case"techie":return`${s}${nr(n,2)}${nr(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function M_(e){return eAe(e,["hour","minute","second","millisecond"])}const nAe=["January","February","March","April","May","June","July","August","September","October","November","December"],kZ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rAe=["J","F","M","A","M","J","J","A","S","O","N","D"];function CZ(e){switch(e){case"narrow":return[...rAe];case"short":return[...kZ];case"long":return[...nAe];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const NZ=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],jZ=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],sAe=["M","T","W","T","F","S","S"];function EZ(e){switch(e){case"narrow":return[...sAe];case"short":return[...jZ];case"long":return[...NZ];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const IZ=["AM","PM"],iAe=["Before Christ","Anno Domini"],oAe=["BC","AD"],aAe=["B","A"];function TZ(e){switch(e){case"narrow":return[...aAe];case"short":return[...oAe];case"long":return[...iAe];default:return null}}function lAe(e){return IZ[e.hour<12?0:1]}function cAe(e,t){return EZ(t)[e.weekday-1]}function uAe(e,t){return CZ(t)[e.month-1]}function dAe(e,t){return TZ(t)[e.year<0?0:1]}function hAe(e,t,n="always",r=!1){const s={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},i=["hours","minutes","seconds"].indexOf(e)===-1;if(n==="auto"&&i){const h=e==="days";switch(t){case 1:return h?"tomorrow":`next ${s[e][0]}`;case-1:return h?"yesterday":`last ${s[e][0]}`;case 0:return h?"today":`this ${s[e][0]}`}}const o=Object.is(t,-0)||t<0,l=Math.abs(t),c=l===1,u=s[e],d=r?c?u[1]:u[2]||u[1]:c?s[e][0]:e;return o?`${l} ${d} ago`:`in ${l} ${d}`}function ML(e,t){let n="";for(const r of e)r.literal?n+=r.val:n+=t(r.val);return n}const fAe={D:b1,DD:qX,DDD:KX,DDDD:GX,t:YX,tt:XX,ttt:ZX,tttt:QX,T:JX,TT:eZ,TTT:tZ,TTTT:nZ,f:rZ,ff:iZ,fff:aZ,ffff:cZ,F:sZ,FF:oZ,FFF:lZ,FFFF:uZ};class Xr{static create(t,n={}){return new Xr(t,n)}static parseFormat(t){let n=null,r="",s=!1;const i=[];for(let o=0;o<t.length;o++){const l=t.charAt(o);l==="'"?((r.length>0||s)&&i.push({literal:s||/^\s+$/.test(r),val:r===""?"'":r}),n=null,r="",s=!s):s||l===n?r+=l:(r.length>0&&i.push({literal:/^\s+$/.test(r),val:r}),r=l,n=l)}return r.length>0&&i.push({literal:s||/^\s+$/.test(r),val:r}),i}static macroTokenToFormatOpts(t){return fAe[t]}constructor(t,n){this.opts=n,this.loc=t,this.systemLoc=null}formatWithSystemDefault(t,n){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(t,{...this.opts,...n}).format()}dtFormatter(t,n={}){return this.loc.dtFormatter(t,{...this.opts,...n})}formatDateTime(t,n){return this.dtFormatter(t,n).format()}formatDateTimeParts(t,n){return this.dtFormatter(t,n).formatToParts()}formatInterval(t,n){return this.dtFormatter(t.start,n).dtf.formatRange(t.start.toJSDate(),t.end.toJSDate())}resolvedOptions(t,n){return this.dtFormatter(t,n).resolvedOptions()}num(t,n=0,r=void 0){if(this.opts.forceSimple)return nr(t,n);const s={...this.opts};return n>0&&(s.padTo=n),r&&(s.signDisplay=r),this.loc.numberFormatter(s).format(t)}formatDateTimeFromString(t,n){const r=this.loc.listingMode()==="en",s=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",i=(m,g)=>this.loc.extract(t,m,g),o=m=>t.isOffsetFixed&&t.offset===0&&m.allowZ?"Z":t.isValid?t.zone.formatOffset(t.ts,m.format):"",l=()=>r?lAe(t):i({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(m,g)=>r?uAe(t,m):i(g?{month:m}:{month:m,day:"numeric"},"month"),u=(m,g)=>r?cAe(t,m):i(g?{weekday:m}:{weekday:m,month:"long",day:"numeric"},"weekday"),d=m=>{const g=Xr.macroTokenToFormatOpts(m);return g?this.formatWithSystemDefault(t,g):m},h=m=>r?dAe(t,m):i({era:m},"era"),f=m=>{switch(m){case"S":return this.num(t.millisecond);case"u":case"SSS":return this.num(t.millisecond,3);case"s":return this.num(t.second);case"ss":return this.num(t.second,2);case"uu":return this.num(Math.floor(t.millisecond/10),2);case"uuu":return this.num(Math.floor(t.millisecond/100));case"m":return this.num(t.minute);case"mm":return this.num(t.minute,2);case"h":return this.num(t.hour%12===0?12:t.hour%12);case"hh":return this.num(t.hour%12===0?12:t.hour%12,2);case"H":return this.num(t.hour);case"HH":return this.num(t.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return t.zone.offsetName(t.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return t.zone.offsetName(t.ts,{format:"long",locale:this.loc.locale});case"z":return t.zoneName;case"a":return l();case"d":return s?i({day:"numeric"},"day"):this.num(t.day);case"dd":return s?i({day:"2-digit"},"day"):this.num(t.day,2);case"c":return this.num(t.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(t.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return s?i({month:"numeric",day:"numeric"},"month"):this.num(t.month);case"LL":return s?i({month:"2-digit",day:"numeric"},"month"):this.num(t.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return s?i({month:"numeric"},"month"):this.num(t.month);case"MM":return s?i({month:"2-digit"},"month"):this.num(t.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return s?i({year:"numeric"},"year"):this.num(t.year);case"yy":return s?i({year:"2-digit"},"year"):this.num(t.year.toString().slice(-2),2);case"yyyy":return s?i({year:"numeric"},"year"):this.num(t.year,4);case"yyyyyy":return s?i({year:"numeric"},"year"):this.num(t.year,6);case"G":return h("short");case"GG":return h("long");case"GGGGG":return h("narrow");case"kk":return this.num(t.weekYear.toString().slice(-2),2);case"kkkk":return this.num(t.weekYear,4);case"W":return this.num(t.weekNumber);case"WW":return this.num(t.weekNumber,2);case"n":return this.num(t.localWeekNumber);case"nn":return this.num(t.localWeekNumber,2);case"ii":return this.num(t.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(t.localWeekYear,4);case"o":return this.num(t.ordinal);case"ooo":return this.num(t.ordinal,3);case"q":return this.num(t.quarter);case"qq":return this.num(t.quarter,2);case"X":return this.num(Math.floor(t.ts/1e3));case"x":return this.num(t.ts);default:return d(m)}};return ML(Xr.parseFormat(n),f)}formatDurationFromString(t,n){const r=this.opts.signMode==="negativeLargestOnly"?-1:1,s=d=>{switch(d[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},i=(d,h)=>f=>{const m=s(f);if(m){const g=h.isNegativeDuration&&m!==h.largestUnit?r:1;let x;return this.opts.signMode==="negativeLargestOnly"&&m!==h.largestUnit?x="never":this.opts.signMode==="all"?x="always":x="auto",this.num(d.get(m)*g,f.length,x)}else return f},o=Xr.parseFormat(n),l=o.reduce((d,{literal:h,val:f})=>h?d:d.concat(f),[]),c=t.shiftTo(...l.map(s).filter(d=>d)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return ML(o,i(c,u))}}const MZ=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Af(...e){const t=e.reduce((n,r)=>n+r.source,"");return RegExp(`^${t}$`)}function $f(...e){return t=>e.reduce(([n,r,s],i)=>{const[o,l,c]=i(t,s);return[{...n,...o},l||r,c]},[{},null,1]).slice(0,2)}function Lf(e,...t){if(e==null)return[null,null];for(const[n,r]of t){const s=n.exec(e);if(s)return r(s)}return[null,null]}function RZ(...e){return(t,n)=>{const r={};let s;for(s=0;s<e.length;s++)r[e[s]]=Al(t[n+s]);return[r,null,n+s]}}const PZ=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,pAe=`(?:${PZ.source}?(?:\\[(${MZ.source})\\])?)?`,JM=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,DZ=RegExp(`${JM.source}${pAe}`),eR=RegExp(`(?:[Tt]${DZ.source})?`),mAe=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,gAe=/(\d{4})-?W(\d\d)(?:-?(\d))?/,xAe=/(\d{4})-?(\d{3})/,vAe=RZ("weekYear","weekNumber","weekDay"),yAe=RZ("year","ordinal"),bAe=/(\d{4})-(\d\d)-(\d\d)/,OZ=RegExp(`${JM.source} ?(?:${PZ.source}|(${MZ.source}))?`),wAe=RegExp(`(?: ${OZ.source})?`);function kh(e,t,n){const r=e[t];return ft(r)?n:Al(r)}function _Ae(e,t){return[{year:kh(e,t),month:kh(e,t+1,1),day:kh(e,t+2,1)},null,t+3]}function Bf(e,t){return[{hours:kh(e,t,0),minutes:kh(e,t+1,0),seconds:kh(e,t+2,0),milliseconds:ZM(e[t+3])},null,t+4]}function Lx(e,t){const n=!e[t]&&!e[t+1],r=T_(e[t+1],e[t+2]),s=n?null:Jr.instance(r);return[{},s,t+3]}function Bx(e,t){const n=e[t]?ha.create(e[t]):null;return[{},n,t+1]}const SAe=RegExp(`^T?${JM.source}$`),kAe=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function CAe(e){const[t,n,r,s,i,o,l,c,u]=e,d=t[0]==="-",h=c&&c[0]==="-",f=(m,g=!1)=>m!==void 0&&(g||m&&d)?-m:m;return[{years:f(Fc(n)),months:f(Fc(r)),weeks:f(Fc(s)),days:f(Fc(i)),hours:f(Fc(o)),minutes:f(Fc(l)),seconds:f(Fc(c),c==="-0"),milliseconds:f(ZM(u),h)}]}const NAe={GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function tR(e,t,n,r,s,i,o){const l={year:t.length===2?ME(Al(t)):Al(t),month:kZ.indexOf(n)+1,day:Al(r),hour:Al(s),minute:Al(i)};return o&&(l.second=Al(o)),e&&(l.weekday=e.length>3?NZ.indexOf(e)+1:jZ.indexOf(e)+1),l}const jAe=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function EAe(e){const[,t,n,r,s,i,o,l,c,u,d,h]=e,f=tR(t,s,r,n,i,o,l);let m;return c?m=NAe[c]:u?m=0:m=T_(d,h),[f,new Jr(m)]}function IAe(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const TAe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,MAe=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,RAe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function RL(e){const[,t,n,r,s,i,o,l]=e;return[tR(t,s,r,n,i,o,l),Jr.utcInstance]}function PAe(e){const[,t,n,r,s,i,o,l]=e;return[tR(t,l,n,r,s,i,o),Jr.utcInstance]}const DAe=Af(mAe,eR),OAe=Af(gAe,eR),AAe=Af(xAe,eR),$Ae=Af(DZ),AZ=$f(_Ae,Bf,Lx,Bx),LAe=$f(vAe,Bf,Lx,Bx),BAe=$f(yAe,Bf,Lx,Bx),FAe=$f(Bf,Lx,Bx);function zAe(e){return Lf(e,[DAe,AZ],[OAe,LAe],[AAe,BAe],[$Ae,FAe])}function HAe(e){return Lf(IAe(e),[jAe,EAe])}function UAe(e){return Lf(e,[TAe,RL],[MAe,RL],[RAe,PAe])}function WAe(e){return Lf(e,[kAe,CAe])}const VAe=$f(Bf);function qAe(e){return Lf(e,[SAe,VAe])}const KAe=Af(bAe,wAe),GAe=Af(OZ),YAe=$f(Bf,Lx,Bx);function XAe(e){return Lf(e,[KAe,AZ],[GAe,YAe])}const PL="Invalid Duration",$Z={weeks:{days:7,hours:7*24,minutes:7*24*60,seconds:7*24*60*60,milliseconds:7*24*60*60*1e3},days:{hours:24,minutes:24*60,seconds:24*60*60,milliseconds:24*60*60*1e3},hours:{minutes:60,seconds:60*60,milliseconds:60*60*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},ZAe={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:91*24,minutes:91*24*60,seconds:91*24*60*60,milliseconds:91*24*60*60*1e3},months:{weeks:4,days:30,hours:30*24,minutes:30*24*60,seconds:30*24*60*60,milliseconds:30*24*60*60*1e3},...$Z},_i=146097/400,Td=146097/4800,QAe={years:{quarters:4,months:12,weeks:_i/7,days:_i,hours:_i*24,minutes:_i*24*60,seconds:_i*24*60*60,milliseconds:_i*24*60*60*1e3},quarters:{months:3,weeks:_i/28,days:_i/4,hours:_i*24/4,minutes:_i*24*60/4,seconds:_i*24*60*60/4,milliseconds:_i*24*60*60*1e3/4},months:{weeks:Td/7,days:Td,hours:Td*24,minutes:Td*24*60,seconds:Td*24*60*60,milliseconds:Td*24*60*60*1e3},...$Z},su=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],JAe=su.slice(0).reverse();function ja(e,t,n=!1){const r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new Ut(r)}function LZ(e,t){var n;let r=(n=t.milliseconds)!=null?n:0;for(const s of JAe.slice(1))t[s]&&(r+=t[s]*e[s].milliseconds);return r}function DL(e,t){const n=LZ(e,t)<0?-1:1;su.reduceRight((r,s)=>{if(ft(t[s]))return r;if(r){const i=t[r]*n,o=e[s][r],l=Math.floor(i/o);t[s]+=l*n,t[r]-=l*o*n}return s},null),su.reduce((r,s)=>{if(ft(t[s]))return r;if(r){const i=t[r]%1;t[r]-=i,t[s]+=i*e[r][s]}return s},null)}function OL(e){const t={};for(const[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}class Ut{constructor(t){const n=t.conversionAccuracy==="longterm"||!1;let r=n?QAe:ZAe;t.matrix&&(r=t.matrix),this.values=t.values,this.loc=t.loc||en.create(),this.conversionAccuracy=n?"longterm":"casual",this.invalid=t.invalid||null,this.matrix=r,this.isLuxonDuration=!0}static fromMillis(t,n){return Ut.fromObject({milliseconds:t},n)}static fromObject(t,n={}){if(t==null||typeof t!="object")throw new Kr(`Duration.fromObject: argument expected to be an object, got ${t===null?"null":typeof t}`);return new Ut({values:S1(t,Ut.normalizeUnit),loc:en.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(ic(t))return Ut.fromMillis(t);if(Ut.isDuration(t))return t;if(typeof t=="object")return Ut.fromObject(t);throw new Kr(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){const[r]=WAe(t);return r?Ut.fromObject(r,n):Ut.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,n){const[r]=qAe(t);return r?Ut.fromObject(r,n):Ut.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,n=null){if(!t)throw new Kr("need to specify a reason the Duration is invalid");const r=t instanceof go?t:new go(t,n);if(On.throwOnInvalid)throw new NOe(r);return new Ut({invalid:r})}static normalizeUnit(t){const n={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[t&&t.toLowerCase()];if(!n)throw new VX(t);return n}static isDuration(t){return t&&t.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(t,n={}){const r={...n,floor:n.round!==!1&&n.floor!==!1};return this.isValid?Xr.create(this.loc,r).formatDurationFromString(this,t):PL}toHuman(t={}){if(!this.isValid)return PL;const n=t.showZeros!==!1,r=su.map(s=>{const i=this.values[s];return ft(i)||i===0&&!n?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...t,unit:s.slice(0,-1)}).format(i)}).filter(s=>s);return this.loc.listFormatter({type:"conjunction",style:t.listStyle||"narrow",...t}).format(r)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let t="P";return this.years!==0&&(t+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(t+=this.months+this.quarters*3+"M"),this.weeks!==0&&(t+=this.weeks+"W"),this.days!==0&&(t+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(t+="T"),this.hours!==0&&(t+=this.hours+"H"),this.minutes!==0&&(t+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(t+=QM(this.seconds+this.milliseconds/1e3,3)+"S"),t==="P"&&(t+="T0S"),t}toISOTime(t={}){if(!this.isValid)return null;const n=this.toMillis();return n<0||n>=864e5?null:(t={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...t,includeOffset:!1},xt.fromMillis(n,{zone:"UTC"}).toISOTime(t))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?LZ(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;const n=Ut.fromDurationLike(t),r={};for(const s of su)(rf(n.values,s)||rf(this.values,s))&&(r[s]=n.get(s)+this.get(s));return ja(this,{values:r},!0)}minus(t){if(!this.isValid)return this;const n=Ut.fromDurationLike(t);return this.plus(n.negate())}mapUnits(t){if(!this.isValid)return this;const n={};for(const r of Object.keys(this.values))n[r]=SZ(t(this.values[r],r));return ja(this,{values:n},!0)}get(t){return this[Ut.normalizeUnit(t)]}set(t){if(!this.isValid)return this;const n={...this.values,...S1(t,Ut.normalizeUnit)};return ja(this,{values:n})}reconfigure({locale:t,numberingSystem:n,conversionAccuracy:r,matrix:s}={}){const o={loc:this.loc.clone({locale:t,numberingSystem:n}),matrix:s,conversionAccuracy:r};return ja(this,o)}as(t){return this.isValid?this.shiftTo(t).get(t):NaN}normalize(){if(!this.isValid)return this;const t=this.toObject();return DL(this.matrix,t),ja(this,{values:t},!0)}rescale(){if(!this.isValid)return this;const t=OL(this.normalize().shiftToAll().toObject());return ja(this,{values:t},!0)}shiftTo(...t){if(!this.isValid)return this;if(t.length===0)return this;t=t.map(o=>Ut.normalizeUnit(o));const n={},r={},s=this.toObject();let i;for(const o of su)if(t.indexOf(o)>=0){i=o;let l=0;for(const u in r)l+=this.matrix[u][o]*r[u],r[u]=0;ic(s[o])&&(l+=s[o]);const c=Math.trunc(l);n[o]=c,r[o]=(l*1e3-c*1e3)/1e3}else ic(s[o])&&(r[o]=s[o]);for(const o in r)r[o]!==0&&(n[i]+=o===i?r[o]:r[o]/this.matrix[i][o]);return DL(this.matrix,n),ja(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const t={};for(const n of Object.keys(this.values))t[n]=this.values[n]===0?0:-this.values[n];return ja(this,{values:t},!0)}removeZeros(){if(!this.isValid)return this;const t=OL(this.values);return ja(this,{values:t},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(t){if(!this.isValid||!t.isValid||!this.loc.equals(t.loc))return!1;function n(r,s){return r===void 0||r===0?s===void 0||s===0:r===s}for(const r of su)if(!n(this.values[r],t.values[r]))return!1;return!0}}const Md="Invalid Interval";function e$e(e,t){return!e||!e.isValid?Pn.invalid("missing or invalid start"):!t||!t.isValid?Pn.invalid("missing or invalid end"):t<e?Pn.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null}class Pn{constructor(t){this.s=t.start,this.e=t.end,this.invalid=t.invalid||null,this.isLuxonInterval=!0}static invalid(t,n=null){if(!t)throw new Kr("need to specify a reason the Interval is invalid");const r=t instanceof go?t:new go(t,n);if(On.throwOnInvalid)throw new COe(r);return new Pn({invalid:r})}static fromDateTimes(t,n){const r=Lp(t),s=Lp(n),i=e$e(r,s);return i??new Pn({start:r,end:s})}static after(t,n){const r=Ut.fromDurationLike(n),s=Lp(t);return Pn.fromDateTimes(s,s.plus(r))}static before(t,n){const r=Ut.fromDurationLike(n),s=Lp(t);return Pn.fromDateTimes(s.minus(r),s)}static fromISO(t,n){const[r,s]=(t||"").split("/",2);if(r&&s){let i,o;try{i=xt.fromISO(r,n),o=i.isValid}catch{o=!1}let l,c;try{l=xt.fromISO(s,n),c=l.isValid}catch{c=!1}if(o&&c)return Pn.fromDateTimes(i,l);if(o){const u=Ut.fromISO(s,n);if(u.isValid)return Pn.after(i,u)}else if(c){const u=Ut.fromISO(r,n);if(u.isValid)return Pn.before(l,u)}}return Pn.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(t){return t&&t.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(t="milliseconds"){return this.isValid?this.toDuration(t).get(t):NaN}count(t="milliseconds",n){if(!this.isValid)return NaN;const r=this.start.startOf(t,n);let s;return n!=null&&n.useLocaleWeeks?s=this.end.reconfigure({locale:r.locale}):s=this.end,s=s.startOf(t,n),Math.floor(s.diff(r,t).get(t))+(s.valueOf()!==this.end.valueOf())}hasSame(t){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,t):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(t){return this.isValid?this.s>t:!1}isBefore(t){return this.isValid?this.e<=t:!1}contains(t){return this.isValid?this.s<=t&&this.e>t:!1}set({start:t,end:n}={}){return this.isValid?Pn.fromDateTimes(t||this.s,n||this.e):this}splitAt(...t){if(!this.isValid)return[];const n=t.map(Lp).filter(o=>this.contains(o)).sort((o,l)=>o.toMillis()-l.toMillis()),r=[];let{s}=this,i=0;for(;s<this.e;){const o=n[i]||this.e,l=+o>+this.e?this.e:o;r.push(Pn.fromDateTimes(s,l)),s=l,i+=1}return r}splitBy(t){const n=Ut.fromDurationLike(t);if(!this.isValid||!n.isValid||n.as("milliseconds")===0)return[];let{s:r}=this,s=1,i;const o=[];for(;r<this.e;){const l=this.start.plus(n.mapUnits(c=>c*s));i=+l>+this.e?this.e:l,o.push(Pn.fromDateTimes(r,i)),r=i,s+=1}return o}divideEqually(t){return this.isValid?this.splitBy(this.length()/t).slice(0,t):[]}overlaps(t){return this.e>t.s&&this.s<t.e}abutsStart(t){return this.isValid?+this.e==+t.s:!1}abutsEnd(t){return this.isValid?+t.e==+this.s:!1}engulfs(t){return this.isValid?this.s<=t.s&&this.e>=t.e:!1}equals(t){return!this.isValid||!t.isValid?!1:this.s.equals(t.s)&&this.e.equals(t.e)}intersection(t){if(!this.isValid)return this;const n=this.s>t.s?this.s:t.s,r=this.e<t.e?this.e:t.e;return n>=r?null:Pn.fromDateTimes(n,r)}union(t){if(!this.isValid)return this;const n=this.s<t.s?this.s:t.s,r=this.e>t.e?this.e:t.e;return Pn.fromDateTimes(n,r)}static merge(t){const[n,r]=t.sort((s,i)=>s.s-i.s).reduce(([s,i],o)=>i?i.overlaps(o)||i.abutsStart(o)?[s,i.union(o)]:[s.concat([i]),o]:[s,o],[[],null]);return r&&n.push(r),n}static xor(t){let n=null,r=0;const s=[],i=t.map(c=>[{time:c.s,type:"s"},{time:c.e,type:"e"}]),o=Array.prototype.concat(...i),l=o.sort((c,u)=>c.time-u.time);for(const c of l)r+=c.type==="s"?1:-1,r===1?n=c.time:(n&&+n!=+c.time&&s.push(Pn.fromDateTimes(n,c.time)),n=null);return Pn.merge(s)}difference(...t){return Pn.xor([this].concat(t)).map(n=>this.intersection(n)).filter(n=>n&&!n.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Md}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(t=b1,n={}){return this.isValid?Xr.create(this.s.loc.clone(n),t).formatInterval(this):Md}toISO(t){return this.isValid?`${this.s.toISO(t)}/${this.e.toISO(t)}`:Md}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Md}toISOTime(t){return this.isValid?`${this.s.toISOTime(t)}/${this.e.toISOTime(t)}`:Md}toFormat(t,{separator:n=" – "}={}){return this.isValid?`${this.s.toFormat(t)}${n}${this.e.toFormat(t)}`:Md}toDuration(t,n){return this.isValid?this.e.diff(this.s,t,n):Ut.invalid(this.invalidReason)}mapEndpoints(t){return Pn.fromDateTimes(t(this.s),t(this.e))}}class im{static hasDST(t=On.defaultZone){const n=xt.now().setZone(t).set({month:12});return!t.isUniversal&&n.offset!==n.set({month:6}).offset}static isValidIANAZone(t){return ha.isValidZone(t)}static normalizeZone(t){return Bl(t,On.defaultZone)}static getStartOfWeek({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getWeekendDays().slice()}static months(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null,outputCalendar:i="gregory"}={}){return(s||en.create(n,r,i)).months(t)}static monthsFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null,outputCalendar:i="gregory"}={}){return(s||en.create(n,r,i)).months(t,!0)}static weekdays(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null}={}){return(s||en.create(n,r,null)).weekdays(t)}static weekdaysFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null}={}){return(s||en.create(n,r,null)).weekdays(t,!0)}static meridiems({locale:t=null}={}){return en.create(t).meridiems()}static eras(t="short",{locale:n=null}={}){return en.create(n,null,"gregory").eras(t)}static features(){return{relative:bZ(),localeWeek:wZ()}}}function AL(e,t){const n=s=>s.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(t)-n(e);return Math.floor(Ut.fromMillis(r).as("days"))}function t$e(e,t,n){const r=[["years",(c,u)=>u.year-c.year],["quarters",(c,u)=>u.quarter-c.quarter+(u.year-c.year)*4],["months",(c,u)=>u.month-c.month+(u.year-c.year)*12],["weeks",(c,u)=>{const d=AL(c,u);return(d-d%7)/7}],["days",AL]],s={},i=e;let o,l;for(const[c,u]of r)n.indexOf(c)>=0&&(o=c,s[c]=u(e,t),l=i.plus(s),l>t?(s[c]--,e=i.plus(s),e>t&&(l=e,s[c]--,e=i.plus(s))):e=l);return[e,s,l,o]}function n$e(e,t,n,r){let[s,i,o,l]=t$e(e,t,n);const c=t-s,u=n.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<t&&(o=s.plus({[l]:1})),o!==s&&(i[l]=(i[l]||0)+c/(o-s)));const d=Ut.fromObject(i,r);return u.length>0?Ut.fromMillis(c,r).shiftTo(...u).plus(d):d}const r$e="missing Intl.DateTimeFormat.formatToParts support";function Zt(e,t=n=>n){return{regex:e,deser:([n])=>t(KOe(n))}}const s$e=" ",BZ=`[ ${s$e}]`,FZ=new RegExp(BZ,"g");function i$e(e){return e.replace(/\./g,"\\.?").replace(FZ,BZ)}function $L(e){return e.replace(/\./g,"").replace(FZ," ").toLowerCase()}function oo(e,t){return e===null?null:{regex:RegExp(e.map(i$e).join("|")),deser:([n])=>e.findIndex(r=>$L(n)===$L(r))+t}}function LL(e,t){return{regex:e,deser:([,n,r])=>T_(n,r),groups:t}}function D0(e){return{regex:e,deser:([t])=>t}}function o$e(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function a$e(e,t){const n=io(t),r=io(t,"{2}"),s=io(t,"{3}"),i=io(t,"{4}"),o=io(t,"{6}"),l=io(t,"{1,2}"),c=io(t,"{1,3}"),u=io(t,"{1,6}"),d=io(t,"{1,9}"),h=io(t,"{2,4}"),f=io(t,"{4,6}"),m=b=>({regex:RegExp(o$e(b.val)),deser:([y])=>y,literal:!0}),x=(b=>{if(e.literal)return m(b);switch(b.val){case"G":return oo(t.eras("short"),0);case"GG":return oo(t.eras("long"),0);case"y":return Zt(u);case"yy":return Zt(h,ME);case"yyyy":return Zt(i);case"yyyyy":return Zt(f);case"yyyyyy":return Zt(o);case"M":return Zt(l);case"MM":return Zt(r);case"MMM":return oo(t.months("short",!0),1);case"MMMM":return oo(t.months("long",!0),1);case"L":return Zt(l);case"LL":return Zt(r);case"LLL":return oo(t.months("short",!1),1);case"LLLL":return oo(t.months("long",!1),1);case"d":return Zt(l);case"dd":return Zt(r);case"o":return Zt(c);case"ooo":return Zt(s);case"HH":return Zt(r);case"H":return Zt(l);case"hh":return Zt(r);case"h":return Zt(l);case"mm":return Zt(r);case"m":return Zt(l);case"q":return Zt(l);case"qq":return Zt(r);case"s":return Zt(l);case"ss":return Zt(r);case"S":return Zt(c);case"SSS":return Zt(s);case"u":return D0(d);case"uu":return D0(l);case"uuu":return Zt(n);case"a":return oo(t.meridiems(),0);case"kkkk":return Zt(i);case"kk":return Zt(h,ME);case"W":return Zt(l);case"WW":return Zt(r);case"E":case"c":return Zt(n);case"EEE":return oo(t.weekdays("short",!1),1);case"EEEE":return oo(t.weekdays("long",!1),1);case"ccc":return oo(t.weekdays("short",!0),1);case"cccc":return oo(t.weekdays("long",!0),1);case"Z":case"ZZ":return LL(new RegExp(`([+-]${l.source})(?::(${r.source}))?`),2);case"ZZZ":return LL(new RegExp(`([+-]${l.source})(${r.source})?`),2);case"z":return D0(/[a-z_+-/]{1,256}?/i);case" ":return D0(/[^\S\n\r]/);default:return m(b)}})(e)||{invalidReason:r$e};return x.token=e,x}const l$e={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function c$e(e,t,n){const{type:r,value:s}=e;if(r==="literal"){const c=/^\s+$/.test(s);return{literal:!c,val:c?" ":s}}const i=t[r];let o=r;r==="hour"&&(t.hour12!=null?o=t.hour12?"hour12":"hour24":t.hourCycle!=null?t.hourCycle==="h11"||t.hourCycle==="h12"?o="hour12":o="hour24":o=n.hour12?"hour12":"hour24");let l=l$e[o];if(typeof l=="object"&&(l=l[i]),l)return{literal:!1,val:l}}function u$e(e){return[`^${e.map(n=>n.regex).reduce((n,r)=>`${n}(${r.source})`,"")}$`,e]}function d$e(e,t,n){const r=e.match(t);if(r){const s={};let i=1;for(const o in n)if(rf(n,o)){const l=n[o],c=l.groups?l.groups+1:1;!l.literal&&l.token&&(s[l.token.val[0]]=l.deser(r.slice(i,i+c))),i+=c}return[r,s]}else return[r,{}]}function h$e(e){const t=i=>{switch(i){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let n=null,r;return ft(e.z)||(n=ha.create(e.z)),ft(e.Z)||(n||(n=new Jr(e.Z)),r=e.Z),ft(e.q)||(e.M=(e.q-1)*3+1),ft(e.h)||(e.h<12&&e.a===1?e.h+=12:e.h===12&&e.a===0&&(e.h=0)),e.G===0&&e.y&&(e.y=-e.y),ft(e.u)||(e.S=ZM(e.u)),[Object.keys(e).reduce((i,o)=>{const l=t(o);return l&&(i[l]=e[o]),i},{}),n,r]}let IC=null;function f$e(){return IC||(IC=xt.fromMillis(1555555555555)),IC}function p$e(e,t){if(e.literal)return e;const n=Xr.macroTokenToFormatOpts(e.val),r=WZ(n,t);return r==null||r.includes(void 0)?e:r}function zZ(e,t){return Array.prototype.concat(...e.map(n=>p$e(n,t)))}class HZ{constructor(t,n){if(this.locale=t,this.format=n,this.tokens=zZ(Xr.parseFormat(n),t),this.units=this.tokens.map(r=>a$e(r,t)),this.disqualifyingUnit=this.units.find(r=>r.invalidReason),!this.disqualifyingUnit){const[r,s]=u$e(this.units);this.regex=RegExp(r,"i"),this.handlers=s}}explainFromTokens(t){if(this.isValid){const[n,r]=d$e(t,this.regex,this.handlers),[s,i,o]=r?h$e(r):[null,null,void 0];if(rf(r,"a")&&rf(r,"H"))throw new oh("Can't include meridiem when specifying 24-hour format");return{input:t,tokens:this.tokens,regex:this.regex,rawMatches:n,matches:r,result:s,zone:i,specificOffset:o}}else return{input:t,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function UZ(e,t,n){return new HZ(e,n).explainFromTokens(t)}function m$e(e,t,n){const{result:r,zone:s,specificOffset:i,invalidReason:o}=UZ(e,t,n);return[r,s,i,o]}function WZ(e,t){if(!e)return null;const r=Xr.create(t,e).dtFormatter(f$e()),s=r.formatToParts(),i=r.resolvedOptions();return s.map(o=>c$e(o,e,i))}const TC="Invalid DateTime",BL=864e13;function om(e){return new go("unsupported zone",`the zone "${e.name}" is not supported`)}function MC(e){return e.weekData===null&&(e.weekData=w1(e.c)),e.weekData}function RC(e){return e.localWeekData===null&&(e.localWeekData=w1(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function zc(e,t){const n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new xt({...n,...t,old:n})}function VZ(e,t,n){let r=e-t*60*1e3;const s=n.offset(r);if(t===s)return[r,t];r-=(s-t)*60*1e3;const i=n.offset(r);return s===i?[r,s]:[e-Math.min(s,i)*60*1e3,Math.max(s,i)]}function O0(e,t){e+=t*60*1e3;const n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function Ly(e,t,n){return VZ(I_(e),t,n)}function FL(e,t){const n=e.o,r=e.c.year+Math.trunc(t.years),s=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,i={...e.c,year:r,month:s,day:Math.min(e.c.day,_1(r,s))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=Ut.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),l=I_(i);let[c,u]=VZ(l,n,e.zone);return o!==0&&(c+=o,u=e.zone.offset(c)),{ts:c,o:u}}function Rd(e,t,n,r,s,i){const{setZone:o,zone:l}=n;if(e&&Object.keys(e).length!==0||t){const c=t||l,u=xt.fromObject(e,{...n,zone:c,specificOffset:i});return o?u:u.setZone(l)}else return xt.invalid(new go("unparsable",`the input "${s}" can't be parsed as ${r}`))}function A0(e,t,n=!0){return e.isValid?Xr.create(en.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function PC(e,t,n){const r=e.c.year>9999||e.c.year<0;let s="";if(r&&e.c.year>=0&&(s+="+"),s+=nr(e.c.year,r?6:4),n==="year")return s;if(t){if(s+="-",s+=nr(e.c.month),n==="month")return s;s+="-"}else if(s+=nr(e.c.month),n==="month")return s;return s+=nr(e.c.day),s}function zL(e,t,n,r,s,i,o){let l=!n||e.c.millisecond!==0||e.c.second!==0,c="";switch(o){case"day":case"month":case"year":break;default:if(c+=nr(e.c.hour),o==="hour")break;if(t){if(c+=":",c+=nr(e.c.minute),o==="minute")break;l&&(c+=":",c+=nr(e.c.second))}else{if(c+=nr(e.c.minute),o==="minute")break;l&&(c+=nr(e.c.second))}if(o==="second")break;l&&(!r||e.c.millisecond!==0)&&(c+=".",c+=nr(e.c.millisecond,3))}return s&&(e.isOffsetFixed&&e.offset===0&&!i?c+="Z":e.o<0?(c+="-",c+=nr(Math.trunc(-e.o/60)),c+=":",c+=nr(Math.trunc(-e.o%60))):(c+="+",c+=nr(Math.trunc(e.o/60)),c+=":",c+=nr(Math.trunc(e.o%60)))),i&&(c+="["+e.zone.ianaName+"]"),c}const qZ={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},g$e={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},x$e={ordinal:1,hour:0,minute:0,second:0,millisecond:0},By=["year","month","day","hour","minute","second","millisecond"],v$e=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],y$e=["year","ordinal","hour","minute","second","millisecond"];function Fy(e){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new VX(e);return t}function HL(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Fy(e)}}function b$e(e){if(am===void 0&&(am=On.now()),e.type!=="iana")return e.offset(am);const t=e.name;let n=RE.get(t);return n===void 0&&(n=e.offset(am),RE.set(t,n)),n}function UL(e,t){const n=Bl(t.zone,On.defaultZone);if(!n.isValid)return xt.invalid(om(n));const r=en.fromObject(t);let s,i;if(ft(e.year))s=On.now();else{for(const c of By)ft(e[c])&&(e[c]=qZ[c]);const o=vZ(e)||yZ(e);if(o)return xt.invalid(o);const l=b$e(n);[s,i]=Ly(e,l,n)}return new xt({ts:s,zone:n,loc:r,o:i})}function WL(e,t,n){const r=ft(n.round)?!0:n.round,s=ft(n.rounding)?"trunc":n.rounding,i=(l,c)=>(l=QM(l,r||n.calendary?0:2,n.calendary?"round":s),t.loc.clone(n).relFormatter(n).format(l,c)),o=l=>n.calendary?t.hasSame(e,l)?0:t.startOf(l).diff(e.startOf(l),l).get(l):t.diff(e,l).get(l);if(n.unit)return i(o(n.unit),n.unit);for(const l of n.units){const c=o(l);if(Math.abs(c)>=1)return i(c,l)}return i(e>t?-0:0,n.units[n.units.length-1])}function VL(e){let t={},n;return e.length>0&&typeof e[e.length-1]=="object"?(t=e[e.length-1],n=Array.from(e).slice(0,e.length-1)):n=Array.from(e),[t,n]}let am;const RE=new Map;class xt{constructor(t){const n=t.zone||On.defaultZone;let r=t.invalid||(Number.isNaN(t.ts)?new go("invalid input"):null)||(n.isValid?null:om(n));this.ts=ft(t.ts)?On.now():t.ts;let s=null,i=null;if(!r)if(t.old&&t.old.ts===this.ts&&t.old.zone.equals(n))[s,i]=[t.old.c,t.old.o];else{const l=ic(t.o)&&!t.old?t.o:n.offset(this.ts);s=O0(this.ts,l),r=Number.isNaN(s.year)?new go("invalid input"):null,s=r?null:s,i=r?null:l}this._zone=n,this.loc=t.loc||en.create(),this.invalid=r,this.weekData=null,this.localWeekData=null,this.c=s,this.o=i,this.isLuxonDateTime=!0}static now(){return new xt({})}static local(){const[t,n]=VL(arguments),[r,s,i,o,l,c,u]=n;return UL({year:r,month:s,day:i,hour:o,minute:l,second:c,millisecond:u},t)}static utc(){const[t,n]=VL(arguments),[r,s,i,o,l,c,u]=n;return t.zone=Jr.utcInstance,UL({year:r,month:s,day:i,hour:o,minute:l,second:c,millisecond:u},t)}static fromJSDate(t,n={}){const r=QOe(t)?t.valueOf():NaN;if(Number.isNaN(r))return xt.invalid("invalid input");const s=Bl(n.zone,On.defaultZone);return s.isValid?new xt({ts:r,zone:s,loc:en.fromObject(n)}):xt.invalid(om(s))}static fromMillis(t,n={}){if(ic(t))return t<-BL||t>BL?xt.invalid("Timestamp out of range"):new xt({ts:t,zone:Bl(n.zone,On.defaultZone),loc:en.fromObject(n)});throw new Kr(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(ic(t))return new xt({ts:t*1e3,zone:Bl(n.zone,On.defaultZone),loc:en.fromObject(n)});throw new Kr("fromSeconds requires a numerical input")}static fromObject(t,n={}){t=t||{};const r=Bl(n.zone,On.defaultZone);if(!r.isValid)return xt.invalid(om(r));const s=en.fromObject(n),i=S1(t,HL),{minDaysInFirstWeek:o,startOfWeek:l}=EL(i,s),c=On.now(),u=ft(n.specificOffset)?r.offset(c):n.specificOffset,d=!ft(i.ordinal),h=!ft(i.year),f=!ft(i.month)||!ft(i.day),m=h||f,g=i.weekYear||i.weekNumber;if((m||d)&&g)throw new oh("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(f&&d)throw new oh("Can't mix ordinal dates with month/day");const x=g||i.weekday&&!m;let b,y,v=O0(c,u);x?(b=v$e,y=g$e,v=w1(v,o,l)):d?(b=y$e,y=x$e,v=EC(v)):(b=By,y=qZ);let w=!1;for(const E of b){const I=i[E];ft(I)?w?i[E]=y[E]:i[E]=v[E]:w=!0}const _=x?YOe(i,o,l):d?XOe(i):vZ(i),S=_||yZ(i);if(S)return xt.invalid(S);const k=x?NL(i,o,l):d?jL(i):i,[C,j]=Ly(k,u,r),T=new xt({ts:C,zone:r,o:j,loc:s});return i.weekday&&m&&t.weekday!==T.weekday?xt.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${T.toISO()}`):T.isValid?T:xt.invalid(T.invalid)}static fromISO(t,n={}){const[r,s]=zAe(t);return Rd(r,s,n,"ISO 8601",t)}static fromRFC2822(t,n={}){const[r,s]=HAe(t);return Rd(r,s,n,"RFC 2822",t)}static fromHTTP(t,n={}){const[r,s]=UAe(t);return Rd(r,s,n,"HTTP",n)}static fromFormat(t,n,r={}){if(ft(t)||ft(n))throw new Kr("fromFormat requires an input string and a format");const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0}),[l,c,u,d]=m$e(o,t,n);return d?xt.invalid(d):Rd(l,c,r,`format ${n}`,t,u)}static fromString(t,n,r={}){return xt.fromFormat(t,n,r)}static fromSQL(t,n={}){const[r,s]=XAe(t);return Rd(r,s,n,"SQL",t)}static invalid(t,n=null){if(!t)throw new Kr("need to specify a reason the DateTime is invalid");const r=t instanceof go?t:new go(t,n);if(On.throwOnInvalid)throw new kOe(r);return new xt({invalid:r})}static isDateTime(t){return t&&t.isLuxonDateTime||!1}static parseFormatForOpts(t,n={}){const r=WZ(t,en.fromObject(n));return r?r.map(s=>s?s.val:null).join(""):null}static expandFormat(t,n={}){return zZ(Xr.parseFormat(t),en.fromObject(n)).map(s=>s.val).join("")}static resetCache(){am=void 0,RE.clear()}get(t){return this[t]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?MC(this).weekYear:NaN}get weekNumber(){return this.isValid?MC(this).weekNumber:NaN}get weekday(){return this.isValid?MC(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?RC(this).weekday:NaN}get localWeekNumber(){return this.isValid?RC(this).weekNumber:NaN}get localWeekYear(){return this.isValid?RC(this).weekYear:NaN}get ordinal(){return this.isValid?EC(this.c).ordinal:NaN}get monthShort(){return this.isValid?im.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?im.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?im.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?im.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const t=864e5,n=6e4,r=I_(this.c),s=this.zone.offset(r-t),i=this.zone.offset(r+t),o=this.zone.offset(r-s*n),l=this.zone.offset(r-i*n);if(o===l)return[this];const c=r-o*n,u=r-l*n,d=O0(c,o),h=O0(u,l);return d.hour===h.hour&&d.minute===h.minute&&d.second===h.second&&d.millisecond===h.millisecond?[zc(this,{ts:c}),zc(this,{ts:u})]:[this]}get isInLeapYear(){return $x(this.year)}get daysInMonth(){return _1(this.year,this.month)}get daysInYear(){return this.isValid?Sh(this.year):NaN}get weeksInWeekYear(){return this.isValid?Lg(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Lg(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(t={}){const{locale:n,numberingSystem:r,calendar:s}=Xr.create(this.loc.clone(t),t).resolvedOptions(this);return{locale:n,numberingSystem:r,outputCalendar:s}}toUTC(t=0,n={}){return this.setZone(Jr.instance(t),n)}toLocal(){return this.setZone(On.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=Bl(t,On.defaultZone),t.equals(this.zone))return this;if(t.isValid){let s=this.ts;if(n||r){const i=t.offset(this.ts),o=this.toObject();[s]=Ly(o,i,t)}return zc(this,{ts:s,zone:t})}else return xt.invalid(om(t))}reconfigure({locale:t,numberingSystem:n,outputCalendar:r}={}){const s=this.loc.clone({locale:t,numberingSystem:n,outputCalendar:r});return zc(this,{loc:s})}setLocale(t){return this.reconfigure({locale:t})}set(t){if(!this.isValid)return this;const n=S1(t,HL),{minDaysInFirstWeek:r,startOfWeek:s}=EL(n,this.loc),i=!ft(n.weekYear)||!ft(n.weekNumber)||!ft(n.weekday),o=!ft(n.ordinal),l=!ft(n.year),c=!ft(n.month)||!ft(n.day),u=l||c,d=n.weekYear||n.weekNumber;if((u||o)&&d)throw new oh("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new oh("Can't mix ordinal dates with month/day");let h;i?h=NL({...w1(this.c,r,s),...n},r,s):ft(n.ordinal)?(h={...this.toObject(),...n},ft(n.day)&&(h.day=Math.min(_1(h.year,h.month),h.day))):h=jL({...EC(this.c),...n});const[f,m]=Ly(h,this.o,this.zone);return zc(this,{ts:f,o:m})}plus(t){if(!this.isValid)return this;const n=Ut.fromDurationLike(t);return zc(this,FL(this,n))}minus(t){if(!this.isValid)return this;const n=Ut.fromDurationLike(t).negate();return zc(this,FL(this,n))}startOf(t,{useLocaleWeeks:n=!1}={}){if(!this.isValid)return this;const r={},s=Ut.normalizeUnit(t);switch(s){case"years":r.month=1;case"quarters":case"months":r.day=1;case"weeks":case"days":r.hour=0;case"hours":r.minute=0;case"minutes":r.second=0;case"seconds":r.millisecond=0;break}if(s==="weeks")if(n){const i=this.loc.getStartOfWeek(),{weekday:o}=this;o<i&&(r.weekNumber=this.weekNumber-1),r.weekday=i}else r.weekday=1;if(s==="quarters"){const i=Math.ceil(this.month/3);r.month=(i-1)*3+1}return this.set(r)}endOf(t,n){return this.isValid?this.plus({[t]:1}).startOf(t,n).minus(1):this}toFormat(t,n={}){return this.isValid?Xr.create(this.loc.redefaultToEN(n)).formatDateTimeFromString(this,t):TC}toLocaleString(t=b1,n={}){return this.isValid?Xr.create(this.loc.clone(n),t).formatDateTime(this):TC}toLocaleParts(t={}){return this.isValid?Xr.create(this.loc.clone(t),t).formatDateTimeParts(this):[]}toISO({format:t="extended",suppressSeconds:n=!1,suppressMilliseconds:r=!1,includeOffset:s=!0,extendedZone:i=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=Fy(o);const l=t==="extended";let c=PC(this,l,o);return By.indexOf(o)>=3&&(c+="T"),c+=zL(this,l,n,r,s,i,o),c}toISODate({format:t="extended",precision:n="day"}={}){return this.isValid?PC(this,t==="extended",Fy(n)):null}toISOWeekDate(){return A0(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:t=!1,suppressSeconds:n=!1,includeOffset:r=!0,includePrefix:s=!1,extendedZone:i=!1,format:o="extended",precision:l="milliseconds"}={}){return this.isValid?(l=Fy(l),(s&&By.indexOf(l)>=3?"T":"")+zL(this,o==="extended",n,t,r,i,l)):null}toRFC2822(){return A0(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return A0(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?PC(this,!0):null}toSQLTime({includeOffset:t=!0,includeZone:n=!1,includeOffsetSpace:r=!0}={}){let s="HH:mm:ss.SSS";return(n||t)&&(r&&(s+=" "),n?s+="z":t&&(s+="ZZ")),A0(this,s,!0)}toSQL(t={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(t)}`:null}toString(){return this.isValid?this.toISO():TC}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(t={}){if(!this.isValid)return{};const n={...this.c};return t.includeConfig&&(n.outputCalendar=this.outputCalendar,n.numberingSystem=this.loc.numberingSystem,n.locale=this.loc.locale),n}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(t,n="milliseconds",r={}){if(!this.isValid||!t.isValid)return Ut.invalid("created by diffing an invalid DateTime");const s={locale:this.locale,numberingSystem:this.numberingSystem,...r},i=JOe(n).map(Ut.normalizeUnit),o=t.valueOf()>this.valueOf(),l=o?this:t,c=o?t:this,u=n$e(l,c,i,s);return o?u.negate():u}diffNow(t="milliseconds",n={}){return this.diff(xt.now(),t,n)}until(t){return this.isValid?Pn.fromDateTimes(this,t):this}hasSame(t,n,r){if(!this.isValid)return!1;const s=t.valueOf(),i=this.setZone(t.zone,{keepLocalTime:!0});return i.startOf(n,r)<=s&&s<=i.endOf(n,r)}equals(t){return this.isValid&&t.isValid&&this.valueOf()===t.valueOf()&&this.zone.equals(t.zone)&&this.loc.equals(t.loc)}toRelative(t={}){if(!this.isValid)return null;const n=t.base||xt.fromObject({},{zone:this.zone}),r=t.padding?this<n?-t.padding:t.padding:0;let s=["years","months","days","hours","minutes","seconds"],i=t.unit;return Array.isArray(t.unit)&&(s=t.unit,i=void 0),WL(n,this.plus(r),{...t,numeric:"always",units:s,unit:i})}toRelativeCalendar(t={}){return this.isValid?WL(t.base||xt.fromObject({},{zone:this.zone}),this,{...t,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...t){if(!t.every(xt.isDateTime))throw new Kr("min requires all arguments be DateTimes");return IL(t,n=>n.valueOf(),Math.min)}static max(...t){if(!t.every(xt.isDateTime))throw new Kr("max requires all arguments be DateTimes");return IL(t,n=>n.valueOf(),Math.max)}static fromFormatExplain(t,n,r={}){const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0});return UZ(o,t,n)}static fromStringExplain(t,n,r={}){return xt.fromFormatExplain(t,n,r)}static buildFormatParser(t,n={}){const{locale:r=null,numberingSystem:s=null}=n,i=en.fromOpts({locale:r,numberingSystem:s,defaultToEN:!0});return new HZ(i,t)}static fromFormatParser(t,n,r={}){if(ft(t)||ft(n))throw new Kr("fromFormatParser requires an input string and a format parser");const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0});if(!o.equals(n.locale))throw new Kr(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${n.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:d}=n.explainFromTokens(t);return d?xt.invalid(d):Rd(l,c,r,`format ${n.format}`,t,u)}static get DATE_SHORT(){return b1}static get DATE_MED(){return qX}static get DATE_MED_WITH_WEEKDAY(){return jOe}static get DATE_FULL(){return KX}static get DATE_HUGE(){return GX}static get TIME_SIMPLE(){return YX}static get TIME_WITH_SECONDS(){return XX}static get TIME_WITH_SHORT_OFFSET(){return ZX}static get TIME_WITH_LONG_OFFSET(){return QX}static get TIME_24_SIMPLE(){return JX}static get TIME_24_WITH_SECONDS(){return eZ}static get TIME_24_WITH_SHORT_OFFSET(){return tZ}static get TIME_24_WITH_LONG_OFFSET(){return nZ}static get DATETIME_SHORT(){return rZ}static get DATETIME_SHORT_WITH_SECONDS(){return sZ}static get DATETIME_MED(){return iZ}static get DATETIME_MED_WITH_SECONDS(){return oZ}static get DATETIME_MED_WITH_WEEKDAY(){return EOe}static get DATETIME_FULL(){return aZ}static get DATETIME_FULL_WITH_SECONDS(){return lZ}static get DATETIME_HUGE(){return cZ}static get DATETIME_HUGE_WITH_SECONDS(){return uZ}}function Lp(e){if(xt.isDateTime(e))return e;if(e&&e.valueOf&&ic(e.valueOf()))return xt.fromJSDate(e);if(e&&typeof e=="object")return xt.fromObject(e);throw new Kr(`Unknown datetime argument: ${e}, of type ${typeof e}`)}const w$e="3.7.2";mi.DateTime=xt;mi.Duration=Ut;mi.FixedOffsetZone=Jr;mi.IANAZone=ha;mi.Info=im;mi.Interval=Pn;mi.InvalidZone=fZ;mi.Settings=On;mi.SystemZone=Ax;mi.VERSION=w$e;mi.Zone=Of;var Hc=mi;vt.prototype.addYear=function(){this._date=this._date.plus({years:1})};vt.prototype.addMonth=function(){this._date=this._date.plus({months:1}).startOf("month")};vt.prototype.addDay=function(){this._date=this._date.plus({days:1}).startOf("day")};vt.prototype.addHour=function(){var e=this._date;this._date=this._date.plus({hours:1}).startOf("hour"),this._date<=e&&(this._date=this._date.plus({hours:1}))};vt.prototype.addMinute=function(){var e=this._date;this._date=this._date.plus({minutes:1}).startOf("minute"),this._date<e&&(this._date=this._date.plus({hours:1}))};vt.prototype.addSecond=function(){var e=this._date;this._date=this._date.plus({seconds:1}).startOf("second"),this._date<e&&(this._date=this._date.plus({hours:1}))};vt.prototype.subtractYear=function(){this._date=this._date.minus({years:1})};vt.prototype.subtractMonth=function(){this._date=this._date.minus({months:1}).endOf("month").startOf("second")};vt.prototype.subtractDay=function(){this._date=this._date.minus({days:1}).endOf("day").startOf("second")};vt.prototype.subtractHour=function(){var e=this._date;this._date=this._date.minus({hours:1}).endOf("hour").startOf("second"),this._date>=e&&(this._date=this._date.minus({hours:1}))};vt.prototype.subtractMinute=function(){var e=this._date;this._date=this._date.minus({minutes:1}).endOf("minute").startOf("second"),this._date>e&&(this._date=this._date.minus({hours:1}))};vt.prototype.subtractSecond=function(){var e=this._date;this._date=this._date.minus({seconds:1}).startOf("second"),this._date>e&&(this._date=this._date.minus({hours:1}))};vt.prototype.getDate=function(){return this._date.day};vt.prototype.getFullYear=function(){return this._date.year};vt.prototype.getDay=function(){var e=this._date.weekday;return e==7?0:e};vt.prototype.getMonth=function(){return this._date.month-1};vt.prototype.getHours=function(){return this._date.hour};vt.prototype.getMinutes=function(){return this._date.minute};vt.prototype.getSeconds=function(){return this._date.second};vt.prototype.getMilliseconds=function(){return this._date.millisecond};vt.prototype.getTime=function(){return this._date.valueOf()};vt.prototype.getUTCDate=function(){return this._getUTC().day};vt.prototype.getUTCFullYear=function(){return this._getUTC().year};vt.prototype.getUTCDay=function(){var e=this._getUTC().weekday;return e==7?0:e};vt.prototype.getUTCMonth=function(){return this._getUTC().month-1};vt.prototype.getUTCHours=function(){return this._getUTC().hour};vt.prototype.getUTCMinutes=function(){return this._getUTC().minute};vt.prototype.getUTCSeconds=function(){return this._getUTC().second};vt.prototype.toISOString=function(){return this._date.toUTC().toISO()};vt.prototype.toJSON=function(){return this._date.toJSON()};vt.prototype.setDate=function(e){this._date=this._date.set({day:e})};vt.prototype.setFullYear=function(e){this._date=this._date.set({year:e})};vt.prototype.setDay=function(e){this._date=this._date.set({weekday:e})};vt.prototype.setMonth=function(e){this._date=this._date.set({month:e+1})};vt.prototype.setHours=function(e){this._date=this._date.set({hour:e})};vt.prototype.setMinutes=function(e){this._date=this._date.set({minute:e})};vt.prototype.setSeconds=function(e){this._date=this._date.set({second:e})};vt.prototype.setMilliseconds=function(e){this._date=this._date.set({millisecond:e})};vt.prototype._getUTC=function(){return this._date.toUTC()};vt.prototype.toString=function(){return this.toDate().toString()};vt.prototype.toDate=function(){return this._date.toJSDate()};vt.prototype.isLastDayOfMonth=function(){var e=this._date.plus({days:1}).startOf("day");return this._date.month!==e.month};vt.prototype.isLastWeekdayOfMonth=function(){var e=this._date.plus({days:7}).startOf("day");return this._date.month!==e.month};function vt(e,t){var n={zone:t};if(e?e instanceof vt?this._date=e._date:e instanceof Date?this._date=Hc.DateTime.fromJSDate(e,n):typeof e=="number"?this._date=Hc.DateTime.fromMillis(e,n):typeof e=="string"&&(this._date=Hc.DateTime.fromISO(e,n),this._date.isValid||(this._date=Hc.DateTime.fromRFC2822(e,n)),this._date.isValid||(this._date=Hc.DateTime.fromSQL(e,n)),this._date.isValid||(this._date=Hc.DateTime.fromFormat(e,"EEE, d MMM yyyy HH:mm:ss",n))):this._date=Hc.DateTime.local(),!this._date||!this._date.isValid)throw new Error("CronDate: unhandled timestamp: "+JSON.stringify(e));t&&t!==this._date.zoneName&&(this._date=this._date.setZone(t))}var _$e=vt;function Qc(e){return{start:e,count:1}}function qL(e,t){e.end=t,e.step=t-e.start,e.count=2}function DC(e,t,n){t&&(t.count===2?(e.push(Qc(t.start)),e.push(Qc(t.end))):e.push(t)),n&&e.push(n)}function S$e(e){for(var t=[],n=void 0,r=0;r<e.length;r++){var s=e[r];typeof s!="number"?(DC(t,n,Qc(s)),n=void 0):n?n.count===1?qL(n,s):n.step===s-n.end?(n.count++,n.end=s):n.count===2?(t.push(Qc(n.start)),n=Qc(n.end),qL(n,s)):(DC(t,n),n=Qc(s)):n=Qc(s)}return DC(t,n),t}var k$e=S$e,C$e=k$e;function N$e(e,t,n){var r=C$e(e);if(r.length===1){var s=r[0],i=s.step;if(i===1&&s.start===t&&s.end===n)return"*";if(i!==1&&s.start===t&&s.end===n-i+1)return"*/"+i}for(var o=[],l=0,c=r.length;l<c;++l){var u=r[l];if(u.count===1){o.push(u.start);continue}var i=u.step;if(u.step===1){o.push(u.start+"-"+u.end);continue}var d=u.start==0?u.count-1:u.count;u.step*d>u.end?o=o.concat(Array.from({length:u.end-u.start+1}).map(function(f,m){var g=u.start+m;return(g-u.start)%u.step===0?g:null}).filter(function(f){return f!=null})):u.end===n-u.step+1?o.push(u.start+"/"+u.step):o.push(u.start+"-"+u.end+"/"+u.step)}return o.join(",")}var j$e=N$e,cu=_$e,E$e=j$e,KL=1e4;function Be(e,t){this._options=t,this._utc=t.utc||!1,this._tz=this._utc?"UTC":t.tz,this._currentDate=new cu(t.currentDate,this._tz),this._startDate=t.startDate?new cu(t.startDate,this._tz):null,this._endDate=t.endDate?new cu(t.endDate,this._tz):null,this._isIterator=t.iterator||!1,this._hasIterated=!1,this._nthDayOfWeek=t.nthDayOfWeek||0,this.fields=Be._freezeFields(e)}Be.map=["second","minute","hour","dayOfMonth","month","dayOfWeek"];Be.predefined={"@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *"};Be.constraints=[{min:0,max:59,chars:[]},{min:0,max:59,chars:[]},{min:0,max:23,chars:[]},{min:1,max:31,chars:["L"]},{min:1,max:12,chars:[]},{min:0,max:7,chars:["L"]}];Be.daysInMonth=[31,29,31,30,31,30,31,31,30,31,30,31];Be.aliases={month:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},dayOfWeek:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}};Be.parseDefaults=["0","*","*","*","*","*"];Be.standardValidCharacters=/^[,*\d/-]+$/;Be.dayOfWeekValidCharacters=/^[?,*\dL#/-]+$/;Be.dayOfMonthValidCharacters=/^[?,*\dL/-]+$/;Be.validCharacters={second:Be.standardValidCharacters,minute:Be.standardValidCharacters,hour:Be.standardValidCharacters,dayOfMonth:Be.dayOfMonthValidCharacters,month:Be.standardValidCharacters,dayOfWeek:Be.dayOfWeekValidCharacters};Be._isValidConstraintChar=function(t,n){return typeof n!="string"?!1:t.chars.some(function(r){return n.indexOf(r)>-1})};Be._parseField=function(t,n,r){switch(t){case"month":case"dayOfWeek":var s=Be.aliases[t];n=n.replace(/[a-z]{3}/gi,function(c){if(c=c.toLowerCase(),typeof s[c]<"u")return s[c];throw new Error('Validation error, cannot resolve alias "'+c+'"')});break}if(!Be.validCharacters[t].test(n))throw new Error("Invalid characters, got value: "+n);n.indexOf("*")!==-1?n=n.replace(/\*/g,r.min+"-"+r.max):n.indexOf("?")!==-1&&(n=n.replace(/\?/g,r.min+"-"+r.max));function i(c){var u=[];function d(g){if(g instanceof Array)for(var x=0,b=g.length;x<b;x++){var y=g[x];if(Be._isValidConstraintChar(r,y)){u.push(y);continue}if(typeof y!="number"||Number.isNaN(y)||y<r.min||y>r.max)throw new Error("Constraint error, got value "+y+" expected range "+r.min+"-"+r.max);u.push(y)}else{if(Be._isValidConstraintChar(r,g)){u.push(g);return}var v=+g;if(Number.isNaN(v)||v<r.min||v>r.max)throw new Error("Constraint error, got value "+g+" expected range "+r.min+"-"+r.max);t==="dayOfWeek"&&(v=v%7),u.push(v)}}var h=c.split(",");if(!h.every(function(g){return g.length>0}))throw new Error("Invalid list value format");if(h.length>1)for(var f=0,m=h.length;f<m;f++)d(o(h[f]));else d(o(c));return u.sort(Be._sortCompareFn),u}function o(c){var u=1,d=c.split("/");if(d.length>2)throw new Error("Invalid repeat: "+c);return d.length>1?(d[0]==+d[0]&&(d=[d[0]+"-"+r.max,d[1]]),l(d[0],d[d.length-1])):l(c,u)}function l(c,u){var d=[],h=c.split("-");if(h.length>1){if(h.length<2)return+c;if(!h[0].length){if(!h[1].length)throw new Error("Invalid range: "+c);return+c}var f=+h[0],m=+h[1];if(Number.isNaN(f)||Number.isNaN(m)||f<r.min||m>r.max)throw new Error("Constraint error, got range "+f+"-"+m+" expected range "+r.min+"-"+r.max);if(f>m)throw new Error("Invalid range: "+c);var g=+u;if(Number.isNaN(g)||g<=0)throw new Error("Constraint error, cannot repeat at every "+g+" time.");t==="dayOfWeek"&&m%7===0&&d.push(0);for(var x=f,b=m;x<=b;x++){var y=d.indexOf(x)!==-1;!y&&g>0&&g%u===0?(g=1,d.push(x)):g++}return d}return Number.isNaN(+c)?c:+c}return i(n)};Be._sortCompareFn=function(e,t){var n=typeof e=="number",r=typeof t=="number";return n&&r?e-t:!n&&r?1:n&&!r?-1:e.localeCompare(t)};Be._handleMaxDaysInMonth=function(e){if(e.month.length===1){var t=Be.daysInMonth[e.month[0]-1];if(e.dayOfMonth[0]>t)throw new Error("Invalid explicit day of month definition");return e.dayOfMonth.filter(function(n){return n==="L"?!0:n<=t}).sort(Be._sortCompareFn)}};Be._freezeFields=function(e){for(var t=0,n=Be.map.length;t<n;++t){var r=Be.map[t],s=e[r];e[r]=Object.freeze(s)}return Object.freeze(e)};Be.prototype._applyTimezoneShift=function(e,t,n){if(n==="Month"||n==="Day"){var r=e.getTime();e[t+n]();var s=e.getTime();r===s&&(e.getMinutes()===0&&e.getSeconds()===0?e.addHour():e.getMinutes()===59&&e.getSeconds()===59&&e.subtractHour())}else{var i=e.getHours();e[t+n]();var o=e.getHours(),l=o-i;l===2?this.fields.hour.length!==24&&(this._dstStart=o):l===0&&e.getMinutes()===0&&e.getSeconds()===0&&this.fields.hour.length!==24&&(this._dstEnd=o)}};Be.prototype._findSchedule=function(t){function n(y,v){for(var w=0,_=v.length;w<_;w++)if(v[w]>=y)return v[w]===y;return v[0]===y}function r(y,v){if(v<6){if(y.getDate()<8&&v===1)return!0;var w=y.getDate()%7?1:0,_=y.getDate()-y.getDate()%7,S=Math.floor(_/7)+w;return S===v}return!1}function s(y){return y.length>0&&y.some(function(v){return typeof v=="string"&&v.indexOf("L")>=0})}t=t||!1;var i=t?"subtract":"add",o=new cu(this._currentDate,this._tz),l=this._startDate,c=this._endDate,u=o.getTime(),d=0;function h(y){return y.some(function(v){if(!s([v]))return!1;var w=Number.parseInt(v[0])%7;if(Number.isNaN(w))throw new Error("Invalid last weekday of the month expression: "+v);return o.getDay()===w&&o.isLastWeekdayOfMonth()})}for(;d<KL;){if(d++,t){if(l&&o.getTime()-l.getTime()<0)throw new Error("Out of the timespan range")}else if(c&&c.getTime()-o.getTime()<0)throw new Error("Out of the timespan range");var f=n(o.getDate(),this.fields.dayOfMonth);s(this.fields.dayOfMonth)&&(f=f||o.isLastDayOfMonth());var m=n(o.getDay(),this.fields.dayOfWeek);s(this.fields.dayOfWeek)&&(m=m||h(this.fields.dayOfWeek));var g=this.fields.dayOfMonth.length>=Be.daysInMonth[o.getMonth()],x=this.fields.dayOfWeek.length===Be.constraints[5].max-Be.constraints[5].min+1,b=o.getHours();if(!f&&(!m||x)){this._applyTimezoneShift(o,i,"Day");continue}if(!g&&x&&!f){this._applyTimezoneShift(o,i,"Day");continue}if(g&&!x&&!m){this._applyTimezoneShift(o,i,"Day");continue}if(this._nthDayOfWeek>0&&!r(o,this._nthDayOfWeek)){this._applyTimezoneShift(o,i,"Day");continue}if(!n(o.getMonth()+1,this.fields.month)){this._applyTimezoneShift(o,i,"Month");continue}if(n(b,this.fields.hour)){if(this._dstEnd===b&&!t){this._dstEnd=null,this._applyTimezoneShift(o,"add","Hour");continue}}else if(this._dstStart!==b){this._dstStart=null,this._applyTimezoneShift(o,i,"Hour");continue}else if(!n(b-1,this.fields.hour)){o[i+"Hour"]();continue}if(!n(o.getMinutes(),this.fields.minute)){this._applyTimezoneShift(o,i,"Minute");continue}if(!n(o.getSeconds(),this.fields.second)){this._applyTimezoneShift(o,i,"Second");continue}if(u===o.getTime()){i==="add"||o.getMilliseconds()===0?this._applyTimezoneShift(o,i,"Second"):o.setMilliseconds(0);continue}break}if(d>=KL)throw new Error("Invalid expression, loop limit exceeded");return this._currentDate=new cu(o,this._tz),this._hasIterated=!0,o};Be.prototype.next=function(){var t=this._findSchedule();return this._isIterator?{value:t,done:!this.hasNext()}:t};Be.prototype.prev=function(){var t=this._findSchedule(!0);return this._isIterator?{value:t,done:!this.hasPrev()}:t};Be.prototype.hasNext=function(){var e=this._currentDate,t=this._hasIterated;try{return this._findSchedule(),!0}catch{return!1}finally{this._currentDate=e,this._hasIterated=t}};Be.prototype.hasPrev=function(){var e=this._currentDate,t=this._hasIterated;try{return this._findSchedule(!0),!0}catch{return!1}finally{this._currentDate=e,this._hasIterated=t}};Be.prototype.iterate=function(t,n){var r=[];if(t>=0)for(var s=0,i=t;s<i;s++)try{var o=this.next();r.push(o),n&&n(o,s)}catch{break}else for(var s=0,i=t;s>i;s--)try{var o=this.prev();r.push(o),n&&n(o,s)}catch{break}return r};Be.prototype.reset=function(t){this._currentDate=new cu(t||this._options.currentDate)};Be.prototype.stringify=function(t){for(var n=[],r=t?0:1,s=Be.map.length;r<s;++r){var i=Be.map[r],o=this.fields[i],l=Be.constraints[r];i==="dayOfMonth"&&this.fields.month.length===1?l={min:1,max:Be.daysInMonth[this.fields.month[0]-1]}:i==="dayOfWeek"&&(l={min:0,max:6},o=o[o.length-1]===7?o.slice(0,-1):o),n.push(E$e(o,l.min,l.max))}return n.join(" ")};Be.parse=function(t,n){var r=this;typeof n=="function"&&(n={});function s(i,o){o||(o={}),typeof o.currentDate>"u"&&(o.currentDate=new cu(void 0,r._tz)),Be.predefined[i]&&(i=Be.predefined[i]);var l=[],c=(i+"").trim().split(/\s+/);if(c.length>6)throw new Error("Invalid cron expression");for(var u=Be.map.length-c.length,d=0,h=Be.map.length;d<h;++d){var f=Be.map[d],m=c[c.length>h?d:d-u];if(d<u||!m)l.push(Be._parseField(f,Be.parseDefaults[d],Be.constraints[d]));else{var g=f==="dayOfWeek"?v(m):m;l.push(Be._parseField(f,g,Be.constraints[d]))}}for(var x={},d=0,h=Be.map.length;d<h;d++){var b=Be.map[d];x[b]=l[d]}var y=Be._handleMaxDaysInMonth(x);return x.dayOfMonth=y||x.dayOfMonth,new Be(x,o);function v(w){var _=w.split("#");if(_.length>1){var S=+_[_.length-1];if(/,/.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `,` special characters are incompatible");if(/\//.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `/` special characters are incompatible");if(/-/.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `-` special characters are incompatible");if(_.length>2||Number.isNaN(S)||S<1||S>5)throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return o.nthDayOfWeek=S,_[0]}return w}}return s(t,n)};Be.fieldsToExpression=function(t,n){function r(f,m,g){if(!m)throw new Error("Validation error, Field "+f+" is missing");if(m.length===0)throw new Error("Validation error, Field "+f+" contains no values");for(var x=0,b=m.length;x<b;x++){var y=m[x];if(!Be._isValidConstraintChar(g,y)&&(typeof y!="number"||Number.isNaN(y)||y<g.min||y>g.max))throw new Error("Constraint error, got value "+y+" expected range "+g.min+"-"+g.max)}}for(var s={},i=0,o=Be.map.length;i<o;++i){var l=Be.map[i],c=t[l];r(l,c,Be.constraints[i]);for(var u=[],d=-1;++d<c.length;)u[d]=c[d];if(c=u.sort(Be._sortCompareFn).filter(function(f,m,g){return!m||f!==g[m-1]}),c.length!==u.length)throw new Error("Validation error, Field "+l+" contains duplicate values");s[l]=c}var h=Be._handleMaxDaysInMonth(s);return s.dayOfMonth=h||s.dayOfMonth,new Be(s,n||{})};var I$e=Be;const T$e={},M$e=Object.freeze(Object.defineProperty({__proto__:null,default:T$e},Symbol.toStringTag,{value:"Module"})),R$e=Dne(M$e);var k1=I$e;function fc(){}fc._parseEntry=function(t){var n=t.split(" ");if(n.length===6)return{interval:k1.parse(t)};if(n.length>6)return{interval:k1.parse(n.slice(0,6).join(" ")),command:n.slice(6,n.length)};throw new Error("Invalid entry: "+t)};fc.parseExpression=function(t,n){return k1.parse(t,n)};fc.fieldsToExpression=function(t,n){return k1.fieldsToExpression(t,n)};fc.parseString=function(t){for(var n=t.split(`
915
+ `)}function KPe(e){const t=e.prompt??"hello";if(!e.gatewayUrl)return a.jsxs(yC,{children:["中心还没配调用地址(",a.jsx("code",{className:"font-mono",children:"PERSONA_CLOUD_GATEWAY_URL"}),"), 这里就给不出能跑的命令。persona 已经在云上了,派活不受影响。"]});if(e.apiKey===void 0)return a.jsx(yC,{children:"正在读你的调用 key…"});if(e.apiKey===null)return a.jsxs(yC,{children:["你还没有调用 key。去",e.onOpenSettings?a.jsx("button",{onClick:e.onOpenSettings,className:"mx-1 cursor-pointer text-accent hover:underline",children:"设置 → 账号"}):a.jsx("span",{className:"mx-1",children:"设置 → 账号"}),"生成一把,这里就会给出填好的命令。"]});const{gatewayUrl:n,apiKey:r,personaId:s}=e,i=C_(n,s),o=l=>yE({gatewayUrl:n,personaId:s,apiKey:r,prompt:t,entry:l});return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-text-400",children:"base_url"}),a.jsx("code",{className:"min-w-0 truncate font-mono text-text-200",children:i}),a.jsx(MX,{text:i,label:"复制"})]}),a.jsx(x1,{label:"chat curl",curl:o("chat")}),a.jsx(x1,{label:"task curl",curl:o("task")})]})}function x1(e){return a.jsxs("div",{className:"space-y-1 text-xs",children:[a.jsx("span",{className:"text-text-400",children:e.label}),a.jsxs("div",{className:"relative rounded-md border border-border bg-surface-page",children:[a.jsx("pre",{"data-testid":e.testId,className:"overflow-x-auto px-3 py-2.5 pr-24 font-mono text-[11px] leading-relaxed text-text-200",children:e.curl}),a.jsx("div",{className:"absolute right-2 top-2",children:a.jsx(MX,{text:e.curl,label:"复制 curl"})})]})]})}function yC(e){return a.jsx("div",{className:"text-[13px] leading-relaxed text-text-400",children:e.children})}function MX(e){const[t,n]=p.useState(!1),r=async()=>{try{await navigator.clipboard.writeText(e.text),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return a.jsxs("button",{onClick:()=>void r(),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-surface-card px-2 py-1 text-[11px] font-medium text-text-300 transition-colors hover:border-accent/50 hover:text-accent",children:[t?a.jsx(Gt,{className:"size-3 text-success"}):a.jsx(pa,{className:"size-3"}),t?"已复制":e.label]})}const GPe={build:"构建镜像",smoke:"云上试跑",deploy:"登记上线",[mo]:"自动验证"};function Ti(e){return a.jsxs("a",{href:e.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-[13px] text-accent hover:underline",children:[e.children,a.jsx(Lr,{className:"size-3"})]})}function YPe(e){return a.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-[13px]",children:e.rows.map(([t,n])=>a.jsxs("div",{className:"contents",children:[a.jsx("dt",{className:"text-text-400",children:t}),a.jsx("dd",{className:"min-w-0 truncate font-mono text-[12px] text-text-200",children:n})]},t))})}function v1(e){return a.jsx("div",{className:"text-xs text-text-400",children:e.children})}function y1(e,t){if(e===void 0||t===void 0)return;const n=Math.round((t-e)/1e3);if(!(n<0))return n<60?`${n}s`:`${Math.floor(n/60)}m${String(n%60).padStart(2,"0")}s`}function XPe(e){if(e.status!=="pending")return e.status==="waiting"?"等审批":e.status==="running"&&e.startedAt!==void 0?"进行中":y1(e.startedAt,e.completedAt)}function bC(e){return a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{children:"前面那一段挂了,这一段没有跑。云上跑的还是上一版。"}),a.jsxs("div",{className:"text-text-400",children:["修好重发之后,它会:",e.children]})]})}function wC(e){return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:e.what}),a.jsx(v1,{children:e.impact}),e.url&&a.jsx(Ti,{href:e.url,children:"看这一段的完整日志"})]})}function ZPe(e,t){const n=t.url,r=n?a.jsx(Ti,{href:n,children:t.status==="running"?"看实时日志":"看这一段的日志"}):null;if(e==="build")switch(t.status){case"pending":return a.jsx("div",{children:"会在 runner 上按清单把要装的东西装进底座镜像,构出一层 persona 镜像推到 ACR。镜像 tag 带 commit sha,不可变。"});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"正在按清单装东西,然后构镜像。"}),r]});case"done":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"镜像构出来了,清单里要装的都在、都报得出版本,persona 目录也在。已经推到 ACR。"}),r]});case"failed":return a.jsx(wC,{what:"构镜像这一步挂了。",url:n,impact:"云上跑的还是上一版,没被动过"});default:return a.jsx(bC,{children:"按清单装好东西、构出 persona 镜像推到 ACR。"})}if(e==="smoke")switch(t.status){case"pending":return a.jsxs("div",{children:["会拿刚构出来的镜像在集群上",a.jsx("b",{children:"临时登记一次"}),"、真起一个 Pod、投一句「只回复 ok」,验的是拉得到镜像、容器起得来、卷挂得上、codex 回得了话。验完就撤销。"]});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"临时登记好了,在等集群拉镜像、起 Pod。第一次拉几百 MB 的镜像会慢一些。"}),r]});case"done":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"集群拉到了镜像、容器起来了、codex 回了话。临时登记已经撤销,没有残留。"}),r]});case"failed":return a.jsx(wC,{what:"镜像在集群上没跑起来,或者跑起来了但没回话。",url:n,impact:"镜像构出来了,但没敢登记;云上跑的还是上一版"});default:return a.jsx(bC,{children:"拿新构出来的镜像在集群上临时起一次,验拉得到、起得来、回得了话。"})}switch(t.status){case"pending":return a.jsxs("div",{children:["会把这份镜像在 gateway 上登记成",a.jsx("b",{children:"正式"}),"。从这一刻起,别人派活过来起的就是这一版。同一台 gateway 上挂着别的 persona 不受影响,重新登记只覆盖自己那一行。"]});case"waiting":return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:["仓库给 ",a.jsx("code",{className:"font-mono",children:"production"})," 环境配了审核人,这一步停在这里等人点。批了才会登记成正式,云上现在跑的还是上一版。"]}),n&&a.jsx(Ti,{href:n,children:"去 GitHub 批准"})]});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"正在往 gateway 写这一版的登记(镜像地址 + 部署者提供的那几条凭据)。"}),r]});case"failed":return a.jsx(wC,{what:"gateway 没收下这次登记。",url:n,impact:"云上跑的还是上一版,没被动过"});case"done":return null;default:return a.jsx(bC,{children:"把这份镜像在 gateway 上登记成正式,别人派活过来就起这一版。"})}}function QPe(e,t,n){const r=n?"后来下线了,现在线上没有它。":t?"现在线上跑的就是它。":"后来被更新的发布覆盖了,线上跑的是标「线上」那条。";return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:["这一版在 gateway 上登记成了正式。",r]}),e.url&&a.jsx(Ti,{href:e.url,children:"看这一段的日志"})]})}const JPe=(e,t)=>()=>e(t);function En(e){return a.jsx("div",{className:"space-y-3",children:e.children})}function eDe(e){const t={key:"scan",label:"扫描"},{latest:n}=e;if(e.frozen){if(!n)return{...t,status:"done",meta:"记录已丢",detail:a.jsx("div",{children:"这次发布对应的扫描记录找不到了(可能是旧版 clawd 留下的)。"})};const s=y1(n.startedAt,n.finishedAt);return{...t,status:"done",...s?{meta:s}:{},detail:a.jsx("div",{children:"清单是这次扫描的,在下面的卡片里。"})}}if(e.starting)return{...t,status:"running",meta:"进行中",detail:a.jsxs(En,{children:[a.jsx("div",{children:e.repo?"正在把 persona 目录落存、起管家会话…":"正在建仓库、把 persona 提交进去、起管家会话…"}),e.actions]})};if(!n)return{...t,status:"pending",detail:a.jsxs(En,{children:[a.jsx("div",{children:"还没扫过。扫描会把 persona 整个读一遍,列出它挪到云上要预备什么:镜像里要装的东西、要连的连接器、要填的凭据。"}),e.actions]})};if(n.status==="scanning")return{...t,status:"running",meta:"进行中",detail:a.jsxs(En,{children:[a.jsx("div",{children:"管家在读 persona,清单在下面一条条长出来。右上角「管家分析中」能看它读了什么。"}),e.actions]})};if(n.status==="failed")return{...t,status:"failed",detail:a.jsxs(En,{children:[a.jsx("div",{children:n.error??"扫描没跑完。"}),a.jsx(v1,{children:"云上跑的还是上一版,没被动过。"}),e.actions]}),...e.onRescan?{onRetry:e.onRescan}:{}};const r=y1(n.startedAt,n.finishedAt);return ww(n,e.repo,e.lastRelease)?!e.anchored&&e.blockers.length>0?{...t,status:"waiting",meta:"等你处理",detail:a.jsxs(En,{children:[a.jsxs("div",{children:["扫完了,还差 ",a.jsxs("span",{className:"font-medium text-warning",children:[e.blockers.length," 项必填"]}),",填好就能发布。"]}),e.actions]})}:{...t,status:"done",...r?{meta:r}:{},detail:a.jsxs(En,{children:[a.jsx("div",{children:"清单是这一版扫的,在下面的卡片里。"}),e.actions]})}:{...t,status:"waiting",meta:"已过时",detail:a.jsxs(En,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-warning",children:"有未提交的改动"}),",最新这份清单是改动前扫的。要上云的话重新扫一遍。"]}),e.actions]})}}function _C(e){return a.jsx("ul",{className:"list-disc space-y-0.5 pl-5",children:e.lines.map(t=>a.jsx("li",{children:t},t))})}function tDe(e){const t={key:"config",label:"配置"},n=e.current&&e.tested?IPe(e.tested,e.current):[],r=e.runUrl?a.jsx(Ti,{href:e.runUrl,children:"在 GitHub 看应用配置的流水线"}):null;switch(e.phase.kind){case"editing":return e.blocker&&e.scanDone?{...t,status:"waiting",meta:"等你处理",detail:a.jsxs(En,{children:[a.jsx("div",{className:"text-warning",children:e.blocker}),e.actions]})}:{...t,status:e.scanDone?"done":"pending",detail:a.jsxs(En,{children:[a.jsx("div",{children:"引擎、模型和资源在下面定,随下一次「发测试环境」一起生效。发测试环境之后再改它们,不用重新扫描。"}),e.actions]})};case"synced":return{...t,status:"done",meta:"与测试一致",detail:a.jsxs(En,{children:[a.jsx("div",{children:"测试环境用的就是当前配置。之后改了引擎、模型或资源,回到这里「应用到测试环境」就行,不用重新扫描、重新构建。"}),e.actions]})};case"pending":return{...t,status:"waiting",meta:`改了 ${e.phase.keys.length} 项`,detail:a.jsxs(En,{children:[a.jsx("div",{children:"测试环境还是旧配置,已改:"}),a.jsx(_C,{lines:n}),a.jsx(v1,{children:"只重新登记并验证,不重新构建,几分钟;线上不受影响。应用并确认之前不能上线。"}),e.actions]})};case"needsRepublish":return{...t,status:"waiting",meta:"需重发",detail:a.jsxs(En,{children:[a.jsx("div",{children:"配置改了:"}),a.jsx(_C,{lines:n}),a.jsx("div",{children:"但这个仓库的发布流水线是旧版本,不认单独应用的配置。重新扫描、再发一次测试环境(会重新构建),之后就能直接应用配置了。"}),e.actions]})};case"applying":return{...t,status:"running",meta:"应用中",detail:a.jsxs(En,{children:[a.jsx("div",{children:"正在把新配置登记到测试环境,并重新验证真实对话(不重新构建)。"}),n.length>0&&a.jsx(_C,{lines:n}),r,e.actions]})};case"failed":return{...t,status:"failed",meta:"没通过",detail:a.jsxs(En,{children:[a.jsx("div",{className:"text-error",children:"应用配置没通过。"}),a.jsx(v1,{children:"测试环境里可能已经是新配置但没验证过,线上没有被动过。看日志找原因,改好配置后重新应用。"}),r,e.actions]})};case"unknown":return{...t,status:"done",meta:"无法比较",detail:a.jsxs(En,{children:[a.jsx("div",{children:"读不到测试环境当时用的配置,没法比较有没有改过。"}),e.actions]})}}}function nDe(e){const t={key:"push",label:"推送"};if(e.releasing)return{...t,status:"running",meta:"进行中",detail:a.jsxs(En,{children:[a.jsxs("div",{children:["正在把这次扫描的清单写进仓库、提交并推送到 ",a.jsx("code",{className:"font-mono",children:e.environment??"main"}),"…"]}),e.actions]})};if(!e.anchored||!e.released)return{...t,status:"pending",detail:a.jsx(En,{children:e.actions})};const n=e.released.head.slice(0,7);return{...t,status:"done",meta:n,detail:a.jsxs(En,{children:[e.run?a.jsxs(a.Fragment,{children:[e.released.reconfigOf?a.jsx("div",{children:"这一轮最近一次是「应用配置」:没有新的提交,复用上一次测试验证过的镜像,只换了配置。"}):a.jsxs("div",{children:["persona 目录和这次扫描的清单一起提交并推到了 ",a.jsx("code",{className:"font-mono",children:e.environment??"main"}),",下面这条流水线由这次推送触发。"]}),a.jsx(YPe,{rows:[["提交",n],["流水线",`#${e.run.runId}`]]}),a.jsx(Ti,{href:e.run.htmlUrl,children:"在 GitHub 看这次流水线"})]}):e.awaitingRun?a.jsx("div",{children:"提交推上去了,GitHub 那边还没把这次流水线列出来。通常几秒。"}):a.jsx("div",{children:"提交推上去了,但 GitHub 上没列出这一版的流水线:查不到 GitHub(没网 / 授权失效)、仓库的 Actions 没开、或者这条 run 已经被 GitHub 清掉了。刷新看看,或者去 GitHub 看。"}),e.actions]})}}const rDe={deploy:"应用配置后,会把新配置重新发到测试环境。",[mo]:"发到测试环境后,流水线会重新验证真实对话。",production:"新配置在测试环境验证通过后才能上线。"};function sDe(e,t){const n=t.kind;if(n!=="pending"&&n!=="applying"&&n!=="failed"&&n!=="needsRepublish")return;const r=d=>{d.status="pending",delete d.meta,delete d.onRetry,delete d.next;const h=rDe[d.key];h?d.detail=a.jsx("div",{children:h}):delete d.detail},s=e.findIndex(d=>d.key==="config");if(s<0)return;if(n==="needsRepublish"){for(const d of e.slice(s+1))r(d);return}const i=e.find(d=>d.key==="build"),o=e[s],l=e.filter(d=>d.key!=="scan"&&d.key!=="config"&&d.key!=="push"&&d.key!=="smoke"&&d.key!=="build"),c=i?[i.status!=="done"?i:{...i,status:"done",meta:"复用上次镜像",detail:a.jsx("div",{children:"只应用配置,不重新构建:用的是上一次测试验证过的镜像。"})}]:[];if(n==="pending")for(const d of l)r(d);else(n==="applying"||l.some(d=>d.status==="failed"))&&(o.status="done",o.meta="已提交");const u=l.findIndex(d=>d.status==="failed");if(u>=0)for(const d of l.slice(u+1))r(d);e.splice(0,e.length,e[0],...c,o,...l)}function RX(e){var y,v,w,_;const t=!!e.frozen,{released:n}=e,r=m1(e.scans,n),s=!!e.releasing&&!t,i=!!e.awaitingRun&&!t,o=t?n!==void 0:Dm(r,n),l=o&&!s&&Pu(n,e.run)?e.run:void 0,c=!t&&o&&e.retry&&e.retry.headSha===(n==null?void 0:n.head)&&(!e.run||e.run.runId===e.retry.runId)?e.retry:void 0,u=c?wm.indexOf(c.key):-1,d=[eDe({...r?{latest:r}:{},...e.repo?{repo:e.repo}:{},...e.lastRelease??n?{lastRelease:e.lastRelease??n}:{},blockers:e.blockers,starting:!!e.starting&&!t,anchored:o,frozen:t,...e.scanActions!==void 0&&!t?{actions:e.scanActions}:{},...e.onRescan&&!t?{onRescan:e.onRescan}:{}}),...e.config?[tDe({phase:e.config.phase,...e.config.current?{current:e.config.current}:{},...e.config.tested?{tested:e.config.tested}:{},...e.config.blocker?{blocker:e.config.blocker}:{},scanDone:!!r&&r.status==="done"&&ww(r,e.repo,e.lastRelease??n),...l!=null&&l.htmlUrl?{runUrl:l.htmlUrl}:{},...e.config.actions!==void 0?{actions:e.config.actions}:{}})]:[],nDe({...e.flow?{environment:"integration"}:{},...n?{released:n}:{},...l?{run:l}:{},releasing:s,anchored:o,awaitingRun:i,...e.releaseActions!==void 0?{actions:e.releaseActions}:{}})],h=!s&&o&&(l?l.status!=="completed":i),f=new Map((l==null?void 0:l.jobs.map(S=>[S.key,S]))??[]),m=!!e.flow&&(l==null?void 0:l.status)==="completed"&&!e.flow.confirmed&&!(n!=null&&n.reconfigOf);let g=!0;for(const S of wm){if(S===mo&&!e.flow&&!f.has(S))continue;const k=c&&wm.indexOf(S)>u,C=(c==null?void 0:c.key)===S,j=k?void 0:f.get(S),T=!c&&!j&&h&&g,E=!c&&h&&g&&((j==null?void 0:j.status)==="pending"||T&&(l==null?void 0:l.status)==="queued"),I=k?{status:"pending"}:C?{jobId:c.jobId,status:c.phase==="submitting"?"running":c.phase==="failed"?"failed":"waiting"}:j??{status:"pending"};g=g&&I.status==="done";const R=C?S==="build"?"等待构建开始":"等待这一步开始":"等待开始",P=C?c.phase==="submitting"?"正在重试":c.phase==="failed"?"重试请求失败":c.phase==="unknown"?"状态待确认":R:E?"排队中":T?R:XPe(I),O=C?a.jsxs(En,{children:[a.jsx("div",{children:c.phase==="submitting"?"正在提交重试请求,请不要重复点击。":c.phase==="failed"?"重试请求失败,请核实原因后重试。":c.phase==="unknown"?"暂时无法确认这次重试的状态。":"重试请求已返回,正在等待新一轮的执行状态。"}),c.error&&a.jsx("div",{className:"text-error",children:c.error}),(l==null?void 0:l.htmlUrl)&&a.jsx(Ti,{href:l.htmlUrl,children:"查看这次发布"}),c.phase==="unknown"&&e.onRefreshRetry&&a.jsx("button",{className:"text-accent hover:underline",onClick:e.onRefreshRetry,children:"刷新状态"})]}):E||T?a.jsxs(En,{children:[a.jsx("div",{children:E?"GitHub 已将这一步排队,等待开始执行。":"正在等待这一步的执行状态;尚未确认开始。"}),(l==null?void 0:l.htmlUrl)&&a.jsx(Ti,{href:l.htmlUrl,children:"查看这次发布"})]}):n!=null&&n.reconfigOf&&S==="build"&&I.status==="done"?a.jsxs(En,{children:[a.jsx("div",{children:"这次只应用配置,没有重新构建:用的是上一次测试验证过的镜像。"}),I.url&&a.jsx(Ti,{href:I.url,children:"看这一段的日志"})]}):e.flow&&S==="deploy"?a.jsxs(En,{children:[a.jsx("div",{children:I.status==="done"?"已发到测试环境,流水线接着自动验证真实对话。":"这一步会把本次版本发到测试环境。"}),I.url&&a.jsx(Ti,{href:I.url,children:"查看这一步的日志"})]}):S===mo?a.jsxs(En,{children:[a.jsx("div",{children:I.status==="running"?"流水线正在用测试账号验证真实对话,收到有效回复并正常结束才算通过。":I.status==="failed"?"自动对话验证失败,线上没有改动。查看日志后重试。":(y=e.flow)!=null&&y.confirmed?"测试通过,已收到有效回复并正常结束。上线将使用同一个版本。":I.status==="done"?"正在核对验证结果和测试环境版本;版本变化时需要重新发布测试。":(l==null?void 0:l.status)==="completed"?"这次发布没有通过自动对话验证,请重新扫描并发布测试环境。":"测试环境发布后,流水线会自动验证真实对话。"}),I.url&&a.jsx(Ti,{href:I.url,children:"查看这一步的日志"}),(v=e.flow)==null?void 0:v.testActions]}):S==="deploy"&&I.status==="done"&&t?QPe(I,e.live,!!e.offline):S==="deploy"&&I.status==="done"&&e.offline?a.jsx("div",{children:"这一版登记上线过,后来下线了:gateway 上已经没有它,别人看不到、用不了。重新扫描、发布就能再上线。"}):S==="deploy"&&I.status==="done"?a.jsx(KPe,{gatewayUrl:((w=e.cloud)==null?void 0:w.gatewayUrl)??null,personaId:e.personaId,apiKey:(_=e.cloud)==null?void 0:_.apiKey,...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{}}):ZPe(S,I);d.push({key:S,label:e.flow?{build:"构建",smoke:"自动试跑",deploy:"发测试环境",[mo]:"自动验证"}[S]:GPe[S],status:E||T||S===mo&&e.flow&&!c&&!e.flow.confirmed&&(I.status==="done"||(l==null?void 0:l.status)==="completed"&&!j)?"waiting":I.status,...P?{meta:P}:{},...O?{detail:O}:{},...(I.status==="failed"||m&&S==="build"&&I.status==="done")&&I.jobId!==void 0&&e.onRetry&&!t&&(!c||c.phase==="failed")?{onRetry:JPe(e.onRetry,I.jobId)}:{}})}if(e.flow){const{confirmed:S,promotion:k,productionActions:C,submissionError:j}=e.flow,T=!!e.flow.promoting&&!t,E=T?"正在提交上线":j?"上线请求失败":void 0,I=T?"正在核对测试版本并提交上线,请不要重复点击。":j?"上线请求失败,请核实原因后再继续。":(k==null?void 0:k.phase)==="completed"?"这一版已上线。":(k==null?void 0:k.phase)==="failed"?"上线失败,请查看原因后再继续。":k!=null&&k.error?"上线已暂停,请处理下面的问题后再继续。":(k==null?void 0:k.phase)==="main-pushed"?"已推送到线上分支,正在提交上线任务。":(k==null?void 0:k.phase)==="dispatching"?"正在向 GitHub 提交上线任务。":(k==null?void 0:k.phase)==="dispatched"?"上线任务已提交,正在等待执行结果。":(k==null?void 0:k.phase)==="prepared"?"正在准备上线已测试的版本。":S?"把已测试的提交推到线上分支,上线同一个版本。":"先等待自动对话验证通过。",R=e.repo&&(k!=null&&k.runId)?`${e.repo.url.replace(/\.git$/,"")}/actions/runs/${k.runId}`:void 0;d.push({key:"production",label:"发线上环境",status:T?"running":j?"failed":(k==null?void 0:k.phase)==="completed"?"done":(k==null?void 0:k.phase)==="failed"?"failed":k!=null&&k.error?"waiting":k?"running":"pending",...E?{meta:E}:{},detail:a.jsxs(En,{children:[a.jsx("div",{children:I}),!T&&(j||(k==null?void 0:k.error))&&a.jsx("div",{className:"text-error",children:j??(k==null?void 0:k.error)}),!T&&R&&a.jsx(Ti,{href:R,children:"查看上线进度"}),C]})})}e.config&&sDe(d,e.config.phase);const b=d.some(S=>S.status==="failed"||S.status==="running"||S.status==="waiting")?void 0:d.find(S=>S.status==="pending");return b&&(b.next=!0),d}function iDe(e,t,n){if(!e)return{kind:"missing"};const r=e.indexOf(":");if(r===-1)return{kind:"raw",text:e};const s=e.slice(0,r),i=e.slice(r+1);if(!i)return{kind:"raw",text:e};switch(s){case"npm":return{kind:"known",text:`npm i -g ${i}${t?`@${t}`:""}`};case"apt":return{kind:"known",text:`apt-get install -y ${i}`};case"pip":return{kind:"known",text:`pip install ${i}${t?`==${t}`:""}`};case"github":return n?{kind:"known",text:`从 GitHub release 拉二进制 · ${n.url.split("?")[0].split("/").pop()||n.url}`}:{kind:"known",text:`从 GitHub release 拉二进制 · ${i}${t?` v${t}`:""}`};default:return{kind:"raw",text:e}}}function oDe(e,t){if(e)return`= ${e}`;if(t)return`≥ ${t}`}function aDe(e){var r;if(!((r=e.from)!=null&&r.startsWith("apt:")))return;const t=e.localVersion?`(本机 ${e.localVersion})`:"",n=Xle.label;return e.name&&a7.includes(e.name)?{tone:"info",text:`云上底座自带,不从 ${n} 装${t}`}:e.aptMissing?{tone:"error",text:`${n} 没有这个包,云上装不了${t}`}:e.aptVersion?e.version?e.localVersion&&e.localVersion!==e.version?{tone:"warn",text:`云上装 ${n} 的 ${e.version},本机 ${e.localVersion}`}:{tone:"info",text:`云上装 ${n} 的 ${e.version}`}:{tone:e.min?"error":"warn",text:`云上是 ${n} 的 ${e.aptVersion}${e.min?`,不满足要求 ≥ ${e.min}`:",没按它钉版本"}${t}`}:{tone:"warn",text:`没查到 ${n} 里的版本,云上装它自带的${t}`}}function lDe(e,t){if(!t)return{tone:"warn",text:"本机未探到"};if(e!==t)return{tone:"error",text:`本机 ${t} ≠ 云上 ${e??"—"}`}}function cDe(e){const t=iDe(e.from,e.version,e.artifact);return a.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[a.jsx("span",{className:"shrink-0 text-text-500",children:"装法:"}),t.kind==="missing"?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-warning",children:"没查到"}),a.jsx("span",{className:"text-text-500",children:"· 见存疑项"})]}):a.jsx("code",{className:"rounded-sm border border-border bg-bg-100 px-1.5 py-0.5 text-text-400",children:t.text})]})}function PX(e){const t=oDe(e.version,e.min),n=aDe(e)??lDe(e.version,e.localVersion),r=e.blockers??[];return a.jsxs("div",{className:"border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:e.name}),r.length>0&&a.jsx(Px,{}),t&&a.jsx("span",{className:"font-mono text-xs text-text-400",children:t}),n&&a.jsx("span",{className:`text-xs ${n.tone==="error"?"text-error":n.tone==="warn"?"text-warning":"text-text-400"}`,children:n.text})]}),r.map(s=>a.jsx("div",{className:"mt-1 text-xs text-error",children:s},s)),a.jsx(cDe,{from:e.from,version:e.version,artifact:e.artifact}),e.evidence&&a.jsx(LM,{evidence:e.evidence})]})}const bE={none:{label:"不用账号",hint:e=>`${e} 是公开服务,不用登录就能用`},shared:{label:"发布者的账号",hint:e=>`用户用发布者的账号使用 ${e}:发布者在这一页填好自己的 key,所有人共用这一份`},personal:{label:"用户自己的账号",hint:e=>`用户用自己的账号使用 ${e}:每个用户第一次用时自己关联一次`}},$y={oauth:{label:"OAuth",hint:e=>`用户点链接跳到 ${e} 的授权页登录,不用碰 key`},fields:{label:"粘贴 API key",hint:()=>"用户把自己的 API key 粘进表单"}},DX=e=>e.runner==="cli"?w5(e)?"CLI · Lark App Bot":e.protocol==="lark-sidecar"?"CLI · 飞书 sidecar":"CLI":e.kind==="proxy"?"http MCP":"stdio MCP",uDe=e=>e.kind==="env"||e.fields.length>0?"fields":"oauth",dDe=/^[A-Z][A-Z0-9_]*$/;function hDe(e){const t=e.connector,[n,r]=p.useState(""),[s,i]=p.useState(null),o=t.name==="feishu"&&t.runner==="cli",l=w5(t),c=o,u=f7(t),d=!t.credentialSource,h=t.credentialSource==="personal"&&!t.auth,f=u.length>0&&!d&&!h,m=t.credentialSource==="personal",g=!o&&(t.credentialSource==="shared"||t.credentialSource==="personal"&&t.auth==="fields"),x=v=>{const{publisherUnionId:w,..._}=t;e.onChange({..._,kind:v==="bot"?"env":"proxy",protocol:v==="bot"?void 0:"lark-sidecar",credentialSource:v==="user"?"personal":"shared",auth:v==="bot"?"fields":"oauth",fields:v==="bot"?[...h7]:[]})},b=v=>{e.onChange({...t,credentialSource:v,...v==="personal"&&!t.auth?{auth:uDe(t)}:{}})},y=()=>{const v=n.trim();if(!dDe.test(v)){i("变量名只能是大写字母、数字、下划线,且以字母开头");return}t.fields.includes(v)||e.onChange({...t,fields:[...t.fields,v]}),r(""),i(null)};return a.jsxs("div",{className:"border-b border-border-card px-5 py-4 last:border-b-0","data-testid":`connector-row-${t.name}`,"data-required":u.length>0||void 0,children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:t.name}),a.jsx("span",{className:"rounded-sm bg-text-100-dim px-1.5 py-px text-[11px] text-text-400",children:DX(t)}),a.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-text-500",title:t.id,children:t.id})]}),e.evidence&&a.jsx(LM,{evidence:e.evidence}),a.jsx(li,{delayDuration:120,children:a.jsxs("div",{className:"mt-3 space-y-2",children:[o?a.jsx(Om,{label:"用谁的账号",name:"feishu-source",value:l?"bot":t.credentialSource==="shared"?"publisher":"user",options:[{value:"publisher",label:"发布者账号",hint:"所有使用者共用发布者的飞书 OAuth 权限;发布者需先关联飞书账号"},{value:"user",label:"用户自己的账号",hint:"每个使用者关联自己的飞书账号,使用本人权限"},{value:"bot",label:"Lark App Bot",hint:"发布者填写 App ID 和 App Secret,所有使用者共用这个应用的机器人身份"}],onPick:x}):a.jsx(Om,{label:"用谁的账号",required:d,name:`${t.name}-source`,value:t.credentialSource,options:u7.map(v=>({value:v,label:bE[v].label,hint:bE[v].hint(t.name)})),disabled:c,onPick:v=>b(v)}),m&&a.jsx(Om,{label:"关联方式",required:h,name:`${t.name}-auth`,value:t.auth,options:y5.filter(v=>t.kind==="proxy"||v==="fields").map(v=>({value:v,label:$y[v].label,hint:t.kind==="env"?`${$y[v].hint(t.name)}。进程型(stdio MCP / CLI)没有登录页,只有这一种`:$y[v].hint(t.name)})),disabled:c,onPick:v=>e.onChange({...t,auth:v})}),g&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"要填的变量:"}),f&&a.jsx(Px,{}),t.fields.map(v=>a.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-xs text-text-200",children:[v,a.jsx("button",{type:"button","aria-label":`去掉 ${v}`,className:"text-text-400 hover:text-error",onClick:()=>e.onChange({...t,fields:t.fields.filter(w=>w!==v)}),children:a.jsx(Yt,{className:"size-3"})})]},v)),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(ar,{"aria-label":`${t.name} 新增一个变量`,className:"h-7 w-44 font-mono text-xs",placeholder:"变量名,如 GH_TOKEN",value:n,onChange:v=>r(v.target.value.toUpperCase()),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),y())}}),a.jsx("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:y,children:"添加"})]}),s&&a.jsx("span",{className:"w-full text-xs text-error",children:s}),t.fields.length===0&&a.jsx("span",{className:"w-full text-xs text-text-500",children:t.runner==="cli"?"这个工具从哪个环境变量读凭据,查清楚填这里":"扫描没在 .mcp.json 里找到 ${VAR} 占位;它要什么就填什么"})]})]})}),o&&!l&&t.credentialSource==="shared"&&a.jsxs("div",{className:"mt-3 space-y-2 text-xs text-text-300",children:[a.jsx("p",{children:"所有使用者将使用你的飞书权限。请先关联发布者账号:"}),["integration","production"].map(v=>{var S;const w=(S=e.publisherAuth)==null?void 0:S[v],_=v==="integration"?"测试环境":"线上环境";return a.jsx("div",{children:w!=null&&w.connected?a.jsxs("span",{children:[_,":已关联"]}):w!=null&&w.authUrl?a.jsxs("a",{className:"text-accent underline",href:w.authUrl,target:"_blank",rel:"noopener noreferrer",children:["关联",_,"飞书账号"]}):a.jsxs("span",{children:[_,":",(w==null?void 0:w.error)??"请刷新授权状态"]})},v)}),a.jsx("button",{type:"button",className:"text-accent underline",onClick:e.onRefreshPublisherAuth,children:"刷新授权状态"})]}),e.secretCard&&(!o||l)&&a.jsx("div",{className:"mt-3 rounded-md border border-border-card bg-bg-50",children:e.secretCard})]})}function Om(e){return a.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"radiogroup","aria-label":e.label,children:[a.jsxs("span",{className:"w-20 shrink-0 text-xs text-text-400",children:[e.label,":"]}),e.required&&a.jsx(Px,{}),e.options.map(t=>{const n=t.value===e.value,r=a.jsx("button",{type:"button",role:"radio","aria-checked":n,disabled:e.disabled,"data-testid":`${e.name}-${t.value}`,onClick:()=>e.onPick(t.value),className:Q("rounded-full border px-2.5 py-0.5 text-xs transition-colors",n?"border-accent bg-accent text-accent-contrast":"border-border text-text-300 hover:border-accent/50 hover:text-accent",e.disabled&&"cursor-default opacity-70 hover:border-border hover:text-text-300"),children:t.label});return a.jsxs(Gi,{children:[a.jsx(Yi,{asChild:!0,children:r}),a.jsx(hi,{side:"top",className:"max-w-[360px]",children:t.hint})]},t.value)})]})}const nf=e=>new Date(e).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1});function fDe(e){const t=e.manifest,n=[t.packages.length?`镜像 ${t.packages.length}`:null,t.connectors.length?`连接器 ${t.connectors.length}`:null,t.secrets.length?`凭据 ${t.secrets.length}`:null,e.notes.length?`存疑项 ${e.notes.length}`:null].filter(r=>r!==null);return n.length?n.join(" · "):e.status==="scanning"?"…":"什么都不需要"}function pDe(e){const t=e.scans.map((l,c)=>({s:l,n:c+1})).reverse(),[n,r]=p.useState(!1),s=(l,c)=>{var u;return c===e.scans.length||((u=e.released)==null?void 0:u.scanId)===l.id||l.status==="scanning"||l.id===e.selectedId},i=n?t:t.filter(({s:l,n:c})=>s(l,c)),o=t.length-i.length;return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Yr,{icon:a.jsx(q5,{className:"size-[18px]"}),title:"扫描历史",count:`${e.scans.length} 次`}),a.jsxs("ul",{className:"divide-y divide-border-card","data-testid":"scan-history",children:[i.map(({s:l,n:c})=>{var g;const u=l.id===e.selectedId,d=c===e.scans.length,h=e.online!==!1&&((g=e.released)==null?void 0:g.scanId)===l.id,f=jce(l,e.released),m=(l.head??"").slice(0,7);return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>e.onSelect(l.id),"aria-current":u,"aria-label":`第 ${c} 次扫描`,className:`flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left text-[13px] transition-colors ${u?"bg-accent-dim/60":"hover:bg-text-100-dim/40"}`,children:[a.jsxs("span",{className:"w-8 shrink-0 font-mono text-xs text-text-400",children:["#",c]}),a.jsx("span",{className:"shrink-0 tabular-nums text-text-200",children:nf(l.startedAt)}),e.repo&&f&&m?a.jsxs("a",{href:`https://github.com/${$h(e.repo.url)}/commit/${l.head}`,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-accent hover:underline",children:[m,a.jsx(Lr,{className:"size-3"})]}):a.jsx("span",{className:"shrink-0 font-mono text-xs text-text-400",title:"还没推到 GitHub,发布之后才会有",children:m||"—"}),a.jsx("span",{className:"shrink-0 rounded-full bg-text-100-dim px-1.5 py-0.5 text-[11px] text-text-400",children:l.baseKind==="soft"?"软扫":"硬扫"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-text-300",children:fDe(l)}),d&&a.jsx("span",{className:"shrink-0 rounded-full bg-accent-dim px-1.5 py-0.5 text-[11px] font-medium text-accent",children:"最新"}),h&&a.jsx("span",{className:"shrink-0 rounded-full bg-success-dim px-1.5 py-0.5 text-[11px] font-medium text-success",children:"线上"}),a.jsx(mDe,{s:l})]})},l.id)}),o>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>r(!0),className:"flex w-full cursor-pointer items-center gap-1.5 px-4 py-2 text-xs text-text-400 hover:bg-text-100-dim/40 hover:text-text-200",children:[a.jsx(Jt,{className:"size-3.5"}),"还有 ",o," 次扫描"]})})]})]})}function mDe({s:e}){return e.status==="scanning"?a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-accent",children:[a.jsx(st,{className:"size-3 animate-spin"}),"进行中"]}):e.status==="failed"?a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-error",children:[a.jsx(Yt,{className:"size-3"}),"失败"]}):a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-text-400",children:[a.jsx(Gt,{className:"size-3 text-success"}),y1(e.startedAt,e.finishedAt)??"完成"]})}const $p={tiny:{label:"微",mem:"256 MB",hint:"纯对话、查资料"},small:{label:"小",mem:"512 MB",hint:"调 MCP、读写文件"},medium:{label:"中",mem:"1 GB",hint:"跑脚本、python / jq 这类"},large:{label:"大",mem:"2 GB",hint:"装依赖、构建、开浏览器"},xlarge:{label:"超大",mem:"4 GB",hint:"较大构建、内存密集任务"}},gDe=e=>e!==void 0&&S5.includes(e);function xDe(e){const t=p.useId(),n=e.taskConcurrency,r=e.size===void 0||e.size==="",s=r?Db:e.size,i=gDe(s),o=e.cpu===void 0,l=o?i?qN[s]:void 0:e.cpu,c=l!==void 0&&Ob.includes(l),u=!!e.disabled||!!e.saving;return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"resource-estimate",children:[a.jsx(Yr,{icon:a.jsx(U5,{className:"size-[18px]"}),title:"资源预估"}),a.jsxs("div",{className:"px-5 py-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-400",children:[a.jsx("span",{children:"内存:"}),a.jsx("span",{className:"text-text-300",children:"每 Pod 的内存预留与上限"}),r&&a.jsx("span",{children:"(没选过,按默认)"})]}),a.jsx("div",{className:"mt-2.5 grid grid-cols-2 gap-2 sm:grid-cols-5",role:"radiogroup","aria-label":"内存",children:S5.map(d=>{const h=d===s;return a.jsxs("button",{type:"button",role:"radio","aria-checked":h,"aria-label":`${$p[d].label} · ${$p[d].mem}`,disabled:u||!e.onChange,onClick:()=>{var f;h||(f=e.onChange)==null||f.call(e,d)},className:Q("rounded-md border px-3 py-2.5 text-left transition-colors",h?"border-accent bg-accent-dim":"border-border-card hover:border-accent/60"),children:[a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[a.jsx("span",{className:Q("text-base font-semibold",h?"text-accent":"text-text-100"),children:$p[d].label}),a.jsx("span",{className:"font-mono text-xs text-text-300",children:$p[d].mem}),d===Db&&a.jsx("span",{className:"ml-auto text-[11px] text-text-400",children:"默认"})]}),a.jsx("div",{className:"mt-0.5 text-xs text-text-400",children:$p[d].hint})]},d)})}),!i&&a.jsxs("div",{className:"mt-2 text-xs text-warning",children:["persona.json 里写的是 ",a.jsx("code",{className:"font-mono",children:s}),",不是支持的内存档,发布会被拒;点一档换掉"]}),a.jsxs("div",{className:"mt-5 border-t border-border-card pt-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-400",children:[a.jsx("span",{children:"CPU:"}),a.jsx("span",{className:"text-text-300",children:"每 Pod 的 CPU 预留与上限"})]}),a.jsx("div",{className:"mt-2.5 grid grid-cols-3 gap-2",role:"radiogroup","aria-label":"CPU",children:Ob.map(d=>{const h=d===l;return a.jsxs("button",{type:"button",role:"radio","aria-label":`${d} 核`,"aria-checked":h,disabled:u||!e.onChangeCpu,onClick:()=>{var f;(o||!h)&&((f=e.onChangeCpu)==null||f.call(e,d))},className:Q("rounded-md border px-3 py-2.5 text-left transition-colors",h?"border-accent bg-accent-dim":"border-border-card hover:border-accent/60"),children:[a.jsx("span",{className:Q("text-base font-semibold",h?"text-accent":"text-text-100"),children:d}),a.jsx("span",{className:"ml-1.5 text-xs text-text-300",children:"核"})]},d)})}),o&&c&&a.jsxs("div",{className:"mt-2 text-xs text-text-400",children:["未单独配置,暂按内存档位取 ",l," 核;点选任意 CPU 档位后独立配置(也可点当前档位),最后统一保存。"]}),!c&&a.jsx("div",{className:"mt-2 text-xs text-warning",children:o?"内存档位未知,无法确定默认 CPU;请选择 CPU 和内存后发布。":`CPU 配置 ${String(e.cpu)} 不在支持范围内,发布会被拒;请选择一档修复。`}),a.jsx("div",{role:"status",className:"mt-2 text-xs text-text-400",children:e.saving?"正在保存资源设置…":"在上方统一保存配置,再应用或发布到云上。预留不是独占物理核心。"}),e.error&&a.jsx("div",{role:"alert",className:"mt-2 text-xs text-error",children:e.error})]}),n&&a.jsxs("div",{className:"mt-5 border-t border-border-card pt-4",children:[a.jsx("label",{htmlFor:t,className:"text-sm font-medium text-text-100",children:"单 Pod 任务并发数"}),a.jsxs("div",{id:`${t}-hint`,className:"mt-1 text-xs leading-relaxed text-text-400",children:["每个 task Pod 最多同时运行的任务数,仅影响 task 调用。默认 4,随其他配置一起保存。",n.defaulted&&a.jsx("span",{children:"(未配置,按默认)"})]}),a.jsx("div",{className:"mt-2.5 flex items-center gap-2",children:a.jsx(ar,{id:t,inputMode:"numeric",className:"w-28",value:n.value,disabled:n.disabled,"aria-describedby":`${t}-hint${n.error?` ${t}-error`:""}`,"aria-invalid":!!n.error,onChange:d=>n.onChange(d.target.value)})}),n.error&&a.jsx("div",{id:`${t}-error`,role:"alert",className:"mt-2 text-xs text-error",children:n.error})]})]})]})}function Ox(e,t,n){var i;const r=n.find(o=>o.name==="effort"),s=e?t.find(o=>o.id===e):void 0;if(s!=null&&s.efforts&&s.efforts.length>0){const o=(i=r==null?void 0:r.options)==null?void 0:i.find(c=>c.value==="none");return{options:o?[o,...s.efforts.filter(c=>c.value!=="none")]:s.efforts,defaultValue:s.defaultEffort??""}}return{options:(r==null?void 0:r.options)??[],defaultValue:typeof(r==null?void 0:r.default)=="string"?r.default:""}}function OX(e,t){var r;const n=t.options.some(s=>s.value===e)?e:t.defaultValue;return{value:n,label:((r=t.options.find(s=>s.value===n))==null?void 0:r.label)??"默认"}}function N_(e,t,n){var c;if(!t)return((c=(e??[]).find(u=>u.id===""))==null?void 0:c.label)??"未指定";const r=t.toLowerCase(),s=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[u,d]of s){if(!r.includes(u))continue;const h=r.match(new RegExp(`${u}-(\\d+)(?:-(\\d+))?`));return h?h[2]?`${d} ${h[1]}.${h[2]}`:`${d} ${h[1]}`:d}const i=e??[],o=i.find(u=>u.id===t);if(o)return o.label;const l=i.find(u=>u.id&&t.toLowerCase().includes(u.id.toLowerCase()));return l?l.label:t}function vDe(e){return e.map(t=>({value:t.id,label:t.label,...t.description?{description:t.description}:{},...t.group?{group:t.group}:{}}))}function AX({testid:e,list:t,options:n,current:r,onSelect:s}){if(t.loading)return a.jsx(Tt,{disabled:!0,"data-testid":`${e}-loading`,className:"text-[12px] text-text-400",children:"正在读取最新模型…"});if(t.error)return a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":`${e}-error`,className:"px-2 py-1.5 text-[11px] text-warning",children:t.error}),a.jsx(Tt,{"data-testid":`${e}-retry`,className:"text-[12px]",onSelect:o=>{o.preventDefault(),t.load()},children:"重试"})]});const i=n??vDe(t.models);return i.length===0?a.jsx(Tt,{disabled:!0,"data-testid":`${e}-empty`,className:"text-[12px] text-text-400",children:"没有可选模型"}):a.jsx(a.Fragment,{children:zM(i).map((o,l)=>{const c=o.value===r;return a.jsxs(K.Fragment,{children:[o.groupHeading?a.jsxs(a.Fragment,{children:[l>0?a.jsx(da,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:o.groupHeading})]}):null,a.jsxs(Tt,{"data-testid":`${e}-option-${o.value||"default"}`,onSelect:()=>s(o.value),className:"items-start gap-2",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:Q("block text-[12px]",c?"font-medium text-text-100":"text-text-300"),children:o.label}),o.description?a.jsx("span",{className:"mt-0.5 block text-[11px] text-text-400",children:o.description}):null]}),c?a.jsx(Gt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent"}):null]})]},o.value||"default")})})}function j_({testid:e,list:t,options:n,current:r,onSelect:s,trigger:i,align:o="start",side:l,contentClassName:c}){const[u,d]=p.useState(!1),h=f=>{f&&!u&&t.load(),d(f)};return a.jsxs(is,{open:u,onOpenChange:h,children:[a.jsx(os,{asChild:!0,children:typeof i=="function"?i(()=>h(!0)):i}),a.jsx(zr,{align:o,...l?{side:l}:{},className:Q("max-h-[420px] w-[260px] overflow-y-auto",c),"data-testid":`${e}-menu`,children:a.jsx(AX,{testid:e,list:t,...n?{options:n}:{},current:r,onSelect:s})})]})}const yDe={codex:"Codex",pi:"pi",claude:"Claude"},bDe={codex:"Codex",pi:"pi",claude:"Claude Agent SDK"},ih="[1m]",wDe=e=>e.endsWith(ih)?e.slice(0,-ih.length):e;function _De(e){const[t,n]=p.useState(!1),r=il(e.tool),s=e.tool||"claude",i=s==="claude",o=i?wDe(e.model):e.model,l=i&&e.model.endsWith(ih),c=e.modelList.models,u=c.filter(g=>g.id!=="").map(g=>({value:g.id,label:g.label,...g.description?{description:g.description}:{},...g.group?{group:g.group}:{}})),d=!e.model,h=Ox(o,c,e.configSchema),{value:f,label:m}=OX(e.effort,h);return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"deploy-engine-card",children:[a.jsx(Yr,{icon:a.jsx(H5,{className:"size-[18px]"}),title:"引擎与模型"}),a.jsx(li,{delayDuration:120,children:a.jsxs("div",{className:"space-y-2.5 px-5 py-4",children:[a.jsx("div",{className:"text-xs text-text-400",children:i?"只影响云上:本机 Claude 的模型不变":"本地 persona 也会改变"}),a.jsx(Om,{label:"引擎",required:!r,name:"deploy-engine",value:r?s:void 0,options:T7.map(g=>({value:g,label:yDe[g],hint:`云上跑 ${bDe[g]} ${M7[g]}`})),onPick:g=>{g!==s&&e.onChange({tool:g})}}),!r&&a.jsxs("div",{className:"pl-[88px] text-xs text-warning",children:["现在是 ",s,",云上只跑 Codex、pi 或 Claude,选一个"]}),r&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"模型:"}),d&&a.jsx(Px,{}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[a.jsx(j_,{testid:"deploy-engine-model",list:e.modelList,options:u,current:o,onSelect:g=>{g!==o&&e.onChange({model:l?`${g}${ih}`:g})},trigger:a.jsx(Dx,{testid:"deploy-engine-model",label:d?"选一个模型":N_(c,o),needsAttention:d,disabled:e.allowManualModel})}),e.allowManualModel&&a.jsx("div",{className:"text-xs text-warning",children:"选择上方订阅通道即可读取模型;平台默认或旧订阅可在高级选项中指定模型 ID"}),e.allowManualModel&&a.jsxs("div",{className:"space-y-1",children:[a.jsx(ze,{size:"sm",variant:"ghost","aria-expanded":t,onClick:()=>n(g=>!g),children:"高级:指定模型 ID"}),t&&a.jsx(ar,{defaultValue:o,"aria-label":"云端模型 ID",placeholder:"模型 ID(高级)",onBlur:g=>{const x=g.target.value.trim();x&&x!==o&&e.onChange({model:l?x+ih:x})},onKeyDown:g=>{g.key==="Enter"&&g.currentTarget.blur()}},o)]})]})]}),r&&i&&!d&&a.jsx(Om,{label:"上下文",name:"deploy-engine-context",value:l?"1m":"default",options:[{value:"default",label:"默认",hint:"Claude 模型用它自己的窗口;号池里别的模型 Claude Code 不知道窗口多大,按 200K 用"},{value:"1m",label:"1M",hint:"模型 id 带 [1m]:Claude Code 按 1M 窗口用(模型本身和号池都要支持 1M,号池不报这个,要你自己确认)"}],onPick:g=>{g==="1m"!==l&&e.onChange({model:g==="1m"?`${o}${ih}`:o})}}),r&&!d&&h.options.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"推理强度:"}),a.jsx(bX,{align:"start",testid:"deploy-engine-effort",label:m,current:f,items:h.options.map(g=>({value:g.value,label:g.label})),onSelect:g=>{g!==f&&e.onChange({effort:g})}})]})]})})]})}function $X(e){const[t,n]=p.useState(""),[r,s]=p.useState(!1),[i,o]=p.useState(!1),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[h,f]=p.useState(null),{status:m}=e;if(!m)return null;const g=async()=>{if(!(!e.onAuthorize||t.trim().length===0)){c(!0),f(null);try{await e.onAuthorize(t.trim()),n(""),s(!1)}catch(v){f(v instanceof Error?v.message:String(v))}finally{c(!1)}}},x=async()=>{if(e.onStartOauth){d(!0),f(null);try{const v=await e.onStartOauth();v&&window.open(v,"_blank","noopener"),s(!1)}catch(v){f(v instanceof Error?v.message:String(v))}finally{d(!1)}}},b=e.onAuthorize&&a.jsxs("form",{className:"flex flex-wrap items-center gap-2",onSubmit:v=>{v.preventDefault(),g()},children:[a.jsx(ar,{type:"password",autoComplete:"off",placeholder:"ghp_… 或 github_pat_…","aria-label":"GitHub token",value:t,onChange:v=>n(v.target.value),className:"min-w-0 flex-1 font-mono text-xs",disabled:l||e.busy}),a.jsx(ze,{type:"submit",size:"sm",variant:"outline",disabled:l||e.busy||t.trim().length===0,children:l?"正在核对…":"用这个 token"}),a.jsxs("div",{className:"w-full text-xs text-text-400",children:["去 GitHub 建一个 classic personal access token,勾 ",a.jsx("code",{className:"font-mono",children:"repo"})," 和"," ",a.jsx("code",{className:"font-mono",children:"workflow"}),",账号要在 ",O7," 组织里。"]})]});if(m.status==="authorized"&&!r)return a.jsxs("div",{"data-testid":"github-account-card",className:"flex items-center gap-2 rounded-lg border border-border-card bg-surface-card px-4 py-2 text-xs text-text-300",children:[a.jsx(Gt,{className:"size-3.5 shrink-0 text-success"}),a.jsxs("span",{children:["GitHub 已关联 ",a.jsxs("span",{className:"font-mono text-text-100",children:["@",m.login]}),a.jsxs("span",{className:"text-text-400",children:[" · ",m.source==="git"?"来自本机 git 的凭据":"来自本机凭据表"]})]}),(e.onStartOauth||e.onAuthorize)&&a.jsx("button",{type:"button",onClick:()=>s(!0),className:"ml-auto cursor-pointer whitespace-nowrap text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"换一个"})]});if(m.status==="pending")return a.jsxs("div",{"data-testid":"github-account-card",className:"rounded-lg border border-border bg-surface-card",children:[a.jsxs("div",{className:"flex items-baseline gap-2 border-b border-border px-4 py-2.5",children:[a.jsx("span",{className:"self-center text-text-400",children:a.jsx(st,{className:"size-4 animate-spin"})}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:"等你在 GitHub 那页点「Authorize」"})]}),a.jsxs("div",{className:"space-y-2 px-4 py-3 text-[13px] leading-snug text-text-200",children:[a.jsx("div",{children:"已经在新标签页打开了 GitHub 的授权页。点同意之后会自动回到这里,这张卡会自己变绿。"}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsxs("a",{href:m.authUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-accent underline underline-offset-4",children:[a.jsx(Lr,{className:"size-3"}),"没打开的话点这里"]}),e.onAuthorize&&!i&&a.jsx("button",{type:"button",onClick:()=>o(!0),className:"cursor-pointer text-xs text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"或手动粘一个 token"})]}),i&&b,h&&a.jsx("div",{className:"text-xs text-error",children:h})]})]});const y=m.status==="invalid";return a.jsxs("div",{"data-testid":"github-account-card",className:`rounded-lg border bg-surface-card ${y?"border-error/40":m.status==="missing"?"border-warning/50":"border-border"}`,children:[a.jsxs("div",{className:"flex items-baseline gap-2 border-b border-border px-4 py-2.5",children:[a.jsx("span",{className:"self-center text-text-400",children:y?a.jsx(vg,{className:"size-4 text-error"}):a.jsx(gg,{className:"size-4"})}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:y?"GitHub 授权失效":m.status==="missing"?"先关联 GitHub":"换一个 GitHub 账号"})]}),a.jsxs("div",{className:"space-y-3 px-4 py-3",children:[y?a.jsx("div",{className:"text-[13px] leading-snug text-text-200",children:m.message}):a.jsxs("div",{className:"text-[13px] leading-snug text-text-200",children:["关联一次,app-builder 建仓推代码、persona 上云、PR 收件箱、persona 里的 git push 都用它。",m.status==="missing"&&" 本机 git 里没有 github.com 的凭据。","存在本机 git 里,clawd 不另存。"]}),e.onStartOauth&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsx(ze,{type:"button",size:"sm",onClick:()=>void x(),disabled:u||e.busy,children:u?"正在打开 GitHub…":"关联 GitHub"}),e.onAuthorize&&!i&&a.jsx("button",{type:"button",onClick:()=>o(!0),className:"cursor-pointer text-xs text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"或手动粘一个 token"})]}),(i||!e.onStartOauth)&&b,h&&a.jsx("div",{className:"text-xs text-error",children:h}),r&&!l&&!u&&a.jsx("button",{type:"button",onClick:()=>{s(!1),o(!1)},className:"cursor-pointer text-xs text-text-400 hover:text-accent",children:"算了,还用原来的"})]})]})}function uL(e){return a.jsxs("a",{href:e.href,target:"_blank",rel:"noreferrer",className:"inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-accent hover:underline",children:[e.children,a.jsx(Lr,{className:"size-3"})]})}function SDe(e){const[t,n]=p.useState(!1),{status:r}=e,s=()=>{var o;n(!1),(o=e.onUnpublish)==null||o.call(e)},i=(()=>{switch(r.kind){case"online":return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"size-2 shrink-0 rounded-full bg-success"}),a.jsxs("span",{className:"min-w-0 truncate",children:[a.jsx("span",{className:"text-text-100",children:"在线上"}),a.jsx("span",{className:"text-text-400",children:" · 别人能看到、能用"})]}),e.onUnpublish&&a.jsx(ze,{size:"sm",variant:"outline",className:"ml-auto h-7",disabled:e.busy,onClick:()=>n(!0),children:"下线"})]});case"unpublishing":return a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"size-3.5 shrink-0 animate-spin text-text-300"}),a.jsx("span",{className:"min-w-0 truncate text-text-100",children:"正在下线…"}),r.runUrl&&a.jsx("span",{className:"ml-auto",children:a.jsx(uL,{href:r.runUrl,children:"查看流水线"})})]});case"failed":return a.jsxs(a.Fragment,{children:[a.jsx(Sn,{className:"size-3.5 shrink-0 text-error"}),a.jsx("span",{className:"min-w-0 truncate text-text-100",children:"下线没成功"}),a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-3",children:[r.runUrl&&a.jsx(uL,{href:r.runUrl,children:"看日志"}),e.onUnpublish&&a.jsx(ze,{size:"sm",variant:"outline",className:"h-7",disabled:e.busy,onClick:()=>n(!0),children:"重试"})]})]});case"offline":return a.jsxs(a.Fragment,{children:[a.jsx(nhe,{className:"size-3.5 shrink-0 text-text-400"}),a.jsxs("span",{className:"min-w-0 truncate",children:[a.jsx("span",{className:"text-text-100",children:"已下线"}),a.jsx("span",{className:"text-text-400",children:" · 别人看不到、用不了。重新扫描、发布就能再上线"})]})]});case"unknown":return a.jsxs(a.Fragment,{children:[a.jsx(fH,{className:"size-3.5 shrink-0 text-text-400"}),a.jsx("span",{className:"min-w-0 truncate text-text-400",children:"查不到现在在不在线上"})]})}})();return a.jsxs("div",{"data-testid":"deploy-live-card",className:"rounded-lg border border-border-card bg-surface-card px-4 py-2 text-xs text-text-300",children:[a.jsx("div",{className:"flex min-h-7 items-center gap-2",children:i}),e.error&&a.jsx("div",{className:"mt-1 text-error",children:e.error}),a.jsx(xs,{open:t,onOpenChange:n,children:a.jsxs(ts,{children:[a.jsxs(Ls,{children:[a.jsx(ns,{children:"下线这个 persona?"}),a.jsx(zi,{children:"下线后别人看不到、也用不了它。正在进行的对话会继续到结束,聊天记录不会丢。以后重新扫描、发布就能再上线。"})]}),a.jsxs(Ja,{children:[a.jsx(ze,{variant:"outline",onClick:()=>n(!1),children:"取消"}),a.jsx(ze,{variant:"destructive",onClick:s,children:"确认下线"})]})]})})]})}function LX({test:e}){return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Yr,{icon:a.jsx(Gt,{className:"size-[18px]"}),title:"发布者验收",count:`${e.checks.length} 项必验`}),a.jsxs("div",{className:"space-y-2 px-5 py-4 text-[13px] text-text-300",children:[a.jsx("div",{className:"font-mono",children:e.entry}),a.jsx("div",{children:e.checks.join(" / ")}),a.jsxs("div",{className:"text-xs text-text-400",children:["测试环境候选镜像中执行 · 最长 ",e.timeoutSeconds," 秒 · 全部通过才可上线"]})]})]})}function kDe(e){var ke,ie,De,rt,ht,jt,Bt,hn,jn,Xn,zt;const t=e.state.targets?{...e.state,run:(ke=e.state.targets.integration)==null?void 0:ke.run,secrets:(ie=e.state.targets.integration)==null?void 0:ie.secrets}:e.state,{repo:n}=t,r=t.releases.find(pe=>{var ct;return pe.head===((ct=t.repo)==null?void 0:ct.head)})??ya(t.releases),s=SX(t,e.roundIdx??Ay(t)),i=e.starting?[]:s.scans,o=e.starting?void 0:s.release,l=((De=e.retry)==null?void 0:De.headSha)===(o==null?void 0:o.head)?e.retry:void 0,c=!!e.promoting&&!!o&&Dm(m1(i,o),o),u=e.busy||c||!!l&&l.phase!=="failed",d=kc(i),h=m1(i,o),f=!!e.starting,m=!!e.releasing,g=!!e.awaitingRun&&!!o,x=(d==null?void 0:d.status)==="scanning",b=t.run!==void 0&&t.run.status!=="completed",y=Dm(h,o),v=!t.github||t.github.status==="authorized",w=!e.engine||il(e.engine.tool),_=e.taskConcurrencyDraft??String(e.taskConcurrency??4),S=/^\d+$/.test(_.trim())&&Number.isSafeInteger(Number(_))&&Number(_)>0,k=e.onChangeTaskConcurrency&&!S?"请输入大于 0 的整数":void 0,C=e.resourceSaving?"正在保存配置,请等待保存完成":e.cpu!==void 0&&!Ob.includes(e.cpu)?"先在「资源预估」中修复 CPU 配置":void 0,j=e.configDirty?"配置有未保存的修改,请先保存配置":void 0,T=NX({current:e.currentConfig,release:o,run:t.run,anchored:y}),E=CX(e.engine)[0],I=C??k??j??E,[R,P]=p.useState(!1),[O,F]=p.useState(null),L=p.useRef(!1),U=async()=>{if(!(!e.onApplyConfig||!(o!=null&&o.id)||L.current)){L.current=!0,P(!0),F(null);try{await e.onApplyConfig(o.id)}catch(pe){F(pe instanceof Error?pe.message:String(pe))}finally{L.current=!1,P(!1)}}},[B,D]=p.useState(null),M=pe=>D({latestId:d==null?void 0:d.id,id:pe}),V=(B&&B.latestId===(d==null?void 0:d.id)?t.scans.find(pe=>pe.id===B.id):void 0)??h,z=V?t.scans.indexOf(V)+1:0,$=iL(t,h),q=iL(t,V),X=sD(V,n,r),G=I7(V,n,r),te=Dm(V,o),[ae,Z]=p.useState(null),J=ae?t.scans.find(pe=>pe.id===ae):void 0,be=`${(d==null?void 0:d.id)??""}-${(o==null?void 0:o.head)??""}`,[oe,ce]=p.useState(null),[se,he]=p.useState(x),me=v&&w&&!e.configDirty&&!e.resourceSaving&&!f&&!x&&!m&&!u&&!!e.onScan,Te=e.configDirty?"配置有未保存的修改,请先到「配置」保存":v?w?f?n?"正在落存、起管家会话…":"正在建仓库…":x?"管家在读 persona…":n?(d==null?void 0:d.status)==="done"&&!sD(d,n,r)?a.jsx("span",{className:"text-warning",children:"有未提交的改动,清单是改动前扫的"}):d?"再扫一遍会新增一条记录;发布默认用最新那次":"让管家读一遍 persona,列出它需要什么":`会先在 ${O7} 建一个私有仓库、把 persona 提交进去,再让管家读一遍它需要什么`:"云上只跑 Codex、pi 或 Claude,在「引擎与模型」里选一个":"先在上面那张卡里关联 GitHub",Ve=!!V&&V.status==="done"&&X&&q.length===0&&!x&&!f,ge=Ve,Ne=f||x?"等扫描结束":V?V.status==="failed"?"扫描失败了,重新扫描":X?q.length>0?`还差 ${q.length} 项,按下面标「必填」的那几行处理`:void 0:"有未提交的改动,先重新扫描":"先扫描",Me=a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"inline-flex",children:[a.jsxs(ze,{size:"sm",className:"rounded-r-none",onClick:()=>{var pe;return(pe=e.onScan)==null?void 0:pe.call(e)},disabled:!me,children:[f||x?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(Vfe,{className:"size-4"}),d?"重新扫描":"开始扫描"]}),a.jsxs(is,{children:[a.jsx(os,{asChild:!0,disabled:!me,children:a.jsx(ze,{size:"sm","aria-label":"选扫描方式",className:"rounded-l-none border-l border-accent-contrast/30 px-2",children:a.jsx(Jt,{className:"size-4"})})}),a.jsxs(zr,{align:"start",children:[a.jsx(Tt,{onSelect:()=>{var pe;return(pe=e.onScan)==null?void 0:pe.call(e,"soft")},children:a.jsxs("div",{children:[a.jsx("div",{children:"软扫"}),a.jsx("div",{className:"text-xs text-text-400",children:"只重看跟线上正跑那版有差别的部分;不成立会自动改硬扫"})]})}),a.jsx(Tt,{onSelect:()=>{var pe;return(pe=e.onScan)==null?void 0:pe.call(e,"hard")},children:a.jsxs("div",{children:[a.jsx("div",{children:"硬扫"}),a.jsx("div",{className:"text-xs text-text-400",children:"从零把 persona 整个读一遍"})]})})]})]})]}),a.jsxs(ze,{size:"sm",className:"shrink-0",disabled:!Ve,onClick:()=>ce({attempt:be,key:"config"}),title:Ve?"扫描这一段过了,去配置引擎、模型和资源":Ne,children:["下一步:配置 ",a.jsx(hD,{className:"size-4"})]})]}),a.jsx("div",{className:"text-xs text-text-400",children:Te}),e.scanError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.scanError})]}),Ue=i.filter(pe=>pe.status==="done"),ut=g?"刚推上去,等流水线跑起来":b?"上一次还在跑,等它走完":void 0,Ct=!!V&&V.status==="done"&&X&&q.length===0&&!ut&&!m&&!f&&!u&&!!e.onRelease&&!I&&!(G&&x),Nt=I??(m?"正在提交并推送…":Ue.length===0&&(V==null?void 0:V.status)!=="done"?"先扫描":!V||V.status!=="done"?"这次扫描没扫完,换一次":G&&x?"有一次扫描正在跑,等它扫完再回到旧版本":X?q.length>0?`还差 ${q.length} 项必填,回「扫描」段标「必填」的位置填`:ut||(te?"这一版已推到测试分支,继续查看测试结果":G?"会先把本机 persona 回到这次扫描时的内容,再推到测试分支,构建、自动试跑,再发到测试环境":"把这次扫描推到测试分支,构建、自动试跑,再发到测试环境"):"有未提交的改动,这次扫描之后内容变过;重新扫描,或在上面的扫描历史里换一次"),ne=Ice((rt=e.engine)==null?void 0:rt.tool,e.localEngineVersion),re=a.jsxs("div",{className:"space-y-3",children:[e.integrationLogin,ne&&a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-[13px] text-warning",role:"status",children:[a.jsx(Sn,{className:"mt-0.5 size-4 shrink-0"}),a.jsxs("div",{children:["本机 ",ne.tool," ",ne.local,",云上底座清单指定 ",ne.tool," ",ne.cloud,"。已发布 persona 的实际版本以其镜像为准;本机验过的行为不保证云上一样。"]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"text-text-400",children:"发布的扫描:"}),V&&V.status==="done"?a.jsx(CDe,{s:V,n:z,latest:V===d}):a.jsx("span",{className:"text-text-400",children:"—"}),a.jsx("span",{className:"text-xs text-text-400",children:"想发别的版本,在「扫描」段的扫描历史里点那一次"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsxs(ze,{size:"sm",onClick:()=>{var pe;!V||!Ct||(G?Z(V.id):(pe=e.onRelease)==null||pe.call(e,V.id))},disabled:!Ct,children:[m?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(vy,{className:"size-4"}),te?"查看测试发布":G?"回到这个版本并发测试环境":"发测试环境"]}),a.jsx("span",{className:"text-xs text-text-400",children:Nt}),e.releaseError&&a.jsx("div",{className:"w-full text-xs text-error",children:e.releaseError})]}),a.jsx(xs,{open:!!J,onOpenChange:pe=>{pe||Z(null)},children:a.jsxs(ts,{children:[a.jsxs(Ls,{children:[a.jsxs(ns,{children:["回到第 ",J?t.scans.indexOf(J)+1:0," 次扫描的版本?"]}),a.jsxs(zi,{children:["本机 persona 的文件会回到这次扫描时的样子(",((J==null?void 0:J.head)??"").slice(0,7),"),作为一个新提交,再推到测试分支。 没提交的改动会先自动保存;现在这一版仍留在 git 历史里(推送失败时这个回退提交会留在本机,重试即可)。引擎、模型和凭据用现在的设置,不跟着回去。"]})]}),a.jsxs(Ja,{children:[a.jsx(ze,{size:"sm",variant:"ghost",onClick:()=>Z(null),children:"取消"}),a.jsx(ze,{size:"sm",onClick:()=>{var ct;const pe=ae;Z(null),pe&&((ct=e.onRelease)==null||ct.call(e,pe))},children:"回到这个版本并发布"})]})]})}),y&&o&&n&&a.jsxs("div",{className:"text-xs text-text-400",children:["这一轮发的:第 ",t.scans.findIndex(pe=>pe.id===o.scanId)+1," 次扫描的清单 ·"," ",a.jsxs("a",{href:`https://github.com/${$h(n.url)}/commit/${o.head}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 font-mono text-accent hover:underline",children:[o.head.slice(0,7),a.jsx(Lr,{className:"size-3"})]})]})]}),Ee=R||T.kind==="applying",Ae=(T.kind==="pending"||T.kind==="failed")&&!!e.onApplyConfig&&!I&&!Ee&&!u&&!b&&!g&&!m&&!f,et=(ge||y)&&!I&&!f&&!m,qe=a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.onSaveConfig&&a.jsx(ze,{size:"sm",onClick:e.onSaveConfig,disabled:!e.configDirty||!S||!!e.resourceSaving||m||g||u||Ee,children:e.resourceSaving?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"size-4 animate-spin"}),"保存中…"]}):"保存配置"}),T.kind==="pending"||T.kind==="failed"||T.kind==="applying"?a.jsxs(ze,{size:"sm",onClick:()=>void U(),disabled:!Ae,children:[Ee?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(vy,{className:"size-4"}),T.kind==="applying"||R?"应用中":T.kind==="failed"?"重新应用":"应用到测试环境"]}):T.kind==="needsRepublish"?a.jsx(ze,{size:"sm",onClick:()=>ce({attempt:be,key:"scan"}),children:"去重新扫描"}):a.jsxs(ze,{size:"sm",disabled:!et,onClick:()=>ce({attempt:be,key:"push"}),title:et?void 0:I,children:["下一步:发测试环境 ",a.jsx(hD,{className:"size-4"})]}),I&&a.jsx("span",{className:"text-xs text-text-400",children:I})]}),e.configError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.configError}),O&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:O})]}),tt=RX({personaId:t.personaId,flow:{ready:!!(o!=null&&o.verified)&&Pu(o,t.run)&&sc(t.run)&&((jt=(ht=t.targets)==null?void 0:ht.integration)==null?void 0:jt.image)===o.verified.image,confirmed:Pu(o,t.run)&&sc(t.run)&&!!((Bt=o==null?void 0:o.verified)!=null&&Bt.verification.checks.includes("persona-dialogue"))&&((hn=t.run)==null?void 0:hn.jobs.some(pe=>pe.key===mo&&pe.status==="done"))===!0&&o.runId===t.run.runId&&o.runAttempt===t.run.runAttempt&&((Xn=(jn=t.targets)==null?void 0:jn.integration)==null?void 0:Xn.image)===((zt=o.verified)==null?void 0:zt.image),promotion:[...t.promotions??[]].reverse().find(pe=>pe.releaseId===(o==null?void 0:o.id)),testActions:e.testActions,productionActions:e.productionActions,promoting:c,submissionError:o&&!e.starting?e.productionError:void 0},...n?{repo:n}:{},scans:i,...o?{released:o}:{},...r?{lastRelease:r}:{},...t.run?{run:t.run}:{},blockers:$,starting:f,releasing:m,awaitingRun:g,...l?{retry:l}:{},...e.onRefreshRetry?{onRefreshRetry:e.onRefreshRetry}:{},...e.cloud?{cloud:e.cloud}:{},config:{phase:T,...e.currentConfig?{current:e.currentConfig}:{},...o!=null&&o.config?{tested:o.config}:{},...I?{blocker:I}:{},actions:qe},scanActions:Me,releaseActions:re,...e.onRetryJob?{onRetry:e.onRetryJob}:{},...e.onScan&&!u?{onRescan:()=>{var pe;return(pe=e.onScan)==null?void 0:pe.call(e)}}:{},...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{},offline:t.online===!1&&sc(t.run)}),Pt=p.useRef({attempt:be,key:g1(tt)??"scan"});Pt.current.attempt!==be&&(Pt.current={attempt:be,key:g1(tt)??"scan"});const wt=WPe(tt);wt&&(Pt.current.key=wt);const _e=oe&&oe.attempt===be?oe.key:Pt.current.key,Le=$b(t.secrets),dt=pe=>V==null?void 0:V.evidence.find(ct=>ct.target===pe),ot=V==null?void 0:V.manifest,dn=(()=>{if(!ot)return[];const pe=new Set(bw(ot).flatMap(ct=>ct.env));return ot.secrets.map(ct=>({...ct,env:ct.env.filter(on=>!pe.has(on))})).filter(ct=>ct.env.length>0)})();return a.jsxs("div",{className:"flex h-full overflow-hidden bg-surface-page text-text-100",children:[a.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 px-6 py-8",children:[a.jsx("div",{className:"sticky top-0 z-10 -mx-6 bg-surface-page/95 px-6 py-2 backdrop-blur",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Sw,{className:"size-5 text-accent"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-medium",children:"发布到云上"}),a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs text-text-400",children:[a.jsx("span",{className:"truncate",title:t.personaId,children:t.personaId}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx(NDe,{state:t,starting:f,scanBase:jDe(d)})]})]}),a.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.workPanel&&a.jsxs("button",{onClick:()=>he(pe=>!pe),"aria-expanded":se,className:"group inline-flex cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border border-accent/50 bg-accent-dim px-2.5 py-1 text-xs font-medium text-accent transition-colors hover:bg-accent hover:text-accent-contrast",children:[x?a.jsx(st,{className:"size-3 animate-spin"}):a.jsx(Gt,{className:"size-3"}),a.jsx("span",{children:x?"管家分析中":"管家的分析过程"}),a.jsx(Jt,{className:`size-3 transition-transform ${se?"-rotate-90":"rotate-90"}`})]})})]})}),a.jsx($X,{status:t.github,onAuthorize:e.onAuthorizeGithub,onStartOauth:e.onStartGithubOauth,busy:u}),e.live&&a.jsx(SDe,{status:e.live.status,busy:u,...e.live.error?{error:e.live.error}:{},...e.live.onUnpublish?{onUnpublish:e.live.onUnpublish}:{}}),a.jsxs(Id,{className:"border-accent/40",children:[a.jsx(Yr,{icon:a.jsx(vy,{className:"size-[18px]"}),title:"上云流程",tone:"accent"}),a.jsx("div",{className:"px-5 py-4",children:a.jsx(TX,{stages:tt,activeKey:_e,onPick:pe=>ce({attempt:be,key:pe})},be)})]}),_e==="scan"&&a.jsxs(a.Fragment,{children:[t.historyError&&a.jsx(Id,{className:"border-error/40",children:a.jsxs("div",{className:"px-4 py-3 text-[13px] leading-snug text-text-200",children:["扫描记录读不出来:",t.historyError,"。重新扫描会重建它。"]})}),!f&&t.scans.length>0&&a.jsx(pDe,{scans:t.scans,...n?{repo:n}:{},...r?{released:r}:{},...V?{selectedId:V.id}:{},...t.online!==void 0?{online:t.online}:{},onSelect:M}),ot&&V&&ot.packages.length>0&&a.jsxs(Id,{children:[a.jsx(Yr,{icon:a.jsx(kw,{className:"size-[18px]"}),title:"镜像",count:V.status==="scanning"?"还在长…":`${ot.packages.length} 项`}),ot.packages.map(pe=>a.jsx(PX,{name:pe.name,version:pe.version,min:pe.min,localVersion:pe.localVersion,from:pe.from,aptVersion:pe.aptVersion,aptMissing:pe.aptMissing,artifact:pe.artifact,evidence:dt(`package:${pe.name}`),blockers:p7(pe)},pe.name))]}),ot&&V&&ot.connectors.length>0&&a.jsxs(Id,{children:[a.jsx(Yr,{icon:a.jsx(Cw,{className:"size-[18px]"}),title:"连接器",count:`${ot.connectors.length} 个`}),ot.connectors.map(pe=>a.jsx(hDe,{connector:pe,publisherAuth:t.publisherFeishuAuth,onRefreshPublisherAuth:e.onRefreshPublisherAuth,evidence:dt(`connector:${pe.name}`),onChange:ct=>{var on;return(on=e.onPatchConnector)==null?void 0:on.call(e,V.id,ct)},...pe.credentialSource==="shared"&&pe.fields.length>0?{secretCard:a.jsx(xE,{embedded:!0,secret:{name:pe.name,env:pe.fields},presence:t.secrets?t.secrets.filter(ct=>pe.fields.includes(ct.env)):void 0,onSubmitValues:ct=>e.onPutSecret(V.id,pe.name,ct)})}:{}},pe.name))]}),ot&&V&&dn.length>0&&a.jsxs(Id,{children:[a.jsx(Yr,{icon:a.jsx(gg,{className:"size-[18px]"}),title:"凭据",count:`${dn.length} 条`}),dn.map(pe=>a.jsx(xE,{secret:pe,evidence:dt(`secret:${pe.name}`),presence:t.secrets?t.secrets.filter(ct=>pe.env.includes(ct.env)):void 0,onSubmitValues:ct=>e.onPutSecret(V.id,pe.name,ct)},pe.name))]}),(ot==null?void 0:ot.test)&&a.jsx(LX,{test:ot.test}),V&&V.notes.length>0&&a.jsxs(Id,{children:[a.jsx(Yr,{icon:a.jsx(Sn,{className:"size-[18px]"}),title:"存疑项",count:`${V.notes.length} 条`,tone:"warning"}),a.jsx("div",{className:"space-y-2 px-5 py-4",children:V.notes.map((pe,ct)=>a.jsxs("div",{className:"flex gap-2 text-[13px] leading-snug text-text-300",children:[a.jsx("span",{className:"shrink-0 text-warning",children:"•"}),pe]},ct))})]})]}),_e==="config"&&a.jsxs("fieldset",{className:"min-w-0 space-y-6",disabled:!!e.resourceSaving||m||g||u||Ee,children:[e.onChangeEngineAuth&&a.jsx(_X,{...Le?{state:Le}:{},channels:e.channels,channelId:e.engineChannelId,onRefreshChannels:e.onRefreshChannels,onAddChannel:e.onAddChannel,onChange:e.onChangeEngineAuth}),e.engine&&e.engineEditor&&a.jsx(_De,{tool:e.engine.tool,model:e.engine.model,effort:e.engine.effort??"",...e.engineEditor}),(e.onChangeSize||e.onChangeCpu)&&a.jsx(xDe,{size:e.size,cpu:e.cpu,onChange:e.onChangeSize,onChangeCpu:e.onChangeCpu,saving:e.resourceSaving,disabled:m||g||u||Ee,taskConcurrency:e.onChangeTaskConcurrency?{value:_,defaulted:e.taskConcurrency===void 0,disabled:m||g||!!e.resourceSaving,error:S?null:"请输入大于 0 的整数",onChange:e.onChangeTaskConcurrency}:void 0}),e.scanError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.scanError})]})]})}),e.workPanel&&a.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${se?"w-[380px]":"w-0"}`,children:a.jsx("div",{className:"h-full w-[380px] border-l border-border bg-surface-card",children:e.workPanel})})]})}function CDe(e){return a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsxs("span",{children:["第 ",e.n," 次"]}),a.jsx("span",{className:"text-text-400",children:nf(e.s.startedAt)}),a.jsx("span",{className:"font-mono text-xs text-text-400",children:(e.s.head??"").slice(0,7)}),a.jsx("span",{className:"text-xs text-text-400",children:e.s.baseKind==="soft"?"软扫":"硬扫"}),e.latest&&a.jsx("span",{className:"rounded-full bg-text-100-dim px-1.5 text-[11px] text-text-400",children:"最新"})]})}function NDe(e){const{repo:t}=e.state;if(!t)return a.jsx("span",{children:e.starting?"正在建仓库…":"还没有仓库"});const n=t.dirty?"有未提交的改动":t.ahead>0?`有 ${t.ahead} 个提交没推`:"已同步";return a.jsxs(a.Fragment,{children:[a.jsx(wu,{className:"size-3 shrink-0"}),a.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",title:$h(t.url),className:"truncate hover:text-accent hover:underline",children:$h(t.url)}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",children:t.branch}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:`shrink-0 ${t.dirty||t.ahead>0?"text-warning":""}`,children:n}),e.scanBase&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",title:e.scanBase.title,children:e.scanBase.label})]})]})}function jDe(e){if(e)return e.baseKind==="soft"?{label:"软扫",title:"只重看了跟线上正跑那版有差别的部分"}:{label:"硬扫",title:"从零把 persona 整个读了一遍"}}const Id=p.forwardRef(function(t,n){return a.jsx("div",{ref:n,className:`rounded-lg border border-border-card bg-surface-card ${t.className??""}`,children:t.children})});function EDe(e){const t=ca("sessions"),n=t==null?void 0:t.find(r=>r.sessionId===e.sessionId);return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-4 py-2.5",children:[e.live?a.jsx(st,{className:"size-3.5 animate-spin text-accent"}):a.jsx(Gt,{className:"size-3.5 text-success"}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:"管家在读这个 persona"}),a.jsx("span",{className:"text-xs text-text-400",children:e.live?"进行中":"可以接着问它"})]}),a.jsx("div",{className:"min-h-0 flex-1",children:n?a.jsx(S_,{extras:{session:n,api:e.api,hideHeader:!0,flatProcess:!0}},n.sessionId):a.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-xs text-text-400",children:[a.jsx(st,{className:"size-3.5 animate-spin"}),"正在接上管家的会话"]})})]})}function IDe(e){var wa,vr,ve,Qe,He,Ht,ur,Qi,rv,nd,sv,Xf,iv,rd,ov,Ji,av,Zf,sd,lv,cv,uv,gi,Qf,id,Ic,od;const{state:t,remoteReady:n,remoteError:r,loading:s,error:i,refresh:o,awaitingRun:l,retry:c,scan:u,patch:d,putSecret:h,setEngineAuth:f,release:m,rerunJob:g,applyConfig:x,unpublishFrom:b,unpublish:y,promote:v,openTest:w}=VM(e.personaId,{mode:"staged"}),_=Un(),S=qV(_,"integration"),[k,C]=p.useState(null),[j,T]=p.useState(null),[E,I]=p.useState(!1),[R,P]=p.useState(null),[O,F]=p.useState(!1),L=p.useRef(null),U=p.useRef(null),[B,D]=p.useState(!1),[M,V]=p.useState({personaId:e.personaId,patch:{}}),z=M.personaId===e.personaId?M:void 0,[$,q]=p.useState(null);p.useEffect(()=>{L.current=null,U.current=null,D(!1),V({personaId:e.personaId,patch:{}}),q(null),F(!1),P(null)},[e.personaId]);const[X,G]=p.useState(!1),te=p.useRef(e.personaId),ae=p.useRef(null);te.current!==e.personaId&&(te.current=e.personaId,ae.current=null),t&&n&&ae.current===null&&(ae.current=Ay(t));const Z=t?SX(t,ae.current??Ay(t)):void 0,J=!X&&Dm(m1(Z==null?void 0:Z.scans,Z==null?void 0:Z.release),Z==null?void 0:Z.release)?Z==null?void 0:Z.release:void 0,be=((ve=(vr=(wa=t==null?void 0:t.targets)==null?void 0:wa.integration)==null?void 0:vr.run)==null?void 0:ve.status)==="completed"&&t.targets.integration.run.conclusion==="success"&&!!(J!=null&&J.verified)&&((He=(Qe=t==null?void 0:t.targets)==null?void 0:Qe.integration)==null?void 0:He.image)===J.verified.image&&((Qi=(ur=(Ht=t==null?void 0:t.targets)==null?void 0:Ht.integration)==null?void 0:ur.run)==null?void 0:Qi.runId)===J.runId&&((sv=(nd=(rv=t.targets)==null?void 0:rv.integration)==null?void 0:nd.run)==null?void 0:sv.runAttempt)===J.runAttempt,oe=be&&!!((Xf=J==null?void 0:J.verified)!=null&&Xf.verification.checks.includes("persona-dialogue"))&&((ov=(rd=(iv=t==null?void 0:t.targets)==null?void 0:iv.integration)==null?void 0:rd.run)==null?void 0:ov.jobs.some(ye=>ye.key===mo&&ye.status==="done")),ce=t==null?void 0:t.scans.find(ye=>ye.id===(J==null?void 0:J.scanId)),se=(av=(Ji=t==null?void 0:t.targets)==null?void 0:Ji.production)==null?void 0:av.secrets,he=!!ce&&!!se&&nce(ce.manifest).every(ye=>se.some(yt=>yt.env===ye&&yt.setAt))&&((z==null?void 0:z.productionChannelId)!==void 0||$b(se)!=="partial"),me=[...(t==null?void 0:t.promotions)??[]].reverse().find(ye=>ye.releaseId===(J==null?void 0:J.id)),Te=HM(me),Ve=(me==null?void 0:me.phase)==="completed";p.useEffect(()=>{let ye=!1;return C(null),J!=null&&J.id&&e.api.sessionList().then(({sessions:yt})=>{ye||C(yt.find(Vn=>{var eo;return Vn.testReleaseId===J.id&&Vn.cloudExpectedImage===((eo=J.verified)==null?void 0:eo.image)})??null)}).catch(()=>{}),()=>{ye=!0}},[e.api,J==null?void 0:J.id,(Zf=J==null?void 0:J.verified)==null?void 0:Zf.image]);const ge=async()=>{if(J!=null&&J.id){I(!0),T(null);try{const ye=await w(J.id),eo=(await e.api.sessionList()).sessions.find(dl=>dl.testReleaseId===J.id&&dl.cloudExpectedImage===ye.expectedImage&&dl.ownerPersonaId===ye.personaId)??await e.api.sessionCreate({ownerPersonaId:ye.personaId,label:"测试 · "+e.personaId});C(eo)}catch(ye){T(ye instanceof Error?ye.message:String(ye))}finally{I(!1)}}},Ne=async()=>{if(!(J!=null&&J.id)||L.current||Te||Ve||U.current)return;const ye={releaseId:J.id};L.current=ye,F(!0),P(null);try{if((z==null?void 0:z.productionChannelId)!==void 0){if(await f(z.productionChannelId===null?null:{channelId:z.productionChannelId},"production"),L.current!==ye)return;V(yt=>({...yt,productionChannelId:void 0}))}await v(J.id)}catch(yt){L.current===ye&&P({releaseId:ye.releaseId,message:yt instanceof Error?yt.message:String(yt)})}finally{L.current===ye&&(L.current=null,F(!1))}},{status:Me,startOauth:Ue,authorize:ut}=jX(),Ct=p.useCallback(async()=>{const ye=await Ue();return await o(),ye},[Ue,o]),Nt=p.useCallback(async ye=>{await ut(ye),await o()},[ut,o]),ne=(Me==null?void 0:Me.status)==="authorized";p.useEffect(()=>{ne&&o()},[ne,o]);const{persona:re,refresh:Ee}=DM(e.personaId),Ae=re?{...re,...z==null?void 0:z.patch}:void 0,et=Ae?R7(Ae):void 0,qe=(z==null?void 0:z.concurrency)??String((re==null?void 0:re.taskConcurrency)??4),tt=/^\d+$/.test(qe.trim())&&Number.isSafeInteger(Number(qe))&&Number(qe)>0,Pt=(z==null?void 0:z.concurrency)!==void 0&&(!tt||Number(qe)!==((re==null?void 0:re.taskConcurrency)??4)),wt=(z==null?void 0:z.channelId)!==void 0||Pt||Object.entries((z==null?void 0:z.patch)??{}).some(([ye,yt])=>JSON.stringify(yt)!==JSON.stringify(re==null?void 0:re[ye])),_e=re?Pce(re):void 0,Le=wt?"配置有未保存的修改,请先保存配置":TPe(NX({current:_e,release:Z==null?void 0:Z.release,run:((lv=(sd=t==null?void 0:t.targets)==null?void 0:sd.integration)==null?void 0:lv.run)??(t==null?void 0:t.run),anchored:!!J})),dt=(et==null?void 0:et.tool)==="claude",{capabilities:ot}=ni(et&&il(et.tool)?et.tool:null),dn=APe(e.api,et==null?void 0:et.tool),[ke,ie]=p.useState([]),De=p.useRef(0),rt=p.useCallback(async()=>{const ye=++De.current,yt=await e.api.subscriptionChannelGet();De.current===ye&&ie(yt.channels)},[e.api]);p.useEffect(()=>(rt().catch(()=>{}),()=>{De.current++}),[rt]);const ht=ke.find(ye=>ye.id===(z==null?void 0:z.channelId)),jt=async ye=>{const yt=await e.api.subscriptionChannelSave(ye);De.current++,ie(yt.channels);const Vn=[...yt.channels].reverse().find(eo=>eo.name===ye.name&&eo.baseUrl===_ce(ye.baseUrl));if(!Vn)throw new Error("通道已保存,请刷新列表后选择");return Vn},Bt=(z==null?void 0:z.channelId)===void 0?(cv=t==null?void 0:t.engineChannels)==null?void 0:cv.integration:z.channelId===null?null:{channelId:z.channelId,...ht?{updatedAt:ht.updatedAt}:{}},hn=BPe(e.api,Bt),[jn,Xn]=p.useState(!1),[zt,pe]=p.useState(!1),[ct,on]=p.useState(null),[Xt,lr]=p.useState(null),[Zn,Ft]=p.useState(null),Dt=ye=>ye instanceof Error?ye.message:String(ye),Fn=async ye=>{const yt=ae.current;t&&(ae.current=t.releases.length),G(!0),on(null),lr(null),T(null),P(null);try{await u(ye)}catch(Vn){ae.current=yt,on(Dt(Vn))}finally{G(!1)}},Qn=async ye=>{if(!U.current){Xn(!0),lr(null),Ft(null);try{await m(ye)}catch(yt){lr(Dt(yt))}finally{Xn(!1)}}},Us=async ye=>{var yt,Vn,eo,dl;lr(null);try{await g(ye)}catch(Jf){!((eo=(Vn=(yt=t==null?void 0:t.targets)==null?void 0:yt.integration)==null?void 0:Vn.run)!=null&&eo.jobs.some(Tc=>Tc.jobId===ye))&&!((dl=t==null?void 0:t.run)!=null&&dl.jobs.some(Tc=>Tc.jobId===ye))&&lr(Dt(Jf))}},Ec=async()=>{pe(!0),Ft(null);try{await y()}catch(ye){Ft(Dt(ye).replace(/^[A-Z_]+: /,""))}finally{pe(!1)}},cr=ye=>{te.current!==e.personaId||L.current||Te||U.current||jn||l||(q(null),V(yt=>({...yt.personaId===e.personaId?yt:{personaId:e.personaId,patch:{}},...ye})))},Ss=ye=>{const yt="tool"in ye?{tool:ye.tool,model:ye.tool===((re==null?void 0:re.tool)??"claude")?re==null?void 0:re.model:void 0,effort:ye.tool===((re==null?void 0:re.tool)??"claude")?re==null?void 0:re.effort:void 0}:dt?{cloudEngine:{...Ae==null?void 0:Ae.cloudEngine,...ye}}:ye;cr({patch:{...z==null?void 0:z.patch,...yt}})},Zi=async()=>{if(U.current||!wt||!tt)return;const ye={};U.current=ye,D(!0),q(null);try{if((z==null?void 0:z.channelId)!==void 0&&(await f(z.channelId===null?null:{channelId:z.channelId}),U.current!==ye))return;const yt={...z==null?void 0:z.patch,...Pt?{taskConcurrency:Number(qe)}:{}};if(Object.keys(yt).length>0){const Vn=await e.api.personaUpdate(e.personaId,yt);if(U.current!==ye)return;Ee(Vn).catch(()=>{})}V(Vn=>Vn===z?{personaId:e.personaId,patch:{},productionChannelId:Vn.productionChannelId}:Vn)}catch(yt){U.current===ye&&q(Dt(yt))}finally{U.current===ye&&(U.current=null,D(!1))}};if(s&&!t)return a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-text-400",children:[a.jsx(st,{className:"size-4 animate-spin"}),"正在打开"]});if(i&&!t)return a.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-error",children:i});if(!t)return null;const Ws=kc(t.scans);return a.jsx(kDe,{state:t,..._e?{currentConfig:_e}:{},onApplyConfig:x,integrationLogin:S.identity?a.jsxs("div",{className:"text-xs text-text-400",children:["测试环境 · 已登录 ",S.identity.displayName]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(ze,{size:"sm",onClick:()=>{S.login().then(ye=>window.open(ye,"_blank","noopener,noreferrer")).catch(ye=>T(ye instanceof Error?ye.message:String(ye)))},children:"用当前飞书账号登录测试环境"}),S.error&&a.jsx("div",{className:"text-error",children:S.error})]}),testActions:a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex flex-wrap gap-2",children:a.jsx(ze,{size:"sm",onClick:()=>void ge(),disabled:!be||E,children:"打开测试对话(可选)"})}),j&&a.jsx("div",{className:"text-error",children:j}),k&&k.testReleaseId===(J==null?void 0:J.id)&&a.jsx("div",{className:"h-[480px] overflow-hidden rounded-lg border border-border",children:a.jsx(S_,{extras:{session:k,api:e.api,hideHeader:!0}},k.sessionId)})]}),productionActions:a.jsxs("div",{className:"space-y-3",children:[ce&&a.jsxs("details",{children:[a.jsx("summary",{className:"cursor-pointer",children:"线上环境的凭据"}),a.jsxs("fieldset",{disabled:O||Te||B,children:[a.jsx("div",{className:"text-xs text-text-400",children:"在这里填写线上使用的账号。测试环境的账号单独保存。"}),[...ce.manifest.secrets,...bw(ce.manifest)].map(ye=>a.jsx(xE,{secret:ye,presence:se,onSubmitValues:yt=>h(ce.id,ye.name,yt,"production")},ye.name)),a.jsx(_X,{disabled:O||Te||B,state:se?$b(se):void 0,channels:ke,channelId:(z==null?void 0:z.productionChannelId)!==void 0?z.productionChannelId:((uv=t.engineChannels)==null?void 0:uv.production)===null?null:(Qf=(gi=t.engineChannels)==null?void 0:gi.production)==null?void 0:Qf.channelId,onRefreshChannels:rt,onAddChannel:jt,onChange:ye=>cr({productionChannelId:(ye==null?void 0:ye.channelId)??null})})]})]}),Le&&a.jsx("div",{className:"text-warning",children:Le}),!Le&&!he&&oe&&a.jsx("div",{className:"text-warning",children:"先填齐线上环境的凭据,再上线。"}),a.jsx(ze,{size:"sm",onClick:()=>void Ne(),disabled:!oe||!!Le||!he||O||Te||Ve||B,children:O?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"mr-1.5 size-3.5 animate-spin"}),"正在提交上线"]}):Te?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"mr-1.5 size-3.5 animate-spin"}),"正在上线"]}):Ve?"已上线":"上线"})]}),starting:X,releasing:jn,awaitingRun:l,retry:c,promoting:O,productionError:(R==null?void 0:R.releaseId)===(J==null?void 0:J.id)&&!Te&&!Ve?R==null?void 0:R.message:void 0,onRefreshRetry:()=>void o(),busy:zt||O||Te,scanError:ct??(!n&&r?`读不到线上状态(${r}),先只显示本机已知的内容;关掉再打开发布页可重试。`:null),releaseError:Xt,onScan:ye=>void Fn(ye),onRelease:ye=>void Qn(ye),onRetryJob:ye=>void Us(ye),onPutSecret:h,onChangeEngineAuth:ye=>cr({channelId:(ye==null?void 0:ye.channelId)??null}),engineChannelId:(z==null?void 0:z.channelId)!==void 0?z.channelId:((id=t.engineChannels)==null?void 0:id.integration)===null?null:(od=(Ic=t.engineChannels)==null?void 0:Ic.integration)==null?void 0:od.channelId,configDirty:wt,configError:$,onSaveConfig:()=>void Zi(),channels:ke,onRefreshChannels:rt,onAddChannel:jt,onRefreshPublisherAuth:()=>void o(),onPatchConnector:(ye,yt)=>{on(null),d(ye,{connector:yt}).then(()=>yt.protocol==="lark-sidecar"&&yt.credentialSource==="shared"?o():void 0).catch(Vn=>on(Dt(Vn)))},onAuthorizeGithub:Nt,onStartGithubOauth:Ct,...et?{engine:et}:{},localEngineVersion:dn,...(Ae==null?void 0:Ae.size)!==void 0?{size:Ae.size}:{},...(Ae==null?void 0:Ae.cpu)!==void 0?{cpu:Ae.cpu}:{},resourceSaving:B,onChangeSize:ye=>cr({patch:{...z==null?void 0:z.patch,size:ye}}),onChangeCpu:ye=>cr({patch:{...z==null?void 0:z.patch,cpu:ye}}),...re?{taskConcurrency:re.taskConcurrency,taskConcurrencyDraft:qe,onChangeTaskConcurrency:ye=>cr({concurrency:ye})}:{},engineEditor:{modelList:hn,...Bt?{}:{allowManualModel:!0},configSchema:(ot==null?void 0:ot.configSchema)??[],onChange:Ss},roundIdx:ae.current??Ay(t),...MPe(t)||b!==void 0?{live:{status:WM(t,b),error:Zn,onUnpublish:()=>void Ec()}}:{},...e.cloud?{cloud:e.cloud}:{},...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{},...Ws!=null&&Ws.scanSessionId?{workPanel:a.jsx(EDe,{api:e.api,sessionId:Ws.scanSessionId,live:Ws.status==="scanning"})}:{}},e.personaId)}function BX(e,t,n){const r=Un(),[s,i]=p.useState({}),o=p.useRef(0),l=p.useRef(new Set);return p.useEffect(()=>{o.current++,l.current=new Set,i({})},[e]),p.useEffect(()=>{if(!n||!e)return;const c=t.filter(h=>!l.current.has(cn(h)));if(c.length===0)return;for(const h of c)l.current.add(cn(h));i(h=>({...h,...Object.fromEntries(c.map(f=>[cn(f),"loading"]))}));const u=o.current,d=new Wt(r);for(const h of c)d.deployGet(e,h.id?{releaseId:h.id,environment:h.environment}:{releaseHead:h.head}).then(f=>u===o.current&&i(m=>({...m,[cn(h)]:f.run})),()=>u===o.current&&i(f=>({...f,[cn(h)]:void 0})))},[r,e,t,n]),s}function FX(e){const{slot:t}=e;return t==="loading"?a.jsx(st,{className:"size-3 animate-spin text-text-400","aria-label":"查流水线"}):t===void 0?a.jsx("span",{className:"text-text-400",children:"查不到"}):t.status!=="completed"?a.jsxs("span",{className:"inline-flex items-center gap-1 text-accent",children:[a.jsx(st,{className:"size-3 animate-spin"}),"进行中"]}):sc(t)?a.jsxs("span",{className:"inline-flex items-center gap-1 text-success",children:[a.jsx(Gt,{className:"size-3"}),"成功"]}):a.jsxs("span",{className:"inline-flex items-center gap-1 text-error",children:[a.jsx(Yt,{className:"size-3"}),"失败"]})}function TDe(e){const{releases:t,scans:n}=e,[r,s]=p.useState(!1),i=UM(t,e.runs,e.online),o=ya(t),l=m=>m===o||m===i||kX(m,e.runs)||cn(m)===e.selectedHead,c=t.map((m,g)=>({r:m,n:g+1})).reverse(),u=r?c:c.filter(({r:m})=>l(m)),d=c.length-u.length,h=e.repo?$h(e.repo.url):void 0,f=m=>n.find(g=>g.id===m.scanId);return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Yr,{icon:a.jsx(q5,{className:"size-[18px]"}),title:"发布历史",count:`${t.length} 次`}),a.jsxs("ul",{className:"divide-y divide-border-card","data-testid":"release-history",children:[u.map(({r:m,n:g})=>{const x=cn(m)===e.selectedHead,b=f(m);return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>e.onSelect(cn(m)),"aria-current":x,"aria-label":`第 ${g} 次发布`,className:`flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left text-[13px] transition-colors ${x?"bg-accent-dim/60":"hover:bg-text-100-dim/40"}`,children:[a.jsxs("span",{className:"w-8 shrink-0 font-mono text-xs text-text-400",children:["#",g]}),a.jsx("span",{className:"shrink-0 tabular-nums text-text-200",children:nf(m.at)}),h?a.jsxs("a",{href:`https://github.com/${h}/commit/${m.head}`,target:"_blank",rel:"noreferrer",onClick:y=>y.stopPropagation(),className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-accent hover:underline",children:[m.head.slice(0,7),a.jsx(Lr,{className:"size-3"})]}):a.jsx("span",{className:"shrink-0 font-mono text-xs text-text-400",children:m.head.slice(0,7)}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-text-400",children:b?`${b.baseKind==="soft"?"软扫":"硬扫"} · ${nf(b.startedAt)}`:"扫描记录已丢"}),m.environment&&a.jsx("span",{className:"shrink-0 text-xs text-text-400",children:m.environment==="integration"?"测试":"线上发布"}),i&&cn(i)===cn(m)&&a.jsx("span",{className:"shrink-0 rounded-full bg-success-dim px-1.5 py-0.5 text-[11px] font-medium text-success",children:"线上"}),a.jsx("span",{className:"w-28 shrink-0 text-right text-xs",children:a.jsx(FX,{slot:e.runs[cn(m)]})})]})},cn(m))}),d>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>s(!0),className:"flex w-full cursor-pointer items-center gap-1.5 px-4 py-2 text-xs text-text-400 hover:bg-text-100-dim/40 hover:text-text-200",children:[a.jsx(Jt,{className:"size-3.5"}),"还有 ",d," 次发布"]})})]})]})}function R0(e){return a.jsx("div",{className:"rounded-lg border border-border-card bg-surface-card",children:e.children})}function MDe(e){const{scan:t}=e,n=t.manifest,r=s=>t.evidence.find(i=>i.target===s);return a.jsxs(a.Fragment,{children:[n.packages.length>0&&a.jsxs(R0,{children:[a.jsx(Yr,{icon:a.jsx(kw,{className:"size-[18px]"}),title:"镜像",count:`${n.packages.length} 项`}),n.packages.map(s=>a.jsx(PX,{name:s.name,version:s.version,min:s.min,localVersion:s.localVersion,from:s.from,aptVersion:s.aptVersion,aptMissing:s.aptMissing,artifact:s.artifact,evidence:r(`package:${s.name}`)},s.name))]}),n.connectors.length>0&&a.jsxs(R0,{children:[a.jsx(Yr,{icon:a.jsx(Cw,{className:"size-[18px]"}),title:"连接器",count:`${n.connectors.length} 个`}),n.connectors.map(s=>a.jsxs("div",{className:"flex items-baseline gap-3 border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsx("span",{className:"text-[15px] font-semibold",children:s.name}),a.jsx("span",{className:"text-xs text-text-400",children:DX(s)}),a.jsxs("span",{className:"ml-auto text-xs text-text-300",children:[s.credentialSource?bE[s.credentialSource].label:"—",s.credentialSource==="personal"&&s.auth?` · ${$y[s.auth].label}`:"",s.fields.length>0&&(s.credentialSource==="shared"||s.auth==="fields")?` · ${s.fields.join(" / ")}`:""]})]},s.name))]}),n.secrets.length>0&&a.jsxs(R0,{children:[a.jsx(Yr,{icon:a.jsx(gg,{className:"size-[18px]"}),title:"凭据",count:`${n.secrets.length} 条`}),n.secrets.map(s=>a.jsxs("div",{className:"flex items-baseline gap-3 border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsx("span",{className:"text-[15px] font-semibold",children:s.name}),a.jsx("span",{className:"ml-auto font-mono text-xs text-text-300",children:s.env.join(" / ")})]},s.name))]}),n.test&&a.jsx(LX,{test:n.test}),t.notes.length>0&&a.jsxs(R0,{children:[a.jsx(Yr,{icon:a.jsx(Sn,{className:"size-[18px]"}),title:"存疑项",count:`${t.notes.length} 条`,tone:"warning"}),a.jsx("div",{className:"space-y-2 px-5 py-4",children:t.notes.map((s,i)=>a.jsxs("div",{className:"flex gap-2 text-[13px] leading-snug text-text-300",children:[a.jsx("span",{className:"shrink-0 text-warning",children:"•"}),s]},i))})]})]})}function RDe(e){const{state:t,runs:n}=e,{releases:r,scans:s,repo:i}=t,[o,l]=p.useState(e.initialHead??null),c=(o?r.find(w=>cn(w)===o):void 0)??ya(r),u=c?r.indexOf(c)+1:0,d=UM(r,n,t.online),h=i?$h(i.url):void 0,f=c?s.find(w=>w.id===c.scanId):void 0,m=c?n[cn(c)]:void 0,g=m==="loading"?void 0:m,x=c?RX({personaId:t.personaId,frozen:!0,live:d!==void 0&&cn(d)===cn(c),offline:t.online===!1,scans:f?[f]:[],released:c,...g?{run:g}:{},blockers:[]}):[],[b,y]=p.useState(null),v=b&&c&&b.head===cn(c)?b.key:g1(x)??"scan";return a.jsx("div",{className:"flex h-full overflow-hidden bg-surface-page text-text-100",children:a.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 px-6 py-8",children:[a.jsx("div",{className:"sticky top-0 z-10 -mx-6 bg-surface-page/95 px-6 py-2 backdrop-blur",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(q5,{className:"size-5 text-accent"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-medium",children:"发布历史"}),a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs text-text-400",children:[a.jsx("span",{className:"truncate",title:t.personaId,children:t.personaId}),h&&i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx(wu,{className:"size-3 shrink-0"}),a.jsx("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"truncate hover:text-accent hover:underline",children:h})]}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",children:"只读"})]})]})]})}),r.length===0&&a.jsx("div",{className:"rounded-lg border border-border-card bg-surface-card px-5 py-6 text-[13px] text-text-300",children:"还没发布过。去 persona 卡片上点「发布到云上」,从扫描开始。"}),r.length>0&&a.jsx(TDe,{releases:r,scans:s,runs:n,...i?{repo:i}:{},...c?{selectedHead:cn(c)}:{},...t.online!==void 0?{online:t.online}:{},onSelect:w=>{l(w),y(null)}}),c&&a.jsxs("div",{className:"rounded-lg border border-accent/40 bg-surface-card",children:[a.jsx(Yr,{icon:a.jsx(vy,{className:"size-[18px]"}),title:`第 ${u} 次发布`,count:nf(c.at),tone:"accent"}),a.jsx("div",{className:"px-5 py-4",children:a.jsx(TX,{stages:x,activeKey:v,onPick:w=>y({head:cn(c),key:w})},cn(c))})]}),f&&a.jsx(MDe,{scan:f})]})})})}function PDe(e){const{state:t,loading:n,error:r}=VM(e.personaId),s=(t==null?void 0:t.releases)??[],i=BX(e.personaId,s,t!==null);if(n&&!t)return a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-text-400",children:[a.jsx(st,{className:"size-4 animate-spin"}),"正在打开"]});if(r&&!t)return a.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-error",children:r});if(!t)return null;const o=ya(s),l=o&&Pu(o,t.run)?{...i,[cn(o)]:t.run}:i;return a.jsx(RDe,{state:t,runs:l,...e.initialHead?{initialHead:e.initialHead}:{}})}const SC=10*60*1e3,dL=["bg-rose-500","bg-orange-500","bg-amber-500","bg-lime-500","bg-emerald-500","bg-cyan-500","bg-blue-500","bg-violet-500","bg-fuchsia-500"];function DDe(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return dL[Math.abs(t)%dL.length]}function ODe(e){const t=e.trim();if(!t)return"?";const n=t.split(/\s+/);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():t.slice(0,2).toUpperCase()}function wE(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ADe(e){const t=new Date(e),n=new Date,r=t.toDateString()===n.toDateString(),s=new Date(n);s.setDate(s.getDate()-1);const i=t.toDateString()===s.toDateString();return r?`今天 ${wE(e)}`:i?`昨天 ${wE(e)}`:t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function $De(e){const t=[];let n;for(let r=0;r<e.length;r++){const s=e[r];(!n||s.createdAt-n.createdAt>=SC)&&t.push({kind:"divider",divider:s.createdAt});const i=!!n&&n.fromOwner===s.fromOwner&&s.createdAt-n.createdAt<SC,o=e[r+1],l=o&&o.fromOwner===s.fromOwner&&o.createdAt-s.createdAt<SC;t.push({kind:"bubble",msg:s,showAvatar:!i,isLast:!l}),n=s}return t}function LDe({thread:e,messages:t,selfDisplayName:n,onSend:r,readOnlyHint:s}){const[i,o]=p.useState(""),l=p.useRef(null),c=p.useRef(null),u=p.useMemo(()=>$De(t),[t]);p.useEffect(()=>{const m=c.current;m&&(m.scrollTop=m.scrollHeight)},[t.length]);const d=()=>{const m=l.current;m&&(m.style.height="auto",m.style.height=Math.min(m.scrollHeight,160)+"px")};p.useEffect(()=>{d()},[i]);const h=()=>{const m=i.trim();m&&(r==null||r(m),o(""),l.current&&(l.current.value=""))},f=fi(h);return a.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full bg-bg-100",children:[a.jsxs("header",{className:"px-4 py-3 border-b border-border bg-elevated flex items-center gap-3 shrink-0",children:[a.jsx(qM,{name:e.peerDisplayName,size:"md"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h2",{className:"text-sm font-semibold text-text-100 leading-tight",children:e.peerDisplayName}),a.jsx("p",{className:"text-[11px] text-text-400 mt-0.5 flex items-center gap-1.5",children:s?a.jsx("span",{children:"访客"}):e.peerOnline?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-emerald-500"}),a.jsx("span",{children:"在线"})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-text-400"}),a.jsx("span",{children:"离线"})]})})]}),a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("button",{className:"p-2 rounded text-text-400 hover:bg-bg-200 hover:text-text-100 transition-colors",children:a.jsx(che,{className:"h-4 w-4"})})})]}),a.jsx("div",{ref:c,className:"flex-1 overflow-auto px-4 py-3 flex flex-col gap-1",children:t.length===0?a.jsx(BDe,{peerName:e.peerDisplayName}):u.map((m,g)=>m.kind==="divider"?a.jsx("div",{className:"flex items-center justify-center my-3",children:a.jsx("span",{className:"text-[10px] text-text-400 bg-bg-100 px-2 py-0.5 rounded-full",children:ADe(m.divider)})},`d-${g}`):a.jsx(FDe,{msg:m.msg,peerName:e.peerDisplayName,selfName:n,showAvatar:m.showAvatar,isLast:m.isLast},m.msg.id))}),!e.peerOnline&&!s&&a.jsxs("div",{className:"px-4 py-1.5 bg-amber-50 border-t border-amber-100 text-[11px] text-amber-900 shrink-0",children:[e.peerDisplayName," 离线,发出的消息会标记为失败"]}),s?a.jsx("footer",{"data-testid":"dm-readonly-hint",className:"px-4 py-3 border-t border-border bg-elevated shrink-0 text-[12px] text-text-400 text-center",children:s}):a.jsxs("footer",{className:"px-4 py-3 border-t border-border bg-elevated shrink-0",children:[a.jsxs("div",{className:"flex items-end gap-2 rounded-lg border border-border bg-bg-50 focus-within:border-accent focus-within:ring-1 focus-within:ring-accent transition-colors px-3 py-2",children:[a.jsx("textarea",{ref:l,rows:1,placeholder:`给 ${e.peerDisplayName} 发消息...`,value:i,onChange:m=>o(m.target.value),...f,className:"flex-1 resize-none bg-transparent text-sm text-text-100 placeholder:text-text-400 focus:outline-none leading-relaxed py-0.5",style:{maxHeight:160}}),a.jsx(ze,{size:"sm",variant:i.trim()?"default":"ghost",disabled:!i.trim(),onClick:h,className:"h-8 w-8 p-0 shrink-0",children:a.jsx(Nw,{className:"h-4 w-4"})})]}),a.jsxs("p",{className:"text-[10px] text-text-400 mt-1.5 px-1",children:[a.jsx("kbd",{className:"font-mono",children:"Enter"})," 发送 · ",a.jsx("kbd",{className:"font-mono",children:"Shift"}),"+",a.jsx("kbd",{className:"font-mono",children:"Enter"})," 换行"]})]})]})}function BDe({peerName:e}){return a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-4 py-8",children:[a.jsx(qM,{name:e,size:"xl"}),a.jsx("p",{className:"text-sm text-text-200 mt-4",children:e}),a.jsx("p",{className:"text-xs text-text-400 mt-1",children:"这是你们之间的开始 — 打个招呼吧"})]})}function FDe({msg:e,peerName:t,selfName:n,showAvatar:r,isLast:s}){const i=e.fromOwner,o=i?n:t;return a.jsxs("div",{className:Q("group flex items-start gap-2",i?"flex-row-reverse":"flex-row",r?"mt-2":"mt-0.5"),children:[a.jsx("div",{className:"w-7 shrink-0",children:r&&o?a.jsx(qM,{name:o,size:"sm"}):null}),a.jsxs("div",{className:Q("flex flex-col max-w-[70%] min-w-0",i?"items-end":"items-start"),children:[a.jsxs("div",{className:Q("px-3 py-1.5 break-words",i?"bg-accent text-accent-contrast":"bg-bg-200 text-text-100",i?Q("rounded-2xl",s?"rounded-br-md":"rounded-br-2xl",r?"rounded-tr-2xl":"rounded-tr-md"):Q("rounded-2xl",s?"rounded-bl-md":"rounded-bl-2xl",r?"rounded-tl-2xl":"rounded-tl-md")),children:[e.personaOrigin&&a.jsx("span",{"data-testid":"dm-persona-origin",className:Q("block text-[10px] mb-0.5 opacity-80",i?"text-accent-contrast":"text-text-300"),children:`${e.personaOrigin} 助手代发`}),a.jsx("p",{className:"text-[13.5px] leading-relaxed whitespace-pre-wrap",children:e.text})]}),a.jsxs("div",{className:Q("flex items-center gap-1 px-1 mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity",i?"flex-row-reverse":""),children:[a.jsx("span",{className:"text-[10px] text-text-400",children:wE(e.createdAt)}),i&&a.jsx(zDe,{status:e.deliveryStatus})]})]})]})}function zDe({status:e}){return e==="sending"?a.jsx(F5,{className:"h-3 w-3 text-text-400"}):e==="sent"?a.jsx(Gt,{className:"h-3 w-3 text-text-400"}):e==="delivered"?a.jsx($de,{className:"h-3 w-3 text-text-400"}):e==="failed"?a.jsx(fa,{className:"h-3 w-3 text-destructive"}):null}function qM({name:e,size:t="sm"}){const n=t==="xl"?"h-16 w-16 text-xl":t==="md"?"h-9 w-9 text-sm":"h-7 w-7 text-[11px]";return a.jsx("div",{className:Q("rounded-full flex items-center justify-center text-white font-semibold shrink-0",DDe(e),n),children:ODe(e)})}const HDe="访客消息由 persona 代发,这里不能回复——请到对应会话里处理";function UDe(e,t,n){var s;const r=e.senderDeviceId===t;return{id:e.id,threadId:e.peerDeviceId,fromOwner:r,fromDisplayName:r?void 0:n,text:e.text,createdAt:e.createdAt,deliveryStatus:r?"delivered":void 0,personaOrigin:((s=e.origin)==null?void 0:s.kind)==="persona"?e.origin.personaId:void 0}}function WDe({contact:e,im:t,selfPrincipalId:n,selfDisplayName:r,readOnly:s}){const i=t.ensurePeerLoaded;p.useEffect(()=>{i(e.deviceId)},[e.deviceId,i]);const o=p.useRef(new Map),l=t.messagesByPeerDeviceId.get(e.deviceId)??[],c=l.length>0?l[l.length-1].createdAt:0;p.useEffect(()=>{c===0||(o.current.get(e.deviceId)??0)>=c||(o.current.set(e.deviceId,c),t.markRead(e.deviceId,c))},[e.deviceId,c,t]);const u=p.useMemo(()=>(t.messagesByPeerDeviceId.get(e.deviceId)??[]).map(m=>UDe(m,n,e.displayName)),[t.messagesByPeerDeviceId,e.deviceId,e.displayName,n]),d=t.statusByPeerDeviceId.get(e.deviceId)==="connected",h={threadId:e.deviceId,peerAlias:e.deviceId,peerDisplayName:e.displayName,lastMessageAt:u.length>0?u[u.length-1].createdAt:0,lastMessagePreview:u.length>0?u[u.length-1].text:"",unreadCount:0,peerOnline:d};return a.jsx(LDe,{thread:h,messages:u,selfDisplayName:r,onSend:s?void 0:f=>void t.sendMessage(e.deviceId,f),readOnlyHint:s?HDe:void 0})}function VDe({status:e,onRetry:t,topBanner:n}){if(e.kind==="starting")return a.jsxs("div",{"data-testid":"extension-iframe-starting",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-bg-50",children:[a.jsx(st,{className:"w-6 h-6 text-text-300 animate-spin"}),a.jsxs("div",{className:"text-[13px] text-text-200",children:["Starting ",e.name,"…"]}),a.jsx("div",{className:"text-[11px] text-text-400/80",children:"spawning child process"})]});if(e.kind==="error")return a.jsxs("div",{"data-testid":"extension-iframe-error",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-bg-50 px-8",children:[a.jsx(Sn,{className:"w-6 h-6 text-red-400"}),a.jsxs("div",{className:"text-[13px] text-text-100",children:["Failed to start ",e.name]}),a.jsx("div",{className:"text-[11px] text-text-400/90 max-w-md text-center font-mono",children:e.message}),a.jsxs("button",{type:"button",onClick:t,"data-testid":"extension-iframe-retry",className:Q("mt-1 flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[12px]","border border-border text-text-200 hover:text-text-100 hover:bg-text-100/5 transition-colors"),children:[a.jsx(wf,{className:"w-3.5 h-3.5"}),"Retry"]})]});const r=e.target.kind==="local"?`http://127.0.0.1:${e.target.port}/`:e.target.url;return a.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n,a.jsx("iframe",{"data-testid":"extension-iframe-running","data-target-kind":e.target.kind,title:e.name,src:r,className:"flex-1 w-full h-full border-0 bg-bg-50",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox"})]})}function qDe({state:e,onUpdate:t,onDismiss:n,onViewLogs:r}){if(e.kind==="idle")return null;const s=YDe(e.kind);return a.jsxs("div",{"data-testid":"update-available-banner","data-state":e.kind,className:Q("flex items-center gap-2 px-4 h-9 shrink-0 text-[12px] border-b",s.className),children:[a.jsx(s.Icon,{className:Q("w-3.5 h-3.5 shrink-0",s.iconClassName),"aria-hidden":!0}),a.jsx("span",{className:"truncate flex-1",children:KDe(e)}),GDe(e,{onUpdate:t,onDismiss:n,onViewLogs:r})]})}function KDe(e){switch(e.kind){case"available":return`${e.extName} 有新版 v${e.toVersion}(当前 v${e.fromVersion})`;case"updating":{const t={fetching:"拉取中",extracting:"应用中",restarting:"重启中"}[e.step];return`正在更新 ${e.extName} → v${e.toVersion}(${t}…)`}case"success":return`${e.extName} 已更新到 v${e.toVersion}`;case"failed-rollback":return`${e.extName} v${e.attemptedVersion} 启动失败,已回退到 v${e.rolledBackTo}`}}function GDe(e,{onUpdate:t,onDismiss:n,onViewLogs:r}){return e.kind==="available"?a.jsxs(a.Fragment,{children:[a.jsx(hL,{tone:"accent",onClick:t,testId:"update-banner-update",children:"更新"}),a.jsx(kC,{onClick:n})]}):e.kind==="success"?a.jsx(kC,{onClick:n}):e.kind==="failed-rollback"?a.jsxs(a.Fragment,{children:[r?a.jsx(hL,{tone:"error",onClick:r,testId:"update-banner-view-logs",children:"查看日志"}):null,a.jsx(kC,{onClick:n})]}):null}function hL({tone:e,onClick:t,testId:n,children:r}){const s=e==="accent"?"bg-accent/10 hover:bg-accent/20 text-accent border border-accent/30":"bg-error/10 hover:bg-error/20 text-error border border-error/30";return a.jsx("button",{type:"button",onClick:t,"data-testid":n,className:Q("inline-flex items-center gap-1 px-2 h-6 rounded-sm text-[11px] font-medium transition-colors",s),children:r})}function kC({onClick:e}){return a.jsx("button",{type:"button",onClick:e,"data-testid":"update-banner-dismiss",className:"inline-flex items-center justify-center w-5 h-5 text-text-400 hover:text-text-100 rounded-sm","aria-label":"dismiss",children:a.jsx(Yt,{className:"w-3 h-3"})})}function YDe(e){switch(e){case"available":return{Icon:hH,iconClassName:"",className:"bg-accent-dim text-accent border-accent/30"};case"updating":return{Icon:st,iconClassName:"animate-spin",className:"bg-warning-dim text-warning border-warning/30"};case"success":return{Icon:oi,iconClassName:"",className:"bg-success-dim text-success border-success/30"};case"failed-rollback":return{Icon:Sn,iconClassName:"",className:"bg-error-dim text-error border-error/30"}}}function XDe({client:e,extId:t,updateInfo:n,onApplyUpdate:r}){const[s,i]=p.useState({kind:"starting",name:t}),[o,l]=p.useState(null),[c,u]=p.useState(!1);p.useEffect(()=>{l(null),u(!1)},[t]);const d=p.useCallback(async()=>{let g=t;try{const b=(await e.request("extension.list",{})).extensions.find(y=>y.extId===t);b&&b.state!=="invalid"&&(g=b.manifest.name)}catch{}i({kind:"starting",name:g});try{const x=await e.request("extension.open",{extId:t});i({kind:"running",name:g,target:x})}catch(x){i({kind:"error",name:g,message:x.message})}},[e,t]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async()=>{if(!(!n||!r)){l({kind:"updating",extName:n.extName,toVersion:n.toVersion,step:"fetching"});try{const g=await r(n);g.kind==="updated"?(l({kind:"success",extName:n.extName,toVersion:g.installedVersion}),d()):l({kind:"failed-rollback",extName:n.extName,attemptedVersion:n.toVersion,rolledBackTo:g.rolledBackTo,reason:g.reason})}catch(g){l({kind:"failed-rollback",extName:n.extName,attemptedVersion:n.toVersion,rolledBackTo:n.fromVersion,reason:g.message})}}},[n,r,d]);let f={kind:"idle"};o?f=o:n&&!c&&(f={kind:"available",extName:n.extName,fromVersion:n.fromVersion,toVersion:n.toVersion});const m=f.kind==="idle"?null:a.jsx(qDe,{state:f,onUpdate:()=>void h(),onDismiss:()=>{l(null),u(!0)}});return a.jsx(VDe,{status:s,onRetry:()=>void d(),topBanner:m})}function ZDe(e){const t=new Map;return{observe(n,r){let s=t.get(n);s||(s={data:void 0,hasData:!1,listeners:new Set},t.set(n,s));const i=c=>r(c);s.listeners.add(i);const o=s.listeners.size===1;i(s.hasData?s.data:void 0),o&&e.onFirstObserver(n);let l=!1;return()=>{if(l)return;l=!0;const c=t.get(n);c&&(c.listeners.delete(i),c.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const s=t.get(n);if(!s)return;const i=s.hasData?s.data:void 0,o=r(i);s.data=o,s.hasData=!0;for(const l of s.listeners)l(o)}}}function QDe(){const e=[],t=new Map,n=r=>{for(const s of e)if(s.pattern.test(r))return s.source;return null};return{register(r,s){e.push({pattern:r,source:s})},activate(r){if(t.has(r))return;const s=n(r);if(!s)throw new Error(`no source registered for key: ${r}`);t.set(r,s.start(r))},deactivate(r){const s=t.get(r);s&&(t.delete(r),s())}}}function JDe(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of Y7)n.push(e.on(r,s=>t(r,s)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}const eOe=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:yG(e)});function tOe(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let s=!1;const i=async()=>{try{const l=await e.request("capabilities:get",{tool:r});if(s)return;t(n,()=>l)}catch{if(s)return;t(n,()=>eOe(r))}},o=e.onConnect(()=>{i()});return i(),()=>{s=!0,o()}}}}function nOe(e,t){return{start(n){let r=!1;const s=async()=>{try{const l=await e.request("session:list",void 0);if(r)return;t(n,()=>l.sessions??[])}catch{}},i=e.onFrame((l,c)=>{if(l==="session:info"){const u=c;if(u.chatId!==void 0)return;t(n,d=>[u,...(d??[]).filter(h=>h.sessionId!==u.sessionId)])}else if(l==="session:deleted"){const u=c;t(n,d=>(d??[]).filter(h=>h.sessionId!==u.sessionId))}}),o=e.onConnect(()=>{s()});return s(),()=>{r=!0,i(),o()}}}}const rOe="session/";function sOe(e){return{sid:e.slice(rOe.length)}}const iOe=new Set(A5);function zX(e){return iOe.has(e)}function fL(e){return zX(e)?e:"idle"}function oOe(e,t){return{start(n){const{sid:r}=sOe(n);let s=!1,i=-1;const o=f=>{t(n,m=>XV(m??Eg,f,r))},l=async f=>{const m=f==="baseline"?-1:i;try{const g=await e.request("session:events",{sessionId:r,afterSeq:m});if(s)return;const x=g.events??[],b=g.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:x,latestSeq:b}),i=b;else{const y=g.bufferStartSeq??0,v=b<m||y>m+1;o({type:v?"session:events":"session:events:append",sessionId:r,events:x,latestSeq:b}),i=Math.max(i,b)}}catch{}},c=async()=>{try{const f=await e.request("info");if(s)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(m=>({sessionId:m.sessionId,freshSpawn:m.freshSpawn,status:fL(m.status)}))})}catch{}},u=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}s||(await l(i<0?"baseline":"delta"),!s&&await c())},d=e.onFrame((f,m)=>{if(!s)if(f==="session:event"){const g=m;if(g.sessionId!==r)return;const x=g.event.seq;Pe("session-events","push session:event",{sid:r,kind:g.event.kind,seq:x,lastSeqBefore:i}),o({type:"session:event",sessionId:g.sessionId,event:g.event}),typeof x=="number"&&x>i&&(i=x)}else if(f==="session:status"){const g=m;if(g.sessionId!==r)return;if(!zX(g.status)){Pe("session-events","push session:status drop",{sid:r,status:g.status});return}Pe("session-events","push session:status",{sid:r,status:g.status}),o({type:"session:status",sessionId:g.sessionId,status:g.status})}else if(f==="session:cleared"){if(m.sessionId!==r)return;Pe("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),i=-1}else if(f==="session:queue"){const g=m;if(g.sessionId!==r)return;Pe("session-events","push session:queue",{sid:r,count:g.items.length}),o({type:"session:queue",sessionId:g.sessionId,items:g.items})}else if(f==="permission:request"){const g=m;if(g.sessionId!==r)return;o({type:"permission:request",sessionId:g.sessionId,requestId:g.requestId,tool:g.tool,input:g.input,...typeof g.toolUseId=="string"&&g.toolUseId?{toolUseId:g.toolUseId}:{}})}else if(f==="session:question"){const g=m;if(g.sessionId!==r)return;o({type:"session:question",sessionId:g.sessionId,toolUseId:g.toolUseId,requestId:g.requestId,questions:g.questions})}else if(f==="session:question:cleared"){const g=m;if(g.sessionId!==r)return;g.answers&&Object.keys(g.answers).length>0?o({type:"session:question:submitted",sessionId:g.sessionId,toolUseId:g.toolUseId,answers:g.answers}):o({type:"session:question:clear",sessionId:g.sessionId,toolUseId:g.toolUseId})}else if(f==="session:rewound"){const g=m;if(g.sessionId!==r)return;o({type:"session:rewound",sessionId:g.sessionId,userMessageId:g.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(m.runningSessions??[]).map(x=>({sessionId:x.sessionId,freshSpawn:x.freshSpawn,status:fL(x.status)}))})}),h=e.onConnect(()=>{u()});return e.isConnected&&u(),()=>{s=!0,d(),h(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const aOe=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function lOe(e,t){return{start(n){let r=!1;const s=async()=>{try{const l=await e.request("info",void 0);if(r)return;t(n,()=>l)}catch{}},i=e.onConnect(()=>{s()}),o=e.onFrame(l=>{aOe.has(l)&&s()});return s(),()=>{r=!0,i(),o()}}}}function cOe(){return{start(){return()=>{}}}}function uOe(e,t){return{start(n){let r=!1;const s=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},i=e.onConnect(()=>{s()});return s(),()=>{r=!0,i()}}}}function HX(e){const t=JDe(e),n=QDe();let r=null;const s=(o,l)=>{r==null||r.setData(o,l)};n.register(/^capabilities\//,tOe(t,s)),n.register(/^sessions$/,nOe(t,s)),n.register(/^session\//,oOe(t,s)),n.register(/^personas$/,uOe(t,s)),n.register(/^persona-detail\//,cOe()),n.register(/^daemon-info$/,lOe(t,s));const i=ZDe({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=i,{cache:i,channel:t}}function dOe({client:e,children:t}){const n=p.useMemo(()=>HX(e),[e]);return p.useEffect(()=>()=>{},[n]),a.jsx(fxe,{client:e,children:a.jsx(YV,{cache:n.cache,children:a.jsx(qK,{children:t})})})}function hOe(e,t){var g,x,b,y;const{models:n,modes:r,configSchema:s}=t,i=e.resolvedModel??e.model,o=Ox(i,n,s),l=o.options,c=l.some(v=>v.value===e.effort)?e.effort:o.defaultValue,u=e.effort===""&&e.resolvedEffort?((g=l.find(v=>v.value===e.resolvedEffort))==null?void 0:g.label)??e.resolvedEffort:((x=l.find(v=>v.value===c))==null?void 0:x.label)??null,d=((b=s.find(v=>v.name==="permissionMode"))==null?void 0:b.default)??"",h=r.some(v=>v.id===e.permissionMode)?e.permissionMode:d,m=h===d?null:((y=r.find(v=>v.id===h))==null?void 0:y.label)??null;return{modelLabel:N_(n,i),effortOptions:l,effortValue:c,effortLabel:u,modeValue:h,modeLabel:m,modeTone:m===null?null:h==="bypassPermissions"?"danger":"info"}}function UX({models:e,modelList:t,modes:n=[],configSchema:r=[],model:s,resolvedModel:i,resolvedEffort:o,effort:l,permissionMode:c,onPatch:u}){var b;const d=t??$Pe(e??[]),h=d.models,f=hOe({model:s,resolvedModel:i,resolvedEffort:o,effort:l,permissionMode:c},{models:h,modes:n,configSchema:r}),m=i??s,g=h.map(y=>{const v=y.id===""&&i?`${y.description?`${y.description};`:""}当前:${i}`:y.description;return{value:y.id,label:y.label,...v?{description:v}:{},...y.group?{group:y.group}:{}}}),x=n.map(y=>({value:y.id,label:y.label,...y.description?{description:y.description}:{}}));return a.jsxs(is,{children:[a.jsx(os,{asChild:!0,children:a.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[a.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:m||f.modelLabel}),f.effortLabel?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-500",children:"·"}),a.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:f.effortLabel})]}):null,f.modeLabel?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-500",children:"·"}),a.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":f.modeTone,className:Q("font-semibold",f.modeTone==="danger"?"text-red-400":"text-blue-400"),children:f.modeLabel})]}):null]})}),a.jsxs(zr,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[a.jsx(fOe,{list:d,current:s,currentLabel:f.modelLabel,options:g,onSelect:y=>u({model:y})}),a.jsx(pL,{testid:"session-config-effort",label:"Reasoning effort",current:f.effortValue,currentLabel:f.effortLabel??"—",options:f.effortOptions,onSelect:y=>u({effort:y})}),x.length>0?a.jsx(pL,{testid:"session-config-mode",label:"Permission mode",current:f.modeValue,currentLabel:((b=n.find(y=>y.id===f.modeValue))==null?void 0:b.label)??"—",currentTone:f.modeTone,options:x,onSelect:y=>u({permissionMode:y})}):null]})]})}function WX({label:e,currentLabel:t,currentTone:n}){return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"flex-1 text-text-200",children:e}),a.jsx("span",{className:Q("truncate max-w-[100px]",n==="danger"?"text-red-400 font-semibold":n==="info"?"text-blue-400 font-semibold":"text-text-400"),children:t}),a.jsx(Yn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]})}function fOe({list:e,current:t,currentLabel:n,options:r,onSelect:s}){const[i,o]=p.useState(!1),l=c=>{c&&!i&&e.load(),o(c)};return a.jsxs(yX,{open:i,onOpenChange:l,children:[a.jsx(BM,{"data-testid":"session-config-model",className:"gap-2 text-[12px]",children:a.jsx(WX,{label:"Model",currentLabel:n})}),a.jsx(FM,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:a.jsx(AX,{testid:"session-config-model",list:e,options:r,current:t,onSelect:s})})]})}function pL({testid:e,label:t,current:n,currentLabel:r,currentTone:s,options:i,onSelect:o}){const l=i.length===0;return a.jsxs(yX,{children:[a.jsx(BM,{"data-testid":e,disabled:l,className:"gap-2 text-[12px]",children:a.jsx(WX,{label:t,currentLabel:r,currentTone:s??null})}),a.jsx(FM,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:zM(i).map((c,u)=>{const d=c.value===n;return a.jsxs(K.Fragment,{children:[c.groupHeading?a.jsxs(a.Fragment,{children:[u>0?a.jsx(da,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:c.groupHeading})]}):null,a.jsxs(Tt,{"data-testid":`${e}-option-${c.value||"default"}`,onSelect:()=>o(c.value),className:"items-start gap-2",children:[a.jsxs("span",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:Q("block text-[12px]",d?"text-text-100 font-medium":"text-text-300"),children:c.label}),c.description?a.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:c.description}):null]}),d?a.jsx(Gt,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]})]},c.value||"default")})})]})}function pOe(e,t,n=0){const[r,s]=p.useState(null),[i,o]=p.useState(!1),l=p.useCallback(async()=>{if(!t){s(null);return}o(!0);try{const c=await e.getGitBranch(t);s(c.branch??null)}catch{s(null)}finally{o(!1)}},[e,t]);return p.useEffect(()=>{l()},[l,n]),{branch:r,loading:i,refresh:()=>void l()}}function mOe(e,t,n=0){const[r,s]=p.useState(null),[i,o]=p.useState(!1),l=p.useCallback(async()=>{if(!t){s(null);return}o(!0);try{const c=await e.getGitRoot(t);s(c.gitRoot??null)}catch{s(null)}finally{o(!1)}},[e,t]);return p.useEffect(()=>{l()},[l,n]),{worktreeRoot:r,loading:i,refresh:()=>void l()}}const gOe=5e3;function xOe(e,t,n=0){const[r,s]=p.useState(null);return p.useEffect(()=>{if(!t){s(null);return}let i=!1;const o=async()=>{try{const c=await e.cloudVolumeGet();i||s(c.volume??null)}catch{i||s(null)}},l=n>0?setTimeout(()=>void o(),gOe):null;return l||o(),()=>{i=!0,l&&clearTimeout(l)}},[e,t,n]),{volume:r}}const vOe=90;function yOe(e){return e.sizeBytes>0?Math.min(100,Math.max(0,Math.round(e.usedBytes/e.sizeBytes*100))):0}function mL(e){const t=e/1073741824;return t>=.1?`${t.toFixed(1)} GB`:`${Math.max(1,Math.round(e/1024**2))} MB`}function bOe({volume:e}){if(!e)return null;const t=yOe(e),n=t>=vOe?"warn":"ok",r=new Date(e.measuredAt).toLocaleString(),s=n==="ok"?"上一次任务结束时量的。":"盘快满了:在会话里说「清理一下云盘」,persona 会分析工作区里哪些能删、列给你确认后清掉。";return a.jsxs("span",{"data-testid":"chat-header-cloud-volume","data-tone":n,title:`云盘已用 ${mL(e.usedBytes)} / ${mL(e.sizeBytes)}(${r})。${s}`,className:Q("ml-1.5 inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded text-[11px] tabular-nums",n==="ok"&&"bg-text-100/10 text-text-400",n==="warn"&&"bg-warning-dim text-warning"),children:[a.jsx("span",{className:"relative inline-block w-8 h-1 rounded-full bg-current/20 overflow-hidden","aria-hidden":!0,children:a.jsx("span",{className:"absolute inset-y-0 left-0 rounded-full bg-current",style:{width:`${t}%`}})}),"云盘 ",t,"%"]})}function KM({api:e,session:t,focused:n,totalPanes:r,onFocus:s,onClose:i,onNewSession:o,onOpenConfig:l,onFork:c,onQuickAsk:u,className:d,viewerRole:h="owner",hideHeader:f}){const{capabilities:m}=ni(t.tool),g=_h(t.tool),[x,b]=p.useState(0),[y,v]=p.useState(n);K.useEffect(()=>{n&&v(!0)},[n]);const w=Pb(t.tool),_=w?void 0:t.cwd,{branch:S}=pOe(e,_,x),{worktreeRoot:k}=mOe(e,_,x),{volume:C}=xOe(e,w,x),j=r>1,T=E=>{e.sessionUpdate(t.sessionId,E).catch(I=>{console.error("[session-config] session:update failed",t.sessionId,I)})};return a.jsxs("div",{className:`group/pane relative flex-1 ${d??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${j?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:s,"data-testid":`session-pane-${t.sessionId}`,children:[a.jsx(Jw,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:a.jsx(qh,{id:"chat",minSize:"400px",children:a.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:(n||y)&&a.jsx(wOe,{api:e,session:t,focused:n,liveGitBranch:S,liveWorktreeRoot:k,...w&&C?{cloudVolume:a.jsx(bOe,{volume:C})}:{},onNewSession:o,onTurnEnd:()=>b(E=>E+1),onOpenConfig:l,onFork:c,onQuickAsk:u,viewerRole:h,hideHeader:f,configSlot:m?a.jsx(UX,{modelList:g,modes:m.permissionModes,configSchema:m.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:T}):null})})})}),j&&a.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),i()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:a.jsx(Yt,{className:"w-3.5 h-3.5"})})]})}function wOe({api:e,session:t,focused:n,liveGitBranch:r,liveWorktreeRoot:s,cloudVolume:i,onNewSession:o,onTurnEnd:l,onOpenConfig:c,onFork:u,onQuickAsk:d,viewerRole:h,configSlot:f,hideHeader:m}){return a.jsx(S_,{extras:{session:t,api:e,focused:n,...r!==void 0?{liveGitBranch:r}:{},...s!==void 0?{liveWorktreeRoot:s}:{},...i!==void 0?{cloudVolume:i}:{},onNewSession:o,onTurnEnd:l,onOpenConfig:c,...u?{onFork:g=>{u(g)}}:{},...d?{onQuickAsk:g=>{d(g)}}:{},...h?{viewerRole:h}:{},...f?{configSlot:f}:{},...m?{hideHeader:m}:{}}})}function _Oe({client:e,session:t,remoteSessions:n,hasLoadedForOwner:r,focused:s,totalPanes:i,onFocus:o,onClose:l,onMirrorOrphan:c,className:u}){const d=p.useMemo(()=>new Wt(e),[e]),h=t.originOwnerPrincipalId,f=t.sessionId,m=p.useMemo(()=>n.some(g=>g.sessionId===f),[n,f]);return p.useEffect(()=>{!r||!c||m||c(f,h)},[r,m,f,h,c]),a.jsx(dOe,{client:e,children:a.jsx(KM,{api:d,session:t,focused:s,totalPanes:i,onFocus:o,onClose:l,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest",...u!==void 0?{className:u}:{}})})}function SOe(){const e=Un(),[t,n]=p.useState([]),[r,s]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(async()=>{s(!0),o(null);try{const u=await new Wt(e).shiftList();n(u.shifts)}catch(c){o(c instanceof Error?c.message:String(c))}finally{s(!1)}},[e]);return p.useEffect(()=>{l()},[l]),{shifts:t,loading:r,error:i,refresh:l}}var mi={};Object.defineProperty(mi,"__esModule",{value:!0});class Ju extends Error{}class kOe extends Ju{constructor(t){super(`Invalid DateTime: ${t.toMessage()}`)}}class COe extends Ju{constructor(t){super(`Invalid Interval: ${t.toMessage()}`)}}class NOe extends Ju{constructor(t){super(`Invalid Duration: ${t.toMessage()}`)}}class oh extends Ju{}class VX extends Ju{constructor(t){super(`Invalid unit ${t}`)}}class Kr extends Ju{}class jl extends Ju{constructor(){super("Zone is an abstract class")}}const Oe="numeric",Io="short",ri="long",b1={year:Oe,month:Oe,day:Oe},qX={year:Oe,month:Io,day:Oe},jOe={year:Oe,month:Io,day:Oe,weekday:Io},KX={year:Oe,month:ri,day:Oe},GX={year:Oe,month:ri,day:Oe,weekday:ri},YX={hour:Oe,minute:Oe},XX={hour:Oe,minute:Oe,second:Oe},ZX={hour:Oe,minute:Oe,second:Oe,timeZoneName:Io},QX={hour:Oe,minute:Oe,second:Oe,timeZoneName:ri},JX={hour:Oe,minute:Oe,hourCycle:"h23"},eZ={hour:Oe,minute:Oe,second:Oe,hourCycle:"h23"},tZ={hour:Oe,minute:Oe,second:Oe,hourCycle:"h23",timeZoneName:Io},nZ={hour:Oe,minute:Oe,second:Oe,hourCycle:"h23",timeZoneName:ri},rZ={year:Oe,month:Oe,day:Oe,hour:Oe,minute:Oe},sZ={year:Oe,month:Oe,day:Oe,hour:Oe,minute:Oe,second:Oe},iZ={year:Oe,month:Io,day:Oe,hour:Oe,minute:Oe},oZ={year:Oe,month:Io,day:Oe,hour:Oe,minute:Oe,second:Oe},EOe={year:Oe,month:Io,day:Oe,weekday:Io,hour:Oe,minute:Oe},aZ={year:Oe,month:ri,day:Oe,hour:Oe,minute:Oe,timeZoneName:Io},lZ={year:Oe,month:ri,day:Oe,hour:Oe,minute:Oe,second:Oe,timeZoneName:Io},cZ={year:Oe,month:ri,day:Oe,weekday:ri,hour:Oe,minute:Oe,timeZoneName:ri},uZ={year:Oe,month:ri,day:Oe,weekday:ri,hour:Oe,minute:Oe,second:Oe,timeZoneName:ri};class Of{get type(){throw new jl}get name(){throw new jl}get ianaName(){return this.name}get isUniversal(){throw new jl}offsetName(t,n){throw new jl}formatOffset(t,n){throw new jl}offset(t){throw new jl}equals(t){throw new jl}get isValid(){throw new jl}}let CC=null;class Ax extends Of{static get instance(){return CC===null&&(CC=new Ax),CC}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return _Z(t,n,r)}formatOffset(t,n){return Am(this.offset(t),n)}offset(t){return-new Date(t).getTimezoneOffset()}equals(t){return t.type==="system"}get isValid(){return!0}}const _E=new Map;function IOe(e){let t=_E.get(e);return t===void 0&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),_E.set(e,t)),t}const TOe={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function MOe(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,s,i,o,l,c,u,d]=r;return[o,s,i,l,c,u,d]}function ROe(e,t){const n=e.formatToParts(t),r=[];for(let s=0;s<n.length;s++){const{type:i,value:o}=n[s],l=TOe[i];i==="era"?r[l]=o:ft(l)||(r[l]=parseInt(o,10))}return r}const NC=new Map;class ha extends Of{static create(t){let n=NC.get(t);return n===void 0&&NC.set(t,n=new ha(t)),n}static resetCache(){NC.clear(),_E.clear()}static isValidSpecifier(t){return this.isValidZone(t)}static isValidZone(t){if(!t)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=ha.isValidZone(t)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return _Z(t,n,r,this.name)}formatOffset(t,n){return Am(this.offset(t),n)}offset(t){if(!this.valid)return NaN;const n=new Date(t);if(isNaN(n))return NaN;const r=IOe(this.name);let[s,i,o,l,c,u,d]=r.formatToParts?ROe(r,n):MOe(r,n);l==="BC"&&(s=-Math.abs(s)+1);const f=I_({year:s,month:i,day:o,hour:c===24?0:c,minute:u,second:d,millisecond:0});let m=+n;const g=m%1e3;return m-=g>=0?g:1e3+g,(f-m)/(60*1e3)}equals(t){return t.type==="iana"&&t.name===this.name}get isValid(){return this.valid}}let gL={};function POe(e,t={}){const n=JSON.stringify([e,t]);let r=gL[n];return r||(r=new Intl.ListFormat(e,t),gL[n]=r),r}const SE=new Map;function kE(e,t={}){const n=JSON.stringify([e,t]);let r=SE.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),SE.set(n,r)),r}const CE=new Map;function DOe(e,t={}){const n=JSON.stringify([e,t]);let r=CE.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),CE.set(n,r)),r}const NE=new Map;function OOe(e,t={}){const{base:n,...r}=t,s=JSON.stringify([e,r]);let i=NE.get(s);return i===void 0&&(i=new Intl.RelativeTimeFormat(e,t),NE.set(s,i)),i}let sm=null;function AOe(){return sm||(sm=new Intl.DateTimeFormat().resolvedOptions().locale,sm)}const jE=new Map;function dZ(e){let t=jE.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),jE.set(e,t)),t}const EE=new Map;function $Oe(e){let t=EE.get(e);if(!t){const n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in t||(t={...hZ,...t}),EE.set(e,t)}return t}function LOe(e){const t=e.indexOf("-x-");t!==-1&&(e=e.substring(0,t));const n=e.indexOf("-u-");if(n===-1)return[e];{let r,s;try{r=kE(e).resolvedOptions(),s=e}catch{const c=e.substring(0,n);r=kE(c).resolvedOptions(),s=c}const{numberingSystem:i,calendar:o}=r;return[s,i,o]}}function BOe(e,t,n){return(n||t)&&(e.includes("-u-")||(e+="-u"),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`)),e}function FOe(e){const t=[];for(let n=1;n<=12;n++){const r=xt.utc(2009,n,1);t.push(e(r))}return t}function zOe(e){const t=[];for(let n=1;n<=7;n++){const r=xt.utc(2016,11,13+n);t.push(e(r))}return t}function P0(e,t,n,r){const s=e.listingMode();return s==="error"?null:s==="en"?n(t):r(t)}function HOe(e){return e.numberingSystem&&e.numberingSystem!=="latn"?!1:e.numberingSystem==="latn"||!e.locale||e.locale.startsWith("en")||dZ(e.locale).numberingSystem==="latn"}class UOe{constructor(t,n,r){this.padTo=r.padTo||0,this.floor=r.floor||!1;const{padTo:s,floor:i,...o}=r;if(!n||Object.keys(o).length>0){const l={useGrouping:!1,...r};r.padTo>0&&(l.minimumIntegerDigits=r.padTo),this.inf=DOe(t,l)}}format(t){if(this.inf){const n=this.floor?Math.floor(t):t;return this.inf.format(n)}else{const n=this.floor?Math.floor(t):QM(t,3);return nr(n,this.padTo)}}}class WOe{constructor(t,n,r){this.opts=r,this.originalZone=void 0;let s;if(this.opts.timeZone)this.dt=t;else if(t.zone.type==="fixed"){const o=-1*(t.offset/60),l=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;t.offset!==0&&ha.create(l).valid?(s=l,this.dt=t):(s="UTC",this.dt=t.offset===0?t:t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone)}else t.zone.type==="system"?this.dt=t:t.zone.type==="iana"?(this.dt=t,s=t.zone.name):(s="UTC",this.dt=t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone);const i={...this.opts};i.timeZone=i.timeZone||s,this.dtf=kE(n,i)}format(){return this.originalZone?this.formatToParts().map(({value:t})=>t).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const t=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?t.map(n=>{if(n.type==="timeZoneName"){const r=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...n,value:r}}else return n}):t}resolvedOptions(){return this.dtf.resolvedOptions()}}class VOe{constructor(t,n,r){this.opts={style:"long",...r},!n&&bZ()&&(this.rtf=OOe(t,r))}format(t,n){return this.rtf?this.rtf.format(t,n):hAe(n,t,this.opts.numeric,this.opts.style!=="long")}formatToParts(t,n){return this.rtf?this.rtf.formatToParts(t,n):[]}}const hZ={firstDay:1,minimalDays:4,weekend:[6,7]};class en{static fromOpts(t){return en.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,n,r,s,i=!1){const o=t||On.defaultLocale,l=o||(i?"en-US":AOe()),c=n||On.defaultNumberingSystem,u=r||On.defaultOutputCalendar,d=TE(s)||On.defaultWeekSettings;return new en(l,c,u,d,o)}static resetCache(){sm=null,SE.clear(),CE.clear(),NE.clear(),jE.clear(),EE.clear()}static fromObject({locale:t,numberingSystem:n,outputCalendar:r,weekSettings:s}={}){return en.create(t,n,r,s)}constructor(t,n,r,s,i){const[o,l,c]=LOe(t);this.locale=o,this.numberingSystem=n||l||null,this.outputCalendar=r||c||null,this.weekSettings=s,this.intl=BOe(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=HOe(this)),this.fastNumbersCached}listingMode(){const t=this.isEnglish(),n=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return t&&n?"en":"intl"}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:en.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,TE(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(t={}){return this.clone({...t,defaultToEN:!0})}redefaultToSystem(t={}){return this.clone({...t,defaultToEN:!1})}months(t,n=!1){return P0(this,t,CZ,()=>{const r=this.intl==="ja"||this.intl.startsWith("ja-");n&=!r;const s=n?{month:t,day:"numeric"}:{month:t},i=n?"format":"standalone";if(!this.monthsCache[i][t]){const o=r?l=>this.dtFormatter(l,s).format():l=>this.extract(l,s,"month");this.monthsCache[i][t]=FOe(o)}return this.monthsCache[i][t]})}weekdays(t,n=!1){return P0(this,t,EZ,()=>{const r=n?{weekday:t,year:"numeric",month:"long",day:"numeric"}:{weekday:t},s=n?"format":"standalone";return this.weekdaysCache[s][t]||(this.weekdaysCache[s][t]=zOe(i=>this.extract(i,r,"weekday"))),this.weekdaysCache[s][t]})}meridiems(){return P0(this,void 0,()=>IZ,()=>{if(!this.meridiemCache){const t={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[xt.utc(2016,11,13,9),xt.utc(2016,11,13,19)].map(n=>this.extract(n,t,"dayperiod"))}return this.meridiemCache})}eras(t){return P0(this,t,TZ,()=>{const n={era:t};return this.eraCache[t]||(this.eraCache[t]=[xt.utc(-40,1,1),xt.utc(2017,1,1)].map(r=>this.extract(r,n,"era"))),this.eraCache[t]})}extract(t,n,r){const s=this.dtFormatter(t,n),i=s.formatToParts(),o=i.find(l=>l.type.toLowerCase()===r);return o?o.value:null}numberFormatter(t={}){return new UOe(this.intl,t.forceSimple||this.fastNumbers,t)}dtFormatter(t,n={}){return new WOe(t,this.intl,n)}relFormatter(t={}){return new VOe(this.intl,this.isEnglish(),t)}listFormatter(t={}){return POe(this.intl,t)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||dZ(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:wZ()?$Oe(this.locale):hZ}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(t){return this.locale===t.locale&&this.numberingSystem===t.numberingSystem&&this.outputCalendar===t.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let jC=null;class Jr extends Of{static get utcInstance(){return jC===null&&(jC=new Jr(0)),jC}static instance(t){return t===0?Jr.utcInstance:new Jr(t)}static parseSpecifier(t){if(t){const n=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new Jr(T_(n[1],n[2]))}return null}constructor(t){super(),this.fixed=t}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Am(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Am(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(t,n){return Am(this.fixed,n)}get isUniversal(){return!0}offset(){return this.fixed}equals(t){return t.type==="fixed"&&t.fixed===this.fixed}get isValid(){return!0}}class fZ extends Of{constructor(t){super(),this.zoneName=t}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function Bl(e,t){if(ft(e)||e===null)return t;if(e instanceof Of)return e;if(ZOe(e)){const n=e.toLowerCase();return n==="default"?t:n==="local"||n==="system"?Ax.instance:n==="utc"||n==="gmt"?Jr.utcInstance:Jr.parseSpecifier(n)||ha.create(e)}else return ic(e)?Jr.instance(e):typeof e=="object"&&"offset"in e&&typeof e.offset=="function"?e:new fZ(e)}const GM={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},xL={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},qOe=GM.hanidec.replace(/[\[|\]]/g,"").split("");function KOe(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(e[n].search(GM.hanidec)!==-1)t+=qOe.indexOf(e[n]);else for(const s in xL){const[i,o]=xL[s];r>=i&&r<=o&&(t+=r-i)}}return parseInt(t,10)}else return t}const IE=new Map;function GOe(){IE.clear()}function io({numberingSystem:e},t=""){const n=e||"latn";let r=IE.get(n);r===void 0&&(r=new Map,IE.set(n,r));let s=r.get(t);return s===void 0&&(s=new RegExp(`${GM[n]}${t}`),r.set(t,s)),s}let vL=()=>Date.now(),yL="system",bL=null,wL=null,_L=null,SL=60,kL,CL=null;class On{static get now(){return vL}static set now(t){vL=t}static set defaultZone(t){yL=t}static get defaultZone(){return Bl(yL,Ax.instance)}static get defaultLocale(){return bL}static set defaultLocale(t){bL=t}static get defaultNumberingSystem(){return wL}static set defaultNumberingSystem(t){wL=t}static get defaultOutputCalendar(){return _L}static set defaultOutputCalendar(t){_L=t}static get defaultWeekSettings(){return CL}static set defaultWeekSettings(t){CL=TE(t)}static get twoDigitCutoffYear(){return SL}static set twoDigitCutoffYear(t){SL=t%100}static get throwOnInvalid(){return kL}static set throwOnInvalid(t){kL=t}static resetCaches(){en.resetCache(),ha.resetCache(),xt.resetCache(),GOe()}}class go{constructor(t,n){this.reason=t,this.explanation=n}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const pZ=[0,31,59,90,120,151,181,212,243,273,304,334],mZ=[0,31,60,91,121,152,182,213,244,274,305,335];function Ri(e,t){return new go("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function YM(e,t,n){const r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);const s=r.getUTCDay();return s===0?7:s}function gZ(e,t,n){return n+($x(e)?mZ:pZ)[t-1]}function xZ(e,t){const n=$x(e)?mZ:pZ,r=n.findIndex(i=>i<t),s=t-n[r];return{month:r+1,day:s}}function XM(e,t){return(e-t+7)%7+1}function w1(e,t=4,n=1){const{year:r,month:s,day:i}=e,o=gZ(r,s,i),l=XM(YM(r,s,i),n);let c=Math.floor((o-l+14-t)/7),u;return c<1?(u=r-1,c=Lg(u,t,n)):c>Lg(r,t,n)?(u=r+1,c=1):u=r,{weekYear:u,weekNumber:c,weekday:l,...M_(e)}}function NL(e,t=4,n=1){const{weekYear:r,weekNumber:s,weekday:i}=e,o=XM(YM(r,1,t),n),l=Sh(r);let c=s*7+i-o-7+t,u;c<1?(u=r-1,c+=Sh(u)):c>l?(u=r+1,c-=Sh(r)):u=r;const{month:d,day:h}=xZ(u,c);return{year:u,month:d,day:h,...M_(e)}}function EC(e){const{year:t,month:n,day:r}=e,s=gZ(t,n,r);return{year:t,ordinal:s,...M_(e)}}function jL(e){const{year:t,ordinal:n}=e,{month:r,day:s}=xZ(t,n);return{year:t,month:r,day:s,...M_(e)}}function EL(e,t){if(!ft(e.localWeekday)||!ft(e.localWeekNumber)||!ft(e.localWeekYear)){if(!ft(e.weekday)||!ft(e.weekNumber)||!ft(e.weekYear))throw new oh("Cannot mix locale-based week fields with ISO-based week fields");return ft(e.localWeekday)||(e.weekday=e.localWeekday),ft(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),ft(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function YOe(e,t=4,n=1){const r=E_(e.weekYear),s=Pi(e.weekNumber,1,Lg(e.weekYear,t,n)),i=Pi(e.weekday,1,7);return r?s?i?!1:Ri("weekday",e.weekday):Ri("week",e.weekNumber):Ri("weekYear",e.weekYear)}function XOe(e){const t=E_(e.year),n=Pi(e.ordinal,1,Sh(e.year));return t?n?!1:Ri("ordinal",e.ordinal):Ri("year",e.year)}function vZ(e){const t=E_(e.year),n=Pi(e.month,1,12),r=Pi(e.day,1,_1(e.year,e.month));return t?n?r?!1:Ri("day",e.day):Ri("month",e.month):Ri("year",e.year)}function yZ(e){const{hour:t,minute:n,second:r,millisecond:s}=e,i=Pi(t,0,23)||t===24&&n===0&&r===0&&s===0,o=Pi(n,0,59),l=Pi(r,0,59),c=Pi(s,0,999);return i?o?l?c?!1:Ri("millisecond",s):Ri("second",r):Ri("minute",n):Ri("hour",t)}function ft(e){return typeof e>"u"}function ic(e){return typeof e=="number"}function E_(e){return typeof e=="number"&&e%1===0}function ZOe(e){return typeof e=="string"}function QOe(e){return Object.prototype.toString.call(e)==="[object Date]"}function bZ(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function wZ(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function JOe(e){return Array.isArray(e)?e:[e]}function IL(e,t,n){if(e.length!==0)return e.reduce((r,s)=>{const i=[t(s),s];return r&&n(r[0],i[0])===r[0]?r:i},null)[1]}function eAe(e,t){return t.reduce((n,r)=>(n[r]=e[r],n),{})}function rf(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function TE(e){if(e==null)return null;if(typeof e!="object")throw new Kr("Week settings must be an object");if(!Pi(e.firstDay,1,7)||!Pi(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(t=>!Pi(t,1,7)))throw new Kr("Invalid week settings");return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Pi(e,t,n){return E_(e)&&e>=t&&e<=n}function tAe(e,t){return e-t*Math.floor(e/t)}function nr(e,t=2){const n=e<0;let r;return n?r="-"+(""+-e).padStart(t,"0"):r=(""+e).padStart(t,"0"),r}function Al(e){if(!(ft(e)||e===null||e===""))return parseInt(e,10)}function Fc(e){if(!(ft(e)||e===null||e===""))return parseFloat(e)}function ZM(e){if(!(ft(e)||e===null||e==="")){const t=parseFloat("0."+e)*1e3;return Math.floor(t)}}function QM(e,t,n="round"){const r=10**t;switch(n){case"expand":return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case"trunc":return Math.trunc(e*r)/r;case"round":return Math.round(e*r)/r;case"floor":return Math.floor(e*r)/r;case"ceil":return Math.ceil(e*r)/r;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function $x(e){return e%4===0&&(e%100!==0||e%400===0)}function Sh(e){return $x(e)?366:365}function _1(e,t){const n=tAe(t-1,12)+1,r=e+(t-n)/12;return n===2?$x(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function I_(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function TL(e,t,n){return-XM(YM(e,1,t),n)+t-1}function Lg(e,t=4,n=1){const r=TL(e,t,n),s=TL(e+1,t,n);return(Sh(e)-r+s)/7}function ME(e){return e>99?e:e>On.twoDigitCutoffYear?1900+e:2e3+e}function _Z(e,t,n,r=null){const s=new Date(e),i={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(i.timeZone=r);const o={timeZoneName:t,...i},l=new Intl.DateTimeFormat(n,o).formatToParts(s).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function T_(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);const r=parseInt(t,10)||0,s=n<0||Object.is(n,-0)?-r:r;return n*60+s}function SZ(e){const t=Number(e);if(typeof e=="boolean"||e===""||!Number.isFinite(t))throw new Kr(`Invalid unit value ${e}`);return t}function S1(e,t){const n={};for(const r in e)if(rf(e,r)){const s=e[r];if(s==null)continue;n[t(r)]=SZ(s)}return n}function Am(e,t){const n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),s=e>=0?"+":"-";switch(t){case"short":return`${s}${nr(n,2)}:${nr(r,2)}`;case"narrow":return`${s}${n}${r>0?`:${r}`:""}`;case"techie":return`${s}${nr(n,2)}${nr(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function M_(e){return eAe(e,["hour","minute","second","millisecond"])}const nAe=["January","February","March","April","May","June","July","August","September","October","November","December"],kZ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rAe=["J","F","M","A","M","J","J","A","S","O","N","D"];function CZ(e){switch(e){case"narrow":return[...rAe];case"short":return[...kZ];case"long":return[...nAe];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const NZ=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],jZ=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],sAe=["M","T","W","T","F","S","S"];function EZ(e){switch(e){case"narrow":return[...sAe];case"short":return[...jZ];case"long":return[...NZ];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const IZ=["AM","PM"],iAe=["Before Christ","Anno Domini"],oAe=["BC","AD"],aAe=["B","A"];function TZ(e){switch(e){case"narrow":return[...aAe];case"short":return[...oAe];case"long":return[...iAe];default:return null}}function lAe(e){return IZ[e.hour<12?0:1]}function cAe(e,t){return EZ(t)[e.weekday-1]}function uAe(e,t){return CZ(t)[e.month-1]}function dAe(e,t){return TZ(t)[e.year<0?0:1]}function hAe(e,t,n="always",r=!1){const s={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},i=["hours","minutes","seconds"].indexOf(e)===-1;if(n==="auto"&&i){const h=e==="days";switch(t){case 1:return h?"tomorrow":`next ${s[e][0]}`;case-1:return h?"yesterday":`last ${s[e][0]}`;case 0:return h?"today":`this ${s[e][0]}`}}const o=Object.is(t,-0)||t<0,l=Math.abs(t),c=l===1,u=s[e],d=r?c?u[1]:u[2]||u[1]:c?s[e][0]:e;return o?`${l} ${d} ago`:`in ${l} ${d}`}function ML(e,t){let n="";for(const r of e)r.literal?n+=r.val:n+=t(r.val);return n}const fAe={D:b1,DD:qX,DDD:KX,DDDD:GX,t:YX,tt:XX,ttt:ZX,tttt:QX,T:JX,TT:eZ,TTT:tZ,TTTT:nZ,f:rZ,ff:iZ,fff:aZ,ffff:cZ,F:sZ,FF:oZ,FFF:lZ,FFFF:uZ};class Xr{static create(t,n={}){return new Xr(t,n)}static parseFormat(t){let n=null,r="",s=!1;const i=[];for(let o=0;o<t.length;o++){const l=t.charAt(o);l==="'"?((r.length>0||s)&&i.push({literal:s||/^\s+$/.test(r),val:r===""?"'":r}),n=null,r="",s=!s):s||l===n?r+=l:(r.length>0&&i.push({literal:/^\s+$/.test(r),val:r}),r=l,n=l)}return r.length>0&&i.push({literal:s||/^\s+$/.test(r),val:r}),i}static macroTokenToFormatOpts(t){return fAe[t]}constructor(t,n){this.opts=n,this.loc=t,this.systemLoc=null}formatWithSystemDefault(t,n){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(t,{...this.opts,...n}).format()}dtFormatter(t,n={}){return this.loc.dtFormatter(t,{...this.opts,...n})}formatDateTime(t,n){return this.dtFormatter(t,n).format()}formatDateTimeParts(t,n){return this.dtFormatter(t,n).formatToParts()}formatInterval(t,n){return this.dtFormatter(t.start,n).dtf.formatRange(t.start.toJSDate(),t.end.toJSDate())}resolvedOptions(t,n){return this.dtFormatter(t,n).resolvedOptions()}num(t,n=0,r=void 0){if(this.opts.forceSimple)return nr(t,n);const s={...this.opts};return n>0&&(s.padTo=n),r&&(s.signDisplay=r),this.loc.numberFormatter(s).format(t)}formatDateTimeFromString(t,n){const r=this.loc.listingMode()==="en",s=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",i=(m,g)=>this.loc.extract(t,m,g),o=m=>t.isOffsetFixed&&t.offset===0&&m.allowZ?"Z":t.isValid?t.zone.formatOffset(t.ts,m.format):"",l=()=>r?lAe(t):i({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(m,g)=>r?uAe(t,m):i(g?{month:m}:{month:m,day:"numeric"},"month"),u=(m,g)=>r?cAe(t,m):i(g?{weekday:m}:{weekday:m,month:"long",day:"numeric"},"weekday"),d=m=>{const g=Xr.macroTokenToFormatOpts(m);return g?this.formatWithSystemDefault(t,g):m},h=m=>r?dAe(t,m):i({era:m},"era"),f=m=>{switch(m){case"S":return this.num(t.millisecond);case"u":case"SSS":return this.num(t.millisecond,3);case"s":return this.num(t.second);case"ss":return this.num(t.second,2);case"uu":return this.num(Math.floor(t.millisecond/10),2);case"uuu":return this.num(Math.floor(t.millisecond/100));case"m":return this.num(t.minute);case"mm":return this.num(t.minute,2);case"h":return this.num(t.hour%12===0?12:t.hour%12);case"hh":return this.num(t.hour%12===0?12:t.hour%12,2);case"H":return this.num(t.hour);case"HH":return this.num(t.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return t.zone.offsetName(t.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return t.zone.offsetName(t.ts,{format:"long",locale:this.loc.locale});case"z":return t.zoneName;case"a":return l();case"d":return s?i({day:"numeric"},"day"):this.num(t.day);case"dd":return s?i({day:"2-digit"},"day"):this.num(t.day,2);case"c":return this.num(t.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(t.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return s?i({month:"numeric",day:"numeric"},"month"):this.num(t.month);case"LL":return s?i({month:"2-digit",day:"numeric"},"month"):this.num(t.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return s?i({month:"numeric"},"month"):this.num(t.month);case"MM":return s?i({month:"2-digit"},"month"):this.num(t.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return s?i({year:"numeric"},"year"):this.num(t.year);case"yy":return s?i({year:"2-digit"},"year"):this.num(t.year.toString().slice(-2),2);case"yyyy":return s?i({year:"numeric"},"year"):this.num(t.year,4);case"yyyyyy":return s?i({year:"numeric"},"year"):this.num(t.year,6);case"G":return h("short");case"GG":return h("long");case"GGGGG":return h("narrow");case"kk":return this.num(t.weekYear.toString().slice(-2),2);case"kkkk":return this.num(t.weekYear,4);case"W":return this.num(t.weekNumber);case"WW":return this.num(t.weekNumber,2);case"n":return this.num(t.localWeekNumber);case"nn":return this.num(t.localWeekNumber,2);case"ii":return this.num(t.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(t.localWeekYear,4);case"o":return this.num(t.ordinal);case"ooo":return this.num(t.ordinal,3);case"q":return this.num(t.quarter);case"qq":return this.num(t.quarter,2);case"X":return this.num(Math.floor(t.ts/1e3));case"x":return this.num(t.ts);default:return d(m)}};return ML(Xr.parseFormat(n),f)}formatDurationFromString(t,n){const r=this.opts.signMode==="negativeLargestOnly"?-1:1,s=d=>{switch(d[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},i=(d,h)=>f=>{const m=s(f);if(m){const g=h.isNegativeDuration&&m!==h.largestUnit?r:1;let x;return this.opts.signMode==="negativeLargestOnly"&&m!==h.largestUnit?x="never":this.opts.signMode==="all"?x="always":x="auto",this.num(d.get(m)*g,f.length,x)}else return f},o=Xr.parseFormat(n),l=o.reduce((d,{literal:h,val:f})=>h?d:d.concat(f),[]),c=t.shiftTo(...l.map(s).filter(d=>d)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return ML(o,i(c,u))}}const MZ=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Af(...e){const t=e.reduce((n,r)=>n+r.source,"");return RegExp(`^${t}$`)}function $f(...e){return t=>e.reduce(([n,r,s],i)=>{const[o,l,c]=i(t,s);return[{...n,...o},l||r,c]},[{},null,1]).slice(0,2)}function Lf(e,...t){if(e==null)return[null,null];for(const[n,r]of t){const s=n.exec(e);if(s)return r(s)}return[null,null]}function RZ(...e){return(t,n)=>{const r={};let s;for(s=0;s<e.length;s++)r[e[s]]=Al(t[n+s]);return[r,null,n+s]}}const PZ=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,pAe=`(?:${PZ.source}?(?:\\[(${MZ.source})\\])?)?`,JM=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,DZ=RegExp(`${JM.source}${pAe}`),eR=RegExp(`(?:[Tt]${DZ.source})?`),mAe=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,gAe=/(\d{4})-?W(\d\d)(?:-?(\d))?/,xAe=/(\d{4})-?(\d{3})/,vAe=RZ("weekYear","weekNumber","weekDay"),yAe=RZ("year","ordinal"),bAe=/(\d{4})-(\d\d)-(\d\d)/,OZ=RegExp(`${JM.source} ?(?:${PZ.source}|(${MZ.source}))?`),wAe=RegExp(`(?: ${OZ.source})?`);function kh(e,t,n){const r=e[t];return ft(r)?n:Al(r)}function _Ae(e,t){return[{year:kh(e,t),month:kh(e,t+1,1),day:kh(e,t+2,1)},null,t+3]}function Bf(e,t){return[{hours:kh(e,t,0),minutes:kh(e,t+1,0),seconds:kh(e,t+2,0),milliseconds:ZM(e[t+3])},null,t+4]}function Lx(e,t){const n=!e[t]&&!e[t+1],r=T_(e[t+1],e[t+2]),s=n?null:Jr.instance(r);return[{},s,t+3]}function Bx(e,t){const n=e[t]?ha.create(e[t]):null;return[{},n,t+1]}const SAe=RegExp(`^T?${JM.source}$`),kAe=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function CAe(e){const[t,n,r,s,i,o,l,c,u]=e,d=t[0]==="-",h=c&&c[0]==="-",f=(m,g=!1)=>m!==void 0&&(g||m&&d)?-m:m;return[{years:f(Fc(n)),months:f(Fc(r)),weeks:f(Fc(s)),days:f(Fc(i)),hours:f(Fc(o)),minutes:f(Fc(l)),seconds:f(Fc(c),c==="-0"),milliseconds:f(ZM(u),h)}]}const NAe={GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function tR(e,t,n,r,s,i,o){const l={year:t.length===2?ME(Al(t)):Al(t),month:kZ.indexOf(n)+1,day:Al(r),hour:Al(s),minute:Al(i)};return o&&(l.second=Al(o)),e&&(l.weekday=e.length>3?NZ.indexOf(e)+1:jZ.indexOf(e)+1),l}const jAe=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function EAe(e){const[,t,n,r,s,i,o,l,c,u,d,h]=e,f=tR(t,s,r,n,i,o,l);let m;return c?m=NAe[c]:u?m=0:m=T_(d,h),[f,new Jr(m)]}function IAe(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const TAe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,MAe=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,RAe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function RL(e){const[,t,n,r,s,i,o,l]=e;return[tR(t,s,r,n,i,o,l),Jr.utcInstance]}function PAe(e){const[,t,n,r,s,i,o,l]=e;return[tR(t,l,n,r,s,i,o),Jr.utcInstance]}const DAe=Af(mAe,eR),OAe=Af(gAe,eR),AAe=Af(xAe,eR),$Ae=Af(DZ),AZ=$f(_Ae,Bf,Lx,Bx),LAe=$f(vAe,Bf,Lx,Bx),BAe=$f(yAe,Bf,Lx,Bx),FAe=$f(Bf,Lx,Bx);function zAe(e){return Lf(e,[DAe,AZ],[OAe,LAe],[AAe,BAe],[$Ae,FAe])}function HAe(e){return Lf(IAe(e),[jAe,EAe])}function UAe(e){return Lf(e,[TAe,RL],[MAe,RL],[RAe,PAe])}function WAe(e){return Lf(e,[kAe,CAe])}const VAe=$f(Bf);function qAe(e){return Lf(e,[SAe,VAe])}const KAe=Af(bAe,wAe),GAe=Af(OZ),YAe=$f(Bf,Lx,Bx);function XAe(e){return Lf(e,[KAe,AZ],[GAe,YAe])}const PL="Invalid Duration",$Z={weeks:{days:7,hours:7*24,minutes:7*24*60,seconds:7*24*60*60,milliseconds:7*24*60*60*1e3},days:{hours:24,minutes:24*60,seconds:24*60*60,milliseconds:24*60*60*1e3},hours:{minutes:60,seconds:60*60,milliseconds:60*60*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},ZAe={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:91*24,minutes:91*24*60,seconds:91*24*60*60,milliseconds:91*24*60*60*1e3},months:{weeks:4,days:30,hours:30*24,minutes:30*24*60,seconds:30*24*60*60,milliseconds:30*24*60*60*1e3},...$Z},_i=146097/400,Td=146097/4800,QAe={years:{quarters:4,months:12,weeks:_i/7,days:_i,hours:_i*24,minutes:_i*24*60,seconds:_i*24*60*60,milliseconds:_i*24*60*60*1e3},quarters:{months:3,weeks:_i/28,days:_i/4,hours:_i*24/4,minutes:_i*24*60/4,seconds:_i*24*60*60/4,milliseconds:_i*24*60*60*1e3/4},months:{weeks:Td/7,days:Td,hours:Td*24,minutes:Td*24*60,seconds:Td*24*60*60,milliseconds:Td*24*60*60*1e3},...$Z},su=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],JAe=su.slice(0).reverse();function ja(e,t,n=!1){const r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new Ut(r)}function LZ(e,t){var n;let r=(n=t.milliseconds)!=null?n:0;for(const s of JAe.slice(1))t[s]&&(r+=t[s]*e[s].milliseconds);return r}function DL(e,t){const n=LZ(e,t)<0?-1:1;su.reduceRight((r,s)=>{if(ft(t[s]))return r;if(r){const i=t[r]*n,o=e[s][r],l=Math.floor(i/o);t[s]+=l*n,t[r]-=l*o*n}return s},null),su.reduce((r,s)=>{if(ft(t[s]))return r;if(r){const i=t[r]%1;t[r]-=i,t[s]+=i*e[r][s]}return s},null)}function OL(e){const t={};for(const[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}class Ut{constructor(t){const n=t.conversionAccuracy==="longterm"||!1;let r=n?QAe:ZAe;t.matrix&&(r=t.matrix),this.values=t.values,this.loc=t.loc||en.create(),this.conversionAccuracy=n?"longterm":"casual",this.invalid=t.invalid||null,this.matrix=r,this.isLuxonDuration=!0}static fromMillis(t,n){return Ut.fromObject({milliseconds:t},n)}static fromObject(t,n={}){if(t==null||typeof t!="object")throw new Kr(`Duration.fromObject: argument expected to be an object, got ${t===null?"null":typeof t}`);return new Ut({values:S1(t,Ut.normalizeUnit),loc:en.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(ic(t))return Ut.fromMillis(t);if(Ut.isDuration(t))return t;if(typeof t=="object")return Ut.fromObject(t);throw new Kr(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){const[r]=WAe(t);return r?Ut.fromObject(r,n):Ut.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,n){const[r]=qAe(t);return r?Ut.fromObject(r,n):Ut.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,n=null){if(!t)throw new Kr("need to specify a reason the Duration is invalid");const r=t instanceof go?t:new go(t,n);if(On.throwOnInvalid)throw new NOe(r);return new Ut({invalid:r})}static normalizeUnit(t){const n={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[t&&t.toLowerCase()];if(!n)throw new VX(t);return n}static isDuration(t){return t&&t.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(t,n={}){const r={...n,floor:n.round!==!1&&n.floor!==!1};return this.isValid?Xr.create(this.loc,r).formatDurationFromString(this,t):PL}toHuman(t={}){if(!this.isValid)return PL;const n=t.showZeros!==!1,r=su.map(s=>{const i=this.values[s];return ft(i)||i===0&&!n?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...t,unit:s.slice(0,-1)}).format(i)}).filter(s=>s);return this.loc.listFormatter({type:"conjunction",style:t.listStyle||"narrow",...t}).format(r)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let t="P";return this.years!==0&&(t+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(t+=this.months+this.quarters*3+"M"),this.weeks!==0&&(t+=this.weeks+"W"),this.days!==0&&(t+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(t+="T"),this.hours!==0&&(t+=this.hours+"H"),this.minutes!==0&&(t+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(t+=QM(this.seconds+this.milliseconds/1e3,3)+"S"),t==="P"&&(t+="T0S"),t}toISOTime(t={}){if(!this.isValid)return null;const n=this.toMillis();return n<0||n>=864e5?null:(t={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...t,includeOffset:!1},xt.fromMillis(n,{zone:"UTC"}).toISOTime(t))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?LZ(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;const n=Ut.fromDurationLike(t),r={};for(const s of su)(rf(n.values,s)||rf(this.values,s))&&(r[s]=n.get(s)+this.get(s));return ja(this,{values:r},!0)}minus(t){if(!this.isValid)return this;const n=Ut.fromDurationLike(t);return this.plus(n.negate())}mapUnits(t){if(!this.isValid)return this;const n={};for(const r of Object.keys(this.values))n[r]=SZ(t(this.values[r],r));return ja(this,{values:n},!0)}get(t){return this[Ut.normalizeUnit(t)]}set(t){if(!this.isValid)return this;const n={...this.values,...S1(t,Ut.normalizeUnit)};return ja(this,{values:n})}reconfigure({locale:t,numberingSystem:n,conversionAccuracy:r,matrix:s}={}){const o={loc:this.loc.clone({locale:t,numberingSystem:n}),matrix:s,conversionAccuracy:r};return ja(this,o)}as(t){return this.isValid?this.shiftTo(t).get(t):NaN}normalize(){if(!this.isValid)return this;const t=this.toObject();return DL(this.matrix,t),ja(this,{values:t},!0)}rescale(){if(!this.isValid)return this;const t=OL(this.normalize().shiftToAll().toObject());return ja(this,{values:t},!0)}shiftTo(...t){if(!this.isValid)return this;if(t.length===0)return this;t=t.map(o=>Ut.normalizeUnit(o));const n={},r={},s=this.toObject();let i;for(const o of su)if(t.indexOf(o)>=0){i=o;let l=0;for(const u in r)l+=this.matrix[u][o]*r[u],r[u]=0;ic(s[o])&&(l+=s[o]);const c=Math.trunc(l);n[o]=c,r[o]=(l*1e3-c*1e3)/1e3}else ic(s[o])&&(r[o]=s[o]);for(const o in r)r[o]!==0&&(n[i]+=o===i?r[o]:r[o]/this.matrix[i][o]);return DL(this.matrix,n),ja(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const t={};for(const n of Object.keys(this.values))t[n]=this.values[n]===0?0:-this.values[n];return ja(this,{values:t},!0)}removeZeros(){if(!this.isValid)return this;const t=OL(this.values);return ja(this,{values:t},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(t){if(!this.isValid||!t.isValid||!this.loc.equals(t.loc))return!1;function n(r,s){return r===void 0||r===0?s===void 0||s===0:r===s}for(const r of su)if(!n(this.values[r],t.values[r]))return!1;return!0}}const Md="Invalid Interval";function e$e(e,t){return!e||!e.isValid?Pn.invalid("missing or invalid start"):!t||!t.isValid?Pn.invalid("missing or invalid end"):t<e?Pn.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null}class Pn{constructor(t){this.s=t.start,this.e=t.end,this.invalid=t.invalid||null,this.isLuxonInterval=!0}static invalid(t,n=null){if(!t)throw new Kr("need to specify a reason the Interval is invalid");const r=t instanceof go?t:new go(t,n);if(On.throwOnInvalid)throw new COe(r);return new Pn({invalid:r})}static fromDateTimes(t,n){const r=Lp(t),s=Lp(n),i=e$e(r,s);return i??new Pn({start:r,end:s})}static after(t,n){const r=Ut.fromDurationLike(n),s=Lp(t);return Pn.fromDateTimes(s,s.plus(r))}static before(t,n){const r=Ut.fromDurationLike(n),s=Lp(t);return Pn.fromDateTimes(s.minus(r),s)}static fromISO(t,n){const[r,s]=(t||"").split("/",2);if(r&&s){let i,o;try{i=xt.fromISO(r,n),o=i.isValid}catch{o=!1}let l,c;try{l=xt.fromISO(s,n),c=l.isValid}catch{c=!1}if(o&&c)return Pn.fromDateTimes(i,l);if(o){const u=Ut.fromISO(s,n);if(u.isValid)return Pn.after(i,u)}else if(c){const u=Ut.fromISO(r,n);if(u.isValid)return Pn.before(l,u)}}return Pn.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(t){return t&&t.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(t="milliseconds"){return this.isValid?this.toDuration(t).get(t):NaN}count(t="milliseconds",n){if(!this.isValid)return NaN;const r=this.start.startOf(t,n);let s;return n!=null&&n.useLocaleWeeks?s=this.end.reconfigure({locale:r.locale}):s=this.end,s=s.startOf(t,n),Math.floor(s.diff(r,t).get(t))+(s.valueOf()!==this.end.valueOf())}hasSame(t){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,t):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(t){return this.isValid?this.s>t:!1}isBefore(t){return this.isValid?this.e<=t:!1}contains(t){return this.isValid?this.s<=t&&this.e>t:!1}set({start:t,end:n}={}){return this.isValid?Pn.fromDateTimes(t||this.s,n||this.e):this}splitAt(...t){if(!this.isValid)return[];const n=t.map(Lp).filter(o=>this.contains(o)).sort((o,l)=>o.toMillis()-l.toMillis()),r=[];let{s}=this,i=0;for(;s<this.e;){const o=n[i]||this.e,l=+o>+this.e?this.e:o;r.push(Pn.fromDateTimes(s,l)),s=l,i+=1}return r}splitBy(t){const n=Ut.fromDurationLike(t);if(!this.isValid||!n.isValid||n.as("milliseconds")===0)return[];let{s:r}=this,s=1,i;const o=[];for(;r<this.e;){const l=this.start.plus(n.mapUnits(c=>c*s));i=+l>+this.e?this.e:l,o.push(Pn.fromDateTimes(r,i)),r=i,s+=1}return o}divideEqually(t){return this.isValid?this.splitBy(this.length()/t).slice(0,t):[]}overlaps(t){return this.e>t.s&&this.s<t.e}abutsStart(t){return this.isValid?+this.e==+t.s:!1}abutsEnd(t){return this.isValid?+t.e==+this.s:!1}engulfs(t){return this.isValid?this.s<=t.s&&this.e>=t.e:!1}equals(t){return!this.isValid||!t.isValid?!1:this.s.equals(t.s)&&this.e.equals(t.e)}intersection(t){if(!this.isValid)return this;const n=this.s>t.s?this.s:t.s,r=this.e<t.e?this.e:t.e;return n>=r?null:Pn.fromDateTimes(n,r)}union(t){if(!this.isValid)return this;const n=this.s<t.s?this.s:t.s,r=this.e>t.e?this.e:t.e;return Pn.fromDateTimes(n,r)}static merge(t){const[n,r]=t.sort((s,i)=>s.s-i.s).reduce(([s,i],o)=>i?i.overlaps(o)||i.abutsStart(o)?[s,i.union(o)]:[s.concat([i]),o]:[s,o],[[],null]);return r&&n.push(r),n}static xor(t){let n=null,r=0;const s=[],i=t.map(c=>[{time:c.s,type:"s"},{time:c.e,type:"e"}]),o=Array.prototype.concat(...i),l=o.sort((c,u)=>c.time-u.time);for(const c of l)r+=c.type==="s"?1:-1,r===1?n=c.time:(n&&+n!=+c.time&&s.push(Pn.fromDateTimes(n,c.time)),n=null);return Pn.merge(s)}difference(...t){return Pn.xor([this].concat(t)).map(n=>this.intersection(n)).filter(n=>n&&!n.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Md}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(t=b1,n={}){return this.isValid?Xr.create(this.s.loc.clone(n),t).formatInterval(this):Md}toISO(t){return this.isValid?`${this.s.toISO(t)}/${this.e.toISO(t)}`:Md}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Md}toISOTime(t){return this.isValid?`${this.s.toISOTime(t)}/${this.e.toISOTime(t)}`:Md}toFormat(t,{separator:n=" – "}={}){return this.isValid?`${this.s.toFormat(t)}${n}${this.e.toFormat(t)}`:Md}toDuration(t,n){return this.isValid?this.e.diff(this.s,t,n):Ut.invalid(this.invalidReason)}mapEndpoints(t){return Pn.fromDateTimes(t(this.s),t(this.e))}}class im{static hasDST(t=On.defaultZone){const n=xt.now().setZone(t).set({month:12});return!t.isUniversal&&n.offset!==n.set({month:6}).offset}static isValidIANAZone(t){return ha.isValidZone(t)}static normalizeZone(t){return Bl(t,On.defaultZone)}static getStartOfWeek({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getWeekendDays().slice()}static months(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null,outputCalendar:i="gregory"}={}){return(s||en.create(n,r,i)).months(t)}static monthsFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null,outputCalendar:i="gregory"}={}){return(s||en.create(n,r,i)).months(t,!0)}static weekdays(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null}={}){return(s||en.create(n,r,null)).weekdays(t)}static weekdaysFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null}={}){return(s||en.create(n,r,null)).weekdays(t,!0)}static meridiems({locale:t=null}={}){return en.create(t).meridiems()}static eras(t="short",{locale:n=null}={}){return en.create(n,null,"gregory").eras(t)}static features(){return{relative:bZ(),localeWeek:wZ()}}}function AL(e,t){const n=s=>s.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(t)-n(e);return Math.floor(Ut.fromMillis(r).as("days"))}function t$e(e,t,n){const r=[["years",(c,u)=>u.year-c.year],["quarters",(c,u)=>u.quarter-c.quarter+(u.year-c.year)*4],["months",(c,u)=>u.month-c.month+(u.year-c.year)*12],["weeks",(c,u)=>{const d=AL(c,u);return(d-d%7)/7}],["days",AL]],s={},i=e;let o,l;for(const[c,u]of r)n.indexOf(c)>=0&&(o=c,s[c]=u(e,t),l=i.plus(s),l>t?(s[c]--,e=i.plus(s),e>t&&(l=e,s[c]--,e=i.plus(s))):e=l);return[e,s,l,o]}function n$e(e,t,n,r){let[s,i,o,l]=t$e(e,t,n);const c=t-s,u=n.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<t&&(o=s.plus({[l]:1})),o!==s&&(i[l]=(i[l]||0)+c/(o-s)));const d=Ut.fromObject(i,r);return u.length>0?Ut.fromMillis(c,r).shiftTo(...u).plus(d):d}const r$e="missing Intl.DateTimeFormat.formatToParts support";function Zt(e,t=n=>n){return{regex:e,deser:([n])=>t(KOe(n))}}const s$e=" ",BZ=`[ ${s$e}]`,FZ=new RegExp(BZ,"g");function i$e(e){return e.replace(/\./g,"\\.?").replace(FZ,BZ)}function $L(e){return e.replace(/\./g,"").replace(FZ," ").toLowerCase()}function oo(e,t){return e===null?null:{regex:RegExp(e.map(i$e).join("|")),deser:([n])=>e.findIndex(r=>$L(n)===$L(r))+t}}function LL(e,t){return{regex:e,deser:([,n,r])=>T_(n,r),groups:t}}function D0(e){return{regex:e,deser:([t])=>t}}function o$e(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function a$e(e,t){const n=io(t),r=io(t,"{2}"),s=io(t,"{3}"),i=io(t,"{4}"),o=io(t,"{6}"),l=io(t,"{1,2}"),c=io(t,"{1,3}"),u=io(t,"{1,6}"),d=io(t,"{1,9}"),h=io(t,"{2,4}"),f=io(t,"{4,6}"),m=b=>({regex:RegExp(o$e(b.val)),deser:([y])=>y,literal:!0}),x=(b=>{if(e.literal)return m(b);switch(b.val){case"G":return oo(t.eras("short"),0);case"GG":return oo(t.eras("long"),0);case"y":return Zt(u);case"yy":return Zt(h,ME);case"yyyy":return Zt(i);case"yyyyy":return Zt(f);case"yyyyyy":return Zt(o);case"M":return Zt(l);case"MM":return Zt(r);case"MMM":return oo(t.months("short",!0),1);case"MMMM":return oo(t.months("long",!0),1);case"L":return Zt(l);case"LL":return Zt(r);case"LLL":return oo(t.months("short",!1),1);case"LLLL":return oo(t.months("long",!1),1);case"d":return Zt(l);case"dd":return Zt(r);case"o":return Zt(c);case"ooo":return Zt(s);case"HH":return Zt(r);case"H":return Zt(l);case"hh":return Zt(r);case"h":return Zt(l);case"mm":return Zt(r);case"m":return Zt(l);case"q":return Zt(l);case"qq":return Zt(r);case"s":return Zt(l);case"ss":return Zt(r);case"S":return Zt(c);case"SSS":return Zt(s);case"u":return D0(d);case"uu":return D0(l);case"uuu":return Zt(n);case"a":return oo(t.meridiems(),0);case"kkkk":return Zt(i);case"kk":return Zt(h,ME);case"W":return Zt(l);case"WW":return Zt(r);case"E":case"c":return Zt(n);case"EEE":return oo(t.weekdays("short",!1),1);case"EEEE":return oo(t.weekdays("long",!1),1);case"ccc":return oo(t.weekdays("short",!0),1);case"cccc":return oo(t.weekdays("long",!0),1);case"Z":case"ZZ":return LL(new RegExp(`([+-]${l.source})(?::(${r.source}))?`),2);case"ZZZ":return LL(new RegExp(`([+-]${l.source})(${r.source})?`),2);case"z":return D0(/[a-z_+-/]{1,256}?/i);case" ":return D0(/[^\S\n\r]/);default:return m(b)}})(e)||{invalidReason:r$e};return x.token=e,x}const l$e={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function c$e(e,t,n){const{type:r,value:s}=e;if(r==="literal"){const c=/^\s+$/.test(s);return{literal:!c,val:c?" ":s}}const i=t[r];let o=r;r==="hour"&&(t.hour12!=null?o=t.hour12?"hour12":"hour24":t.hourCycle!=null?t.hourCycle==="h11"||t.hourCycle==="h12"?o="hour12":o="hour24":o=n.hour12?"hour12":"hour24");let l=l$e[o];if(typeof l=="object"&&(l=l[i]),l)return{literal:!1,val:l}}function u$e(e){return[`^${e.map(n=>n.regex).reduce((n,r)=>`${n}(${r.source})`,"")}$`,e]}function d$e(e,t,n){const r=e.match(t);if(r){const s={};let i=1;for(const o in n)if(rf(n,o)){const l=n[o],c=l.groups?l.groups+1:1;!l.literal&&l.token&&(s[l.token.val[0]]=l.deser(r.slice(i,i+c))),i+=c}return[r,s]}else return[r,{}]}function h$e(e){const t=i=>{switch(i){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let n=null,r;return ft(e.z)||(n=ha.create(e.z)),ft(e.Z)||(n||(n=new Jr(e.Z)),r=e.Z),ft(e.q)||(e.M=(e.q-1)*3+1),ft(e.h)||(e.h<12&&e.a===1?e.h+=12:e.h===12&&e.a===0&&(e.h=0)),e.G===0&&e.y&&(e.y=-e.y),ft(e.u)||(e.S=ZM(e.u)),[Object.keys(e).reduce((i,o)=>{const l=t(o);return l&&(i[l]=e[o]),i},{}),n,r]}let IC=null;function f$e(){return IC||(IC=xt.fromMillis(1555555555555)),IC}function p$e(e,t){if(e.literal)return e;const n=Xr.macroTokenToFormatOpts(e.val),r=WZ(n,t);return r==null||r.includes(void 0)?e:r}function zZ(e,t){return Array.prototype.concat(...e.map(n=>p$e(n,t)))}class HZ{constructor(t,n){if(this.locale=t,this.format=n,this.tokens=zZ(Xr.parseFormat(n),t),this.units=this.tokens.map(r=>a$e(r,t)),this.disqualifyingUnit=this.units.find(r=>r.invalidReason),!this.disqualifyingUnit){const[r,s]=u$e(this.units);this.regex=RegExp(r,"i"),this.handlers=s}}explainFromTokens(t){if(this.isValid){const[n,r]=d$e(t,this.regex,this.handlers),[s,i,o]=r?h$e(r):[null,null,void 0];if(rf(r,"a")&&rf(r,"H"))throw new oh("Can't include meridiem when specifying 24-hour format");return{input:t,tokens:this.tokens,regex:this.regex,rawMatches:n,matches:r,result:s,zone:i,specificOffset:o}}else return{input:t,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function UZ(e,t,n){return new HZ(e,n).explainFromTokens(t)}function m$e(e,t,n){const{result:r,zone:s,specificOffset:i,invalidReason:o}=UZ(e,t,n);return[r,s,i,o]}function WZ(e,t){if(!e)return null;const r=Xr.create(t,e).dtFormatter(f$e()),s=r.formatToParts(),i=r.resolvedOptions();return s.map(o=>c$e(o,e,i))}const TC="Invalid DateTime",BL=864e13;function om(e){return new go("unsupported zone",`the zone "${e.name}" is not supported`)}function MC(e){return e.weekData===null&&(e.weekData=w1(e.c)),e.weekData}function RC(e){return e.localWeekData===null&&(e.localWeekData=w1(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function zc(e,t){const n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new xt({...n,...t,old:n})}function VZ(e,t,n){let r=e-t*60*1e3;const s=n.offset(r);if(t===s)return[r,t];r-=(s-t)*60*1e3;const i=n.offset(r);return s===i?[r,s]:[e-Math.min(s,i)*60*1e3,Math.max(s,i)]}function O0(e,t){e+=t*60*1e3;const n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function Ly(e,t,n){return VZ(I_(e),t,n)}function FL(e,t){const n=e.o,r=e.c.year+Math.trunc(t.years),s=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,i={...e.c,year:r,month:s,day:Math.min(e.c.day,_1(r,s))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=Ut.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),l=I_(i);let[c,u]=VZ(l,n,e.zone);return o!==0&&(c+=o,u=e.zone.offset(c)),{ts:c,o:u}}function Rd(e,t,n,r,s,i){const{setZone:o,zone:l}=n;if(e&&Object.keys(e).length!==0||t){const c=t||l,u=xt.fromObject(e,{...n,zone:c,specificOffset:i});return o?u:u.setZone(l)}else return xt.invalid(new go("unparsable",`the input "${s}" can't be parsed as ${r}`))}function A0(e,t,n=!0){return e.isValid?Xr.create(en.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function PC(e,t,n){const r=e.c.year>9999||e.c.year<0;let s="";if(r&&e.c.year>=0&&(s+="+"),s+=nr(e.c.year,r?6:4),n==="year")return s;if(t){if(s+="-",s+=nr(e.c.month),n==="month")return s;s+="-"}else if(s+=nr(e.c.month),n==="month")return s;return s+=nr(e.c.day),s}function zL(e,t,n,r,s,i,o){let l=!n||e.c.millisecond!==0||e.c.second!==0,c="";switch(o){case"day":case"month":case"year":break;default:if(c+=nr(e.c.hour),o==="hour")break;if(t){if(c+=":",c+=nr(e.c.minute),o==="minute")break;l&&(c+=":",c+=nr(e.c.second))}else{if(c+=nr(e.c.minute),o==="minute")break;l&&(c+=nr(e.c.second))}if(o==="second")break;l&&(!r||e.c.millisecond!==0)&&(c+=".",c+=nr(e.c.millisecond,3))}return s&&(e.isOffsetFixed&&e.offset===0&&!i?c+="Z":e.o<0?(c+="-",c+=nr(Math.trunc(-e.o/60)),c+=":",c+=nr(Math.trunc(-e.o%60))):(c+="+",c+=nr(Math.trunc(e.o/60)),c+=":",c+=nr(Math.trunc(e.o%60)))),i&&(c+="["+e.zone.ianaName+"]"),c}const qZ={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},g$e={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},x$e={ordinal:1,hour:0,minute:0,second:0,millisecond:0},By=["year","month","day","hour","minute","second","millisecond"],v$e=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],y$e=["year","ordinal","hour","minute","second","millisecond"];function Fy(e){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new VX(e);return t}function HL(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Fy(e)}}function b$e(e){if(am===void 0&&(am=On.now()),e.type!=="iana")return e.offset(am);const t=e.name;let n=RE.get(t);return n===void 0&&(n=e.offset(am),RE.set(t,n)),n}function UL(e,t){const n=Bl(t.zone,On.defaultZone);if(!n.isValid)return xt.invalid(om(n));const r=en.fromObject(t);let s,i;if(ft(e.year))s=On.now();else{for(const c of By)ft(e[c])&&(e[c]=qZ[c]);const o=vZ(e)||yZ(e);if(o)return xt.invalid(o);const l=b$e(n);[s,i]=Ly(e,l,n)}return new xt({ts:s,zone:n,loc:r,o:i})}function WL(e,t,n){const r=ft(n.round)?!0:n.round,s=ft(n.rounding)?"trunc":n.rounding,i=(l,c)=>(l=QM(l,r||n.calendary?0:2,n.calendary?"round":s),t.loc.clone(n).relFormatter(n).format(l,c)),o=l=>n.calendary?t.hasSame(e,l)?0:t.startOf(l).diff(e.startOf(l),l).get(l):t.diff(e,l).get(l);if(n.unit)return i(o(n.unit),n.unit);for(const l of n.units){const c=o(l);if(Math.abs(c)>=1)return i(c,l)}return i(e>t?-0:0,n.units[n.units.length-1])}function VL(e){let t={},n;return e.length>0&&typeof e[e.length-1]=="object"?(t=e[e.length-1],n=Array.from(e).slice(0,e.length-1)):n=Array.from(e),[t,n]}let am;const RE=new Map;class xt{constructor(t){const n=t.zone||On.defaultZone;let r=t.invalid||(Number.isNaN(t.ts)?new go("invalid input"):null)||(n.isValid?null:om(n));this.ts=ft(t.ts)?On.now():t.ts;let s=null,i=null;if(!r)if(t.old&&t.old.ts===this.ts&&t.old.zone.equals(n))[s,i]=[t.old.c,t.old.o];else{const l=ic(t.o)&&!t.old?t.o:n.offset(this.ts);s=O0(this.ts,l),r=Number.isNaN(s.year)?new go("invalid input"):null,s=r?null:s,i=r?null:l}this._zone=n,this.loc=t.loc||en.create(),this.invalid=r,this.weekData=null,this.localWeekData=null,this.c=s,this.o=i,this.isLuxonDateTime=!0}static now(){return new xt({})}static local(){const[t,n]=VL(arguments),[r,s,i,o,l,c,u]=n;return UL({year:r,month:s,day:i,hour:o,minute:l,second:c,millisecond:u},t)}static utc(){const[t,n]=VL(arguments),[r,s,i,o,l,c,u]=n;return t.zone=Jr.utcInstance,UL({year:r,month:s,day:i,hour:o,minute:l,second:c,millisecond:u},t)}static fromJSDate(t,n={}){const r=QOe(t)?t.valueOf():NaN;if(Number.isNaN(r))return xt.invalid("invalid input");const s=Bl(n.zone,On.defaultZone);return s.isValid?new xt({ts:r,zone:s,loc:en.fromObject(n)}):xt.invalid(om(s))}static fromMillis(t,n={}){if(ic(t))return t<-BL||t>BL?xt.invalid("Timestamp out of range"):new xt({ts:t,zone:Bl(n.zone,On.defaultZone),loc:en.fromObject(n)});throw new Kr(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(ic(t))return new xt({ts:t*1e3,zone:Bl(n.zone,On.defaultZone),loc:en.fromObject(n)});throw new Kr("fromSeconds requires a numerical input")}static fromObject(t,n={}){t=t||{};const r=Bl(n.zone,On.defaultZone);if(!r.isValid)return xt.invalid(om(r));const s=en.fromObject(n),i=S1(t,HL),{minDaysInFirstWeek:o,startOfWeek:l}=EL(i,s),c=On.now(),u=ft(n.specificOffset)?r.offset(c):n.specificOffset,d=!ft(i.ordinal),h=!ft(i.year),f=!ft(i.month)||!ft(i.day),m=h||f,g=i.weekYear||i.weekNumber;if((m||d)&&g)throw new oh("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(f&&d)throw new oh("Can't mix ordinal dates with month/day");const x=g||i.weekday&&!m;let b,y,v=O0(c,u);x?(b=v$e,y=g$e,v=w1(v,o,l)):d?(b=y$e,y=x$e,v=EC(v)):(b=By,y=qZ);let w=!1;for(const E of b){const I=i[E];ft(I)?w?i[E]=y[E]:i[E]=v[E]:w=!0}const _=x?YOe(i,o,l):d?XOe(i):vZ(i),S=_||yZ(i);if(S)return xt.invalid(S);const k=x?NL(i,o,l):d?jL(i):i,[C,j]=Ly(k,u,r),T=new xt({ts:C,zone:r,o:j,loc:s});return i.weekday&&m&&t.weekday!==T.weekday?xt.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${T.toISO()}`):T.isValid?T:xt.invalid(T.invalid)}static fromISO(t,n={}){const[r,s]=zAe(t);return Rd(r,s,n,"ISO 8601",t)}static fromRFC2822(t,n={}){const[r,s]=HAe(t);return Rd(r,s,n,"RFC 2822",t)}static fromHTTP(t,n={}){const[r,s]=UAe(t);return Rd(r,s,n,"HTTP",n)}static fromFormat(t,n,r={}){if(ft(t)||ft(n))throw new Kr("fromFormat requires an input string and a format");const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0}),[l,c,u,d]=m$e(o,t,n);return d?xt.invalid(d):Rd(l,c,r,`format ${n}`,t,u)}static fromString(t,n,r={}){return xt.fromFormat(t,n,r)}static fromSQL(t,n={}){const[r,s]=XAe(t);return Rd(r,s,n,"SQL",t)}static invalid(t,n=null){if(!t)throw new Kr("need to specify a reason the DateTime is invalid");const r=t instanceof go?t:new go(t,n);if(On.throwOnInvalid)throw new kOe(r);return new xt({invalid:r})}static isDateTime(t){return t&&t.isLuxonDateTime||!1}static parseFormatForOpts(t,n={}){const r=WZ(t,en.fromObject(n));return r?r.map(s=>s?s.val:null).join(""):null}static expandFormat(t,n={}){return zZ(Xr.parseFormat(t),en.fromObject(n)).map(s=>s.val).join("")}static resetCache(){am=void 0,RE.clear()}get(t){return this[t]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?MC(this).weekYear:NaN}get weekNumber(){return this.isValid?MC(this).weekNumber:NaN}get weekday(){return this.isValid?MC(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?RC(this).weekday:NaN}get localWeekNumber(){return this.isValid?RC(this).weekNumber:NaN}get localWeekYear(){return this.isValid?RC(this).weekYear:NaN}get ordinal(){return this.isValid?EC(this.c).ordinal:NaN}get monthShort(){return this.isValid?im.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?im.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?im.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?im.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const t=864e5,n=6e4,r=I_(this.c),s=this.zone.offset(r-t),i=this.zone.offset(r+t),o=this.zone.offset(r-s*n),l=this.zone.offset(r-i*n);if(o===l)return[this];const c=r-o*n,u=r-l*n,d=O0(c,o),h=O0(u,l);return d.hour===h.hour&&d.minute===h.minute&&d.second===h.second&&d.millisecond===h.millisecond?[zc(this,{ts:c}),zc(this,{ts:u})]:[this]}get isInLeapYear(){return $x(this.year)}get daysInMonth(){return _1(this.year,this.month)}get daysInYear(){return this.isValid?Sh(this.year):NaN}get weeksInWeekYear(){return this.isValid?Lg(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Lg(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(t={}){const{locale:n,numberingSystem:r,calendar:s}=Xr.create(this.loc.clone(t),t).resolvedOptions(this);return{locale:n,numberingSystem:r,outputCalendar:s}}toUTC(t=0,n={}){return this.setZone(Jr.instance(t),n)}toLocal(){return this.setZone(On.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=Bl(t,On.defaultZone),t.equals(this.zone))return this;if(t.isValid){let s=this.ts;if(n||r){const i=t.offset(this.ts),o=this.toObject();[s]=Ly(o,i,t)}return zc(this,{ts:s,zone:t})}else return xt.invalid(om(t))}reconfigure({locale:t,numberingSystem:n,outputCalendar:r}={}){const s=this.loc.clone({locale:t,numberingSystem:n,outputCalendar:r});return zc(this,{loc:s})}setLocale(t){return this.reconfigure({locale:t})}set(t){if(!this.isValid)return this;const n=S1(t,HL),{minDaysInFirstWeek:r,startOfWeek:s}=EL(n,this.loc),i=!ft(n.weekYear)||!ft(n.weekNumber)||!ft(n.weekday),o=!ft(n.ordinal),l=!ft(n.year),c=!ft(n.month)||!ft(n.day),u=l||c,d=n.weekYear||n.weekNumber;if((u||o)&&d)throw new oh("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new oh("Can't mix ordinal dates with month/day");let h;i?h=NL({...w1(this.c,r,s),...n},r,s):ft(n.ordinal)?(h={...this.toObject(),...n},ft(n.day)&&(h.day=Math.min(_1(h.year,h.month),h.day))):h=jL({...EC(this.c),...n});const[f,m]=Ly(h,this.o,this.zone);return zc(this,{ts:f,o:m})}plus(t){if(!this.isValid)return this;const n=Ut.fromDurationLike(t);return zc(this,FL(this,n))}minus(t){if(!this.isValid)return this;const n=Ut.fromDurationLike(t).negate();return zc(this,FL(this,n))}startOf(t,{useLocaleWeeks:n=!1}={}){if(!this.isValid)return this;const r={},s=Ut.normalizeUnit(t);switch(s){case"years":r.month=1;case"quarters":case"months":r.day=1;case"weeks":case"days":r.hour=0;case"hours":r.minute=0;case"minutes":r.second=0;case"seconds":r.millisecond=0;break}if(s==="weeks")if(n){const i=this.loc.getStartOfWeek(),{weekday:o}=this;o<i&&(r.weekNumber=this.weekNumber-1),r.weekday=i}else r.weekday=1;if(s==="quarters"){const i=Math.ceil(this.month/3);r.month=(i-1)*3+1}return this.set(r)}endOf(t,n){return this.isValid?this.plus({[t]:1}).startOf(t,n).minus(1):this}toFormat(t,n={}){return this.isValid?Xr.create(this.loc.redefaultToEN(n)).formatDateTimeFromString(this,t):TC}toLocaleString(t=b1,n={}){return this.isValid?Xr.create(this.loc.clone(n),t).formatDateTime(this):TC}toLocaleParts(t={}){return this.isValid?Xr.create(this.loc.clone(t),t).formatDateTimeParts(this):[]}toISO({format:t="extended",suppressSeconds:n=!1,suppressMilliseconds:r=!1,includeOffset:s=!0,extendedZone:i=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=Fy(o);const l=t==="extended";let c=PC(this,l,o);return By.indexOf(o)>=3&&(c+="T"),c+=zL(this,l,n,r,s,i,o),c}toISODate({format:t="extended",precision:n="day"}={}){return this.isValid?PC(this,t==="extended",Fy(n)):null}toISOWeekDate(){return A0(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:t=!1,suppressSeconds:n=!1,includeOffset:r=!0,includePrefix:s=!1,extendedZone:i=!1,format:o="extended",precision:l="milliseconds"}={}){return this.isValid?(l=Fy(l),(s&&By.indexOf(l)>=3?"T":"")+zL(this,o==="extended",n,t,r,i,l)):null}toRFC2822(){return A0(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return A0(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?PC(this,!0):null}toSQLTime({includeOffset:t=!0,includeZone:n=!1,includeOffsetSpace:r=!0}={}){let s="HH:mm:ss.SSS";return(n||t)&&(r&&(s+=" "),n?s+="z":t&&(s+="ZZ")),A0(this,s,!0)}toSQL(t={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(t)}`:null}toString(){return this.isValid?this.toISO():TC}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(t={}){if(!this.isValid)return{};const n={...this.c};return t.includeConfig&&(n.outputCalendar=this.outputCalendar,n.numberingSystem=this.loc.numberingSystem,n.locale=this.loc.locale),n}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(t,n="milliseconds",r={}){if(!this.isValid||!t.isValid)return Ut.invalid("created by diffing an invalid DateTime");const s={locale:this.locale,numberingSystem:this.numberingSystem,...r},i=JOe(n).map(Ut.normalizeUnit),o=t.valueOf()>this.valueOf(),l=o?this:t,c=o?t:this,u=n$e(l,c,i,s);return o?u.negate():u}diffNow(t="milliseconds",n={}){return this.diff(xt.now(),t,n)}until(t){return this.isValid?Pn.fromDateTimes(this,t):this}hasSame(t,n,r){if(!this.isValid)return!1;const s=t.valueOf(),i=this.setZone(t.zone,{keepLocalTime:!0});return i.startOf(n,r)<=s&&s<=i.endOf(n,r)}equals(t){return this.isValid&&t.isValid&&this.valueOf()===t.valueOf()&&this.zone.equals(t.zone)&&this.loc.equals(t.loc)}toRelative(t={}){if(!this.isValid)return null;const n=t.base||xt.fromObject({},{zone:this.zone}),r=t.padding?this<n?-t.padding:t.padding:0;let s=["years","months","days","hours","minutes","seconds"],i=t.unit;return Array.isArray(t.unit)&&(s=t.unit,i=void 0),WL(n,this.plus(r),{...t,numeric:"always",units:s,unit:i})}toRelativeCalendar(t={}){return this.isValid?WL(t.base||xt.fromObject({},{zone:this.zone}),this,{...t,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...t){if(!t.every(xt.isDateTime))throw new Kr("min requires all arguments be DateTimes");return IL(t,n=>n.valueOf(),Math.min)}static max(...t){if(!t.every(xt.isDateTime))throw new Kr("max requires all arguments be DateTimes");return IL(t,n=>n.valueOf(),Math.max)}static fromFormatExplain(t,n,r={}){const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0});return UZ(o,t,n)}static fromStringExplain(t,n,r={}){return xt.fromFormatExplain(t,n,r)}static buildFormatParser(t,n={}){const{locale:r=null,numberingSystem:s=null}=n,i=en.fromOpts({locale:r,numberingSystem:s,defaultToEN:!0});return new HZ(i,t)}static fromFormatParser(t,n,r={}){if(ft(t)||ft(n))throw new Kr("fromFormatParser requires an input string and a format parser");const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0});if(!o.equals(n.locale))throw new Kr(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${n.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:d}=n.explainFromTokens(t);return d?xt.invalid(d):Rd(l,c,r,`format ${n.format}`,t,u)}static get DATE_SHORT(){return b1}static get DATE_MED(){return qX}static get DATE_MED_WITH_WEEKDAY(){return jOe}static get DATE_FULL(){return KX}static get DATE_HUGE(){return GX}static get TIME_SIMPLE(){return YX}static get TIME_WITH_SECONDS(){return XX}static get TIME_WITH_SHORT_OFFSET(){return ZX}static get TIME_WITH_LONG_OFFSET(){return QX}static get TIME_24_SIMPLE(){return JX}static get TIME_24_WITH_SECONDS(){return eZ}static get TIME_24_WITH_SHORT_OFFSET(){return tZ}static get TIME_24_WITH_LONG_OFFSET(){return nZ}static get DATETIME_SHORT(){return rZ}static get DATETIME_SHORT_WITH_SECONDS(){return sZ}static get DATETIME_MED(){return iZ}static get DATETIME_MED_WITH_SECONDS(){return oZ}static get DATETIME_MED_WITH_WEEKDAY(){return EOe}static get DATETIME_FULL(){return aZ}static get DATETIME_FULL_WITH_SECONDS(){return lZ}static get DATETIME_HUGE(){return cZ}static get DATETIME_HUGE_WITH_SECONDS(){return uZ}}function Lp(e){if(xt.isDateTime(e))return e;if(e&&e.valueOf&&ic(e.valueOf()))return xt.fromJSDate(e);if(e&&typeof e=="object")return xt.fromObject(e);throw new Kr(`Unknown datetime argument: ${e}, of type ${typeof e}`)}const w$e="3.7.2";mi.DateTime=xt;mi.Duration=Ut;mi.FixedOffsetZone=Jr;mi.IANAZone=ha;mi.Info=im;mi.Interval=Pn;mi.InvalidZone=fZ;mi.Settings=On;mi.SystemZone=Ax;mi.VERSION=w$e;mi.Zone=Of;var Hc=mi;vt.prototype.addYear=function(){this._date=this._date.plus({years:1})};vt.prototype.addMonth=function(){this._date=this._date.plus({months:1}).startOf("month")};vt.prototype.addDay=function(){this._date=this._date.plus({days:1}).startOf("day")};vt.prototype.addHour=function(){var e=this._date;this._date=this._date.plus({hours:1}).startOf("hour"),this._date<=e&&(this._date=this._date.plus({hours:1}))};vt.prototype.addMinute=function(){var e=this._date;this._date=this._date.plus({minutes:1}).startOf("minute"),this._date<e&&(this._date=this._date.plus({hours:1}))};vt.prototype.addSecond=function(){var e=this._date;this._date=this._date.plus({seconds:1}).startOf("second"),this._date<e&&(this._date=this._date.plus({hours:1}))};vt.prototype.subtractYear=function(){this._date=this._date.minus({years:1})};vt.prototype.subtractMonth=function(){this._date=this._date.minus({months:1}).endOf("month").startOf("second")};vt.prototype.subtractDay=function(){this._date=this._date.minus({days:1}).endOf("day").startOf("second")};vt.prototype.subtractHour=function(){var e=this._date;this._date=this._date.minus({hours:1}).endOf("hour").startOf("second"),this._date>=e&&(this._date=this._date.minus({hours:1}))};vt.prototype.subtractMinute=function(){var e=this._date;this._date=this._date.minus({minutes:1}).endOf("minute").startOf("second"),this._date>e&&(this._date=this._date.minus({hours:1}))};vt.prototype.subtractSecond=function(){var e=this._date;this._date=this._date.minus({seconds:1}).startOf("second"),this._date>e&&(this._date=this._date.minus({hours:1}))};vt.prototype.getDate=function(){return this._date.day};vt.prototype.getFullYear=function(){return this._date.year};vt.prototype.getDay=function(){var e=this._date.weekday;return e==7?0:e};vt.prototype.getMonth=function(){return this._date.month-1};vt.prototype.getHours=function(){return this._date.hour};vt.prototype.getMinutes=function(){return this._date.minute};vt.prototype.getSeconds=function(){return this._date.second};vt.prototype.getMilliseconds=function(){return this._date.millisecond};vt.prototype.getTime=function(){return this._date.valueOf()};vt.prototype.getUTCDate=function(){return this._getUTC().day};vt.prototype.getUTCFullYear=function(){return this._getUTC().year};vt.prototype.getUTCDay=function(){var e=this._getUTC().weekday;return e==7?0:e};vt.prototype.getUTCMonth=function(){return this._getUTC().month-1};vt.prototype.getUTCHours=function(){return this._getUTC().hour};vt.prototype.getUTCMinutes=function(){return this._getUTC().minute};vt.prototype.getUTCSeconds=function(){return this._getUTC().second};vt.prototype.toISOString=function(){return this._date.toUTC().toISO()};vt.prototype.toJSON=function(){return this._date.toJSON()};vt.prototype.setDate=function(e){this._date=this._date.set({day:e})};vt.prototype.setFullYear=function(e){this._date=this._date.set({year:e})};vt.prototype.setDay=function(e){this._date=this._date.set({weekday:e})};vt.prototype.setMonth=function(e){this._date=this._date.set({month:e+1})};vt.prototype.setHours=function(e){this._date=this._date.set({hour:e})};vt.prototype.setMinutes=function(e){this._date=this._date.set({minute:e})};vt.prototype.setSeconds=function(e){this._date=this._date.set({second:e})};vt.prototype.setMilliseconds=function(e){this._date=this._date.set({millisecond:e})};vt.prototype._getUTC=function(){return this._date.toUTC()};vt.prototype.toString=function(){return this.toDate().toString()};vt.prototype.toDate=function(){return this._date.toJSDate()};vt.prototype.isLastDayOfMonth=function(){var e=this._date.plus({days:1}).startOf("day");return this._date.month!==e.month};vt.prototype.isLastWeekdayOfMonth=function(){var e=this._date.plus({days:7}).startOf("day");return this._date.month!==e.month};function vt(e,t){var n={zone:t};if(e?e instanceof vt?this._date=e._date:e instanceof Date?this._date=Hc.DateTime.fromJSDate(e,n):typeof e=="number"?this._date=Hc.DateTime.fromMillis(e,n):typeof e=="string"&&(this._date=Hc.DateTime.fromISO(e,n),this._date.isValid||(this._date=Hc.DateTime.fromRFC2822(e,n)),this._date.isValid||(this._date=Hc.DateTime.fromSQL(e,n)),this._date.isValid||(this._date=Hc.DateTime.fromFormat(e,"EEE, d MMM yyyy HH:mm:ss",n))):this._date=Hc.DateTime.local(),!this._date||!this._date.isValid)throw new Error("CronDate: unhandled timestamp: "+JSON.stringify(e));t&&t!==this._date.zoneName&&(this._date=this._date.setZone(t))}var _$e=vt;function Qc(e){return{start:e,count:1}}function qL(e,t){e.end=t,e.step=t-e.start,e.count=2}function DC(e,t,n){t&&(t.count===2?(e.push(Qc(t.start)),e.push(Qc(t.end))):e.push(t)),n&&e.push(n)}function S$e(e){for(var t=[],n=void 0,r=0;r<e.length;r++){var s=e[r];typeof s!="number"?(DC(t,n,Qc(s)),n=void 0):n?n.count===1?qL(n,s):n.step===s-n.end?(n.count++,n.end=s):n.count===2?(t.push(Qc(n.start)),n=Qc(n.end),qL(n,s)):(DC(t,n),n=Qc(s)):n=Qc(s)}return DC(t,n),t}var k$e=S$e,C$e=k$e;function N$e(e,t,n){var r=C$e(e);if(r.length===1){var s=r[0],i=s.step;if(i===1&&s.start===t&&s.end===n)return"*";if(i!==1&&s.start===t&&s.end===n-i+1)return"*/"+i}for(var o=[],l=0,c=r.length;l<c;++l){var u=r[l];if(u.count===1){o.push(u.start);continue}var i=u.step;if(u.step===1){o.push(u.start+"-"+u.end);continue}var d=u.start==0?u.count-1:u.count;u.step*d>u.end?o=o.concat(Array.from({length:u.end-u.start+1}).map(function(f,m){var g=u.start+m;return(g-u.start)%u.step===0?g:null}).filter(function(f){return f!=null})):u.end===n-u.step+1?o.push(u.start+"/"+u.step):o.push(u.start+"-"+u.end+"/"+u.step)}return o.join(",")}var j$e=N$e,cu=_$e,E$e=j$e,KL=1e4;function Be(e,t){this._options=t,this._utc=t.utc||!1,this._tz=this._utc?"UTC":t.tz,this._currentDate=new cu(t.currentDate,this._tz),this._startDate=t.startDate?new cu(t.startDate,this._tz):null,this._endDate=t.endDate?new cu(t.endDate,this._tz):null,this._isIterator=t.iterator||!1,this._hasIterated=!1,this._nthDayOfWeek=t.nthDayOfWeek||0,this.fields=Be._freezeFields(e)}Be.map=["second","minute","hour","dayOfMonth","month","dayOfWeek"];Be.predefined={"@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *"};Be.constraints=[{min:0,max:59,chars:[]},{min:0,max:59,chars:[]},{min:0,max:23,chars:[]},{min:1,max:31,chars:["L"]},{min:1,max:12,chars:[]},{min:0,max:7,chars:["L"]}];Be.daysInMonth=[31,29,31,30,31,30,31,31,30,31,30,31];Be.aliases={month:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},dayOfWeek:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}};Be.parseDefaults=["0","*","*","*","*","*"];Be.standardValidCharacters=/^[,*\d/-]+$/;Be.dayOfWeekValidCharacters=/^[?,*\dL#/-]+$/;Be.dayOfMonthValidCharacters=/^[?,*\dL/-]+$/;Be.validCharacters={second:Be.standardValidCharacters,minute:Be.standardValidCharacters,hour:Be.standardValidCharacters,dayOfMonth:Be.dayOfMonthValidCharacters,month:Be.standardValidCharacters,dayOfWeek:Be.dayOfWeekValidCharacters};Be._isValidConstraintChar=function(t,n){return typeof n!="string"?!1:t.chars.some(function(r){return n.indexOf(r)>-1})};Be._parseField=function(t,n,r){switch(t){case"month":case"dayOfWeek":var s=Be.aliases[t];n=n.replace(/[a-z]{3}/gi,function(c){if(c=c.toLowerCase(),typeof s[c]<"u")return s[c];throw new Error('Validation error, cannot resolve alias "'+c+'"')});break}if(!Be.validCharacters[t].test(n))throw new Error("Invalid characters, got value: "+n);n.indexOf("*")!==-1?n=n.replace(/\*/g,r.min+"-"+r.max):n.indexOf("?")!==-1&&(n=n.replace(/\?/g,r.min+"-"+r.max));function i(c){var u=[];function d(g){if(g instanceof Array)for(var x=0,b=g.length;x<b;x++){var y=g[x];if(Be._isValidConstraintChar(r,y)){u.push(y);continue}if(typeof y!="number"||Number.isNaN(y)||y<r.min||y>r.max)throw new Error("Constraint error, got value "+y+" expected range "+r.min+"-"+r.max);u.push(y)}else{if(Be._isValidConstraintChar(r,g)){u.push(g);return}var v=+g;if(Number.isNaN(v)||v<r.min||v>r.max)throw new Error("Constraint error, got value "+g+" expected range "+r.min+"-"+r.max);t==="dayOfWeek"&&(v=v%7),u.push(v)}}var h=c.split(",");if(!h.every(function(g){return g.length>0}))throw new Error("Invalid list value format");if(h.length>1)for(var f=0,m=h.length;f<m;f++)d(o(h[f]));else d(o(c));return u.sort(Be._sortCompareFn),u}function o(c){var u=1,d=c.split("/");if(d.length>2)throw new Error("Invalid repeat: "+c);return d.length>1?(d[0]==+d[0]&&(d=[d[0]+"-"+r.max,d[1]]),l(d[0],d[d.length-1])):l(c,u)}function l(c,u){var d=[],h=c.split("-");if(h.length>1){if(h.length<2)return+c;if(!h[0].length){if(!h[1].length)throw new Error("Invalid range: "+c);return+c}var f=+h[0],m=+h[1];if(Number.isNaN(f)||Number.isNaN(m)||f<r.min||m>r.max)throw new Error("Constraint error, got range "+f+"-"+m+" expected range "+r.min+"-"+r.max);if(f>m)throw new Error("Invalid range: "+c);var g=+u;if(Number.isNaN(g)||g<=0)throw new Error("Constraint error, cannot repeat at every "+g+" time.");t==="dayOfWeek"&&m%7===0&&d.push(0);for(var x=f,b=m;x<=b;x++){var y=d.indexOf(x)!==-1;!y&&g>0&&g%u===0?(g=1,d.push(x)):g++}return d}return Number.isNaN(+c)?c:+c}return i(n)};Be._sortCompareFn=function(e,t){var n=typeof e=="number",r=typeof t=="number";return n&&r?e-t:!n&&r?1:n&&!r?-1:e.localeCompare(t)};Be._handleMaxDaysInMonth=function(e){if(e.month.length===1){var t=Be.daysInMonth[e.month[0]-1];if(e.dayOfMonth[0]>t)throw new Error("Invalid explicit day of month definition");return e.dayOfMonth.filter(function(n){return n==="L"?!0:n<=t}).sort(Be._sortCompareFn)}};Be._freezeFields=function(e){for(var t=0,n=Be.map.length;t<n;++t){var r=Be.map[t],s=e[r];e[r]=Object.freeze(s)}return Object.freeze(e)};Be.prototype._applyTimezoneShift=function(e,t,n){if(n==="Month"||n==="Day"){var r=e.getTime();e[t+n]();var s=e.getTime();r===s&&(e.getMinutes()===0&&e.getSeconds()===0?e.addHour():e.getMinutes()===59&&e.getSeconds()===59&&e.subtractHour())}else{var i=e.getHours();e[t+n]();var o=e.getHours(),l=o-i;l===2?this.fields.hour.length!==24&&(this._dstStart=o):l===0&&e.getMinutes()===0&&e.getSeconds()===0&&this.fields.hour.length!==24&&(this._dstEnd=o)}};Be.prototype._findSchedule=function(t){function n(y,v){for(var w=0,_=v.length;w<_;w++)if(v[w]>=y)return v[w]===y;return v[0]===y}function r(y,v){if(v<6){if(y.getDate()<8&&v===1)return!0;var w=y.getDate()%7?1:0,_=y.getDate()-y.getDate()%7,S=Math.floor(_/7)+w;return S===v}return!1}function s(y){return y.length>0&&y.some(function(v){return typeof v=="string"&&v.indexOf("L")>=0})}t=t||!1;var i=t?"subtract":"add",o=new cu(this._currentDate,this._tz),l=this._startDate,c=this._endDate,u=o.getTime(),d=0;function h(y){return y.some(function(v){if(!s([v]))return!1;var w=Number.parseInt(v[0])%7;if(Number.isNaN(w))throw new Error("Invalid last weekday of the month expression: "+v);return o.getDay()===w&&o.isLastWeekdayOfMonth()})}for(;d<KL;){if(d++,t){if(l&&o.getTime()-l.getTime()<0)throw new Error("Out of the timespan range")}else if(c&&c.getTime()-o.getTime()<0)throw new Error("Out of the timespan range");var f=n(o.getDate(),this.fields.dayOfMonth);s(this.fields.dayOfMonth)&&(f=f||o.isLastDayOfMonth());var m=n(o.getDay(),this.fields.dayOfWeek);s(this.fields.dayOfWeek)&&(m=m||h(this.fields.dayOfWeek));var g=this.fields.dayOfMonth.length>=Be.daysInMonth[o.getMonth()],x=this.fields.dayOfWeek.length===Be.constraints[5].max-Be.constraints[5].min+1,b=o.getHours();if(!f&&(!m||x)){this._applyTimezoneShift(o,i,"Day");continue}if(!g&&x&&!f){this._applyTimezoneShift(o,i,"Day");continue}if(g&&!x&&!m){this._applyTimezoneShift(o,i,"Day");continue}if(this._nthDayOfWeek>0&&!r(o,this._nthDayOfWeek)){this._applyTimezoneShift(o,i,"Day");continue}if(!n(o.getMonth()+1,this.fields.month)){this._applyTimezoneShift(o,i,"Month");continue}if(n(b,this.fields.hour)){if(this._dstEnd===b&&!t){this._dstEnd=null,this._applyTimezoneShift(o,"add","Hour");continue}}else if(this._dstStart!==b){this._dstStart=null,this._applyTimezoneShift(o,i,"Hour");continue}else if(!n(b-1,this.fields.hour)){o[i+"Hour"]();continue}if(!n(o.getMinutes(),this.fields.minute)){this._applyTimezoneShift(o,i,"Minute");continue}if(!n(o.getSeconds(),this.fields.second)){this._applyTimezoneShift(o,i,"Second");continue}if(u===o.getTime()){i==="add"||o.getMilliseconds()===0?this._applyTimezoneShift(o,i,"Second"):o.setMilliseconds(0);continue}break}if(d>=KL)throw new Error("Invalid expression, loop limit exceeded");return this._currentDate=new cu(o,this._tz),this._hasIterated=!0,o};Be.prototype.next=function(){var t=this._findSchedule();return this._isIterator?{value:t,done:!this.hasNext()}:t};Be.prototype.prev=function(){var t=this._findSchedule(!0);return this._isIterator?{value:t,done:!this.hasPrev()}:t};Be.prototype.hasNext=function(){var e=this._currentDate,t=this._hasIterated;try{return this._findSchedule(),!0}catch{return!1}finally{this._currentDate=e,this._hasIterated=t}};Be.prototype.hasPrev=function(){var e=this._currentDate,t=this._hasIterated;try{return this._findSchedule(!0),!0}catch{return!1}finally{this._currentDate=e,this._hasIterated=t}};Be.prototype.iterate=function(t,n){var r=[];if(t>=0)for(var s=0,i=t;s<i;s++)try{var o=this.next();r.push(o),n&&n(o,s)}catch{break}else for(var s=0,i=t;s>i;s--)try{var o=this.prev();r.push(o),n&&n(o,s)}catch{break}return r};Be.prototype.reset=function(t){this._currentDate=new cu(t||this._options.currentDate)};Be.prototype.stringify=function(t){for(var n=[],r=t?0:1,s=Be.map.length;r<s;++r){var i=Be.map[r],o=this.fields[i],l=Be.constraints[r];i==="dayOfMonth"&&this.fields.month.length===1?l={min:1,max:Be.daysInMonth[this.fields.month[0]-1]}:i==="dayOfWeek"&&(l={min:0,max:6},o=o[o.length-1]===7?o.slice(0,-1):o),n.push(E$e(o,l.min,l.max))}return n.join(" ")};Be.parse=function(t,n){var r=this;typeof n=="function"&&(n={});function s(i,o){o||(o={}),typeof o.currentDate>"u"&&(o.currentDate=new cu(void 0,r._tz)),Be.predefined[i]&&(i=Be.predefined[i]);var l=[],c=(i+"").trim().split(/\s+/);if(c.length>6)throw new Error("Invalid cron expression");for(var u=Be.map.length-c.length,d=0,h=Be.map.length;d<h;++d){var f=Be.map[d],m=c[c.length>h?d:d-u];if(d<u||!m)l.push(Be._parseField(f,Be.parseDefaults[d],Be.constraints[d]));else{var g=f==="dayOfWeek"?v(m):m;l.push(Be._parseField(f,g,Be.constraints[d]))}}for(var x={},d=0,h=Be.map.length;d<h;d++){var b=Be.map[d];x[b]=l[d]}var y=Be._handleMaxDaysInMonth(x);return x.dayOfMonth=y||x.dayOfMonth,new Be(x,o);function v(w){var _=w.split("#");if(_.length>1){var S=+_[_.length-1];if(/,/.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `,` special characters are incompatible");if(/\//.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `/` special characters are incompatible");if(/-/.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `-` special characters are incompatible");if(_.length>2||Number.isNaN(S)||S<1||S>5)throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return o.nthDayOfWeek=S,_[0]}return w}}return s(t,n)};Be.fieldsToExpression=function(t,n){function r(f,m,g){if(!m)throw new Error("Validation error, Field "+f+" is missing");if(m.length===0)throw new Error("Validation error, Field "+f+" contains no values");for(var x=0,b=m.length;x<b;x++){var y=m[x];if(!Be._isValidConstraintChar(g,y)&&(typeof y!="number"||Number.isNaN(y)||y<g.min||y>g.max))throw new Error("Constraint error, got value "+y+" expected range "+g.min+"-"+g.max)}}for(var s={},i=0,o=Be.map.length;i<o;++i){var l=Be.map[i],c=t[l];r(l,c,Be.constraints[i]);for(var u=[],d=-1;++d<c.length;)u[d]=c[d];if(c=u.sort(Be._sortCompareFn).filter(function(f,m,g){return!m||f!==g[m-1]}),c.length!==u.length)throw new Error("Validation error, Field "+l+" contains duplicate values");s[l]=c}var h=Be._handleMaxDaysInMonth(s);return s.dayOfMonth=h||s.dayOfMonth,new Be(s,n||{})};var I$e=Be;const T$e={},M$e=Object.freeze(Object.defineProperty({__proto__:null,default:T$e},Symbol.toStringTag,{value:"Module"})),R$e=Dne(M$e);var k1=I$e;function fc(){}fc._parseEntry=function(t){var n=t.split(" ");if(n.length===6)return{interval:k1.parse(t)};if(n.length>6)return{interval:k1.parse(n.slice(0,6).join(" ")),command:n.slice(6,n.length)};throw new Error("Invalid entry: "+t)};fc.parseExpression=function(t,n){return k1.parse(t,n)};fc.fieldsToExpression=function(t,n){return k1.fieldsToExpression(t,n)};fc.parseString=function(t){for(var n=t.split(`
916
916
  `),r={variables:{},expressions:[],errors:{}},s=0,i=n.length;s<i;s++){var o=n[s],l=null,c=o.trim();if(c.length>0){if(c.match(/^#/))continue;if(l=c.match(/^(.*)=(.*)$/))r.variables[l[1]]=l[2];else{var u=null;try{u=fc._parseEntry("0 "+c),r.expressions.push(u.interval)}catch(d){r.errors[c]=d}}}}return r};fc.parseFile=function(t,n){R$e.readFile(t,function(r,s){if(r){n(r);return}return n(null,fc.parseString(s.toString()))})};var P$e=fc;const D$e=pn(P$e),O$e=5*6e4;function A$e(e,t){if(!(!e||e.length===0)){for(const n of e)if(n.startedAtMs>=t&&n.startedAtMs<t+O$e)return n}}const $$e=30*6e4,L$e=30*24*36e5;function B$e(e,t,n,r=new Date){const s=r.getTime(),i=s-L$e,o=[];for(const l of e){const c=n(l.agentId);switch(l.schedule.kind){case"at":{const u=new Date(l.schedule.at);if(Number.isNaN(u.getTime())||u<t.from||u>=t.to||u.getTime()<i)break;o.push(OC(l,c,u,"once",s));break}case"cron":{const u=D$e.parseExpression(l.schedule.expr,{currentDate:t.from,endDate:t.to,tz:l.schedule.tz});for(;u.hasNext();){const d=u.next().toDate();d.getTime()<i||o.push(OC(l,c,d,d.toISOString(),s))}break}case"every":{const u=l.schedule.everyMs;if(u<=0)break;const d=t.from.getTime(),h=t.to.getTime(),f=l.schedule.anchorMs??d;let m;if(f>=d)m=f;else{const g=Math.ceil((d-f)/u);m=f+g*u}for(;m<h;)m>=i&&o.push(OC(l,c,new Date(m),new Date(m).toISOString(),s)),m+=u;break}}}return o}function OC(e,t,n,r,s){const i=n.getTime(),o=i<=s,l=o?A$e(e.runs,i):void 0;return{id:`${e.id}:${r}`,shiftId:e.id,agentId:e.agentId,title:t.name,start:n,end:new Date(i+$$e),resourceColor:t.color,note:e.note,isPast:o,...l!=null&&l.sessionId?{sessionId:l.sessionId}:{}}}var KZ={exports:{}},F$e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",z$e=F$e,H$e=z$e;function GZ(){}function YZ(){}YZ.resetWarningCache=GZ;var U$e=function(){function e(r,s,i,o,l,c){if(c!==H$e){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:YZ,resetWarningCache:GZ};return n.PropTypes=n,n};KZ.exports=U$e();var W$e=KZ.exports;const je=pn(W$e);var V$e=function(e,t,n,r,s,i,o,l){if(!e){var c;if(t===void 0)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,s,i,o,l],d=0;c=new Error(t.replace(/%s/g,function(){return u[d++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}},q$e=V$e;const Bg=pn(q$e);var K$e=function(){};function G$e(e,t){var n={};return Object.keys(e).forEach(function(r){n[zy(r)]=K$e}),n}function GL(e,t){return e[t]!==void 0}function zy(e){return"default"+e.charAt(0).toUpperCase()+e.substr(1)}function Y$e(e){return!!e&&(typeof e!="function"||e.prototype&&e.prototype.isReactComponent)}function X$e(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,vb(e,t)}function XZ(){var e=this.constructor.getDerivedStateFromProps(this.props,this.state);e!=null&&this.setState(e)}function ZZ(e){function t(n){var r=this.constructor.getDerivedStateFromProps(e,n);return r??null}this.setState(t.bind(this))}function QZ(e,t){try{var n=this.props,r=this.state;this.props=e,this.state=t,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,r)}finally{this.props=n,this.state=r}}XZ.__suppressDeprecationWarning=!0;ZZ.__suppressDeprecationWarning=!0;QZ.__suppressDeprecationWarning=!0;function Z$e(e){var t=e.prototype;if(!t||!t.isReactComponent)throw new Error("Can only polyfill class components");if(typeof e.getDerivedStateFromProps!="function"&&typeof t.getSnapshotBeforeUpdate!="function")return e;var n=null,r=null,s=null;if(typeof t.componentWillMount=="function"?n="componentWillMount":typeof t.UNSAFE_componentWillMount=="function"&&(n="UNSAFE_componentWillMount"),typeof t.componentWillReceiveProps=="function"?r="componentWillReceiveProps":typeof t.UNSAFE_componentWillReceiveProps=="function"&&(r="UNSAFE_componentWillReceiveProps"),typeof t.componentWillUpdate=="function"?s="componentWillUpdate":typeof t.UNSAFE_componentWillUpdate=="function"&&(s="UNSAFE_componentWillUpdate"),n!==null||r!==null||s!==null){var i=e.displayName||e.name,o=typeof e.getDerivedStateFromProps=="function"?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error(`Unsafe legacy lifecycles will not be called for components using new component APIs.
917
917
 
918
918
  `+i+" uses "+o+" but also contains the following legacy lifecycles:"+(n!==null?`