@patodo/localapp 0.1.1 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.localapp-artifact.json +160 -130
- package/README.md +14 -3
- package/bin/localapp.mjs +699 -192
- package/package.json +1 -1
- package/runtime/native/adapter-manifest.json +10 -10
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +57 -5
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +2 -2
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +57 -5
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +2 -2
- package/runtime/native/linux-x64/localapp-native-ipc-client.mjs +57 -5
- package/runtime/native/linux-x64/localapp-notifications +0 -0
- package/runtime/native/win32-x64/localapp-native-ipc-client.mjs +57 -5
- package/runtime/native/win32-x64/localapp-native.exe +0 -0
- package/runtime/server/.localapp-server-runtime.json +62 -62
- package/runtime/server/bin/server-cli.cjs +14 -2
- package/runtime/server/bin/worker.cjs +12706 -3168
- package/runtime/server/web/404.html +1 -1
- package/runtime/server/web/_next/static/chunks/{416-53d48ad9442eb7b2.js → 416-c15a156fd32eefc3.js} +1 -1
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/page-3252f21360e42fa1.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/{layout-5557bc90d966fded.js → layout-2231382739460b63.js} +1 -1
- package/runtime/server/web/_next/static/css/b8973d29c0d3fd9b.css +3 -0
- package/runtime/server/web/inbox.html +1 -1
- package/runtime/server/web/inbox.txt +7 -7
- package/runtime/server/web/index.html +1 -1
- package/runtime/server/web/index.txt +8 -8
- package/runtime/server/web/my/analytics.html +1 -1
- package/runtime/server/web/my/analytics.txt +7 -7
- package/runtime/server/web/my/apps/placeholder/settings.html +1 -1
- package/runtime/server/web/my/apps/placeholder/settings.txt +7 -7
- package/runtime/server/web/my/apps.html +1 -1
- package/runtime/server/web/my/apps.txt +7 -7
- package/runtime/server/web/my/dashboard.html +1 -1
- package/runtime/server/web/my/dashboard.txt +7 -7
- package/runtime/server/web/my/device-actions.html +1 -1
- package/runtime/server/web/my/device-actions.txt +7 -7
- package/runtime/server/web/my/device-notifications.html +1 -1
- package/runtime/server/web/my/device-notifications.txt +7 -7
- package/runtime/server/web/my/favorites.html +1 -1
- package/runtime/server/web/my/favorites.txt +7 -7
- package/runtime/server/web/my/groups.html +1 -1
- package/runtime/server/web/my/groups.txt +7 -7
- package/runtime/server/web/my/info.html +1 -1
- package/runtime/server/web/my/info.txt +7 -7
- package/runtime/server/web/my/keys.html +1 -1
- package/runtime/server/web/my/keys.txt +7 -7
- package/runtime/server/web/my/orgs.html +1 -1
- package/runtime/server/web/my/orgs.txt +7 -7
- package/runtime/server/web/my/pages.html +1 -1
- package/runtime/server/web/my/pages.txt +7 -7
- package/runtime/server/web/my/peers.html +1 -1
- package/runtime/server/web/my/peers.txt +7 -7
- package/runtime/server/web/my/recent.html +1 -1
- package/runtime/server/web/my/recent.txt +7 -7
- package/runtime/server/web/my/settings.html +1 -1
- package/runtime/server/web/my/settings.txt +7 -7
- package/runtime/server/web/my/studio.html +1 -1
- package/runtime/server/web/my/studio.txt +7 -7
- package/runtime/server/web/my/subscriptions.html +1 -1
- package/runtime/server/web/my/subscriptions.txt +7 -7
- package/runtime/server/web/my/system.html +1 -1
- package/runtime/server/web/my/system.txt +7 -7
- package/runtime/server/web/my/tasks.html +1 -1
- package/runtime/server/web/my/tasks.txt +7 -7
- package/runtime/server/web/my/users.html +1 -1
- package/runtime/server/web/my/users.txt +7 -7
- package/runtime/server/web/my.html +1 -1
- package/runtime/server/web/my.txt +7 -7
- package/runtime/server/web/platform-shell/placeholder/placeholder.html +1 -1
- package/runtime/server/web/platform-shell/placeholder/placeholder.txt +8 -8
- package/runtime/server/web/platform-shell-preview.html +1 -1
- package/runtime/server/web/platform-shell-preview.txt +8 -8
- package/runtime/server/web/setup.html +1 -1
- package/runtime/server/web/setup.txt +7 -7
- package/template/.claude/skills/localapp-collaboration/SKILL.md +92 -0
- package/template/AGENTS.md +6 -0
- package/template/CLAUDE.md +6 -0
- package/template/package.json +2 -1
- package/template/runtime/platform-capabilities.json +13 -1
- package/template/runtime/sdk/crdt/package.json +39 -0
- package/template/runtime/sdk/crdt/src/index.ts +440 -0
- package/template/runtime/sdk/crdt/src/react.ts +67 -0
- package/template/runtime/sdk/crdt/tests/provider.test.ts +169 -0
- package/template/runtime/sdk/crdt/tsconfig.json +18 -0
- package/template/runtime/server-core/dist/generated/platform-capabilities.d.ts +14 -2
- package/template/runtime/server-core/dist/generated/platform-capabilities.d.ts.map +1 -1
- package/template/runtime/server-core/dist/generated/platform-capabilities.js +14 -2
- package/template/runtime/server-core/dist/generated/platform-capabilities.js.map +1 -1
- package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.js +13 -2
- package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.js.map +1 -1
- package/template/runtime/version.json +1 -1
- package/template/tests/agent-guidance-template.test.ts +14 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/page-f4641be7b88818a2.js +0 -1
- package/runtime/server/web/_next/static/css/afdc0938fca59693.css +0 -3
- /package/runtime/server/web/_next/static/{q1M2-7PPyORakTt3WglxD → xssdbCxur5ZBKtk-0DVhn}/_buildManifest.js +0 -0
- /package/runtime/server/web/_next/static/{q1M2-7PPyORakTt3WglxD → xssdbCxur5ZBKtk-0DVhn}/_ssgManifest.js +0 -0
package/runtime/server/web/_next/static/chunks/{416-53d48ad9442eb7b2.js → 416-c15a156fd32eefc3.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[416],{1845:(e,t,s)=>{"use strict";s.d(t,{$:()=>c});var n=s(6472),a=s(2212),l=s(7473),r=s(2770),i=s(3906);let o=(0,r.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),c=a.forwardRef((e,t)=>{let{className:s,variant:a,size:r,asChild:c=!1,...d}=e,u=c?l.DX:"button";return(0,n.jsx)(u,{className:(0,i.cn)(o({variant:a,size:r,className:s})),ref:t,...d})});c.displayName="Button"},2611:(e,t,s)=>{"use strict";s.d(t,{p:()=>r});var n=s(6472),a=s(2212),l=s(3906);let r=a.forwardRef((e,t)=>{let{className:s,type:a,...r}=e;return(0,n.jsx)("input",{type:a,className:(0,l.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...r})});r.displayName="Input"},3906:(e,t,s)=>{"use strict";s.d(t,{cn:()=>l});var n=s(6256),a=s(2520);function l(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,a.QP)((0,n.$)(t))}},5416:(e,t,s)=>{Promise.resolve().then(s.bind(s,7155))},7155:(e,t,s)=>{"use strict";s.d(t,{PlatformShellClient:()=>nv});var n=s(6472),a=s(2949),l=s(2212),r=s(448),i=s.n(r),o=s(3855),c=s(4615),d=s(7380),u=s(8932),m=s(7110),h=s(4721),p=s(8706),f=s(555),x=s(1845),b=s(8172);function g(e){var t,s,a;let{pageName:r,user:g,favCount:v,isFavorited:y,onToggleFavorite:w,onOpenIssues:j,openIssueCount:N,aiMode:k,aiOpen:I,onToggleAI:S,bell:A,editSession:C,presenceCount:E,presenceSnapshot:_}=e,{openLogin:T}=(0,b.M)(),L=g?(g.displayName||g.name).charAt(0).toUpperCase():"?",R=null!=(t=null==C?void 0:C.busy)&&t,D=null!=(a=null!=(s=null==_?void 0:_.count)?s:E)?a:null,[z,q]=(0,l.useState)(!1),U=(0,l.useRef)(null),P=null!=N?N:null,F=null===P?"Issue":"Issue,".concat(P," 个待处理");return(0,l.useEffect)(()=>{if(!z)return;let e=e=>{var t;(null==(t=U.current)?void 0:t.contains(e.target))||q(!1)},t=e=>{"Escape"===e.key&&q(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[z]),(0,n.jsxs)("nav",{className:"flex shrink-0 flex-col bg-card",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 text-sm",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2","data-testid":"localapp-platform-nav-left",children:[(0,n.jsx)("strong",{className:"max-w-[200px] truncate",children:r}),(0,n.jsxs)(x.$,{variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-muted-foreground","aria-label":F,title:F,onClick:j,children:[(0,n.jsx)(o.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Issue"}),null!==P&&(0,n.jsx)("span",{"data-testid":"localapp-open-issue-count","data-empty":0===P,className:"min-w-4 text-center text-[11px] font-semibold tabular-nums ".concat(0===P?"text-muted-foreground/70":"text-foreground"),children:P})]}),null!==D&&(0,n.jsxs)("div",{className:"relative",ref:U,children:[(0,n.jsxs)("button",{type:"button",className:"inline-flex h-7 min-w-12 items-center justify-center gap-1 rounded-md px-2 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":"当前在线用户 ".concat(D," 人"),title:"当前在线用户 ".concat(D," 人"),"aria-expanded":z,onClick:()=>_&&q(e=>!e),children:[(0,n.jsx)(c.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:D})]}),z&&_&&(0,n.jsxs)("div",{className:"absolute left-0 top-8 z-50 w-72 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg",children:[(0,n.jsx)("div",{className:"border-b px-3 py-2 text-xs font-medium",children:"当前在线用户"}),(0,n.jsxs)("div",{className:"max-h-72 overflow-y-auto p-1",children:[_.authenticatedUsers.map(e=>{let t=e.displayName||e.name;return(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded px-2 py-2",children:[e.avatarUrl?(0,n.jsx)("img",{src:e.avatarUrl,alt:"",className:"h-7 w-7 rounded-full object-cover"}):(0,n.jsx)("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-secondary text-[11px] font-semibold",children:t.charAt(0).toUpperCase()}),(0,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("span",{className:"block truncate text-sm font-medium",children:t}),e.displayName&&(0,n.jsxs)("span",{className:"block truncate text-xs text-muted-foreground",children:["@",e.name]})]})]},e.id)}),_.anonymousCount>0&&(0,n.jsxs)("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:["匿名访客 ",_.anonymousCount," 人"]})]})]})]}),C&&(0,n.jsxs)("div",{className:"flex items-center gap-1","data-localapp-edit-session-controls":!0,children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground","aria-label":"保存",title:"保存",disabled:R||!C.canSave,onClick:()=>{C.onSave()},children:(0,n.jsx)(d.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground","aria-label":"撤销",title:"撤销",disabled:R||!C.canUndo,onClick:()=>{C.onUndo()},children:(0,n.jsx)(u.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground","aria-label":"重做",title:"重做",disabled:R||!C.canRedo,onClick:()=>{C.onRedo()},children:(0,n.jsx)(m.A,{className:"h-4 w-4"})})]}),A]}),(0,n.jsxs)("div",{className:"flex items-center gap-3","data-testid":"localapp-platform-nav-right",children:[(0,n.jsxs)(x.$,{variant:"ghost",size:"sm",className:"gap-1.5",onClick:w,title:y?"取消收藏":"收藏",children:[(0,n.jsx)(h.A,{className:"h-4 w-4 ".concat(y?"fill-amber-400 text-amber-400":"text-muted-foreground")}),(0,n.jsx)("span",{className:"text-xs",children:v})]}),k&&(0,n.jsx)(x.$,{variant:"ghost",size:"icon",className:"h-7 w-7 ".concat(I?"text-primary":"text-muted-foreground"),title:"AI 助手",onClick:S,children:(0,n.jsx)(p.A,{className:"h-4 w-4"})}),g?(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsxs)(i(),{href:"/",className:"flex items-center gap-2 hover:opacity-80",children:[g.avatarUrl?(0,n.jsx)("img",{src:g.avatarUrl,alt:"",className:"h-6 w-6 rounded-full"}):(0,n.jsx)("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary text-[10px] font-bold text-primary-foreground",children:L}),(0,n.jsx)("span",{className:"hidden sm:inline max-w-[120px] truncate",children:g.displayName||g.name})]})}):(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsxs)(x.$,{variant:"ghost",size:"sm",className:"gap-1.5",onClick:()=>T(),children:[(0,n.jsx)(f.A,{className:"h-4 w-4"}),"登录"]})})]})]}),(0,n.jsx)("div",{className:"h-[3px] bg-gradient-to-r from-indigo-500 via-fuchsia-500 to-orange-400"})]})}var v=s(6452),y=s(6777),w=s(7711),j=s(7953),N=s(31),k=s(3012),I=s(2211),S=s(1104),A=s(7097),C=s(2611),E=s(9561),_=s(8438),T=s(2078),L=s(9857),R=s(6491),D=s(7600),z=s(9233),q=s(6525),U=s(3037),P=s(2899),F=s(8556),$=s(9441),M=s(7136),K=s(4116),O=s(3142);function J(e){let{triggerLabel:t,onConfirm:s,focusAfterConfirm:a}=e,[r,i]=(0,l.useState)(!1),o="issue-discard-draft-".concat((0,l.useId)().replace(/[^A-Za-z0-9_-]/g,"")),c=(0,l.useRef)(null),d=(0,l.useRef)(null),u=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;r&&(null==(e=d.current)||e.focus())},[r]);let m=()=>{i(!1),window.requestAnimationFrame(()=>{var e;return null==(e=c.current)?void 0:e.focus()})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x.$,{ref:c,type:"button",variant:"ghost",size:"sm",className:"h-11 shrink-0 sm:h-8","aria-expanded":r,onClick:()=>i(!0),children:t}),r&&(0,n.jsxs)("div",{role:"alertdialog","aria-label":"丢弃草稿确认","aria-describedby":o,onKeyDown:e=>{var t,s;if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),m();return}"Tab"===e.key&&(e.shiftKey&&document.activeElement===d.current?(e.preventDefault(),null==(t=u.current)||t.focus()):e.shiftKey||document.activeElement!==u.current||(e.preventDefault(),null==(s=d.current)||s.focus()))},className:"basis-full rounded-md border border-destructive/30 bg-destructive/5 p-3",children:[(0,n.jsx)("p",{className:"font-medium",children:"丢弃草稿?"}),(0,n.jsx)("p",{id:o,className:"mt-1 text-sm text-muted-foreground",children:"未提交内容和已上传附件将被清除且无法恢复。"}),(0,n.jsxs)("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:d,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",onClick:m,children:"保留草稿"}),(0,n.jsx)(x.$,{ref:u,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",onClick:()=>{i(!1),s(),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>null==a?void 0:a()))},children:"确认丢弃"})]})]})]})}var B=s(8323),H=s(2591),W=s(4039),V=s(4316),X=s(249),Q=s(4924);let Z=/^(?:[ \t]*(?:[-+*]|\d+[.)])[ \t]+)\[([ xX])\]/;function G(e){if(!e.includes("["))return[];let t=(0,X.l)().use(Q.A).use(W.A).parse(e),s=[],n=t=>{var a,l,r,i,o;if("listItem"===t.type&&"boolean"==typeof t.checked){let n=null==(l=t.position)||null==(a=l.start)?void 0:a.offset,o=null==(i=t.position)||null==(r=i.end)?void 0:r.offset;if("number"==typeof n&&"number"==typeof o){let a=Z.exec(e.slice(n,o));if(a){let l=e.slice(n+a[0].length,o).split(/\r?\n/,1)[0].trimEnd().replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/<[^>]+>/g,"").replace(/[`*_~]+/g,"").replace(/\s+/g," ").trim();s.push({index:s.length,checked:t.checked,markerOffset:n+a[0].length-2,title:l,convertible:!t.checked&&!!l&&!/^#\d+$/.test(l)})}}}for(let e of null!=(o=t.children)?o:[])n(e)};return n(t),s}function Y(e,t,s){let n=G(e)[t];if(!n)throw Error("Task not found");if(n.checked===s)throw Error("Task state changed");return"".concat(e.slice(0,n.markerOffset)).concat(s?"x":" ").concat(e.slice(n.markerOffset+1))}let ee="#localapp-issue-",et=/(^|[^\\\w])#([1-9]\d*)\b/g;function es(){return(e,t)=>{var s;return function e(t,s){!t.children||["link","linkReference","code","inlineCode","html"].includes(t.type)||(t.children=t.children.flatMap(t=>"text"===t.type?function(e,t){var s,n,a,l,r,i;let o=null!=(s=e.value)?s:"",c=[],d=0;for(let s of o.matchAll(et)){let u=s[1],m=s[2],h=(null!=(i=s.index)?i:0)+u.length,p=null==(a=e.position)||null==(n=a.start)?void 0:n.offset,f=null==(r=e.position)||null==(l=r.end)?void 0:l.offset;if("number"==typeof p&&"number"==typeof f){let e=t.slice(p,f),s=e.indexOf("#".concat(m));if(s>0&&"\\"===e[s-1])continue}h>d&&c.push({type:"text",value:o.slice(d,h)}),c.push({type:"link",url:"".concat(ee).concat(m),children:[{type:"text",value:"#".concat(m)}]}),d=h+m.length+1}return 0===d?[e]:(d<o.length&&c.push({type:"text",value:o.slice(d)}),c)}(t,s):(e(t,s),[t])))}(e,String(null!=(s=t.value)?s:""))}}function en(){return e=>{let t=0,s=e=>{var n,a;for(let l of("element"===e.type&&"input"===e.tagName&&(null==(n=e.properties)?void 0:n.type)==="checkbox"&&(e.properties.dataIssueTaskIndex=t++),null!=(a=e.children)?a:[]))s(l)};s(e)}}function ea(e){let{children:t,className:s="",tasksDisabled:a=!1,onToggleTask:l,onConvertTask:r,getIssueReferenceHref:i,onOpenIssueReference:o}=e,c=G(t),d=c.filter(e=>e.checked).length;return(0,n.jsxs)("div",{className:"min-w-0 ".concat(s),children:[c.length>0&&(0,n.jsxs)("div",{role:"progressbar","aria-label":"任务进度","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":c.length,"aria-valuetext":"已完成 ".concat(d," / ").concat(c.length," 个任务"),className:"mb-3 flex items-center gap-3 text-xs text-muted-foreground",children:[(0,n.jsxs)("span",{className:"shrink-0 font-medium",children:["任务 ",d," / ",c.length]}),(0,n.jsx)("span",{className:"h-2 min-w-20 flex-1 overflow-hidden rounded-full bg-muted",children:(0,n.jsx)("span",{className:"block h-full bg-emerald-600 transition-[width] motion-reduce:transition-none",style:{width:"".concat(Math.round(d/c.length*100),"%")}})})]}),(0,n.jsx)("div",{className:"prose prose-sm min-w-0 max-w-none overflow-hidden break-words text-sm leading-6 [overflow-wrap:anywhere] dark:prose-invert",children:(0,n.jsx)(H.oz,{remarkPlugins:[W.A,es],rehypePlugins:[en],components:{pre:e=>{let{children:t,...s}=e;return(0,n.jsx)("pre",{...s,className:"max-w-full overflow-x-auto",children:t})},code:e=>{let{children:t,...s}=e;return(0,n.jsx)("code",{...s,className:"break-normal [overflow-wrap:normal]",children:t})},a:e=>{let{children:t,href:s,...a}=e,l=function(e){if(!(null==e?void 0:e.startsWith(ee)))return null;let t=Number(e.slice(ee.length));return Number.isSafeInteger(t)&&t>0?t:null}(s),r=null!==l&&i?i(l):s;return(0,n.jsx)("a",{...a,href:r,tabIndex:null!==l?-1:void 0,"data-localapp-issue-reference":null!=l?l:void 0,className:"break-all",onClick:null!==l&&o?e=>{0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),o(l))}:void 0,children:t})},img:e=>{let{...t}=e;return(0,n.jsx)("img",{...t,className:"h-auto max-w-full"})},input:e=>{let{type:t,checked:s,...i}=e;if("checkbox"!==t)return(0,n.jsx)("input",{type:t,...i});let o=i["data-issue-task-index"],d="number"==typeof o&&Number.isSafeInteger(o)&&o>=0?o:null,u=null===d?null:c[d];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("label",{className:"-my-2 mr-1 inline-flex h-11 w-11 cursor-pointer items-center justify-center align-middle sm:-my-0 sm:h-6 sm:w-6",children:(0,n.jsx)("input",{...i,type:"checkbox",className:"h-4 w-4",checked:!!s,disabled:null===d||!l||a,"aria-label":null===d?"任务,".concat(s?"已完成":"未完成"):"任务 ".concat(d+1,",").concat(s?"已完成":"未完成"),onChange:e=>{null!==d&&(null==l||l(d,e.currentTarget.checked))}})}),(null==u?void 0:u.convertible)&&r&&(0,n.jsx)("button",{type:"button",title:"转换为 Sub-issue","aria-label":"将任务 ".concat(d+1," 转换为 Sub-issue"),disabled:a,className:"-my-2 mr-1 inline-flex h-11 w-11 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 sm:-my-0 sm:h-6 sm:w-6",onClick:e=>r(d,u.title,e.currentTarget),children:(0,n.jsx)(V.A,{className:"h-4 w-4","aria-hidden":"true"})})]})}},children:t})})]})}let el=new Set(["heading","quote","bullet-list","ordered-list","task-list"]),er=/^\s*(?:#{1,6}\s+|>\s?|[-*+]\s+(?:\[[ xX]\]\s+)?|\d+[.)]\s+)/,ei={task:"任务",bug:"缺陷",feature:"功能"},eo={resolved:"已解决",off_topic:"偏离主题",too_heated:"讨论过热",spam:"垃圾信息"},ec={abuse:"滥用内容","off-topic":"偏离主题",outdated:"内容过时",resolved:"问题已解决",duplicate:"重复内容",spam:"垃圾内容"},ed=["+1","-1","laugh","hooray","confused","heart","rocket","eyes"];function eu(e){return["image/png","image/jpeg","image/gif","image/webp"].includes(e.toLowerCase())}function em(e,t){let s=new URLSearchParams({pagePath:e});return"/api/issues/attachments/".concat(encodeURIComponent(t),"?").concat(s.toString())}function eh(e){return e<1024?"".concat(e," B"):e<1048576?"".concat(Math.ceil(e/1024)," KB"):"".concat((e/1048576).toFixed(1)," MB")}let ep={q:"",searchIn:"",status:"open",label:"",issueType:"",author:"",participant:"",assignee:"",milestone:"",reason:"",subscribed:!1,mentioned:!1,locked:"",sort:"activity",direction:"desc",limit:25,offset:0};function ef(e){return{...e.q?{q:e.q.trim()}:{},...e.searchIn?{searchIn:e.searchIn.split(",")}:{},...e.status!==ep.status?{status:e.status}:{},...e.label?{label:e.label}:{},...e.issueType?{issueType:e.issueType}:{},...e.author?{author:e.author}:{},...e.participant?{participant:e.participant}:{},...e.assignee?{assignee:e.assignee}:{},...e.milestone?{milestone:e.milestone}:{},..."closed"===e.status&&e.reason?{reason:e.reason}:{},...e.subscribed?{subscribed:!0}:{},...e.mentioned?{mentioned:!0}:{},...e.locked?{locked:e.locked}:{},...e.sort!==ep.sort?{sort:e.sort}:{},...e.direction!==ep.direction?{direction:e.direction}:{},...e.limit!==ep.limit?{limit:e.limit}:{},offset:0}}function ex(e){var t,s,n;return{...ep,...e,searchIn:null!=(s=null==(t=e.searchIn)?void 0:t.join(","))?s:"",reason:"closed"===e.status&&null!=(n=e.reason)?n:"",offset:0}}function eb(e,t){return JSON.stringify(ef(ex(e)))===JSON.stringify(ef(t))}let eg={q:"localappIssueQ",searchIn:"localappIssueIn",status:"localappIssueStatus",label:"localappIssueLabel",issueType:"localappIssueType",author:"localappIssueAuthor",participant:"localappIssueParticipant",assignee:"localappIssueAssignee",milestone:"localappIssueMilestone",reason:"localappIssueReason",subscribed:"localappIssueSubscribed",mentioned:"localappIssueMentioned",locked:"localappIssueLocked",sort:"localappIssueSort",direction:"localappIssueDirection",offset:"localappIssueOffset"},ev=["activity","created","updated","comments"],ey=new Set(["title","body","comments","title,body","title,comments","body,comments","title,body,comments"]);function ew(e,t,s){var n,a;let l=null!=(a=null==(n=e.searchParams.get(t))?void 0:n.trim())?a:"";return l.length<=s?l:""}function ej(e){var t;let s=e.searchParams.get(eg.status),n=e.searchParams.get(eg.sort),a=e.searchParams.get(eg.direction),l=e.searchParams.get(eg.offset),r=e.searchParams.get(eg.issueType),i=null!==l&&/^\d+$/.test(l)?Number(l):0;return{...ep,q:ew(e,eg.q,200),searchIn:ey.has(null!=(t=e.searchParams.get(eg.searchIn))?t:"")?e.searchParams.get(eg.searchIn):"",status:"closed"===s?"closed":"open",label:ew(e,eg.label,100),issueType:"task"===r||"bug"===r||"feature"===r?r:"",author:ew(e,eg.author,100),participant:ew(e,eg.participant,100),assignee:ew(e,eg.assignee,100),milestone:ew(e,eg.milestone,100),reason:"closed"===s&&"not_planned"===e.searchParams.get(eg.reason)?"not_planned":"closed"===s&&"completed"===e.searchParams.get(eg.reason)?"completed":"",subscribed:"1"===e.searchParams.get(eg.subscribed),mentioned:"1"===e.searchParams.get(eg.mentioned),locked:"locked"===e.searchParams.get(eg.locked)?"locked":"unlocked"===e.searchParams.get(eg.locked)?"unlocked":"",sort:ev.includes(n)?n:ep.sort,direction:"asc"===a?"asc":"desc",offset:Number.isSafeInteger(i)&&i>=0?i:0}}let eN=["q","searchIn","author","participant","assignee","milestone"],ek="Issue 服务暂不可用";async function eI(e,t){try{return await e(t)}catch(n){var s;if((null==t?void 0:t.aborted)||n instanceof Error&&"AbortError"===n.name)throw n;return await ((null==t?void 0:t.aborted)?Promise.reject(null!=(s=t.reason)?s:new DOMException("Aborted","AbortError")):new Promise((e,s)=>{let n=setTimeout(function(){null==t||t.removeEventListener("abort",a),e()},300);function a(){var e;clearTimeout(n),s(null!=(e=null==t?void 0:t.reason)?e:new DOMException("Aborted","AbortError"))}null==t||t.addEventListener("abort",a,{once:!0})})),e(t)}}async function eS(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8e3,n=new AbortController,a=!1,l=()=>n.abort(null==t?void 0:t.reason);(null==t?void 0:t.aborted)?l():null==t||t.addEventListener("abort",l,{once:!0});let r=setTimeout(()=>{a=!0,n.abort(new DOMException("Issue list request timed out","TimeoutError"))},s);try{return await e(n.signal)}catch(e){if(a)throw Error(ek);throw e}finally{clearTimeout(r),null==t||t.removeEventListener("abort",l)}}class eA extends Error{constructor(){super("内容已被其他用户更新,当前草稿已保留"),this.name="IssueContentConflictError"}}async function eC(e){var t;let s;if(!(null==(t=e.headers.get("content-type"))?void 0:t.toLowerCase().includes("application/json")))throw Error(ek);try{s=await e.json()}catch(e){throw Error(ek)}if(!e.ok||!s.success){if(409===e.status&&"issue_content_conflict"===s.code)throw new eA;throw Error(s.error||ek)}return{data:s.data,pinned:s.pinned,meta:s.meta}}async function eE(e){return(await eC(e)).data}async function e_(e){var t;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return eS(async t=>eE(await fetch(e,{...s,signal:t})),null!=(t=s.signal)?t:void 0)}function eT(e){return new URLSearchParams({pagePath:e}).toString()}async function eL(e){try{return await eS(async e=>{var t;let s,n=await fetch("/api/users",{credentials:"include",signal:e});if(!n.ok||!(null==(t=n.headers.get("content-type"))?void 0:t.toLowerCase().includes("application/json")))throw Error("负责人目录加载失败");try{s=await n.json()}catch(e){throw Error("负责人目录加载失败")}if(!s.success||!Array.isArray(s.data))throw Error("负责人目录加载失败");return s.data.filter(e=>!!e&&"object"==typeof e&&"string"==typeof e.id&&(null===e.displayName||"string"==typeof e.displayName)&&(void 0===e.name||"string"==typeof e.name)&&(null===e.avatarUrl||"string"==typeof e.avatarUrl))},e)}catch(t){if(null==e?void 0:e.aborted)throw t;throw Error("负责人目录加载失败")}}async function eR(e,t){return e_("/api/issues/config?".concat(eT(e)),{credentials:"include",signal:t}).then(e=>Array.isArray(e.templates)?e.templates:[])}async function eD(e,t){let s=await e_("/api/issues/views?".concat(eT(e)),{credentials:"include",signal:t});return Array.isArray(s)?s.filter(e=>!!e&&"object"==typeof e&&Number.isSafeInteger(e.id)&&"string"==typeof e.user_id&&"string"==typeof e.name&&!!e.name.trim()&&"string"==typeof e.description&&!!e.query&&"object"==typeof e.query&&0===e.query.offset&&"string"==typeof e.created_at&&"string"==typeof e.updated_at):[]}async function ez(e,t,s){return e_("/api/issues/".concat(t,"/duplicate/").concat(s),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eq(e,t,s,n){return e_("/api/issues/views",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,name:t,description:s,query:ef(n)})})}async function eU(e,t,s){return e_("/api/issues/views/".concat(t),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...s,...s.query?{query:ef(s.query)}:{}})})}async function eP(e,t){return e_("/api/issues/views/".concat(t,"/copy"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eF(e,t){await e_("/api/issues/views/".concat(t),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function e$(e,t,s){var n;let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8e3,l=function(e){let t=new URLSearchParams({status:e.status,sort:e.sort,direction:e.direction,limit:String(e.limit),offset:String(e.offset)});for(let s of["q","label","author","participant","assignee","milestone","reason"])e[s]&&t.set(s,e[s]);return e.issueType&&t.set("type",e.issueType),e.q&&e.searchIn&&t.set("in",e.searchIn),e.locked&&t.set("locked","locked"===e.locked?"true":"false"),e.subscribed&&t.set("subscribed","true"),e.mentioned&&t.set("mentioned","true"),t}(t);l.set("pagePath",e);let r=await eS(async e=>eC(await fetch("/api/issues?".concat(l.toString()),{credentials:"include",signal:e})),s,a);return{data:r.data,pinned:Array.isArray(r.pinned)?r.pinned:[],meta:null!=(n=r.meta)?n:{total:r.data.length,open:"open"===t.status?r.data.length:0,closed:"closed"===t.status?r.data.length:0,limit:t.limit,offset:t.offset}}}async function eM(e,t,s,n){let a=new URLSearchParams({pagePath:e,title:t,body:s});return eE(await fetch("/api/issues/potential-duplicates?".concat(a),{credentials:"include",signal:n}))}async function eK(e,t,s){return e_("/api/issues/".concat(t,"/pin"),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,pinned:s})})}async function eO(e,t,s){return e_("/api/issues/".concat(t,"/sub-issues/").concat(s),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eJ(e,t,s){return e_("/api/issues/".concat(t,"/sub-issues/").concat(s),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eB(e,t,s,n){return e_("/api/issues/".concat(t,"/sub-issues/priority"),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,childIssueId:s,afterIssueId:n})})}async function eH(e,t,s,n,a){return e_("/api/issues/".concat(t,"/tasks/").concat(s,"/convert"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,expectedUpdatedAt:n,title:a})})}async function eW(e,t,s){return e_("/api/issues/".concat(t,"/dependencies/blocked-by/").concat(s),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eV(e,t,s){return e_("/api/issues/".concat(t,"/dependencies/blocked-by/").concat(s),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eX(e,t,s){return eE(await fetch("/api/issues/".concat(t,"/sub-issues?").concat(eT(e)),{credentials:"include",signal:s}))}async function eQ(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8e3;return eS(async s=>eE(await fetch("/api/issues/".concat(t,"?").concat(eT(e)),{credentials:"include",signal:s})),void 0,s)}async function eZ(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8e3;return eS(async s=>eE(await fetch("/api/issues/by-number/".concat(t,"?").concat(eT(e)),{credentials:"include",signal:s})),void 0,s)}async function eG(e,t,s){let n=void 0===s?"/api/issues/".concat(t,"/history"):"/api/issues/".concat(t,"/comments/").concat(s,"/history");return e_("".concat(n,"?").concat(eT(e)),{credentials:"include"})}async function eY(e,t){return(await e_("/api/issues/labels?".concat(eT(e)),{credentials:"include",signal:t})).filter(e=>!!e&&"object"==typeof e&&"string"==typeof e.id&&"string"==typeof e.name&&"string"==typeof e.color)}async function e0(e,t){await e_("/api/issues/labels/".concat(encodeURIComponent(t),"?").concat(eT(e)),{method:"DELETE",credentials:"include"})}function e1(e,t){return e_("/api/issues/milestones?".concat(eT(e)),{credentials:"include",signal:t})}async function e2(e,t){await e_("/api/issues/milestones/".concat(t,"?").concat(eT(e)),{method:"DELETE",credentials:"include"})}async function e4(e,t,s,n){return e_("/api/issues/".concat(t,"/").concat(s),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...n})})}function e3(e,t,s){return e4(e,t,"labels",{labelIds:s})}function e5(e,t,s){return e4(e,t,"assignees",{userIds:s})}function e8(e,t,s){return e4(e,t,"milestone",{milestoneId:s})}async function e6(e,t,s,n){return e_("/api/issues/".concat(t,"/lock"),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,locked:s,...s&&n?{reason:n}:{}})})}async function e7(e,t,s,n,a){return e_("/api/issues/".concat(t,"/reactions"),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...void 0===a?{}:{commentId:a},content:s,reacted:n})})}async function e9(e){return e_("/api/issues",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function te(e,t,s){return e_("/api/issues/".concat(t),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...s})})}async function tt(e,t,s){return e_("/api/issues/".concat(t,"/comments"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...s})})}async function ts(e,t,s,n,a,l,r,i){return e_("/api/issues/".concat(t,"/comments/").concat(s),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,body:n,...a?{expectedUpdatedAt:a}:{},...l?{draftId:l,attachmentIds:null!=r?r:[],removedAttachmentIds:null!=i?i:[]}:{}})})}async function tn(e,t,s){return e_("/api/issues/".concat(t,"/comments/").concat(s,"?").concat(eT(e)),{method:"DELETE",credentials:"include"})}async function ta(e,t,s,n){return e_("/api/issues/".concat(t,"/comments/").concat(s,"/pin"),{method:n?"PUT":"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function tl(e,t,s,n){return e_("/api/issues/".concat(t,"/comments/").concat(s,"/minimize"),{method:null===n?"DELETE":"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...null===n?{}:{reason:n}})})}async function tr(e,t){return e_("/api/issues/".concat(t,"?").concat(eT(e)),{method:"DELETE",credentials:"include"})}async function ti(e,t,s){let n=new FormData;return n.set("pagePath",e),n.set("draftId",t),n.set("file",s),e_("/api/issues/attachments",{method:"POST",credentials:"include",body:n})}let to=/(?:^|[^A-Za-z0-9_.+@/-])@([A-Za-z0-9_-]{0,64})$/;var tc=s(8669),td=s(7272);async function tu(e,t){let s=await fetch(e,{credentials:"include",...t,headers:{...(null==t?void 0:t.body)?{"Content-Type":"application/json"}:{},...null==t?void 0:t.headers}}),n=await s.json().catch(()=>null);if(!s.ok)throw Error((null==n?void 0:n.error)||"保存回复请求失败 (".concat(s.status,")"));return null==n?void 0:n.data}let tm=(0,l.forwardRef)(function(e,t){let{tabIndex:s,onFocus:a,onKeyDown:r,onInsert:i}=e,[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)([]),[m,h]=(0,l.useState)(""),[p,f]=(0,l.useState)(!1),[b,g]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),[w,k]=(0,l.useState)(null),[I,S]=(0,l.useState)(""),[A,E]=(0,l.useState)(""),[_,T]=(0,l.useState)(!1),[L,R]=(0,l.useState)(0),D=(0,l.useRef)(null),z=(0,l.useRef)(null),q=d.filter(e=>e.title.toLocaleLowerCase().includes(m.trim().toLocaleLowerCase())),U=async()=>{f(!0),g(null);try{let e=await tu("/api/issues/saved-replies");u(Array.isArray(e)?e.filter(e=>!!(e&&"object"==typeof e&&Number.isSafeInteger(e.id)&&"string"==typeof e.title&&"string"==typeof e.body)):[])}catch(e){g(e instanceof Error?e.message:"加载保存回复失败")}finally{f(!1)}},P=()=>{c(!1),y(null),k(null),g(null),requestAnimationFrame(()=>{var e;return null==(e=z.current)?void 0:e.focus()})},F=e=>{y(e),k(null),S("new"===e?"":e.title),E("new"===e?"":e.body),g(null)},$=async()=>{T(!0),g(null);try{let e=await tu("new"===v?"/api/issues/saved-replies":"/api/issues/saved-replies/".concat(null==v?void 0:v.id),{method:"new"===v?"POST":"PATCH",body:JSON.stringify({title:I,body:A})});u(t=>"new"===v?[e,...t]:t.map(t=>t.id===e.id?e:t)),y(null)}catch(e){g(e instanceof Error?e.message:"保存回复失败")}finally{T(!1)}},M=async()=>{if(w){T(!0),g(null);try{await tu("/api/issues/saved-replies/".concat(w.id),{method:"DELETE"}),u(e=>e.filter(e=>e.id!==w.id)),k(null)}catch(e){g(e instanceof Error?e.message:"删除保存回复失败")}finally{T(!1)}}};return(0,l.useEffect)(()=>{R(0)},[m]),(0,n.jsxs)("div",{className:"relative shrink-0",children:[(0,n.jsx)(x.$,{ref:e=>{z.current=e,"function"==typeof t?t(e):t&&(t.current=e)},type:"button",variant:"ghost",size:"icon",tabIndex:s,"aria-label":"保存回复","aria-keyshortcuts":"Control+.",title:"保存回复",className:"h-11 w-11 sm:h-8 sm:w-8",onFocus:a,onKeyDown:r,onMouseDown:e=>e.preventDefault(),onClick:()=>o?P():void(c(!0),h(""),y(null),k(null),U(),requestAnimationFrame(()=>{var e;return null==(e=D.current)?void 0:e.focus()})),children:(0,n.jsx)(tc.A,{className:"h-4 w-4"})}),o&&(0,n.jsxs)("div",{role:"dialog","aria-label":"保存回复",onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),P())},className:"absolute right-0 top-full z-50 mt-1 w-[min(24rem,calc(100vw-2rem))] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-xl",children:[(0,n.jsxs)("header",{className:"flex min-h-12 items-center gap-2 border-b px-3",children:[(0,n.jsx)("strong",{className:"min-w-0 flex-1 text-sm",children:"保存回复"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"关闭保存回复",onClick:P,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),v?(0,n.jsxs)("div",{className:"space-y-3 p-3",children:[(0,n.jsx)(C.p,{autoFocus:!0,"aria-label":"回复标题",maxLength:80,value:I,onChange:e=>S(e.target.value),placeholder:"回复标题"}),(0,n.jsx)(B.T,{"aria-label":"回复正文",maxLength:2e4,rows:7,value:A,onChange:e=>E(e.target.value),placeholder:"Markdown 回复正文;使用 %cursor% 指定插入后光标"}),b&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:b}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:_,onClick:()=>{y(null),g(null)},children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:_||!I.trim()||!A.trim(),onClick:()=>void $(),children:_?"保存中...":"保存回复"})]})]}):w?(0,n.jsxs)("div",{className:"space-y-3 p-3",children:[(0,n.jsxs)("p",{className:"text-sm",children:["删除“",w.title,"”?此操作无法撤销。"]}),b&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:b}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(x.$,{autoFocus:!0,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:_,onClick:()=>k(null),children:"取消删除"}),(0,n.jsx)(x.$,{type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:_,onClick:()=>void M(),children:_?"删除中...":"确认删除"})]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex gap-2 border-b p-2",children:[(0,n.jsx)(C.p,{ref:D,type:"search",role:"searchbox","aria-label":"搜索保存回复",value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{if(q.length){if(["ArrowDown","ArrowUp","Home","End"].includes(e.key))e.preventDefault(),R("Home"===e.key?0:"End"===e.key?q.length-1:(L+("ArrowDown"===e.key?1:-1)+q.length)%q.length);else if("Enter"===e.key){var t;e.preventDefault(),i(null!=(t=q[L])?t:q[0]),P()}}},placeholder:"搜索标题"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"icon",className:"h-11 w-11 shrink-0","aria-label":"新建保存回复",onClick:()=>F("new"),children:(0,n.jsx)(j.A,{className:"h-4 w-4"})})]}),(0,n.jsx)("div",{role:"listbox","aria-label":"保存回复列表",className:"max-h-72 overflow-y-auto p-1",children:p?(0,n.jsx)("p",{role:"status",className:"px-3 py-4 text-sm text-muted-foreground",children:"正在加载保存回复..."}):b?(0,n.jsxs)("div",{className:"space-y-2 p-3",children:[(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:b}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8",onClick:()=>void U(),children:"重试"})]}):0===q.length?(0,n.jsxs)("div",{className:"space-y-2 px-3 py-4",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:d.length?"没有匹配的保存回复":"尚未创建保存回复"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8",onClick:()=>F("new"),children:"新建保存回复"})]}):q.map((e,t)=>(0,n.jsxs)("div",{className:"group flex min-h-11 items-center gap-1 rounded ".concat(t===L?"bg-accent":"hover:bg-muted"),children:[(0,n.jsx)("button",{type:"button",role:"option","aria-label":e.title,"aria-selected":t===L,className:"min-h-11 min-w-0 flex-1 truncate px-3 text-left text-sm font-medium",onMouseEnter:()=>R(t),onClick:()=>{i(e),P()},children:e.title}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"编辑 ".concat(e.title),onClick:()=>F(e),children:(0,n.jsx)(td.A,{className:"h-3.5 w-3.5"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 text-destructive sm:h-8 sm:w-8","aria-label":"删除 ".concat(e.title),onClick:()=>{k(e),g(null)},children:(0,n.jsx)(O.A,{className:"h-3.5 w-3.5"})})]},e.id))})]})]})]})}),th=new Set(Array.from("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"));function tp(e){if(!e)return"";let t=Array.from(e.file_name,e=>th.has(e)?"\\".concat(e):e).join("");return eu(e.mime_type)?".concat(e.url,")"):"[".concat(t,"](").concat(e.url,")")}function tf(e){if(!e)return"";try{var t;return null!=(t=window.sessionStorage.getItem(e))?t:""}catch(e){return""}}function tx(e,t){if(e)try{t?window.sessionStorage.setItem(e,t):window.sessionStorage.removeItem(e)}catch(e){}}function tb(e){return e?"".concat(e,":attachments"):void 0}function tg(e){let t=tb(e);if(t)try{window.sessionStorage.removeItem(t)}catch(e){}}function tv(e,t){let s=new URLSearchParams({pagePath:e,draftId:t.draft_id});fetch("/api/issues/attachments/".concat(encodeURIComponent(t.id),"?").concat(s),{method:"DELETE",credentials:"include",keepalive:!0}).catch(()=>void 0)}function ty(e,t){let s=tw(t,e);tg(t),null==s||s.attachments.forEach(t=>tv(e,t))}function tw(e,t){let s=tb(e);if(!s)return null;try{let e=window.sessionStorage.getItem(s);if(!e)return null;let n=JSON.parse(e);if("string"!=typeof n.draftId||!n.draftId||!Array.isArray(n.attachments)||n.attachments.length>20||n.attachments.some(e=>!function(e,t){if(!e||"object"!=typeof e)return!1;let s="string"==typeof e.url&&e.url.startsWith("/api/issues/attachments/")&&new URL(e.url,window.location.origin).searchParams.get("pagePath")===t;return"string"==typeof e.id&&e.id.length>0&&s&&null===e.issue_id&&null===e.comment_id&&"string"==typeof e.draft_id&&e.draft_id.length>0&&"string"==typeof e.uploader_id&&"string"==typeof e.file_name&&e.file_name.length>0&&"string"==typeof e.mime_type&&"number"==typeof e.size_bytes&&Number.isFinite(e.size_bytes)&&e.size_bytes>0&&e.size_bytes<=0x1900000&&"string"==typeof e.created_at}(e,t)||e.draft_id!==n.draftId))return window.sessionStorage.removeItem(s),null;return{draftId:n.draftId,attachments:n.attachments}}catch(e){try{window.sessionStorage.removeItem(s)}catch(e){}return null}}function tj(e,t,s){let n=tb(e);if(!n)return;let a=s.flatMap(e=>"uploaded"===e.status&&e.attachment?[e.attachment]:[]);try{a.length>0?window.sessionStorage.setItem(n,JSON.stringify({draftId:t,attachments:a})):window.sessionStorage.removeItem(n)}catch(e){}}function tN(e){var t,s;let{pagePath:a,draftId:r,initialBody:i="",textareaLabel:o,placeholder:c,submitLabel:d,status:u,closeReason:m="completed",attachments:h=!0,persistenceKey:p,preferPersistedDraft:f=!1,showRestoredDraftNotice:b=!1,restoredDraft:g=!1,autoFocus:v=d.startsWith("保存"),allowEmpty:y=!1,submitDisabled:w=!1,insertRequest:j,removeTextRequest:N,mentionCandidates:k=[],savedReplies:I=!1,onInsertRequestApplied:S,onDiscardRestoredDraft:C,onBodyChange:E,onCancel:H,onSubmit:W}=e,V=null!=c?c:o.includes("评论")?"留下评论":"详细描述问题、复现步骤或期望结果",[X]=(0,l.useState)(()=>tw(p,a)),[Q,Z]=(0,l.useState)(()=>{let e=tf(p);return f&&e?e:i||e}),[G,Y]=(0,l.useState)(()=>b&&!!(g||tf(p)||(null==X?void 0:X.attachments.length))),[ee,et]=(0,l.useState)("edit"),[es,en]=(0,l.useState)(null!=(t=null==X?void 0:X.draftId)?t:r),[ei,eo]=(0,l.useState)(()=>{var e;return null!=(e=null==X?void 0:X.attachments.map(e=>({clientId:e.id,fileName:e.file_name,fileSize:e.size_bytes,previewUrl:eu(e.mime_type)?e.url:null,attachment:e,markdown:tp(e),status:"uploaded"})))?e:[]}),[ec,ed]=(0,l.useState)(!1),[em,ep]=(0,l.useState)(!1),[ef,ex]=(0,l.useState)(null),[eb,eg]=(0,l.useState)(null),[ev,ey]=(0,l.useState)(""),[ew,ej]=(0,l.useState)(null),[eN,ek]=(0,l.useState)(!1),[eI,eS]=(0,l.useState)(Q.length),[eA,eC]=(0,l.useState)(!1),[eE,e_]=(0,l.useState)(0),eT="issue-composer-".concat((0,l.useId)().replace(/[^A-Za-z0-9_-]/g,"")),eL="".concat(eT,"-mentions"),eR="".concat(eT,"-edit-tab"),eD="".concat(eT,"-preview-tab"),ez="".concat(eT,"-panel"),eq="".concat(eT,"-attachments"),eU=(0,l.useRef)(null),eP=(0,l.useRef)(null);(0,l.useEffect)(()=>{null==E||E(Q)},[Q,E]);let eF=(0,l.useRef)(new Map),e$=(0,l.useRef)(null),eM=(0,l.useRef)([]),[eK,eO]=(0,l.useState)(0),eJ=(0,l.useRef)(null),eB=(0,l.useRef)(null),eH=(0,l.useRef)({start:Q.length,end:Q.length}),eW=(0,l.useRef)(!1),eV=(0,l.useRef)([]),eX=(0,l.useRef)(new Map),eQ=(0,l.useRef)(0),eZ=(0,l.useRef)(null),eG=(0,l.useRef)(null),eY=eA?function(e,t){let s=e.slice(0,Math.max(0,t)),n=s.match(to);return n?{start:s.length-n[1].length-1,end:t,query:n[1]}:null}(Q,eI):null,e0=null!=(s=null==eY?void 0:eY.query.toLocaleLowerCase())?s:"",e1=eY?Array.from(new Map(k.map(e=>[e.id,e])).values()).filter(e=>{var t,s;let n=(null==(t=e.displayName)?void 0:t.trim())||(null==(s=e.name)?void 0:s.trim())||e.id;return e.id.toLocaleLowerCase().includes(e0)||n.toLocaleLowerCase().includes(e0)}).slice(0,8):[];(0,l.useEffect)(()=>{eV.current=ei},[ei]),(0,l.useEffect)(()=>{ev&&(Q||ei.length>0)&&ey("")},[ei.length,Q,ev]),(0,l.useEffect)(()=>{if(!v)return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=e$.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[v]),(0,l.useEffect)(()=>{tx(p,Q)},[Q,p]),(0,l.useEffect)(()=>{tj(p,es,ei),0===ei.length&&en(r)},[es,ei,r,p]),(0,l.useEffect)(()=>{j&&eZ.current!==j.id&&(eZ.current=j.id,Z(e=>{let t=e.trim()?"".concat(e,"\n\n").concat(j.text):j.text;return eH.current={start:t.length,end:t.length},t}),et("edit"),eW.current=!0,null==S||S(j.id))},[j,S]),(0,l.useEffect)(()=>{if(!N||eG.current===N.id)return;eG.current=N.id;let e=N.url.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z(t=>t.replace(RegExp("!?\\[[^\\]]*\\]\\(".concat(e,"\\)"),"g"),"").replace(/\n{3,}/g,"\n\n").trim())},[N]),(0,l.useEffect)(()=>()=>{eX.current.clear(),eV.current.forEach(e=>{var t,s,n;(null==(t=e.previewUrl)?void 0:t.startsWith("blob:"))&&(null==(s=(n=URL).revokeObjectURL)||s.call(n,e.previewUrl))})},[]),(0,l.useEffect)(()=>{if("edit"!==ee||!eW.current)return;let e=requestAnimationFrame(()=>{let e=e$.current;e&&(eW.current=!1,e.focus(),e.setSelectionRange(eH.current.start,eH.current.end))});return()=>cancelAnimationFrame(e)},[Q,ee]),(0,l.useEffect)(()=>{e_(0)},[null==eY?void 0:eY.start,e0]);let e2=e=>{eo(t=>{let s=e(t);return eV.current=s,s})},e4=e=>{var t;let s=(null!=(t=eX.current.get(e))?t:0)+1;return eX.current.set(e,s),s},e3=async(e,t)=>{if(e.file)try{let s=await ti(a,es,e.file);if(eX.current.get(e.clientId)!==t)return void tv(a,s);let n=tp(s),l={...e,attachment:s,markdown:n,status:"uploaded",error:void 0};e2(t=>t.map(t=>t.clientId===e.clientId?l:t)),Z(e=>e.trim()?"".concat(e,"\n\n").concat(n):n)}catch(s){if(eX.current.get(e.clientId)!==t)return;e2(t=>t.map(t=>t.clientId===e.clientId?{...t,status:"error",error:s instanceof Error?s.message:"附件上传失败"}:t))}},e5=e=>{let t=Math.max(0,20-eV.current.length),s=e.slice(0,t),n=e.length-s.length;ej(n>0?"每个草稿最多添加 20 个附件;已忽略 ".concat(n," 个文件"):null),s.forEach(e=>{var t,s,n;let a=null!=(n=null==(s=globalThis.crypto)||null==(t=s.randomUUID)?void 0:t.call(s))?n:"".concat(Date.now(),"-").concat(e.name,"-").concat(Math.random()),l={clientId:a,file:e,fileName:e.name,fileSize:e.size,previewUrl:eu(e.type)&&"undefined"!=typeof URL&&URL.createObjectURL?URL.createObjectURL(e):null,status:e.size>0&&e.size<=0x1900000?"uploading":"error",error:0===e.size?"不能上传空文件":e.size>0x1900000?"单个附件不能超过 25 MiB":void 0};e2(e=>[...e,l]),"uploading"===l.status&&e3(l,e4(a))})},e8=async(e,t)=>{e.preventDefault();let s=eV.current;if(!s.some(e=>"uploaded"!==e.status)&&(y||Q.trim()||s.some(e=>"uploaded"===e.status))){eg(null),ey(""),ep(!0),ex(null!=t?t:"submit");try{await W({body:Q.trim(),attachmentIds:s.flatMap(e=>"uploaded"===e.status&&e.attachment?[e.attachment.id]:[]),draftId:es,statusAction:t,stateReason:"closed"===t?m:void 0}),ey("closed"===t?"评论并关闭成功":"open"===t?"重新打开并评论成功":"".concat(d,"成功")),eX.current.clear(),s.forEach(e=>{var t,s,n;(null==(t=e.previewUrl)?void 0:t.startsWith("blob:"))&&(null==(s=(n=URL).revokeObjectURL)||s.call(n,e.previewUrl))}),Z(""),Y(!1),tx(p,""),eV.current=[],eo([]),ej(null),ek(!1),eH.current={start:0,end:0},eS(0),eC(!1),e_(0),et("edit"),t||window.requestAnimationFrame(()=>{var e;return null==(e=e$.current)?void 0:e.focus()})}catch(e){eg(e instanceof Error?e.message:"提交失败,请重试")}finally{ep(!1),ex(null)}}},e6=ei.some(e=>"uploading"===e.status),e7=ei.some(e=>"uploaded"!==e.status),e9=ei.some(e=>"error"===e.status)?"请移除或重试上传失败的附件":null,te=!y&&!Q.trim()&&!ei.some(e=>"uploaded"===e.status),tt=em||e7||te||w,ts=0===ei.length?"没有附件":["".concat(ei.filter(e=>"uploading"===e.status).length," 个上传中"),"".concat(ei.filter(e=>"uploaded"===e.status).length," 个已就绪"),"".concat(ei.filter(e=>"error"===e.status).length," 个失败")].join(","),tn=Math.max(0,ei.filter(e=>"uploaded"===e.status).length-4),ta=0,tl=ei.filter(e=>!!eN||"uploaded"!==e.status||(ta+=1)<=4),tr=()=>{eW.current=!0},tc=()=>{if(eW.current)return;let e=e$.current;e&&(eH.current={start:e.selectionStart,end:e.selectionEnd})},td=e=>{var t,s;let n=e$.current,a=function(e,t,s,n){let a=Math.max(0,Math.min(t,e.length)),l=Math.max(a,Math.min(s,e.length));return el.has(n)?function(e,t,s,n){let a=e.lastIndexOf("\n",Math.max(0,t-1))+1,l=e.indexOf("\n",s>t?s-1:s),r=-1===l?e.length:l,i=(e.slice(a,r)||("heading"===n?"标题":"quote"===n?"引用":"task-list"===n?"任务":"列表项")).split("\n").map(e=>e.replace(er,"")).map((e,t)=>"heading"===n?"## ".concat(e):"quote"===n?"> ".concat(e):"bullet-list"===n?"- ".concat(e):"ordered-list"===n?"".concat(t+1,". ").concat(e):"- [ ] ".concat(e)).join("\n");return{value:e.slice(0,a)+i+e.slice(r),selectionStart:a,selectionEnd:a+i.length}}(e,a,l,n):function(e,t,s,n){let a=e.slice(t,s);if("link"===n){let n=a||"链接文字",l="[".concat(n,"](url)"),r=t+n.length+3;return{value:e.slice(0,t)+l+e.slice(s),selectionStart:r,selectionEnd:r+3}}let{before:l,after:r,placeholder:i}={bold:{before:"**",after:"**",placeholder:"粗体文本"},italic:{before:"_",after:"_",placeholder:"斜体文本"},code:{before:"`",after:"`",placeholder:"代码"}}[n],o=a||i,c=l+o+r,d=t+l.length;return{value:e.slice(0,t)+c+e.slice(s),selectionStart:d,selectionEnd:d+o.length}}(e,a,l,n)}(Q,null!=(t=null==n?void 0:n.selectionStart)?t:eH.current.start,null!=(s=null==n?void 0:n.selectionEnd)?s:eH.current.end,e);eH.current={start:a.selectionStart,end:a.selectionEnd},Z(a.value),et("edit"),tr()},tu=e=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;e.preventDefault();let t="ArrowLeft"===e.key||"Home"===e.key?"edit":"preview";"preview"===t&&"edit"===ee&&tc(),et(t),window.requestAnimationFrame(()=>{var e;return null==(e="edit"===t?eJ.current:eB.current)?void 0:e.focus()})},th=e=>{if(!eY)return;let t=function(e,t,s){let n="@".concat(s," ");return{value:e.slice(0,t.start)+n+e.slice(t.end),caret:t.start+n.length}}(Q,eY,e.id);Z(t.value),eS(t.caret),eH.current={start:t.caret,end:t.caret},eW.current=!0,eC(!1)},tb=[{command:"heading",label:"标题格式",icon:_.A},{command:"bold",label:"粗体",icon:T.A},{command:"italic",label:"斜体",icon:L.A},{command:"quote",label:"引用",icon:R.A},{command:"code",label:"行内代码",icon:D.A},{command:"link",label:"链接",icon:z.A},{command:"bullet-list",label:"无序列表",icon:q.A},{command:"ordered-list",label:"有序列表",icon:U.A},{command:"task-list",label:"任务列表",icon:P.A}],tg=(e,t)=>{var s;let n,a=tb.length+ +!!I;if("Home"===e.key)n=0;else if("End"===e.key)n=a-1;else if("ArrowLeft"===e.key||"ArrowUp"===e.key)n=(t-1+a)%a;else{if("ArrowRight"!==e.key&&"ArrowDown"!==e.key)return;n=(t+1)%a}e.preventDefault(),eO(n),null==(s=eM.current[n])||s.focus()};return(0,n.jsxs)("form",{onSubmit:e=>void e8(e),onKeyDown:e=>{if(!e.nativeEvent.isComposing&&229!==e.keyCode){if("Enter"===e.key&&!e.shiftKey&&(e.metaKey||e.ctrlKey)&&!e.altKey){if(e.defaultPrevented||tt)return;e.preventDefault(),e.currentTarget.requestSubmit();return}(e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&"p"===e.key.toLowerCase()&&(e.preventDefault(),"edit"===ee?(tc(),et("preview"),window.requestAnimationFrame(()=>{var e;return null==(e=eB.current)?void 0:e.focus()})):(et("edit"),tr()))}},className:"space-y-3",children:[(0,n.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true","aria-label":"提交状态",className:"sr-only",children:ev}),G&&(0,n.jsxs)("div",{role:"status",className:"flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{children:"已恢复未提交的草稿"}),(0,n.jsx)(J,{triggerLabel:"丢弃草稿",onConfirm:()=>{eV.current.forEach(e=>{e.attachment&&tv(a,e.attachment)}),Z(i),tx(p,""),tj(p,es,[]),e2(()=>[]),ej(null),ek(!1),Y(!1),et("edit"),null==C||C()},focusAfterConfirm:()=>{var e;return null==(e=e$.current)?void 0:e.focus()}})]}),(0,n.jsxs)("div",{"data-localapp-issue-editor":!0,className:"overflow-visible rounded-md border bg-background",children:[(0,n.jsxs)("div",{role:"tablist","aria-label":"Markdown 模式",className:"flex items-center gap-1 border-b bg-muted/30 px-2 py-1.5",children:[(0,n.jsx)("button",{ref:eJ,id:eR,type:"button",role:"tab","aria-selected":"edit"===ee,"aria-controls":ez,tabIndex:"edit"===ee?0:-1,onKeyDown:tu,onClick:()=>{et("edit"),tr()},className:"h-11 rounded px-3 text-xs font-medium sm:h-7 sm:px-2 ".concat("edit"===ee?"bg-background shadow-sm":"text-muted-foreground"),children:"编辑"}),(0,n.jsx)("button",{ref:eB,id:eD,type:"button",role:"tab","aria-selected":"preview"===ee,"aria-controls":ez,tabIndex:"preview"===ee?0:-1,"aria-keyshortcuts":"Meta+Shift+P Control+Shift+P",onKeyDown:tu,onClick:()=>{tc(),et("preview")},className:"h-11 rounded px-3 text-xs font-medium sm:h-7 sm:px-2 ".concat("preview"===ee?"bg-background shadow-sm":"text-muted-foreground"),children:"预览"})]}),"edit"===ee?(0,n.jsxs)("div",{id:ez,role:"tabpanel","aria-labelledby":eR,children:[(0,n.jsxs)("div",{"data-localapp-issue-toolbar":!0,role:"toolbar","aria-label":"Markdown 工具栏",className:"flex min-h-10 flex-wrap items-center gap-0.5 overflow-x-hidden border-b bg-muted/20 px-2 py-1 sm:flex-nowrap sm:overflow-x-auto",children:[tb.map((e,t)=>{let{command:s,label:a,icon:l}=e;return(0,n.jsx)(x.$,{ref:e=>{eM.current[t]=e},type:"button",variant:"ghost",size:"icon",tabIndex:eK===t?0:-1,"aria-label":a,title:a,className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8",onFocus:()=>eO(t),onKeyDown:e=>tg(e,t),onMouseDown:e=>e.preventDefault(),onClick:()=>td(s),children:(0,n.jsx)(l,{className:"h-4 w-4"})},s)}),I&&(0,n.jsx)(tm,{ref:e=>{eM.current[tb.length]=e},tabIndex:eK===tb.length?0:-1,onFocus:()=>eO(tb.length),onKeyDown:e=>tg(e,tb.length),onInsert:e=>{var t,s;let n=e$.current,a=function(e,t,s,n){let a=Math.max(0,Math.min(t,e.length)),l=Math.max(a,Math.min(s,e.length)),r=n.indexOf("%cursor%"),i=r<0?n:"".concat(n.slice(0,r)).concat(n.slice(r+8)),o="".concat(e.slice(0,a)).concat(i).concat(e.slice(l)),c=a+(r<0?i.length:r);return{body:o,selectionStart:c,selectionEnd:c}}(Q,null!=(t=null==n?void 0:n.selectionStart)?t:eH.current.start,null!=(s=null==n?void 0:n.selectionEnd)?s:eH.current.end,e.body);eH.current={start:a.selectionStart,end:a.selectionEnd},Z(a.body),et("edit"),tr()}})]}),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(B.T,{ref:e$,"aria-label":o,placeholder:V,"aria-autocomplete":"list","aria-expanded":e1.length>0,"aria-controls":e1.length>0?eL:void 0,"aria-activedescendant":e1.length>0?"".concat(eL,"-").concat(eE):void 0,value:Q,onChange:e=>{eg(null),Z(e.target.value),eS(e.target.selectionStart),eH.current={start:e.target.selectionStart,end:e.target.selectionEnd},eC(!0)},onSelect:e=>{tc(),eS(e.currentTarget.selectionStart)},onKeyUp:e=>{tc(),eS(e.currentTarget.selectionStart)},onKeyDown:e=>{var t,s;if(e.nativeEvent.isComposing||229===e.keyCode)return;if(eY&&e1.length>0&&["ArrowDown","ArrowUp","Enter","Tab","Escape"].includes(e.key)){if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),eC(!1);return}if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e_(t=>(t+("ArrowDown"===e.key?1:-1)+e1.length)%e1.length);return}e.preventDefault(),th(null!=(t=e1[eE])?t:e1[0]);return}if(I&&e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&"."===e.key){e.preventDefault(),null==(s=eM.current[tb.length])||s.click();return}if(!(e.ctrlKey||e.metaKey)||e.altKey)return;let n="b"===e.key.toLowerCase()?"bold":"i"===e.key.toLowerCase()?"italic":"k"===e.key.toLowerCase()?"link":null;n&&(e.preventDefault(),td(n))},onPaste:h?e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),e5(t))}:void 0,rows:6,className:"min-h-28 resize-y border-0 focus-visible:ring-0"}),e1.length>0&&(0,n.jsx)("div",{id:eL,role:"listbox","aria-label":"提及用户建议",className:"absolute left-2 right-2 top-full z-30 mt-1 max-h-56 overflow-y-auto rounded-[6px] border bg-popover p-1 shadow-lg",children:e1.map((e,t)=>{var s,a,l;let r=(null==(s=e.displayName)?void 0:s.trim())||(null==(a=e.name)?void 0:a.trim())||e.id;return(0,n.jsxs)("button",{id:"".concat(eL,"-").concat(t),type:"button",role:"option","aria-label":"".concat(r,",账号 @").concat(e.id),"aria-selected":t===eE,className:"flex min-h-11 w-full min-w-0 items-center gap-2 rounded px-2 text-left text-sm sm:min-h-10 ".concat(t===eE?"bg-accent":"hover:bg-muted"),onMouseDown:e=>e.preventDefault(),onClick:()=>th(e),children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold",children:(null==(l=Array.from(r)[0])?void 0:l.toLocaleUpperCase())||"?"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[(0,n.jsx)("strong",{children:r}),(0,n.jsxs)("span",{className:"ml-2 text-muted-foreground",children:["@",e.id]})]})]},e.id)})}),eY&&0===e1.length&&(0,n.jsx)("div",{role:"status","aria-label":"提及用户建议状态",className:"absolute left-2 right-2 top-full z-30 mt-1 rounded-[6px] border bg-popover px-3 py-3 text-sm text-muted-foreground shadow-lg",children:"没有匹配的用户"})]})]}):(0,n.jsx)("div",{id:ez,role:"tabpanel","aria-labelledby":eD,className:"min-h-28 px-3 py-2",children:Q?(0,n.jsx)(ea,{children:Q}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"暂无内容"})})]}),h&&(0,n.jsxs)("div",{"data-localapp-issue-attachment-queue":!0,tabIndex:-1,"data-drag-active":ec?"true":void 0,"aria-label":"拖拽附件到此处","aria-busy":e6||void 0,onDragEnter:e=>{Array.from(e.dataTransfer.types).includes("Files")&&(e.preventDefault(),eQ.current+=1,ed(!0))},onDragLeave:e=>{ec&&(e.preventDefault(),eQ.current=Math.max(0,eQ.current-1),0===eQ.current&&ed(!1))},onDragOver:e=>{Array.from(e.dataTransfer.types).includes("Files")&&e.preventDefault()},onDrop:e=>{e.preventDefault(),eQ.current=0,ed(!1),e5(Array.from(e.dataTransfer.files))},className:"rounded-md border border-dashed px-3 py-2 transition-colors motion-reduce:transition-none ".concat(ec?"border-primary bg-primary/5 ring-2 ring-primary/20":""),children:[ec&&(0,n.jsx)("span",{role:"status","aria-label":"附件拖拽状态",className:"sr-only",children:"松开以上传文件"}),(0,n.jsx)("span",{role:"status","aria-label":"附件队列状态","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:ts}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("input",{ref:eU,"data-testid":"issue-attachment-input",hidden:!0,type:"file",multiple:!0,onChange:e=>{var t;e5(Array.from(null!=(t=e.target.files)?t:[])),e.target.value=""}}),(0,n.jsxs)(x.$,{ref:eP,type:"button",variant:"outline",size:"sm",className:"h-11 gap-1.5 sm:h-8",onClick:()=>{var e;return null==(e=eU.current)?void 0:e.click()},children:[(0,n.jsx)(F.A,{className:"h-3.5 w-3.5"}),"添加附件"]}),(0,n.jsx)("span",{className:"text-xs ".concat(ec?"font-medium text-primary":"text-muted-foreground"),children:ec?"松开以上传文件":"拖拽文件或粘贴截图"})]}),ei.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("ul",{id:eq,className:"mt-2 grid gap-2 sm:grid-cols-2",children:tl.map(e=>{var t;return(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-2 rounded border bg-card p-2 text-xs",children:[e.previewUrl?(0,n.jsx)("img",{src:e.previewUrl,alt:"".concat(e.fileName," 预览"),className:"h-10 w-10 shrink-0 rounded object-cover"}):(0,n.jsx)($.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"truncate font-medium",children:e.fileName}),(0,n.jsxs)("p",{role:"uploaded"===e.status?"status":void 0,"aria-label":"uploaded"===e.status?"".concat(e.fileName," 已上传"):void 0,className:"inline-flex items-center gap-1 ".concat(e.error?"text-destructive":"uploaded"===e.status?"text-emerald-700":"text-muted-foreground"),children:["uploaded"===e.status&&(0,n.jsx)(M.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),null!=(t=e.error)?t:"uploading"===e.status?"上传中...":"已上传 \xb7 ".concat(eh(e.fileSize))]})]}),"uploading"===e.status&&(0,n.jsx)(A.A,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"error"===e.status&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-7 sm:w-7","aria-label":"重试 ".concat(e.fileName),onClick:()=>(e=>{let t={...e,status:"uploading",error:void 0};e2(s=>s.map(s=>s.clientId===e.clientId?t:s)),e3(t,e4(e.clientId))})(e),children:(0,n.jsx)(K.A,{className:"h-3.5 w-3.5"})}),(0,n.jsx)(x.$,{ref:t=>{t?eF.current.set(e.clientId,t):eF.current.delete(e.clientId)},type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-7 sm:w-7","aria-label":"移除 ".concat(e.fileName),onClick:()=>(e=>{var t,s,n,l,r;let i=tl.findIndex(t=>t.clientId===e.clientId),o=null==(t=tl[i+1])?void 0:t.clientId,c=null==(s=tl[i-1])?void 0:s.clientId;ej(null),e4(e.clientId),(null==(n=e.previewUrl)?void 0:n.startsWith("blob:"))&&(null==(l=(r=URL).revokeObjectURL)||l.call(r,e.previewUrl)),e2(t=>t.filter(t=>t.clientId!==e.clientId)),Z(t=>{var s,n;return(n=null!=(s=e.markdown)?s:tp(e.attachment))?t.replace(n,"").replace(/\n{3,}/g,"\n\n").trim():t}),e.attachment&&tv(a,e.attachment),window.requestAnimationFrame(()=>{let e=o&&eF.current.get(o)||c&&eF.current.get(c)||eP.current;null==e||e.focus()})})(e),children:(0,n.jsx)(O.A,{className:"h-3.5 w-3.5"})})]},e.clientId)})}),tn>0&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"mt-2 h-11 sm:h-8","aria-expanded":eN,"aria-controls":eq,onClick:()=>ek(e=>!e),children:eN?"收起已上传附件":"显示其余 ".concat(tn," 个已上传附件")})]})]}),ew&&(0,n.jsx)("p",{role:"alert","data-localapp-issue-attachment-limit-error":!0,className:"text-sm text-destructive",children:ew}),(e9||eb)&&(0,n.jsx)("p",{role:"alert","data-localapp-issue-submit-error":!0,className:"text-sm text-destructive",children:e9||eb}),(0,n.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[H&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:em,onClick:H,children:"取消"}),(0,n.jsxs)(x.$,{type:"submit",size:"sm",className:"h-11 min-w-[5.5rem] gap-1.5 sm:h-8","aria-keyshortcuts":"Meta+Enter Control+Enter","aria-busy":"submit"===ef||void 0,disabled:tt,children:["submit"===ef&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),d]}),"open"===u&&(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 min-w-[7.5rem] gap-1.5 sm:h-8","aria-busy":"closed"===ef||void 0,disabled:tt,onClick:e=>void e8(e,"closed"),children:["closed"===ef&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"评论并关闭"]}),"closed"===u&&(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 min-w-[9rem] gap-1.5 sm:h-8","aria-busy":"open"===ef||void 0,disabled:tt,onClick:e=>void e8(e,"open"),children:["open"===ef&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"重新打开并评论"]})]})]})}let tk={name:"",color:"1f6feb",description:""};function tI(e){let{labels:t,saving:s,error:a,onCreate:r,onUpdate:i,onDelete:o}=e,[c,d]=(0,l.useState)(null),[u,m]=(0,l.useState)(tk),[h,p]=(0,l.useState)(null),f=(0,l.useRef)(null),b=(0,l.useRef)(null),g=(0,l.useRef)(null),v=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;c&&(null==(e=f.current)||e.focus())},[c]),(0,l.useEffect)(()=>{var e;h&&(null==(e=g.current)||e.focus())},[h]);let y=e=>{var t;p(null),d(null!=(t=null==e?void 0:e.id)?t:"new"),m(e?{name:e.name,color:e.color,description:e.description}:tk)},w=async()=>{if(u.name.trim()&&/^[0-9a-fA-F]{6}$/.test(u.color))try{let e={...u,name:u.name.trim(),color:u.color.toLowerCase(),description:u.description.trim()};"new"===c?await r(e):c&&await i(c,e),d(null)}catch(e){}},N=()=>{p(null),window.requestAnimationFrame(()=>{var e;return null==(e=b.current)?void 0:e.focus()})},k=async e=>{try{await o(e),p(null)}catch(e){}},I=t.find(e=>e.id===h);return(0,n.jsxs)("section",{"aria-labelledby":"issue-label-manager-title",className:"relative min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:[(0,n.jsxs)("div",{className:"mx-auto max-w-4xl",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b pb-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{id:"issue-label-manager-title",className:"text-lg font-semibold",children:"标签"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"使用标签对 Issue 进行分类和筛选。"})]}),(0,n.jsxs)(x.$,{type:"button",size:"sm",className:"h-11 gap-1.5 sm:h-8",onClick:()=>y(),children:[(0,n.jsx)(j.A,{className:"h-4 w-4"}),"新建标签"]})]}),a&&(0,n.jsx)("p",{role:"alert",className:"mt-4 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:a}),c&&(0,n.jsxs)("div",{className:"mt-4 rounded-md border bg-muted/20 p-4",children:[(0,n.jsxs)("div",{className:"grid gap-4 sm:grid-cols-[minmax(0,1fr)_140px]",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(E.J,{htmlFor:"issue-label-name",children:"名称"}),(0,n.jsx)(C.p,{ref:f,id:"issue-label-name",className:"mt-1 h-11 sm:h-9",maxLength:50,value:u.name,onChange:e=>m({...u,name:e.target.value})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(E.J,{htmlFor:"issue-label-color",children:"颜色"}),(0,n.jsxs)("div",{className:"mt-1 flex h-11 items-center gap-2 rounded-md border bg-background px-2 sm:h-9",children:[(0,n.jsx)("input",{id:"issue-label-color","aria-label":"标签颜色选择器",type:"color",className:"h-7 w-8 cursor-pointer border-0 bg-transparent p-0",value:"#".concat(/^[0-9a-fA-F]{6}$/.test(u.color)?u.color:"000000"),onChange:e=>m({...u,color:e.target.value.slice(1)})}),(0,n.jsx)("input",{"aria-label":"标签颜色",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none",maxLength:6,value:u.color,onChange:e=>m({...u,color:e.target.value.replace(/^#/,"")})})]})]})]}),(0,n.jsxs)("div",{className:"mt-4",children:[(0,n.jsx)(E.J,{htmlFor:"issue-label-description",children:"描述"}),(0,n.jsx)(C.p,{id:"issue-label-description",className:"mt-1 h-11 sm:h-9",maxLength:200,value:u.description,onChange:e=>m({...u,description:e.target.value})})]}),(0,n.jsxs)("div",{className:"mt-4 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:s,onClick:()=>d(null),children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:s||!u.name.trim()||!/^[0-9a-fA-F]{6}$/.test(u.color),onClick:()=>void w(),children:s?"正在保存...":"new"===c?"创建标签":"保存更改"})]})]}),(0,n.jsx)("ul",{"aria-label":"Issue 标签",className:"mt-4 divide-y rounded-md border",children:t.map(e=>(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-3 px-4 py-3",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:"#".concat(e.color)}}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("strong",{className:"truncate text-sm",children:e.name}),!!e.built_in&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"内置"})]}),(0,n.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.description||"无描述"})]}),!e.built_in&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"编辑标签 ".concat(e.name),onClick:()=>y(e),children:(0,n.jsx)(td.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 text-destructive sm:h-8 sm:w-8","aria-label":"删除标签 ".concat(e.name),onClick:t=>{b.current=t.currentTarget,p(e.id)},children:(0,n.jsx)(O.A,{className:"h-4 w-4"})})]})]},e.id))})]}),I&&(0,n.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-black/45 p-4",children:(0,n.jsxs)("div",{role:"alertdialog","aria-modal":"true","aria-label":"删除标签 ".concat(I.name," 确认"),"aria-describedby":"delete-label-description",onKeyDown:e=>{if("Escape"!==e.key||s){if("Tab"===e.key){let t=g.current,s=v.current;t&&s&&e.shiftKey&&document.activeElement===t?(e.preventDefault(),s.focus()):t&&s&&!e.shiftKey&&document.activeElement===s&&(e.preventDefault(),t.focus())}}else e.preventDefault(),N()},className:"w-full max-w-md rounded-md border bg-background p-4 shadow-xl",children:[(0,n.jsxs)("p",{className:"text-sm font-medium",children:["删除“",I.name,"”?"]}),(0,n.jsx)("p",{id:"delete-label-description",className:"mt-1 text-xs text-muted-foreground",children:"该标签会从所有 Issue 中移除,此操作无法撤销。"}),a&&(0,n.jsx)("p",{role:"alert",className:"mt-3 text-sm text-destructive",children:a}),(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:g,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:s,onClick:N,children:"取消"}),(0,n.jsx)(x.$,{ref:v,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:s,onClick:()=>void k(I.id),children:"确认删除标签"})]})]})})]})}let tS={title:"",description:"",dueOn:null,state:"open"};function tA(e){var t;let{milestones:s,saving:a,error:r,onCreate:i,onUpdate:c,onDelete:d}=e,[u,m]=(0,l.useState)(null),[h,p]=(0,l.useState)(tS),[f,b]=(0,l.useState)(null),g=(0,l.useRef)(null),v=(0,l.useRef)(null),w=(0,l.useRef)(null),N=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;u&&(null==(e=g.current)||e.focus())},[u]),(0,l.useEffect)(()=>{var e;null!==f&&(null==(e=w.current)||e.focus())},[f]);let k=e=>{var t;m(null!=(t=null==e?void 0:e.id)?t:"new"),p(e?{title:e.title,description:e.description,dueOn:e.due_on,state:e.state}:tS)},I=async()=>{if(h.title.trim())try{"new"===u?await i({title:h.title.trim(),description:h.description.trim(),dueOn:h.dueOn||null}):null!==u&&await c(u,{...h,title:h.title.trim(),description:h.description.trim(),dueOn:h.dueOn||null}),m(null)}catch(e){}},S=()=>{b(null),requestAnimationFrame(()=>{var e;return null==(e=v.current)?void 0:e.focus()})},A=s.find(e=>{let{id:t}=e;return t===f});return(0,n.jsxs)("section",{"aria-labelledby":"issue-milestone-manager-title",className:"relative min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:[(0,n.jsxs)("div",{className:"mx-auto max-w-5xl",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b pb-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{id:"issue-milestone-manager-title",className:"text-lg font-semibold",children:"里程碑"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"按版本或阶段组织 Issue,并跟踪完成进度。"})]}),(0,n.jsxs)(x.$,{type:"button",size:"sm",className:"h-11 gap-1.5 sm:h-8",onClick:()=>k(),children:[(0,n.jsx)(j.A,{className:"h-4 w-4"}),"新建里程碑"]})]}),r&&(0,n.jsx)("p",{role:"alert",className:"mt-4 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:r}),null!==u&&(0,n.jsxs)("div",{className:"mt-4 rounded-md border bg-muted/20 p-4",children:[(0,n.jsxs)("div",{className:"grid gap-4 sm:grid-cols-[minmax(0,1fr)_180px]",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(E.J,{htmlFor:"issue-milestone-title",children:"标题"}),(0,n.jsx)(C.p,{ref:g,id:"issue-milestone-title",className:"mt-1 h-11 sm:h-9",maxLength:100,value:h.title,onChange:e=>p({...h,title:e.target.value})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(E.J,{htmlFor:"issue-milestone-due",children:"截止日期"}),(0,n.jsx)(C.p,{id:"issue-milestone-due",type:"date",className:"mt-1 h-11 sm:h-9",value:null!=(t=h.dueOn)?t:"",onChange:e=>p({...h,dueOn:e.target.value||null})})]})]}),(0,n.jsxs)("div",{className:"mt-4",children:[(0,n.jsx)(E.J,{htmlFor:"issue-milestone-description",children:"描述"}),(0,n.jsx)(C.p,{id:"issue-milestone-description",className:"mt-1 h-11 sm:h-9",maxLength:1e3,value:h.description,onChange:e=>p({...h,description:e.target.value})})]}),(0,n.jsxs)("div",{className:"mt-4 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:a,onClick:()=>m(null),children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:a||!h.title.trim(),onClick:()=>void I(),children:a?"正在保存...":"new"===u?"创建里程碑":"保存更改"})]})]}),(0,n.jsx)("ul",{"aria-label":"Issue 里程碑",className:"mt-4 divide-y rounded-md border",children:s.map(e=>{let t=e.open_issues+e.closed_issues,s=0===t?0:Math.round(e.closed_issues/t*100);return(0,n.jsx)("li",{className:"px-4 py-4",children:(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("strong",{className:"text-sm",children:e.title}),(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:["open"===e.state?(0,n.jsx)(o.A,{className:"h-3.5 w-3.5"}):(0,n.jsx)(M.A,{className:"h-3.5 w-3.5"}),"open"===e.state?"开启":"已关闭"]}),e.due_on&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[(0,n.jsx)(y.A,{className:"h-3.5 w-3.5"}),e.due_on]})]}),(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.description||"无描述"}),(0,n.jsx)("div",{className:"mt-3 h-2 overflow-hidden rounded-full bg-muted",children:(0,n.jsx)("div",{className:"h-full bg-primary",style:{width:"".concat(s,"%")}})}),(0,n.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[s,"% 已完成 \xb7 ",e.open_issues," 个开启 \xb7 ",e.closed_issues," 个已关闭"]})]}),(0,n.jsxs)("div",{className:"flex shrink-0 gap-1",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"编辑里程碑 ".concat(e.title),onClick:()=>k(e),children:(0,n.jsx)(td.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"".concat("open"===e.state?"关闭":"重开","里程碑 ").concat(e.title),onClick:()=>void c(e.id,{title:e.title,description:e.description,dueOn:e.due_on,state:"open"===e.state?"closed":"open"}),children:"open"===e.state?(0,n.jsx)(M.A,{className:"h-4 w-4"}):(0,n.jsx)(o.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 text-destructive sm:h-8 sm:w-8","aria-label":"删除里程碑 ".concat(e.title),onClick:t=>{v.current=t.currentTarget,b(e.id)},children:(0,n.jsx)(O.A,{className:"h-4 w-4"})})]})]})},e.id)})})]}),A&&(0,n.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-black/45 p-4",children:(0,n.jsxs)("div",{role:"alertdialog","aria-modal":"true","aria-label":"删除里程碑 ".concat(A.title," 确认"),onKeyDown:e=>{"Escape"!==e.key||a?"Tab"===e.key&&w.current&&N.current&&(e.shiftKey&&document.activeElement===w.current?(e.preventDefault(),N.current.focus()):e.shiftKey||document.activeElement!==N.current||(e.preventDefault(),w.current.focus())):(e.preventDefault(),e.stopPropagation(),S())},className:"w-full max-w-md rounded-md border bg-background p-4 shadow-xl",children:[(0,n.jsxs)("p",{className:"text-sm font-medium",children:["删除“",A.title,"”?"]}),(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"关联的 Issue 会变为无里程碑,不会删除 Issue。此操作无法撤销。"}),r&&(0,n.jsx)("p",{role:"alert",className:"mt-3 text-sm text-destructive",children:r}),(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:w,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:a,onClick:S,children:"取消"}),(0,n.jsx)(x.$,{ref:N,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:a,onClick:()=>void d(A.id).then(()=>b(null)).catch(()=>void 0),children:"确认删除里程碑"})]})]})})]})}var tC=s(1678),tE=s(7445),t_=s(1774),tT=s(8667),tL=s(5572),tR=s(824),tD=s(5098),tz=s(882),tq=s(3902),tU=s(6839);function tP(e){let{label:t,onSelect:s}=e,a=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-2 w-2 rounded-full",style:{backgroundColor:"#".concat(t.color)}}),t.name]});return s?(0,n.jsx)("button",{type:"button","aria-label":"按标签筛选 ".concat(t.name),onClick:()=>s(t.id),className:"inline-flex min-h-6 shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:a}):(0,n.jsx)("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium",children:a})}let tF=[{value:"is:",label:"状态",description:"筛选 Open 或 Closed Issue"},{value:"in:",label:"范围",description:"限定搜索标题、正文或评论"},{value:"label:",label:"标签",description:"筛选带指定标签的 Issue"},{value:"type:",label:"类型",description:"筛选任务、缺陷或功能 Issue"},{value:"author:",label:"作者",description:"筛选指定用户创建的 Issue"},{value:"assignee:",label:"负责人",description:"筛选分配给指定用户的 Issue"},{value:"involves:",label:"参与者",description:"筛选指定用户参与的 Issue"},{value:"milestone:",label:"里程碑",description:"筛选指定里程碑内的 Issue"},{value:"reason:",label:"关闭原因",description:"筛选已完成或不计划处理的 Closed Issue"},{value:"mentions:",label:"提及",description:"筛选提及当前用户的 Issue"},{value:"no:",label:"缺失项",description:"筛选缺少元数据的 Issue"},{value:"sort:",label:"排序",description:"按活动、创建、更新或评论排序"}],t$=[["activity-desc","最近活动"],["activity-asc","最早活动"],["created-desc","最新创建"],["created-asc","最早创建"],["updated-desc","最近更新"],["updated-asc","最早更新"],["comments-desc","评论最多"],["comments-asc","评论最少"]],tM=["title","body","comments"];function tK(e,t,s){let n=function(e,t){let s=Math.max(0,Math.min(t,e.length)),n=0,a=!1;for(let t=0;t<s;t+=1){let s=e[t];'"'===s?a=!a:/\s/.test(s)&&!a&&(n=t+1)}return{start:n,end:s}}(e,t),a=e.slice(n.start,n.end),l=a.indexOf(":");if(l<0){let e=a.toLowerCase();return{...n,items:tF.filter(e=>"mentions:"!==e.value||!!s.currentUserId).filter(t=>t.value.startsWith(e)).map(e=>({id:"key-".concat(e.value.slice(0,-1)),...e}))}}let r=a.slice(0,l).toLowerCase(),i=a.slice(l+1).replace(/^"/,"").toLowerCase(),o=[],c=(e,t,s)=>{let n="".concat(r,":").concat(/\s/.test(e)?'"'.concat(e.replaceAll('"','\\"'),'"'):e);(e.toLowerCase().startsWith(i)||"is"!==r&&t.toLowerCase().includes(i))&&o.push({id:"".concat(r,"-").concat(encodeURIComponent(e.toLowerCase())),value:n,label:t,description:s})};if("is"===r)c("open","Open","仅显示待处理 Issue"),c("closed","Closed","仅显示已关闭 Issue"),c("locked","Locked","仅显示已锁定对话"),c("unlocked","Unlocked","仅显示未锁定对话"),s.currentUserId&&c("subscribed","Subscribed","仅显示当前用户关注的 Issue");else if("in"===r)c("title","标题","仅搜索 Issue 标题"),c("body","正文","仅搜索 Issue 首帖正文"),c("comments","评论","仅搜索未删除评论");else if("label"===r)for(let e of s.labels)c(e.name,e.name,e.id);else if("type"===r)c("task","任务","Task Issue"),c("bug","缺陷","Bug Issue"),c("feature","功能","Feature Issue");else if("milestone"===r){var d;for(let e of null!=(d=s.milestones)?d:[])c(e.title,e.title,"#".concat(e.id))}else if("reason"===r)c("completed","已完成","仅显示以已完成关闭的 Issue"),c("not planned","不计划处理","仅显示以不计划处理关闭的 Issue");else if("mentions"===r)s.currentUserId&&c("@me","@me","提及当前用户");else if("no"===r)c("assignee","无负责人","仅显示尚未分配负责人的 Issue"),c("label","无标签","仅显示尚未添加标签的 Issue"),c("milestone","无里程碑","仅显示尚未设置里程碑的 Issue");else if("author"===r||"involves"===r||"assignee"===r)for(let e of(s.currentUserId&&c("@me","@me","当前用户"),new Map(s.users.map(e=>[e.id.toLowerCase(),e])).values())){let t=e.displayName||e.name||e.id;c(e.id,t,"@".concat(e.id))}else if("sort"===r)for(let[e,t]of t$)c(e,t,e.endsWith("-desc")?"降序":"升序");return{...n,items:o.slice(0,8)}}function tO(e,t){let s={q:"",offset:0},n=[],a=new Set;for(let i of function(e){let t=[],s="",n=!1,a=()=>{s&&t.push({value:s,quotesClosed:!n}),s="",n=!1};for(let t of e.trim()){if(/\s/.test(t)&&!n){a();continue}s+=t,'"'===t&&(n=!n)}return a(),t}(e)){var l,r;let e=i.value.indexOf(":");if(e<=0||!i.quotesClosed){n.push(i.value);continue}let o=i.value.slice(0,e).toLowerCase(),c=(l=i.value.slice(e+1))?l.startsWith('"')||l.endsWith('"')?l.startsWith('"')&&l.endsWith('"')&&l.length>=2?l.slice(1,-1):null:l:null,d=!1;if(null!==c&&"in"===o){let e=c.toLowerCase().split(",");if(e.length>0&&e.every(e=>tM.includes(e))){for(let t of e)a.add(t);d=!0}}else if(null!==c&&"is"===o&&/^(open|closed)$/i.test(c))s.status=c.toLowerCase(),d=!0;else if(null!==c&&"is"===o&&/^(locked|unlocked)$/i.test(c))s.locked=c.toLowerCase(),d=!0;else if(null!==c&&"is"===o&&"subscribed"===c.toLowerCase()&&t.currentUserId)s.subscribed=!0,d=!0;else if(null!==c&&"label"===o){let e=t.labels.find(e=>e.id.toLowerCase()===c.toLowerCase()||e.name.toLowerCase()===c.toLowerCase());e&&(s.label=e.id,d=!0)}else if(null!==c&&"type"===o&&/^(task|bug|feature)$/i.test(c))s.issueType=c.toLowerCase(),d=!0;else if(null!==c&&"milestone"===o){let e=(null!=(r=t.milestones)?r:[]).find(e=>String(e.id)===c||e.title.toLowerCase()===c.toLowerCase());e&&(s.milestone=String(e.id),d=!0)}else if(null!==c&&"reason"===o&&/^(completed|not[ _]planned)$/i.test(c))s.status="closed",s.reason="completed"===c.toLowerCase()?"completed":"not_planned",d=!0;else if(null!==c&&"mentions"===o&&"@me"===c.toLowerCase()&&t.currentUserId)s.mentioned=!0,d=!0;else if(null!==c&&"no"===o&&/^(assignee|label|milestone)$/i.test(c))s[c.toLowerCase()]="none",d=!0;else if(null!==c&&("author"===o||"involves"===o||"assignee"===o)){let e="@me"===c.toLowerCase()?t.currentUserId:c.replace(/^@/,"");e&&(s["author"===o?"author":"assignee"===o?"assignee":"participant"]=e,d=!0)}else if(null!==c&&"sort"===o){let e=/^(activity|created|updated|comments)-(asc|desc)$/i.exec(c);e&&(s.sort=e[1].toLowerCase(),s.direction=e[2].toLowerCase(),d=!0)}d||n.push(i.value)}return s.q=n.join(" "),s.q&&a.size>0&&(s.searchIn=tM.filter(e=>a.has(e)).join(",")),s}function tJ(e,t){return[e,e&&t?"in:".concat(t):""].filter(Boolean).join(" ")}function tB(e){let{timestamp:t,href:s,precise:a=!1,now:l,className:r}=e,i=new Date(t),o=Number.isFinite(i.getTime())?i.toLocaleString():t,c=a?o:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),s=new Date(e).getTime();if(!Number.isFinite(s))return e;let n=Math.floor(Math.max(0,t-s)/6e4);if(n<1)return"刚刚";if(n<60)return"".concat(n,"分钟前");let a=Math.floor(n/60);if(a<24)return"".concat(a,"小时前");let l=Math.floor(a/24);return l<30?"".concat(l,"天前"):new Date(s).toLocaleDateString()}(t,l),d=(0,n.jsx)("time",{dateTime:t,title:o,className:s?void 0:r,children:c});return s?(0,n.jsx)("a",{href:s,className:"-my-2 inline-flex h-11 items-center px-1 sm:-my-0 sm:h-6 ".concat(null!=r?r:""),children:d}):d}var tH=s(3403),tW=s(4112),tV=s(7338);function tX(e){let{label:t,items:s}=e,a=(0,l.useId)(),[r,i]=(0,l.useState)(!1),o=(0,l.useRef)(null),c=(0,l.useRef)(null),d=(0,l.useRef)([]),u=(0,l.useRef)("first"),m=e=>{i(!1),e&&window.requestAnimationFrame(()=>{var e;return null==(e=c.current)?void 0:e.focus()})};return((0,l.useEffect)(()=>{if(!r)return;let e=()=>d.current.filter(e=>!!(e&&!e.disabled)),t=window.requestAnimationFrame(()=>{var t;let s=e();null==(t="last"===u.current?s.at(-1):s[0])||t.focus()}),s=e=>{var t;e.target instanceof Node&&!(null==(t=o.current)?void 0:t.contains(e.target))&&m(!0)},n=t=>{var s;let n;if(!(t.target instanceof Node)||!(null==(s=o.current)?void 0:s.contains(t.target)))return;if("Escape"===t.key){t.preventDefault(),t.stopPropagation(),m(!0);return}let a=e();if(0===a.length)return;let l=Math.max(0,a.indexOf(document.activeElement));if("ArrowDown"===t.key)n=a[(l+1)%a.length];else if("ArrowUp"===t.key)n=a[(l-1+a.length)%a.length];else if("Home"===t.key)n=a[0];else if("End"===t.key)n=a.at(-1);else if(1===t.key.length&&!t.ctrlKey&&!t.metaKey&&!t.altKey){let e=t.key.toLocaleLowerCase();n=[...a.slice(l+1),...a.slice(0,l+1)].find(t=>{var s;return null==(s=t.textContent)?void 0:s.trim().toLocaleLowerCase().startsWith(e)})}n&&(t.preventDefault(),t.stopPropagation(),n.focus())};return document.addEventListener("mousedown",s),document.addEventListener("keydown",n,!0),()=>{window.cancelAnimationFrame(t),document.removeEventListener("mousedown",s),document.removeEventListener("keydown",n,!0)}},[r]),(0,l.useEffect)(()=>{0===s.length&&i(!1)},[s.length]),(0,l.useEffect)(()=>{var e;if(!r||0===s.length||(null==(e=o.current)?void 0:e.contains(document.activeElement)))return;let t=window.requestAnimationFrame(()=>{var e;null==(e=d.current.find(e=>e&&!e.disabled))||e.focus()});return()=>window.cancelAnimationFrame(t)},[s,r]),0===s.length)?null:(0,n.jsxs)("div",{ref:o,className:"relative shrink-0",children:[(0,n.jsx)(x.$,{ref:c,type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":t,"aria-haspopup":"menu","aria-controls":a,"aria-expanded":r,onKeyDown:e=>{("ArrowDown"===e.key||"ArrowUp"===e.key)&&(e.preventDefault(),e.stopPropagation(),u.current="ArrowUp"===e.key?"last":"first",i(!0))},onClick:()=>{u.current="first",i(e=>!e)},children:(0,n.jsx)(tV.A,{className:"h-4 w-4"})}),r&&(0,n.jsx)("div",{id:a,role:"menu","aria-label":t,className:"absolute right-0 top-12 z-30 min-w-40 overflow-hidden rounded-[6px] border bg-popover p-1 shadow-lg sm:top-9",children:s.map((e,t)=>(0,n.jsx)("button",{ref:e=>{d.current[t]=e},type:"button",role:"menuitem",disabled:e.disabled,className:"flex min-h-11 w-full items-center rounded px-3 text-left text-sm outline-none hover:bg-muted focus:bg-muted disabled:opacity-50 sm:min-h-8 sm:px-2.5 ".concat(e.destructive?"text-destructive":"text-popover-foreground"),onClick:()=>{m(!1!==e.restoreFocus),e.onSelect(c.current)},children:e.label},e.label))})]})}function tQ(e){var t;let{views:s,activeViewId:a,dirty:r,currentQuery:i,loading:o,error:c,saving:u,onApply:m,onCreate:h,onUpdate:p,onCopy:f,onDelete:b,onRetry:g}=e,[v,y]=(0,l.useState)(null),[w,j]=(0,l.useState)(""),[k,I]=(0,l.useState)(""),[S,_]=(0,l.useState)(null),[T,L]=(0,l.useState)(null),R=(0,l.useRef)(null),D=null!=(t=s.find(e=>e.id===a))?t:null;(0,l.useEffect)(()=>{var e,t,s,n,a;v&&(j("edit"===v.mode?null!=(s=null==(e=v.view)?void 0:e.name)?s:"":"save-as"===v.mode&&D?"".concat(D.name," copy"):""),I("edit"===v.mode?null!=(n=null==(t=v.view)?void 0:t.description)?n:"":"save-as"===v.mode&&null!=(a=null==D?void 0:D.description)?a:""),_(null))},[D,v]);let z=e=>y(e),q=()=>{u||y(null)},U=async()=>{if(v&&w.trim()&&!u){_(null);try{"edit"===v.mode&&v.view?await p(v.view.id,{name:w.trim(),description:k.trim()}):await h(w.trim(),k.trim()),y(null)}catch(e){_(e instanceof Error?e.message:"保存视图失败")}}},P=async e=>{_(null);try{await f(e)}catch(e){_(e instanceof Error?e.message:"复制视图失败")}},F=async()=>{if(T&&!u){_(null);try{await b(T.id),L(null)}catch(e){_(e instanceof Error?e.message:"删除视图失败")}}};return(0,n.jsxs)("section",{"aria-labelledby":"issue-saved-views-title",className:"mt-2 min-w-0 lg:mt-4 lg:border-t lg:pt-3",children:[(0,n.jsxs)("div",{className:"mb-1 flex min-h-8 items-center justify-end gap-2 px-0 lg:px-2",children:[(0,n.jsx)("h3",{id:"issue-saved-views-title",className:"sr-only min-w-0 flex-1 text-xs font-semibold uppercase text-muted-foreground lg:not-sr-only",children:"保存的视图"}),D&&r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 lg:h-8 lg:w-8","aria-label":"保存视图更改",title:"保存更改",disabled:u,onClick:()=>void p(D.id,{query:i}),children:(0,n.jsx)(d.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 lg:h-8 lg:w-8","aria-label":"将当前查询另存为视图",title:"另存为",disabled:u,onClick:()=>z({mode:"save-as"}),children:(0,n.jsx)(tH.A,{className:"h-4 w-4"})})]}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 lg:h-8 lg:w-8","aria-label":"保存当前 Issue 视图",title:"保存当前视图",onClick:()=>z({mode:"create"}),children:(0,n.jsx)(tW.A,{className:"h-4 w-4"})})]}),o&&(0,n.jsxs)("p",{role:"status",className:"hidden min-h-11 items-center gap-2 px-2 text-xs text-muted-foreground lg:flex",children:[(0,n.jsx)(A.A,{className:"h-3.5 w-3.5 animate-spin"}),"正在加载保存视图..."]}),c&&(0,n.jsxs)("div",{role:"alert",className:"hidden space-y-2 px-2 py-2 text-xs text-destructive lg:block",children:[(0,n.jsx)("p",{children:c}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8","aria-label":"重试保存视图",onClick:g,children:"重试"})]}),!o&&!c&&0===s.length&&(0,n.jsx)("p",{className:"hidden px-2 py-2 text-xs text-muted-foreground lg:block",children:"尚未保存视图"}),!o&&!c&&s.length>0&&(0,n.jsx)("div",{className:"hidden space-y-1 lg:block",children:s.map(e=>(0,n.jsxs)("div",{className:"group flex min-w-0 items-center gap-1",children:[(0,n.jsxs)("button",{type:"button","aria-label":"打开保存视图 ".concat(e.name),"aria-pressed":a===e.id,title:e.description||e.name,onClick:()=>m(e),className:"h-11 min-w-0 flex-1 truncate rounded px-2.5 text-left text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8 ".concat(a===e.id?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[e.name,a===e.id&&r?(0,n.jsx)("span",{"aria-hidden":"true",children:" *"}):null]}),(0,n.jsx)(tX,{label:"管理保存视图 ".concat(e.name),items:[{label:"编辑视图",restoreFocus:!1,onSelect:()=>z({mode:"edit",view:e})},{label:"复制视图",onSelect:()=>void P(e.id)},{label:"删除视图",destructive:!0,restoreFocus:!1,onSelect:()=>{L(e),window.requestAnimationFrame(()=>{var e;return null==(e=R.current)?void 0:e.focus()})}}]})]},e.id))}),D&&r&&(0,n.jsx)("p",{role:"status",className:"mt-2 hidden rounded-md border bg-muted/30 p-2 text-xs font-medium lg:block",children:"有未保存更改"}),S&&!v&&(0,n.jsx)("p",{role:"alert",className:"mt-2 px-2 text-xs text-destructive",children:S}),v&&(0,n.jsx)("div",{className:"absolute inset-0 z-[80] flex items-center justify-center bg-black/45 p-4",children:(0,n.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"saved-view-editor-title",className:"w-full max-w-lg overflow-hidden rounded-md border bg-card shadow-2xl",children:[(0,n.jsxs)("header",{className:"flex min-h-14 items-center gap-3 border-b px-4",children:[(0,n.jsx)("h3",{id:"saved-view-editor-title",className:"min-w-0 flex-1 text-sm font-semibold",children:"edit"===v.mode?"编辑保存视图":"save-as"===v.mode?"另存当前视图":"保存当前视图"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11","aria-label":"关闭保存视图编辑器",onClick:q,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(0,n.jsxs)("div",{className:"space-y-4 p-4",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(E.J,{htmlFor:"saved-view-name",children:"视图名称"}),(0,n.jsx)(C.p,{id:"saved-view-name",autoFocus:!0,value:w,maxLength:50,onChange:e=>j(e.target.value)})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(E.J,{htmlFor:"saved-view-description",children:"视图说明"}),(0,n.jsx)(C.p,{id:"saved-view-description",value:k,maxLength:200,onChange:e=>I(e.target.value)})]}),S&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:S})]}),(0,n.jsxs)("footer",{className:"flex justify-end gap-2 border-t px-4 py-3",children:[(0,n.jsx)(x.$,{type:"button",variant:"outline",className:"h-11 sm:h-8",disabled:u,onClick:q,children:"取消"}),(0,n.jsx)(x.$,{type:"button",className:"h-11 sm:h-8",disabled:u||!w.trim(),onClick:()=>void U(),children:u?"保存中...":"保存视图"})]})]})}),T&&(0,n.jsx)("div",{className:"absolute inset-0 z-[80] flex items-center justify-center bg-black/45 p-4",children:(0,n.jsxs)("div",{role:"alertdialog","aria-modal":"true","aria-labelledby":"saved-view-delete-title","aria-describedby":"saved-view-delete-description",className:"w-full max-w-md overflow-hidden rounded-md border bg-card shadow-2xl",children:[(0,n.jsxs)("div",{className:"space-y-2 p-4",children:[(0,n.jsx)("h3",{id:"saved-view-delete-title",className:"text-sm font-semibold",children:"删除保存视图"}),(0,n.jsxs)("p",{id:"saved-view-delete-description",className:"text-sm text-muted-foreground",children:["“",T.name,"”将从你的个人视图中删除,不会修改任何 Issue。"]}),S&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:S})]}),(0,n.jsxs)("footer",{className:"flex justify-end gap-2 border-t px-4 py-3",children:[(0,n.jsx)(x.$,{ref:R,type:"button",variant:"outline",className:"h-11 sm:h-8",disabled:u,onClick:()=>L(null),children:"取消删除"}),(0,n.jsx)(x.$,{type:"button",variant:"destructive",className:"h-11 sm:h-8","aria-label":"确认删除视图",disabled:u,onClick:()=>void F(),children:u?"删除中...":"确认删除"})]})]})})]})}function tZ(e){let{status:t,className:s="h-4 w-4"}=e;return"open"===t?(0,n.jsx)(o.A,{className:"".concat(s," text-primary"),"aria-hidden":"true"}):(0,n.jsx)(M.A,{className:"".concat(s," text-muted-foreground"),"aria-hidden":"true"})}function tG(e){let{issue:t,className:s="h-4 w-4"}=e;if("open"===t.status)return(0,n.jsx)("span",{"aria-label":"开启",title:"开启",className:s,children:(0,n.jsx)(o.A,{className:"h-full w-full text-primary","aria-hidden":"true"})});let a="not_planned"===t.state_reason,l=a?"已关闭:不计划处理":"已关闭:已完成";return(0,n.jsx)("span",{"aria-label":l,title:l,className:s,children:a?(0,n.jsx)(tC.A,{className:"h-full w-full text-muted-foreground","aria-hidden":"true"}):(0,n.jsx)(M.A,{className:"h-full w-full text-primary","aria-hidden":"true"})})}function tY(e){var t,s;let{issue:a}=e,l=null!=(s=null!=(t=a.last_activity_at)?t:a.updated_at)?s:a.created_at,r=l===a.created_at;return(0,n.jsxs)("span",{"data-localapp-issue-activity":!0,"data-kind":r?"created":"activity",className:"inline-flex min-w-0 flex-wrap items-center gap-1",children:[(0,n.jsx)("span",{children:r?"创建于":"活动于"}),(0,n.jsx)(tB,{timestamp:l})]})}function t0(e){let{ids:t,users:s,onSelect:a}=e,l=Array.from(new Set(t));if(0===l.length)return null;let r=l.map(e=>{var t;let n=s.find(t=>t.id===e);return{id:e,label:(null==n?void 0:n.displayName)||(null==n?void 0:n.name)||e,avatarUrl:null!=(t=null==n?void 0:n.avatarUrl)?t:null}}),i=r.slice(0,3),o=r.length-i.length;return(0,n.jsxs)("div",{role:"group","aria-label":"负责人:".concat(r.map(e=>e.label).join("、")),className:"hidden shrink-0 self-center -space-x-1.5 sm:flex",children:[i.map(e=>{var t;return(0,n.jsx)("button",{type:"button","aria-label":"按负责人筛选 ".concat(e.label),title:"".concat(e.label," @").concat(e.id),onClick:()=>a(e.id),className:"flex h-7 w-7 items-center justify-center overflow-hidden rounded-full border-2 border-background bg-muted text-[10px] font-semibold text-muted-foreground hover:z-10 hover:ring-2 hover:ring-ring focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:e.avatarUrl?(0,n.jsx)("img",{src:e.avatarUrl,alt:"",className:"h-full w-full object-cover"}):(null==(t=Array.from(e.label)[0])?void 0:t.toLocaleUpperCase())||"?"},e.id)}),o>0&&(0,n.jsxs)("span",{"aria-label":"另外 ".concat(o," 位负责人"),className:"flex h-7 min-w-7 items-center justify-center rounded-full border-2 border-background bg-muted px-1 text-[10px] font-semibold text-muted-foreground",children:["+",o]})]})}function t1(e){let{milestone:t,onSelect:s}=e;return t?(0,n.jsxs)("button",{type:"button","aria-label":"按里程碑筛选 ".concat(t.title),onClick:()=>s(t.id),className:"inline-flex min-h-6 max-w-full items-center gap-1 rounded-sm text-left hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,n.jsx)(y.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,n.jsx)("span",{className:"break-words",children:t.title})]}):null}function t2(e){var t,s,a,r,i,c;let{currentUserId:d,error:u,issues:m,pinnedIssues:h=[],labels:p,milestones:f,users:b,loading:g,meta:v,query:w,searchInput:j,searchInputRef:I,onOpenIssue:E,getIssueHref:_,onQueryChange:T,onReset:L,onRetry:R,onSearchInputChange:D,onSubmitSearch:z,canBulkManage:q=!1,onBulkStatus:U,onBulkIssueType:P,onBulkLabel:F,onBulkAssignee:$,onBulkMilestone:K,savedViews:O=[],savedViewsLoading:J=!1,savedViewsError:B=null,savedViewsSaving:H=!1,activeSavedViewId:W=null,savedViewDirty:V=!1,onApplySavedView:X,onCreateSavedView:Q,onUpdateSavedView:Z,onCopySavedView:G,onDeleteSavedView:Y,onRetrySavedViews:ee,onLeaveSavedView:et}=e,[es,en]=(0,l.useState)("all"),ea=function(e,t){let s=e.author===t&&!e.participant&&!e.assignee&&!e.subscribed&&!e.mentioned,n=e.assignee===t&&!e.author&&!e.participant&&!e.subscribed&&!e.mentioned,a=s?"":e.author,l=n?"":e.assignee;return[e.issueType,e.label,a,l,e.milestone,e.locked,e.reason].filter(Boolean).length+Number("activity"!==e.sort||"desc"!==e.direction)}(w,d),[el,er]=(0,l.useState)(()=>ea>0),[eo,ec]=(0,l.useState)(new Set),[ed,eu]=(0,l.useState)(!1),[em,eh]=(0,l.useState)(""),[ep,ef]=(0,l.useState)(""),[ex,eb]=(0,l.useState)(""),[eg,ev]=(0,l.useState)(""),[ey,ew]=(0,l.useState)(""),[ej,eN]=(0,l.useState)(!1),[ek,eI]=(0,l.useState)(j.length),[eS,eA]=(0,l.useState)(-1),eC=(0,l.useRef)(null),eE=(0,l.useRef)(null),e_=(0,l.useRef)(null),eT=(0,l.useRef)(!1),eL=(0,l.useRef)(!1),eR=(0,l.useRef)(null),eD=(0,l.useRef)(!1),ez=(0,l.useRef)(null),eq=(0,l.useRef)(null),eU=(0,l.useRef)(null),eP="localapp-issue-search-suggestions",eF=tK(j,null!=(r=eR.current)?r:ek,{currentUserId:d,labels:p,milestones:f,users:b}),e$=ej?eF.items:[];(0,l.useEffect)(()=>{!d||!w.mentioned||w.author||w.participant||w.assignee||w.subscribed?!d||!w.subscribed||w.author||w.participant||w.assignee||w.mentioned?!d||w.assignee!==d||w.author||w.participant||w.subscribed||w.mentioned?!d||w.author!==d||w.participant||w.assignee||w.subscribed||w.mentioned?!d||w.participant!==d||w.author||w.assignee||w.subscribed||w.mentioned?(w.author||w.participant||w.assignee||w.subscribed||w.mentioned||"assigned"===es||"created"===es||"participating"===es||"subscribed"===es||"mentioned"===es)&&en("all"):en("participating"):en("created"):en("assigned"):en("subscribed"):en("mentioned")},[es,d,w.assignee,w.author,w.participant,w.subscribed,w.mentioned]),(0,l.useEffect)(()=>{ec(new Set),eh(""),eE.current=null},[w.q,w.status,w.issueType,w.label,w.author,w.participant,w.assignee,w.milestone,w.reason,w.subscribed,w.mentioned,w.locked,w.sort,w.direction,w.limit,w.offset]);let eM=m.map(e=>e.id).join(",");(0,l.useEffect)(()=>{eE.current=null},[eM]),(0,l.useEffect)(()=>{if(0===eo.size)return;let e=new Set(m.map(e=>e.id)),t=new Set(Array.from(eo).filter(t=>e.has(t))),s=eo.size-t.size;0!==s&&(eL.current=eT.current||null!==e_.current&&!e.has(e_.current),ec(t),eh("".concat(s," 条已选 Issue 已不在当前列表,选择已更新")),eL.current&&window.requestAnimationFrame(()=>{var e;null==(e=eC.current)||e.focus(),eL.current=!1,e_.current=null,eT.current=!1}))},[m,eo]);let eK=!!(w.q||w.searchIn||w.issueType||w.label||w.author||w.participant||w.assignee||w.milestone||w.reason||w.subscribed||w.mentioned||w.locked),eO="all"===es&&"open"===w.status&&0===w.offset&&!eK&&"activity"===w.sort&&"desc"===w.direction&&h.length>0,eJ=w.offset>0&&0===m.length;(0,l.useEffect)(()=>{if(!eD.current)return;if(ez.current!==w.offset){eD.current=!1,ez.current=null;return}if(g||u||v.offset!==w.offset)return;eD.current=!1,ez.current=null;let e=window.requestAnimationFrame(()=>{var e,t,s;m.length>0?null==(t=eq.current)||null==(e=t.querySelector("[data-localapp-issue-link]"))||e.focus():eJ&&(null==(s=eU.current)||s.focus())});return()=>window.cancelAnimationFrame(e)},[u,m,g,v.offset,eJ,w.offset]);let eB=e=>{eD.current=!0,ez.current=e,T({offset:e})},eH=e=>{let t=b.find(t=>t.id===e);return(null==t?void 0:t.displayName)||(null==t?void 0:t.name)||e},eW=[...w.issueType?[{key:"issueType",kind:"类型",value:ei[w.issueType]}]:[],...w.label?[{key:"label",kind:"标签",value:"none"===w.label?"未添加":null!=(i=null==(t=p.find(e=>e.id===w.label))?void 0:t.name)?i:w.label}]:[],...w.author?[{key:"author",kind:"作者",value:eH(w.author)}]:[],...w.participant?[{key:"participant",kind:"参与者",value:eH(w.participant)}]:[],...w.assignee?[{key:"assignee",kind:"负责人",value:"none"===w.assignee?"未分配":eH(w.assignee)}]:[],...w.milestone?[{key:"milestone",kind:"里程碑",value:"none"===w.milestone?"无里程碑":null!=(c=null==(s=f.find(e=>String(e.id)===w.milestone))?void 0:s.title)?c:"#".concat(w.milestone)}]:[],...w.reason?[{key:"reason",kind:"关闭原因",value:"not_planned"===w.reason?"不计划处理":"已完成"}]:[],...w.subscribed?[{key:"subscribed",kind:"关注",value:"我"}]:[],...w.mentioned?[{key:"mentioned",kind:"提及",value:"我"}]:[],...w.locked?[{key:"locked",kind:"对话",value:"locked"===w.locked?"已锁定":"未锁定"}]:[]],eV=g&&m.length>0,eX=eo.size,eQ=m.length>0&&m.every(e=>eo.has(e.id)),eZ=eX>0&&!eQ;(0,l.useEffect)(()=>{eC.current&&(eC.current.indeterminate=eZ)},[eZ]);let eG=[["all","全部 Issue"],...d?[["assigned","分配给我的"],["created","我创建的"],["participating","我参与的"],["subscribed","我关注的"],["mentioned","提及我的"]]:[],["recent","最近活动"]],eY=e=>(null==et||et(),en(e),"assigned"===e&&d)?void T({author:"",participant:"",assignee:d,subscribed:!1,mentioned:!1}):"created"===e&&d?void T({author:d,participant:"",assignee:"",subscribed:!1,mentioned:!1}):"participating"===e&&d?void T({author:"",participant:d,assignee:"",subscribed:!1,mentioned:!1}):"subscribed"===e&&d?void T({author:"",participant:"",assignee:"",subscribed:!0,mentioned:!1}):"mentioned"===e&&d?void T({author:"",participant:"",assignee:"",subscribed:!1,mentioned:!0}):"recent"===e?void T({author:"",participant:"",assignee:"",subscribed:!1,mentioned:!1,sort:"activity",direction:"desc"}):void T({author:"",participant:"",assignee:"",subscribed:!1,mentioned:!1}),e0=()=>{en("all"),L(),window.requestAnimationFrame(()=>{var e;return null==I||null==(e=I.current)?void 0:e.focus()})},e1=e=>T({status:e}),e2=(e,t)=>{0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),E(t))},e4=(e,t,s)=>{let n=eE.current,a=s&&null!==n?m.findIndex(e=>e.id===n):-1,l=m.findIndex(t=>t.id===e);ec(s=>{let n=new Set(s);for(let s of a>=0&&l>=0?m.slice(Math.min(a,l),Math.max(a,l)+1).map(e=>e.id):[e])t?n.add(s):n.delete(s);return n}),eE.current=e},e3=async e=>{if(U&&0!==eX&&!ed){eu(!0),eh("");try{let t=await U(Array.from(eo),e);eE.current=null,ec(new Set(t.failedIds)),eh(t.failedIds.length?"".concat(t.succeeded," 条成功,").concat(t.failedIds.length," 条失败,可重试失败项"):"".concat(t.succeeded," 条 Issue 已更新")),0===t.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){eh(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1)}}},e5=async e=>{if(P&&0!==eX&&!ed&&e){eu(!0),eh("");try{let t=await P(Array.from(eo),e);eE.current=null,ec(new Set(t.failedIds)),eh(t.failedIds.length?"".concat(t.succeeded," 条成功,").concat(t.failedIds.length," 条失败,可重试失败项"):"".concat(t.succeeded," 条 Issue 已更新")),0===t.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){eh(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1),ef("")}}},e8=async e=>{if(!F||0===eX||ed||!e)return;let[t,s]=e.split(":",2);if(s&&("add"===t||"remove"===t)){eu(!0),eh("");try{let e=await F(Array.from(eo),s,"add"===t);eE.current=null,ec(new Set(e.failedIds)),eh(e.failedIds.length?"".concat(e.succeeded," 条成功,").concat(e.failedIds.length," 条失败,可重试失败项"):"".concat(e.succeeded," 条 Issue 已更新")),0===e.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){eh(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1),eb("")}}},e6=async e=>{if(!$||0===eX||ed||!e)return;let[t,s]=e.split(":",2);if(s&&("add"===t||"remove"===t)){eu(!0),eh("");try{let e=await $(Array.from(eo),s,"add"===t);eE.current=null,ec(new Set(e.failedIds)),eh(e.failedIds.length?"".concat(e.succeeded," 条成功,").concat(e.failedIds.length," 条失败,可重试失败项"):"".concat(e.succeeded," 条 Issue 已更新")),0===e.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){eh(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1),ev("")}}},e7=async e=>{if(!K||0===eX||ed||!e)return;let t="none"===e?null:Number(e);if(null===t||Number.isInteger(t)&&!(t<=0)){eu(!0),eh("");try{let e=await K(Array.from(eo),t);eE.current=null,ec(new Set(e.failedIds)),eh(e.failedIds.length?"".concat(e.succeeded," 条成功,").concat(e.failedIds.length," 条失败,可重试失败项"):"".concat(e.succeeded," 条 Issue 已更新")),0===e.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){eh(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1),ew("")}}},e9=e=>{var t;let s=function(e,t,s,n){let a=e.slice(s.end),l=!n.endsWith(":"),r=l&&(0===a.length||!/^\s/.test(a)),i=e.slice(0,s.start)+n+(r?" ":"")+a;return{value:i,cursor:Math.min(s.start+n.length+(l&&(r||/^\s/.test(a))?1:0),i.length)}}(j,0,eF,e.value);D(s.value),eR.current=s.cursor,eI(s.cursor),eA(-1),eN(!0),null==I||null==(t=I.current)||t.focus(),window.requestAnimationFrame(()=>{var e;null==I||null==(e=I.current)||e.setSelectionRange(s.cursor,s.cursor)})},te=()=>{D(""),T({q:"",searchIn:"",offset:0}),eN(!1),eA(-1),eI(0),window.requestAnimationFrame(()=>{var e;return null==I||null==(e=I.current)?void 0:e.focus()})};return(0,n.jsxs)("section",{"data-localapp-issue-list":!0,"data-testid":"issue-list-workspace",className:"grid min-h-0 max-w-full flex-1 grid-rows-[auto_minmax(0,1fr)] overflow-x-hidden [&_[data-localapp-issue-bulk-toolbar]_label:focus-within]:ring-2 [&_[data-localapp-issue-bulk-toolbar]_label:focus-within]:ring-ring lg:grid-cols-[240px_minmax(0,1fr)] lg:grid-rows-1",children:[(0,n.jsxs)("aside",{"data-localapp-issue-view-rail":!0,"data-testid":"issue-view-rail","aria-label":"Issue 视图",className:"min-w-0 border-b bg-muted/20 px-3 py-2 lg:border-b-0 lg:border-r lg:px-3 lg:py-4",children:[(0,n.jsxs)("label",{className:"flex h-11 w-full items-center rounded-md border bg-background px-3 text-sm font-medium text-foreground focus-within:ring-2 focus-within:ring-ring lg:hidden",children:[(0,n.jsx)("span",{className:"sr-only",children:"Issue 视图"}),(0,n.jsxs)("select",{"aria-label":"Issue 视图",value:W?"saved:".concat(W):es,onChange:e=>{let t=e.target.value;if(t.startsWith("saved:")){let e=O.find(e=>e.id===Number(t.slice(6)));e&&(null==X||X(e))}else eY(t)},className:"h-full min-w-0 w-full cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("optgroup",{label:"内置视图",children:eG.map(e=>{let[t,s]=e;return(0,n.jsx)("option",{value:t,children:s},t)})}),O.length>0&&(0,n.jsx)("optgroup",{label:"保存的视图",children:O.map(e=>(0,n.jsxs)("option",{value:"saved:".concat(e.id),children:[e.name,W===e.id&&V?" *":""]},e.id))})]})]}),(0,n.jsx)("nav",{className:"hidden max-w-full gap-1 lg:flex lg:flex-col","aria-label":"Issue 视图导航",children:eG.map(e=>{let[t,s]=e;return(0,n.jsx)("button",{type:"button","aria-pressed":es===t,onClick:()=>eY(t),className:"h-11 shrink-0 rounded px-3 text-left text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8 sm:px-2.5 ".concat(es===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:s},t)})}),Q&&Z&&G&&Y&&ee&&(0,n.jsx)(tQ,{views:O,activeViewId:W,dirty:V,currentQuery:w,loading:J,error:B,saving:H,onApply:e=>null==X?void 0:X(e),onCreate:Q,onUpdate:Z,onCopy:G,onDelete:Y,onRetry:ee})]}),(0,n.jsxs)("div",{className:"flex min-w-0 max-w-full flex-col overflow-x-hidden",children:[(0,n.jsxs)("div",{"data-localapp-issue-toolbar":!0,"data-testid":"issue-toolbar",className:"flex min-w-0 flex-col gap-2 border-b bg-muted/20 px-4 py-2.5 [&_label:focus-within]:ring-2 [&_label:focus-within]:ring-ring sm:flex-row sm:flex-wrap sm:items-center sm:px-5",children:[(0,n.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,n.jsx)(tE.A,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)(C.p,{ref:I,type:"search","aria-label":"搜索 Issue","aria-keyshortcuts":"Meta+/ Control+/","aria-autocomplete":"list","aria-expanded":e$.length>0,"aria-controls":e$.length>0?eP:void 0,"aria-activedescendant":eS>=0?null==(a=e$[eS])?void 0:a.id:void 0,value:j,onFocus:e=>{var t;null===eR.current&&eI(null!=(t=e.currentTarget.selectionStart)?t:j.length),eN(!0)},onBlur:()=>window.setTimeout(()=>eN(!1),0),onChange:e=>{var t;eR.current=null,D(e.target.value),eI(null!=(t=e.target.selectionStart)?t:e.target.value.length),eA(-1),eN(!0)},onKeyDown:e=>{if("ArrowDown"===e.key&&e$.length>0){e.preventDefault(),eA(e=>(e+1)%e$.length);return}if("ArrowUp"===e.key&&e$.length>0){e.preventDefault(),eA(e=>e<=0?e$.length-1:e-1);return}if(("Enter"===e.key||"Tab"===e.key)&&eS>=0&&e$[eS]){e.preventDefault(),e9(e$[eS]);return}if("Escape"===e.key&&e$.length>0){e.preventDefault(),e.stopPropagation(),eN(!1),eA(-1);return}if("Escape"===e.key&&j){e.preventDefault(),e.stopPropagation(),te();return}"Enter"===e.key&&(e.preventDefault(),eN(!1),z())},placeholder:"搜索 Issues",className:"h-11 min-w-0 pl-8 pr-11 text-xs [&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none sm:h-8 sm:pr-9"}),j&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon","aria-label":"清除 Issue 搜索",className:"absolute right-0 top-0 h-11 w-11 sm:h-8 sm:w-8",onMouseDown:e=>e.preventDefault(),onClick:te,children:(0,n.jsx)(N.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e$.length>0&&(0,n.jsx)("div",{id:eP,role:"listbox","aria-label":"搜索限定词建议",className:"absolute left-0 right-0 top-[calc(100%+4px)] z-[65] max-h-72 overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-lg",children:e$.map((e,t)=>(0,n.jsxs)("button",{id:e.id,type:"button",role:"option","aria-selected":eS===t,"aria-label":"".concat(e.label," ").concat(e.description),onMouseDown:e=>e.preventDefault(),onClick:()=>e9(e),className:"flex min-h-11 w-full min-w-0 items-center gap-3 rounded px-3 py-1.5 text-left sm:min-h-10 sm:px-2.5 ".concat(eS===t?"bg-accent text-accent-foreground":"hover:bg-muted"),children:[(0,n.jsx)("code",{className:"shrink-0 text-xs font-semibold",children:e.value}),(0,n.jsx)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:e.description})]},e.id))})]}),(0,n.jsxs)("button",{type:"button","aria-label":ea>0?"筛选,已启用 ".concat(ea," 项"):"筛选","aria-expanded":el,"aria-controls":"localapp-issue-advanced-filters",onClick:()=>er(e=>!e),className:"flex h-11 w-full items-center justify-between rounded-md border bg-background px-3 text-xs font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:hidden",children:[(0,n.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,n.jsx)(t_.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"筛选"]}),ea>0&&(0,n.jsx)("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:ea})]}),(0,n.jsxs)("div",{id:"localapp-issue-advanced-filters","data-testid":"issue-advanced-filters",className:"".concat(el?"grid":"hidden"," min-w-0 grid-cols-1 gap-2 min-[360px]:grid-cols-2 sm:contents [&>label]:min-w-0"),children:[(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(t_.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按类型筛选"}),(0,n.jsxs)("select",{"aria-label":"按类型筛选",value:w.issueType,onChange:e=>T({issueType:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部类型"}),(0,n.jsx)("option",{value:"task",children:"任务"}),(0,n.jsx)("option",{value:"bug",children:"缺陷"}),(0,n.jsx)("option",{value:"feature",children:"功能"})]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(t_.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按标签筛选"}),(0,n.jsxs)("select",{"aria-label":"按标签筛选","aria-keyshortcuts":"L",value:w.label,onChange:e=>T({label:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部标签"}),(0,n.jsx)("option",{value:"none",children:"无标签"}),p.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),"closed"===w.status&&(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(tC.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按关闭原因筛选"}),(0,n.jsxs)("select",{"aria-label":"按关闭原因筛选",value:w.reason,onChange:e=>T({reason:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部关闭原因"}),(0,n.jsx)("option",{value:"completed",children:"已完成"}),(0,n.jsx)("option",{value:"not_planned",children:"不计划处理"})]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(tT.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按创建者筛选"}),(0,n.jsxs)("select",{"aria-label":"按创建者筛选","aria-keyshortcuts":"U",value:w.author,onChange:e=>T({author:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部创建者"}),w.author&&!b.some(e=>e.id===w.author)&&(0,n.jsx)("option",{value:w.author,children:w.author}),b.map(e=>(0,n.jsx)("option",{value:e.id,children:e.displayName||e.name||e.id},e.id))]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(tT.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按负责人筛选"}),(0,n.jsxs)("select",{"aria-label":"按负责人筛选","aria-keyshortcuts":"A",value:w.assignee,onChange:e=>T({assignee:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部负责人"}),(0,n.jsx)("option",{value:"none",children:"未分配"}),b.map(e=>(0,n.jsx)("option",{value:e.id,children:e.displayName||e.name||e.id},e.id))]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(y.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按里程碑筛选"}),(0,n.jsxs)("select",{"aria-label":"按里程碑筛选","aria-keyshortcuts":"M",value:w.milestone,onChange:e=>T({milestone:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部里程碑"}),(0,n.jsx)("option",{value:"none",children:"无里程碑"}),w.milestone&&"none"!==w.milestone&&!f.some(e=>String(e.id)===w.milestone)&&(0,n.jsxs)("option",{value:w.milestone,children:["里程碑 #",w.milestone]}),f.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title,"closed"===e.state?"(已关闭)":""]},e.id))]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(tL.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"排序 Issue"}),(0,n.jsxs)("select",{"aria-label":"排序 Issue",value:"".concat(w.sort,":").concat(w.direction),onChange:e=>{let[t,s]=e.target.value.split(":");T({sort:t,direction:s})},className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"activity:desc",children:"最近活动"}),(0,n.jsx)("option",{value:"created:desc",children:"最新创建"}),(0,n.jsx)("option",{value:"created:asc",children:"最早创建"}),(0,n.jsx)("option",{value:"updated:desc",children:"最近更新"}),(0,n.jsx)("option",{value:"comments:desc",children:"评论最多"})]})]})]})]}),eW.length>0&&(0,n.jsxs)("div",{role:"region","aria-label":"已应用筛选",className:"flex min-w-0 flex-wrap items-center gap-1.5 border-b bg-muted/10 px-4 py-2 sm:px-5",children:[eW.map(e=>(0,n.jsxs)("button",{type:"button","aria-label":"移除".concat(e.kind,"筛选 ").concat(e.value),onClick:()=>{var t;T("subscribed"===(t=e.key)?{subscribed:!1}:"mentioned"===t?{mentioned:!1}:{[t]:""}),window.requestAnimationFrame(()=>{var e;return null==I||null==(e=I.current)?void 0:e.focus()})},className:"inline-flex h-11 max-w-full min-w-0 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-7 sm:px-2",children:[(0,n.jsxs)("span",{className:"truncate",children:[(0,n.jsxs)("strong",{className:"font-medium text-foreground",children:[e.kind,":"]})," ",e.value]}),(0,n.jsx)(N.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"})]},e.key)),(0,n.jsx)("button",{type:"button",onClick:e0,"aria-label":"清除全部筛选",className:"h-11 shrink-0 rounded px-3 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-7 sm:px-2",children:"清除全部"})]}),eO&&(0,n.jsxs)("section",{"data-localapp-pinned-issues":!0,"aria-labelledby":"localapp-pinned-issues-title",className:"border-b bg-muted/10 px-4 py-3 sm:px-5",children:[(0,n.jsxs)("h3",{id:"localapp-pinned-issues-title",className:"mb-2 flex items-center gap-1.5 text-xs font-semibold text-muted-foreground",children:[(0,n.jsx)(tR.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"置顶 Issues"]}),(0,n.jsx)("div",{className:"grid min-w-0 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:h.map(e=>{var t,s,a;return(0,n.jsxs)("article",{className:"min-w-0 rounded-[6px] border bg-card px-3 py-3",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,n.jsx)(tG,{issue:e,className:"mt-1 h-4 w-4 shrink-0"}),(0,n.jsx)("a",{href:_(e),"aria-label":"#".concat(e.issue_number," ").concat(e.title),onClick:t=>e2(t,e),className:"min-h-6 min-w-0 flex-1 break-words font-semibold leading-6 hover:text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:e.title})]}),(0,n.jsxs)("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[(0,n.jsxs)("span",{children:["#",e.issue_number]}),(0,n.jsx)("button",{type:"button",onClick:()=>{var t;return T({issueType:null!=(t=e.issue_type)?t:e.label,offset:0})},className:"rounded border px-1.5 py-0.5 font-medium text-foreground hover:bg-muted",children:ei[null!=(s=e.issue_type)?s:e.label]}),null==(t=e.labels)?void 0:t.map(e=>(0,n.jsx)(tP,{label:e},e.id)),!!e.is_duplicate&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,n.jsx)(S.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"重复"]}),!!e.is_blocked&&(0,n.jsxs)("span",{"aria-label":"已阻塞:存在未解决依赖",title:"已阻塞:存在未解决依赖",className:"inline-flex items-center gap-1 text-destructive",children:[(0,n.jsx)(tD.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"已阻塞"]}),(null!=(a=e.comment_count)?a:0)>0&&(0,n.jsxs)("span",{children:[e.comment_count," 条评论"]}),(0,n.jsx)(tY,{issue:e})]})]},e.id)})})]}),(0,n.jsxs)("div",{className:"flex min-h-11 flex-wrap items-center justify-between gap-x-3 gap-y-1 border-b px-4 py-2 sm:px-5",children:[(0,n.jsxs)("div",{className:"inline-flex min-w-0 items-center gap-1",children:[q&&(0,n.jsx)("label",{className:"-my-2 -ml-2 inline-flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded focus-within:ring-2 focus-within:ring-ring sm:-my-0 sm:-ml-1 sm:h-6 sm:w-6",children:(0,n.jsx)("input",{ref:eC,type:"checkbox","aria-label":"选择当前页全部 Issue",checked:eQ,disabled:g||ed||0===m.length,onChange:e=>{var t;return t=e.target.checked,void(eE.current=null,ec(t?new Set(m.map(e=>e.id)):new Set))},className:"h-4 w-4"})}),(0,n.jsxs)("button",{type:"button","aria-label":"开启 ".concat(v.open),"aria-pressed":"open"===w.status,onClick:()=>e1("open"),className:"inline-flex h-11 items-center gap-1.5 rounded px-3 text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8 sm:px-2 ".concat("open"===w.status?"text-foreground":"text-muted-foreground"),children:[(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"}),"开启 ",v.open]}),(0,n.jsxs)("button",{type:"button","aria-label":"已关闭 ".concat(v.closed),"aria-pressed":"closed"===w.status,onClick:()=>e1("closed"),className:"inline-flex h-11 items-center gap-1.5 rounded px-3 text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8 sm:px-2 ".concat("closed"===w.status?"text-foreground":"text-muted-foreground"),children:[(0,n.jsx)(M.A,{className:"h-4 w-4","aria-hidden":"true"}),"已关闭 ",v.closed]})]}),(0,n.jsx)("span",{role:"status","aria-live":"polite",className:"inline-flex min-h-5 items-center gap-1.5 text-sm text-muted-foreground",children:eV?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(A.A,{className:"h-3.5 w-3.5 motion-safe:animate-spin","aria-hidden":"true"}),"正在更新结果"]}):"".concat(v.total," 个结果")})]}),q&&(0,n.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true","aria-label":"Issue 选择状态",className:"sr-only",children:eX>0?"已选择 ".concat(eX," 条 Issue"):"未选择 Issue"}),q&&eX>0&&(0,n.jsxs)("div",{"data-localapp-issue-bulk-toolbar":!0,role:"toolbar","aria-label":"批量 Issue 操作",onFocusCapture:()=>{eT.current=!0},onBlurCapture:e=>{let t=e.currentTarget;window.requestAnimationFrame(()=>{t.isConnected&&!t.contains(document.activeElement)&&(eT.current=!1)})},className:"flex min-h-11 flex-wrap items-center gap-2 border-b bg-muted/30 px-4 py-2 sm:px-5",children:[(0,n.jsxs)("strong",{className:"mr-auto text-sm",children:["已选择 ",eX," 条"]}),(0,n.jsxs)("label",{className:"inline-flex h-11 items-center rounded-md border bg-background px-2 text-xs sm:h-7",children:[(0,n.jsx)("span",{className:"sr-only",children:"批量类型操作"}),(0,n.jsxs)("select",{"aria-label":"批量类型操作",value:ep,disabled:ed,onChange:e=>{let t=e.target.value;ef(t),e5(t)},className:"h-full bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",disabled:!0,children:"类型"}),(0,n.jsx)("option",{value:"task",children:"任务"}),(0,n.jsx)("option",{value:"bug",children:"缺陷"}),(0,n.jsx)("option",{value:"feature",children:"功能"})]})]}),(0,n.jsxs)("label",{className:"inline-flex h-11 items-center rounded-md border bg-background px-2 text-xs sm:h-7",children:[(0,n.jsx)("span",{className:"sr-only",children:"批量标签操作"}),(0,n.jsxs)("select",{"aria-label":"批量标签操作",value:ex,disabled:ed,onChange:e=>{let t=e.target.value;eb(t),e8(t)},className:"h-full bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",disabled:!0,children:"标签"}),(0,n.jsx)("optgroup",{label:"添加标签",children:p.map(e=>(0,n.jsxs)("option",{value:"add:".concat(e.id),children:["添加:",e.name]},"add-".concat(e.id)))}),(0,n.jsx)("optgroup",{label:"移除标签",children:p.map(e=>(0,n.jsxs)("option",{value:"remove:".concat(e.id),children:["移除:",e.name]},"remove-".concat(e.id)))})]})]}),(0,n.jsxs)("label",{className:"inline-flex h-11 items-center rounded-md border bg-background px-2 text-xs sm:h-7",children:[(0,n.jsx)("span",{className:"sr-only",children:"批量负责人操作"}),(0,n.jsxs)("select",{"aria-label":"批量负责人操作",value:eg,disabled:ed,onChange:e=>{let t=e.target.value;ev(t),e6(t)},className:"h-full bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",disabled:!0,children:"负责人"}),(0,n.jsx)("optgroup",{label:"添加负责人",children:b.map(e=>(0,n.jsxs)("option",{value:"add:".concat(e.id),children:["添加:",e.displayName||e.name||e.id]},"add-".concat(e.id)))}),(0,n.jsx)("optgroup",{label:"移除负责人",children:b.map(e=>(0,n.jsxs)("option",{value:"remove:".concat(e.id),children:["移除:",e.displayName||e.name||e.id]},"remove-".concat(e.id)))})]})]}),(0,n.jsxs)("label",{className:"inline-flex h-11 items-center rounded-md border bg-background px-2 text-xs sm:h-7",children:[(0,n.jsx)("span",{className:"sr-only",children:"批量里程碑操作"}),(0,n.jsxs)("select",{"aria-label":"批量里程碑操作",value:ey,disabled:ed,onChange:e=>{let t=e.target.value;ew(t),e7(t)},className:"h-full bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",disabled:!0,children:"里程碑"}),(0,n.jsx)("option",{value:"none",children:"清除里程碑"}),f.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title,"closed"===e.state?"(已关闭)":""]},e.id))]})]}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-7",disabled:ed,onClick:()=>void e3("open"===w.status?"closed":"open"),children:"open"===w.status?"关闭所选":"重新打开所选"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-7",disabled:ed,onClick:()=>{eE.current=null,ec(new Set),eh(""),window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})},children:"清除选择"})]}),(0,n.jsx)("span",{"aria-live":"polite",className:"sr-only",children:ed?"正在更新 ".concat(eX," 条 Issue"):em}),em&&(0,n.jsx)("div",{role:eX>0?"alert":"status",className:"border-b bg-muted/20 px-4 py-2 text-xs text-muted-foreground sm:px-5",children:em}),u&&m.length>0&&(0,n.jsxs)("div",{role:"alert",className:"flex items-center justify-between gap-3 border-b border-destructive/20 bg-destructive/10 px-4 py-2.5 text-sm text-destructive sm:px-5",children:[(0,n.jsxs)("span",{children:["显示上次结果:",u]}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-7",onClick:R,children:"重试"})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","aria-busy":g,children:g&&0===m.length?(0,n.jsxs)("div",{"aria-label":"正在加载 Issue",role:"status",className:"space-y-0",children:[(0,n.jsx)("span",{className:"sr-only",children:"正在加载 Issue 列表"}),Array.from({length:6},(e,t)=>(0,n.jsxs)("div",{className:"flex h-[76px] items-start gap-3 border-b px-4 py-3 motion-safe:animate-pulse sm:px-5",children:[(0,n.jsx)("span",{className:"mt-1 h-4 w-4 rounded-full bg-muted"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block h-4 w-2/3 rounded bg-muted"}),(0,n.jsx)("span",{className:"mt-3 block h-3 w-1/2 rounded bg-muted/70"})]}),(0,n.jsx)("span",{className:"h-4 w-8 rounded bg-muted/70"})]},t))]}):u&&0===m.length?(0,n.jsxs)("div",{role:"alert",className:"flex min-h-[280px] flex-col items-center justify-center px-6 text-center",children:[(0,n.jsx)(tD.A,{className:"h-9 w-9 text-destructive","aria-hidden":"true"}),(0,n.jsx)("p",{className:"mt-3 text-sm font-semibold",children:"无法加载 Issues"}),(0,n.jsx)("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:u}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"mt-4 h-11 sm:h-8",onClick:R,children:"重试"})]}):0===m.length?(0,n.jsxs)("div",{className:"flex min-h-[260px] flex-col items-center justify-center px-6 text-center",children:[(0,n.jsx)(tZ,{status:w.status,className:"h-8 w-8"}),(0,n.jsx)("p",{className:"mt-3 text-sm font-medium",children:eJ?"当前页已无 Issue":eK?"当前筛选没有匹配的 Issue":"此应用还没有".concat("open"===w.status?"开启":"已关闭","的 Issue")}),eJ?(0,n.jsx)(x.$,{ref:eU,type:"button",variant:"outline",size:"sm",className:"mt-4 h-11 sm:h-8",onClick:()=>T({offset:0}),children:"返回第一页"}):eK&&(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"mt-4 h-11 sm:h-8",onClick:e0,children:"重置筛选"})]}):(0,n.jsx)("div",{ref:eq,id:"localapp-issue-results",role:"list","aria-label":"".concat("open"===w.status?"开启":"已关闭","的 Issues"),"aria-busy":eV,"data-stale":eV?"true":void 0,children:m.map((e,t)=>{var s,a,l,r,i;return(0,n.jsxs)("article",{"data-localapp-issue-row":!0,"data-testid":"issue-row-".concat(e.id),role:"listitem","aria-posinset":v.offset+t+1,"aria-setsize":v.total,className:"flex min-w-0 gap-3 border-b px-4 py-3 last:border-b-0 hover:bg-muted/25 focus-within:bg-muted/25 sm:px-5",children:[q&&(0,n.jsx)("label",{className:"-my-2 -ml-2 inline-flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded focus-within:ring-2 focus-within:ring-ring sm:-my-0 sm:-ml-1 sm:h-6 sm:w-6",children:(0,n.jsx)("input",{type:"checkbox","aria-label":"选择 Issue #".concat(e.issue_number),checked:eo.has(e.id),disabled:ed,readOnly:!0,onFocus:()=>{e_.current=e.id},onBlur:e=>{e.currentTarget.isConnected&&(e_.current=null)},onKeyDown:t=>{" "===t.key&&(t.preventDefault(),e4(e.id,!eo.has(e.id),!1))},onClick:t=>e4(e.id,t.currentTarget.checked,t.shiftKey&&t.detail>0),className:"h-4 w-4"})}),(0,n.jsx)(tG,{issue:e,className:"mt-1 h-4 w-4 shrink-0"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("a",{href:_(e),"data-localapp-issue-link":!0,"aria-label":"#".concat(e.issue_number," ").concat(e.title),"aria-keyshortcuts":"J K ArrowDown ArrowUp O Enter",onClick:t=>e2(t,e),className:"flex min-h-11 max-w-full items-center rounded-sm break-words text-left text-base font-semibold leading-6 text-foreground hover:text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:min-h-6",children:e.title}),(0,n.jsxs)("div",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-sm leading-5 text-muted-foreground",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{var t;return T({issueType:null!=(t=e.issue_type)?t:e.label,offset:0})},className:"rounded border px-1.5 py-0.5 text-xs font-medium text-foreground hover:bg-muted",children:ei[null!=(a=e.issue_type)?a:e.label]}),(null!=(l=e.labels)?l:[]).map(e=>(0,n.jsx)(tP,{label:e,onSelect:e=>T({label:e,offset:0})},e.id)),!!e.is_duplicate&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,n.jsx)(S.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"重复"]}),e.locked_at&&(0,n.jsx)("span",{"aria-label":"对话已锁定",title:"对话已锁定",className:"inline-flex items-center",children:(0,n.jsx)(tz.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),!!e.is_blocked&&(0,n.jsxs)("span",{"aria-label":"已阻塞:存在未解决依赖",title:"已阻塞:存在未解决依赖",className:"inline-flex items-center gap-1 text-destructive",children:[(0,n.jsx)(tD.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"已阻塞"]}),(0,n.jsx)(t1,{milestone:f.find(t=>t.id===e.milestone_id),onSelect:e=>T({milestone:String(e),offset:0})}),(0,n.jsxs)("span",{children:["#",e.issue_number]}),(0,n.jsx)("button",{type:"button","aria-label":"按创建者筛选 ".concat(eH(e.reporter_id)),title:"".concat(eH(e.reporter_id)," @").concat(e.reporter_id),onClick:()=>T({author:e.reporter_id,offset:0}),className:"min-h-6 max-w-full rounded-sm break-words text-left hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:eH(e.reporter_id)}),(0,n.jsx)(tY,{issue:e}),(null==(s=e.participant_ids)?void 0:s.length)?(0,n.jsxs)("span",{className:"hidden sm:inline",children:[e.participant_ids.length," 位参与者"]}):null]})]}),(0,n.jsx)(t0,{ids:null!=(r=e.assignee_ids)?r:[],users:b,onSelect:e=>T({assignee:e,offset:0})}),(null!=(i=e.comment_count)?i:0)>0?(0,n.jsxs)("a",{href:_(e),"aria-label":"".concat(e.issue_number," 的评论数 ").concat(e.comment_count),onClick:t=>e2(t,e),className:"-my-2 inline-flex h-11 w-11 shrink-0 items-center justify-center gap-1 rounded-sm text-sm leading-5 text-muted-foreground hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:-my-0 sm:h-6 sm:w-10",children:[(0,n.jsx)(k.A,{className:"h-4 w-4","aria-hidden":"true"}),e.comment_count]}):(0,n.jsx)("span",{"aria-hidden":"true",className:"h-11 w-11 shrink-0 sm:h-6 sm:w-10"})]},e.id)})})}),(0,n.jsxs)("div",{className:"flex min-h-11 items-center justify-between border-t px-4 text-xs text-muted-foreground sm:px-5",children:[(0,n.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true","aria-label":0===m.length?"当前没有可显示的 Issue,共 ".concat(v.total," 条 Issue"):"当前显示第 ".concat(v.offset+1," 至 ").concat(Math.min(v.offset+m.length,v.total)," 条,共 ").concat(v.total," 条 Issue"),children:0===m.length?"0 / ".concat(v.total):"".concat(v.offset+1,"-").concat(Math.min(v.offset+m.length,v.total)," / ").concat(v.total)}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"上一页","aria-controls":"localapp-issue-results",disabled:0===w.offset,onClick:()=>eB(Math.max(0,w.offset-w.limit)),children:(0,n.jsx)(tq.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"下一页","aria-controls":"localapp-issue-results",disabled:w.offset+w.limit>=v.total,onClick:()=>eB(w.offset+w.limit),children:(0,n.jsx)(tU.A,{className:"h-4 w-4"})})]})]})]})]})}var t4=s(7528),t3=s(507),t5=s(760),t8=s(289);function t6(e,t){var s,n;let a=new Map(t.map(e=>[e.id,e])).get(e);return a?{...a,displayName:(null==(s=a.displayName)?void 0:s.trim())||(null==(n=a.name)?void 0:n.trim())||a.id||"未知用户",avatarUrl:a.avatarUrl||null}:{id:e,displayName:e||"未知用户",avatarUrl:null}}function t7(e){var t,s;let{identity:a,timestamp:r,timestampHref:i,timestampSuffix:o,badge:c,action:d}=e,u=(null==(t=a.displayName)?void 0:t.trim())||(null==(s=a.name)?void 0:s.trim())||a.id||"未知用户",m="Author"===c?"作者":c,h=(0,l.isValidElement)(o)&&"edited"===o.props.children?(0,l.cloneElement)(o,{children:"已编辑"}):o;return(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[a.avatarUrl?(0,n.jsx)("img",{src:a.avatarUrl,alt:"",className:"h-8 w-8 shrink-0 rounded-full object-cover"}):(0,n.jsx)("span",{"aria-hidden":"true",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground",children:function(e){var t,s;if(!e.id.trim())return"?";let n=(null==(t=e.displayName)?void 0:t.trim())||(null==(s=e.name)?void 0:s.trim())||e.id.trim();return n?Array.from(n)[0].toLocaleUpperCase():"?"}(a)}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 text-xs leading-5",children:[(0,n.jsxs)("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2",children:[(0,n.jsx)("strong",{className:"break-words text-sm font-semibold text-foreground",children:u}),(0,n.jsxs)("span",{className:"break-all text-muted-foreground",children:["@",a.id||"未知"]}),m&&(0,n.jsx)("span",{className:"shrink-0 rounded-full border px-1.5 text-[10px] font-medium leading-4 text-muted-foreground",children:m})]}),r&&(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-1.5",children:[(0,n.jsx)(tB,{timestamp:r,href:i,className:"text-muted-foreground hover:underline"}),h]})]}),d&&(0,n.jsx)("div",{"data-localapp-issue-actor-action":!0,className:"shrink-0 self-start",children:d})]})}function t9(e){let{label:t,accessibleLabel:s,items:a,selectedIds:r,disabled:i=!1,onToggle:o}=e,[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(""),[h,p]=(0,l.useState)(null),[f,b]=(0,l.useState)(null),g=(0,l.useRef)(null),v=(0,l.useRef)(null),y=(0,l.useRef)(null),w=(0,l.useRef)([]),j=(0,l.useId)(),N=null!=s?s:"Labels"===t?"标签":"Assignees"===t?"负责人":t,k="编辑".concat(N),S="选择".concat(N),A="搜索".concat(N),C=(0,l.useMemo)(()=>new Set(r),[r]),E=(0,l.useMemo)(()=>{let e=u.trim().toLocaleLowerCase();return e?a.filter(t=>{var s;return"".concat(t.label,"\n").concat(t.id,"\n").concat(null!=(s=t.description)?s:"").toLocaleLowerCase().includes(e)}):a},[a,u]);(0,l.useEffect)(()=>{if(!c)return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=y.current)?void 0:e.focus()}),t=e=>{var t;(null==(t=g.current)?void 0:t.contains(e.target))||d(!1)};return document.addEventListener("mousedown",t),()=>{window.cancelAnimationFrame(e),document.removeEventListener("mousedown",t)}},[c]);let _=async e=>{if(!h&&!i){b(null),p(e.id);try{await o(e.id,!C.has(e.id))}catch(e){b(e instanceof Error?e.message:"".concat(N,"更新失败"))}finally{p(null)}}};return(0,n.jsxs)("div",{ref:g,className:"relative",children:[(0,n.jsx)(x.$,{ref:v,type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-7 sm:w-7","aria-label":k,title:k,"aria-haspopup":"dialog","aria-expanded":c,"aria-controls":c?j:void 0,disabled:i,onClick:()=>{d(e=>!e),m(""),b(null)},children:(0,n.jsx)(td.A,{className:"h-3.5 w-3.5"})}),c&&(0,n.jsxs)("div",{id:j,role:"dialog","aria-label":S,onKeyDown:e=>{var t;if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),d(!1),m(""),b(null),window.requestAnimationFrame(()=>{var e;return null==(e=v.current)?void 0:e.focus()});return}if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key)||0===E.length)return;let s=w.current.findIndex(e=>e===document.activeElement),n=s;n="Home"===e.key?0:"End"===e.key?E.length-1:"ArrowDown"===e.key?s<0?0:(s+1)%E.length:s<0?E.length-1:(s-1+E.length)%E.length,e.preventDefault(),null==(t=w.current[n])||t.focus()},className:"absolute right-0 top-12 z-40 w-[min(320px,calc(100vw-2rem))] overflow-hidden rounded-[6px] border bg-popover text-popover-foreground shadow-lg sm:top-8",children:[(0,n.jsxs)("div",{className:"relative border-b p-2",children:[(0,n.jsx)(tE.A,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)("input",{ref:y,type:"search",role:"searchbox","aria-label":A,value:u,onChange:e=>m(e.target.value),className:"h-11 w-full rounded border bg-background pl-8 pr-2 text-sm outline-none focus:ring-2 focus:ring-ring sm:h-8"})]}),f&&(0,n.jsx)("div",{role:"alert",className:"mx-2 mt-2 rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:f}),(0,n.jsx)("div",{className:"max-h-64 overflow-y-auto p-1",children:0===E.length?(0,n.jsx)("p",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:"没有匹配项"}):E.map((e,t)=>(0,n.jsxs)("label",{className:"flex min-h-11 cursor-pointer items-center gap-2 rounded px-2 py-1.5 hover:bg-muted focus-within:bg-muted focus-within:ring-2 focus-within:ring-ring",children:[(0,n.jsx)("input",{ref:e=>{w.current[t]=e},type:"checkbox",className:"sr-only","aria-label":e.label,checked:C.has(e.id),disabled:i||null!==h,onChange:()=>void _(e)}),(0,n.jsx)("span",{"aria-hidden":"true",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",children:C.has(e.id)&&(0,n.jsx)(I.A,{className:"h-3 w-3"})}),e.leading,(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block truncate text-sm font-medium",children:e.label}),(0,n.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description||e.id})]})]},e.id))})]})]})}var se=s(2914),st=s(535),ss=s(8210);let sn={"+1":"\uD83D\uDC4D","-1":"\uD83D\uDC4E",laugh:"\uD83D\uDE04",hooray:"\uD83C\uDF89",confused:"\uD83D\uDE15",heart:"❤️",rocket:"\uD83D\uDE80",eyes:"\uD83D\uDC40"};function sa(e){let{reactions:t,commentId:s=0,currentUserId:a,disabled:r=!1,additionsDisabled:i=!1,onToggle:o}=e,[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),[h,p]=(0,l.useState)(""),f=(0,l.useRef)(null),b=(0,l.useRef)(null),g=(0,l.useRef)([]),v=t.filter(e=>e.comment_id===s),y=ed.map(e=>({content:e,entries:v.filter(t=>t.content===e)})).filter(e=>e.entries.length>0),w=async(e,t)=>{m(e),p("");try{await o(e,t,0===s?void 0:s),j(!0)}catch(e){p(e instanceof Error?e.message:"表态更新失败")}finally{m(null)}},j=e=>{d(!1),p(""),e&&window.requestAnimationFrame(()=>{var e;return null==(e=b.current)?void 0:e.focus()})};return((0,l.useEffect)(()=>{(i||!a)&&d(!1),(i||!a)&&p("")},[i,a]),(0,l.useEffect)(()=>{if(!c)return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=g.current[0])?void 0:e.focus()}),t=e=>{var t;e.target instanceof Node&&!(null==(t=f.current)?void 0:t.contains(e.target))&&j(!0)};return document.addEventListener("mousedown",t),()=>{window.cancelAnimationFrame(e),document.removeEventListener("mousedown",t)}},[c]),a||0!==y.length)?(0,n.jsxs)("div",{ref:f,className:"relative mt-3 flex flex-wrap items-center gap-1.5","data-localapp-issue-reactions":!0,children:[h&&(0,n.jsx)("p",{role:"alert",className:"w-full text-xs text-destructive",children:h}),y.map(e=>{let{content:t,entries:s}=e,l=!!(a&&s.some(e=>e.user_id===a)),o="".concat(sn[t]," ").concat(s.length," 个表态");return a?(0,n.jsxs)(x.$,{type:"button",variant:l?"secondary":"outline",size:"sm",className:"h-11 min-w-11 gap-1 rounded-full px-3 text-xs sm:h-7 sm:min-w-10 sm:px-2.5","aria-label":o,"aria-pressed":l,disabled:r||null!==u||i&&!l,onClick:()=>void w(t,!l),children:[(0,n.jsx)("span",{"aria-hidden":"true",children:sn[t]}),(0,n.jsx)("span",{children:s.length})]},t):(0,n.jsxs)("span",{"aria-label":o,className:"inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-full border px-3 text-xs sm:h-7 sm:min-w-10 sm:px-2.5",children:[(0,n.jsx)("span",{"aria-hidden":"true",children:sn[t]}),(0,n.jsx)("span",{children:s.length})]},t)}),a&&!i&&(0,n.jsx)(x.$,{ref:b,type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 rounded-full sm:h-7 sm:w-7","aria-label":"添加表态","aria-haspopup":"menu","aria-expanded":c,disabled:r||null!==u,onClick:()=>d(e=>!e),children:(0,n.jsx)(ss.A,{className:"h-4 w-4"})}),c&&a&&!i&&(0,n.jsx)("div",{className:"absolute bottom-12 left-0 z-20 grid grid-cols-4 gap-1 rounded-md border bg-popover p-1.5 shadow-lg sm:bottom-9",role:"menu","aria-label":"选择表态",onKeyDown:e=>{var t;if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),j(!0);return}if(!["ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(e.key))return;let s=g.current.filter(e=>!!(e&&!e.disabled));if(!s.length)return;let n=Math.max(0,s.indexOf(document.activeElement)),a="ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:"ArrowDown"===e.key?4:"ArrowUp"===e.key?-4:0,l="Home"===e.key?0:"End"===e.key?s.length-1:(n+a+s.length)%s.length;e.preventDefault(),e.stopPropagation(),null==(t=s[l])||t.focus()},children:ed.map((e,t)=>{let s=v.some(t=>t.content===e&&t.user_id===a);return(0,n.jsx)("button",{ref:e=>{g.current[t]=e},type:"button",role:"menuitemcheckbox","aria-checked":s,"aria-label":"".concat(s?"取消":"添加"," ").concat(sn[e]," 表态"),disabled:r||null!==u,className:"flex h-11 w-11 items-center justify-center rounded outline-none hover:bg-muted focus:bg-muted focus:ring-2 focus:ring-ring sm:h-8 sm:w-8 ".concat(s?"bg-muted":""),onClick:()=>void w(e,!s),children:sn[e]},e)})})]}):null}let sl="localappIssueId",sr="localappIssueNumber",si="localappIssueCommentId",so="localappIssues";function sc(e,t){let s=e.searchParams.get(t);if(!s||!/^\d+$/.test(s))return null;let n=Number(s);return Number.isSafeInteger(n)&&n>0?n:null}function sd(e){return"1"===e.searchParams.get(so)||null!==sc(e,sl)||null!==sc(e,sr)}function su(e,t){let s=new URL(e.href);return t?s.searchParams.set(so,"1"):(s.searchParams.delete(so),s.searchParams.delete(sl),s.searchParams.delete(sr),s.searchParams.delete(si)),s}function sm(e,t){let s=new URL(e.href);return s.searchParams.set(so,"1"),null===t?s.searchParams.delete(sl):s.searchParams.set(sl,String(t)),s.searchParams.delete(sr),s.searchParams.delete(si),s}function sh(e,t){let s=new URL(e.href);return s.searchParams.set(so,"1"),s.searchParams.delete(sl),s.searchParams.set(sr,String(t)),s.searchParams.delete(si),s}function sp(e,t,s){let n=new URL(e.href);return n.searchParams.set(so,"1"),n.searchParams.set(sl,String(t)),n.searchParams.delete(sr),n.searchParams.set(si,String(s)),n}async function sf(e){var t;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;if(!(()=>{let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let s="function"==typeof document.execCommand&&document.execCommand("copy");return t.remove(),s})()){if(!(null==(t=navigator.clipboard)?void 0:t.writeText))throw Error("Clipboard write failed");await Promise.race([navigator.clipboard.writeText(e),new Promise((e,t)=>window.setTimeout(()=>t(Error("Clipboard write timed out")),s))])}}function sx(e,t){let s=function(e){if(!e.includes("/api/issues/attachments/"))return new Set;let t=(0,X.l)().use(Q.A).use(W.A).parse(e),s=new Set,n=e=>{var t;if(("image"===e.type||"link"===e.type)&&"string"==typeof e.url){let t=function(e){try{let t=new URL(e,"https://localapp.local"),s=/^\/api\/issues\/attachments\/([^/]+)$/.exec(t.pathname);return s?decodeURIComponent(s[1]):null}catch(e){return null}}(e.url);t&&s.add(t)}for(let s of null!=(t=e.children)?t:[])n(s)};return n(t),s}(e);return 0===s.size?[...t]:t.filter(e=>!s.has(e.id))}var sb=s(5230);function sg(e){let{reference:t,actorName:s,href:a,onOpen:l}=e,r="来源 Issue #".concat(t.source_issue_number," ").concat(t.source_issue_title).concat(null===t.source_comment_id?"":",评论 ".concat(t.source_comment_id));return(0,n.jsx)("li",{"data-localapp-issue-cross-reference":!0,className:"relative min-w-0 py-2 pl-3 text-xs text-muted-foreground before:absolute before:bottom-0 before:left-[19px] before:top-0 before:w-px before:bg-border",children:(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,n.jsx)("span",{className:"relative z-10 mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-card",children:(0,n.jsx)(sb.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("p",{className:"break-words",children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:s})," 在 ",(0,n.jsxs)("a",{href:a,"aria-label":r,className:"font-semibold text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:e=>{!l||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),l(t.source_issue_number,t.source_comment_id))},children:["#",t.source_issue_number," ",t.source_issue_title]})," 中提到了此 Issue ",(0,n.jsx)(tB,{timestamp:t.created_at})]}),t.excerpt&&(0,n.jsx)("p",{className:"mt-1 line-clamp-2 break-words border-l-2 pl-2 text-muted-foreground",children:t.excerpt})]})]})})}function sv(e,t){try{let s=JSON.parse(e)[t];return"number"==typeof s&&Number.isSafeInteger(s)?s:null}catch(e){return null}}function sy(e,t){var s,n,a,l,r,i,o,c,d,u,m,h;let p=e.event;if("opened"===p.event_type)return"打开了此 Issue";if("closed"===p.event_type)try{return(null==(s=JSON.parse(p.payload_json))?void 0:s.stateReason)==="not_planned"?"以不计划处理关闭了此 Issue":"以已完成关闭了此 Issue"}catch(e){return"以已完成关闭了此 Issue"}if("reopened"===p.event_type)return"重新打开了此 Issue";if("edited"===p.event_type)return"编辑了此 Issue";if("labels_changed"===p.event_type)return"更新了标签";if("assignees_changed"===p.event_type){let{added:e,removed:s}=function(e){try{let t=JSON.parse(e),s=Array.isArray(t.from)?t.from.filter(e=>"string"==typeof e).slice(0,20):[],n=Array.isArray(t.to)?t.to.filter(e=>"string"==typeof e).slice(0,20):[];return{added:n.filter(e=>!s.includes(e)),removed:s.filter(e=>!n.includes(e))}}catch(e){return{added:[],removed:[]}}}(p.payload_json);return 1===e.length&&0===s.length?"将 ".concat(t6(e[0],t).displayName," 设为负责人"):1===s.length&&0===e.length?"取消了 ".concat(t6(s[0],t).displayName," 的负责人"):"更新了负责人"}if("subscribed"===p.event_type)return"订阅了此 Issue";if("unsubscribed"===p.event_type)return"取消订阅了此 Issue";if("locked"===p.event_type)try{let e=null==(n=JSON.parse(p.payload_json))?void 0:n.reason;return e&&eo[e]?"锁定了对话(".concat(eo[e],")"):"锁定了对话"}catch(e){return"锁定了对话"}return"unlocked"===p.event_type?"解锁了对话":"pinned"===p.event_type?"置顶了此 Issue":"unpinned"===p.event_type?"取消置顶了此 Issue":"comment_pinned"===p.event_type?"置顶了评论 #".concat(null!=(a=sv(p.payload_json,"commentId"))?a:"?"):"comment_unpinned"===p.event_type?"取消置顶了评论 #".concat(null!=(l=sv(p.payload_json,"commentId"))?l:"?"):"comment_minimized"===p.event_type?"最小化了评论 #".concat(null!=(r=sv(p.payload_json,"commentId"))?r:"?"):"comment_unminimized"===p.event_type?"恢复了评论 #".concat(null!=(i=sv(p.payload_json,"commentId"))?i:"?"):"sub_issue_added"===p.event_type?"添加了 Sub-issue #".concat(null!=(o=sv(p.payload_json,"childIssueNumber"))?o:"?"):"sub_issue_removed"===p.event_type?"移除了 Sub-issue #".concat(null!=(c=sv(p.payload_json,"childIssueNumber"))?c:"?"):"parent_added"===p.event_type?"设置了父 Issue #".concat(null!=(d=sv(p.payload_json,"parentIssueNumber"))?d:"?"):"parent_removed"===p.event_type?"移除了父 Issue #".concat(null!=(u=sv(p.payload_json,"parentIssueNumber"))?u:"?"):"marked_as_duplicate"===p.event_type?"将此 Issue 标记为 #".concat(null!=(m=sv(p.payload_json,"canonicalIssueNumber"))?m:"?"," 的重复项"):"unmarked_as_duplicate"===p.event_type?"撤销了与 #".concat(null!=(h=sv(p.payload_json,"canonicalIssueNumber"))?h:"?"," 的重复关系"):"更新了此 Issue"}function sw(e){let{type:t}=e;return"closed"===t?(0,n.jsx)(M.A,{className:"h-4 w-4","aria-hidden":"true"}):"reopened"===t?(0,n.jsx)(se.A,{className:"h-4 w-4","aria-hidden":"true"}):"labels_changed"===t?(0,n.jsx)(w.A,{className:"h-4 w-4","aria-hidden":"true"}):"assignees_changed"===t?(0,n.jsx)(tT.A,{className:"h-4 w-4","aria-hidden":"true"}):"subscribed"===t||"unsubscribed"===t?(0,n.jsx)(t3.A,{className:"h-4 w-4","aria-hidden":"true"}):"locked"===t?(0,n.jsx)(tz.A,{className:"h-4 w-4","aria-hidden":"true"}):"unlocked"===t?(0,n.jsx)(t8.A,{className:"h-4 w-4","aria-hidden":"true"}):"pinned"===t||"unpinned"===t||"comment_pinned"===t||"comment_unpinned"===t?(0,n.jsx)(tR.A,{className:"h-4 w-4","aria-hidden":"true"}):(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"})}function sj(e){let{pagePath:t,attachments:s,onRemove:a}=e;return s.length?(0,n.jsx)("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:s.map(e=>{let s=em(t,e.id);return(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-1",children:[eu(e.mime_type)?(0,n.jsx)("a",{href:s,target:"_blank",rel:"noreferrer","aria-label":"在新标签页打开附件 ".concat(e.file_name),className:"block min-w-0 flex-1 overflow-hidden rounded border",children:(0,n.jsx)("img",{src:s,alt:e.file_name,loading:"lazy",decoding:"async",className:"max-h-64 w-full object-contain"})}):(0,n.jsxs)("a",{href:s,target:"_blank",rel:"noreferrer","aria-label":"在新标签页打开附件 ".concat(e.file_name),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded border px-3 py-2 text-xs text-primary hover:underline",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.file_name}),(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground",children:eh(e.size_bytes)})]}),a&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"移除现有附件 ".concat(e.file_name),onClick:()=>a(e.id),children:(0,n.jsx)(O.A,{className:"h-4 w-4"})})]},e.id)})}):null}function sN(e){let{item:t,identities:s}=e,[a,r]=(0,l.useState)(!1),i=t6(t.actorId,s).displayName;return(0,n.jsxs)("li",{"data-localapp-issue-event-group":!0,className:"relative min-w-0 py-2 pl-3 text-xs text-muted-foreground before:absolute before:bottom-0 before:left-[19px] before:top-0 before:w-px before:bg-border",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{className:"relative z-10 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-card",children:(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("button",{type:"button","aria-expanded":a,"aria-controls":"".concat(t.key,"-events"),className:"flex min-w-0 items-center gap-1 rounded text-left hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>r(e=>!e),children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:i}),(0,n.jsxs)("span",{children:["编辑了此 Issue ",t.events.length," 次"]}),(0,n.jsx)(st.A,{className:"h-3.5 w-3.5 transition-transform motion-reduce:transition-none ".concat(a?"rotate-180":""),"aria-hidden":"true"})]})]}),a&&(0,n.jsx)("ol",{id:"".concat(t.key,"-events"),"aria-label":"".concat(i," 的编辑事件"),className:"ml-6 mt-2 space-y-1 border-l pl-3",children:t.events.map(e=>(0,n.jsx)("li",{children:(0,n.jsx)(tB,{timestamp:e.created_at,precise:!0})},e.id))})]})}function sk(e){let{item:t,identities:s}=e,[a,r]=(0,l.useState)(!1),i=t.actorId?t6(t.actorId,s).displayName:null;return(0,n.jsxs)("li",{"data-localapp-issue-history-group":!0,className:"relative min-w-0 py-2 pl-3 text-xs text-muted-foreground before:absolute before:bottom-0 before:left-[19px] before:top-0 before:w-px before:bg-border",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{className:"relative z-10 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-card",children:(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("button",{type:"button","aria-expanded":a,"aria-controls":"".concat(t.key,"-events"),className:"flex min-w-0 items-center gap-1 rounded text-left hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>r(e=>!e),children:[i&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:i}),(0,n.jsx)("span",{children:"进行了"})]}),(0,n.jsxs)("span",{children:[t.events.length," 项历史更新"]}),(0,n.jsx)(st.A,{className:"h-3.5 w-3.5 shrink-0 transition-transform motion-reduce:transition-none ".concat(a?"rotate-180":""),"aria-hidden":"true"})]})]}),a&&(0,n.jsx)("ol",{id:"".concat(t.key,"-events"),"aria-label":"历史更新明细,共 ".concat(t.events.length," 项"),className:"ml-6 mt-2 space-y-2 border-l pl-3",children:t.events.map(e=>(0,n.jsxs)("li",{className:"flex min-w-0 items-start gap-2",children:[(0,n.jsx)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center",children:(0,n.jsx)(sw,{type:e.event_type})}),(0,n.jsxs)("span",{className:"min-w-0 break-words",children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:t6(e.actor_id,s).displayName})," ",sy({kind:"event",event:e},s)," ",(0,n.jsx)(tB,{timestamp:e.created_at,precise:!0})]})]},e.id))})]})}function sI(e,t){let s=e.trim().split(/\r?\n/).map(e=>"> ".concat(e)).join("\n");return"".concat(s,"\n\n@").concat(t," ")}function sS(e){let{issueId:t,reporterId:s,pagePath:a,timeline:r,attachments:i,identities:o,currentUserId:c,reactions:d,commentDraftPrefix:u,onToggleReaction:m,onEditComment:h,onDeleteComment:p,onQuoteComment:f,onReferenceComment:b,selectedCommentId:g,getCommentHref:v,getIssueReferenceHref:y,onOpenIssueReference:w,onCopyCommentLink:j,onViewHistory:N,savingTaskTarget:k,onToggleCommentTask:I,interactionsLocked:S=!1,canManageCommentPins:A=!1,onToggleCommentPin:C,canManageCommentMinimization:E=!1,onToggleCommentMinimized:_}=e,T=(0,l.useRef)(null),L=(0,l.useRef)(null),[R,D]=(0,l.useState)(null),z=(0,l.useRef)(null),[q,U]=(0,l.useState)(null),[P,F]=(0,l.useState)(null),$=(0,l.useRef)(null),M=(0,l.useRef)(null),K=(0,l.useRef)(null),[O,B]=(0,l.useState)(""),[H,W]=(0,l.useState)(null),[V,X]=(0,l.useState)(null),[Q,Z]=(0,l.useState)(()=>new Set),[G,Y]=(0,l.useState)(null),[ee,et]=(0,l.useState)("off-topic"),[es,en]=(0,l.useState)(null),[el,er]=(0,l.useState)(!1),[ei,eo]=(0,l.useState)("all"),[ed,eu]=(0,l.useState)(20),em="all"===ei?[...r]:r.filter(e=>"comments"===ei?"comment"===e.kind:"comment"!==e.kind),eh=em.find(e=>"comment"===e.kind&&!!e.comment.pinned_at&&!e.comment.deleted_at);eh&&(em.splice(em.indexOf(eh),1),em.unshift(eh));let ep=function(e){let t=[];for(let s=0;s<e.length;){let n=e[s];if("event"!==n.kind){t.push(n),s+=1;continue}if("edited"!==n.event.event_type){let a=[n.event],l=s+1;for(;l<e.length;){let t=e[l];if("event"!==t.kind||"edited"===t.event.event_type)break;a.push(t.event),l+=1}if(a.length<4)t.push(...e.slice(s,l));else{let e=a.every(e=>e.actor_id===a[0].actor_id)?a[0].actor_id:null;t.push({kind:"event-group",groupType:"history",key:"history-".concat(a[0].id,"-").concat(a.at(-1).id),actorId:e,events:a})}s=l;continue}let a=[n.event],l=s+1;for(;l<e.length;){let t=e[l];if("event"!==t.kind||"edited"!==t.event.event_type||t.event.actor_id!==n.event.actor_id)break;a.push(t.event),l+=1}a.length<2?t.push(n):t.push({kind:"event-group",groupType:"edited",key:"edited-".concat(a[0].id,"-").concat(a.at(-1).id),actorId:n.event.actor_id,events:a}),s=l}return t}(em),ef=g?ep.findIndex(e=>"comment"===e.kind&&e.comment.id===g):-1,ex=Math.max(0,ep.length-ed),eb=ef>=0?Math.min(ex,ef):ex,eg=ep.slice(eb),ev={all:r.length,comments:r.filter(e=>"comment"===e.kind).length,history:r.filter(e=>"comment"!==e.kind).length},ey=[{value:"all",label:"全部"},{value:"comments",label:"评论"},{value:"history",label:"历史"}],ew=!!(g&&r.some(e=>"comment"===e.kind&&e.comment.id===g&&!e.comment.deleted_at)),ej=(e,t)=>u?"".concat(u,":").concat(e,":").concat(t):void 0,eN=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{["body","version"].forEach(t=>{let s=ej(e,t);s&&window.sessionStorage.removeItem(s)})}catch(e){}let s=ej(e,"body");t?ty(a,s):tg(s)};(0,l.useEffect)(()=>{eo("all"),eu(20),Z(new Set),Y(null)},[t]),(0,l.useEffect)(()=>{eu(20)},[ei]),(0,l.useEffect)(()=>{ew&&eo("comments")},[g,ew]),(0,l.useEffect)(()=>{var e;let t=z.current;if(z.current=null!=(e=null==R?void 0:R.id)?e:null,null===t||null!==R)return;let s=window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector('[data-testid="issue-comment-'.concat(t,'"]')))?void 0:e.focus()});return()=>window.cancelAnimationFrame(s)},[R]),(0,l.useEffect)(()=>{if(!R)return;let e=r.find(e=>"comment"===e.kind&&e.comment.id===R.id);(!e||e.comment.deleted_at)&&(D(null),B("评论已被删除,编辑已结束"))},[R,r]),(0,l.useEffect)(()=>{if(!ew||"comments"!==ei)return;let e=window.requestAnimationFrame(()=>{var e;let t=document.querySelector('[data-testid="issue-comment-'.concat(g,'"]:not([data-deleted="true"])'));t&&(null==(e=t.scrollIntoView)||e.call(t,{block:"center"}),t.focus({preventScroll:!0}))});return()=>window.cancelAnimationFrame(e)},[ei,g,ew,r]),(0,l.useEffect)(()=>{if(null===P)return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=M.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[P]),(0,l.useEffect)(()=>{if(null===P)return;let e=r.find(e=>"comment"===e.kind&&e.comment.id===P);(!e||e.comment.deleted_at)&&(F(null),window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector('[data-testid="issue-comment-'.concat(P,'"]')))?void 0:e.focus()}))},[P,r]);let ek=()=>{F(null),window.requestAnimationFrame(()=>{var e;return null==(e=$.current)?void 0:e.focus()})},eI=async e=>{U(e);try{await p(e),F(null),B("评论已删除");let t=function(e,t){let s=new URL(e.href);return(void 0===t||sc(s,si)===t)&&s.searchParams.delete(si),s}(new URL(window.location.href),e);t.href!==window.location.href&&window.history.replaceState(window.history.state,"",t),window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-testid="issue-comment-'.concat(e,'"]')))?void 0:t.focus()})}catch(e){}finally{U(null)}},eS=e=>{var t,s;if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),ek();return}"Tab"===e.key&&(e.shiftKey&&document.activeElement===M.current?(e.preventDefault(),null==(t=K.current)||t.focus()):e.shiftKey||document.activeElement!==K.current||(e.preventDefault(),null==(s=M.current)||s.focus()))};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true","aria-label":"时间线操作状态",className:"sr-only",children:O}),(0,n.jsxs)("div",{className:"mb-3 flex min-w-0 flex-col items-stretch gap-2 border-y py-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[(0,n.jsx)("span",{className:"shrink-0 whitespace-nowrap text-xs font-medium text-muted-foreground",children:"活动"}),(0,n.jsx)("div",{role:"radiogroup","aria-label":"筛选时间线活动",className:"grid w-full grid-cols-3 rounded-md border bg-muted/20 p-0.5 sm:w-auto",children:ey.map((e,t)=>(0,n.jsxs)("button",{type:"button",role:"radio","aria-checked":ei===e.value,tabIndex:ei===e.value?0:-1,onClick:()=>eo(e.value),onKeyDown:e=>{let s;if("Home"===e.key)s=0;else if("End"===e.key)s=ey.length-1;else if(["ArrowLeft","ArrowUp"].includes(e.key))s=(t-1+ey.length)%ey.length;else{if(!["ArrowRight","ArrowDown"].includes(e.key))return;s=(t+1)%ey.length}e.preventDefault();let n=ey[s];eo(n.value),window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector('[data-issue-activity-filter="'.concat(n.value,'"]')))?void 0:e.focus()})},"data-issue-activity-filter":e.value,className:"h-11 rounded px-2.5 text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-7 ".concat(ei===e.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.label," ",ev[e.value]]},e.value))})]}),0===ep.length?(0,n.jsx)("div",{role:"status",className:"rounded-md border border-dashed px-4 py-8 text-center text-sm text-muted-foreground",children:"comments"===ei?"还没有评论":"history"===ei?"还没有历史活动":"还没有活动"}):(0,n.jsxs)("ol",{ref:T,tabIndex:-1,"aria-label":"Issue 时间线",className:"space-y-3 outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[eb>0&&(0,n.jsx)("li",{className:"relative z-10 flex justify-center bg-background py-1",children:(0,n.jsxs)("button",{ref:L,type:"button","aria-label":"显示更早的 ".concat(eb," 条活动"),className:"h-11 rounded-md border px-3 text-xs font-medium text-muted-foreground hover:bg-muted/30 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8",onClick:()=>{let e=eb<=20;eu(e=>e+20),window.requestAnimationFrame(()=>{var t,s;e?null==(t=T.current)||t.focus():null==(s=L.current)||s.focus()})},children:["显示更早活动 \xb7 ",eb]})}),eg.map(e=>{var t,l;return"event-group"===e.kind?"edited"===e.groupType?(0,n.jsx)(sN,{item:e,identities:o},e.key):(0,n.jsx)(sk,{item:e,identities:o},e.key):"event"===e.kind?(0,n.jsxs)("li",{"data-localapp-issue-event":!0,"data-testid":"issue-event-".concat(e.event.id),className:"relative flex min-w-0 items-center gap-2 py-2 pl-3 text-xs text-muted-foreground before:absolute before:bottom-0 before:left-[19px] before:top-0 before:w-px before:bg-border",children:[(0,n.jsx)("span",{className:"relative z-10 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-card",children:(0,n.jsx)(sw,{type:e.event.event_type})}),(0,n.jsxs)("span",{className:"min-w-0 break-words",children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:t6(e.event.actor_id,o).displayName})," ",sy(e,o)," ",(0,n.jsx)(tB,{timestamp:e.event.created_at})]})]},"event-".concat(e.event.id)):"cross_reference"===e.kind?(0,n.jsx)(sg,{reference:e.crossReference,actorName:t6(e.crossReference.actor_id,o).displayName,href:(()=>{var t;let s=null!=(t=null==y?void 0:y(e.crossReference.source_issue_number))?t:"#";if(null===e.crossReference.source_comment_id||"#"===s)return s;let n=new URL(s,window.location.origin);return n.searchParams.set("localappIssueCommentId",String(e.crossReference.source_comment_id)),"".concat(n.pathname).concat(n.search).concat(n.hash)})(),onOpen:(e,t)=>null==w?void 0:w(e,t)},"cross-reference-".concat(e.crossReference.id)):(0,n.jsxs)("li",{id:"issuecomment-".concat(e.comment.id),"data-localapp-issue-comment-card":!0,"data-localapp-issue-comment-pinned":e.comment.pinned_at?"true":void 0,"data-testid":"issue-comment-".concat(e.comment.id),"data-deleted":e.comment.deleted_at?"true":void 0,tabIndex:-1,"aria-current":g!==e.comment.id||e.comment.deleted_at?void 0:"location",className:"min-w-0 overflow-hidden rounded-[6px] border bg-card outline-none ".concat(e.comment.pinned_at?"border-primary/50":""," ").concat(g!==e.comment.id||e.comment.deleted_at?"":"ring-2 ring-primary ring-offset-2"),children:[e.comment.pinned_at&&(0,n.jsxs)("div",{className:"flex min-h-9 items-center gap-2 border-b border-primary/20 bg-primary/5 px-4 py-2 text-xs font-medium text-foreground",children:[(0,n.jsx)(tR.A,{className:"h-3.5 w-3.5 text-primary","aria-hidden":"true"}),(0,n.jsx)("span",{children:"置顶评论"}),(0,n.jsxs)("span",{className:"text-muted-foreground",children:["由 ",t6(null!=(t=e.comment.pinned_by)?t:"",o).displayName," 置顶 ",(0,n.jsx)(tB,{timestamp:e.comment.pinned_at})]})]}),(0,n.jsx)("div",{className:"border-b bg-muted/20 px-4 py-3",children:(0,n.jsx)(t7,{identity:t6(e.comment.author_id,o),timestamp:e.comment.created_at,timestampHref:e.comment.deleted_at?void 0:v(e.comment.id),timestampSuffix:!e.comment.deleted_at&&e.comment.revision_count?(0,n.jsx)("button",{type:"button","aria-label":"查看评论编辑历史,".concat(e.comment.revision_count," 次修改"),className:"-my-2 inline-flex h-11 items-center px-1 text-muted-foreground hover:underline sm:-my-0 sm:h-6",onClick:t=>N(e.comment.id,t.currentTarget),children:"edited"}):void 0,badge:e.comment.author_id===s?"Author":void 0,action:e.comment.deleted_at?void 0:(0,n.jsx)(tX,{label:"评论操作",items:[{label:"复制评论链接",onSelect:()=>{B(""),j(e.comment.id).then(()=>B("评论链接已复制")).catch(()=>B("无法复制评论链接"))}},...A&&C?[{label:e.comment.pinned_at?"取消置顶评论":"置顶评论",disabled:null!==H,restoreFocus:!1,onSelect:async()=>{X(null),W(e.comment.id);try{await C(e.comment.id,!e.comment.pinned_at),window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-testid="issue-comment-'.concat(e.comment.id,'"]')))?void 0:t.focus()})}catch(e){X(e instanceof Error?e.message:"无法更新置顶评论")}finally{W(null)}}}]:[],...E&&_?[{label:e.comment.minimized_at?"取消最小化评论":"最小化评论",restoreFocus:!1,disabled:el,onSelect:t=>{e.comment.minimized_at?(er(!0),_(e.comment.id,null).then(()=>window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-testid="issue-comment-'.concat(e.comment.id,'"]')))?void 0:t.focus()})).catch(e=>B(e instanceof Error?e.message:"无法恢复评论")).finally(()=>er(!1))):($.current=t,et("off-topic"),en(null),Y(e.comment.id))}}]:[],...c?[{label:"引用到新 Issue",restoreFocus:!1,onSelect:t=>b(e.comment.id,e.comment.body,e.comment.author_id,t)}]:[],...c&&!S?[{label:"引用回复",restoreFocus:!1,onSelect:()=>f(e.comment.body,e.comment.author_id)}]:[],...c===e.comment.author_id?[{label:"编辑评论",restoreFocus:!1,disabled:q===e.comment.id||P===e.comment.id,onSelect:()=>{let t=ej(e.comment.id,"version"),s=ej(e.comment.id,"body"),n=e.comment.updated_at,a=!1;try{let e=t&&window.sessionStorage.getItem(t);a=!!(e||s&&window.sessionStorage.getItem(s)),n=e||n,t&&window.sessionStorage.setItem(t,n)}catch(e){}D({id:e.comment.id,expectedUpdatedAt:n,restoredDraft:a,draftId:crypto.randomUUID(),removedAttachmentIds:[]})}},{label:"删除评论",restoreFocus:!1,destructive:!0,disabled:q===e.comment.id,onSelect:t=>{$.current=t,F(e.comment.id)}}]:[]]})})}),(0,n.jsxs)("div",{className:"px-3 py-3",children:[G===e.comment.id&&(0,n.jsxs)("div",{role:"alertdialog","aria-label":"最小化评论",className:"mb-3 rounded-md border bg-muted/20 p-3",children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:"选择最小化原因"}),(0,n.jsx)("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:Object.entries(ec).map(t=>{let[s,a]=t;return(0,n.jsxs)("label",{className:"flex min-h-11 items-center gap-2 rounded border px-3 py-2 text-sm",children:[(0,n.jsx)("input",{type:"radio",name:"minimize-reason-".concat(e.comment.id),value:s,checked:ee===s,onChange:()=>et(s)}),a]},s)})}),es&&(0,n.jsx)("p",{role:"alert",className:"mt-3 text-sm text-destructive",children:es}),(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:el,onClick:()=>{Y(null),en(null),window.requestAnimationFrame(()=>{var e;return null==(e=$.current)?void 0:e.focus()})},children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:el,onClick:()=>{_&&(er(!0),en(null),_(e.comment.id,ee).then(()=>{Y(null),window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-testid="issue-comment-'.concat(e.comment.id,'"]')))?void 0:t.focus()})}).catch(e=>en(e instanceof Error?e.message:"无法最小化评论")).finally(()=>er(!1)))},children:"最小化评论"})]})]}),P===e.comment.id&&(0,n.jsxs)("div",{role:"alertdialog","aria-label":"删除评论确认","aria-describedby":"delete-comment-".concat(e.comment.id,"-description"),onKeyDown:eS,className:"mb-3 rounded-md border border-destructive/30 bg-destructive/5 p-3",children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:"确定删除这条评论吗?"}),(0,n.jsx)("p",{id:"delete-comment-".concat(e.comment.id,"-description"),className:"mt-1 text-xs text-muted-foreground",children:"删除后评论内容将不再显示。"}),(0,n.jsxs)("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:M,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:q===e.comment.id,onClick:ek,children:"取消删除"}),(0,n.jsx)(x.$,{ref:K,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:q===e.comment.id,onClick:()=>void eI(e.comment.id),children:"确认删除评论"})]})]}),e.comment.deleted_at?(0,n.jsx)("p",{className:"text-sm italic text-muted-foreground",children:"此评论已删除。"}):e.comment.minimized_at&&!Q.has(e.comment.id)?(0,n.jsxs)("div",{"data-localapp-issue-comment-minimized":!0,className:"flex min-h-11 flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsxs)("span",{children:["此评论已最小化 \xb7 ",ec[null!=(l=e.comment.minimized_reason)?l:"off-topic"]]}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",onClick:()=>Z(t=>new Set(t).add(e.comment.id)),children:"显示评论"})]}):(null==R?void 0:R.id)===e.comment.id?(0,n.jsxs)(n.Fragment,{children:[R.expectedUpdatedAt!==e.comment.updated_at&&(0,n.jsxs)("div",{role:"status",className:"mb-3 flex items-center justify-between gap-3 rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{children:"此评论有新变更,当前草稿尚未被覆盖。"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-8",onClick:()=>{eN(e.comment.id,!0),D(null)},children:"加载最新内容"})]}),R.restoredDraft&&(0,n.jsxs)("div",{role:"status",className:"mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{children:"已恢复上次未完成的编辑"}),(0,n.jsx)(J,{triggerLabel:"丢弃已恢复草稿",onConfirm:()=>{eN(e.comment.id,!0),D(null)},focusAfterConfirm:()=>{var t;return null==(t=document.getElementById("issuecomment-".concat(e.comment.id)))?void 0:t.focus()}})]}),(0,n.jsx)(tN,{pagePath:a,draftId:R.draftId,persistenceKey:ej(e.comment.id,"body"),preferPersistedDraft:!0,initialBody:e.comment.body,textareaLabel:"编辑评论内容",placeholder:"更新评论",submitLabel:"保存评论",allowEmpty:i.some(t=>t.comment_id===e.comment.id&&!R.removedAttachmentIds.includes(t.id)),mentionCandidates:o,onCancel:()=>{eN(e.comment.id,!0),D(null)},onSubmit:async t=>{let{body:s,attachmentIds:n,draftId:a}=t;await h(e.comment.id,s,R.expectedUpdatedAt,a,n,R.removedAttachmentIds),eN(e.comment.id),D(null)}},"edit-comment-".concat(e.comment.id,"-").concat(R.expectedUpdatedAt)),(0,n.jsx)(sj,{pagePath:a,attachments:i.filter(t=>t.comment_id===e.comment.id&&!R.removedAttachmentIds.includes(t.id)),onRemove:e=>D(t=>t?{...t,removedAttachmentIds:[...t.removedAttachmentIds,e]}:t)})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ea,{tasksDisabled:S||k===e.comment.id,onToggleTask:c===e.comment.author_id&&I?(t,s)=>{I(e.comment.id,t,s).catch(()=>void 0)}:void 0,getIssueReferenceHref:y,onOpenIssueReference:w,children:e.comment.body}),(0,n.jsx)(sj,{pagePath:a,attachments:sx(e.comment.body,i.filter(t=>t.comment_id===e.comment.id))}),(0,n.jsx)(sa,{reactions:d,commentId:e.comment.id,currentUserId:c,additionsDisabled:S,onToggle:m})]})]})]},"comment-".concat(e.comment.id))})]})]})}let sA=Object.entries(eo);function sC(e){let{saving:t,error:s,onCancel:a,onConfirm:r}=e,[i,o]=(0,l.useState)("resolved"),c=(0,l.useRef)(null),d=(0,l.useRef)(null);return(0,l.useEffect)(()=>{var e;null==(e=d.current)||e.focus()},[]),(0,n.jsx)("div",{"data-localapp-issue-lock-layer":!0,className:"absolute inset-0 z-[80] flex items-center justify-center bg-black/45 p-4",onMouseDown:e=>{e.target!==e.currentTarget||t||a()},children:(0,n.jsxs)("div",{ref:c,role:"dialog","aria-modal":"true","aria-labelledby":"issue-lock-title","aria-describedby":"issue-lock-description",onKeyDown:e=>{var s,n;if("Escape"===e.key&&!t){e.preventDefault(),e.stopPropagation(),a();return}if("Tab"!==e.key)return;let l=Array.from(null!=(n=null==(s=c.current)?void 0:s.querySelectorAll("button:not([disabled]), select:not([disabled])"))?n:[]);if(0===l.length)return;let r=l[0],i=l[l.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),r.focus())},className:"w-full max-w-md overflow-hidden rounded-[6px] border bg-card shadow-2xl",children:[(0,n.jsxs)("header",{className:"flex items-center gap-3 border-b px-4 py-3",children:[(0,n.jsx)(tz.A,{className:"h-4 w-4","aria-hidden":"true"}),(0,n.jsx)("h3",{id:"issue-lock-title",className:"min-w-0 flex-1 text-sm font-semibold",children:"锁定对话"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"取消锁定",disabled:t,onClick:a,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(0,n.jsxs)("div",{className:"space-y-4 p-4",children:[(0,n.jsx)("p",{id:"issue-lock-description",className:"text-sm text-muted-foreground",children:"锁定后,参与者无法新增评论、表态或勾选任务。现有内容仍然可见。"}),s&&(0,n.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:s}),(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:["锁定原因",(0,n.jsx)("select",{ref:d,"aria-label":"锁定原因",value:i,disabled:t,onChange:e=>o(e.target.value),className:"block h-11 w-full rounded-md border bg-background px-3 text-sm outline-none focus:ring-2 focus:ring-ring sm:h-9",children:sA.map(e=>{let[t,s]=e;return(0,n.jsx)("option",{value:t,children:s},t)})})]})]}),(0,n.jsxs)("footer",{className:"flex justify-end gap-2 border-t px-4 py-3",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:t,onClick:a,children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:t,onClick:()=>{r(i).catch(()=>void 0)},children:t?"正在锁定...":"确认锁定"})]})]})})}var sE=s(2415),s_=s(5246),sT=s(3930),sL=s(6758);function sR(e){var t,s;let{pagePath:a="",detail:r,identities:i,canManage:c,saving:d,getIssueHref:u,onOpenIssue:m,onCreate:h,onLink:p,onRemove:f,onReprioritize:b,loadChildren:g}=e,[v,y]=(0,l.useState)(!1),[w,N]=(0,l.useState)(""),[k,I]=(0,l.useState)(null),[S,E]=(0,l.useState)(""),[_,T]=(0,l.useState)(null),L=(0,l.useRef)(null),R=(0,l.useRef)(null),D=(0,l.useRef)(new Map),[z,q]=(0,l.useState)(()=>new Set),[U,P]=(0,l.useState)({}),F=null!=(t=r.subIssueSummary)?t:{total:0,completed:0,percent:0},$=null!=(s=r.subIssues)?s:[],K=(0,l.useCallback)(async function(e){var t,s;let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!n&&(null==(t=U[e])?void 0:t.status)==="loaded")return;null==(s=D.current.get(e))||s.abort();let l=new AbortController;D.current.set(e,l),P(t=>{var s,n;return{...t,[e]:{status:"loading",items:null!=(n=null==(s=t[e])?void 0:s.items)?n:[]}}});try{let t=await (g?g(e,l.signal):eX(a,e,l.signal));l.signal.aborted||P(s=>({...s,[e]:{status:"loaded",items:t.items}}))}catch(t){l.signal.aborted||P(s=>{var n,a;return{...s,[e]:{status:"error",items:null!=(a=null==(n=s[e])?void 0:n.items)?a:[],error:t instanceof Error?t.message:"无法加载子层级"}}})}},[U,g,a]),O=e=>{q(t=>{let s=new Set(t);return s.has(e)?s.delete(e):(s.add(e),K(e)),s})};(0,l.useEffect)(()=>()=>{D.current.forEach(e=>e.abort())},[]),(0,l.useEffect)(()=>{for(let e of z)K(e,!0)},[r]),(0,l.useEffect)(()=>{if(null===L.current||d)return;let e=L.current;L.current=null,window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-localapp-sub-issue-id="'.concat(e,'"] button[aria-label^="重排 Sub-issue"]')))?void 0:t.focus()})},[d,$]);let J=async(e,t)=>{let s=$.findIndex(t=>t.id===e);I(null);try{var n,a;L.current=e,await b(e,t);let l=$.filter(t=>t.id!==e),r=null===t?1:l.findIndex(e=>e.id===t)+2;E("Sub-issue #".concat(null!=(a=null==(n=$[s])?void 0:n.issue_number)?a:e," 已移动到第 ").concat(r," 位"))}catch(e){L.current=null,I(e instanceof Error?e.message:"无法重排 Sub-issue")}},B=async()=>{let e=Number(w.replace(/^#/,""));if(!Number.isSafeInteger(e)||e<1)return void I("请输入有效的 Issue 编号");I(null);try{await p(e),N(""),y(!1),window.requestAnimationFrame(()=>{var e;return null==(e=R.current)?void 0:e.focus()})}catch(e){I(e instanceof Error?e.message:"无法关联 Sub-issue")}},H=(e,t,s)=>(0,n.jsx)("ul",{role:"group",className:"border-t bg-muted/10",children:e.map(e=>{var a,l,r;let i=(null!=(a=e.child_count)?a:0)>0,c=z.has(e.id),d=U[e.id],h=s.has(e.id)||t>=8,p=new Set(s).add(e.id);return(0,n.jsxs)("li",{role:"treeitem","aria-level":t,"aria-expanded":i&&!h?c:void 0,"data-localapp-sub-issue-id":e.id,children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2 py-2.5 pr-4",style:{paddingLeft:"".concat(20*Math.min(t,8),"px")},children:[i&&!h?(0,n.jsx)("button",{type:"button",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"".concat(c?"折叠":"展开"," Sub-issue #").concat(e.issue_number),onClick:()=>O(e.id),onKeyDown:t=>{"ArrowRight"!==t.key||c?"ArrowLeft"===t.key&&c&&(t.preventDefault(),O(e.id)):(t.preventDefault(),O(e.id))},children:c?(0,n.jsx)(st.A,{className:"h-4 w-4"}):(0,n.jsx)(tU.A,{className:"h-4 w-4"})}):(0,n.jsx)("span",{className:"h-8 w-8 shrink-0"}),"closed"===e.status?(0,n.jsx)(M.A,{className:"h-4 w-4 shrink-0 text-violet-600","aria-label":"已关闭"}):(0,n.jsx)(o.A,{className:"h-4 w-4 shrink-0 text-emerald-700","aria-label":"开启"}),(0,n.jsxs)("a",{href:null!=(l=null==u?void 0:u(e.issue_number))?l:"#","aria-label":"#".concat(e.issue_number," ").concat(e.title),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 py-2 font-medium hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:t=>{!m||0!==t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),m(e.issue_number))},children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words",children:e.title}),(0,n.jsxs)("span",{className:"shrink-0 text-xs font-normal text-muted-foreground",children:["#",e.issue_number]})]}),i&&(0,n.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground",children:[null!=(r=e.completed_child_count)?r:0,"/",e.child_count]})]}),c&&(null==d?void 0:d.status)==="loading"&&(0,n.jsxs)("div",{role:"status",className:"flex items-center gap-2 py-3 pr-4 text-sm text-muted-foreground",style:{paddingLeft:"".concat(20*Math.min(t+1,8),"px")},children:[(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin"}),"正在加载子项"]}),c&&(null==d?void 0:d.status)==="error"&&(0,n.jsxs)("div",{role:"alert",className:"flex items-center gap-2 py-3 pr-4 text-sm text-destructive",style:{paddingLeft:"".concat(20*Math.min(t+1,8),"px")},children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:d.error}),(0,n.jsxs)(x.$,{type:"button",variant:"ghost",size:"sm",className:"gap-1",onClick:()=>void K(e.id,!0),children:[(0,n.jsx)(sE.A,{className:"h-4 w-4"}),"重试"]})]}),c&&(null==d?void 0:d.status)==="loaded"&&d.items.length>0&&H(d.items.filter(e=>!p.has(e.id)),t+1,p),c&&(null==d?void 0:d.status)==="loaded"&&0===d.items.length&&(0,n.jsx)("div",{className:"py-3 pr-4 text-sm text-muted-foreground",style:{paddingLeft:"".concat(20*Math.min(t+1,8),"px")},children:"没有更多子项"})]},e.id)})});return(0,n.jsxs)("section",{"data-localapp-sub-issues":!0,"aria-labelledby":"issue-sub-issues-title",className:"mt-5 overflow-hidden rounded-[6px] border bg-card",children:[(0,n.jsx)("span",{className:"sr-only","aria-live":"polite",children:S}),(0,n.jsxs)("header",{className:"flex min-w-0 flex-wrap items-center gap-3 border-b bg-muted/20 px-4 py-3",children:[(0,n.jsx)(sb.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h4",{id:"issue-sub-issues-title",className:"text-sm font-semibold",children:"Sub-issues"}),(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[F.completed," / ",F.total," 已完成"]})]}),c&&(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsxs)(x.$,{ref:R,type:"button",variant:"ghost",size:"sm",className:"h-11 gap-1.5 sm:h-8",disabled:d,"aria-expanded":v,onClick:()=>{I(null),y(e=>!e)},children:[(0,n.jsx)(s_.A,{className:"h-4 w-4"}),"关联"]}),(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 gap-1.5 sm:h-8",disabled:d,onClick:h,children:[(0,n.jsx)(j.A,{className:"h-4 w-4"}),"创建子 Issue"]})]})]}),F.total>0&&(0,n.jsx)("div",{className:"h-1 bg-muted",role:"progressbar","aria-label":"Sub-issues 完成进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":F.percent,children:(0,n.jsx)("div",{className:"h-full bg-emerald-600",style:{width:"".concat(F.percent,"%")}})}),v&&(0,n.jsxs)("form",{className:"flex flex-col gap-2 border-b px-4 py-3 sm:flex-row",onSubmit:e=>{e.preventDefault(),B()},children:[(0,n.jsx)(C.p,{autoFocus:!0,"aria-label":"要关联的 Issue 编号",placeholder:"#123",value:w,onChange:e=>N(e.target.value),className:"h-11 min-w-0 flex-1 sm:h-9"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",className:"h-11 sm:h-9",onClick:()=>{y(!1),I(null),window.requestAnimationFrame(()=>{var e;return null==(e=R.current)?void 0:e.focus()})},children:"取消"}),(0,n.jsx)(x.$,{type:"submit",className:"h-11 sm:h-9",disabled:d,children:"关联 Issue"})]}),k&&(0,n.jsx)("p",{role:"alert",className:"basis-full text-sm text-destructive",children:k})]}),0===$.length?(0,n.jsx)("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"还没有 Sub-issue"}):(0,n.jsxs)("ul",{role:"tree","aria-label":"Sub-issues",className:"divide-y",onDragOver:e=>{c&&null!==_&&e.preventDefault()},onDrop:e=>{c&&null!==_&&e.target===e.currentTarget&&(e.preventDefault(),J(_,null),T(null))},children:[null!==_&&(0,n.jsx)("li",{"data-localapp-sub-issue-drop-first":!0,className:"h-3 bg-primary/10","aria-hidden":"true",onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),e.stopPropagation(),J(_,null),T(null)}}),$.map((e,t)=>{var s,a,l,h;let p=null!=(a=null==u?void 0:u(e.issue_number))?a:"#",b=t<=1?null:$[t-2].id,g=t<$.length-1?$[t+1].id:e.id,v=null!=(l=null==(s=$.at(-1))?void 0:s.id)?l:e.id,y=(null!=(h=e.child_count)?h:0)>0,w=z.has(e.id),j=U[e.id];return(0,n.jsxs)("li",{role:"treeitem","aria-level":1,"aria-expanded":y?w:void 0,"data-localapp-sub-issue-id":e.id,className:_===e.id?"opacity-60":"",onDragOver:t=>{c&&null!==_&&_!==e.id&&t.preventDefault()},onDrop:t=>{c&&null!==_&&_!==e.id&&(t.preventDefault(),t.stopPropagation(),J(_,e.id),T(null))},children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-3 py-2.5 sm:gap-3 sm:px-4",children:[c&&(0,n.jsx)("button",{type:"button",draggable:!d,"aria-label":"拖动 Sub-issue #".concat(e.issue_number),title:"拖动重排",disabled:d,className:"hidden h-8 w-8 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:flex",onDragStart:t=>{T(e.id),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",String(e.id))},onDragEnd:()=>T(null),children:(0,n.jsx)(sT.A,{className:"h-4 w-4"})}),y?(0,n.jsx)("button",{type:"button",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"".concat(w?"折叠":"展开"," Sub-issue #").concat(e.issue_number),onClick:()=>O(e.id),onKeyDown:t=>{"ArrowRight"!==t.key||w?"ArrowLeft"===t.key&&w&&(t.preventDefault(),O(e.id)):(t.preventDefault(),O(e.id))},children:w?(0,n.jsx)(st.A,{className:"h-4 w-4"}):(0,n.jsx)(tU.A,{className:"h-4 w-4"})}):(0,n.jsx)("span",{className:"h-8 w-8 shrink-0"}),"closed"===e.status?(0,n.jsx)(M.A,{className:"h-4 w-4 shrink-0 text-violet-600","aria-label":"已关闭"}):(0,n.jsx)(o.A,{className:"h-4 w-4 shrink-0 text-emerald-700","aria-label":"开启"}),(0,n.jsxs)("a",{href:p,"aria-label":"#".concat(e.issue_number," ").concat(e.title),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 py-2 font-medium hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:t=>{!m||0!==t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),m(e.issue_number))},children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words",children:e.title}),(0,n.jsxs)("span",{className:"shrink-0 text-xs font-normal text-muted-foreground",children:["#",e.issue_number]})]}),e.assignee_ids.slice(0,3).map(e=>{var t;let s=t6(e,i);return(0,n.jsx)("span",{title:"".concat(s.displayName," @").concat(e),"aria-label":"负责人 ".concat(s.displayName),className:"hidden h-7 w-7 shrink-0 items-center justify-center rounded-full border bg-muted text-[10px] font-semibold sm:flex",children:(null==(t=Array.from(s.displayName)[0])?void 0:t.toLocaleUpperCase())||"?"},e)}),c&&(0,n.jsx)(tX,{label:"重排 Sub-issue #".concat(e.issue_number),items:[{label:"移到顶部",disabled:d||0===t,restoreFocus:!1,onSelect:()=>void J(e.id,null)},{label:"上移",disabled:d||0===t,restoreFocus:!1,onSelect:()=>void J(e.id,b)},{label:"下移",disabled:d||t===$.length-1,restoreFocus:!1,onSelect:()=>void J(e.id,g)},{label:"移到底部",disabled:d||t===$.length-1,restoreFocus:!1,onSelect:()=>void J(e.id,v)}]}),c&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8",disabled:d,"aria-label":"移除 Sub-issue #".concat(e.issue_number),onClick:()=>{I(null),f(e.id).catch(e=>I(e instanceof Error?e.message:"无法移除 Sub-issue"))},children:(0,n.jsx)(sL.A,{className:"h-4 w-4"})})]}),w&&(null==j?void 0:j.status)==="loading"&&(0,n.jsxs)("div",{role:"status",className:"flex items-center gap-2 border-t px-12 py-3 text-sm text-muted-foreground",children:[(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin"}),"正在加载子项"]}),w&&(null==j?void 0:j.status)==="error"&&(0,n.jsxs)("div",{role:"alert",className:"flex items-center gap-2 border-t px-12 py-3 text-sm text-destructive",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:j.error}),(0,n.jsxs)(x.$,{type:"button",variant:"ghost",size:"sm",className:"gap-1",onClick:()=>void K(e.id,!0),children:[(0,n.jsx)(sE.A,{className:"h-4 w-4"}),"重试"]})]}),w&&(null==j?void 0:j.status)==="loaded"&&j.items.length>0&&H(j.items.filter(t=>t.id!==r.issue.id&&t.id!==e.id),2,new Set([r.issue.id,e.id]))]},e.id)})]}),k&&!v&&(0,n.jsx)("p",{role:"alert",className:"border-t px-4 py-2 text-sm text-destructive",children:k})]})}function sD(e){let{initialTitle:t,saving:s,error:a,onCancel:r,onConfirm:i}=e,[o,c]=(0,l.useState)(t),d=(0,l.useRef)(null),u=(0,l.useRef)(null),m=Array.from(o).length,h=!o.trim()||m>256;return(0,l.useEffect)(()=>{var e,t;null==(e=u.current)||e.focus(),null==(t=u.current)||t.select()},[]),(0,n.jsx)("div",{"data-localapp-issue-task-convert-layer":!0,className:"absolute inset-0 z-[80] flex items-center justify-center bg-black/45 p-4",onMouseDown:e=>{e.target!==e.currentTarget||s||r()},children:(0,n.jsxs)("div",{ref:d,role:"alertdialog","aria-modal":"true","aria-labelledby":"issue-task-convert-title","aria-describedby":"issue-task-convert-description",onKeyDown:e=>{var t,n;if("Escape"===e.key&&!s){e.preventDefault(),e.stopPropagation(),r();return}if("Tab"!==e.key)return;let a=Array.from(null!=(n=null==(t=d.current)?void 0:t.querySelectorAll("input:not([disabled]), button:not([disabled])"))?n:[]);if(!a.length)return;let l=a[0],i=a[a.length-1];e.shiftKey&&document.activeElement===l?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),l.focus())},className:"w-full max-w-lg overflow-hidden rounded-[6px] border bg-card shadow-2xl",children:[(0,n.jsxs)("header",{className:"flex items-center gap-3 border-b px-4 py-3",children:[(0,n.jsx)(V.A,{className:"h-4 w-4","aria-hidden":"true"}),(0,n.jsx)("h3",{id:"issue-task-convert-title",className:"min-w-0 flex-1 text-sm font-semibold",children:"转换为 Sub-issue"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"取消转换",disabled:s,onClick:r,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(0,n.jsxs)("div",{className:"space-y-4 p-4",children:[(0,n.jsx)("p",{id:"issue-task-convert-description",className:"text-sm text-muted-foreground",children:"将创建一个新的 Sub-issue,并把当前任务替换为可追踪的 Issue 引用。"}),a&&(0,n.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:a}),(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsxs)("span",{className:"flex justify-between gap-3",children:[(0,n.jsx)("span",{children:"Sub-issue 标题"}),(0,n.jsxs)("span",{className:m>256?"text-destructive":"text-muted-foreground",children:[m," / 256"]})]}),(0,n.jsx)("input",{ref:u,"aria-label":"Sub-issue 标题","aria-invalid":h||void 0,value:o,disabled:s,onChange:e=>c(e.target.value),className:"block h-11 w-full rounded-md border bg-background px-3 text-sm outline-none focus:ring-2 focus:ring-ring"})]})]}),(0,n.jsxs)("footer",{className:"flex justify-end gap-2 border-t px-4 py-3",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:s,onClick:r,children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:s||h,onClick:()=>{i(o.trim()).catch(()=>void 0)},children:s?"正在创建...":"创建 Sub-issue"})]})]})})}var sz=s(9927);function sq(e){var t,s,a;let{detail:r,identities:i,canManage:c,saving:d,getIssueHref:u,onOpenIssue:m,onAdd:h,onRemove:p}=e,[f,b]=(0,l.useState)(null),[g,v]=(0,l.useState)(""),[y,w]=(0,l.useState)(null),j=(0,l.useRef)({blockedBy:null,blocking:null}),N=null!=(t=r.dependencySummary)?t:{blockedBy:0,blocking:0,unresolvedBlockers:0,isBlocked:!1},k=async()=>{if(!f)return;let e=Number(g.replace(/^#/,""));if(!Number.isSafeInteger(e)||e<1)return void w("请输入有效的 Issue 编号");w(null);try{await h(f,e),v(""),b(null),window.requestAnimationFrame(()=>{var e;return null==(e=j.current[f])?void 0:e.focus()})}catch(e){w(e instanceof Error?e.message:"无法添加 Issue 依赖")}},I=[{direction:"blockedBy",title:"被以下 Issue 阻塞",empty:"没有 blocker",items:null!=(s=r.blockedBy)?s:[]},{direction:"blocking",title:"正在阻塞",empty:"没有阻塞其他 Issue",items:null!=(a=r.blocking)?a:[]}];return(0,n.jsxs)("section",{"data-localapp-issue-dependencies":!0,"aria-labelledby":"issue-dependencies-title",className:"mt-5 overflow-hidden rounded-[6px] border bg-card",children:[(0,n.jsxs)("header",{className:"flex min-w-0 items-center gap-3 border-b bg-muted/20 px-4 py-3",children:[(0,n.jsx)(sz.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h4",{id:"issue-dependencies-title",className:"text-sm font-semibold",children:"Relationships"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:N.unresolvedBlockers?"".concat(N.unresolvedBlockers," 个未解决 blocker"):"当前未被阻塞"})]})]}),I.map(e=>(0,n.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,n.jsxs)("div",{className:"flex min-h-11 items-center gap-2 px-4 py-2",children:[(0,n.jsx)("h5",{className:"min-w-0 flex-1 text-xs font-semibold text-muted-foreground",children:e.title}),c&&(0,n.jsxs)(x.$,{ref:t=>{j.current[e.direction]=t},type:"button",variant:"ghost",size:"sm",className:"h-11 gap-1.5 sm:h-8",disabled:d,"aria-expanded":f===e.direction,onClick:()=>{w(null),v(""),b(t=>t===e.direction?null:e.direction)},children:[(0,n.jsx)(s_.A,{className:"h-4 w-4"}),"添加"]})]}),f===e.direction&&(0,n.jsxs)("form",{className:"flex flex-col gap-2 border-t px-4 py-3 sm:flex-row",onSubmit:e=>{e.preventDefault(),k()},children:[(0,n.jsx)(C.p,{autoFocus:!0,"aria-label":"".concat(e.title,"的 Issue 编号"),placeholder:"#123",value:g,onChange:e=>v(e.target.value),className:"h-11 min-w-0 flex-1 sm:h-9"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",className:"h-11 sm:h-9",onClick:()=>{b(null),w(null),window.requestAnimationFrame(()=>{var t;return null==(t=j.current[e.direction])?void 0:t.focus()})},children:"取消"}),(0,n.jsx)(x.$,{type:"submit",className:"h-11 sm:h-9",disabled:d,children:"添加依赖"})]}),y&&(0,n.jsx)("p",{role:"alert",className:"basis-full text-sm text-destructive",children:y})]}),0===e.items.length?(0,n.jsx)("p",{className:"border-t px-4 py-3 text-xs text-muted-foreground",children:e.empty}):(0,n.jsx)("ul",{"aria-label":e.title,className:"divide-y border-t",children:e.items.map(t=>{var s;return(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-3 px-4 py-2.5",children:["closed"===t.status?(0,n.jsx)(M.A,{className:"h-4 w-4 shrink-0 text-violet-600","aria-label":"已关闭"}):(0,n.jsx)(o.A,{className:"h-4 w-4 shrink-0 text-emerald-700","aria-label":"开启"}),(0,n.jsxs)("a",{href:null!=(s=null==u?void 0:u(t.issue_number))?s:"#",className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 py-2 font-medium hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:e=>{!m||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),m(t.issue_number))},children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words",children:t.title}),(0,n.jsxs)("span",{className:"shrink-0 text-xs font-normal text-muted-foreground",children:["#",t.issue_number]})]}),t.assignee_ids.slice(0,3).map(e=>{var t;let s=t6(e,i);return(0,n.jsx)("span",{title:"".concat(s.displayName," @").concat(e),className:"hidden h-7 w-7 shrink-0 items-center justify-center rounded-full border bg-muted text-[10px] font-semibold sm:flex",children:(null==(t=Array.from(s.displayName)[0])?void 0:t.toLocaleUpperCase())||"?"},e)}),c&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8",disabled:d,"aria-label":"移除依赖 #".concat(t.issue_number),onClick:()=>{w(null),p(e.direction,t.id).catch(e=>w(e instanceof Error?e.message:"无法移除 Issue 依赖"))},children:(0,n.jsx)(sL.A,{className:"h-4 w-4"})})]},t.id)})})]},e.direction)),y&&!f&&(0,n.jsx)("p",{role:"alert",className:"border-t px-4 py-2 text-sm text-destructive",children:y})]})}function sU(e){let{issue:t,prefix:s,getIssueHref:a,onOpenIssue:l}=e;return(0,n.jsxs)("a",{href:a(t.issue_number),"aria-label":"".concat(s," Issue #").concat(t.issue_number," ").concat(t.title),className:"flex min-h-11 min-w-0 items-center gap-2 rounded px-3 py-2 text-sm hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:min-h-9",onClick:e=>{!l||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),l(t.issue_number))},children:[(0,n.jsxs)("span",{className:"shrink-0 text-muted-foreground",children:["#",t.issue_number]}),(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words font-medium",children:t.title})]})}function sP(e){let{duplicateOf:t,duplicates:s=[],canManage:a,getIssueHref:r,onOpenIssue:i,onUnmark:o}=e,[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),h=(0,l.useRef)(null);if(!t&&0===s.length)return null;let p=async()=>{if(!t||c)return;d(!0),m(null);let e=!1;try{await o(t.id),e=!0}catch(e){m(e instanceof Error?e.message:"撤销重复标记失败")}finally{d(!1),requestAnimationFrame(()=>{var t;return null==(t=e?document.querySelector("[data-localapp-issue-title]"):h.current)?void 0:t.focus()})}};return(0,n.jsxs)("section",{"aria-label":"Duplicate Issues",className:"mt-5 overflow-hidden rounded-[6px] border bg-card",children:[t&&(0,n.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 border-b bg-muted/20 px-3 py-2",children:[(0,n.jsx)(S.A,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)("span",{className:"text-sm",children:"此 Issue 是重复项:"}),(0,n.jsxs)("a",{href:r(t.issue_number),"aria-label":"Canonical Issue #".concat(t.issue_number," ").concat(t.title),className:"min-h-11 min-w-0 flex-1 break-words rounded py-2 text-sm font-medium hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:min-h-8 sm:py-1",onClick:e=>{!i||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i(t.issue_number))},children:["#",t.issue_number," ",t.title]}),a&&(0,n.jsx)(x.$,{ref:h,type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-8",disabled:c,onClick:()=>void p(),children:c?"撤销中...":"撤销重复标记"})]}),u&&(0,n.jsx)("p",{role:"alert",className:"border-b px-3 py-2 text-sm text-destructive",children:u}),s.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("h4",{className:"px-3 pt-3 text-sm font-semibold",children:"重复 Issue"}),(0,n.jsx)("p",{className:"px-3 pb-1 text-xs text-muted-foreground",children:"以下 Issue 已标记为当前 Issue 的重复项"}),(0,n.jsx)("ul",{"aria-label":"重复 Issues",className:"divide-y",children:s.map(e=>(0,n.jsx)("li",{children:(0,n.jsx)(sU,{issue:e,prefix:"重复",getIssueHref:r,onOpenIssue:i})},e.id))})]})]})}function sF(e){let{pagePath:t,attachments:s,onRemove:a}=e;return s.length?(0,n.jsx)("div",{className:"mt-4 grid min-w-0 gap-2 sm:grid-cols-2",children:s.map(e=>{let s=em(t,e.id);return(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-1",children:[eu(e.mime_type)?(0,n.jsx)("a",{href:s,target:"_blank",rel:"noreferrer","aria-label":"在新标签页打开附件 ".concat(e.file_name),className:"block min-w-0 flex-1 overflow-hidden rounded-[6px] border",children:(0,n.jsx)("img",{src:s,alt:e.file_name,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full object-contain"})}):(0,n.jsxs)("a",{href:s,target:"_blank",rel:"noreferrer","aria-label":"在新标签页打开附件 ".concat(e.file_name),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-[6px] border px-3 py-2 text-xs text-primary hover:underline",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.file_name}),(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground",children:eh(e.size_bytes)})]}),a&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"移除现有附件 ".concat(e.file_name),onClick:()=>a(e.id),children:(0,n.jsx)(O.A,{className:"h-4 w-4"})})]},e.id)})}):null}function s$(e){let{participantIds:t,identities:s}=e,a=t.slice(0,8),l=Math.max(0,t.length-a.length);return(0,n.jsxs)("ul",{"aria-label":"Issue 参与者",className:"flex flex-wrap gap-1.5",children:[a.map(e=>{var t;let a=t6(e,s),l="".concat(a.displayName," @").concat(a.id);return(0,n.jsx)("li",{children:(0,n.jsx)("span",{"aria-label":l,title:l,className:"flex h-7 w-7 items-center justify-center overflow-hidden rounded-full border bg-muted text-[10px] font-semibold text-muted-foreground",children:a.avatarUrl?(0,n.jsx)("img",{src:a.avatarUrl,alt:"",className:"h-full w-full object-cover"}):(null==(t=Array.from(a.displayName)[0])?void 0:t.toLocaleUpperCase())||"?"})},e)}),l>0&&(0,n.jsx)("li",{children:(0,n.jsxs)("span",{"aria-label":"另外 ".concat(l," 位参与者"),title:"另外 ".concat(l," 位参与者"),className:"flex h-7 min-w-7 items-center justify-center rounded-full border bg-muted px-1 text-[10px] font-semibold text-muted-foreground",children:["+",l]})})]})}function sM(e){var t,s,a,r,i,o,c,d,u,m,h;let{detail:p,identities:f,availableLabels:b,availableMilestones:g,currentUserId:v,canManage:y,saving:w,onToggleLabel:j,onSetIssueType:N,onToggleAssignee:k,onSetMilestone:I,onToggleSubscription:S,canManageLock:A,onToggleLock:C,canManagePin:E,onTogglePin:_}=e,[T,L]=(0,l.useState)(null),[R,D]=(0,l.useState)(!1),z=(0,l.useRef)(null),q=p.collaboration,U=Array.from(new Set([p.issue.reporter_id,...null!=(s=null==q?void 0:q.participant_ids)?s:[],...null!=(a=p.issue.participant_ids)?a:[],...p.timeline.flatMap(e=>"comment"===e.kind?[e.comment.author_id]:"event"===e.kind?[e.event.actor_id]:[e.crossReference.actor_id])])).filter(Boolean),P=t6(p.issue.reporter_id,f),F=null!=(r=null==q?void 0:q.labels.map(e=>e.id))?r:[],$=Array.from(new Map([...null!=(i=null==q?void 0:q.labels)?i:[],...b].map(e=>[e.id,e])).values()),M=null!=(o=null==q?void 0:q.assignee_ids)?o:[],K=Array.from(new Set([...M,...f.map(e=>e.id)])).map(e=>t6(e,f)),O=!!(v&&(null==q?void 0:q.subscriber_ids.includes(v))),J=async e=>{if(e){L(null);try{await e}catch(e){throw L(e instanceof Error?e.message:"Issue 元数据更新失败"),e}}},B=()=>{D(!1),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>{var e;return null==(e=z.current)?void 0:e.focus()}))};return(0,n.jsxs)("div",{className:"space-y-5 text-sm",children:[T&&!R&&(0,n.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:T}),(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"创建者"}),(0,n.jsx)(t7,{identity:P})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold text-muted-foreground",children:"类型"}),y&&(0,n.jsxs)("select",{"aria-label":"设置 Issue 类型",className:"h-11 rounded-md border bg-background px-2 text-xs sm:h-8",disabled:w,value:null!=(c=p.issue.issue_type)?c:p.issue.label,onChange:e=>void J(null==N?void 0:N(e.target.value)),children:[(0,n.jsx)("option",{value:"task",children:"任务"}),(0,n.jsx)("option",{value:"bug",children:"缺陷"}),(0,n.jsx)("option",{value:"feature",children:"功能"})]})]}),(0,n.jsx)("p",{className:"text-xs font-medium text-foreground",children:ei[null!=(d=p.issue.issue_type)?d:p.issue.label]})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold text-muted-foreground",children:"标签"}),y&&(0,n.jsx)(t9,{label:"Labels",items:$.map(e=>({id:e.id,label:e.name,description:e.description||e.id,leading:(0,n.jsx)("span",{"aria-hidden":"true",className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:"#".concat(e.color)}})})),selectedIds:F,disabled:w,onToggle:(e,t)=>null==j?void 0:j(e,t)})]}),(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:(null!=(u=null==q?void 0:q.labels)?u:[]).map(e=>(0,n.jsx)(tP,{label:e},e.id))})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold text-muted-foreground",children:"负责人"}),y&&(0,n.jsx)(t9,{label:"Assignees",items:K.map(e=>{var t;return{id:e.id,label:e.displayName,description:"@".concat(e.id),leading:(0,n.jsx)("span",{"aria-hidden":"true",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold",children:(null==(t=Array.from(e.displayName)[0])?void 0:t.toLocaleUpperCase())||"?"})}}),selectedIds:M,disabled:w,onToggle:(e,t)=>null==k?void 0:k(e,t)})]}),M.length>0?(0,n.jsx)("div",{className:"space-y-2",children:M.map(e=>(0,n.jsx)(t7,{identity:t6(e,f)},e))}):(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"尚未分配"})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold text-muted-foreground",children:"里程碑"}),y&&(0,n.jsxs)("select",{"aria-label":"设置里程碑",className:"h-11 min-w-0 max-w-[170px] rounded-md border bg-background px-2 text-xs sm:h-8",disabled:w,value:null!=(m=p.issue.milestone_id)?m:"",onChange:e=>void J(null==I?void 0:I(e.target.value?Number(e.target.value):null)),children:[(0,n.jsx)("option",{value:"",children:"无里程碑"}),g.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title,"closed"===e.state?"(已关闭)":""]},e.id))]})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:null!=(h=null==(t=g.find(e=>e.id===p.issue.milestone_id))?void 0:t.title)?h:p.issue.milestone_id?"里程碑 #".concat(p.issue.milestone_id):"尚未设置"})]}),v&&(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"通知"}),(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 w-full justify-start gap-2 sm:h-8",disabled:w,"aria-label":O?"取消订阅":"订阅 Issue",onClick:()=>J(null==S?void 0:S(!O)),children:[O?(0,n.jsx)(t4.A,{className:"h-4 w-4"}):(0,n.jsx)(t3.A,{className:"h-4 w-4"}),O?"取消订阅":"订阅 Issue"]})]}),E&&(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"置顶"}),(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 w-full justify-start gap-2 sm:h-8",disabled:w,"aria-label":p.issue.pinned_at?"取消置顶":"置顶 Issue",onClick:()=>{J(null==_?void 0:_(!p.issue.pinned_at)).catch(()=>void 0)},children:[p.issue.pinned_at?(0,n.jsx)(t5.A,{className:"h-4 w-4"}):(0,n.jsx)(tR.A,{className:"h-4 w-4"}),p.issue.pinned_at?"取消置顶":"置顶 Issue"]})]}),A&&(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"对话"}),(0,n.jsxs)(x.$,{ref:z,type:"button",variant:"outline",size:"sm",className:"h-11 w-full justify-start gap-2 sm:h-8",disabled:w,"aria-label":p.issue.locked_at?"解锁对话":"锁定对话",onClick:()=>p.issue.locked_at?J(null==C?void 0:C(!1)):D(!0),children:[p.issue.locked_at?(0,n.jsx)(t8.A,{className:"h-4 w-4"}):(0,n.jsx)(tz.A,{className:"h-4 w-4"}),p.issue.locked_at?"解锁对话":"锁定对话"]})]}),(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"参与者"}),(0,n.jsx)(s$,{participantIds:U,identities:f})]}),R&&(0,n.jsx)(sC,{saving:w,error:T,onCancel:B,onConfirm:async e=>{await J(null==C?void 0:C(!0,e)),B()}})]})}function sK(e){var t,s,a,r,i,c,d,u;let{pagePath:m,detail:h,identities:p,currentUserId:f,availableLabels:x=[],availableMilestones:b=[],canManageMetadata:g=!1,metadataSaving:v=!1,headerAction:y,bodyAction:w,statusAction:j,composer:N,commentDraftPrefix:k,onEditComment:I,onDeleteComment:S,canManageCommentPins:A=!1,onToggleCommentPin:C,canManageCommentMinimization:E=!1,onToggleCommentMinimized:_,onQuoteComment:T,onReferenceComment:L,selectedCommentId:R,getCommentHref:D,getIssueHref:z,getIssueReferenceHref:q,onOpenIssueReference:U,onCopyCommentLink:P,onViewIssueHistory:F,onViewCommentHistory:$,onToggleLabel:K,onSetIssueType:O,onToggleAssignee:J,onSetMilestone:B,onToggleSubscription:H,canManageLock:W=!1,onToggleLock:V,canManagePin:X=!1,onTogglePin:Q,canManageSubIssues:Z=!1,onCreateSubIssue:G,onLinkSubIssue:Y,onRemoveSubIssue:ee,onReprioritizeSubIssue:et,canManageDependencies:es=!1,onAddDependency:en,onRemoveDependency:el,canManageDuplicates:er=!1,onUnmarkDuplicate:ei,onToggleReaction:eo,savingTaskTarget:ec,onToggleIssueTask:ed,onConvertIssueTask:eu,onToggleCommentTask:em}=e,[eh,ep]=(0,l.useState)(null),[ef,ex]=(0,l.useState)(!1),[eb,eg]=(0,l.useState)(null),[ev,ey]=(0,l.useState)(null),ew=t6(h.issue.reporter_id,p),ej=sx(h.issue.description,h.attachments.filter(e=>null===e.comment_id)),eN=h.timeline.filter(e=>"comment"===e.kind&&!e.comment.deleted_at),ek=eN[0],eI="open"===h.issue.status,eS=!eI&&"not_planned"===h.issue.state_reason,eA=null!=(r=null==(t=h.collaboration)?void 0:t.labels.length)?r:0,eC=null!=(i=null==(s=h.collaboration)?void 0:s.assignee_ids.length)?i:0,eE="".concat(eA," 个标签 \xb7 ").concat(eC?"".concat(eC," 位负责人"):"未分配").concat(h.issue.locked_at?" \xb7 已锁定":"");return(0,l.useEffect)(()=>{if(null===ev)return;let e=0,t=0,s=()=>{let n=document.querySelector('[data-localapp-issue-reference="'.concat(ev,'"]'));if(null==n||n.focus(),n&&document.activeElement===n)return void ey(null);e++<10&&(t=window.setTimeout(s,30))};return t=window.setTimeout(s,0),()=>window.clearTimeout(t)},[h.issue.description,ev]),(0,n.jsxs)("section",{"data-localapp-issue-detail":!0,"data-testid":"issue-detail-workspace",className:"relative grid min-w-0 grid-cols-1 lg:grid-cols-[minmax(0,3fr)_minmax(240px,1fr)] lg:gap-6",children:[(0,n.jsx)("span",{"aria-label":"Issue 元数据状态","aria-live":"polite",className:"sr-only",children:v?"正在更新 Issue 元数据":"Issue 元数据已同步"}),(0,n.jsx)("span",{"aria-live":"polite",className:"sr-only",children:null!=ec?"正在保存任务状态":""}),(0,n.jsxs)("header",{className:"min-w-0 border-b pb-5 lg:col-span-2",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,n.jsxs)("h3",{"data-localapp-issue-title":!0,tabIndex:-1,"aria-label":h.issue.title,className:"min-w-0 flex-1 break-words text-2xl font-normal leading-8 tracking-normal outline-none sm:text-[32px] sm:leading-10",children:[h.issue.title," ",(0,n.jsxs)("span",{className:"whitespace-nowrap text-muted-foreground",children:["#",h.issue.issue_number]})]}),y]}),(0,n.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 font-medium text-white ".concat(eI?"bg-emerald-700":"bg-violet-600"),children:[eI?(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"}):eS?(0,n.jsx)(tC.A,{className:"h-4 w-4","aria-hidden":"true"}):(0,n.jsx)(M.A,{className:"h-4 w-4","aria-hidden":"true"}),eI?"开启":"not_planned"===h.issue.state_reason?"已关闭 \xb7 不计划处理":"已关闭 \xb7 已完成"]}),(0,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:ew.displayName})," 打开了此 Issue ",(0,n.jsx)(tB,{timestamp:h.issue.created_at})]}),(0,n.jsxs)("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[(0,n.jsx)("span",{className:"hidden sm:inline","aria-hidden":"true",children:"\xb7"}),ek?(0,n.jsxs)("a",{href:D(ek.comment.id),className:"-my-2 inline-flex h-11 items-center px-1 font-medium text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:-my-0 sm:h-6",children:[eN.length," 条评论"]}):(0,n.jsx)("span",{children:"0 条评论"})]}),h.issue.locked_at&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 font-medium text-foreground",children:[(0,n.jsx)(tz.A,{className:"h-4 w-4","aria-hidden":"true"}),"已锁定"]})]}),h.parent&&(0,n.jsxs)("a",{href:null!=(c=null==q?void 0:q(h.parent.issue_number))?c:"#",className:"mt-2 inline-flex min-h-11 items-center text-sm font-medium text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:min-h-7",onClick:e=>{!U||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),U(h.parent.issue_number))},children:["父 Issue:#",h.parent.issue_number," ",h.parent.title]})]}),(h.duplicateOf||(null==(a=h.duplicates)?void 0:a.length))&&(0,n.jsx)("div",{className:"min-w-0 lg:col-span-2",children:(0,n.jsx)(sP,{duplicateOf:h.duplicateOf,duplicates:h.duplicates,canManage:er,getIssueHref:e=>{var t;return null!=(t=null==q?void 0:q(e))?t:"#"},onOpenIssue:U,onUnmark:null!=ei?ei:async()=>void 0})}),(0,n.jsxs)("details",{"data-localapp-issue-metadata":!0,"data-testid":"issue-metadata-mobile",className:"border-b py-3 lg:hidden",children:[(0,n.jsx)("summary",{className:"min-h-11 cursor-pointer py-3 text-sm font-semibold",children:(0,n.jsxs)("span",{className:"inline-flex w-[calc(100%-1.25rem)] items-center justify-between gap-3 align-middle",children:[(0,n.jsx)("span",{children:"Issue 详情"}),(0,n.jsx)("span",{"data-localapp-issue-metadata-summary":!0,className:"min-w-0 truncate text-xs font-normal text-muted-foreground",children:eE})]})}),(0,n.jsx)("div",{className:"pt-4",children:(0,n.jsx)(sM,{detail:h,identities:p,availableLabels:x,availableMilestones:b,currentUserId:f,canManage:g,saving:v,onToggleLabel:K,onSetIssueType:O,onToggleAssignee:J,onSetMilestone:B,onToggleSubscription:H,canManageLock:W,onToggleLock:V,canManagePin:X,onTogglePin:Q})})]}),(0,n.jsxs)("main",{"data-localapp-issue-discussion":!0,"data-testid":"issue-discussion",className:"min-w-0 py-6",children:[(0,n.jsxs)("article",{"data-localapp-issue-body-card":!0,"data-testid":"issue-body-card",className:"min-w-0 overflow-hidden rounded-[6px] border bg-card",children:[(0,n.jsx)("header",{className:"border-b bg-muted/20 px-4 py-3",children:(0,n.jsx)(t7,{identity:ew,timestamp:h.issue.created_at,timestampHref:z(),timestampSuffix:h.issue.revision_count?(0,n.jsx)("button",{type:"button","aria-label":"查看 Issue 编辑历史,".concat(h.issue.revision_count," 次修改"),className:"-my-2 inline-flex h-11 items-center px-1 text-muted-foreground hover:underline sm:-my-0 sm:h-6",onClick:e=>F(e.currentTarget),children:"edited"}):void 0,badge:"Author",action:w})}),(0,n.jsxs)("div",{className:"min-w-0 px-4 py-4",children:[(0,n.jsx)(ea,{tasksDisabled:!!h.issue.locked_at||"issue"===ec||ef,onToggleTask:ed?(e,t)=>{ed(e,t).catch(()=>void 0)}:void 0,onConvertTask:eu&&!h.issue.locked_at?(e,t,s)=>{eg(null),ep({index:e,title:t,trigger:s})}:void 0,getIssueReferenceHref:q,onOpenIssueReference:U,children:h.issue.description.trim()||"未提供描述。"}),(0,n.jsx)(sF,{pagePath:m,attachments:ej}),(0,n.jsx)(sa,{reactions:null!=(d=h.reactions)?d:[],currentUserId:f,additionsDisabled:!!h.issue.locked_at,onToggle:eo})]})]}),(0,n.jsx)(sR,{pagePath:m,detail:h,identities:p,canManage:Z,saving:v,getIssueHref:q,onOpenIssue:U,onCreate:null!=G?G:()=>void 0,onLink:null!=Y?Y:async()=>void 0,onRemove:null!=ee?ee:async()=>void 0,onReprioritize:null!=et?et:async()=>void 0}),(0,n.jsx)(sq,{detail:h,identities:p,canManage:es,saving:v,getIssueHref:q,onOpenIssue:U,onAdd:null!=en?en:async()=>void 0,onRemove:null!=el?el:async()=>void 0}),(0,n.jsx)("div",{className:"mt-5",children:(0,n.jsx)(sS,{issueId:h.issue.id,reporterId:h.issue.reporter_id,pagePath:m,timeline:h.timeline,attachments:h.attachments,identities:p,currentUserId:f,reactions:null!=(u=h.reactions)?u:[],commentDraftPrefix:k,onToggleReaction:eo,onEditComment:I,onDeleteComment:S,canManageCommentPins:A,onToggleCommentPin:C,canManageCommentMinimization:E,onToggleCommentMinimized:_,onQuoteComment:T,onReferenceComment:L,selectedCommentId:R,getCommentHref:D,getIssueReferenceHref:q,onOpenIssueReference:U,onCopyCommentLink:P,onViewHistory:$,savingTaskTarget:"number"==typeof ec?ec:null,onToggleCommentTask:em,interactionsLocked:!!h.issue.locked_at})}),j&&(0,n.jsx)("div",{className:"mt-4 flex justify-end",children:j}),N&&(0,n.jsx)("div",{className:"mt-6 border-t pt-5",children:N})]}),(0,n.jsx)("aside",{"data-localapp-issue-metadata":!0,"data-testid":"issue-metadata-desktop",className:"max-lg:hidden min-w-0 border-l py-6 pl-6",children:(0,n.jsx)(sM,{detail:h,identities:p,availableLabels:x,availableMilestones:b,currentUserId:f,canManage:g,saving:v,onToggleLabel:K,onSetIssueType:O,onToggleAssignee:J,onSetMilestone:B,onToggleSubscription:H,canManageLock:W,onToggleLock:V,canManagePin:X,onTogglePin:Q})}),eh&&(0,n.jsx)(sD,{initialTitle:eh.title,saving:ef,error:eb,onCancel:()=>{let e=eh.trigger;ep(null),eg(null),window.requestAnimationFrame(()=>e.focus())},onConfirm:async e=>{ex(!0),eg(null);try{let t=await eu(eh.index,e);ey(t),ep(null)}catch(e){throw eg(e instanceof Error?e.message:"无法转换任务"),e}finally{ex(!1)}}})]})}function sO(e){let{pagePath:t,issueId:s,commentId:a,currentTitle:r,currentBody:i,currentUpdatedAt:o,identities:c,returnFocus:d,onClose:u}=e,[m,h]=(0,l.useState)([]),[p,f]=(0,l.useState)(!0),[b,g]=(0,l.useState)(null),v=(0,l.useRef)(null),y=(0,l.useCallback)(async()=>{f(!0),g(null);try{h(await eG(t,s,a))}catch(e){g(e instanceof Error?e.message:"无法加载编辑历史")}finally{f(!1)}},[a,s,t]);(0,l.useEffect)(()=>{y()},[y]),(0,l.useEffect)(()=>{var e;return null==(e=v.current)||e.focus(),()=>{(null==d?void 0:d.isConnected)&&d.focus()}},[d]);let w=()=>u(),j=m[0]?t6(m[0].editor_id,c):null;return(0,n.jsx)("div",{"data-localapp-issue-history-layer":!0,className:"absolute inset-0 z-[70] flex items-center justify-center bg-black/45 p-0 sm:p-4",onMouseDown:e=>{e.target===e.currentTarget&&w()},children:(0,n.jsxs)("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":"issue-history-title","aria-describedby":"issue-history-target",tabIndex:-1,onKeyDown:e=>{if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),w();return}if("Tab"!==e.key||!v.current)return;e.stopPropagation();let t=Array.from(v.current.querySelectorAll("button:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])"));if(!t.length){e.preventDefault(),v.current.focus();return}let s=t[0],n=t[t.length-1];e.shiftKey&&(document.activeElement===s||document.activeElement===v.current)?(e.preventDefault(),n.focus()):e.shiftKey||document.activeElement!==n||(e.preventDefault(),s.focus())},className:"flex h-full w-full max-w-4xl flex-col overflow-hidden bg-card shadow-2xl outline-none sm:h-[min(760px,calc(100%-2rem))] sm:rounded-lg sm:border",children:[(0,n.jsxs)("header",{className:"flex min-h-14 items-center gap-3 border-b px-4 py-3 sm:px-5",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h3",{id:"issue-history-title",className:"truncate text-sm font-semibold",children:"编辑历史"}),(0,n.jsx)("p",{id:"issue-history-target",className:"truncate text-xs text-muted-foreground",children:void 0===a?"Issue #".concat(s):"评论 #".concat(a)})]}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"关闭编辑历史",onClick:w,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-5",children:p?(0,n.jsx)("p",{role:"status",className:"py-12 text-center text-sm text-muted-foreground",children:"正在加载编辑历史..."}):b?(0,n.jsxs)("div",{role:"alert",className:"mx-auto max-w-md rounded-[6px] border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:[(0,n.jsx)("p",{children:b}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"mt-3 h-11 sm:h-8",onClick:()=>void y(),children:"重试"})]}):(0,n.jsxs)("ol",{"aria-label":"编辑历史版本",className:"space-y-4",children:[(0,n.jsxs)("li",{className:"overflow-hidden rounded-[6px] border",children:[(0,n.jsxs)("header",{className:"border-b bg-muted/20 px-4 py-2.5 text-xs",children:[(0,n.jsx)("strong",{children:"当前版本"}),(0,n.jsxs)("span",{className:"ml-2 text-muted-foreground",children:[new Date(o).toLocaleString(),j?" \xb7 ".concat(j.displayName||j.name||j.id):""]})]}),(0,n.jsxs)("div",{className:"min-w-0 px-4 py-4",children:[void 0!==r&&(0,n.jsx)("h4",{className:"mb-3 break-words text-base font-semibold",children:r}),(0,n.jsx)(ea,{children:i.trim()||"未提供内容。"})]})]}),m.map(e=>{let t=t6(e.editor_id,c);return(0,n.jsxs)("li",{className:"overflow-hidden rounded-[6px] border",children:[(0,n.jsxs)("header",{className:"border-b bg-muted/20 px-4 py-2.5 text-xs",children:[(0,n.jsx)("strong",{children:"编辑前版本"}),(0,n.jsxs)("span",{className:"ml-2 text-muted-foreground",children:[new Date(e.created_at).toLocaleString()," \xb7 ",t.displayName||t.name||t.id]})]}),(0,n.jsxs)("div",{className:"min-w-0 px-4 py-4",children:[null!==e.title&&(0,n.jsx)("h4",{className:"mb-3 break-words text-base font-semibold",children:e.title}),(0,n.jsx)(ea,{children:e.body.trim()||"未提供内容。"})]})]},e.id)})]})})]})})}function sJ(){return(0,n.jsxs)("div",{role:"status","aria-label":"正在加载 Issue 详情",className:"min-h-0 flex-1 overflow-hidden px-5 py-5 sm:px-6",children:[(0,n.jsx)("span",{className:"sr-only",children:"正在加载 Issue 详情"}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,3fr)_minmax(240px,1fr)]",children:[(0,n.jsxs)("div",{className:"space-y-3 border-b pb-5 lg:col-span-2",children:[(0,n.jsx)("div",{className:"h-9 w-2/3 rounded bg-muted motion-safe:animate-pulse"}),(0,n.jsx)("div",{className:"h-7 w-56 rounded bg-muted/70 motion-safe:animate-pulse"})]}),(0,n.jsxs)("main",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"overflow-hidden rounded-[6px] border",children:[(0,n.jsx)("div",{className:"h-14 border-b bg-muted/30 motion-safe:animate-pulse"}),(0,n.jsxs)("div",{className:"space-y-3 p-4",children:[(0,n.jsx)("div",{className:"h-4 w-full rounded bg-muted motion-safe:animate-pulse"}),(0,n.jsx)("div",{className:"h-4 w-5/6 rounded bg-muted motion-safe:animate-pulse"}),(0,n.jsx)("div",{className:"h-4 w-1/2 rounded bg-muted motion-safe:animate-pulse"})]})]}),Array.from({length:2},(e,t)=>(0,n.jsx)("div",{className:"h-20 rounded-[6px] border bg-muted/20 motion-safe:animate-pulse"},t))]}),(0,n.jsx)("aside",{className:"hidden space-y-6 border-l pl-6 lg:block",children:Array.from({length:4},(e,t)=>(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("div",{className:"h-3 w-20 rounded bg-muted"}),(0,n.jsx)("div",{className:"h-7 w-32 rounded bg-muted/70 motion-safe:animate-pulse"})]},t))})]})]})}function sB(e){let{message:t,onRetry:s,onBack:a}=e,r=(0,l.useRef)(null),i=(0,l.useId)(),o=(0,l.useId)();return(0,l.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{var e;return null==(e=r.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[]),(0,n.jsxs)("div",{role:"alert","aria-labelledby":i,"aria-describedby":o,className:"flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center",children:[(0,n.jsx)(tD.A,{className:"h-10 w-10 text-destructive","aria-hidden":"true"}),(0,n.jsx)("h3",{ref:r,id:i,tabIndex:-1,className:"mt-3 text-base font-semibold outline-none",children:"无法加载 Issue 详情"}),(0,n.jsx)("p",{id:o,className:"mt-1 max-w-md text-sm text-muted-foreground",children:t}),(0,n.jsxs)("div",{className:"mt-4 flex gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8","aria-label":"从错误页返回 Issue 列表",onClick:a,children:"返回列表"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8","aria-label":"重试加载 Issue 详情",onClick:s,children:"重试"})]})]})}function sH(e){let{candidates:t,loading:s,error:a,getIssueHref:l,onOpenIssue:r,onRetry:i}=e;return s||a||0!==t.length?(0,n.jsxs)("section",{"data-localapp-potential-duplicates":!0,"aria-labelledby":"potential-duplicates-title",className:"overflow-hidden rounded-[6px] border bg-muted/10",children:[(0,n.jsxs)("header",{className:"flex min-h-11 items-center gap-2 border-b px-3 py-2",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h3",{id:"potential-duplicates-title",className:"text-sm font-semibold",children:"可能重复的 Issue"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"提交前检查是否已有相同问题"})]}),s&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin text-muted-foreground motion-reduce:animate-none","aria-label":"正在查找潜在重复 Issue"})]}),a?(0,n.jsxs)("div",{role:"alert",className:"flex min-h-11 items-center gap-3 px-3 py-2 text-sm text-destructive",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:a}),(0,n.jsxs)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 shrink-0 gap-1.5 sm:h-8",onClick:i,children:[(0,n.jsx)(K.A,{className:"h-4 w-4"}),"重试"]})]}):t.length>0&&(0,n.jsx)("ul",{"aria-label":"潜在重复 Issues",className:"divide-y",children:t.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("a",{href:l(e.issue_number),className:"flex min-h-11 min-w-0 items-start gap-3 px-3 py-2.5 hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:t=>{0!==t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),r(e.issue_number))},children:["closed"===e.status?(0,n.jsx)(M.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-label":"已关闭"}):(0,n.jsx)(o.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-700","aria-label":"开启"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block break-words text-sm font-medium",children:e.title}),(0,n.jsxs)("span",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsxs)("span",{children:["#",e.issue_number]}),(0,n.jsx)("span",{children:"活动于"}),(0,n.jsx)(tB,{timestamp:e.last_activity_at})]})]})]})},e.id))})]}):null}function sW(e){let{templates:t,loading:s,error:a,onSelect:l,onBlank:r,onRetry:i}=e;return(0,n.jsx)("main",{"data-testid":"issue-template-chooser",className:"min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8",children:(0,n.jsxs)("div",{className:"mx-auto w-full max-w-4xl",children:[(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("h3",{className:"text-base font-semibold",children:"选择 Issue 模板"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"选择最符合当前工作的模板,或从空白 Issue 开始。"})]}),a&&(0,n.jsxs)("div",{role:"alert",className:"mb-4 flex min-h-11 flex-wrap items-center gap-3 rounded-md border border-destructive/40 bg-destructive/5 px-4 py-3 text-sm text-destructive",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:a}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8",onClick:i,children:"重试"})]}),s&&0===t.length?(0,n.jsx)("p",{role:"status",className:"py-10 text-center text-sm text-muted-foreground",children:"正在加载 Issue 模板..."}):(0,n.jsx)("ul",{"aria-label":"Issue 模板",className:"divide-y rounded-md border bg-background",children:t.map(e=>(0,n.jsxs)("li",{className:"flex min-w-0 flex-col gap-3 px-4 py-4 sm:flex-row sm:items-center",children:[(0,n.jsx)("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border bg-muted",children:(0,n.jsx)($.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("strong",{className:"block break-words text-sm",children:e.name}),(0,n.jsx)("span",{className:"mt-1 block break-words text-sm text-muted-foreground",children:e.description})]}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 w-full shrink-0 sm:h-8 sm:w-auto",onClick:()=>l(e),children:"开始"})]},e.id))}),(0,n.jsxs)("div",{className:"mt-5 flex min-w-0 flex-col gap-3 rounded-md border border-dashed px-4 py-4 sm:flex-row sm:items-center",children:[(0,n.jsx)("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border bg-muted",children:(0,n.jsx)(j.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("strong",{className:"block text-sm",children:"空白 Issue"}),(0,n.jsx)("span",{className:"mt-1 block text-sm text-muted-foreground",children:"不使用模板,自由填写标题和描述。"})]}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 w-full shrink-0 sm:h-8 sm:w-auto",onClick:r,children:"打开空白 Issue"})]})]})})}let sV=/!?\[[^\]]*\]\((?:https?:\/\/[^)]+)?\/api\/issues\/attachments\/[^)]+\)/gi;function sX(e){return Array.from(e.trim()).length}function sQ(e,t){try{t?window.sessionStorage.setItem(e,JSON.stringify(t)):window.sessionStorage.removeItem(e)}catch(e){}}function sZ(){var e,t,s;return null!=(s=null==(t=globalThis.crypto)||null==(e=t.randomUUID)?void 0:e.call(t))?s:"issue-draft-".concat(Date.now(),"-").concat(Math.random())}function sG(e,t){return"localapp:issues:draft:v1:".concat(encodeURIComponent(e),":").concat(encodeURIComponent(t))}function sY(e){try{var t,s;let n=JSON.parse(null!=(t=window.sessionStorage.getItem(e))?t:"null"),a=null!=(s=null==n?void 0:n.issueType)?s:null==n?void 0:n.label;return{title:"string"==typeof(null==n?void 0:n.title)?n.title:"",issueType:"feature"===a?"feature":"bug"===a?"bug":"task",labelIds:Array.isArray(null==n?void 0:n.labelIds)?n.labelIds.filter(e=>"string"==typeof e&&"bug"!==e&&"feature"!==e):[],assigneeIds:Array.isArray(null==n?void 0:n.assigneeIds)?n.assigneeIds.filter(e=>"string"==typeof e):[],milestoneId:"number"==typeof(null==n?void 0:n.milestoneId)&&Number.isSafeInteger(null==n?void 0:n.milestoneId)&&n.milestoneId>0?n.milestoneId:null}}catch(e){return{title:"",issueType:"task",labelIds:[],assigneeIds:[],milestoneId:null}}}function s0(e){try{let t=sY(e);return!!(t.title||"task"!==t.issueType||t.labelIds.length||t.assigneeIds.length||null!==t.milestoneId||window.sessionStorage.getItem("".concat(e,":body"))||window.sessionStorage.getItem("".concat(e,":body:attachments")))}catch(e){return!1}}function s1(e,t,s){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;try{t||"task"!==s||n.length>0||a.length>0||null!==l?window.sessionStorage.setItem(e,JSON.stringify({title:t,issueType:s,labelIds:n,assigneeIds:a,milestoneId:l})):window.sessionStorage.removeItem(e)}catch(e){}}function s2(e){var t;let{pagePath:s,pageName:a,user:r,onClose:i,onIssuesChanged:o,selectedIssueId:c,selectedIssueNumber:d,onIssueNavigate:u}=e,[m,h]=(0,l.useState)({kind:"list"}),[p,f]=(0,l.useState)(()=>ej(new URL(window.location.href))),[b,g]=(0,l.useState)(()=>{let e=ej(new URL(window.location.href));return tJ(e.q,e.searchIn)}),[_,T]=(0,l.useState)([]),[L,R]=(0,l.useState)([]),[D,z]=(0,l.useState)({total:0,open:0,closed:0,limit:25,offset:0}),[q,U]=(0,l.useState)(!0),[P,F]=(0,l.useState)(null),[$,M]=(0,l.useState)(null),[K,O]=(0,l.useState)(!1),[B,H]=(0,l.useState)(!1),[W,V]=(0,l.useState)(null),X=(0,l.useRef)(null),Q=(0,l.useRef)(null),Z=(0,l.useRef)(null),[G,ee]=(0,l.useState)(null),[et,es]=(0,l.useState)(""),[en,ea]=(0,l.useState)(""),[el,er]=(0,l.useState)(""),[ec,ed]=(0,l.useState)(!1),[eu,em]=(0,l.useState)([]),[eh,ef]=(0,l.useState)(!1),[ev,ey]=(0,l.useState)(!0),[ew,ek]=(0,l.useState)(null),[eS,eC]=(0,l.useState)(0),[eE,eT]=(0,l.useState)(null),[eX,eG]=(0,l.useState)([]),[ti,to]=(0,l.useState)(!1),[tc,td]=(0,l.useState)(null),[tu,tm]=(0,l.useState)(!1),[th,tp]=(0,l.useState)(0),[tf,tx]=(0,l.useState)(null),[tb,tg]=(0,l.useState)([]),[tv,tw]=(0,l.useState)(!1),[tj,tk]=(0,l.useState)(null),[tS,tC]=(0,l.useState)(0),[tE,t_]=(0,l.useState)("task"),[tT,tL]=(0,l.useState)([]),[tR,tD]=(0,l.useState)([]),[tz,tq]=(0,l.useState)(null),[tU,tF]=(0,l.useState)(sZ),[t$,tM]=(0,l.useState)(sZ),[tB,tH]=(0,l.useState)(null),[tW,tV]=(0,l.useState)(null),[tQ,tZ]=(0,l.useState)([]),[tG,tY]=(0,l.useState)(!1),[t0,t1]=(0,l.useState)(!1),[t4,t3]=(0,l.useState)(0),[t5,t8]=(0,l.useState)([]),[se,st]=(0,l.useState)(!1),[ss,sn]=(0,l.useState)(!1),[sa,sl]=(0,l.useState)(0),[sr,so]=(0,l.useState)(!1),[sd,su]=(0,l.useState)(null),[sx,sb]=(0,l.useState)([]),[sg,sv]=(0,l.useState)(!1),[sy,sw]=(0,l.useState)(!1),[sj,sN]=(0,l.useState)(!1),[sk,sS]=(0,l.useState)(0),[sA,sC]=(0,l.useState)(!1),[sE,s_]=(0,l.useState)(null),[sT,sL]=(0,l.useState)(!1),[sR,sD]=(0,l.useState)("completed"),[sz,sq]=(0,l.useState)(!1),[sU,sP]=(0,l.useState)(null),[s$,sM]=(0,l.useState)(!1),[s2,s4]=(0,l.useState)(!1),[s3,s5]=(0,l.useState)(!1),[s8,s6]=(0,l.useState)(!1),[s7,s9]=(0,l.useState)(!1),[ne,nt]=(0,l.useState)(!1),ns=r?sG(s,r.id):null,nn=ns?"".concat(ns,":").concat("create"===m.kind&&m.reference?"reference-comment:".concat(m.reference.detail.issue.id,":").concat(m.reference.commentId):"create"):null,na=s.split("/",1)[0],nl=sc(new URL(window.location.href),si),nr=(0,l.useRef)(null),ni=(0,l.useRef)(null),no=(0,l.useRef)(i),nc=(0,l.useRef)(u),nd=(0,l.useRef)(0),nu=(0,l.useRef)(null),nm=(0,l.useRef)(0),nh=(0,l.useRef)(null),np=(0,l.useRef)(null),nf=(0,l.useRef)(null),nx=(0,l.useRef)(null),nb=(0,l.useRef)(!1),ng=(0,l.useRef)(null),nv=(0,l.useRef)(null),ny=(0,l.useRef)(!1),nw=(0,l.useRef)(!1),nj=(0,l.useRef)(!1),nN=(0,l.useRef)(0),nk=(0,l.useRef)(null),nI=(0,l.useRef)(new Set),nS=(0,l.useRef)(m),nA=(0,l.useRef)(null),nC=(0,l.useRef)(p),nE=(0,l.useRef)("undefined"!=typeof document&&document.activeElement instanceof HTMLElement?document.activeElement:null);no.current=i,nc.current=u,nS.current=m,nC.current=p;let n_="edit"===m.kind?m.detail.issue.id:null;(0,l.useEffect)(()=>{let e=nA.current;if(nA.current=n_,null===e||null!==n_)return;let t=window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector('[data-testid="issue-body-card"] button[aria-label="Issue 操作"]'))?void 0:e.focus()});return()=>window.cancelAnimationFrame(t)},[n_]);let nT=(0,l.useCallback)(()=>{var e;(null==(e=nE.current)?void 0:e.isConnected)&&nE.current.focus()},[]),nL=(0,l.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"push";f(s=>{let n=function(e,t){let s={...t};for(let e of eN)"string"==typeof s[e]&&(s[e]=s[e].trim());let n={...e,...s};return"open"===n.status&&(n.reason=""),Object.keys(s).some(t=>"offset"!==t&&e[t]!==n[t])&&(n.offset=0),n}(s,e),a=function(e,t){let s=new URL(e.href);for(let e of(s.searchParams.set("localappIssues","1"),Object.values(eg)))s.searchParams.delete(e);for(let[e,n,a]of[[eg.q,t.q,ep.q],[eg.searchIn,t.searchIn,ep.searchIn],[eg.status,t.status,ep.status],[eg.label,t.label,ep.label],[eg.issueType,t.issueType,ep.issueType],[eg.author,t.author,ep.author],[eg.participant,t.participant,ep.participant],[eg.assignee,t.assignee,ep.assignee],[eg.milestone,t.milestone,ep.milestone],[eg.reason,"closed"===t.status?t.reason:"",ep.reason],[eg.subscribed,+!!t.subscribed,0],[eg.mentioned,+!!t.mentioned,0],[eg.locked,t.locked,ep.locked],[eg.sort,t.sort,ep.sort],[eg.direction,t.direction,ep.direction],[eg.offset,t.offset,ep.offset]])n!==a&&""!==n&&s.searchParams.set(e,String(n));return s}(new URL(window.location.href),n);return a.href!==window.location.href&&window.history["push"===t?"pushState":"replaceState"](null,"",a),n})},[]);(0,l.useEffect)(()=>{let e=()=>{let e=ej(new URL(window.location.href));f(e),g(tJ(e.q,e.searchIn))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let nR=(0,l.useCallback)(()=>{var e,t;let s=null==(e=nr.current)?void 0:e.querySelector('[data-localapp-issue-attachment-queue][aria-busy="true"]');if(s){s.focus(),null==(t=s.scrollIntoView)||t.call(s,{block:"nearest"});return}nT(),no.current()},[nT]),nD=(0,l.useCallback)(function(e,t){var n,a,l;let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];M(null),eT(null);let o=r?sG(s,r.id)+":create":null,c=o?sY(o):{title:"",issueType:"task",labelIds:[],assigneeIds:[],milestoneId:null},d=!!o&&s0(o);ed(d);let u=t&&!d?t.labels.filter(e=>t5.some(t=>t.id===e)):[],m=t&&!d?t.labels.filter(e=>!t5.some(t=>t.id===e)):[];es(d?c.title:null!=(n=null==t?void 0:t.titlePrefix)?n:"");let p=d?"":null!=(a=null==t?void 0:t.body)?a:"";er(p),ea(p),t_(d?c.issueType:null!=(l=null==t?void 0:t.type)?l:"task"),tL(d?c.labelIds:u),tD(c.assigneeIds),tq(c.milestoneId),m.length>0&&eT("模板中的标签已不可用:".concat(m.join("、"))),tF(sZ()),h({kind:"create",...void 0===e?{}:{parentIssueId:e},...i?{returnToTemplates:!0}:{}})},[t5,s,r]),nz=(0,l.useCallback)(()=>{let e=r?"".concat(sG(s,r.id),":create"):null;return e&&s0(e)?void nD():!eh||ev||ew||eu.length>0?void h({kind:"templates"}):void nD()},[eu.length,ew,eh,ev,s,nD,r]);(0,l.useEffect)(()=>{let e=new AbortController;return ey(!0),ek(null),eR(s,e.signal).then(e=>{em(e),ef(!0)}).catch(t=>{e.signal.aborted||(ek(t instanceof Error?t.message:"Issue 模板暂不可用"),ef(!0))}).finally(()=>{e.signal.aborted||ey(!1)}),()=>e.abort()},[eS,s]),(0,l.useEffect)(()=>{if(!r){eG([]),to(!1),td(null),tx(null);return}let e=new AbortController;return to(!0),td(null),eD(s,e.signal).then(eG).catch(t=>{e.signal.aborted||td(t instanceof Error?t.message:"保存视图加载失败")}).finally(()=>{e.signal.aborted||to(!1)}),()=>e.abort()},[s,th,null==r?void 0:r.id]),(0,l.useEffect)(()=>{var e,t;null!==tf&&eX.some(e=>e.id===tf)||tx(null!=(t=null==(e=eX.find(e=>eb(e.query,p)))?void 0:e.id)?t:null)},[tf,p,eX]),(0,l.useEffect)(()=>{if("create"!==m.kind||!et.trim()||Array.from(en).length<100){tg([]),tw(!1),tk(null);return}let e=new AbortController;tg([]),tk(null),tw(!0);let t=window.setTimeout(()=>{eM(s,et.trim(),en,e.signal).then(tg).catch(t=>{e.signal.aborted||t instanceof Error&&"AbortError"===t.name||tk("重复项建议暂不可用")}).finally(()=>{e.signal.aborted||tw(!1)})},400);return()=>{window.clearTimeout(t),e.abort()}},[en,et,s,tS,m.kind]),(0,l.useEffect)(()=>{"create"===m.kind&&nn&&s1(nn,et,tE,tT,tR,tz)},[tR,tE,tT,tz,et,ns,m.kind]),(0,l.useEffect)(()=>{"create"===m.kind&&sg&&null!==tz&&!sx.some(e=>e.id===tz)&&tq(null)},[tz,sx,sg,m.kind]);let nq=(0,l.useCallback)(async e=>{var t;let n=++nd.current;null==(t=nu.current)||t.abort();let a=new AbortController;nu.current=a,U(!0),F(null);try{let t=await e$(s,e,a.signal);if(nd.current!==n)return;T(t.data),R(t.pinned),z(t.meta)}catch(e){if(nd.current!==n||e instanceof DOMException&&"AbortError"===e.name)return;F(e instanceof Error?e.message:"Issue 服务暂不可用")}finally{nd.current===n&&U(!1)}},[s]);(0,l.useEffect)(()=>{if("undefined"==typeof EventSource)return;let e=new URLSearchParams({pagePath:s}),t=null,n=!0,a=e=>{try{var t;let n=JSON.parse(e.data);if((null==(t=n.data)?void 0:t.pagePath)!==s)return;let a="number"==typeof n.data.issueId?n.data.issueId:null;nI.current.add(a),null!==nk.current&&window.clearTimeout(nk.current),nk.current=window.setTimeout(()=>{nk.current=null;let e=new Set(nI.current);nI.current.clear(),nq(nC.current);let t=nS.current;if("edit"===t.kind){(e.has(null)||e.has(t.detail.issue.id))&&s4(!0);return}if("detail"!==t.kind||!e.has(null)&&!e.has(t.detail.issue.id))return;let n=t.detail.issue.id;eQ(s,n).then(e=>{let s=e.issue.updated_at!==t.detail.issue.updated_at||e.timeline.length!==t.detail.timeline.length;h(t=>"detail"===t.kind&&t.detail.issue.id===n?{kind:"detail",detail:e}:t),s&&nt(!0),s4(!1)}).then(()=>s6(!1)).catch(()=>{s6(!0),M("无法同步最新 Issue,当前内容可能已过期")})},120)}catch(e){}},l=()=>{null==t||t.close(),t=null},r=l=>{if("hidden"===document.visibilityState||!n||t||((t=new EventSource("/api/issues/events?".concat(e.toString()))).addEventListener("issue:changed",a),!l))return;nq(nC.current);let r=nS.current;if("detail"===r.kind){let e=r.detail.issue.id;eQ(s,e).then(t=>{h(s=>"detail"===s.kind&&s.detail.issue.id===e?{kind:"detail",detail:t}:s),s6(!1)}).catch(()=>s6(!0))}},i=()=>"hidden"===document.visibilityState?l():r(!0),o=()=>{n=!1,l()},c=()=>{n=!0,r(!0)};return r(!1),document.addEventListener("visibilitychange",i),window.addEventListener("blur",o),window.addEventListener("focus",c),window.addEventListener("pagehide",o),window.addEventListener("pageshow",c),()=>{document.removeEventListener("visibilitychange",i),window.removeEventListener("blur",o),window.removeEventListener("focus",c),window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",c),l(),null!==nk.current&&window.clearTimeout(nk.current),nI.current.clear()}},[nq,s]),(0,l.useEffect)(()=>(nq(p),()=>{var e;return null==(e=nu.current)?void 0:e.abort()}),[nq,p]),(0,l.useEffect)(()=>{if(!r){tY(!1),t1(!1);return}let e=new AbortController,t=!0;return tY(!1),t1(!0),eI(()=>eL(e.signal),e.signal).then(e=>{t&&(tZ(e),tY(!1))}).catch(e=>{!(e instanceof Error&&"AbortError"===e.name)&&t&&tY(!0)}).finally(()=>{t&&t1(!1)}),()=>{t=!1,e.abort()}},[null==r?void 0:r.id,t4]),(0,l.useEffect)(()=>{let e=new AbortController,t=!0;return st(!1),sn(!0),eI(()=>eY(s,e.signal),e.signal).then(e=>{t&&(t8(e),st(!1))}).catch(e=>{t&&!(e instanceof Error&&"AbortError"===e.name)&&st(!0)}).finally(()=>{t&&sn(!1)}),()=>{t=!1,e.abort(new DOMException("Superseded","AbortError"))}},[sa,s]),(0,l.useEffect)(()=>{let e=new AbortController,t=!0;return sw(!1),sN(!0),eI(()=>e1(s,e.signal),e.signal).then(e=>{t&&(sb(e),sv(!0),sw(!1))}).catch(e=>{t&&!(e instanceof Error&&"AbortError"===e.name)&&sw(!0)}).finally(()=>{t&&sN(!1)}),()=>{t=!1,e.abort(new DOMException("Superseded","AbortError"))}},[sk,s]),(0,l.useEffect)(()=>{if(b.trim()===tJ(p.q,p.searchIn))return;let e=[...r?[{id:r.id,name:r.name,displayName:r.name}]:[],...tQ];if(tK(b,b.length,{currentUserId:null==r?void 0:r.id,labels:t5,users:e}).items.length>0)return;let t=window.setTimeout(()=>{nL(tO(b,{currentUserId:null==r?void 0:r.id,labels:t5,milestones:sx}),"replace")},250);return()=>window.clearTimeout(t)},[nL,t5,sx,tQ,p.q,p.searchIn,b,r]),(0,l.useEffect)(()=>{if("list"!==m.kind||q||null===nh.current)return;let e=nh.current,t=window.requestAnimationFrame(()=>{var t;let s=document.querySelector('[data-testid="issue-row-'.concat(e,'"] a'));null==(t=null!=s?s:ni.current)||t.focus(),nh.current=null});return()=>window.cancelAnimationFrame(t)},[_,q,m.kind]),(0,l.useEffect)(()=>{var e;null==(e=nr.current)||e.focus();let t=e=>{var t,s,n,a,l;let i=e.target,o=i instanceof Element&&i.closest('[role="dialog"]')!==nr.current;if(o)return;if("Escape"===e.key){e.preventDefault(),nR();return}let c=i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName));if("/"===e.key&&(e.metaKey||e.ctrlKey)&&"list"===m.kind&&!c){e.preventDefault(),null==(s=ni.current)||s.focus();return}if("/"===e.key&&"list"===m.kind&&!c){e.preventDefault(),null==(n=ni.current)||n.focus();return}if("c"===e.key.toLowerCase()&&"list"===m.kind&&r&&!c&&!e.metaKey&&!e.ctrlKey&&!e.altKey){e.preventDefault(),nz();return}if("r"===e.key.toLowerCase()&&"detail"===m.kind&&r&&(null==(t=nr.current)?void 0:t.querySelector("[data-localapp-issue-comment-composer]"))&&!c&&!o&&!e.metaKey&&!e.ctrlKey&&!e.altKey){e.preventDefault(),(()=>{var e,t,s,n;let a=null==(e=nr.current)?void 0:e.querySelector("[data-localapp-issue-comment-composer] textarea");null==a||null==(n=a.scrollIntoView)||n.call(a,{block:"center",behavior:(null==(t=(s=window).matchMedia)?void 0:t.call(s,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth"}),window.requestAnimationFrame(()=>null==a?void 0:a.focus())})();return}let d={u:"按创建者筛选",l:"按标签筛选",m:"按里程碑筛选",a:"按负责人筛选"}[e.key.toLowerCase()];if(d&&"list"===m.kind&&!c&&!o&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&nr.current){let t=nr.current.querySelector('select[aria-label="'.concat(d,'"]'));if(t){e.preventDefault();let s=t.closest("#localapp-issue-advanced-filters");(null==s?void 0:s.classList.contains("hidden"))&&(null==(a=nr.current.querySelector('[aria-controls="localapp-issue-advanced-filters"]'))||a.click()),window.requestAnimationFrame(()=>t.focus());return}}if("o"===e.key.toLowerCase()&&"list"===m.kind&&!c&&!o&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&document.activeElement instanceof HTMLAnchorElement&&document.activeElement.matches("[data-localapp-issue-link]")){e.preventDefault(),document.activeElement.click();return}let u=e.key.toLowerCase(),h="j"===u||"ArrowDown"===e.key?1:"k"===u||"ArrowUp"===e.key?-1:0;if(0!==h&&"list"===m.kind&&!c&&!o&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&nr.current){let t=Array.from(nr.current.querySelectorAll("[data-localapp-issue-link]")),s=t.indexOf(document.activeElement),n="ArrowDown"===e.key||"ArrowUp"===e.key;if(t.length>0&&(!n||t.includes(document.activeElement))){e.preventDefault();let n=s<0?h>0?0:t.length-1:(s+h+t.length)%t.length;null==(l=t[n])||l.focus();return}}if("ArrowLeft"===e.key&&e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&"list"!==m.kind&&!c&&!o){e.preventDefault(),nV();return}if("Tab"!==e.key||!nr.current)return;let p=Array.from(nr.current.querySelectorAll("button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])")).filter(e=>(function(e,t){for(let s=e;s&&!s.hidden&&"true"!==s.getAttribute("aria-hidden");s=s.parentElement){let e=window.getComputedStyle(s);if("none"===e.display||"hidden"===e.visibility)break;if(s===t)return!0}return!1})(e,nr.current));if(!p.length){e.preventDefault(),nr.current.focus();return}let f=p[0],x=p[p.length-1];e.shiftKey&&(document.activeElement===f||document.activeElement===nr.current)?(e.preventDefault(),x.focus()):e.shiftKey||document.activeElement!==x&&document.activeElement!==nr.current||(e.preventDefault(),f.focus())};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t),nT()}},[nz,nR,nT,r,m.kind]);let nU=(0,l.useCallback)(async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=++nm.current;M(null),s6(!1),nt(!1),ee(null),h({kind:"detail-loading",issueId:e,lookupByNumber:n});try{let t=await (n?eZ(s,e):eQ(s,e));if(nm.current!==a)return;if(n){var l;null==(l=nc.current)||l.call(nc,t.issue.id,"replace");let e=nf.current;if(nf.current=null,null!==e){let s=sp(new URL(window.location.href),t.issue.id,e);window.history.replaceState(window.history.state,"",s)}}ee(null),tM(sZ()),h({kind:"detail",detail:t})}catch(e){if(nm.current!==a)return;ee(null!=t?t:null),M(e instanceof Error?e.message:"Issue 服务暂不可用")}},[s]);(0,l.useEffect)(()=>{if(void 0!==c){if(null===c){if(null!=d)return;++nm.current,h(e=>"detail"===e.kind||"detail-loading"===e.kind||"edit"===e.kind?{kind:"list"}:e);return}("detail"===m.kind||"edit"===m.kind?m.detail.issue.id:"detail-loading"!==m.kind||m.lookupByNumber?null:m.issueId)!==c&&nU(c)}},[nU,c,d,m]),(0,l.useEffect)(()=>{null!=d&&("detail"===m.kind||"edit"===m.kind?m.detail.issue.issue_number:"detail-loading"===m.kind&&m.lookupByNumber?m.issueId:null)!==d&&nU(d,void 0,!0)},[nU,d,m]);let nP=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;nf.current=t,nU(e,void 0,!0)},nF=e=>sm(new URL(window.location.href),e),n$=e=>{let t=nF(e);return"".concat(t.pathname).concat(t.search).concat(t.hash)},nM=e=>{let t=sh(new URL(window.location.href),e);return"".concat(t.pathname).concat(t.search).concat(t.hash)},nK=(e,t)=>sp(new URL(window.location.href),e,t),nO=(e,t)=>{let s=nK(e,t);return"".concat(s.pathname).concat(s.search).concat(s.hash)},nJ=async e=>{M(null);try{await sf(nF(e).href),sM(!0)}catch(e){sM(!1),M("无法复制 Issue 链接,请从浏览器地址栏复制")}},nB=async e=>{h({kind:"detail",detail:await eQ(s,e)}),s6(!1)},nH=async()=>{let e=nS.current;if(!s7&&"detail"===e.kind){s9(!0);try{await nB(e.detail.issue.id),M(null)}catch(e){s6(!0),M("无法同步最新 Issue,当前内容可能已过期")}finally{s9(!1)}}},nW=async()=>{let e=nS.current;if(!s3&&"edit"===e.kind){s5(!0);try{let t=await eQ(s,e.detail.issue.id);if(ns){sQ("".concat(ns,":edit:").concat(e.detail.issue.id,":meta"),null);try{window.sessionStorage.removeItem("".concat(ns,":edit:").concat(e.detail.issue.id,":body"))}catch(e){}}h({kind:"detail",detail:t}),s4(!1)}catch(e){M("无法加载最新 Issue")}finally{s5(!1)}}},nV=e=>{let t=nS.current;"create"===t.kind&&(ny.current=!0),("detail"===t.kind||"edit"===t.kind)&&null===nh.current&&(nh.current=t.detail.issue.id),++nm.current,e&&nL({status:e}),h({kind:"list"}),nt(!1),null==u||u(null)};(0,l.useEffect)(()=>{if("list"!==m.kind||!ny.current)return;ny.current=!1;let e=window.requestAnimationFrame(()=>{var e;return null==(e=nv.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[m.kind]),(0,l.useEffect)(()=>{if("list"!==m.kind||q||P||!nw.current)return;nw.current=!1;let e=window.requestAnimationFrame(()=>{var e;return null==(e=ni.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[P,q,m.kind]);let nX=ss||t0||sj;(0,l.useEffect)(()=>{if(nj.current&&!nX&&!se&&!tG&&!sy){nj.current=!1;let e=nS.current,t="list"===e.kind?null:"create"===e.kind?"#issue-title":"edit"===e.kind?"#issue-edit-title":"[data-localapp-issue-title]";window.requestAnimationFrame(()=>{var e;return null==(e=t?document.querySelector(t):ni.current)?void 0:e.focus()})}},[nX,se,sy,tG]);let nQ=null!=(t=eX.find(e=>e.id===tf))?t:null,nZ=!!(nQ&&!eb(nQ.query,p)),nG=async(e,t)=>{tm(!0),td(null);try{let n=await eq(s,e,t,p);eG(e=>[...e,n]),tx(n.id)}finally{tm(!1)}},nY=async(e,t)=>{tm(!0),td(null);try{let n=await eU(s,e,t);eG(t=>t.map(t=>t.id===e?n:t))}finally{tm(!1)}},n0=async e=>{tm(!0),td(null);try{let t=await eP(s,e);eG(e=>[...e,t])}finally{tm(!1)}},n1=async e=>{tm(!0),td(null);try{await eF(s,e),eG(t=>t.filter(t=>t.id!==e)),tf===e&&tx(null)}finally{tm(!1)}},n2=async e=>{let{body:t,attachmentIds:n,draftId:a}=e;if(et.trim()){M(null);try{let e=await e9({pagePath:s,title:et.trim(),description:t,issueType:tE,draftId:a,attachmentIds:n,...(null==r?void 0:r.id)===na?{labelIds:tT,assigneeIds:tR,...null===tz?{}:{milestoneId:tz},..."create"===m.kind&&void 0!==m.parentIssueId?{parentIssueId:m.parentIssueId}:{}}:{}});es(""),er(""),ea(""),ed(!1),t_("task"),tL([]),tD([]),tq(null),ns&&s1(null!=nn?nn:"".concat(ns,":create"),"","task",[],[],null),tF(sZ()),g(""),nL({...ep},"replace"),null==o||o(),null==u||u(e.id),await nU(e.id,e)}catch(e){throw e}}},n4=async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.draftId?"composer":"workspace";M(null);try{let a=void 0!==t.title||void 0!==t.description;await te(s,e.issue.id,{...t,...a&&void 0===t.expectedUpdatedAt?{expectedUpdatedAt:e.issue.updated_at}:{}}),await Promise.all([nB(e.issue.id),nq(p)]),n&&(null==o||o())}catch(e){throw e instanceof eA&&s4(!0),"workspace"===a&&M(e instanceof Error?e.message:"Issue 服务暂不可用"),e}},n3=async(e,t)=>{M(null);try{let n=await tt(s,e.issue.id,t),a=new Set(e.timeline.flatMap(e=>"comment"===e.kind?[e.comment.id]:[])),l=n.timeline.find(e=>"comment"===e.kind&&!a.has(e.comment.id));if((null==l?void 0:l.kind)==="comment"){let t=sp(new URL(window.location.href),e.issue.id,l.comment.id);window.history.replaceState(window.history.state,"",t)}tM(sZ()),h({kind:"detail",detail:n}),await nq(p),t.statusAction&&(null==o||o())}catch(e){throw e}},n5="detail"===m.kind||"edit"===m.kind?m.detail:null,n8=sX(et),n6=n8>256,n7=n5?sX(n5.issue.title):0,n9=n7>256;(0,l.useEffect)(()=>{if(tW)return;if("list"===m.kind||"create"===m.kind||"detail-loading"===m.kind){ng.current=null;return}if("detail"!==m.kind||!n5||ng.current===n5.issue.id||(ng.current=n5.issue.id,nl))return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector("[data-localapp-issue-title]"))?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[null==n5?void 0:n5.issue.id,tW,nl,m.kind]),(0,l.useEffect)(()=>{if("detail"!==m.kind||null===np.current)return;let e=np.current,t=0,s=0,n=()=>{var a,l;if(null==(a=nr.current)?void 0:a.querySelector('[role="alertdialog"]')){t++<20&&(s=window.setTimeout(n,30));return}let r=null==(l=nr.current)?void 0:l.querySelector('[data-localapp-issue-reference="'.concat(e,'"]'));if(null==r||r.focus(),r&&document.activeElement===r){np.current=null;return}t++<10&&(s=window.setTimeout(n,30))};return s=window.setTimeout(n,0),()=>window.clearTimeout(s)},[null==n5?void 0:n5.issue.description,m.kind]),(0,l.useEffect)(()=>{if(sT||!nb.current)return;nb.current=!1;let e=window.requestAnimationFrame(()=>{var e;return null==(e=nx.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[null==n5?void 0:n5.issue.status,sT]);let ae=!!(n5&&r&&(r.id===n5.issue.reporter_id||r.id===na)),at=!!(n5&&(null==r?void 0:r.id)===na),as=n5&&ns?"".concat(ns,":edit:").concat(n5.issue.id,":meta"):null,an=n5&&ns?"".concat(ns,":edit:").concat(n5.issue.id,":body"):void 0,aa=e=>{if(as&&sQ(as,null),an)try{window.sessionStorage.removeItem(an)}catch(e){}ty(s,an),s4(!1),h({kind:"detail",detail:e.originalDetail})},al=!!(r&&r.id===na),ar="edit"===m.kind?m.detail.attachments.filter(e=>e.issue_id===m.detail.issue.id&&null===e.comment_id&&!m.removedAttachmentIds.includes(e.id)):[],ai="edit"===m.kind&&m.removedAttachmentIds.length>0?(()=>{let e=m.removedAttachmentIds.at(-1),t=m.originalDetail.attachments.find(t=>t.id===e);return t?{id:e,url:t.url}:null})():null,ao=Array.from(new Map([...r?[{id:r.id,name:r.name,displayName:r.name,avatarUrl:null}]:[],...tQ].map(e=>[e.id,e])).values()),ac=ao.filter(e=>e.id),ad=async e=>{sq(!0),M(null);try{let t=await e();h({kind:"detail",detail:t}),await nq(p)}catch(e){throw e}finally{sq(!1)}},au=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"completed";nb.current=!0,sL(!0);try{await n4(e,"open"===e.issue.status?{status:"closed",stateReason:t}:{status:"open",stateReason:null},!0)}catch(e){}finally{sL(!1)}},am=n5?"Issue #".concat(n5.issue.issue_number," \xb7 ").concat(n5.issue.title):null,ah="templates"===m.kind?"新建 Issue":"create"===m.kind?void 0===m.parentIssueId?"新建 Issue":"新建 Sub-issue":"labels"===m.kind?"标签":"milestones"===m.kind?"里程碑":"detail-loading"===m.kind?"Issue #".concat(m.issueId):null!=am?am:"Issues";return(0,n.jsxs)("div",{"data-localapp-issues-layer":!0,className:"absolute inset-0 z-50 flex items-center justify-center p-0 sm:p-2",children:[(0,n.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-black/45","aria-hidden":"true"}),(0,n.jsxs)("div",{ref:nr,role:"dialog","aria-modal":"true","aria-labelledby":"issues-dialog-title",tabIndex:-1,"data-localapp-issues-workspace":!0,className:"relative flex h-full w-full flex-col overflow-hidden bg-card shadow-2xl outline-none sm:rounded-lg sm:border",children:[(0,n.jsxs)("header",{className:"flex min-h-14 items-center gap-3 border-b px-4 py-3 sm:px-5",children:["list"!==m.kind&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"create"===m.kind&&void 0!==m.parentIssueId?"返回父 Issue":"create"===m.kind&&m.returnToTemplates?"返回模板选择":"返回 Issue 列表","aria-keyshortcuts":"Alt+ArrowLeft",onClick:()=>{"create"===m.kind&&void 0!==m.parentIssueId?(null==u||u(m.parentIssueId),nU(m.parentIssueId)):"create"===m.kind&&m.returnToTemplates?h({kind:"templates"}):nV()},children:(0,n.jsx)(v.A,{className:"h-4 w-4"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h2",{id:"issues-dialog-title",title:null!=am?am:void 0,className:"min-w-0 truncate text-sm font-semibold",children:ah}),(0,n.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:a})]}),"list"===m.kind&&(null==r?void 0:r.id)===na&&(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 gap-1.5 sm:h-8","aria-label":"管理 Issue 里程碑",onClick:()=>{s_(null),h({kind:"milestones"}),e1(s).then(sb).catch(e=>s_(e instanceof Error?e.message:"里程碑加载失败"))},children:[(0,n.jsx)(y.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden md:inline",children:"里程碑"})]}),"list"===m.kind&&(null==r?void 0:r.id)===na&&(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 gap-1.5 sm:h-8","aria-label":"管理 Issue 标签",onClick:()=>{su(null),h({kind:"labels"})},children:[(0,n.jsx)(w.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"标签"})]}),"list"===m.kind&&r&&(0,n.jsxs)(x.$,{ref:nv,type:"button",size:"sm",className:"h-11 shrink-0 gap-1.5 sm:h-8","aria-label":"新建 Issue","aria-keyshortcuts":"C",onClick:nz,children:[(0,n.jsx)(j.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"新建 Issue"})]}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"关闭 Issue 面板","aria-keyshortcuts":"Escape",onClick:nR,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(se||tG||sy)&&!("list"===m.kind&&P&&0===_.length)&&(0,n.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center justify-between gap-3 border-b border-amber-500/30 bg-amber-500/10 px-5 py-2.5 text-sm",children:[(0,n.jsx)("span",{children:Number(se)+Number(tG)+Number(sy)>1?"元数据目录加载失败,正在显示可用的本地信息":se?"标签目录暂不可用":tG?"负责人目录加载失败,正在显示已知用户":"里程碑目录加载失败,正在显示已知里程碑"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-7",disabled:nX,"aria-label":Number(se)+Number(tG)+Number(sy)>1?"重试元数据目录":se?"重试标签目录":tG?"重试负责人目录":"重试里程碑目录",onClick:()=>{nj.current=!0,se&&sl(e=>e+1),tG&&t3(e=>e+1),sy&&sS(e=>e+1)},children:nX?"正在重试...":"重试"})]}),$&&"list"!==m.kind&&"detail-loading"!==m.kind&&(0,n.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center justify-between gap-3 border-b border-destructive/20 bg-destructive/10 px-5 py-2.5 text-sm text-destructive",children:[(0,n.jsx)("span",{children:$}),s8&&(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-7",disabled:s7,onClick:()=>void nH(),children:s7?"正在同步...":"重新同步"})]}),ne&&"detail"===m.kind&&(0,n.jsxs)("div",{role:"status","aria-label":"Issue 协作更新",className:"flex min-h-11 items-center gap-3 border-b bg-muted/60 px-5 py-2 text-sm",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:"已同步最新协作活动"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-7 sm:w-7","aria-label":"关闭协作更新提示",onClick:()=>nt(!1),children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),s2&&"edit"===m.kind&&(0,n.jsxs)("div",{role:"status",className:"flex flex-wrap items-center justify-between gap-3 border-b bg-muted px-5 py-2.5 text-sm",children:[(0,n.jsx)("span",{children:"此 Issue 有新变更,你的编辑内容尚未被覆盖。"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-8",disabled:s3,onClick:()=>{nW()},children:s3?"正在加载...":"放弃草稿并加载最新"})]}),"list"===m.kind&&(0,n.jsx)(t2,{currentUserId:null==r?void 0:r.id,error:P,issues:_,pinnedIssues:L,labels:t5,milestones:sx,users:ao,loading:q,meta:D,query:p,searchInput:b,searchInputRef:ni,onOpenIssue:e=>{nh.current=e.id,null==u||u(e.id),nU(e.id,e)},getIssueHref:e=>n$(e.id),onQueryChange:e=>nL(e),onReset:()=>{g(""),nL({q:"",searchIn:"",label:"",author:"",participant:"",assignee:"",milestone:"",subscribed:!1,mentioned:!1,locked:"",offset:0})},onRetry:()=>{nw.current=!0,nq(p)},onSearchInputChange:g,onSubmitSearch:()=>{var e;let t=tO(b,{currentUserId:null==r?void 0:r.id,labels:t5,milestones:sx});g(tJ(t.q,null!=(e=t.searchIn)?e:"")),nL(t)},savedViews:eX,savedViewsLoading:ti,savedViewsError:tc,savedViewsSaving:tu,activeSavedViewId:tf,savedViewDirty:nZ,onApplySavedView:e=>{let t=ex(e.query);tx(e.id),g(tJ(t.q,t.searchIn)),nL(t)},onCreateSavedView:nG,onUpdateSavedView:nY,onCopySavedView:n0,onDeleteSavedView:n1,onRetrySavedViews:()=>tp(e=>e+1),onLeaveSavedView:()=>tx(null),canBulkManage:!!(r&&r.id===s.split("/",1)[0]),onBulkStatus:async(e,t)=>{let n=await Promise.allSettled(e.map(e=>te(s,e,{status:t}))),a=e.filter((e,t)=>"rejected"===n[t].status);return await nq(p),n.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:n.length-a.length,failedIds:a}},onBulkIssueType:async(e,t)=>{let n=await Promise.allSettled(e.map(e=>te(s,e,{issueType:t}))),a=e.filter((e,t)=>"rejected"===n[t].status);return await nq(p),n.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:n.length-a.length,failedIds:a}},onBulkLabel:async(e,t,n)=>{let a=await Promise.allSettled(e.map(e=>{var a,l;let r=_.find(t=>t.id===e),i=null!=(l=null==r||null==(a=r.labels)?void 0:a.map(e=>e.id))?l:[];return e3(s,e,n?Array.from(new Set([...i,t])):i.filter(e=>e!==t))})),l=e.filter((e,t)=>"rejected"===a[t].status);return await nq(p),a.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:a.length-l.length,failedIds:l}},onBulkAssignee:async(e,t,n)=>{let a=await Promise.allSettled(e.map(e=>{var a,l;let r=null!=(l=null==(a=_.find(t=>t.id===e))?void 0:a.assignee_ids)?l:[];return e5(s,e,n?Array.from(new Set([...r,t])):r.filter(e=>e!==t))})),l=e.filter((e,t)=>"rejected"===a[t].status);return await nq(p),a.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:a.length-l.length,failedIds:l}},onBulkMilestone:async(e,t)=>{let n=await Promise.allSettled(e.map(e=>e8(s,e,t))),a=e.filter((e,t)=>"rejected"===n[t].status);return await nq(p),n.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:n.length-a.length,failedIds:a}}}),"labels"===m.kind&&(0,n.jsx)(tI,{labels:t5,saving:sr,error:sd,onCreate:async e=>{so(!0),su(null);try{await e_("/api/issues/labels",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:s,...e})}),t8(await eY(s))}catch(e){throw su(e instanceof Error?e.message:"标签保存失败"),e}finally{so(!1)}},onUpdate:async(e,t)=>{so(!0),su(null);try{await e_("/api/issues/labels/".concat(encodeURIComponent(e)),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:s,...t})}),t8(await eY(s))}catch(e){throw su(e instanceof Error?e.message:"标签保存失败"),e}finally{so(!1)}},onDelete:async e=>{so(!0),su(null);try{await e0(s,e),t8(await eY(s)),await nq(p)}catch(e){throw su(e instanceof Error?e.message:"标签删除失败"),e}finally{so(!1)}}}),"milestones"===m.kind&&(0,n.jsx)(tA,{milestones:sx,saving:sA,error:sE,onCreate:async e=>{sC(!0),s_(null);try{await e_("/api/issues/milestones",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:s,...e})}),sb(await e1(s))}catch(e){throw s_(e instanceof Error?e.message:"里程碑保存失败"),e}finally{sC(!1)}},onUpdate:async(e,t)=>{sC(!0),s_(null);try{await e_("/api/issues/milestones/".concat(e),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:s,...t})}),sb(await e1(s))}catch(e){throw s_(e instanceof Error?e.message:"里程碑保存失败"),e}finally{sC(!1)}},onDelete:async e=>{sC(!0),s_(null);try{await e2(s,e),sb(await e1(s));let t=p.milestone===String(e)?{...p,milestone:"none",offset:0}:p;t!==p&&nL({milestone:"none"}),await nq(t)}catch(e){throw s_(e instanceof Error?e.message:"里程碑删除失败"),e}finally{sC(!1)}}}),"detail-loading"===m.kind&&($?(0,n.jsx)(sB,{message:$,onRetry:()=>void nU(m.issueId,null!=G?G:void 0,m.lookupByNumber),onBack:()=>nV()}):(0,n.jsx)(sJ,{})),n5&&("detail"===m.kind||"edit"===m.kind)&&(0,n.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:[K&&(0,n.jsxs)("div",{role:"alertdialog","aria-label":"删除 Issue 确认","aria-describedby":"delete-issue-description",onKeyDown:e=>{if("Escape"!==e.key||B){if("Tab"===e.key){let t=Q.current,s=Z.current;t&&s&&e.shiftKey&&document.activeElement===t?(e.preventDefault(),s.focus()):t&&s&&!e.shiftKey&&document.activeElement===s&&(e.preventDefault(),t.focus())}}else e.preventDefault(),O(!1),V(null),window.requestAnimationFrame(()=>{var e;return null==(e=X.current)?void 0:e.focus()})},className:"mb-4 rounded-md border border-destructive/30 bg-destructive/5 p-4",children:[(0,n.jsx)("p",{className:"font-medium",children:"确定永久删除此 Issue 吗?"}),(0,n.jsx)("p",{id:"delete-issue-description",className:"mt-1 text-sm text-muted-foreground",children:"评论、编辑历史、表态和附件都将被永久删除,此操作无法撤销。"}),W&&(0,n.jsx)("p",{role:"alert",className:"mt-3 text-sm text-destructive",children:W}),(0,n.jsxs)("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:Q,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:B,onClick:()=>{O(!1),V(null),window.requestAnimationFrame(()=>{var e;return null==(e=X.current)?void 0:e.focus()})},children:"取消删除"}),(0,n.jsx)(x.$,{ref:Z,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:B,onClick:()=>{H(!0),V(null),tr(s,n5.issue.id).then(async()=>{O(!1),nV(),await nq(p),null==o||o()}).catch(e=>V(e instanceof Error?e.message:"Issue 服务暂不可用")).finally(()=>H(!1))},children:"确认删除 Issue"})]})]}),"edit"===m.kind?(0,n.jsxs)("div",{className:"space-y-4",children:[m.restoredDraft&&(0,n.jsxs)("div",{role:"status",className:"flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{children:"已恢复上次未完成的编辑"}),(0,n.jsx)(J,{triggerLabel:"丢弃已恢复草稿",onConfirm:()=>aa(m),focusAfterConfirm:()=>{var e;return null==(e=document.querySelector("[data-localapp-issue-title]"))?void 0:e.focus()}})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsx)(E.J,{htmlFor:"issue-edit-title",children:"Issue 标题"}),(0,n.jsxs)("span",{className:"text-xs ".concat(n9?"text-destructive":"text-muted-foreground"),children:[n7," / ",256]})]}),(0,n.jsx)(C.p,{id:"issue-edit-title","aria-label":"Issue 标题","aria-invalid":n9||void 0,"aria-describedby":n9?"issue-edit-title-error":void 0,className:"h-11 sm:h-10",value:n5.issue.title,onChange:e=>{var t;let s=e.target.value;as&&sQ(as,{title:s,issueType:null!=(t=n5.issue.issue_type)?t:n5.issue.label,expectedUpdatedAt:m.expectedUpdatedAt}),h({...m,detail:{...n5,issue:{...n5.issue,title:s}}})}}),n9&&(0,n.jsx)("p",{id:"issue-edit-title-error",role:"alert",className:"text-sm text-destructive",children:"Issue 标题不能超过 256 个字符"})]}),al&&(0,n.jsxs)("fieldset",{className:"space-y-1.5",children:[(0,n.jsx)("legend",{className:"text-sm font-medium",children:"类型"}),(0,n.jsx)("div",{className:"inline-flex rounded-md border bg-background p-0.5",children:["task","bug","feature"].map(e=>{var t,s;return(0,n.jsx)("button",{type:"button","aria-pressed":(null!=(t=n5.issue.issue_type)?t:n5.issue.label)===e,onClick:()=>{as&&sQ(as,{title:n5.issue.title,issueType:e,expectedUpdatedAt:m.expectedUpdatedAt}),h({...m,detail:{...n5,issue:{...n5.issue,issue_type:e,label:e}}})},className:"h-11 rounded px-3 text-xs font-medium sm:h-8 ".concat((null!=(s=n5.issue.issue_type)?s:n5.issue.label)===e?"bg-accent text-foreground":"text-muted-foreground"),children:ei[e]},e)})})]}),(0,n.jsx)(tN,{pagePath:s,draftId:m.draftId,persistenceKey:an,preferPersistedDraft:!0,initialBody:n5.issue.description,textareaLabel:"Issue 描述",placeholder:"更新 Issue 描述",submitLabel:"保存 Issue",mentionCandidates:ao,removeTextRequest:ai,allowEmpty:!0,submitDisabled:!n5.issue.title.trim()||n9,onCancel:()=>aa(m),onSubmit:async e=>{var t;let{body:s,attachmentIds:n,draftId:a}=e;await n4(n5,{title:n5.issue.title.trim(),description:s,...al?{issueType:null!=(t=n5.issue.issue_type)?t:n5.issue.label}:{},expectedUpdatedAt:m.expectedUpdatedAt,draftId:a,attachmentIds:n,removedAttachmentIds:m.removedAttachmentIds}),as&&sQ(as,null)}},"edit-".concat(n5.issue.id,"-").concat(m.expectedUpdatedAt)),(0,n.jsx)(sF,{pagePath:s,attachments:ar,onRemove:e=>h({...m,removedAttachmentIds:[...m.removedAttachmentIds,e]})})]}):(0,n.jsx)(sK,{pagePath:s,detail:n5,identities:ao,currentUserId:null==r?void 0:r.id,availableLabels:t5,availableMilestones:sx,canManageMetadata:!!(r&&r.id===na),canManageLock:ae,canManagePin:!!(r&&r.id===na),metadataSaving:sz,savingTaskTarget:sU,headerAction:(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[r&&!n5.issue.locked_at&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"添加评论","aria-keyshortcuts":"R",title:"添加评论",onClick:()=>{var e,t,s,n;let a=null==(e=nr.current)?void 0:e.querySelector("[data-localapp-issue-comment-composer] textarea");null==a||null==(n=a.scrollIntoView)||n.call(a,{block:"center",behavior:(null==(t=(s=window).matchMedia)?void 0:t.call(s,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth"}),window.requestAnimationFrame(()=>null==a?void 0:a.focus())},children:(0,n.jsx)(k.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":s$?"已复制 Issue 链接":"复制 Issue 链接",title:s$?"已复制":"复制 Issue 链接",onClick:()=>void nJ(n5.issue.id),children:s$?(0,n.jsx)(I.A,{className:"h-4 w-4"}):(0,n.jsx)(S.A,{className:"h-4 w-4"})})]}),bodyAction:ae||at||r&&!n5.issue.locked_at&&n5.issue.description.trim()?(0,n.jsx)(tX,{label:"Issue 操作",items:[...ae?[{label:"编辑 Issue",restoreFocus:!1,onSelect:()=>(e=>{var t,s;let n=ns?function(e){try{var t,s;let n=JSON.parse(null!=(t=window.sessionStorage.getItem(e))?t:"null"),a=null!=(s=null==n?void 0:n.issueType)?s:null==n?void 0:n.label;return n&&"string"==typeof n.title&&("task"===a||"bug"===a||"feature"===a)&&"string"==typeof n.expectedUpdatedAt?{title:n.title,issueType:a,expectedUpdatedAt:n.expectedUpdatedAt}:null}catch(e){return null}}("".concat(ns,":edit:").concat(e.issue.id,":meta")):null,a=null!=(t=null==n?void 0:n.expectedUpdatedAt)?t:e.issue.updated_at;ns&&!n&&sQ("".concat(ns,":edit:").concat(e.issue.id,":meta"),{title:e.issue.title,issueType:null!=(s=e.issue.issue_type)?s:e.issue.label,expectedUpdatedAt:a}),s4(!!(n&&n.expectedUpdatedAt!==e.issue.updated_at)),h({kind:"edit",originalDetail:e,expectedUpdatedAt:a,restoredDraft:!!n,draftId:sZ(),removedAttachmentIds:[],detail:n?{...e,issue:{...e.issue,title:n.title,issue_type:n.issueType,label:n.issueType}}:e})})(n5)}]:[],...r&&!n5.issue.locked_at&&n5.issue.description.trim()?[{label:"引用回复",restoreFocus:!1,onSelect:()=>tH({id:++nN.current,text:sI(n5.issue.description,n5.issue.reporter_id)})}]:[],...at?[{label:"删除 Issue",destructive:!0,restoreFocus:!1,onSelect:e=>{X.current=e,V(null),O(!0),window.requestAnimationFrame(()=>{var e;return null==(e=Q.current)?void 0:e.focus()})}}]:[]]}):void 0,statusAction:ae?"open"===n5.issue.status?(0,n.jsxs)("div",{role:"group","aria-label":"关闭 Issue",className:"grid w-full grid-cols-2 gap-2 sm:flex sm:w-fit sm:items-center sm:justify-end",children:[(0,n.jsxs)("label",{className:"inline-flex h-11 min-w-0 items-center justify-center rounded-md border bg-background px-2 text-xs text-muted-foreground focus-within:ring-2 focus-within:ring-ring sm:h-8",children:[(0,n.jsx)("span",{className:"sr-only",children:"关闭原因"}),(0,n.jsxs)("select",{"aria-label":"关闭原因",value:sR,disabled:sT,onChange:e=>sD(e.target.value),className:"h-full min-w-0 bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"completed",children:"已完成"}),(0,n.jsx)("option",{value:"not_planned",children:"不计划处理"})]})]}),(0,n.jsxs)(x.$,{ref:nx,type:"button",variant:"outline",size:"sm",className:"h-11 min-w-[6.5rem] shrink-0 gap-1.5 sm:h-8",disabled:sT,"aria-busy":sT||void 0,onClick:()=>void au(n5,sR),children:[sT&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"关闭 Issue"]})]}):(0,n.jsxs)(x.$,{ref:nx,type:"button",variant:"outline",size:"sm",className:"h-11 min-w-[7.5rem] gap-1.5 sm:h-8",disabled:sT,"aria-busy":sT||void 0,"aria-label":"重新打开 Issue",onClick:()=>void au(n5),children:[sT&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"重新打开 Issue"]}):void 0,composer:n5.issue.locked_at?(0,n.jsxs)("div",{role:"status",className:"flex items-start gap-2 rounded-md border bg-muted/30 px-4 py-3 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"对话已锁定"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:n5.issue.locked_by?"@".concat(n5.issue.locked_by," 锁定了此 Issue").concat(n5.issue.lock_reason?"(".concat(eo[n5.issue.lock_reason],")"):"",",解锁后可继续评论。"):"解锁后可继续评论。"})]}):r?(0,n.jsx)("div",{"data-localapp-issue-comment-composer":!0,children:(0,n.jsx)(tN,{pagePath:s,draftId:t$,persistenceKey:"".concat(ns,":comment:").concat(n5.issue.id,":body"),showRestoredDraftNotice:!0,textareaLabel:"评论内容",placeholder:"留下评论",submitLabel:"评论",status:ae?n5.issue.status:void 0,closeReason:sR,mentionCandidates:ao,savedReplies:!0,insertRequest:tB,onInsertRequestApplied:e=>tH(t=>(null==t?void 0:t.id)===e?null:t),onSubmit:async e=>n3(n5,e)},"comment-".concat(n5.issue.id))}):void 0,commentDraftPrefix:ns?"".concat(ns,":edit-comment"):void 0,onEditComment:async(e,t,n,a,l,r)=>{try{await ts(s,n5.issue.id,e,t,n,a,l,r),await Promise.all([nB(n5.issue.id),nq(p)])}catch(e){throw e instanceof eA&&await nB(n5.issue.id).catch(()=>void 0),e}},onDeleteComment:async e=>{try{await tn(s,n5.issue.id,e),await Promise.all([nB(n5.issue.id),nq(p)])}catch(e){throw M(e instanceof Error?e.message:"Issue 服务暂不可用"),e}},canManageCommentPins:!!(r&&r.id===na),onToggleCommentPin:async(e,t)=>{try{await ta(s,n5.issue.id,e,t),await Promise.all([nB(n5.issue.id),nq(p)])}catch(e){throw M(e instanceof Error?e.message:"无法更新置顶评论"),e}},canManageCommentMinimization:!!(r&&r.id===na),onToggleCommentMinimized:async(e,t)=>{try{await tl(s,n5.issue.id,e,t),await Promise.all([nB(n5.issue.id),nq(p)])}catch(e){throw M(e instanceof Error?e.message:"无法更新评论最小化状态"),e}},onQuoteComment:(e,t)=>tH({id:++nN.current,text:sI(e,t)}),onReferenceComment:(e,t,s,n)=>((e,t,s,n,a)=>{if(!r||!ns)return;let l="".concat(ns,":reference-comment:").concat(e.issue.id,":").concat(t),i=sY(l),o=s0(l),c=o?"":function(e,t,s,n){let a=e.replace(sV,"").replace(/[ \t]+$/gm,"").trim(),l=Array.from(a),r=((l.length>500?"".concat(l.slice(0,499).join(""),"…"):a)||"@".concat(t," 的附件评论")).split(/\r?\n/).map(e=>"> ".concat(e)).join("\n");return"".concat(r,"\n\n来源:#").concat(s,"\n\n[查看 @").concat(t," 的原评论](").concat(n,")")}(s,n,e.issue.issue_number,nO(e.issue.id,t));M(null),eT(null),ed(o),es(o?i.title:""),er(c),ea(c),t_(o?i.issueType:"task"),tL(o?i.labelIds:[]),tD(o?i.assigneeIds:[]),tq(o?i.milestoneId:null),tF(sZ()),h({kind:"create",reference:{detail:e,commentId:t,trigger:a}})})(n5,e,t,s,n),selectedCommentId:nl,getCommentHref:e=>nO(n5.issue.id,e),getIssueHref:()=>n$(n5.issue.id),getIssueReferenceHref:nM,onOpenIssueReference:nP,onCopyCommentLink:async e=>{M(null);try{await sf(nK(n5.issue.id,e).href)}catch(e){throw M("无法复制评论链接,请从浏览器地址栏复制"),Error("无法复制评论链接")}},onViewIssueHistory:e=>tV({title:n5.issue.title,body:n5.issue.description,updatedAt:n5.issue.updated_at,returnFocus:e}),onViewCommentHistory:(e,t)=>{let s=n5.timeline.find(t=>"comment"===t.kind&&t.comment.id===e);(null==s?void 0:s.kind)==="comment"&&tV({commentId:e,body:s.comment.body,updatedAt:s.comment.updated_at,returnFocus:t})},onToggleLabel:async(e,t)=>{var n,a;let l=null!=(a=null==(n=n5.collaboration)?void 0:n.labels.map(e=>e.id))?a:[],r=t?Array.from(new Set([...l,e])):l.filter(t=>t!==e);await ad(()=>e3(s,n5.issue.id,r))},onSetIssueType:async e=>ad(async()=>(await te(s,n5.issue.id,{issueType:e}),eQ(s,n5.issue.id))),onToggleAssignee:async(e,t)=>{var n,a;let l=null!=(a=null==(n=n5.collaboration)?void 0:n.assignee_ids)?a:[],r=t?Array.from(new Set([...l,e])):l.filter(t=>t!==e);await ad(()=>e5(s,n5.issue.id,r))},onSetMilestone:async e=>ad(()=>e8(s,n5.issue.id,e)),onToggleSubscription:async e=>ad(()=>e4(s,n5.issue.id,"subscription",{subscribed:e})),onToggleLock:async(e,t)=>ad(()=>e6(s,n5.issue.id,e,t)),onTogglePin:async e=>{await ad(()=>eK(s,n5.issue.id,e)),await nq(p)},canManageSubIssues:(null==r?void 0:r.id)===na,onCreateSubIssue:()=>nD(n5.issue.id),onLinkSubIssue:async e=>{let t=await eZ(s,e);await ad(()=>eO(s,n5.issue.id,t.issue.id))},onRemoveSubIssue:async e=>ad(()=>eJ(s,n5.issue.id,e)),onReprioritizeSubIssue:async(e,t)=>ad(()=>eB(s,n5.issue.id,e,t)),canManageDependencies:(null==r?void 0:r.id)===na,onAddDependency:async(e,t)=>{let n=await eZ(s,t);await ad(()=>"blockedBy"===e?eW(s,n5.issue.id,n.issue.id):eW(s,n.issue.id,n5.issue.id)),await nq(p)},onRemoveDependency:async(e,t)=>{await ad(()=>"blockedBy"===e?eV(s,n5.issue.id,t):eV(s,t,n5.issue.id)),await nq(p)},canManageDuplicates:(null==r?void 0:r.id)===na,onUnmarkDuplicate:async e=>{await ad(()=>ez(s,n5.issue.id,e)),await nq(p)},onConvertIssueTask:(null==r?void 0:r.id)!==na||n5.issue.locked_at?void 0:async(e,t)=>{M(null);try{var n,a;let l=new Set((null!=(n=n5.subIssues)?n:[]).map(e=>e.id)),r=await eH(s,n5.issue.id,e,n5.issue.updated_at,t),i=(null!=(a=r.subIssues)?a:[]).find(e=>!l.has(e.id));if(!i)throw Error("Sub-issue 已创建,但无法定位新引用");for(let e of(np.current=i.issue_number,h({kind:"detail",detail:r}),await nq(p),[100,300,600]))window.setTimeout(()=>{var e,t;return null==(t=nr.current)||null==(e=t.querySelector('[data-localapp-issue-reference="'.concat(i.issue_number,'"]')))?void 0:e.focus()},e);return i.issue_number}catch(e){throw M(e instanceof Error?e.message:"无法转换任务"),e}},onToggleIssueTask:ae&&!n5.issue.locked_at?async(e,t)=>{sP("issue"),M(null);try{let n=Y(n5.issue.description,e,t);await te(s,n5.issue.id,{description:n,expectedUpdatedAt:n5.issue.updated_at}),await Promise.all([nB(n5.issue.id),nq(p)])}catch(e){throw await nB(n5.issue.id).catch(()=>void 0),M(e instanceof Error?e.message:"任务状态更新失败"),e}finally{sP(null)}}:void 0,onToggleCommentTask:n5.issue.locked_at?void 0:async(e,t,n)=>{let a=n5.timeline.find(t=>"comment"===t.kind&&t.comment.id===e);if(a&&"comment"===a.kind&&a.comment.author_id===(null==r?void 0:r.id)){sP(e),M(null);try{let l=Y(a.comment.body,t,n),r=await ts(s,n5.issue.id,e,l,a.comment.updated_at);h({kind:"detail",detail:r}),await nq(p)}catch(e){throw await nB(n5.issue.id).catch(()=>void 0),M(e instanceof Error?e.message:"任务状态更新失败"),e}finally{sP(null)}}},onToggleReaction:async(e,t,n)=>{M(null);try{let a=await e7(s,n5.issue.id,e,t,n);h({kind:"detail",detail:a}),await nq(p)}catch(e){throw M(e instanceof Error?e.message:"Issue 服务暂不可用"),e}}})]}),"templates"===m.kind&&(0,n.jsx)(sW,{templates:eu,loading:ev,error:ew,onSelect:e=>nD(void 0,e,!0),onBlank:()=>nD(void 0,void 0,!0),onRetry:()=>eC(e=>e+1)}),"create"===m.kind&&(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:(0,n.jsxs)("div",{"data-testid":"issue-create-workspace",className:"grid min-w-0 gap-5 lg:grid-cols-[minmax(0,3fr)_minmax(240px,1fr)] lg:gap-6",children:[(0,n.jsxs)("div",{"data-testid":"issue-create-main",className:"min-w-0 space-y-4",children:[m.reference&&(0,n.jsxs)("div",{role:"status",className:"rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsxs)("strong",{children:["引用自 #",m.reference.detail.issue.issue_number," 评论"]}),(0,n.jsx)("p",{className:"mt-1 text-muted-foreground",children:"原评论保持不变,提交后将创建独立 Issue。"})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsx)(E.J,{htmlFor:"issue-title",children:"标题"}),(0,n.jsxs)("span",{className:"text-xs ".concat(n6?"text-destructive":"text-muted-foreground"),children:[n8," / ",256]})]}),(0,n.jsx)(C.p,{id:"issue-title","aria-label":"标题","aria-invalid":n6||void 0,"aria-describedby":n6?"issue-title-error":void 0,value:et,onChange:e=>es(e.target.value),placeholder:"简要描述问题或需求",className:"h-11 sm:h-10",autoFocus:!0,required:!0}),n6&&(0,n.jsx)("p",{id:"issue-title-error",role:"alert",className:"text-sm text-destructive",children:"Issue 标题不能超过 256 个字符"})]}),eE&&(0,n.jsx)("p",{role:"status","aria-label":"Issue 模板提示",className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm",children:eE}),(0,n.jsx)(sH,{candidates:tb,loading:tv,error:tj,getIssueHref:nM,onOpenIssue:nP,onRetry:()=>tC(e=>e+1)}),(0,n.jsx)(tN,{pagePath:s,draftId:tU,initialBody:el,persistenceKey:nn?"".concat(nn,":body"):void 0,showRestoredDraftNotice:!0,restoredDraft:ec,onDiscardRestoredDraft:()=>{es(""),er(""),ea(""),ed(!1),t_("task"),tL([]),tD([]),tq(null),eT(null),ns&&s1(null!=nn?nn:"".concat(ns,":create"),"","task",[],[],null)},onBodyChange:ea,textareaLabel:"描述",placeholder:"详细描述问题、复现步骤或期望结果",submitLabel:"提交 Issue",mentionCandidates:ao,allowEmpty:!0,submitDisabled:!et.trim()||n6,onSubmit:n2},tU)]}),(0,n.jsxs)("aside",{"data-testid":"issue-create-triage","aria-label":"Issue 分诊",className:"min-w-0 space-y-4 border-t pt-4 lg:border-l lg:border-t-0 lg:pl-5 lg:pt-0",children:[(0,n.jsxs)("fieldset",{className:"space-y-1.5",children:[(0,n.jsx)("legend",{className:"text-sm font-medium",children:"类型"}),(0,n.jsx)("div",{className:"inline-flex rounded-md border bg-background p-0.5",children:["task","bug","feature"].map(e=>(0,n.jsx)("button",{type:"button","aria-pressed":tE===e,onClick:()=>t_(e),className:"h-11 rounded px-3 text-xs font-medium sm:h-8 ".concat(tE===e?"bg-accent text-foreground":"text-muted-foreground"),children:ei[e]},e))})]}),(null==r?void 0:r.id)===na&&(0,n.jsxs)("div",{"data-localapp-create-metadata":!0,className:"space-y-4 border-t pt-4",children:[(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex min-h-7 items-center justify-between",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"附加标签"}),(0,n.jsx)(t9,{label:"附加标签",items:t5.map(e=>({id:e.id,label:e.name,description:e.description||e.id,leading:(0,n.jsx)("span",{"aria-hidden":"true",className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:"#".concat(e.color)}})})),selectedIds:tT,onToggle:(e,t)=>tL(s=>t?Array.from(new Set([...s,e])):s.filter(t=>t!==e))})]}),tT.length>0?(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:tT.map(e=>t5.find(t=>t.id===e)).filter(e=>!!e).map(e=>(0,n.jsx)(tP,{label:e},e.id))}):(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"未添加附加标签"})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex min-h-7 items-center justify-between",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"负责人"}),(0,n.jsx)(t9,{label:"负责人",items:ac.map(e=>({id:e.id,label:e.displayName||e.name||e.id,description:"@".concat(e.id)})),selectedIds:tR,onToggle:(e,t)=>tD(s=>t?Array.from(new Set([...s,e])):s.filter(t=>t!==e))})]}),tR.length>0?(0,n.jsx)("div",{className:"space-y-2",children:tR.map(e=>(0,n.jsx)(t7,{identity:t6(e,ao)},e))}):(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"尚未分配"})]}),(0,n.jsxs)("section",{children:[(0,n.jsx)("label",{className:"mb-2 block text-sm font-medium",htmlFor:"issue-create-milestone",children:"里程碑"}),(0,n.jsxs)("select",{id:"issue-create-milestone","aria-label":"里程碑",className:"h-11 w-full rounded-md border bg-background px-3 text-sm sm:h-9",value:null!=tz?tz:"",onChange:e=>tq(e.target.value?Number(e.target.value):null),children:[(0,n.jsx)("option",{value:"",children:"无里程碑"}),sx.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title,"closed"===e.state?"(已关闭)":""]},e.id))]})]})]})]}),(0,n.jsx)("div",{className:"flex justify-end border-t pt-4 lg:col-span-2",children:(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",onClick:()=>{if("create"===m.kind&&m.reference){let{detail:e,commentId:t,trigger:s}=m.reference;h({kind:"detail",detail:e});let n=nK(e.issue.id,t);window.history.replaceState(null,"",n),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>{var e;return(null==s?void 0:s.isConnected)?s.focus():null==(e=document.querySelector('[data-testid="issue-comment-'.concat(t,'"] button[aria-label="评论操作"]')))?void 0:e.focus()}));return}"create"===m.kind&&m.returnToTemplates?h({kind:"templates"}):nV()},children:"取消"})})]})}),n5&&tW&&(0,n.jsx)(sO,{pagePath:s,issueId:n5.issue.id,commentId:tW.commentId,currentTitle:tW.title,currentBody:tW.body,currentUpdatedAt:tW.updatedAt,identities:ao,returnFocus:tW.returnFocus,onClose:()=>tV(null)})]})]})}var s4=s(1659);let s3="localapp-ai-sidebar-width";function s5(e){var t;let{open:s,onClose:a,messages:r,isRunning:i,error:o,onSend:c}=e,[d,u]=(0,l.useState)(()=>{let e=localStorage.getItem(s3);if(!e)return 380;let t=parseInt(e,10);return Number.isNaN(t)?380:Math.min(600,Math.max(280,t))}),[m,h]=(0,l.useState)(""),[p,f]=(0,l.useState)(!1),b=(0,l.useRef)(null),g=(0,l.useRef)({startX:0,startWidth:0}),v=(0,l.useRef)(d);v.current=d,(0,l.useEffect)(()=>{let e=b.current;e&&(e.scrollTop=e.scrollHeight)},[r]);let y=(0,l.useCallback)(e=>{e.preventDefault(),f(!0),g.current={startX:e.clientX,startWidth:d}},[d]);(0,l.useEffect)(()=>{if(p)return document.body.style.userSelect="none",window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)};function e(e){let t=g.current.startX-e.clientX;u(Math.min(600,Math.max(280,g.current.startWidth+t)))}function t(){f(!1),document.body.style.userSelect="",localStorage.setItem(s3,String(v.current))}},[p,d]);let w=()=>{let e=m.trim();e&&!i&&(c(e),h(""))};return(0,n.jsxs)("div",{className:"absolute right-0 top-0 bottom-0 z-50 flex flex-col border-l bg-background shadow-lg transition-transform duration-300 ease-in-out",style:{width:d,transform:s?"translateX(0)":"translateX(100%)"},children:[(0,n.jsx)("div",{className:"absolute left-0 top-0 bottom-0 cursor-col-resize group",style:{width:8,marginLeft:-4},onMouseDown:y,children:(0,n.jsx)("div",{className:"h-full w-1 mx-auto rounded-full transition-colors group-hover:bg-primary/30",style:p?{backgroundColor:"var(--color-primary)"}:void 0})}),(0,n.jsxs)("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[(0,n.jsx)("span",{className:"text-sm font-medium",children:"AI 助手"}),(0,n.jsx)(x.$,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:a,children:(0,n.jsx)(N.A,{className:"h-3.5 w-3.5"})})]}),o&&(0,n.jsx)("div",{className:"border-b bg-destructive/10 px-3 py-2 text-xs text-destructive",children:o}),(0,n.jsxs)("div",{ref:b,className:"flex-1 overflow-y-auto px-3 py-2 space-y-3 text-sm",children:[0===r.length&&(0,n.jsx)("p",{className:"py-8 text-center text-muted-foreground text-xs",children:"发送消息开始对话"}),r.map((e,t)=>"user"===e.role?(0,n.jsx)(s8,{text:e.content},t):(0,n.jsx)(s6,{text:e.content,toolCalls:e.toolCalls},t)),i&&(null==(t=r[r.length-1])?void 0:t.role)==="user"&&(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)(A.A,{className:"h-3 w-3 animate-spin"}),"思考中..."]})]}),(0,n.jsx)("div",{className:"border-t px-3 py-2",children:(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("input",{className:"flex-1 rounded-md border bg-transparent px-3 py-1.5 text-sm outline-none focus:ring-1 focus:ring-primary",placeholder:"输入消息...",value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),w())},disabled:i}),(0,n.jsx)(x.$,{size:"icon",className:"h-8 w-8 flex-shrink-0",onClick:w,disabled:!m.trim()||i,children:(0,n.jsx)(s4.A,{className:"h-3.5 w-3.5"})})]})})]})}function s8(e){let{text:t}=e;return(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)("div",{className:"max-w-[80%] rounded-2xl rounded-br-sm bg-primary px-3 py-2 text-sm text-primary-foreground whitespace-pre-wrap",children:t})})}function s6(e){let{text:t,toolCalls:s}=e;return(0,n.jsx)("div",{className:"flex justify-start",children:(0,n.jsxs)("div",{className:"max-w-[80%] space-y-1.5",children:[t&&(0,n.jsx)("div",{className:"rounded-2xl rounded-bl-sm bg-muted px-3 py-2 text-sm leading-relaxed prose prose-sm max-w-none",children:(0,n.jsx)(H.oz,{remarkPlugins:[W.A],children:t})}),null==s?void 0:s.map(e=>(0,n.jsx)(s7,{tc:e},e.id))]})})}function s7(e){let{tc:t}=e,s="completed"===t.status||"timeout"===t.status,a=t.args&&Object.keys(t.args).length>0,[r,i]=(0,l.useState)(!s);(0,l.useEffect)(()=>{s&&i(!1)},[s]);let o=void 0!==t.result?"string"==typeof t.result?t.result:JSON.stringify(t.result):"",c=o.slice(0,60),d="running"===t.status?"⏳":t.isError?"✗":"✓",u=t.isError?"text-destructive":"text-primary";return(0,n.jsxs)("div",{className:"rounded-md bg-primary/5 px-2.5 py-1.5 text-xs",onClick:s?()=>i(e=>!e):void 0,style:{cursor:s?"pointer":"default"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 font-medium ".concat(u),children:[(0,n.jsx)("span",{children:d}),(0,n.jsx)("span",{children:t.name}),!r&&c&&(0,n.jsxs)("span",{className:"flex-1 truncate font-normal text-muted-foreground",children:[c,o.length>60?"…":""]}),s&&(0,n.jsx)("span",{className:"ml-auto flex-shrink-0 font-normal text-muted-foreground text-[10px]",children:r?"▲ 折叠":"▼ 展开"})]}),r&&(0,n.jsxs)(n.Fragment,{children:[a&&(0,n.jsx)("pre",{className:"mt-1 text-[11px] text-muted-foreground whitespace-pre-wrap",children:JSON.stringify(t.args,null,2)}),void 0!==t.result&&(0,n.jsx)("pre",{className:"mt-1 text-[11px] whitespace-pre-wrap ".concat(t.isError?"text-destructive":"text-green-700"),children:"string"==typeof t.result?t.result:JSON.stringify(t.result,null,2)})]})]})}let s9={all:"全部",important:"仅重要",muted:"静音"};function ne(e){var t;let{pagePath:s,pageName:a,ownerName:r,user:o,meta:c}=e,{openLogin:d}=(0,b.M)(),[u,m]=(0,l.useState)(null),[h,p]=(0,l.useState)(0),[f,g]=(0,l.useState)(!1);if((null==c||null==(t=c.notify)?void 0:t.enabled)!==!0)return null;let v=(0,l.useCallback)(async()=>{if(!o){m(null),p(0);return}try{var e,t,s,n;let[l,i]=await Promise.all([fetch("/api/subscriptions/".concat(r,"/").concat(a,"/status"),{credentials:"include"}).then(e=>e.json()),fetch("/api/inbox/unread-count",{credentials:"include"}).then(e=>e.json())]);l.success&&m(null!=(s=null==(e=l.data)?void 0:e.level)?s:null),i.success&&p(null!=(n=null==(t=i.data)?void 0:t.count)?n:0)}catch(e){}},[o,r,a]);(0,l.useEffect)(()=>{v()},[v]);let y=async e=>{if(!o)return void d();try{let t=await fetch("/api/subscriptions",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_owner:r,app_name:a,level:e})});(await t.json()).success&&m(e)}catch(e){}g(!1)},w=o?u?"已订阅(".concat(s9[u],")\xb7 点击查看收件箱"):"订阅此应用通知":"登录后订阅此应用通知";return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)(x.$,{variant:"ghost",size:"icon",className:"h-7 w-7 ".concat(u?"text-primary":"text-muted-foreground"),title:w,onClick:()=>{if(!o)return void d();u?window.location.href="/inbox":g(e=>!e)},children:[(0,n.jsx)(t3.A,{className:"h-4 w-4"}),h>0&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-red-500 px-1 text-[9px] font-bold text-white",children:h>99?"99+":h})]}),f&&o&&(0,n.jsxs)("div",{className:"absolute right-0 top-9 z-50 w-44 rounded-md border bg-popover p-1 text-sm shadow-md",children:[(0,n.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"选择订阅等级"}),["all","important","muted"].map(e=>(0,n.jsxs)("button",{className:"flex w-full items-center justify-between rounded px-2 py-1.5 hover:bg-accent",onClick:()=>y(e),children:[(0,n.jsx)("span",{children:s9[e]}),u===e&&(0,n.jsx)("span",{className:"text-xs text-primary",children:"✓"})]},e)),(0,n.jsx)("div",{className:"my-1 border-t"}),(0,n.jsx)(i(),{href:"/inbox",className:"block rounded px-2 py-1.5 hover:bg-accent",children:"查看收件箱"})]})]})}let nt=[{name:"getCurrentUser",description:"Return the current signed-in user id and name, or null when unauthenticated.",parameters:{type:"object",properties:{}}}],ns=new Set(nt.map(e=>e.name));async function nn(e,t,s){try{if("getCurrentUser"===e){let e=await fetch("/api/me",{credentials:"include"}),t=await e.json();if(!t.success||!t.data)return{result:null};return{result:{id:t.data.id,name:t.data.name}}}return{result:"Unknown system tool: ".concat(e),isError:!0}}catch(e){return{result:e instanceof Error?e.message:String(e),isError:!0}}}async function na(e,t){let s=new TextDecoder,n="",a=[],l="";for(;;){let{done:m,value:h}=await e.read();if(m)break;let p=(l+=s.decode(h,{stream:!0})).split("\n");for(let e of(l=p.pop()||"",p)){if(!e.startsWith("data: "))continue;let s=e.slice(6).trim();if("[DONE]"!==s)try{var r,i,o,c,d,u;let e=null==(i=JSON.parse(s).choices)||null==(r=i[0])?void 0:r.delta;if(!e)continue;if(e.content&&(n+=e.content),e.tool_calls){for(let t of e.tool_calls)if(t.id)a.push({id:t.id,name:(null==(o=t.function)?void 0:o.name)||"",args:(null==(c=t.function)?void 0:c.arguments)||""});else if(a.length>0){let e=a[a.length-1];(null==(d=t.function)?void 0:d.arguments)&&(e.args+=t.function.arguments),(null==(u=t.function)?void 0:u.name)&&(e.name=t.function.name)}}t(n,a)}catch(e){}}}return{content:n,toolCalls:a}}var nl=s(409),nr=s(4045),ni=s(1580);let no=["@font-face","@keyframes","@-webkit-keyframes","@property","@page"],nc="/_localapp/raw";function nd(e){return e.endsWith("/")?e:"".concat(e,"/")}function nu(e,t){if(!t)return"";if(/^https?:\/\//i.test(t)||t.startsWith("/serve/")||t.startsWith("".concat(nc,"/")))return t;let s=nd(e);return t.startsWith("/assets/")?"".concat(s.slice(0,-1)).concat(t):new URL(t,"http://localapp.local".concat(s)).pathname}function nm(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function nh(e){return nm(e)&&"localapp:platform_request"===e.type&&"string"==typeof e.id&&"string"==typeof e.capability}let np="__localapp_platform_tool_registry__",nf="__localapp_platform_edit_session_registry__";function nx(e){return nm(e)?e:{}}function nb(e){let{userId:t,name:s}=e,r=(0,a.useRouter)(),{openLogin:i}=(0,b.M)(),[o,c]=(0,l.useState)(null),[d,u]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[p,f]=(0,l.useState)(0),[v,y]=(0,l.useState)(!1),[w,j]=(0,l.useState)(()=>sc(new URL(window.location.href),sl)),[N,k]=(0,l.useState)(()=>sc(new URL(window.location.href),sr)),[I,S]=(0,l.useState)(()=>sd(new URL(window.location.href))),A=(0,l.useRef)(w),C=(0,l.useRef)(N);A.current=w,C.current=N;let[E,_]=(0,l.useState)(null),[T,L]=(0,l.useState)(null),[R,D]=(0,l.useState)(null),[z,q]=(0,l.useState)(null),[U,P]=(0,l.useState)(null),F=(0,l.useRef)(0),$="".concat(t,"/").concat(s),M=function(e,t){let s=!function(e){try{return new URL(e).pathname.startsWith("/platform-shell/")}catch(e){return!1}}(window.location.href)?"/serve":nc;return nd("".concat(s,"/").concat(e))}($),K="".concat(M,"|").concat($),O=(null==m?void 0:m.name)===s&&(null==m?void 0:m.userId)===t,J=O&&"online"===m.lifecycleStatus,B=O&&"offline"===m.lifecycleStatus,H=(null==o?void 0:o.id)===t,[W,V]=(0,l.useState)(null),[X,Q]=(0,l.useState)(!1),Z=(0,l.useRef)(null),G=(0,l.useRef)([]),Y=(0,l.useRef)(new Map),ee=(0,l.useRef)(""),et=(0,l.useRef)(null),es=(0,l.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"push",s=sm(new URL(window.location.href),e);window.history["push"===t?"pushState":"replaceState"](window.history.state,"",s),j(e),k(null),S(null!==e||I)},[I]),en=(0,l.useCallback)(()=>{let e=su(new URL(window.location.href),!1);window.history.replaceState(window.history.state,"",e),j(null),k(null),S(!1)},[]),ea=(0,l.useCallback)(()=>{let e=su(new URL(window.location.href),!0);window.history.pushState(window.history.state,"",e),S(!0)},[]);(0,l.useEffect)(()=>{let e=()=>{let e=new URL(window.location.href),t=sd(e);if(!t&&function(){var e;let t=document.querySelector('[data-localapp-issues-workspace] [data-localapp-issue-attachment-queue][aria-busy="true"]');return!!t&&(t.focus(),null==(e=t.scrollIntoView)||e.call(t,{block:"nearest"}),!0)}()){let t=function(e,t,s){let n=su(e,!0);return null!==t?sm(n,t):null!==s?sh(n,s):n}(e,A.current,C.current);window.history.pushState(window.history.state,"",t);return}let s=sc(e,sl),n=sc(e,sr);j(s),k(n),S(t)};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let el=(0,l.useCallback)(e=>{let t=Y.current.get(e.toolName);if(!t)return void window.dispatchEvent(new MessageEvent("message",{data:{type:"localapp:tool_result",callId:e.callId,result:"Unknown tool: ".concat(e.toolName),isError:!0},origin:window.location.origin}));Promise.resolve(t(e.args)).then(t=>{window.dispatchEvent(new MessageEvent("message",{data:{type:"localapp:tool_result",callId:e.callId,result:t,isError:!1},origin:window.location.origin}))}).catch(t=>{window.dispatchEvent(new MessageEvent("message",{data:{type:"localapp:tool_result",callId:e.callId,result:t instanceof Error?t.message:String(t),isError:!0},origin:window.location.origin}))})},[]),{chatMessages:er,isRunning:ei,aiError:eo,agentSend:ec,handleToolResult:ed}=function(e){let{appName:t,userName:s,pagePath:n,postToolCall:a,registeredToolsRef:r,systemHintRef:i}=e,[o,c]=(0,l.useState)([]),[d,u]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),p=(0,l.useRef)(new Map),f=(0,l.useCallback)((e,t,s)=>new Promise(n=>{let l=setTimeout(()=>{p.current.delete(e),n({result:"工具执行超时",isError:!0}),c(t=>t.map(t=>"assistant"===t.role&&t.toolCalls?{...t,toolCalls:t.toolCalls.map(t=>t.id===e?{...t,result:"工具执行超时",isError:!0,status:"timeout"}:t)}:t))},3e4);p.current.set(e,{resolve:(e,t)=>n({result:e,isError:t}),timeout:l}),a({type:"localapp:tool_call",callId:e,toolName:t,args:s})}),[a]),x=(0,l.useCallback)((e,t,s)=>{let n=p.current.get(e);n&&(clearTimeout(n.timeout),p.current.delete(e),n.resolve(t,s),c(n=>n.map(n=>"assistant"===n.role&&n.toolCalls?{...n,toolCalls:n.toolCalls.map(n=>n.id===e?{...n,result:t,isError:s,status:"completed"}:n)}:n)))},[]),b=(0,l.useCallback)(async e=>{let t=await Promise.all(e.map(async e=>{let t,s={};try{s=JSON.parse(e.args)}catch(e){}return t=ns.has(e.name)?await nn(e.name,s,n):await f(e.id,e.name,s),{id:e.id,name:e.name,result:String(t.result),isError:t.isError}}));for(let e of t)ns.has(e.name)&&c(t=>t.map(t=>"assistant"===t.role&&t.toolCalls?{...t,toolCalls:t.toolCalls.map(t=>t.id===e.id?{...t,result:e.result,isError:e.isError,status:"completed"}:t)}:t));return t},[n,f]),g=(0,l.useCallback)(async e=>{var n,a;c(t=>[...t,{role:"user",content:e}]),u(!0),h(null);let l=[{role:"user",content:e}],o=[...nt.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.parameters}})),...(null!=(n=r.current)?n:[]).map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.parameters}}))],d=["你是一个运行在 LocalApp 应用中的 AI 助手。","当前应用: ".concat(t),"当前用户: ".concat(null!=s?s:"未登录"),i.current,"当用户的需求可以映射到工具操作时,必须调用工具执行。","请用中文回复用户。"].filter(Boolean).join("\n");try{let e=0;for(;e<5;){let t=await fetch("/api/llm/chat",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"system",content:d},...l],...o.length>0?{tools:o}:{}})});if(!t.ok)throw Error("LLM 请求失败: ".concat(t.status));let s=null==(a=t.body)?void 0:a.getReader();if(!s)throw Error("无响应体");e>0&&c(e=>[...e,{role:"assistant",content:"",toolCalls:[]}]);let{content:n,toolCalls:r}=await na(s,0===e?e=>{c(t=>{let s=t[t.length-1];return(null==s?void 0:s.role)==="assistant"?[...t.slice(0,-1),{...s,content:e}]:[...t,{role:"assistant",content:e,toolCalls:[]}]})}:e=>{c(t=>{let s=t[t.length-1];return(null==s?void 0:s.role)==="assistant"?[...t.slice(0,-1),{...s,content:e}]:t})}),i=r.map(e=>{let t={};try{t=JSON.parse(e.args)}catch(e){}return{id:e.id,name:e.name,args:t,status:"running"}});if(c(e=>{let t=e[e.length-1];return(null==t?void 0:t.role)==="assistant"?[...e.slice(0,-1),{...t,content:n,toolCalls:i.length>0?i:t.toolCalls}]:[...e,{role:"assistant",content:n,toolCalls:i}]}),0===r.length)break;let u=await b(r);for(let e of(l.push({role:"assistant",content:n||"",tool_calls:r.map(e=>({id:e.id,type:"function",function:{name:e.name,arguments:e.args}}))}),u))l.push({role:"tool",content:JSON.stringify(e),tool_call_id:e.id});e++}0===e&&c(e=>{let t=e[e.length-1];return(null==t?void 0:t.role)==="assistant"?e:[...e,{role:"assistant",content:"",toolCalls:[]}]})}catch(e){h(e instanceof Error?e.message:"未知错误")}finally{u(!1)}},[t,s,r,i,b]);return{chatMessages:o,setChatMessages:c,isRunning:d,aiError:m,agentSend:g,handleToolResult:x}}({appName:s,userName:null==o?void 0:o.name,pagePath:$,postToolCall:el,registeredToolsRef:G,systemHintRef:ee});(0,l.useEffect)(()=>{let e=!1;return u(!1),h(null),Promise.all([fetch("/api/me",{credentials:"include"}).then(e=>e.json()).catch(()=>null),fetch("/api/pages/".concat(t,"/").concat(s,"/meta"),{credentials:"include"}).then(e=>e.json()).catch(()=>null)]).then(t=>{let[s,n]=t;e||((null==s?void 0:s.success)&&s.data&&c(s.data),(null==n?void 0:n.success)&&n.data&&h(n.data),u(!0))}),()=>{e=!0}},[t,s]),(0,l.useEffect)(()=>{let e=globalThis,t=e[np];return e[np]={registerTools:(e,t,s)=>(G.current=e,Y.current=new Map(Object.entries(t)),ee.current=s||"",V("system"),()=>{G.current=[],Y.current=new Map,ee.current=""})},()=>{e[np]=null!=t?t:null}},[]),(0,l.useEffect)(()=>{let e=globalThis,t=e[nf];return e[nf]={registerEditSession:e=>(et.current=e,D(e),()=>{et.current===e&&(et.current=null,D(null))})},()=>{e[nf]=null!=t?t:null,et.current=null,D(null)}},[]),(0,l.useEffect)(()=>{function e(e){let t=et.current;if(!t||t.busy)return;let s=e.key.toLowerCase();if(e.ctrlKey||e.metaKey){if("s"===s&&t.canSave){e.preventDefault(),t.onSave();return}if(!function(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName.toLowerCase();return"input"===t||"textarea"===t||"select"===t}(e.target)){if("z"===s&&e.shiftKey&&t.canRedo){e.preventDefault(),t.onRedo();return}if("z"===s&&!e.shiftKey&&t.canUndo){e.preventDefault(),t.onUndo();return}"y"===s&&t.canRedo&&(e.preventDefault(),t.onRedo())}}}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,l.useEffect)(()=>{fetch("/api/favorites/count?pagePath=".concat(encodeURIComponent($)),{credentials:"include"}).then(e=>e.json()).then(e=>{var t,s;e.success&&f(null!=(s=null==(t=e.data)?void 0:t.count)?s:0)}).catch(()=>{})},[$]);let eu=(0,l.useCallback)(async()=>{let e=++F.current;try{let t=await e$($,{...ep,status:"open",limit:1});if(e!==F.current)return;let s=t.meta.open;P("number"==typeof s&&Number.isFinite(s)&&s>=0?s:t.data.length)}catch(e){}},[$]);(0,l.useEffect)(()=>{eu()},[eu]),(0,l.useEffect)(()=>{o&&fetch("/api/favorites/check?pagePath=".concat(encodeURIComponent($)),{credentials:"include"}).then(e=>e.json()).then(e=>{var t,s;e.success&&y(null!=(s=null==(t=e.data)?void 0:t.favorited)&&s)}).catch(()=>{})},[$,o]),(0,l.useEffect)(()=>{var e,t,s;if(!d||!J||"undefined"==typeof EventSource)return;let n=null!=(s=null==(t=globalThis.crypto)||null==(e=t.randomUUID)?void 0:e.call(t))?s:"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2)),a=JSON.stringify({clientId:n}),l="/serve/".concat($,"/api/presence/heartbeat"),r="/serve/".concat($,"/api/presence/leave"),i=null,o=!0;function c(e){try{var t,s,n;let a=JSON.parse(e.data),l=null==(t=a.data)?void 0:t.count,r=null==(s=a.data)?void 0:s.anonymousCount,i=null==(n=a.data)?void 0:n.authenticatedUsers;Number.isFinite(l)&&Number.isFinite(r)&&Array.isArray(i)&&q({count:Math.max(0,Number(l)),anonymousCount:Math.max(0,Number(r)),authenticatedUsers:i})}catch(e){}}let u=()=>{null==i||i.close(),i=null},m=()=>{fetch(l,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}).catch(()=>{})},h=()=>{var e,t;let s=new Blob([a],{type:"application/json"});null!=(e=(t=navigator).sendBeacon)&&e.call(t,r,s)||fetch(r,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}).catch(()=>{})},p=()=>{"hidden"!==document.visibilityState&&o&&!i&&(i=new EventSource("/serve/".concat($,"/api/presence/events?clientId=").concat(encodeURIComponent(n)))).addEventListener("presence:snapshot",c)},f=()=>{m(),"hidden"===document.visibilityState?u():p()},x=()=>{o=!1,m(),u()},b=()=>{o=!0,m(),p()},g=()=>{o=!1,u(),h()},v=()=>{o=!0,m(),p()};m(),p();let y=window.setInterval(m,3e4);return document.addEventListener("visibilitychange",f),window.addEventListener("blur",x),window.addEventListener("focus",b),window.addEventListener("pagehide",g),window.addEventListener("pageshow",v),()=>{window.clearInterval(y),document.removeEventListener("visibilitychange",f),window.removeEventListener("blur",x),window.removeEventListener("focus",b),window.removeEventListener("pagehide",g),window.removeEventListener("pageshow",v),u(),h()}},[J,$,d]),(0,l.useEffect)(()=>{if(!d||!J||Z.current===K)return;Z.current=K,L(null);let e=!1,t=[];return async function(){try{var s,n;let a=await fetch(M,{credentials:"include"});if(!a.ok)throw Error("App index request failed: ".concat(a.status));let l=await a.text();if(e)return;let r=new DOMParser().parseFromString(l,"text/html"),i=Array.from(r.querySelectorAll('link[rel="stylesheet"][href]')),o=Array.from(r.querySelectorAll('script[type="module"][src]'));for(let e of i){let n=nu(M,null!=(s=e.getAttribute("href"))?s:"");if(!n||document.querySelector('[data-localapp-app-asset="'.concat(n,'"]')))continue;let a=await fetch(n,{credentials:"include"});if(!a.ok)throw Error("App stylesheet request failed: ".concat(a.status));let l=await a.text(),r=document.createElement("style");r.textContent=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:":where([data-localapp-app-root])";return function e(t,s){let n="",a=0;for(;a<t.length;){let l=t.indexOf("{",a);if(-1===l){n+=t.slice(a);break}let r=function(e,t){let s=0,n=null;for(let a=t;a<e.length;a++){let t=e[a],l=e[a-1];if(n){t===n&&"\\"!==l&&(n=null);continue}if('"'===t||"'"===t){n=t;continue}if("{"===t&&s++,"}"===t&&0==--s)return a}return -1}(t,l);if(-1===r){n+=t.slice(a);break}let i=t.slice(a,l),o=t.slice(l+1,r),c=i.trimStart().toLowerCase();n+=function(e,t,s){return s.startsWith("@")?e:(function(e){let t=[],s=0,n=0,a=null;for(let l=0;l<e.length;l++){let r=e[l],i=e[l-1];if(a){r===a&&"\\"!==i&&(a=null);continue}if('"'===r||"'"===r){a=r;continue}("("===r||"["===r||"{"===r)&&n++,(")"===r||"]"===r||"}"===r)&&(n=Math.max(0,n-1)),","===r&&0===n&&(t.push(e.slice(s,l)),s=l+1)}return t.push(e.slice(s)),t})(e).map(e=>(function(e,t){var s,n,a,l;let r=null!=(a=null==(s=e.match(/^\s*/))?void 0:s[0])?a:"",i=null!=(l=null==(n=e.match(/\s*$/))?void 0:n[0])?l:"",o=e.trim();return!o||o.startsWith(t)?e:/^(html|body|:root)\b/.test(o)?"".concat(r).concat(o.replace(/^(html|body|:root)\b/,t)).concat(i):"".concat(r).concat(t," ").concat(o).concat(i)})(e,t)).join(",")}(i,s,c),n+="{",n+=!function(e){return!!e.startsWith("@")&&!no.some(t=>e.startsWith(t))}(c)?o:e(o,s),n+="}",a=r+1}return n}(e,t)}(function(e,t){return e.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(e,s,n)=>{let a=n.trim();if(!a||a.startsWith("#")||a.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(a))return e;try{return"url(".concat(s).concat(new URL(a,t).toString()).concat(s,")")}catch(t){return e}})}(l,n)),r.setAttribute("data-localapp-app-asset",n),r.setAttribute("data-localapp-app-stylesheet","true"),document.head.appendChild(r),t.push(r)}for(let e of o){let s=nu(M,null!=(n=e.getAttribute("src"))?n:"");if(!s)continue;let a=document.createElement("script");a.type="module",a.src=s,a.setAttribute("data-localapp-app-asset",s),document.body.appendChild(a),t.push(a)}0===o.length&&L("App entry module not found in uploaded index.html")}catch(t){e||L(t instanceof Error?t.message:String(t))}}(),()=>{for(let s of(e=!0,t))s.remove()}},[J,K,M,d]);let em=(0,l.useCallback)((e,t,s,n)=>{window.dispatchEvent(new MessageEvent("message",{data:{type:"localapp:platform_response",id:e,ok:t,...t?{result:s}:{error:n}},origin:window.location.origin}))},[]),eh=(0,l.useCallback)(async e=>{try{switch(e.capability){case"getCurrentUser":em(e.id,!0,o);break;case"getServerTime":{let t=await fetch("/serve/".concat($,"/api/time"),{credentials:"include"}),s=await t.json();if(!t.ok||!s.success)throw Error(s.error||"Server time request failed: ".concat(t.status));em(e.id,!0,s.data);break}case"copyText":{let t=nx(e.payload),s="string"==typeof t.text?t.text:"";await navigator.clipboard.writeText(s),em(e.id,!0,{success:!0});break}case"downloadFile":!function(e){let t=nx(e),s="string"==typeof t.filename&&t.filename.trim()?t.filename:"download",n="string"==typeof t.mimeType?t.mimeType:"application/octet-stream",a=t.data,l=a instanceof Blob?a:a instanceof ArrayBuffer?new Blob([a],{type:n}):new Blob(["string"==typeof a?a:JSON.stringify(null!=a?a:"")],{type:n}),r=URL.createObjectURL(l);try{let e=document.createElement("a");e.href=r,e.download=s,e.rel="noopener",document.body.appendChild(e),e.click(),e.remove()}finally{setTimeout(()=>URL.revokeObjectURL(r),0)}}(e.payload),em(e.id,!0,{success:!0});break;case"confirm":{let t=nx(e.payload);_({id:e.id,title:"string"==typeof t.title&&t.title.trim()?t.title:"确认操作",message:"string"==typeof t.message?t.message:"",confirmText:"string"==typeof t.confirmText&&t.confirmText.trim()?t.confirmText:"确认",cancelText:"string"==typeof t.cancelText&&t.cancelText.trim()?t.cancelText:"取消",tone:"danger"===t.tone?"danger":"default"});break}case"openRoute":{let t=nx(e.payload),s="string"==typeof t.href?t.href:"";if(!s)throw Error("openRoute requires href");/^https?:\/\//i.test(s)?window.open(s,"_blank","noopener,noreferrer"):r.push(s),em(e.id,!0,{success:!0});break}case"auth.login":i({returnTo:"".concat(window.location.pathname).concat(window.location.search).concat(window.location.hash)}),em(e.id,!0,{success:!0});break;case"ai.open":V(e=>null!=e?e:"system"),Q(!0),em(e.id,!0,{success:!0});break;case"ai.close":Q(!1),em(e.id,!0,{success:!0});break;case"ai.toggle":V(e=>null!=e?e:"system"),Q(e=>!e),em(e.id,!0,{success:!0});break;default:throw Error("Unknown platform capability: ".concat(e.capability))}}catch(t){em(e.id,!1,void 0,t instanceof Error?t.message:String(t))}},[i,$,em,r,o]);(0,l.useEffect)(()=>{function e(e){var t,s,n,a;(null==(t=e.data)?void 0:t.type)&&(!e.origin||e.origin===window.location.origin)&&(nm(s=e.data)&&"localapp:register_tools"===s.type?(V("system"),G.current=e.data.tools,ee.current=e.data.systemHint||""):nm(n=e.data)&&"localapp:ai_custom_mode"===n.type?V("custom"):nm(a=e.data)&&"localapp:tool_result"===a.type?ed(e.data.callId,e.data.result,e.data.isError):nh(e.data)&&eh(e.data))}function t(e){let t=e.detail;nh(t)&&(e.preventDefault(),eh(t))}return window.addEventListener("message",e),window.addEventListener("localapp:platform_request",t),()=>{window.removeEventListener("message",e),window.removeEventListener("localapp:platform_request",t)}},[eh,ed]);let ef=(0,l.useCallback)(async()=>{if(!o)return void i();try{if(v){let e=await fetch("/api/favorites/".concat(encodeURIComponent($)),{method:"DELETE",credentials:"include"});(await e.json()).success&&(y(!1),f(e=>Math.max(0,e-1)))}else{let e=await fetch("/api/favorites",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:$,pageName:s,ownerName:t})});(await e.json()).success&&(y(!0),f(e=>e+1))}}catch(e){}},[v,$,s,t,o,i]),ex=(0,l.useCallback)(e=>{E&&(em(E.id,!0,e),_(null))},[E,em]);return d?(0,n.jsxs)("div",{className:"flex h-screen flex-col bg-background","data-localapp-native-shell":!0,"data-localapp-app-resource-base":M,children:[(0,n.jsx)("div",{"data-localapp-shell-nav-background":!0,"data-testid":"shell-nav-background",inert:I?"true":void 0,"aria-hidden":!!I||void 0,className:"shrink-0",children:(0,n.jsx)(g,{pageName:s,user:o,favCount:p,isFavorited:v,onToggleFavorite:ef,onOpenIssues:ea,openIssueCount:U,aiMode:W,aiOpen:X,onToggleAI:()=>Q(e=>!e),editSession:R,presenceSnapshot:z,bell:(0,n.jsx)(ne,{pagePath:$,pageName:s,ownerName:t,user:o,meta:m})})}),(0,n.jsxs)("div",{className:"relative flex-1 overflow-hidden","data-localapp-app-area":!0,children:[(0,n.jsxs)("div",{"data-localapp-app-background":!0,"data-testid":"app-background",inert:I?"true":void 0,"aria-hidden":!!I||void 0,className:"absolute inset-0",children:[(0,n.jsx)("div",{className:"h-full overflow-auto","data-localapp-app-container":!0,children:B?(0,n.jsx)("main",{className:"flex min-h-full items-center justify-center px-6 py-12","data-localapp-offline-state":!0,children:(0,n.jsxs)("section",{className:"w-full max-w-lg text-center",children:[(0,n.jsx)(nl.A,{className:"mx-auto size-10 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)("p",{className:"mt-5 text-sm font-medium text-muted-foreground",children:s}),(0,n.jsx)("h1",{className:"mt-2 text-xl font-semibold text-foreground",children:"应用暂时下线"}),(0,n.jsx)("p",{className:"mx-auto mt-2 max-w-md text-sm leading-6 text-muted-foreground",children:"应用当前不可访问,数据和设置均已保留。重新上线后即可继续使用。"}),(0,n.jsxs)("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-2",children:[(0,n.jsxs)(x.$,{variant:"outline",size:"sm",onClick:()=>window.location.reload(),children:[(0,n.jsx)(nr.A,{}),"刷新状态"]}),H&&(0,n.jsxs)(x.$,{size:"sm",onClick:()=>r.push("/my/apps/".concat(encodeURIComponent(s),"/settings?tab=manage")),children:[(0,n.jsx)(ni.A,{}),"应用设置"]})]})]})}):J?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{id:"root","data-localapp-app-root":!0,className:"min-h-full"}),T&&(0,n.jsx)("div",{className:"p-4 text-sm text-destructive",children:T})]}):(0,n.jsx)("main",{className:"flex min-h-full items-center justify-center px-6 py-12","data-localapp-load-unavailable":!0,children:(0,n.jsxs)("section",{className:"w-full max-w-lg text-center",children:[(0,n.jsx)(tD.A,{className:"mx-auto size-10 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)("p",{className:"mt-5 text-sm font-medium text-muted-foreground",children:s}),(0,n.jsx)("h1",{className:"mt-2 text-xl font-semibold text-foreground",children:"暂时无法加载应用"}),(0,n.jsx)("p",{className:"mx-auto mt-2 max-w-md text-sm leading-6 text-muted-foreground",children:"平台暂时无法确认应用状态。为保护应用数据,内容加载已暂停。"}),(0,n.jsx)("div",{className:"mt-6 flex justify-center",children:(0,n.jsxs)(x.$,{variant:"outline",size:"sm",onClick:()=>window.location.reload(),children:[(0,n.jsx)(nr.A,{}),"重新加载"]})})]})})}),"system"===W&&(0,n.jsx)(s5,{open:X,onClose:()=>Q(!1),messages:er,isRunning:ei,error:eo,onSend:ec})]}),I&&(0,n.jsx)(s2,{pagePath:$,pageName:s,user:o,onIssuesChanged:eu,selectedIssueId:w,selectedIssueNumber:N,onIssueNavigate:es,onClose:en})]}),E&&(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4",children:(0,n.jsxs)("div",{className:"w-full max-w-sm rounded-lg border bg-card p-5 shadow-lg",children:[(0,n.jsx)("h2",{className:"text-base font-semibold text-foreground",children:E.title}),E.message&&(0,n.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-sm leading-6 text-muted-foreground",children:E.message}),(0,n.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{variant:"ghost",size:"sm",onClick:()=>ex(!1),children:E.cancelText}),(0,n.jsx)(x.$,{variant:"danger"===E.tone?"destructive":"default",size:"sm",onClick:()=>ex(!0),children:E.confirmText})]})]})})]}):null}function ng(e){let t=window.location.pathname.match(/^\/platform-shell\/([^/]+)\/([^/]+)\/?$/);return t?"userId"===e?t[1]:t[2]:null}function nv(){var e,t,s,l,r,i;let o=(0,a.useParams)(),c=(0,a.useSearchParams)(),d=decodeURIComponent(null!=(s=null!=(t=null!=(e=c.get("userId"))?e:o.userId)?t:ng("userId"))?s:"placeholder"),u=decodeURIComponent(null!=(i=null!=(r=null!=(l=c.get("name"))?l:o.name)?r:ng("name"))?i:"placeholder");return(0,n.jsx)(nb,{userId:d,name:u})}},8172:(e,t,s)=>{"use strict";s.d(t,{AuthProvider:()=>r,M:()=>i});var n=s(6472),a=s(2212);let l=(0,a.createContext)(null);function r(e){let{children:t}=e,[s,r]=(0,a.useState)(!1),[i,o]=(0,a.useState)(null),[c,d]=(0,a.useState)(!1),[u,m]=(0,a.useState)("profile"),[h,p]=(0,a.useState)(null),[f,x]=(0,a.useState)(null),b=(0,a.useCallback)(e=>{var t;let s="".concat(window.location.pathname).concat(window.location.search).concat(window.location.hash);o(null!=(t=null==e?void 0:e.returnTo)?t:s),r(!0)},[]),g=(0,a.useCallback)(()=>r(!1),[]),v=(0,a.useCallback)(e=>{var t;m(e.mode),p(null!=(t=e.userId)?t:null),d(!0)},[]),y=(0,a.useCallback)(()=>{d(!1),x(null)},[]),w=(0,a.useMemo)(()=>({loginOpen:s,loginReturnTo:i,changePasswordOpen:c,changePasswordMode:u,changePasswordUserId:h,pendingOldPassword:f,openLogin:b,closeLogin:g,openChangePassword:v,closeChangePassword:y,setPendingOldPassword:x}),[s,i,c,u,h,f,b,g,v,y,x]);return(0,n.jsx)(l.Provider,{value:w,children:t})}function i(){let e=(0,a.useContext)(l);if(!e)throw Error("useAuthModals must be used within an AuthProvider");return e}},8323:(e,t,s)=>{"use strict";s.d(t,{T:()=>r});var n=s(6472),a=s(2212),l=s(3906);let r=a.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,n.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...a})});r.displayName="Textarea"},9561:(e,t,s)=>{"use strict";s.d(t,{J:()=>c});var n=s(6472),a=s(2212),l=s(9443),r=s(2770),i=s(3906);let o=(0,r.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=a.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,n.jsx)(l.b,{ref:t,className:(0,i.cn)(o(),s),...a})});c.displayName=l.b.displayName}}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[416],{1845:(e,t,s)=>{"use strict";s.d(t,{$:()=>c});var n=s(6472),a=s(2212),l=s(7473),r=s(2770),i=s(3906);let o=(0,r.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),c=a.forwardRef((e,t)=>{let{className:s,variant:a,size:r,asChild:c=!1,...d}=e,u=c?l.DX:"button";return(0,n.jsx)(u,{className:(0,i.cn)(o({variant:a,size:r,className:s})),ref:t,...d})});c.displayName="Button"},2611:(e,t,s)=>{"use strict";s.d(t,{p:()=>r});var n=s(6472),a=s(2212),l=s(3906);let r=a.forwardRef((e,t)=>{let{className:s,type:a,...r}=e;return(0,n.jsx)("input",{type:a,className:(0,l.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...r})});r.displayName="Input"},3906:(e,t,s)=>{"use strict";s.d(t,{cn:()=>l});var n=s(6256),a=s(2520);function l(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,a.QP)((0,n.$)(t))}},5416:(e,t,s)=>{Promise.resolve().then(s.bind(s,8630))},8172:(e,t,s)=>{"use strict";s.d(t,{AuthProvider:()=>r,M:()=>i});var n=s(6472),a=s(2212);let l=(0,a.createContext)(null);function r(e){let{children:t}=e,[s,r]=(0,a.useState)(!1),[i,o]=(0,a.useState)(null),[c,d]=(0,a.useState)(!1),[u,m]=(0,a.useState)("profile"),[p,h]=(0,a.useState)(null),[f,x]=(0,a.useState)(null),b=(0,a.useCallback)(e=>{var t;let s="".concat(window.location.pathname).concat(window.location.search).concat(window.location.hash);o(null!=(t=null==e?void 0:e.returnTo)?t:s),r(!0)},[]),g=(0,a.useCallback)(()=>r(!1),[]),v=(0,a.useCallback)(e=>{var t;m(e.mode),h(null!=(t=e.userId)?t:null),d(!0)},[]),y=(0,a.useCallback)(()=>{d(!1),x(null)},[]),w=(0,a.useMemo)(()=>({loginOpen:s,loginReturnTo:i,changePasswordOpen:c,changePasswordMode:u,changePasswordUserId:p,pendingOldPassword:f,openLogin:b,closeLogin:g,openChangePassword:v,closeChangePassword:y,setPendingOldPassword:x}),[s,i,c,u,p,f,b,g,v,y,x]);return(0,n.jsx)(l.Provider,{value:w,children:t})}function i(){let e=(0,a.useContext)(l);if(!e)throw Error("useAuthModals must be used within an AuthProvider");return e}},8323:(e,t,s)=>{"use strict";s.d(t,{T:()=>r});var n=s(6472),a=s(2212),l=s(3906);let r=a.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,n.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...a})});r.displayName="Textarea"},8630:(e,t,s)=>{"use strict";s.d(t,{PlatformShellClient:()=>nk});var n=s(6472),a=s(2949),l=s(2212),r=s(448),i=s.n(r),o=s(3855),c=s(4615),d=s(7380),u=s(8932),m=s(7110),p=s(4721),h=s(8706),f=s(555),x=s(1845),b=s(8172);function g(e){var t,s,a;let{pageName:r,user:g,favCount:v,isFavorited:y,onToggleFavorite:w,onOpenIssues:j,openIssueCount:N,aiMode:k,aiOpen:I,onToggleAI:S,bell:A,editSession:C,presenceCount:E,presenceSnapshot:_}=e,{openLogin:T}=(0,b.M)(),L=g?(g.displayName||g.name).charAt(0).toUpperCase():"?",R=null!=(t=null==C?void 0:C.busy)&&t,D=null!=(a=null!=(s=null==_?void 0:_.count)?s:E)?a:null,[z,q]=(0,l.useState)(!1),U=(0,l.useRef)(null),F=null!=N?N:null,P=null===F?"Issue":"Issue,".concat(F," 个待处理");return(0,l.useEffect)(()=>{if(!z)return;let e=e=>{var t;(null==(t=U.current)?void 0:t.contains(e.target))||q(!1)},t=e=>{"Escape"===e.key&&q(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[z]),(0,n.jsxs)("nav",{className:"flex shrink-0 flex-col bg-card",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 text-sm",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2","data-testid":"localapp-platform-nav-left",children:[(0,n.jsx)("strong",{className:"max-w-[200px] truncate",children:r}),(0,n.jsxs)(x.$,{variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-muted-foreground","aria-label":P,title:P,onClick:j,children:[(0,n.jsx)(o.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Issue"}),null!==F&&(0,n.jsx)("span",{"data-testid":"localapp-open-issue-count","data-empty":0===F,className:"min-w-4 text-center text-[11px] font-semibold tabular-nums ".concat(0===F?"text-muted-foreground/70":"text-foreground"),children:F})]}),null!==D&&(0,n.jsxs)("div",{className:"relative",ref:U,children:[(0,n.jsxs)("button",{type:"button",className:"inline-flex h-7 min-w-12 items-center justify-center gap-1 rounded-md px-2 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":"当前在线用户 ".concat(D," 人"),title:"当前在线用户 ".concat(D," 人"),"aria-expanded":z,onClick:()=>_&&q(e=>!e),children:[(0,n.jsx)(c.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:D})]}),z&&_&&(0,n.jsxs)("div",{className:"absolute left-0 top-8 z-50 w-72 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg",children:[(0,n.jsx)("div",{className:"border-b px-3 py-2 text-xs font-medium",children:"当前在线用户"}),(0,n.jsxs)("div",{className:"max-h-72 overflow-y-auto p-1",children:[_.authenticatedUsers.map(e=>{let t=e.displayName||e.name;return(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded px-2 py-2",children:[e.avatarUrl?(0,n.jsx)("img",{src:e.avatarUrl,alt:"",className:"h-7 w-7 rounded-full object-cover"}):(0,n.jsx)("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-secondary text-[11px] font-semibold",children:t.charAt(0).toUpperCase()}),(0,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("span",{className:"block truncate text-sm font-medium",children:t}),e.displayName&&(0,n.jsxs)("span",{className:"block truncate text-xs text-muted-foreground",children:["@",e.name]})]})]},e.id)}),_.anonymousCount>0&&(0,n.jsxs)("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:["匿名访客 ",_.anonymousCount," 人"]})]})]})]}),C&&(0,n.jsxs)("div",{className:"flex items-center gap-1","data-localapp-edit-session-controls":!0,children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground","aria-label":"保存",title:"保存",disabled:R||!C.canSave,onClick:()=>{C.onSave()},children:(0,n.jsx)(d.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground","aria-label":"撤销",title:"撤销",disabled:R||!C.canUndo,onClick:()=>{C.onUndo()},children:(0,n.jsx)(u.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground","aria-label":"重做",title:"重做",disabled:R||!C.canRedo,onClick:()=>{C.onRedo()},children:(0,n.jsx)(m.A,{className:"h-4 w-4"})})]}),A]}),(0,n.jsxs)("div",{className:"flex items-center gap-3","data-testid":"localapp-platform-nav-right",children:[(0,n.jsxs)(x.$,{variant:"ghost",size:"sm",className:"gap-1.5",onClick:w,title:y?"取消收藏":"收藏",children:[(0,n.jsx)(p.A,{className:"h-4 w-4 ".concat(y?"fill-amber-400 text-amber-400":"text-muted-foreground")}),(0,n.jsx)("span",{className:"text-xs",children:v})]}),k&&(0,n.jsx)(x.$,{variant:"ghost",size:"icon",className:"h-7 w-7 ".concat(I?"text-primary":"text-muted-foreground"),title:"AI 助手",onClick:S,children:(0,n.jsx)(h.A,{className:"h-4 w-4"})}),g?(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsxs)(i(),{href:"/",className:"flex items-center gap-2 hover:opacity-80",children:[g.avatarUrl?(0,n.jsx)("img",{src:g.avatarUrl,alt:"",className:"h-6 w-6 rounded-full"}):(0,n.jsx)("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary text-[10px] font-bold text-primary-foreground",children:L}),(0,n.jsx)("span",{className:"hidden sm:inline max-w-[120px] truncate",children:g.displayName||g.name})]})}):(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsxs)(x.$,{variant:"ghost",size:"sm",className:"gap-1.5",onClick:()=>T(),children:[(0,n.jsx)(f.A,{className:"h-4 w-4"}),"登录"]})})]})]}),(0,n.jsx)("div",{className:"h-[3px] bg-gradient-to-r from-indigo-500 via-fuchsia-500 to-orange-400"})]})}var v=s(6452),y=s(6777),w=s(7711),j=s(7953),N=s(31),k=s(3012),I=s(2211),S=s(1104),A=s(7097),C=s(2611),E=s(9561),_=s(8438),T=s(2078),L=s(9857),R=s(6491),D=s(7600),z=s(9233),q=s(6525),U=s(3037),F=s(2899),P=s(8556),$=s(9441),M=s(7136),O=s(4116),K=s(3142);function J(e){let{triggerLabel:t,onConfirm:s,focusAfterConfirm:a}=e,[r,i]=(0,l.useState)(!1),o="issue-discard-draft-".concat((0,l.useId)().replace(/[^A-Za-z0-9_-]/g,"")),c=(0,l.useRef)(null),d=(0,l.useRef)(null),u=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;r&&(null==(e=d.current)||e.focus())},[r]);let m=()=>{i(!1),window.requestAnimationFrame(()=>{var e;return null==(e=c.current)?void 0:e.focus()})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x.$,{ref:c,type:"button",variant:"ghost",size:"sm",className:"h-11 shrink-0 sm:h-8","aria-expanded":r,onClick:()=>i(!0),children:t}),r&&(0,n.jsxs)("div",{role:"alertdialog","aria-label":"丢弃草稿确认","aria-describedby":o,onKeyDown:e=>{var t,s;if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),m();return}"Tab"===e.key&&(e.shiftKey&&document.activeElement===d.current?(e.preventDefault(),null==(t=u.current)||t.focus()):e.shiftKey||document.activeElement!==u.current||(e.preventDefault(),null==(s=d.current)||s.focus()))},className:"basis-full rounded-md border border-destructive/30 bg-destructive/5 p-3",children:[(0,n.jsx)("p",{className:"font-medium",children:"丢弃草稿?"}),(0,n.jsx)("p",{id:o,className:"mt-1 text-sm text-muted-foreground",children:"未提交内容和已上传附件将被清除且无法恢复。"}),(0,n.jsxs)("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:d,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",onClick:m,children:"保留草稿"}),(0,n.jsx)(x.$,{ref:u,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",onClick:()=>{i(!1),s(),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>null==a?void 0:a()))},children:"确认丢弃"})]})]})]})}var B=s(8323),H=s(2591),W=s(4039),V=s(4316),X=s(249),Q=s(4924);let Z=/^(?:[ \t]*(?:[-+*]|\d+[.)])[ \t]+)\[([ xX])\]/;function G(e){if(!e.includes("["))return[];let t=(0,X.l)().use(Q.A).use(W.A).parse(e),s=[],n=t=>{var a,l,r,i,o;if("listItem"===t.type&&"boolean"==typeof t.checked){let n=null==(l=t.position)||null==(a=l.start)?void 0:a.offset,o=null==(i=t.position)||null==(r=i.end)?void 0:r.offset;if("number"==typeof n&&"number"==typeof o){let a=Z.exec(e.slice(n,o));if(a){let l=e.slice(n+a[0].length,o).split(/\r?\n/,1)[0].trimEnd().replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/<[^>]+>/g,"").replace(/[`*_~]+/g,"").replace(/\s+/g," ").trim();s.push({index:s.length,checked:t.checked,markerOffset:n+a[0].length-2,title:l,convertible:!t.checked&&!!l&&!/^#\d+$/.test(l)})}}}for(let e of null!=(o=t.children)?o:[])n(e)};return n(t),s}function Y(e,t,s){let n=G(e)[t];if(!n)throw Error("Task not found");if(n.checked===s)throw Error("Task state changed");return"".concat(e.slice(0,n.markerOffset)).concat(s?"x":" ").concat(e.slice(n.markerOffset+1))}let ee="#localapp-issue-",et=/(^|[^\\\w])#([1-9]\d*)\b/g;function es(){return(e,t)=>{var s;return function e(t,s){!t.children||["link","linkReference","code","inlineCode","html"].includes(t.type)||(t.children=t.children.flatMap(t=>"text"===t.type?function(e,t){var s,n,a,l,r,i;let o=null!=(s=e.value)?s:"",c=[],d=0;for(let s of o.matchAll(et)){let u=s[1],m=s[2],p=(null!=(i=s.index)?i:0)+u.length,h=null==(a=e.position)||null==(n=a.start)?void 0:n.offset,f=null==(r=e.position)||null==(l=r.end)?void 0:l.offset;if("number"==typeof h&&"number"==typeof f){let e=t.slice(h,f),s=e.indexOf("#".concat(m));if(s>0&&"\\"===e[s-1])continue}p>d&&c.push({type:"text",value:o.slice(d,p)}),c.push({type:"link",url:"".concat(ee).concat(m),children:[{type:"text",value:"#".concat(m)}]}),d=p+m.length+1}return 0===d?[e]:(d<o.length&&c.push({type:"text",value:o.slice(d)}),c)}(t,s):(e(t,s),[t])))}(e,String(null!=(s=t.value)?s:""))}}function en(){return e=>{let t=0,s=e=>{var n,a;for(let l of("element"===e.type&&"input"===e.tagName&&(null==(n=e.properties)?void 0:n.type)==="checkbox"&&(e.properties.dataIssueTaskIndex=t++),null!=(a=e.children)?a:[]))s(l)};s(e)}}function ea(e){let{children:t,className:s="",tasksDisabled:a=!1,onToggleTask:l,onConvertTask:r,getIssueReferenceHref:i,onOpenIssueReference:o}=e,c=G(t),d=c.filter(e=>e.checked).length;return(0,n.jsxs)("div",{className:"min-w-0 ".concat(s),children:[c.length>0&&(0,n.jsxs)("div",{role:"progressbar","aria-label":"任务进度","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":c.length,"aria-valuetext":"已完成 ".concat(d," / ").concat(c.length," 个任务"),className:"mb-3 flex items-center gap-3 text-xs text-muted-foreground",children:[(0,n.jsxs)("span",{className:"shrink-0 font-medium",children:["任务 ",d," / ",c.length]}),(0,n.jsx)("span",{className:"h-2 min-w-20 flex-1 overflow-hidden rounded-full bg-muted",children:(0,n.jsx)("span",{className:"block h-full bg-emerald-600 transition-[width] motion-reduce:transition-none",style:{width:"".concat(Math.round(d/c.length*100),"%")}})})]}),(0,n.jsx)("div",{className:"prose prose-sm min-w-0 max-w-none overflow-hidden break-words text-sm leading-6 [overflow-wrap:anywhere] dark:prose-invert",children:(0,n.jsx)(H.oz,{remarkPlugins:[W.A,es],rehypePlugins:[en],components:{pre:e=>{let{children:t,...s}=e;return(0,n.jsx)("pre",{...s,className:"max-w-full overflow-x-auto",children:t})},code:e=>{let{children:t,...s}=e;return(0,n.jsx)("code",{...s,className:"break-normal [overflow-wrap:normal]",children:t})},a:e=>{let{children:t,href:s,...a}=e,l=function(e){if(!(null==e?void 0:e.startsWith(ee)))return null;let t=Number(e.slice(ee.length));return Number.isSafeInteger(t)&&t>0?t:null}(s),r=null!==l&&i?i(l):s;return(0,n.jsx)("a",{...a,href:r,tabIndex:null!==l?-1:void 0,"data-localapp-issue-reference":null!=l?l:void 0,className:"break-all",onClick:null!==l&&o?e=>{0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),o(l))}:void 0,children:t})},img:e=>{let{...t}=e;return(0,n.jsx)("img",{...t,className:"h-auto max-w-full"})},input:e=>{let{type:t,checked:s,...i}=e;if("checkbox"!==t)return(0,n.jsx)("input",{type:t,...i});let o=i["data-issue-task-index"],d="number"==typeof o&&Number.isSafeInteger(o)&&o>=0?o:null,u=null===d?null:c[d];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("label",{className:"-my-2 mr-1 inline-flex h-11 w-11 cursor-pointer items-center justify-center align-middle sm:-my-0 sm:h-6 sm:w-6",children:(0,n.jsx)("input",{...i,type:"checkbox",className:"h-4 w-4",checked:!!s,disabled:null===d||!l||a,"aria-label":null===d?"任务,".concat(s?"已完成":"未完成"):"任务 ".concat(d+1,",").concat(s?"已完成":"未完成"),onChange:e=>{null!==d&&(null==l||l(d,e.currentTarget.checked))}})}),(null==u?void 0:u.convertible)&&r&&(0,n.jsx)("button",{type:"button",title:"转换为 Sub-issue","aria-label":"将任务 ".concat(d+1," 转换为 Sub-issue"),disabled:a,className:"-my-2 mr-1 inline-flex h-11 w-11 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 sm:-my-0 sm:h-6 sm:w-6",onClick:e=>r(d,u.title,e.currentTarget),children:(0,n.jsx)(V.A,{className:"h-4 w-4","aria-hidden":"true"})})]})}},children:t})})]})}let el=new Set(["heading","quote","bullet-list","ordered-list","task-list"]),er=/^\s*(?:#{1,6}\s+|>\s?|[-*+]\s+(?:\[[ xX]\]\s+)?|\d+[.)]\s+)/,ei={task:"任务",bug:"缺陷",feature:"功能"},eo={resolved:"已解决",off_topic:"偏离主题",too_heated:"讨论过热",spam:"垃圾信息"},ec={abuse:"滥用内容","off-topic":"偏离主题",outdated:"内容过时",resolved:"问题已解决",duplicate:"重复内容",spam:"垃圾内容"},ed=["+1","-1","laugh","hooray","confused","heart","rocket","eyes"];function eu(e){return["image/png","image/jpeg","image/gif","image/webp"].includes(e.toLowerCase())}function em(e,t){let s=new URLSearchParams({pagePath:e});return"/api/issues/attachments/".concat(encodeURIComponent(t),"?").concat(s.toString())}function ep(e){return e<1024?"".concat(e," B"):e<1048576?"".concat(Math.ceil(e/1024)," KB"):"".concat((e/1048576).toFixed(1)," MB")}let eh={q:"",searchIn:"",status:"open",label:"",issueType:"",author:"",participant:"",assignee:"",milestone:"",reason:"",subscribed:!1,mentioned:!1,locked:"",sort:"activity",direction:"desc",limit:25,offset:0};function ef(e){return{...e.q?{q:e.q.trim()}:{},...e.searchIn?{searchIn:e.searchIn.split(",")}:{},...e.status!==eh.status?{status:e.status}:{},...e.label?{label:e.label}:{},...e.issueType?{issueType:e.issueType}:{},...e.author?{author:e.author}:{},...e.participant?{participant:e.participant}:{},...e.assignee?{assignee:e.assignee}:{},...e.milestone?{milestone:e.milestone}:{},..."closed"===e.status&&e.reason?{reason:e.reason}:{},...e.subscribed?{subscribed:!0}:{},...e.mentioned?{mentioned:!0}:{},...e.locked?{locked:e.locked}:{},...e.sort!==eh.sort?{sort:e.sort}:{},...e.direction!==eh.direction?{direction:e.direction}:{},...e.limit!==eh.limit?{limit:e.limit}:{},offset:0}}function ex(e){var t,s,n;return{...eh,...e,searchIn:null!=(s=null==(t=e.searchIn)?void 0:t.join(","))?s:"",reason:"closed"===e.status&&null!=(n=e.reason)?n:"",offset:0}}function eb(e,t){return JSON.stringify(ef(ex(e)))===JSON.stringify(ef(t))}let eg={q:"localappIssueQ",searchIn:"localappIssueIn",status:"localappIssueStatus",label:"localappIssueLabel",issueType:"localappIssueType",author:"localappIssueAuthor",participant:"localappIssueParticipant",assignee:"localappIssueAssignee",milestone:"localappIssueMilestone",reason:"localappIssueReason",subscribed:"localappIssueSubscribed",mentioned:"localappIssueMentioned",locked:"localappIssueLocked",sort:"localappIssueSort",direction:"localappIssueDirection",offset:"localappIssueOffset"},ev=["activity","created","updated","comments"],ey=new Set(["title","body","comments","title,body","title,comments","body,comments","title,body,comments"]);function ew(e,t,s){var n,a;let l=null!=(a=null==(n=e.searchParams.get(t))?void 0:n.trim())?a:"";return l.length<=s?l:""}function ej(e){var t;let s=e.searchParams.get(eg.status),n=e.searchParams.get(eg.sort),a=e.searchParams.get(eg.direction),l=e.searchParams.get(eg.offset),r=e.searchParams.get(eg.issueType),i=null!==l&&/^\d+$/.test(l)?Number(l):0;return{...eh,q:ew(e,eg.q,200),searchIn:ey.has(null!=(t=e.searchParams.get(eg.searchIn))?t:"")?e.searchParams.get(eg.searchIn):"",status:"closed"===s?"closed":"open",label:ew(e,eg.label,100),issueType:"task"===r||"bug"===r||"feature"===r?r:"",author:ew(e,eg.author,100),participant:ew(e,eg.participant,100),assignee:ew(e,eg.assignee,100),milestone:ew(e,eg.milestone,100),reason:"closed"===s&&"not_planned"===e.searchParams.get(eg.reason)?"not_planned":"closed"===s&&"completed"===e.searchParams.get(eg.reason)?"completed":"",subscribed:"1"===e.searchParams.get(eg.subscribed),mentioned:"1"===e.searchParams.get(eg.mentioned),locked:"locked"===e.searchParams.get(eg.locked)?"locked":"unlocked"===e.searchParams.get(eg.locked)?"unlocked":"",sort:ev.includes(n)?n:eh.sort,direction:"asc"===a?"asc":"desc",offset:Number.isSafeInteger(i)&&i>=0?i:0}}let eN=["q","searchIn","author","participant","assignee","milestone"],ek="Issue 服务暂不可用";async function eI(e,t){try{return await e(t)}catch(n){var s;if((null==t?void 0:t.aborted)||n instanceof Error&&"AbortError"===n.name)throw n;return await ((null==t?void 0:t.aborted)?Promise.reject(null!=(s=t.reason)?s:new DOMException("Aborted","AbortError")):new Promise((e,s)=>{let n=setTimeout(function(){null==t||t.removeEventListener("abort",a),e()},300);function a(){var e;clearTimeout(n),s(null!=(e=null==t?void 0:t.reason)?e:new DOMException("Aborted","AbortError"))}null==t||t.addEventListener("abort",a,{once:!0})})),e(t)}}async function eS(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8e3,n=new AbortController,a=!1,l=()=>n.abort(null==t?void 0:t.reason);(null==t?void 0:t.aborted)?l():null==t||t.addEventListener("abort",l,{once:!0});let r=setTimeout(()=>{a=!0,n.abort(new DOMException("Issue list request timed out","TimeoutError"))},s);try{return await e(n.signal)}catch(e){if(a)throw Error(ek);throw e}finally{clearTimeout(r),null==t||t.removeEventListener("abort",l)}}class eA extends Error{constructor(){super("内容已被其他用户更新,当前草稿已保留"),this.name="IssueContentConflictError"}}async function eC(e){var t;let s;if(!(null==(t=e.headers.get("content-type"))?void 0:t.toLowerCase().includes("application/json")))throw Error(ek);try{s=await e.json()}catch(e){throw Error(ek)}if(!e.ok||!s.success){if(409===e.status&&"issue_content_conflict"===s.code)throw new eA;throw Error(s.error||ek)}return{data:s.data,pinned:s.pinned,meta:s.meta}}async function eE(e){return(await eC(e)).data}async function e_(e){var t;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return eS(async t=>eE(await fetch(e,{...s,signal:t})),null!=(t=s.signal)?t:void 0)}function eT(e){return new URLSearchParams({pagePath:e}).toString()}async function eL(e){try{return await eS(async e=>{var t;let s,n=await fetch("/api/users",{credentials:"include",signal:e});if(!n.ok||!(null==(t=n.headers.get("content-type"))?void 0:t.toLowerCase().includes("application/json")))throw Error("负责人目录加载失败");try{s=await n.json()}catch(e){throw Error("负责人目录加载失败")}if(!s.success||!Array.isArray(s.data))throw Error("负责人目录加载失败");return s.data.filter(e=>!!e&&"object"==typeof e&&"string"==typeof e.id&&(null===e.displayName||"string"==typeof e.displayName)&&(void 0===e.name||"string"==typeof e.name)&&(null===e.avatarUrl||"string"==typeof e.avatarUrl))},e)}catch(t){if(null==e?void 0:e.aborted)throw t;throw Error("负责人目录加载失败")}}async function eR(e,t){return e_("/api/issues/config?".concat(eT(e)),{credentials:"include",signal:t}).then(e=>Array.isArray(e.templates)?e.templates:[])}async function eD(e,t){let s=await e_("/api/issues/views?".concat(eT(e)),{credentials:"include",signal:t});return Array.isArray(s)?s.filter(e=>!!e&&"object"==typeof e&&Number.isSafeInteger(e.id)&&"string"==typeof e.user_id&&"string"==typeof e.name&&!!e.name.trim()&&"string"==typeof e.description&&!!e.query&&"object"==typeof e.query&&0===e.query.offset&&"string"==typeof e.created_at&&"string"==typeof e.updated_at):[]}async function ez(e,t,s){return e_("/api/issues/".concat(t,"/duplicate/").concat(s),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eq(e,t,s,n){return e_("/api/issues/views",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,name:t,description:s,query:ef(n)})})}async function eU(e,t,s){return e_("/api/issues/views/".concat(t),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...s,...s.query?{query:ef(s.query)}:{}})})}async function eF(e,t){return e_("/api/issues/views/".concat(t,"/copy"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eP(e,t){await e_("/api/issues/views/".concat(t),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function e$(e,t,s){var n;let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8e3,l=function(e){let t=new URLSearchParams({status:e.status,sort:e.sort,direction:e.direction,limit:String(e.limit),offset:String(e.offset)});for(let s of["q","label","author","participant","assignee","milestone","reason"])e[s]&&t.set(s,e[s]);return e.issueType&&t.set("type",e.issueType),e.q&&e.searchIn&&t.set("in",e.searchIn),e.locked&&t.set("locked","locked"===e.locked?"true":"false"),e.subscribed&&t.set("subscribed","true"),e.mentioned&&t.set("mentioned","true"),t}(t);l.set("pagePath",e);let r=await eS(async e=>eC(await fetch("/api/issues?".concat(l.toString()),{credentials:"include",signal:e})),s,a);return{data:r.data,pinned:Array.isArray(r.pinned)?r.pinned:[],meta:null!=(n=r.meta)?n:{total:r.data.length,open:"open"===t.status?r.data.length:0,closed:"closed"===t.status?r.data.length:0,limit:t.limit,offset:t.offset}}}async function eM(e,t,s,n){let a=new URLSearchParams({pagePath:e,title:t,body:s});return eE(await fetch("/api/issues/potential-duplicates?".concat(a),{credentials:"include",signal:n}))}async function eO(e,t,s){return e_("/api/issues/".concat(t,"/pin"),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,pinned:s})})}async function eK(e,t,s){return e_("/api/issues/".concat(t,"/sub-issues/").concat(s),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eJ(e,t,s){return e_("/api/issues/".concat(t,"/sub-issues/").concat(s),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eB(e,t,s,n){return e_("/api/issues/".concat(t,"/sub-issues/priority"),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,childIssueId:s,afterIssueId:n})})}async function eH(e,t,s,n,a){return e_("/api/issues/".concat(t,"/tasks/").concat(s,"/convert"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,expectedUpdatedAt:n,title:a})})}async function eW(e,t,s){return e_("/api/issues/".concat(t,"/dependencies/blocked-by/").concat(s),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eV(e,t,s){return e_("/api/issues/".concat(t,"/dependencies/blocked-by/").concat(s),{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function eX(e,t,s){return eE(await fetch("/api/issues/".concat(t,"/sub-issues?").concat(eT(e)),{credentials:"include",signal:s}))}async function eQ(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8e3;return eS(async s=>eE(await fetch("/api/issues/".concat(t,"?").concat(eT(e)),{credentials:"include",signal:s})),void 0,s)}async function eZ(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8e3;return eS(async s=>eE(await fetch("/api/issues/by-number/".concat(t,"?").concat(eT(e)),{credentials:"include",signal:s})),void 0,s)}async function eG(e,t,s){let n=void 0===s?"/api/issues/".concat(t,"/history"):"/api/issues/".concat(t,"/comments/").concat(s,"/history");return e_("".concat(n,"?").concat(eT(e)),{credentials:"include"})}async function eY(e,t){return(await e_("/api/issues/labels?".concat(eT(e)),{credentials:"include",signal:t})).filter(e=>!!e&&"object"==typeof e&&"string"==typeof e.id&&"string"==typeof e.name&&"string"==typeof e.color)}async function e0(e,t){await e_("/api/issues/labels/".concat(encodeURIComponent(t),"?").concat(eT(e)),{method:"DELETE",credentials:"include"})}function e1(e,t){return e_("/api/issues/milestones?".concat(eT(e)),{credentials:"include",signal:t})}async function e2(e,t){await e_("/api/issues/milestones/".concat(t,"?").concat(eT(e)),{method:"DELETE",credentials:"include"})}async function e4(e,t,s,n){return e_("/api/issues/".concat(t,"/").concat(s),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...n})})}function e3(e,t,s){return e4(e,t,"labels",{labelIds:s})}function e5(e,t,s){return e4(e,t,"assignees",{userIds:s})}function e8(e,t,s){return e4(e,t,"milestone",{milestoneId:s})}async function e6(e,t,s,n){return e_("/api/issues/".concat(t,"/lock"),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,locked:s,...s&&n?{reason:n}:{}})})}async function e7(e,t,s,n,a){return e_("/api/issues/".concat(t,"/reactions"),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...void 0===a?{}:{commentId:a},content:s,reacted:n})})}async function e9(e){return e_("/api/issues",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function te(e,t,s){return e_("/api/issues/".concat(t),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...s})})}async function tt(e,t,s){return e_("/api/issues/".concat(t,"/comments"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...s})})}async function ts(e,t,s,n,a,l,r,i){return e_("/api/issues/".concat(t,"/comments/").concat(s),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,body:n,...a?{expectedUpdatedAt:a}:{},...l?{draftId:l,attachmentIds:null!=r?r:[],removedAttachmentIds:null!=i?i:[]}:{}})})}async function tn(e,t,s){return e_("/api/issues/".concat(t,"/comments/").concat(s,"?").concat(eT(e)),{method:"DELETE",credentials:"include"})}async function ta(e,t,s,n){return e_("/api/issues/".concat(t,"/comments/").concat(s,"/pin"),{method:n?"PUT":"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e})})}async function tl(e,t,s,n){return e_("/api/issues/".concat(t,"/comments/").concat(s,"/minimize"),{method:null===n?"DELETE":"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:e,...null===n?{}:{reason:n}})})}async function tr(e,t){return e_("/api/issues/".concat(t,"?").concat(eT(e)),{method:"DELETE",credentials:"include"})}async function ti(e,t,s){let n=new FormData;return n.set("pagePath",e),n.set("draftId",t),n.set("file",s),e_("/api/issues/attachments",{method:"POST",credentials:"include",body:n})}let to=/(?:^|[^A-Za-z0-9_.+@/-])@([A-Za-z0-9_-]{0,64})$/;var tc=s(8669),td=s(7272);async function tu(e,t){let s=await fetch(e,{credentials:"include",...t,headers:{...(null==t?void 0:t.body)?{"Content-Type":"application/json"}:{},...null==t?void 0:t.headers}}),n=await s.json().catch(()=>null);if(!s.ok)throw Error((null==n?void 0:n.error)||"保存回复请求失败 (".concat(s.status,")"));return null==n?void 0:n.data}let tm=(0,l.forwardRef)(function(e,t){let{tabIndex:s,onFocus:a,onKeyDown:r,onInsert:i}=e,[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)([]),[m,p]=(0,l.useState)(""),[h,f]=(0,l.useState)(!1),[b,g]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),[w,k]=(0,l.useState)(null),[I,S]=(0,l.useState)(""),[A,E]=(0,l.useState)(""),[_,T]=(0,l.useState)(!1),[L,R]=(0,l.useState)(0),D=(0,l.useRef)(null),z=(0,l.useRef)(null),q=d.filter(e=>e.title.toLocaleLowerCase().includes(m.trim().toLocaleLowerCase())),U=async()=>{f(!0),g(null);try{let e=await tu("/api/issues/saved-replies");u(Array.isArray(e)?e.filter(e=>!!(e&&"object"==typeof e&&Number.isSafeInteger(e.id)&&"string"==typeof e.title&&"string"==typeof e.body)):[])}catch(e){g(e instanceof Error?e.message:"加载保存回复失败")}finally{f(!1)}},F=()=>{c(!1),y(null),k(null),g(null),requestAnimationFrame(()=>{var e;return null==(e=z.current)?void 0:e.focus()})},P=e=>{y(e),k(null),S("new"===e?"":e.title),E("new"===e?"":e.body),g(null)},$=async()=>{T(!0),g(null);try{let e=await tu("new"===v?"/api/issues/saved-replies":"/api/issues/saved-replies/".concat(null==v?void 0:v.id),{method:"new"===v?"POST":"PATCH",body:JSON.stringify({title:I,body:A})});u(t=>"new"===v?[e,...t]:t.map(t=>t.id===e.id?e:t)),y(null)}catch(e){g(e instanceof Error?e.message:"保存回复失败")}finally{T(!1)}},M=async()=>{if(w){T(!0),g(null);try{await tu("/api/issues/saved-replies/".concat(w.id),{method:"DELETE"}),u(e=>e.filter(e=>e.id!==w.id)),k(null)}catch(e){g(e instanceof Error?e.message:"删除保存回复失败")}finally{T(!1)}}};return(0,l.useEffect)(()=>{R(0)},[m]),(0,n.jsxs)("div",{className:"relative shrink-0",children:[(0,n.jsx)(x.$,{ref:e=>{z.current=e,"function"==typeof t?t(e):t&&(t.current=e)},type:"button",variant:"ghost",size:"icon",tabIndex:s,"aria-label":"保存回复","aria-keyshortcuts":"Control+.",title:"保存回复",className:"h-11 w-11 sm:h-8 sm:w-8",onFocus:a,onKeyDown:r,onMouseDown:e=>e.preventDefault(),onClick:()=>o?F():void(c(!0),p(""),y(null),k(null),U(),requestAnimationFrame(()=>{var e;return null==(e=D.current)?void 0:e.focus()})),children:(0,n.jsx)(tc.A,{className:"h-4 w-4"})}),o&&(0,n.jsxs)("div",{role:"dialog","aria-label":"保存回复",onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),F())},className:"absolute right-0 top-full z-50 mt-1 w-[min(24rem,calc(100vw-2rem))] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-xl",children:[(0,n.jsxs)("header",{className:"flex min-h-12 items-center gap-2 border-b px-3",children:[(0,n.jsx)("strong",{className:"min-w-0 flex-1 text-sm",children:"保存回复"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"关闭保存回复",onClick:F,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),v?(0,n.jsxs)("div",{className:"space-y-3 p-3",children:[(0,n.jsx)(C.p,{autoFocus:!0,"aria-label":"回复标题",maxLength:80,value:I,onChange:e=>S(e.target.value),placeholder:"回复标题"}),(0,n.jsx)(B.T,{"aria-label":"回复正文",maxLength:2e4,rows:7,value:A,onChange:e=>E(e.target.value),placeholder:"Markdown 回复正文;使用 %cursor% 指定插入后光标"}),b&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:b}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:_,onClick:()=>{y(null),g(null)},children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:_||!I.trim()||!A.trim(),onClick:()=>void $(),children:_?"保存中...":"保存回复"})]})]}):w?(0,n.jsxs)("div",{className:"space-y-3 p-3",children:[(0,n.jsxs)("p",{className:"text-sm",children:["删除“",w.title,"”?此操作无法撤销。"]}),b&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:b}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(x.$,{autoFocus:!0,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:_,onClick:()=>k(null),children:"取消删除"}),(0,n.jsx)(x.$,{type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:_,onClick:()=>void M(),children:_?"删除中...":"确认删除"})]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex gap-2 border-b p-2",children:[(0,n.jsx)(C.p,{ref:D,type:"search",role:"searchbox","aria-label":"搜索保存回复",value:m,onChange:e=>p(e.target.value),onKeyDown:e=>{if(q.length){if(["ArrowDown","ArrowUp","Home","End"].includes(e.key))e.preventDefault(),R("Home"===e.key?0:"End"===e.key?q.length-1:(L+("ArrowDown"===e.key?1:-1)+q.length)%q.length);else if("Enter"===e.key){var t;e.preventDefault(),i(null!=(t=q[L])?t:q[0]),F()}}},placeholder:"搜索标题"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"icon",className:"h-11 w-11 shrink-0","aria-label":"新建保存回复",onClick:()=>P("new"),children:(0,n.jsx)(j.A,{className:"h-4 w-4"})})]}),(0,n.jsx)("div",{role:"listbox","aria-label":"保存回复列表",className:"max-h-72 overflow-y-auto p-1",children:h?(0,n.jsx)("p",{role:"status",className:"px-3 py-4 text-sm text-muted-foreground",children:"正在加载保存回复..."}):b?(0,n.jsxs)("div",{className:"space-y-2 p-3",children:[(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:b}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8",onClick:()=>void U(),children:"重试"})]}):0===q.length?(0,n.jsxs)("div",{className:"space-y-2 px-3 py-4",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:d.length?"没有匹配的保存回复":"尚未创建保存回复"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8",onClick:()=>P("new"),children:"新建保存回复"})]}):q.map((e,t)=>(0,n.jsxs)("div",{className:"group flex min-h-11 items-center gap-1 rounded ".concat(t===L?"bg-accent":"hover:bg-muted"),children:[(0,n.jsx)("button",{type:"button",role:"option","aria-label":e.title,"aria-selected":t===L,className:"min-h-11 min-w-0 flex-1 truncate px-3 text-left text-sm font-medium",onMouseEnter:()=>R(t),onClick:()=>{i(e),F()},children:e.title}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"编辑 ".concat(e.title),onClick:()=>P(e),children:(0,n.jsx)(td.A,{className:"h-3.5 w-3.5"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 text-destructive sm:h-8 sm:w-8","aria-label":"删除 ".concat(e.title),onClick:()=>{k(e),g(null)},children:(0,n.jsx)(K.A,{className:"h-3.5 w-3.5"})})]},e.id))})]})]})]})}),tp=new Set(Array.from("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"));function th(e){if(!e)return"";let t=Array.from(e.file_name,e=>tp.has(e)?"\\".concat(e):e).join("");return eu(e.mime_type)?".concat(e.url,")"):"[".concat(t,"](").concat(e.url,")")}function tf(e){if(!e)return"";try{var t;return null!=(t=window.sessionStorage.getItem(e))?t:""}catch(e){return""}}function tx(e,t){if(e)try{t?window.sessionStorage.setItem(e,t):window.sessionStorage.removeItem(e)}catch(e){}}function tb(e){return e?"".concat(e,":attachments"):void 0}function tg(e){let t=tb(e);if(t)try{window.sessionStorage.removeItem(t)}catch(e){}}function tv(e,t){let s=new URLSearchParams({pagePath:e,draftId:t.draft_id});fetch("/api/issues/attachments/".concat(encodeURIComponent(t.id),"?").concat(s),{method:"DELETE",credentials:"include",keepalive:!0}).catch(()=>void 0)}function ty(e,t){let s=tw(t,e);tg(t),null==s||s.attachments.forEach(t=>tv(e,t))}function tw(e,t){let s=tb(e);if(!s)return null;try{let e=window.sessionStorage.getItem(s);if(!e)return null;let n=JSON.parse(e);if("string"!=typeof n.draftId||!n.draftId||!Array.isArray(n.attachments)||n.attachments.length>20||n.attachments.some(e=>!function(e,t){if(!e||"object"!=typeof e)return!1;let s="string"==typeof e.url&&e.url.startsWith("/api/issues/attachments/")&&new URL(e.url,window.location.origin).searchParams.get("pagePath")===t;return"string"==typeof e.id&&e.id.length>0&&s&&null===e.issue_id&&null===e.comment_id&&"string"==typeof e.draft_id&&e.draft_id.length>0&&"string"==typeof e.uploader_id&&"string"==typeof e.file_name&&e.file_name.length>0&&"string"==typeof e.mime_type&&"number"==typeof e.size_bytes&&Number.isFinite(e.size_bytes)&&e.size_bytes>0&&e.size_bytes<=0x1900000&&"string"==typeof e.created_at}(e,t)||e.draft_id!==n.draftId))return window.sessionStorage.removeItem(s),null;return{draftId:n.draftId,attachments:n.attachments}}catch(e){try{window.sessionStorage.removeItem(s)}catch(e){}return null}}function tj(e,t,s){let n=tb(e);if(!n)return;let a=s.flatMap(e=>"uploaded"===e.status&&e.attachment?[e.attachment]:[]);try{a.length>0?window.sessionStorage.setItem(n,JSON.stringify({draftId:t,attachments:a})):window.sessionStorage.removeItem(n)}catch(e){}}function tN(e){var t,s;let{pagePath:a,draftId:r,initialBody:i="",textareaLabel:o,placeholder:c,submitLabel:d,status:u,closeReason:m="completed",attachments:p=!0,persistenceKey:h,preferPersistedDraft:f=!1,showRestoredDraftNotice:b=!1,restoredDraft:g=!1,autoFocus:v=d.startsWith("保存"),allowEmpty:y=!1,submitDisabled:w=!1,insertRequest:j,removeTextRequest:N,mentionCandidates:k=[],savedReplies:I=!1,onInsertRequestApplied:S,onDiscardRestoredDraft:C,onBodyChange:E,onCancel:H,onSubmit:W}=e,V=null!=c?c:o.includes("评论")?"留下评论":"详细描述问题、复现步骤或期望结果",[X]=(0,l.useState)(()=>tw(h,a)),[Q,Z]=(0,l.useState)(()=>{let e=tf(h);return f&&e?e:i||e}),[G,Y]=(0,l.useState)(()=>b&&!!(g||tf(h)||(null==X?void 0:X.attachments.length))),[ee,et]=(0,l.useState)("edit"),[es,en]=(0,l.useState)(null!=(t=null==X?void 0:X.draftId)?t:r),[ei,eo]=(0,l.useState)(()=>{var e;return null!=(e=null==X?void 0:X.attachments.map(e=>({clientId:e.id,fileName:e.file_name,fileSize:e.size_bytes,previewUrl:eu(e.mime_type)?e.url:null,attachment:e,markdown:th(e),status:"uploaded"})))?e:[]}),[ec,ed]=(0,l.useState)(!1),[em,eh]=(0,l.useState)(!1),[ef,ex]=(0,l.useState)(null),[eb,eg]=(0,l.useState)(null),[ev,ey]=(0,l.useState)(""),[ew,ej]=(0,l.useState)(null),[eN,ek]=(0,l.useState)(!1),[eI,eS]=(0,l.useState)(Q.length),[eA,eC]=(0,l.useState)(!1),[eE,e_]=(0,l.useState)(0),eT="issue-composer-".concat((0,l.useId)().replace(/[^A-Za-z0-9_-]/g,"")),eL="".concat(eT,"-mentions"),eR="".concat(eT,"-edit-tab"),eD="".concat(eT,"-preview-tab"),ez="".concat(eT,"-panel"),eq="".concat(eT,"-attachments"),eU=(0,l.useRef)(null),eF=(0,l.useRef)(null);(0,l.useEffect)(()=>{null==E||E(Q)},[Q,E]);let eP=(0,l.useRef)(new Map),e$=(0,l.useRef)(null),eM=(0,l.useRef)([]),[eO,eK]=(0,l.useState)(0),eJ=(0,l.useRef)(null),eB=(0,l.useRef)(null),eH=(0,l.useRef)({start:Q.length,end:Q.length}),eW=(0,l.useRef)(!1),eV=(0,l.useRef)([]),eX=(0,l.useRef)(new Map),eQ=(0,l.useRef)(0),eZ=(0,l.useRef)(null),eG=(0,l.useRef)(null),eY=eA?function(e,t){let s=e.slice(0,Math.max(0,t)),n=s.match(to);return n?{start:s.length-n[1].length-1,end:t,query:n[1]}:null}(Q,eI):null,e0=null!=(s=null==eY?void 0:eY.query.toLocaleLowerCase())?s:"",e1=eY?Array.from(new Map(k.map(e=>[e.id,e])).values()).filter(e=>{var t,s;let n=(null==(t=e.displayName)?void 0:t.trim())||(null==(s=e.name)?void 0:s.trim())||e.id;return e.id.toLocaleLowerCase().includes(e0)||n.toLocaleLowerCase().includes(e0)}).slice(0,8):[];(0,l.useEffect)(()=>{eV.current=ei},[ei]),(0,l.useEffect)(()=>{ev&&(Q||ei.length>0)&&ey("")},[ei.length,Q,ev]),(0,l.useEffect)(()=>{if(!v)return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=e$.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[v]),(0,l.useEffect)(()=>{tx(h,Q)},[Q,h]),(0,l.useEffect)(()=>{tj(h,es,ei),0===ei.length&&en(r)},[es,ei,r,h]),(0,l.useEffect)(()=>{j&&eZ.current!==j.id&&(eZ.current=j.id,Z(e=>{let t=e.trim()?"".concat(e,"\n\n").concat(j.text):j.text;return eH.current={start:t.length,end:t.length},t}),et("edit"),eW.current=!0,null==S||S(j.id))},[j,S]),(0,l.useEffect)(()=>{if(!N||eG.current===N.id)return;eG.current=N.id;let e=N.url.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z(t=>t.replace(RegExp("!?\\[[^\\]]*\\]\\(".concat(e,"\\)"),"g"),"").replace(/\n{3,}/g,"\n\n").trim())},[N]),(0,l.useEffect)(()=>()=>{eX.current.clear(),eV.current.forEach(e=>{var t,s,n;(null==(t=e.previewUrl)?void 0:t.startsWith("blob:"))&&(null==(s=(n=URL).revokeObjectURL)||s.call(n,e.previewUrl))})},[]),(0,l.useEffect)(()=>{if("edit"!==ee||!eW.current)return;let e=requestAnimationFrame(()=>{let e=e$.current;e&&(eW.current=!1,e.focus(),e.setSelectionRange(eH.current.start,eH.current.end))});return()=>cancelAnimationFrame(e)},[Q,ee]),(0,l.useEffect)(()=>{e_(0)},[null==eY?void 0:eY.start,e0]);let e2=e=>{eo(t=>{let s=e(t);return eV.current=s,s})},e4=e=>{var t;let s=(null!=(t=eX.current.get(e))?t:0)+1;return eX.current.set(e,s),s},e3=async(e,t)=>{if(e.file)try{let s=await ti(a,es,e.file);if(eX.current.get(e.clientId)!==t)return void tv(a,s);let n=th(s),l={...e,attachment:s,markdown:n,status:"uploaded",error:void 0};e2(t=>t.map(t=>t.clientId===e.clientId?l:t)),Z(e=>e.trim()?"".concat(e,"\n\n").concat(n):n)}catch(s){if(eX.current.get(e.clientId)!==t)return;e2(t=>t.map(t=>t.clientId===e.clientId?{...t,status:"error",error:s instanceof Error?s.message:"附件上传失败"}:t))}},e5=e=>{let t=Math.max(0,20-eV.current.length),s=e.slice(0,t),n=e.length-s.length;ej(n>0?"每个草稿最多添加 20 个附件;已忽略 ".concat(n," 个文件"):null),s.forEach(e=>{var t,s,n;let a=null!=(n=null==(s=globalThis.crypto)||null==(t=s.randomUUID)?void 0:t.call(s))?n:"".concat(Date.now(),"-").concat(e.name,"-").concat(Math.random()),l={clientId:a,file:e,fileName:e.name,fileSize:e.size,previewUrl:eu(e.type)&&"undefined"!=typeof URL&&URL.createObjectURL?URL.createObjectURL(e):null,status:e.size>0&&e.size<=0x1900000?"uploading":"error",error:0===e.size?"不能上传空文件":e.size>0x1900000?"单个附件不能超过 25 MiB":void 0};e2(e=>[...e,l]),"uploading"===l.status&&e3(l,e4(a))})},e8=async(e,t)=>{e.preventDefault();let s=eV.current;if(!s.some(e=>"uploaded"!==e.status)&&(y||Q.trim()||s.some(e=>"uploaded"===e.status))){eg(null),ey(""),eh(!0),ex(null!=t?t:"submit");try{await W({body:Q.trim(),attachmentIds:s.flatMap(e=>"uploaded"===e.status&&e.attachment?[e.attachment.id]:[]),draftId:es,statusAction:t,stateReason:"closed"===t?m:void 0}),ey("closed"===t?"评论并关闭成功":"open"===t?"重新打开并评论成功":"".concat(d,"成功")),eX.current.clear(),s.forEach(e=>{var t,s,n;(null==(t=e.previewUrl)?void 0:t.startsWith("blob:"))&&(null==(s=(n=URL).revokeObjectURL)||s.call(n,e.previewUrl))}),Z(""),Y(!1),tx(h,""),eV.current=[],eo([]),ej(null),ek(!1),eH.current={start:0,end:0},eS(0),eC(!1),e_(0),et("edit"),t||window.requestAnimationFrame(()=>{var e;return null==(e=e$.current)?void 0:e.focus()})}catch(e){eg(e instanceof Error?e.message:"提交失败,请重试")}finally{eh(!1),ex(null)}}},e6=ei.some(e=>"uploading"===e.status),e7=ei.some(e=>"uploaded"!==e.status),e9=ei.some(e=>"error"===e.status)?"请移除或重试上传失败的附件":null,te=!y&&!Q.trim()&&!ei.some(e=>"uploaded"===e.status),tt=em||e7||te||w,ts=0===ei.length?"没有附件":["".concat(ei.filter(e=>"uploading"===e.status).length," 个上传中"),"".concat(ei.filter(e=>"uploaded"===e.status).length," 个已就绪"),"".concat(ei.filter(e=>"error"===e.status).length," 个失败")].join(","),tn=Math.max(0,ei.filter(e=>"uploaded"===e.status).length-4),ta=0,tl=ei.filter(e=>!!eN||"uploaded"!==e.status||(ta+=1)<=4),tr=()=>{eW.current=!0},tc=()=>{if(eW.current)return;let e=e$.current;e&&(eH.current={start:e.selectionStart,end:e.selectionEnd})},td=e=>{var t,s;let n=e$.current,a=function(e,t,s,n){let a=Math.max(0,Math.min(t,e.length)),l=Math.max(a,Math.min(s,e.length));return el.has(n)?function(e,t,s,n){let a=e.lastIndexOf("\n",Math.max(0,t-1))+1,l=e.indexOf("\n",s>t?s-1:s),r=-1===l?e.length:l,i=(e.slice(a,r)||("heading"===n?"标题":"quote"===n?"引用":"task-list"===n?"任务":"列表项")).split("\n").map(e=>e.replace(er,"")).map((e,t)=>"heading"===n?"## ".concat(e):"quote"===n?"> ".concat(e):"bullet-list"===n?"- ".concat(e):"ordered-list"===n?"".concat(t+1,". ").concat(e):"- [ ] ".concat(e)).join("\n");return{value:e.slice(0,a)+i+e.slice(r),selectionStart:a,selectionEnd:a+i.length}}(e,a,l,n):function(e,t,s,n){let a=e.slice(t,s);if("link"===n){let n=a||"链接文字",l="[".concat(n,"](url)"),r=t+n.length+3;return{value:e.slice(0,t)+l+e.slice(s),selectionStart:r,selectionEnd:r+3}}let{before:l,after:r,placeholder:i}={bold:{before:"**",after:"**",placeholder:"粗体文本"},italic:{before:"_",after:"_",placeholder:"斜体文本"},code:{before:"`",after:"`",placeholder:"代码"}}[n],o=a||i,c=l+o+r,d=t+l.length;return{value:e.slice(0,t)+c+e.slice(s),selectionStart:d,selectionEnd:d+o.length}}(e,a,l,n)}(Q,null!=(t=null==n?void 0:n.selectionStart)?t:eH.current.start,null!=(s=null==n?void 0:n.selectionEnd)?s:eH.current.end,e);eH.current={start:a.selectionStart,end:a.selectionEnd},Z(a.value),et("edit"),tr()},tu=e=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;e.preventDefault();let t="ArrowLeft"===e.key||"Home"===e.key?"edit":"preview";"preview"===t&&"edit"===ee&&tc(),et(t),window.requestAnimationFrame(()=>{var e;return null==(e="edit"===t?eJ.current:eB.current)?void 0:e.focus()})},tp=e=>{if(!eY)return;let t=function(e,t,s){let n="@".concat(s," ");return{value:e.slice(0,t.start)+n+e.slice(t.end),caret:t.start+n.length}}(Q,eY,e.id);Z(t.value),eS(t.caret),eH.current={start:t.caret,end:t.caret},eW.current=!0,eC(!1)},tb=[{command:"heading",label:"标题格式",icon:_.A},{command:"bold",label:"粗体",icon:T.A},{command:"italic",label:"斜体",icon:L.A},{command:"quote",label:"引用",icon:R.A},{command:"code",label:"行内代码",icon:D.A},{command:"link",label:"链接",icon:z.A},{command:"bullet-list",label:"无序列表",icon:q.A},{command:"ordered-list",label:"有序列表",icon:U.A},{command:"task-list",label:"任务列表",icon:F.A}],tg=(e,t)=>{var s;let n,a=tb.length+ +!!I;if("Home"===e.key)n=0;else if("End"===e.key)n=a-1;else if("ArrowLeft"===e.key||"ArrowUp"===e.key)n=(t-1+a)%a;else{if("ArrowRight"!==e.key&&"ArrowDown"!==e.key)return;n=(t+1)%a}e.preventDefault(),eK(n),null==(s=eM.current[n])||s.focus()};return(0,n.jsxs)("form",{onSubmit:e=>void e8(e),onKeyDown:e=>{if(!e.nativeEvent.isComposing&&229!==e.keyCode){if("Enter"===e.key&&!e.shiftKey&&(e.metaKey||e.ctrlKey)&&!e.altKey){if(e.defaultPrevented||tt)return;e.preventDefault(),e.currentTarget.requestSubmit();return}(e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&"p"===e.key.toLowerCase()&&(e.preventDefault(),"edit"===ee?(tc(),et("preview"),window.requestAnimationFrame(()=>{var e;return null==(e=eB.current)?void 0:e.focus()})):(et("edit"),tr()))}},className:"space-y-3",children:[(0,n.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true","aria-label":"提交状态",className:"sr-only",children:ev}),G&&(0,n.jsxs)("div",{role:"status",className:"flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{children:"已恢复未提交的草稿"}),(0,n.jsx)(J,{triggerLabel:"丢弃草稿",onConfirm:()=>{eV.current.forEach(e=>{e.attachment&&tv(a,e.attachment)}),Z(i),tx(h,""),tj(h,es,[]),e2(()=>[]),ej(null),ek(!1),Y(!1),et("edit"),null==C||C()},focusAfterConfirm:()=>{var e;return null==(e=e$.current)?void 0:e.focus()}})]}),(0,n.jsxs)("div",{"data-localapp-issue-editor":!0,className:"overflow-visible rounded-md border bg-background",children:[(0,n.jsxs)("div",{role:"tablist","aria-label":"Markdown 模式",className:"flex items-center gap-1 border-b bg-muted/30 px-2 py-1.5",children:[(0,n.jsx)("button",{ref:eJ,id:eR,type:"button",role:"tab","aria-selected":"edit"===ee,"aria-controls":ez,tabIndex:"edit"===ee?0:-1,onKeyDown:tu,onClick:()=>{et("edit"),tr()},className:"h-11 rounded px-3 text-xs font-medium sm:h-7 sm:px-2 ".concat("edit"===ee?"bg-background shadow-sm":"text-muted-foreground"),children:"编辑"}),(0,n.jsx)("button",{ref:eB,id:eD,type:"button",role:"tab","aria-selected":"preview"===ee,"aria-controls":ez,tabIndex:"preview"===ee?0:-1,"aria-keyshortcuts":"Meta+Shift+P Control+Shift+P",onKeyDown:tu,onClick:()=>{tc(),et("preview")},className:"h-11 rounded px-3 text-xs font-medium sm:h-7 sm:px-2 ".concat("preview"===ee?"bg-background shadow-sm":"text-muted-foreground"),children:"预览"})]}),"edit"===ee?(0,n.jsxs)("div",{id:ez,role:"tabpanel","aria-labelledby":eR,children:[(0,n.jsxs)("div",{"data-localapp-issue-toolbar":!0,role:"toolbar","aria-label":"Markdown 工具栏",className:"flex min-h-10 flex-wrap items-center gap-0.5 overflow-x-hidden border-b bg-muted/20 px-2 py-1 sm:flex-nowrap sm:overflow-x-auto",children:[tb.map((e,t)=>{let{command:s,label:a,icon:l}=e;return(0,n.jsx)(x.$,{ref:e=>{eM.current[t]=e},type:"button",variant:"ghost",size:"icon",tabIndex:eO===t?0:-1,"aria-label":a,title:a,className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8",onFocus:()=>eK(t),onKeyDown:e=>tg(e,t),onMouseDown:e=>e.preventDefault(),onClick:()=>td(s),children:(0,n.jsx)(l,{className:"h-4 w-4"})},s)}),I&&(0,n.jsx)(tm,{ref:e=>{eM.current[tb.length]=e},tabIndex:eO===tb.length?0:-1,onFocus:()=>eK(tb.length),onKeyDown:e=>tg(e,tb.length),onInsert:e=>{var t,s;let n=e$.current,a=function(e,t,s,n){let a=Math.max(0,Math.min(t,e.length)),l=Math.max(a,Math.min(s,e.length)),r=n.indexOf("%cursor%"),i=r<0?n:"".concat(n.slice(0,r)).concat(n.slice(r+8)),o="".concat(e.slice(0,a)).concat(i).concat(e.slice(l)),c=a+(r<0?i.length:r);return{body:o,selectionStart:c,selectionEnd:c}}(Q,null!=(t=null==n?void 0:n.selectionStart)?t:eH.current.start,null!=(s=null==n?void 0:n.selectionEnd)?s:eH.current.end,e.body);eH.current={start:a.selectionStart,end:a.selectionEnd},Z(a.body),et("edit"),tr()}})]}),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(B.T,{ref:e$,"aria-label":o,placeholder:V,"aria-autocomplete":"list","aria-expanded":e1.length>0,"aria-controls":e1.length>0?eL:void 0,"aria-activedescendant":e1.length>0?"".concat(eL,"-").concat(eE):void 0,value:Q,onChange:e=>{eg(null),Z(e.target.value),eS(e.target.selectionStart),eH.current={start:e.target.selectionStart,end:e.target.selectionEnd},eC(!0)},onSelect:e=>{tc(),eS(e.currentTarget.selectionStart)},onKeyUp:e=>{tc(),eS(e.currentTarget.selectionStart)},onKeyDown:e=>{var t,s;if(e.nativeEvent.isComposing||229===e.keyCode)return;if(eY&&e1.length>0&&["ArrowDown","ArrowUp","Enter","Tab","Escape"].includes(e.key)){if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),eC(!1);return}if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e_(t=>(t+("ArrowDown"===e.key?1:-1)+e1.length)%e1.length);return}e.preventDefault(),tp(null!=(t=e1[eE])?t:e1[0]);return}if(I&&e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&"."===e.key){e.preventDefault(),null==(s=eM.current[tb.length])||s.click();return}if(!(e.ctrlKey||e.metaKey)||e.altKey)return;let n="b"===e.key.toLowerCase()?"bold":"i"===e.key.toLowerCase()?"italic":"k"===e.key.toLowerCase()?"link":null;n&&(e.preventDefault(),td(n))},onPaste:p?e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),e5(t))}:void 0,rows:6,className:"min-h-28 resize-y border-0 focus-visible:ring-0"}),e1.length>0&&(0,n.jsx)("div",{id:eL,role:"listbox","aria-label":"提及用户建议",className:"absolute left-2 right-2 top-full z-30 mt-1 max-h-56 overflow-y-auto rounded-[6px] border bg-popover p-1 shadow-lg",children:e1.map((e,t)=>{var s,a,l;let r=(null==(s=e.displayName)?void 0:s.trim())||(null==(a=e.name)?void 0:a.trim())||e.id;return(0,n.jsxs)("button",{id:"".concat(eL,"-").concat(t),type:"button",role:"option","aria-label":"".concat(r,",账号 @").concat(e.id),"aria-selected":t===eE,className:"flex min-h-11 w-full min-w-0 items-center gap-2 rounded px-2 text-left text-sm sm:min-h-10 ".concat(t===eE?"bg-accent":"hover:bg-muted"),onMouseDown:e=>e.preventDefault(),onClick:()=>tp(e),children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold",children:(null==(l=Array.from(r)[0])?void 0:l.toLocaleUpperCase())||"?"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[(0,n.jsx)("strong",{children:r}),(0,n.jsxs)("span",{className:"ml-2 text-muted-foreground",children:["@",e.id]})]})]},e.id)})}),eY&&0===e1.length&&(0,n.jsx)("div",{role:"status","aria-label":"提及用户建议状态",className:"absolute left-2 right-2 top-full z-30 mt-1 rounded-[6px] border bg-popover px-3 py-3 text-sm text-muted-foreground shadow-lg",children:"没有匹配的用户"})]})]}):(0,n.jsx)("div",{id:ez,role:"tabpanel","aria-labelledby":eD,className:"min-h-28 px-3 py-2",children:Q?(0,n.jsx)(ea,{children:Q}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"暂无内容"})})]}),p&&(0,n.jsxs)("div",{"data-localapp-issue-attachment-queue":!0,tabIndex:-1,"data-drag-active":ec?"true":void 0,"aria-label":"拖拽附件到此处","aria-busy":e6||void 0,onDragEnter:e=>{Array.from(e.dataTransfer.types).includes("Files")&&(e.preventDefault(),eQ.current+=1,ed(!0))},onDragLeave:e=>{ec&&(e.preventDefault(),eQ.current=Math.max(0,eQ.current-1),0===eQ.current&&ed(!1))},onDragOver:e=>{Array.from(e.dataTransfer.types).includes("Files")&&e.preventDefault()},onDrop:e=>{e.preventDefault(),eQ.current=0,ed(!1),e5(Array.from(e.dataTransfer.files))},className:"rounded-md border border-dashed px-3 py-2 transition-colors motion-reduce:transition-none ".concat(ec?"border-primary bg-primary/5 ring-2 ring-primary/20":""),children:[ec&&(0,n.jsx)("span",{role:"status","aria-label":"附件拖拽状态",className:"sr-only",children:"松开以上传文件"}),(0,n.jsx)("span",{role:"status","aria-label":"附件队列状态","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:ts}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("input",{ref:eU,"data-testid":"issue-attachment-input",hidden:!0,type:"file",multiple:!0,onChange:e=>{var t;e5(Array.from(null!=(t=e.target.files)?t:[])),e.target.value=""}}),(0,n.jsxs)(x.$,{ref:eF,type:"button",variant:"outline",size:"sm",className:"h-11 gap-1.5 sm:h-8",onClick:()=>{var e;return null==(e=eU.current)?void 0:e.click()},children:[(0,n.jsx)(P.A,{className:"h-3.5 w-3.5"}),"添加附件"]}),(0,n.jsx)("span",{className:"text-xs ".concat(ec?"font-medium text-primary":"text-muted-foreground"),children:ec?"松开以上传文件":"拖拽文件或粘贴截图"})]}),ei.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("ul",{id:eq,className:"mt-2 grid gap-2 sm:grid-cols-2",children:tl.map(e=>{var t;return(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-2 rounded border bg-card p-2 text-xs",children:[e.previewUrl?(0,n.jsx)("img",{src:e.previewUrl,alt:"".concat(e.fileName," 预览"),className:"h-10 w-10 shrink-0 rounded object-cover"}):(0,n.jsx)($.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"truncate font-medium",children:e.fileName}),(0,n.jsxs)("p",{role:"uploaded"===e.status?"status":void 0,"aria-label":"uploaded"===e.status?"".concat(e.fileName," 已上传"):void 0,className:"inline-flex items-center gap-1 ".concat(e.error?"text-destructive":"uploaded"===e.status?"text-emerald-700":"text-muted-foreground"),children:["uploaded"===e.status&&(0,n.jsx)(M.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),null!=(t=e.error)?t:"uploading"===e.status?"上传中...":"已上传 \xb7 ".concat(ep(e.fileSize))]})]}),"uploading"===e.status&&(0,n.jsx)(A.A,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"error"===e.status&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-7 sm:w-7","aria-label":"重试 ".concat(e.fileName),onClick:()=>(e=>{let t={...e,status:"uploading",error:void 0};e2(s=>s.map(s=>s.clientId===e.clientId?t:s)),e3(t,e4(e.clientId))})(e),children:(0,n.jsx)(O.A,{className:"h-3.5 w-3.5"})}),(0,n.jsx)(x.$,{ref:t=>{t?eP.current.set(e.clientId,t):eP.current.delete(e.clientId)},type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-7 sm:w-7","aria-label":"移除 ".concat(e.fileName),onClick:()=>(e=>{var t,s,n,l,r;let i=tl.findIndex(t=>t.clientId===e.clientId),o=null==(t=tl[i+1])?void 0:t.clientId,c=null==(s=tl[i-1])?void 0:s.clientId;ej(null),e4(e.clientId),(null==(n=e.previewUrl)?void 0:n.startsWith("blob:"))&&(null==(l=(r=URL).revokeObjectURL)||l.call(r,e.previewUrl)),e2(t=>t.filter(t=>t.clientId!==e.clientId)),Z(t=>{var s,n;return(n=null!=(s=e.markdown)?s:th(e.attachment))?t.replace(n,"").replace(/\n{3,}/g,"\n\n").trim():t}),e.attachment&&tv(a,e.attachment),window.requestAnimationFrame(()=>{let e=o&&eP.current.get(o)||c&&eP.current.get(c)||eF.current;null==e||e.focus()})})(e),children:(0,n.jsx)(K.A,{className:"h-3.5 w-3.5"})})]},e.clientId)})}),tn>0&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"mt-2 h-11 sm:h-8","aria-expanded":eN,"aria-controls":eq,onClick:()=>ek(e=>!e),children:eN?"收起已上传附件":"显示其余 ".concat(tn," 个已上传附件")})]})]}),ew&&(0,n.jsx)("p",{role:"alert","data-localapp-issue-attachment-limit-error":!0,className:"text-sm text-destructive",children:ew}),(e9||eb)&&(0,n.jsx)("p",{role:"alert","data-localapp-issue-submit-error":!0,className:"text-sm text-destructive",children:e9||eb}),(0,n.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[H&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:em,onClick:H,children:"取消"}),(0,n.jsxs)(x.$,{type:"submit",size:"sm",className:"h-11 min-w-[5.5rem] gap-1.5 sm:h-8","aria-keyshortcuts":"Meta+Enter Control+Enter","aria-busy":"submit"===ef||void 0,disabled:tt,children:["submit"===ef&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),d]}),"open"===u&&(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 min-w-[7.5rem] gap-1.5 sm:h-8","aria-busy":"closed"===ef||void 0,disabled:tt,onClick:e=>void e8(e,"closed"),children:["closed"===ef&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"评论并关闭"]}),"closed"===u&&(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 min-w-[9rem] gap-1.5 sm:h-8","aria-busy":"open"===ef||void 0,disabled:tt,onClick:e=>void e8(e,"open"),children:["open"===ef&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"重新打开并评论"]})]})]})}let tk={name:"",color:"1f6feb",description:""};function tI(e){let{labels:t,saving:s,error:a,onCreate:r,onUpdate:i,onDelete:o}=e,[c,d]=(0,l.useState)(null),[u,m]=(0,l.useState)(tk),[p,h]=(0,l.useState)(null),f=(0,l.useRef)(null),b=(0,l.useRef)(null),g=(0,l.useRef)(null),v=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;c&&(null==(e=f.current)||e.focus())},[c]),(0,l.useEffect)(()=>{var e;p&&(null==(e=g.current)||e.focus())},[p]);let y=e=>{var t;h(null),d(null!=(t=null==e?void 0:e.id)?t:"new"),m(e?{name:e.name,color:e.color,description:e.description}:tk)},w=async()=>{if(u.name.trim()&&/^[0-9a-fA-F]{6}$/.test(u.color))try{let e={...u,name:u.name.trim(),color:u.color.toLowerCase(),description:u.description.trim()};"new"===c?await r(e):c&&await i(c,e),d(null)}catch(e){}},N=()=>{h(null),window.requestAnimationFrame(()=>{var e;return null==(e=b.current)?void 0:e.focus()})},k=async e=>{try{await o(e),h(null)}catch(e){}},I=t.find(e=>e.id===p);return(0,n.jsxs)("section",{"aria-labelledby":"issue-label-manager-title",className:"relative min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:[(0,n.jsxs)("div",{className:"mx-auto max-w-4xl",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b pb-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{id:"issue-label-manager-title",className:"text-lg font-semibold",children:"标签"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"使用标签对 Issue 进行分类和筛选。"})]}),(0,n.jsxs)(x.$,{type:"button",size:"sm",className:"h-11 gap-1.5 sm:h-8",onClick:()=>y(),children:[(0,n.jsx)(j.A,{className:"h-4 w-4"}),"新建标签"]})]}),a&&(0,n.jsx)("p",{role:"alert",className:"mt-4 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:a}),c&&(0,n.jsxs)("div",{className:"mt-4 rounded-md border bg-muted/20 p-4",children:[(0,n.jsxs)("div",{className:"grid gap-4 sm:grid-cols-[minmax(0,1fr)_140px]",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(E.J,{htmlFor:"issue-label-name",children:"名称"}),(0,n.jsx)(C.p,{ref:f,id:"issue-label-name",className:"mt-1 h-11 sm:h-9",maxLength:50,value:u.name,onChange:e=>m({...u,name:e.target.value})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(E.J,{htmlFor:"issue-label-color",children:"颜色"}),(0,n.jsxs)("div",{className:"mt-1 flex h-11 items-center gap-2 rounded-md border bg-background px-2 sm:h-9",children:[(0,n.jsx)("input",{id:"issue-label-color","aria-label":"标签颜色选择器",type:"color",className:"h-7 w-8 cursor-pointer border-0 bg-transparent p-0",value:"#".concat(/^[0-9a-fA-F]{6}$/.test(u.color)?u.color:"000000"),onChange:e=>m({...u,color:e.target.value.slice(1)})}),(0,n.jsx)("input",{"aria-label":"标签颜色",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none",maxLength:6,value:u.color,onChange:e=>m({...u,color:e.target.value.replace(/^#/,"")})})]})]})]}),(0,n.jsxs)("div",{className:"mt-4",children:[(0,n.jsx)(E.J,{htmlFor:"issue-label-description",children:"描述"}),(0,n.jsx)(C.p,{id:"issue-label-description",className:"mt-1 h-11 sm:h-9",maxLength:200,value:u.description,onChange:e=>m({...u,description:e.target.value})})]}),(0,n.jsxs)("div",{className:"mt-4 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:s,onClick:()=>d(null),children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:s||!u.name.trim()||!/^[0-9a-fA-F]{6}$/.test(u.color),onClick:()=>void w(),children:s?"正在保存...":"new"===c?"创建标签":"保存更改"})]})]}),(0,n.jsx)("ul",{"aria-label":"Issue 标签",className:"mt-4 divide-y rounded-md border",children:t.map(e=>(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-3 px-4 py-3",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:"#".concat(e.color)}}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("strong",{className:"truncate text-sm",children:e.name}),!!e.built_in&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"内置"})]}),(0,n.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.description||"无描述"})]}),!e.built_in&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"编辑标签 ".concat(e.name),onClick:()=>y(e),children:(0,n.jsx)(td.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 text-destructive sm:h-8 sm:w-8","aria-label":"删除标签 ".concat(e.name),onClick:t=>{b.current=t.currentTarget,h(e.id)},children:(0,n.jsx)(K.A,{className:"h-4 w-4"})})]})]},e.id))})]}),I&&(0,n.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-black/45 p-4",children:(0,n.jsxs)("div",{role:"alertdialog","aria-modal":"true","aria-label":"删除标签 ".concat(I.name," 确认"),"aria-describedby":"delete-label-description",onKeyDown:e=>{if("Escape"!==e.key||s){if("Tab"===e.key){let t=g.current,s=v.current;t&&s&&e.shiftKey&&document.activeElement===t?(e.preventDefault(),s.focus()):t&&s&&!e.shiftKey&&document.activeElement===s&&(e.preventDefault(),t.focus())}}else e.preventDefault(),N()},className:"w-full max-w-md rounded-md border bg-background p-4 shadow-xl",children:[(0,n.jsxs)("p",{className:"text-sm font-medium",children:["删除“",I.name,"”?"]}),(0,n.jsx)("p",{id:"delete-label-description",className:"mt-1 text-xs text-muted-foreground",children:"该标签会从所有 Issue 中移除,此操作无法撤销。"}),a&&(0,n.jsx)("p",{role:"alert",className:"mt-3 text-sm text-destructive",children:a}),(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:g,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:s,onClick:N,children:"取消"}),(0,n.jsx)(x.$,{ref:v,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:s,onClick:()=>void k(I.id),children:"确认删除标签"})]})]})})]})}let tS={title:"",description:"",dueOn:null,state:"open"};function tA(e){var t;let{milestones:s,saving:a,error:r,onCreate:i,onUpdate:c,onDelete:d}=e,[u,m]=(0,l.useState)(null),[p,h]=(0,l.useState)(tS),[f,b]=(0,l.useState)(null),g=(0,l.useRef)(null),v=(0,l.useRef)(null),w=(0,l.useRef)(null),N=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;u&&(null==(e=g.current)||e.focus())},[u]),(0,l.useEffect)(()=>{var e;null!==f&&(null==(e=w.current)||e.focus())},[f]);let k=e=>{var t;m(null!=(t=null==e?void 0:e.id)?t:"new"),h(e?{title:e.title,description:e.description,dueOn:e.due_on,state:e.state}:tS)},I=async()=>{if(p.title.trim())try{"new"===u?await i({title:p.title.trim(),description:p.description.trim(),dueOn:p.dueOn||null}):null!==u&&await c(u,{...p,title:p.title.trim(),description:p.description.trim(),dueOn:p.dueOn||null}),m(null)}catch(e){}},S=()=>{b(null),requestAnimationFrame(()=>{var e;return null==(e=v.current)?void 0:e.focus()})},A=s.find(e=>{let{id:t}=e;return t===f});return(0,n.jsxs)("section",{"aria-labelledby":"issue-milestone-manager-title",className:"relative min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:[(0,n.jsxs)("div",{className:"mx-auto max-w-5xl",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b pb-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{id:"issue-milestone-manager-title",className:"text-lg font-semibold",children:"里程碑"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"按版本或阶段组织 Issue,并跟踪完成进度。"})]}),(0,n.jsxs)(x.$,{type:"button",size:"sm",className:"h-11 gap-1.5 sm:h-8",onClick:()=>k(),children:[(0,n.jsx)(j.A,{className:"h-4 w-4"}),"新建里程碑"]})]}),r&&(0,n.jsx)("p",{role:"alert",className:"mt-4 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:r}),null!==u&&(0,n.jsxs)("div",{className:"mt-4 rounded-md border bg-muted/20 p-4",children:[(0,n.jsxs)("div",{className:"grid gap-4 sm:grid-cols-[minmax(0,1fr)_180px]",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(E.J,{htmlFor:"issue-milestone-title",children:"标题"}),(0,n.jsx)(C.p,{ref:g,id:"issue-milestone-title",className:"mt-1 h-11 sm:h-9",maxLength:100,value:p.title,onChange:e=>h({...p,title:e.target.value})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(E.J,{htmlFor:"issue-milestone-due",children:"截止日期"}),(0,n.jsx)(C.p,{id:"issue-milestone-due",type:"date",className:"mt-1 h-11 sm:h-9",value:null!=(t=p.dueOn)?t:"",onChange:e=>h({...p,dueOn:e.target.value||null})})]})]}),(0,n.jsxs)("div",{className:"mt-4",children:[(0,n.jsx)(E.J,{htmlFor:"issue-milestone-description",children:"描述"}),(0,n.jsx)(C.p,{id:"issue-milestone-description",className:"mt-1 h-11 sm:h-9",maxLength:1e3,value:p.description,onChange:e=>h({...p,description:e.target.value})})]}),(0,n.jsxs)("div",{className:"mt-4 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:a,onClick:()=>m(null),children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:a||!p.title.trim(),onClick:()=>void I(),children:a?"正在保存...":"new"===u?"创建里程碑":"保存更改"})]})]}),(0,n.jsx)("ul",{"aria-label":"Issue 里程碑",className:"mt-4 divide-y rounded-md border",children:s.map(e=>{let t=e.open_issues+e.closed_issues,s=0===t?0:Math.round(e.closed_issues/t*100);return(0,n.jsx)("li",{className:"px-4 py-4",children:(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("strong",{className:"text-sm",children:e.title}),(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:["open"===e.state?(0,n.jsx)(o.A,{className:"h-3.5 w-3.5"}):(0,n.jsx)(M.A,{className:"h-3.5 w-3.5"}),"open"===e.state?"开启":"已关闭"]}),e.due_on&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[(0,n.jsx)(y.A,{className:"h-3.5 w-3.5"}),e.due_on]})]}),(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.description||"无描述"}),(0,n.jsx)("div",{className:"mt-3 h-2 overflow-hidden rounded-full bg-muted",children:(0,n.jsx)("div",{className:"h-full bg-primary",style:{width:"".concat(s,"%")}})}),(0,n.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[s,"% 已完成 \xb7 ",e.open_issues," 个开启 \xb7 ",e.closed_issues," 个已关闭"]})]}),(0,n.jsxs)("div",{className:"flex shrink-0 gap-1",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"编辑里程碑 ".concat(e.title),onClick:()=>k(e),children:(0,n.jsx)(td.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"".concat("open"===e.state?"关闭":"重开","里程碑 ").concat(e.title),onClick:()=>void c(e.id,{title:e.title,description:e.description,dueOn:e.due_on,state:"open"===e.state?"closed":"open"}),children:"open"===e.state?(0,n.jsx)(M.A,{className:"h-4 w-4"}):(0,n.jsx)(o.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 text-destructive sm:h-8 sm:w-8","aria-label":"删除里程碑 ".concat(e.title),onClick:t=>{v.current=t.currentTarget,b(e.id)},children:(0,n.jsx)(K.A,{className:"h-4 w-4"})})]})]})},e.id)})})]}),A&&(0,n.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-black/45 p-4",children:(0,n.jsxs)("div",{role:"alertdialog","aria-modal":"true","aria-label":"删除里程碑 ".concat(A.title," 确认"),onKeyDown:e=>{"Escape"!==e.key||a?"Tab"===e.key&&w.current&&N.current&&(e.shiftKey&&document.activeElement===w.current?(e.preventDefault(),N.current.focus()):e.shiftKey||document.activeElement!==N.current||(e.preventDefault(),w.current.focus())):(e.preventDefault(),e.stopPropagation(),S())},className:"w-full max-w-md rounded-md border bg-background p-4 shadow-xl",children:[(0,n.jsxs)("p",{className:"text-sm font-medium",children:["删除“",A.title,"”?"]}),(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"关联的 Issue 会变为无里程碑,不会删除 Issue。此操作无法撤销。"}),r&&(0,n.jsx)("p",{role:"alert",className:"mt-3 text-sm text-destructive",children:r}),(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:w,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:a,onClick:S,children:"取消"}),(0,n.jsx)(x.$,{ref:N,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:a,onClick:()=>void d(A.id).then(()=>b(null)).catch(()=>void 0),children:"确认删除里程碑"})]})]})})]})}var tC=s(1678),tE=s(7445),t_=s(1774),tT=s(8667),tL=s(5572),tR=s(824),tD=s(5098),tz=s(882),tq=s(3902),tU=s(6839);function tF(e){let{label:t,onSelect:s}=e,a=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"h-2 w-2 rounded-full",style:{backgroundColor:"#".concat(t.color)}}),t.name]});return s?(0,n.jsx)("button",{type:"button","aria-label":"按标签筛选 ".concat(t.name),onClick:()=>s(t.id),className:"inline-flex min-h-6 shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:a}):(0,n.jsx)("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium",children:a})}let tP=[{value:"is:",label:"状态",description:"筛选 Open 或 Closed Issue"},{value:"in:",label:"范围",description:"限定搜索标题、正文或评论"},{value:"label:",label:"标签",description:"筛选带指定标签的 Issue"},{value:"type:",label:"类型",description:"筛选任务、缺陷或功能 Issue"},{value:"author:",label:"作者",description:"筛选指定用户创建的 Issue"},{value:"assignee:",label:"负责人",description:"筛选分配给指定用户的 Issue"},{value:"involves:",label:"参与者",description:"筛选指定用户参与的 Issue"},{value:"milestone:",label:"里程碑",description:"筛选指定里程碑内的 Issue"},{value:"reason:",label:"关闭原因",description:"筛选已完成或不计划处理的 Closed Issue"},{value:"mentions:",label:"提及",description:"筛选提及当前用户的 Issue"},{value:"no:",label:"缺失项",description:"筛选缺少元数据的 Issue"},{value:"sort:",label:"排序",description:"按活动、创建、更新或评论排序"}],t$=[["activity-desc","最近活动"],["activity-asc","最早活动"],["created-desc","最新创建"],["created-asc","最早创建"],["updated-desc","最近更新"],["updated-asc","最早更新"],["comments-desc","评论最多"],["comments-asc","评论最少"]],tM=["title","body","comments"];function tO(e,t,s){let n=function(e,t){let s=Math.max(0,Math.min(t,e.length)),n=0,a=!1;for(let t=0;t<s;t+=1){let s=e[t];'"'===s?a=!a:/\s/.test(s)&&!a&&(n=t+1)}return{start:n,end:s}}(e,t),a=e.slice(n.start,n.end),l=a.indexOf(":");if(l<0){let e=a.toLowerCase();return{...n,items:tP.filter(e=>"mentions:"!==e.value||!!s.currentUserId).filter(t=>t.value.startsWith(e)).map(e=>({id:"key-".concat(e.value.slice(0,-1)),...e}))}}let r=a.slice(0,l).toLowerCase(),i=a.slice(l+1).replace(/^"/,"").toLowerCase(),o=[],c=(e,t,s)=>{let n="".concat(r,":").concat(/\s/.test(e)?'"'.concat(e.replaceAll('"','\\"'),'"'):e);(e.toLowerCase().startsWith(i)||"is"!==r&&t.toLowerCase().includes(i))&&o.push({id:"".concat(r,"-").concat(encodeURIComponent(e.toLowerCase())),value:n,label:t,description:s})};if("is"===r)c("open","Open","仅显示待处理 Issue"),c("closed","Closed","仅显示已关闭 Issue"),c("locked","Locked","仅显示已锁定对话"),c("unlocked","Unlocked","仅显示未锁定对话"),s.currentUserId&&c("subscribed","Subscribed","仅显示当前用户关注的 Issue");else if("in"===r)c("title","标题","仅搜索 Issue 标题"),c("body","正文","仅搜索 Issue 首帖正文"),c("comments","评论","仅搜索未删除评论");else if("label"===r)for(let e of s.labels)c(e.name,e.name,e.id);else if("type"===r)c("task","任务","Task Issue"),c("bug","缺陷","Bug Issue"),c("feature","功能","Feature Issue");else if("milestone"===r){var d;for(let e of null!=(d=s.milestones)?d:[])c(e.title,e.title,"#".concat(e.id))}else if("reason"===r)c("completed","已完成","仅显示以已完成关闭的 Issue"),c("not planned","不计划处理","仅显示以不计划处理关闭的 Issue");else if("mentions"===r)s.currentUserId&&c("@me","@me","提及当前用户");else if("no"===r)c("assignee","无负责人","仅显示尚未分配负责人的 Issue"),c("label","无标签","仅显示尚未添加标签的 Issue"),c("milestone","无里程碑","仅显示尚未设置里程碑的 Issue");else if("author"===r||"involves"===r||"assignee"===r)for(let e of(s.currentUserId&&c("@me","@me","当前用户"),new Map(s.users.map(e=>[e.id.toLowerCase(),e])).values())){let t=e.displayName||e.name||e.id;c(e.id,t,"@".concat(e.id))}else if("sort"===r)for(let[e,t]of t$)c(e,t,e.endsWith("-desc")?"降序":"升序");return{...n,items:o.slice(0,8)}}function tK(e,t){let s={q:"",offset:0},n=[],a=new Set;for(let i of function(e){let t=[],s="",n=!1,a=()=>{s&&t.push({value:s,quotesClosed:!n}),s="",n=!1};for(let t of e.trim()){if(/\s/.test(t)&&!n){a();continue}s+=t,'"'===t&&(n=!n)}return a(),t}(e)){var l,r;let e=i.value.indexOf(":");if(e<=0||!i.quotesClosed){n.push(i.value);continue}let o=i.value.slice(0,e).toLowerCase(),c=(l=i.value.slice(e+1))?l.startsWith('"')||l.endsWith('"')?l.startsWith('"')&&l.endsWith('"')&&l.length>=2?l.slice(1,-1):null:l:null,d=!1;if(null!==c&&"in"===o){let e=c.toLowerCase().split(",");if(e.length>0&&e.every(e=>tM.includes(e))){for(let t of e)a.add(t);d=!0}}else if(null!==c&&"is"===o&&/^(open|closed)$/i.test(c))s.status=c.toLowerCase(),d=!0;else if(null!==c&&"is"===o&&/^(locked|unlocked)$/i.test(c))s.locked=c.toLowerCase(),d=!0;else if(null!==c&&"is"===o&&"subscribed"===c.toLowerCase()&&t.currentUserId)s.subscribed=!0,d=!0;else if(null!==c&&"label"===o){let e=t.labels.find(e=>e.id.toLowerCase()===c.toLowerCase()||e.name.toLowerCase()===c.toLowerCase());e&&(s.label=e.id,d=!0)}else if(null!==c&&"type"===o&&/^(task|bug|feature)$/i.test(c))s.issueType=c.toLowerCase(),d=!0;else if(null!==c&&"milestone"===o){let e=(null!=(r=t.milestones)?r:[]).find(e=>String(e.id)===c||e.title.toLowerCase()===c.toLowerCase());e&&(s.milestone=String(e.id),d=!0)}else if(null!==c&&"reason"===o&&/^(completed|not[ _]planned)$/i.test(c))s.status="closed",s.reason="completed"===c.toLowerCase()?"completed":"not_planned",d=!0;else if(null!==c&&"mentions"===o&&"@me"===c.toLowerCase()&&t.currentUserId)s.mentioned=!0,d=!0;else if(null!==c&&"no"===o&&/^(assignee|label|milestone)$/i.test(c))s[c.toLowerCase()]="none",d=!0;else if(null!==c&&("author"===o||"involves"===o||"assignee"===o)){let e="@me"===c.toLowerCase()?t.currentUserId:c.replace(/^@/,"");e&&(s["author"===o?"author":"assignee"===o?"assignee":"participant"]=e,d=!0)}else if(null!==c&&"sort"===o){let e=/^(activity|created|updated|comments)-(asc|desc)$/i.exec(c);e&&(s.sort=e[1].toLowerCase(),s.direction=e[2].toLowerCase(),d=!0)}d||n.push(i.value)}return s.q=n.join(" "),s.q&&a.size>0&&(s.searchIn=tM.filter(e=>a.has(e)).join(",")),s}function tJ(e,t){return[e,e&&t?"in:".concat(t):""].filter(Boolean).join(" ")}function tB(e){let{timestamp:t,href:s,precise:a=!1,now:l,className:r}=e,i=new Date(t),o=Number.isFinite(i.getTime())?i.toLocaleString():t,c=a?o:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),s=new Date(e).getTime();if(!Number.isFinite(s))return e;let n=Math.floor(Math.max(0,t-s)/6e4);if(n<1)return"刚刚";if(n<60)return"".concat(n,"分钟前");let a=Math.floor(n/60);if(a<24)return"".concat(a,"小时前");let l=Math.floor(a/24);return l<30?"".concat(l,"天前"):new Date(s).toLocaleDateString()}(t,l),d=(0,n.jsx)("time",{dateTime:t,title:o,className:s?void 0:r,children:c});return s?(0,n.jsx)("a",{href:s,className:"-my-2 inline-flex h-11 items-center px-1 sm:-my-0 sm:h-6 ".concat(null!=r?r:""),children:d}):d}var tH=s(3403),tW=s(4112),tV=s(7338);function tX(e){let{label:t,items:s}=e,a=(0,l.useId)(),[r,i]=(0,l.useState)(!1),o=(0,l.useRef)(null),c=(0,l.useRef)(null),d=(0,l.useRef)([]),u=(0,l.useRef)("first"),m=e=>{i(!1),e&&window.requestAnimationFrame(()=>{var e;return null==(e=c.current)?void 0:e.focus()})};return((0,l.useEffect)(()=>{if(!r)return;let e=()=>d.current.filter(e=>!!(e&&!e.disabled)),t=window.requestAnimationFrame(()=>{var t;let s=e();null==(t="last"===u.current?s.at(-1):s[0])||t.focus()}),s=e=>{var t;e.target instanceof Node&&!(null==(t=o.current)?void 0:t.contains(e.target))&&m(!0)},n=t=>{var s;let n;if(!(t.target instanceof Node)||!(null==(s=o.current)?void 0:s.contains(t.target)))return;if("Escape"===t.key){t.preventDefault(),t.stopPropagation(),m(!0);return}let a=e();if(0===a.length)return;let l=Math.max(0,a.indexOf(document.activeElement));if("ArrowDown"===t.key)n=a[(l+1)%a.length];else if("ArrowUp"===t.key)n=a[(l-1+a.length)%a.length];else if("Home"===t.key)n=a[0];else if("End"===t.key)n=a.at(-1);else if(1===t.key.length&&!t.ctrlKey&&!t.metaKey&&!t.altKey){let e=t.key.toLocaleLowerCase();n=[...a.slice(l+1),...a.slice(0,l+1)].find(t=>{var s;return null==(s=t.textContent)?void 0:s.trim().toLocaleLowerCase().startsWith(e)})}n&&(t.preventDefault(),t.stopPropagation(),n.focus())};return document.addEventListener("mousedown",s),document.addEventListener("keydown",n,!0),()=>{window.cancelAnimationFrame(t),document.removeEventListener("mousedown",s),document.removeEventListener("keydown",n,!0)}},[r]),(0,l.useEffect)(()=>{0===s.length&&i(!1)},[s.length]),(0,l.useEffect)(()=>{var e;if(!r||0===s.length||(null==(e=o.current)?void 0:e.contains(document.activeElement)))return;let t=window.requestAnimationFrame(()=>{var e;null==(e=d.current.find(e=>e&&!e.disabled))||e.focus()});return()=>window.cancelAnimationFrame(t)},[s,r]),0===s.length)?null:(0,n.jsxs)("div",{ref:o,className:"relative shrink-0",children:[(0,n.jsx)(x.$,{ref:c,type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":t,"aria-haspopup":"menu","aria-controls":a,"aria-expanded":r,onKeyDown:e=>{("ArrowDown"===e.key||"ArrowUp"===e.key)&&(e.preventDefault(),e.stopPropagation(),u.current="ArrowUp"===e.key?"last":"first",i(!0))},onClick:()=>{u.current="first",i(e=>!e)},children:(0,n.jsx)(tV.A,{className:"h-4 w-4"})}),r&&(0,n.jsx)("div",{id:a,role:"menu","aria-label":t,className:"absolute right-0 top-12 z-30 min-w-40 overflow-hidden rounded-[6px] border bg-popover p-1 shadow-lg sm:top-9",children:s.map((e,t)=>(0,n.jsx)("button",{ref:e=>{d.current[t]=e},type:"button",role:"menuitem",disabled:e.disabled,className:"flex min-h-11 w-full items-center rounded px-3 text-left text-sm outline-none hover:bg-muted focus:bg-muted disabled:opacity-50 sm:min-h-8 sm:px-2.5 ".concat(e.destructive?"text-destructive":"text-popover-foreground"),onClick:()=>{m(!1!==e.restoreFocus),e.onSelect(c.current)},children:e.label},e.label))})]})}function tQ(e){var t;let{views:s,activeViewId:a,dirty:r,currentQuery:i,loading:o,error:c,saving:u,onApply:m,onCreate:p,onUpdate:h,onCopy:f,onDelete:b,onRetry:g}=e,[v,y]=(0,l.useState)(null),[w,j]=(0,l.useState)(""),[k,I]=(0,l.useState)(""),[S,_]=(0,l.useState)(null),[T,L]=(0,l.useState)(null),R=(0,l.useRef)(null),D=null!=(t=s.find(e=>e.id===a))?t:null;(0,l.useEffect)(()=>{var e,t,s,n,a;v&&(j("edit"===v.mode?null!=(s=null==(e=v.view)?void 0:e.name)?s:"":"save-as"===v.mode&&D?"".concat(D.name," copy"):""),I("edit"===v.mode?null!=(n=null==(t=v.view)?void 0:t.description)?n:"":"save-as"===v.mode&&null!=(a=null==D?void 0:D.description)?a:""),_(null))},[D,v]);let z=e=>y(e),q=()=>{u||y(null)},U=async()=>{if(v&&w.trim()&&!u){_(null);try{"edit"===v.mode&&v.view?await h(v.view.id,{name:w.trim(),description:k.trim()}):await p(w.trim(),k.trim()),y(null)}catch(e){_(e instanceof Error?e.message:"保存视图失败")}}},F=async e=>{_(null);try{await f(e)}catch(e){_(e instanceof Error?e.message:"复制视图失败")}},P=async()=>{if(T&&!u){_(null);try{await b(T.id),L(null)}catch(e){_(e instanceof Error?e.message:"删除视图失败")}}};return(0,n.jsxs)("section",{"aria-labelledby":"issue-saved-views-title",className:"mt-2 min-w-0 lg:mt-4 lg:border-t lg:pt-3",children:[(0,n.jsxs)("div",{className:"mb-1 flex min-h-8 items-center justify-end gap-2 px-0 lg:px-2",children:[(0,n.jsx)("h3",{id:"issue-saved-views-title",className:"sr-only min-w-0 flex-1 text-xs font-semibold uppercase text-muted-foreground lg:not-sr-only",children:"保存的视图"}),D&&r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 lg:h-8 lg:w-8","aria-label":"保存视图更改",title:"保存更改",disabled:u,onClick:()=>void h(D.id,{query:i}),children:(0,n.jsx)(d.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 lg:h-8 lg:w-8","aria-label":"将当前查询另存为视图",title:"另存为",disabled:u,onClick:()=>z({mode:"save-as"}),children:(0,n.jsx)(tH.A,{className:"h-4 w-4"})})]}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 lg:h-8 lg:w-8","aria-label":"保存当前 Issue 视图",title:"保存当前视图",onClick:()=>z({mode:"create"}),children:(0,n.jsx)(tW.A,{className:"h-4 w-4"})})]}),o&&(0,n.jsxs)("p",{role:"status",className:"hidden min-h-11 items-center gap-2 px-2 text-xs text-muted-foreground lg:flex",children:[(0,n.jsx)(A.A,{className:"h-3.5 w-3.5 animate-spin"}),"正在加载保存视图..."]}),c&&(0,n.jsxs)("div",{role:"alert",className:"hidden space-y-2 px-2 py-2 text-xs text-destructive lg:block",children:[(0,n.jsx)("p",{children:c}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8","aria-label":"重试保存视图",onClick:g,children:"重试"})]}),!o&&!c&&0===s.length&&(0,n.jsx)("p",{className:"hidden px-2 py-2 text-xs text-muted-foreground lg:block",children:"尚未保存视图"}),!o&&!c&&s.length>0&&(0,n.jsx)("div",{className:"hidden space-y-1 lg:block",children:s.map(e=>(0,n.jsxs)("div",{className:"group flex min-w-0 items-center gap-1",children:[(0,n.jsxs)("button",{type:"button","aria-label":"打开保存视图 ".concat(e.name),"aria-pressed":a===e.id,title:e.description||e.name,onClick:()=>m(e),className:"h-11 min-w-0 flex-1 truncate rounded px-2.5 text-left text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8 ".concat(a===e.id?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[e.name,a===e.id&&r?(0,n.jsx)("span",{"aria-hidden":"true",children:" *"}):null]}),(0,n.jsx)(tX,{label:"管理保存视图 ".concat(e.name),items:[{label:"编辑视图",restoreFocus:!1,onSelect:()=>z({mode:"edit",view:e})},{label:"复制视图",onSelect:()=>void F(e.id)},{label:"删除视图",destructive:!0,restoreFocus:!1,onSelect:()=>{L(e),window.requestAnimationFrame(()=>{var e;return null==(e=R.current)?void 0:e.focus()})}}]})]},e.id))}),D&&r&&(0,n.jsx)("p",{role:"status",className:"mt-2 hidden rounded-md border bg-muted/30 p-2 text-xs font-medium lg:block",children:"有未保存更改"}),S&&!v&&(0,n.jsx)("p",{role:"alert",className:"mt-2 px-2 text-xs text-destructive",children:S}),v&&(0,n.jsx)("div",{className:"absolute inset-0 z-[80] flex items-center justify-center bg-black/45 p-4",children:(0,n.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"saved-view-editor-title",className:"w-full max-w-lg overflow-hidden rounded-md border bg-card shadow-2xl",children:[(0,n.jsxs)("header",{className:"flex min-h-14 items-center gap-3 border-b px-4",children:[(0,n.jsx)("h3",{id:"saved-view-editor-title",className:"min-w-0 flex-1 text-sm font-semibold",children:"edit"===v.mode?"编辑保存视图":"save-as"===v.mode?"另存当前视图":"保存当前视图"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11","aria-label":"关闭保存视图编辑器",onClick:q,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(0,n.jsxs)("div",{className:"space-y-4 p-4",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(E.J,{htmlFor:"saved-view-name",children:"视图名称"}),(0,n.jsx)(C.p,{id:"saved-view-name",autoFocus:!0,value:w,maxLength:50,onChange:e=>j(e.target.value)})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(E.J,{htmlFor:"saved-view-description",children:"视图说明"}),(0,n.jsx)(C.p,{id:"saved-view-description",value:k,maxLength:200,onChange:e=>I(e.target.value)})]}),S&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:S})]}),(0,n.jsxs)("footer",{className:"flex justify-end gap-2 border-t px-4 py-3",children:[(0,n.jsx)(x.$,{type:"button",variant:"outline",className:"h-11 sm:h-8",disabled:u,onClick:q,children:"取消"}),(0,n.jsx)(x.$,{type:"button",className:"h-11 sm:h-8",disabled:u||!w.trim(),onClick:()=>void U(),children:u?"保存中...":"保存视图"})]})]})}),T&&(0,n.jsx)("div",{className:"absolute inset-0 z-[80] flex items-center justify-center bg-black/45 p-4",children:(0,n.jsxs)("div",{role:"alertdialog","aria-modal":"true","aria-labelledby":"saved-view-delete-title","aria-describedby":"saved-view-delete-description",className:"w-full max-w-md overflow-hidden rounded-md border bg-card shadow-2xl",children:[(0,n.jsxs)("div",{className:"space-y-2 p-4",children:[(0,n.jsx)("h3",{id:"saved-view-delete-title",className:"text-sm font-semibold",children:"删除保存视图"}),(0,n.jsxs)("p",{id:"saved-view-delete-description",className:"text-sm text-muted-foreground",children:["“",T.name,"”将从你的个人视图中删除,不会修改任何 Issue。"]}),S&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:S})]}),(0,n.jsxs)("footer",{className:"flex justify-end gap-2 border-t px-4 py-3",children:[(0,n.jsx)(x.$,{ref:R,type:"button",variant:"outline",className:"h-11 sm:h-8",disabled:u,onClick:()=>L(null),children:"取消删除"}),(0,n.jsx)(x.$,{type:"button",variant:"destructive",className:"h-11 sm:h-8","aria-label":"确认删除视图",disabled:u,onClick:()=>void P(),children:u?"删除中...":"确认删除"})]})]})})]})}function tZ(e){let{status:t,className:s="h-4 w-4"}=e;return"open"===t?(0,n.jsx)(o.A,{className:"".concat(s," text-primary"),"aria-hidden":"true"}):(0,n.jsx)(M.A,{className:"".concat(s," text-muted-foreground"),"aria-hidden":"true"})}function tG(e){let{issue:t,className:s="h-4 w-4"}=e;if("open"===t.status)return(0,n.jsx)("span",{"aria-label":"开启",title:"开启",className:s,children:(0,n.jsx)(o.A,{className:"h-full w-full text-primary","aria-hidden":"true"})});let a="not_planned"===t.state_reason,l=a?"已关闭:不计划处理":"已关闭:已完成";return(0,n.jsx)("span",{"aria-label":l,title:l,className:s,children:a?(0,n.jsx)(tC.A,{className:"h-full w-full text-muted-foreground","aria-hidden":"true"}):(0,n.jsx)(M.A,{className:"h-full w-full text-primary","aria-hidden":"true"})})}function tY(e){var t,s;let{issue:a}=e,l=null!=(s=null!=(t=a.last_activity_at)?t:a.updated_at)?s:a.created_at,r=l===a.created_at;return(0,n.jsxs)("span",{"data-localapp-issue-activity":!0,"data-kind":r?"created":"activity",className:"inline-flex min-w-0 flex-wrap items-center gap-1",children:[(0,n.jsx)("span",{children:r?"创建于":"活动于"}),(0,n.jsx)(tB,{timestamp:l})]})}function t0(e){let{ids:t,users:s,onSelect:a}=e,l=Array.from(new Set(t));if(0===l.length)return null;let r=l.map(e=>{var t;let n=s.find(t=>t.id===e);return{id:e,label:(null==n?void 0:n.displayName)||(null==n?void 0:n.name)||e,avatarUrl:null!=(t=null==n?void 0:n.avatarUrl)?t:null}}),i=r.slice(0,3),o=r.length-i.length;return(0,n.jsxs)("div",{role:"group","aria-label":"负责人:".concat(r.map(e=>e.label).join("、")),className:"hidden shrink-0 self-center -space-x-1.5 sm:flex",children:[i.map(e=>{var t;return(0,n.jsx)("button",{type:"button","aria-label":"按负责人筛选 ".concat(e.label),title:"".concat(e.label," @").concat(e.id),onClick:()=>a(e.id),className:"flex h-7 w-7 items-center justify-center overflow-hidden rounded-full border-2 border-background bg-muted text-[10px] font-semibold text-muted-foreground hover:z-10 hover:ring-2 hover:ring-ring focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:e.avatarUrl?(0,n.jsx)("img",{src:e.avatarUrl,alt:"",className:"h-full w-full object-cover"}):(null==(t=Array.from(e.label)[0])?void 0:t.toLocaleUpperCase())||"?"},e.id)}),o>0&&(0,n.jsxs)("span",{"aria-label":"另外 ".concat(o," 位负责人"),className:"flex h-7 min-w-7 items-center justify-center rounded-full border-2 border-background bg-muted px-1 text-[10px] font-semibold text-muted-foreground",children:["+",o]})]})}function t1(e){let{milestone:t,onSelect:s}=e;return t?(0,n.jsxs)("button",{type:"button","aria-label":"按里程碑筛选 ".concat(t.title),onClick:()=>s(t.id),className:"inline-flex min-h-6 max-w-full items-center gap-1 rounded-sm text-left hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,n.jsx)(y.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,n.jsx)("span",{className:"break-words",children:t.title})]}):null}function t2(e){var t,s,a,r,i,c;let{currentUserId:d,error:u,issues:m,pinnedIssues:p=[],labels:h,milestones:f,users:b,loading:g,meta:v,query:w,searchInput:j,searchInputRef:I,onOpenIssue:E,getIssueHref:_,onQueryChange:T,onReset:L,onRetry:R,onSearchInputChange:D,onSubmitSearch:z,canBulkManage:q=!1,onBulkStatus:U,onBulkIssueType:F,onBulkLabel:P,onBulkAssignee:$,onBulkMilestone:O,savedViews:K=[],savedViewsLoading:J=!1,savedViewsError:B=null,savedViewsSaving:H=!1,activeSavedViewId:W=null,savedViewDirty:V=!1,onApplySavedView:X,onCreateSavedView:Q,onUpdateSavedView:Z,onCopySavedView:G,onDeleteSavedView:Y,onRetrySavedViews:ee,onLeaveSavedView:et}=e,[es,en]=(0,l.useState)("all"),ea=function(e,t){let s=e.author===t&&!e.participant&&!e.assignee&&!e.subscribed&&!e.mentioned,n=e.assignee===t&&!e.author&&!e.participant&&!e.subscribed&&!e.mentioned,a=s?"":e.author,l=n?"":e.assignee;return[e.issueType,e.label,a,l,e.milestone,e.locked,e.reason].filter(Boolean).length+Number("activity"!==e.sort||"desc"!==e.direction)}(w,d),[el,er]=(0,l.useState)(()=>ea>0),[eo,ec]=(0,l.useState)(new Set),[ed,eu]=(0,l.useState)(!1),[em,ep]=(0,l.useState)(""),[eh,ef]=(0,l.useState)(""),[ex,eb]=(0,l.useState)(""),[eg,ev]=(0,l.useState)(""),[ey,ew]=(0,l.useState)(""),[ej,eN]=(0,l.useState)(!1),[ek,eI]=(0,l.useState)(j.length),[eS,eA]=(0,l.useState)(-1),eC=(0,l.useRef)(null),eE=(0,l.useRef)(null),e_=(0,l.useRef)(null),eT=(0,l.useRef)(!1),eL=(0,l.useRef)(!1),eR=(0,l.useRef)(null),eD=(0,l.useRef)(!1),ez=(0,l.useRef)(null),eq=(0,l.useRef)(null),eU=(0,l.useRef)(null),eF="localapp-issue-search-suggestions",eP=tO(j,null!=(r=eR.current)?r:ek,{currentUserId:d,labels:h,milestones:f,users:b}),e$=ej?eP.items:[];(0,l.useEffect)(()=>{!d||!w.mentioned||w.author||w.participant||w.assignee||w.subscribed?!d||!w.subscribed||w.author||w.participant||w.assignee||w.mentioned?!d||w.assignee!==d||w.author||w.participant||w.subscribed||w.mentioned?!d||w.author!==d||w.participant||w.assignee||w.subscribed||w.mentioned?!d||w.participant!==d||w.author||w.assignee||w.subscribed||w.mentioned?(w.author||w.participant||w.assignee||w.subscribed||w.mentioned||"assigned"===es||"created"===es||"participating"===es||"subscribed"===es||"mentioned"===es)&&en("all"):en("participating"):en("created"):en("assigned"):en("subscribed"):en("mentioned")},[es,d,w.assignee,w.author,w.participant,w.subscribed,w.mentioned]),(0,l.useEffect)(()=>{ec(new Set),ep(""),eE.current=null},[w.q,w.status,w.issueType,w.label,w.author,w.participant,w.assignee,w.milestone,w.reason,w.subscribed,w.mentioned,w.locked,w.sort,w.direction,w.limit,w.offset]);let eM=m.map(e=>e.id).join(",");(0,l.useEffect)(()=>{eE.current=null},[eM]),(0,l.useEffect)(()=>{if(0===eo.size)return;let e=new Set(m.map(e=>e.id)),t=new Set(Array.from(eo).filter(t=>e.has(t))),s=eo.size-t.size;0!==s&&(eL.current=eT.current||null!==e_.current&&!e.has(e_.current),ec(t),ep("".concat(s," 条已选 Issue 已不在当前列表,选择已更新")),eL.current&&window.requestAnimationFrame(()=>{var e;null==(e=eC.current)||e.focus(),eL.current=!1,e_.current=null,eT.current=!1}))},[m,eo]);let eO=!!(w.q||w.searchIn||w.issueType||w.label||w.author||w.participant||w.assignee||w.milestone||w.reason||w.subscribed||w.mentioned||w.locked),eK="all"===es&&"open"===w.status&&0===w.offset&&!eO&&"activity"===w.sort&&"desc"===w.direction&&p.length>0,eJ=w.offset>0&&0===m.length;(0,l.useEffect)(()=>{if(!eD.current)return;if(ez.current!==w.offset){eD.current=!1,ez.current=null;return}if(g||u||v.offset!==w.offset)return;eD.current=!1,ez.current=null;let e=window.requestAnimationFrame(()=>{var e,t,s;m.length>0?null==(t=eq.current)||null==(e=t.querySelector("[data-localapp-issue-link]"))||e.focus():eJ&&(null==(s=eU.current)||s.focus())});return()=>window.cancelAnimationFrame(e)},[u,m,g,v.offset,eJ,w.offset]);let eB=e=>{eD.current=!0,ez.current=e,T({offset:e})},eH=e=>{let t=b.find(t=>t.id===e);return(null==t?void 0:t.displayName)||(null==t?void 0:t.name)||e},eW=[...w.issueType?[{key:"issueType",kind:"类型",value:ei[w.issueType]}]:[],...w.label?[{key:"label",kind:"标签",value:"none"===w.label?"未添加":null!=(i=null==(t=h.find(e=>e.id===w.label))?void 0:t.name)?i:w.label}]:[],...w.author?[{key:"author",kind:"作者",value:eH(w.author)}]:[],...w.participant?[{key:"participant",kind:"参与者",value:eH(w.participant)}]:[],...w.assignee?[{key:"assignee",kind:"负责人",value:"none"===w.assignee?"未分配":eH(w.assignee)}]:[],...w.milestone?[{key:"milestone",kind:"里程碑",value:"none"===w.milestone?"无里程碑":null!=(c=null==(s=f.find(e=>String(e.id)===w.milestone))?void 0:s.title)?c:"#".concat(w.milestone)}]:[],...w.reason?[{key:"reason",kind:"关闭原因",value:"not_planned"===w.reason?"不计划处理":"已完成"}]:[],...w.subscribed?[{key:"subscribed",kind:"关注",value:"我"}]:[],...w.mentioned?[{key:"mentioned",kind:"提及",value:"我"}]:[],...w.locked?[{key:"locked",kind:"对话",value:"locked"===w.locked?"已锁定":"未锁定"}]:[]],eV=g&&m.length>0,eX=eo.size,eQ=m.length>0&&m.every(e=>eo.has(e.id)),eZ=eX>0&&!eQ;(0,l.useEffect)(()=>{eC.current&&(eC.current.indeterminate=eZ)},[eZ]);let eG=[["all","全部 Issue"],...d?[["assigned","分配给我的"],["created","我创建的"],["participating","我参与的"],["subscribed","我关注的"],["mentioned","提及我的"]]:[],["recent","最近活动"]],eY=e=>(null==et||et(),en(e),"assigned"===e&&d)?void T({author:"",participant:"",assignee:d,subscribed:!1,mentioned:!1}):"created"===e&&d?void T({author:d,participant:"",assignee:"",subscribed:!1,mentioned:!1}):"participating"===e&&d?void T({author:"",participant:d,assignee:"",subscribed:!1,mentioned:!1}):"subscribed"===e&&d?void T({author:"",participant:"",assignee:"",subscribed:!0,mentioned:!1}):"mentioned"===e&&d?void T({author:"",participant:"",assignee:"",subscribed:!1,mentioned:!0}):"recent"===e?void T({author:"",participant:"",assignee:"",subscribed:!1,mentioned:!1,sort:"activity",direction:"desc"}):void T({author:"",participant:"",assignee:"",subscribed:!1,mentioned:!1}),e0=()=>{en("all"),L(),window.requestAnimationFrame(()=>{var e;return null==I||null==(e=I.current)?void 0:e.focus()})},e1=e=>T({status:e}),e2=(e,t)=>{0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),E(t))},e4=(e,t,s)=>{let n=eE.current,a=s&&null!==n?m.findIndex(e=>e.id===n):-1,l=m.findIndex(t=>t.id===e);ec(s=>{let n=new Set(s);for(let s of a>=0&&l>=0?m.slice(Math.min(a,l),Math.max(a,l)+1).map(e=>e.id):[e])t?n.add(s):n.delete(s);return n}),eE.current=e},e3=async e=>{if(U&&0!==eX&&!ed){eu(!0),ep("");try{let t=await U(Array.from(eo),e);eE.current=null,ec(new Set(t.failedIds)),ep(t.failedIds.length?"".concat(t.succeeded," 条成功,").concat(t.failedIds.length," 条失败,可重试失败项"):"".concat(t.succeeded," 条 Issue 已更新")),0===t.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){ep(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1)}}},e5=async e=>{if(F&&0!==eX&&!ed&&e){eu(!0),ep("");try{let t=await F(Array.from(eo),e);eE.current=null,ec(new Set(t.failedIds)),ep(t.failedIds.length?"".concat(t.succeeded," 条成功,").concat(t.failedIds.length," 条失败,可重试失败项"):"".concat(t.succeeded," 条 Issue 已更新")),0===t.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){ep(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1),ef("")}}},e8=async e=>{if(!P||0===eX||ed||!e)return;let[t,s]=e.split(":",2);if(s&&("add"===t||"remove"===t)){eu(!0),ep("");try{let e=await P(Array.from(eo),s,"add"===t);eE.current=null,ec(new Set(e.failedIds)),ep(e.failedIds.length?"".concat(e.succeeded," 条成功,").concat(e.failedIds.length," 条失败,可重试失败项"):"".concat(e.succeeded," 条 Issue 已更新")),0===e.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){ep(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1),eb("")}}},e6=async e=>{if(!$||0===eX||ed||!e)return;let[t,s]=e.split(":",2);if(s&&("add"===t||"remove"===t)){eu(!0),ep("");try{let e=await $(Array.from(eo),s,"add"===t);eE.current=null,ec(new Set(e.failedIds)),ep(e.failedIds.length?"".concat(e.succeeded," 条成功,").concat(e.failedIds.length," 条失败,可重试失败项"):"".concat(e.succeeded," 条 Issue 已更新")),0===e.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){ep(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1),ev("")}}},e7=async e=>{if(!O||0===eX||ed||!e)return;let t="none"===e?null:Number(e);if(null===t||Number.isInteger(t)&&!(t<=0)){eu(!0),ep("");try{let e=await O(Array.from(eo),t);eE.current=null,ec(new Set(e.failedIds)),ep(e.failedIds.length?"".concat(e.succeeded," 条成功,").concat(e.failedIds.length," 条失败,可重试失败项"):"".concat(e.succeeded," 条 Issue 已更新")),0===e.failedIds.length&&window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})}catch(e){ep(e instanceof Error?e.message:"批量更新失败")}finally{eu(!1),ew("")}}},e9=e=>{var t;let s=function(e,t,s,n){let a=e.slice(s.end),l=!n.endsWith(":"),r=l&&(0===a.length||!/^\s/.test(a)),i=e.slice(0,s.start)+n+(r?" ":"")+a;return{value:i,cursor:Math.min(s.start+n.length+(l&&(r||/^\s/.test(a))?1:0),i.length)}}(j,0,eP,e.value);D(s.value),eR.current=s.cursor,eI(s.cursor),eA(-1),eN(!0),null==I||null==(t=I.current)||t.focus(),window.requestAnimationFrame(()=>{var e;null==I||null==(e=I.current)||e.setSelectionRange(s.cursor,s.cursor)})},te=()=>{D(""),T({q:"",searchIn:"",offset:0}),eN(!1),eA(-1),eI(0),window.requestAnimationFrame(()=>{var e;return null==I||null==(e=I.current)?void 0:e.focus()})};return(0,n.jsxs)("section",{"data-localapp-issue-list":!0,"data-testid":"issue-list-workspace",className:"grid min-h-0 max-w-full flex-1 grid-rows-[auto_minmax(0,1fr)] overflow-x-hidden [&_[data-localapp-issue-bulk-toolbar]_label:focus-within]:ring-2 [&_[data-localapp-issue-bulk-toolbar]_label:focus-within]:ring-ring lg:grid-cols-[240px_minmax(0,1fr)] lg:grid-rows-1",children:[(0,n.jsxs)("aside",{"data-localapp-issue-view-rail":!0,"data-testid":"issue-view-rail","aria-label":"Issue 视图",className:"min-w-0 border-b bg-muted/20 px-3 py-2 lg:border-b-0 lg:border-r lg:px-3 lg:py-4",children:[(0,n.jsxs)("label",{className:"flex h-11 w-full items-center rounded-md border bg-background px-3 text-sm font-medium text-foreground focus-within:ring-2 focus-within:ring-ring lg:hidden",children:[(0,n.jsx)("span",{className:"sr-only",children:"Issue 视图"}),(0,n.jsxs)("select",{"aria-label":"Issue 视图",value:W?"saved:".concat(W):es,onChange:e=>{let t=e.target.value;if(t.startsWith("saved:")){let e=K.find(e=>e.id===Number(t.slice(6)));e&&(null==X||X(e))}else eY(t)},className:"h-full min-w-0 w-full cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("optgroup",{label:"内置视图",children:eG.map(e=>{let[t,s]=e;return(0,n.jsx)("option",{value:t,children:s},t)})}),K.length>0&&(0,n.jsx)("optgroup",{label:"保存的视图",children:K.map(e=>(0,n.jsxs)("option",{value:"saved:".concat(e.id),children:[e.name,W===e.id&&V?" *":""]},e.id))})]})]}),(0,n.jsx)("nav",{className:"hidden max-w-full gap-1 lg:flex lg:flex-col","aria-label":"Issue 视图导航",children:eG.map(e=>{let[t,s]=e;return(0,n.jsx)("button",{type:"button","aria-pressed":es===t,onClick:()=>eY(t),className:"h-11 shrink-0 rounded px-3 text-left text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8 sm:px-2.5 ".concat(es===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:s},t)})}),Q&&Z&&G&&Y&&ee&&(0,n.jsx)(tQ,{views:K,activeViewId:W,dirty:V,currentQuery:w,loading:J,error:B,saving:H,onApply:e=>null==X?void 0:X(e),onCreate:Q,onUpdate:Z,onCopy:G,onDelete:Y,onRetry:ee})]}),(0,n.jsxs)("div",{className:"flex min-w-0 max-w-full flex-col overflow-x-hidden",children:[(0,n.jsxs)("div",{"data-localapp-issue-toolbar":!0,"data-testid":"issue-toolbar",className:"flex min-w-0 flex-col gap-2 border-b bg-muted/20 px-4 py-2.5 [&_label:focus-within]:ring-2 [&_label:focus-within]:ring-ring sm:flex-row sm:flex-wrap sm:items-center sm:px-5",children:[(0,n.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,n.jsx)(tE.A,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)(C.p,{ref:I,type:"search","aria-label":"搜索 Issue","aria-keyshortcuts":"Meta+/ Control+/","aria-autocomplete":"list","aria-expanded":e$.length>0,"aria-controls":e$.length>0?eF:void 0,"aria-activedescendant":eS>=0?null==(a=e$[eS])?void 0:a.id:void 0,value:j,onFocus:e=>{var t;null===eR.current&&eI(null!=(t=e.currentTarget.selectionStart)?t:j.length),eN(!0)},onBlur:()=>window.setTimeout(()=>eN(!1),0),onChange:e=>{var t;eR.current=null,D(e.target.value),eI(null!=(t=e.target.selectionStart)?t:e.target.value.length),eA(-1),eN(!0)},onKeyDown:e=>{if("ArrowDown"===e.key&&e$.length>0){e.preventDefault(),eA(e=>(e+1)%e$.length);return}if("ArrowUp"===e.key&&e$.length>0){e.preventDefault(),eA(e=>e<=0?e$.length-1:e-1);return}if(("Enter"===e.key||"Tab"===e.key)&&eS>=0&&e$[eS]){e.preventDefault(),e9(e$[eS]);return}if("Escape"===e.key&&e$.length>0){e.preventDefault(),e.stopPropagation(),eN(!1),eA(-1);return}if("Escape"===e.key&&j){e.preventDefault(),e.stopPropagation(),te();return}"Enter"===e.key&&(e.preventDefault(),eN(!1),z())},placeholder:"搜索 Issues",className:"h-11 min-w-0 pl-8 pr-11 text-xs [&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none sm:h-8 sm:pr-9"}),j&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon","aria-label":"清除 Issue 搜索",className:"absolute right-0 top-0 h-11 w-11 sm:h-8 sm:w-8",onMouseDown:e=>e.preventDefault(),onClick:te,children:(0,n.jsx)(N.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e$.length>0&&(0,n.jsx)("div",{id:eF,role:"listbox","aria-label":"搜索限定词建议",className:"absolute left-0 right-0 top-[calc(100%+4px)] z-[65] max-h-72 overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-lg",children:e$.map((e,t)=>(0,n.jsxs)("button",{id:e.id,type:"button",role:"option","aria-selected":eS===t,"aria-label":"".concat(e.label," ").concat(e.description),onMouseDown:e=>e.preventDefault(),onClick:()=>e9(e),className:"flex min-h-11 w-full min-w-0 items-center gap-3 rounded px-3 py-1.5 text-left sm:min-h-10 sm:px-2.5 ".concat(eS===t?"bg-accent text-accent-foreground":"hover:bg-muted"),children:[(0,n.jsx)("code",{className:"shrink-0 text-xs font-semibold",children:e.value}),(0,n.jsx)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:e.description})]},e.id))})]}),(0,n.jsxs)("button",{type:"button","aria-label":ea>0?"筛选,已启用 ".concat(ea," 项"):"筛选","aria-expanded":el,"aria-controls":"localapp-issue-advanced-filters",onClick:()=>er(e=>!e),className:"flex h-11 w-full items-center justify-between rounded-md border bg-background px-3 text-xs font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:hidden",children:[(0,n.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,n.jsx)(t_.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"筛选"]}),ea>0&&(0,n.jsx)("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:ea})]}),(0,n.jsxs)("div",{id:"localapp-issue-advanced-filters","data-testid":"issue-advanced-filters",className:"".concat(el?"grid":"hidden"," min-w-0 grid-cols-1 gap-2 min-[360px]:grid-cols-2 sm:contents [&>label]:min-w-0"),children:[(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(t_.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按类型筛选"}),(0,n.jsxs)("select",{"aria-label":"按类型筛选",value:w.issueType,onChange:e=>T({issueType:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部类型"}),(0,n.jsx)("option",{value:"task",children:"任务"}),(0,n.jsx)("option",{value:"bug",children:"缺陷"}),(0,n.jsx)("option",{value:"feature",children:"功能"})]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(t_.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按标签筛选"}),(0,n.jsxs)("select",{"aria-label":"按标签筛选","aria-keyshortcuts":"L",value:w.label,onChange:e=>T({label:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部标签"}),(0,n.jsx)("option",{value:"none",children:"无标签"}),h.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),"closed"===w.status&&(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(tC.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按关闭原因筛选"}),(0,n.jsxs)("select",{"aria-label":"按关闭原因筛选",value:w.reason,onChange:e=>T({reason:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部关闭原因"}),(0,n.jsx)("option",{value:"completed",children:"已完成"}),(0,n.jsx)("option",{value:"not_planned",children:"不计划处理"})]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(tT.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按创建者筛选"}),(0,n.jsxs)("select",{"aria-label":"按创建者筛选","aria-keyshortcuts":"U",value:w.author,onChange:e=>T({author:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部创建者"}),w.author&&!b.some(e=>e.id===w.author)&&(0,n.jsx)("option",{value:w.author,children:w.author}),b.map(e=>(0,n.jsx)("option",{value:e.id,children:e.displayName||e.name||e.id},e.id))]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(tT.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按负责人筛选"}),(0,n.jsxs)("select",{"aria-label":"按负责人筛选","aria-keyshortcuts":"A",value:w.assignee,onChange:e=>T({assignee:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部负责人"}),(0,n.jsx)("option",{value:"none",children:"未分配"}),b.map(e=>(0,n.jsx)("option",{value:e.id,children:e.displayName||e.name||e.id},e.id))]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(y.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"按里程碑筛选"}),(0,n.jsxs)("select",{"aria-label":"按里程碑筛选","aria-keyshortcuts":"M",value:w.milestone,onChange:e=>T({milestone:e.target.value}),className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",children:"全部里程碑"}),(0,n.jsx)("option",{value:"none",children:"无里程碑"}),w.milestone&&"none"!==w.milestone&&!f.some(e=>String(e.id)===w.milestone)&&(0,n.jsxs)("option",{value:w.milestone,children:["里程碑 #",w.milestone]}),f.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title,"closed"===e.state?"(已关闭)":""]},e.id))]})]}),(0,n.jsxs)("label",{className:"flex h-11 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground sm:h-8 sm:px-2",children:[(0,n.jsx)(tL.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,n.jsx)("span",{className:"sr-only",children:"排序 Issue"}),(0,n.jsxs)("select",{"aria-label":"排序 Issue",value:"".concat(w.sort,":").concat(w.direction),onChange:e=>{let[t,s]=e.target.value.split(":");T({sort:t,direction:s})},className:"h-full min-w-0 cursor-pointer bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"activity:desc",children:"最近活动"}),(0,n.jsx)("option",{value:"created:desc",children:"最新创建"}),(0,n.jsx)("option",{value:"created:asc",children:"最早创建"}),(0,n.jsx)("option",{value:"updated:desc",children:"最近更新"}),(0,n.jsx)("option",{value:"comments:desc",children:"评论最多"})]})]})]})]}),eW.length>0&&(0,n.jsxs)("div",{role:"region","aria-label":"已应用筛选",className:"flex min-w-0 flex-wrap items-center gap-1.5 border-b bg-muted/10 px-4 py-2 sm:px-5",children:[eW.map(e=>(0,n.jsxs)("button",{type:"button","aria-label":"移除".concat(e.kind,"筛选 ").concat(e.value),onClick:()=>{var t;T("subscribed"===(t=e.key)?{subscribed:!1}:"mentioned"===t?{mentioned:!1}:{[t]:""}),window.requestAnimationFrame(()=>{var e;return null==I||null==(e=I.current)?void 0:e.focus()})},className:"inline-flex h-11 max-w-full min-w-0 shrink-0 items-center gap-1.5 rounded-md border bg-background px-3 text-xs text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-7 sm:px-2",children:[(0,n.jsxs)("span",{className:"truncate",children:[(0,n.jsxs)("strong",{className:"font-medium text-foreground",children:[e.kind,":"]})," ",e.value]}),(0,n.jsx)(N.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"})]},e.key)),(0,n.jsx)("button",{type:"button",onClick:e0,"aria-label":"清除全部筛选",className:"h-11 shrink-0 rounded px-3 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-7 sm:px-2",children:"清除全部"})]}),eK&&(0,n.jsxs)("section",{"data-localapp-pinned-issues":!0,"aria-labelledby":"localapp-pinned-issues-title",className:"border-b bg-muted/10 px-4 py-3 sm:px-5",children:[(0,n.jsxs)("h3",{id:"localapp-pinned-issues-title",className:"mb-2 flex items-center gap-1.5 text-xs font-semibold text-muted-foreground",children:[(0,n.jsx)(tR.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"置顶 Issues"]}),(0,n.jsx)("div",{className:"grid min-w-0 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:p.map(e=>{var t,s,a;return(0,n.jsxs)("article",{className:"min-w-0 rounded-[6px] border bg-card px-3 py-3",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,n.jsx)(tG,{issue:e,className:"mt-1 h-4 w-4 shrink-0"}),(0,n.jsx)("a",{href:_(e),"aria-label":"#".concat(e.issue_number," ").concat(e.title),onClick:t=>e2(t,e),className:"min-h-6 min-w-0 flex-1 break-words font-semibold leading-6 hover:text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:e.title})]}),(0,n.jsxs)("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[(0,n.jsxs)("span",{children:["#",e.issue_number]}),(0,n.jsx)("button",{type:"button",onClick:()=>{var t;return T({issueType:null!=(t=e.issue_type)?t:e.label,offset:0})},className:"rounded border px-1.5 py-0.5 font-medium text-foreground hover:bg-muted",children:ei[null!=(s=e.issue_type)?s:e.label]}),null==(t=e.labels)?void 0:t.map(e=>(0,n.jsx)(tF,{label:e},e.id)),!!e.is_duplicate&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,n.jsx)(S.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"重复"]}),!!e.is_blocked&&(0,n.jsxs)("span",{"aria-label":"已阻塞:存在未解决依赖",title:"已阻塞:存在未解决依赖",className:"inline-flex items-center gap-1 text-destructive",children:[(0,n.jsx)(tD.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"已阻塞"]}),(null!=(a=e.comment_count)?a:0)>0&&(0,n.jsxs)("span",{children:[e.comment_count," 条评论"]}),(0,n.jsx)(tY,{issue:e})]})]},e.id)})})]}),(0,n.jsxs)("div",{className:"flex min-h-11 flex-wrap items-center justify-between gap-x-3 gap-y-1 border-b px-4 py-2 sm:px-5",children:[(0,n.jsxs)("div",{className:"inline-flex min-w-0 items-center gap-1",children:[q&&(0,n.jsx)("label",{className:"-my-2 -ml-2 inline-flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded focus-within:ring-2 focus-within:ring-ring sm:-my-0 sm:-ml-1 sm:h-6 sm:w-6",children:(0,n.jsx)("input",{ref:eC,type:"checkbox","aria-label":"选择当前页全部 Issue",checked:eQ,disabled:g||ed||0===m.length,onChange:e=>{var t;return t=e.target.checked,void(eE.current=null,ec(t?new Set(m.map(e=>e.id)):new Set))},className:"h-4 w-4"})}),(0,n.jsxs)("button",{type:"button","aria-label":"开启 ".concat(v.open),"aria-pressed":"open"===w.status,onClick:()=>e1("open"),className:"inline-flex h-11 items-center gap-1.5 rounded px-3 text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8 sm:px-2 ".concat("open"===w.status?"text-foreground":"text-muted-foreground"),children:[(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"}),"开启 ",v.open]}),(0,n.jsxs)("button",{type:"button","aria-label":"已关闭 ".concat(v.closed),"aria-pressed":"closed"===w.status,onClick:()=>e1("closed"),className:"inline-flex h-11 items-center gap-1.5 rounded px-3 text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8 sm:px-2 ".concat("closed"===w.status?"text-foreground":"text-muted-foreground"),children:[(0,n.jsx)(M.A,{className:"h-4 w-4","aria-hidden":"true"}),"已关闭 ",v.closed]})]}),(0,n.jsx)("span",{role:"status","aria-live":"polite",className:"inline-flex min-h-5 items-center gap-1.5 text-sm text-muted-foreground",children:eV?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(A.A,{className:"h-3.5 w-3.5 motion-safe:animate-spin","aria-hidden":"true"}),"正在更新结果"]}):"".concat(v.total," 个结果")})]}),q&&(0,n.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true","aria-label":"Issue 选择状态",className:"sr-only",children:eX>0?"已选择 ".concat(eX," 条 Issue"):"未选择 Issue"}),q&&eX>0&&(0,n.jsxs)("div",{"data-localapp-issue-bulk-toolbar":!0,role:"toolbar","aria-label":"批量 Issue 操作",onFocusCapture:()=>{eT.current=!0},onBlurCapture:e=>{let t=e.currentTarget;window.requestAnimationFrame(()=>{t.isConnected&&!t.contains(document.activeElement)&&(eT.current=!1)})},className:"flex min-h-11 flex-wrap items-center gap-2 border-b bg-muted/30 px-4 py-2 sm:px-5",children:[(0,n.jsxs)("strong",{className:"mr-auto text-sm",children:["已选择 ",eX," 条"]}),(0,n.jsxs)("label",{className:"inline-flex h-11 items-center rounded-md border bg-background px-2 text-xs sm:h-7",children:[(0,n.jsx)("span",{className:"sr-only",children:"批量类型操作"}),(0,n.jsxs)("select",{"aria-label":"批量类型操作",value:eh,disabled:ed,onChange:e=>{let t=e.target.value;ef(t),e5(t)},className:"h-full bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",disabled:!0,children:"类型"}),(0,n.jsx)("option",{value:"task",children:"任务"}),(0,n.jsx)("option",{value:"bug",children:"缺陷"}),(0,n.jsx)("option",{value:"feature",children:"功能"})]})]}),(0,n.jsxs)("label",{className:"inline-flex h-11 items-center rounded-md border bg-background px-2 text-xs sm:h-7",children:[(0,n.jsx)("span",{className:"sr-only",children:"批量标签操作"}),(0,n.jsxs)("select",{"aria-label":"批量标签操作",value:ex,disabled:ed,onChange:e=>{let t=e.target.value;eb(t),e8(t)},className:"h-full bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",disabled:!0,children:"标签"}),(0,n.jsx)("optgroup",{label:"添加标签",children:h.map(e=>(0,n.jsxs)("option",{value:"add:".concat(e.id),children:["添加:",e.name]},"add-".concat(e.id)))}),(0,n.jsx)("optgroup",{label:"移除标签",children:h.map(e=>(0,n.jsxs)("option",{value:"remove:".concat(e.id),children:["移除:",e.name]},"remove-".concat(e.id)))})]})]}),(0,n.jsxs)("label",{className:"inline-flex h-11 items-center rounded-md border bg-background px-2 text-xs sm:h-7",children:[(0,n.jsx)("span",{className:"sr-only",children:"批量负责人操作"}),(0,n.jsxs)("select",{"aria-label":"批量负责人操作",value:eg,disabled:ed,onChange:e=>{let t=e.target.value;ev(t),e6(t)},className:"h-full bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",disabled:!0,children:"负责人"}),(0,n.jsx)("optgroup",{label:"添加负责人",children:b.map(e=>(0,n.jsxs)("option",{value:"add:".concat(e.id),children:["添加:",e.displayName||e.name||e.id]},"add-".concat(e.id)))}),(0,n.jsx)("optgroup",{label:"移除负责人",children:b.map(e=>(0,n.jsxs)("option",{value:"remove:".concat(e.id),children:["移除:",e.displayName||e.name||e.id]},"remove-".concat(e.id)))})]})]}),(0,n.jsxs)("label",{className:"inline-flex h-11 items-center rounded-md border bg-background px-2 text-xs sm:h-7",children:[(0,n.jsx)("span",{className:"sr-only",children:"批量里程碑操作"}),(0,n.jsxs)("select",{"aria-label":"批量里程碑操作",value:ey,disabled:ed,onChange:e=>{let t=e.target.value;ew(t),e7(t)},className:"h-full bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"",disabled:!0,children:"里程碑"}),(0,n.jsx)("option",{value:"none",children:"清除里程碑"}),f.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title,"closed"===e.state?"(已关闭)":""]},e.id))]})]}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-7",disabled:ed,onClick:()=>void e3("open"===w.status?"closed":"open"),children:"open"===w.status?"关闭所选":"重新打开所选"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-7",disabled:ed,onClick:()=>{eE.current=null,ec(new Set),ep(""),window.requestAnimationFrame(()=>{var e;return null==(e=eC.current)?void 0:e.focus()})},children:"清除选择"})]}),(0,n.jsx)("span",{"aria-live":"polite",className:"sr-only",children:ed?"正在更新 ".concat(eX," 条 Issue"):em}),em&&(0,n.jsx)("div",{role:eX>0?"alert":"status",className:"border-b bg-muted/20 px-4 py-2 text-xs text-muted-foreground sm:px-5",children:em}),u&&m.length>0&&(0,n.jsxs)("div",{role:"alert",className:"flex items-center justify-between gap-3 border-b border-destructive/20 bg-destructive/10 px-4 py-2.5 text-sm text-destructive sm:px-5",children:[(0,n.jsxs)("span",{children:["显示上次结果:",u]}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-7",onClick:R,children:"重试"})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","aria-busy":g,children:g&&0===m.length?(0,n.jsxs)("div",{"aria-label":"正在加载 Issue",role:"status",className:"space-y-0",children:[(0,n.jsx)("span",{className:"sr-only",children:"正在加载 Issue 列表"}),Array.from({length:6},(e,t)=>(0,n.jsxs)("div",{className:"flex h-[76px] items-start gap-3 border-b px-4 py-3 motion-safe:animate-pulse sm:px-5",children:[(0,n.jsx)("span",{className:"mt-1 h-4 w-4 rounded-full bg-muted"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block h-4 w-2/3 rounded bg-muted"}),(0,n.jsx)("span",{className:"mt-3 block h-3 w-1/2 rounded bg-muted/70"})]}),(0,n.jsx)("span",{className:"h-4 w-8 rounded bg-muted/70"})]},t))]}):u&&0===m.length?(0,n.jsxs)("div",{role:"alert",className:"flex min-h-[280px] flex-col items-center justify-center px-6 text-center",children:[(0,n.jsx)(tD.A,{className:"h-9 w-9 text-destructive","aria-hidden":"true"}),(0,n.jsx)("p",{className:"mt-3 text-sm font-semibold",children:"无法加载 Issues"}),(0,n.jsx)("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:u}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"mt-4 h-11 sm:h-8",onClick:R,children:"重试"})]}):0===m.length?(0,n.jsxs)("div",{className:"flex min-h-[260px] flex-col items-center justify-center px-6 text-center",children:[(0,n.jsx)(tZ,{status:w.status,className:"h-8 w-8"}),(0,n.jsx)("p",{className:"mt-3 text-sm font-medium",children:eJ?"当前页已无 Issue":eO?"当前筛选没有匹配的 Issue":"此应用还没有".concat("open"===w.status?"开启":"已关闭","的 Issue")}),eJ?(0,n.jsx)(x.$,{ref:eU,type:"button",variant:"outline",size:"sm",className:"mt-4 h-11 sm:h-8",onClick:()=>T({offset:0}),children:"返回第一页"}):eO&&(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"mt-4 h-11 sm:h-8",onClick:e0,children:"重置筛选"})]}):(0,n.jsx)("div",{ref:eq,id:"localapp-issue-results",role:"list","aria-label":"".concat("open"===w.status?"开启":"已关闭","的 Issues"),"aria-busy":eV,"data-stale":eV?"true":void 0,children:m.map((e,t)=>{var s,a,l,r,i;return(0,n.jsxs)("article",{"data-localapp-issue-row":!0,"data-testid":"issue-row-".concat(e.id),role:"listitem","aria-posinset":v.offset+t+1,"aria-setsize":v.total,className:"flex min-w-0 gap-3 border-b px-4 py-3 last:border-b-0 hover:bg-muted/25 focus-within:bg-muted/25 sm:px-5",children:[q&&(0,n.jsx)("label",{className:"-my-2 -ml-2 inline-flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded focus-within:ring-2 focus-within:ring-ring sm:-my-0 sm:-ml-1 sm:h-6 sm:w-6",children:(0,n.jsx)("input",{type:"checkbox","aria-label":"选择 Issue #".concat(e.issue_number),checked:eo.has(e.id),disabled:ed,readOnly:!0,onFocus:()=>{e_.current=e.id},onBlur:e=>{e.currentTarget.isConnected&&(e_.current=null)},onKeyDown:t=>{" "===t.key&&(t.preventDefault(),e4(e.id,!eo.has(e.id),!1))},onClick:t=>e4(e.id,t.currentTarget.checked,t.shiftKey&&t.detail>0),className:"h-4 w-4"})}),(0,n.jsx)(tG,{issue:e,className:"mt-1 h-4 w-4 shrink-0"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("a",{href:_(e),"data-localapp-issue-link":!0,"aria-label":"#".concat(e.issue_number," ").concat(e.title),"aria-keyshortcuts":"J K ArrowDown ArrowUp O Enter",onClick:t=>e2(t,e),className:"flex min-h-11 max-w-full items-center rounded-sm break-words text-left text-base font-semibold leading-6 text-foreground hover:text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:min-h-6",children:e.title}),(0,n.jsxs)("div",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-sm leading-5 text-muted-foreground",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{var t;return T({issueType:null!=(t=e.issue_type)?t:e.label,offset:0})},className:"rounded border px-1.5 py-0.5 text-xs font-medium text-foreground hover:bg-muted",children:ei[null!=(a=e.issue_type)?a:e.label]}),(null!=(l=e.labels)?l:[]).map(e=>(0,n.jsx)(tF,{label:e,onSelect:e=>T({label:e,offset:0})},e.id)),!!e.is_duplicate&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,n.jsx)(S.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"重复"]}),e.locked_at&&(0,n.jsx)("span",{"aria-label":"对话已锁定",title:"对话已锁定",className:"inline-flex items-center",children:(0,n.jsx)(tz.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),!!e.is_blocked&&(0,n.jsxs)("span",{"aria-label":"已阻塞:存在未解决依赖",title:"已阻塞:存在未解决依赖",className:"inline-flex items-center gap-1 text-destructive",children:[(0,n.jsx)(tD.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"已阻塞"]}),(0,n.jsx)(t1,{milestone:f.find(t=>t.id===e.milestone_id),onSelect:e=>T({milestone:String(e),offset:0})}),(0,n.jsxs)("span",{children:["#",e.issue_number]}),(0,n.jsx)("button",{type:"button","aria-label":"按创建者筛选 ".concat(eH(e.reporter_id)),title:"".concat(eH(e.reporter_id)," @").concat(e.reporter_id),onClick:()=>T({author:e.reporter_id,offset:0}),className:"min-h-6 max-w-full rounded-sm break-words text-left hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:eH(e.reporter_id)}),(0,n.jsx)(tY,{issue:e}),(null==(s=e.participant_ids)?void 0:s.length)?(0,n.jsxs)("span",{className:"hidden sm:inline",children:[e.participant_ids.length," 位参与者"]}):null]})]}),(0,n.jsx)(t0,{ids:null!=(r=e.assignee_ids)?r:[],users:b,onSelect:e=>T({assignee:e,offset:0})}),(null!=(i=e.comment_count)?i:0)>0?(0,n.jsxs)("a",{href:_(e),"aria-label":"".concat(e.issue_number," 的评论数 ").concat(e.comment_count),onClick:t=>e2(t,e),className:"-my-2 inline-flex h-11 w-11 shrink-0 items-center justify-center gap-1 rounded-sm text-sm leading-5 text-muted-foreground hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:-my-0 sm:h-6 sm:w-10",children:[(0,n.jsx)(k.A,{className:"h-4 w-4","aria-hidden":"true"}),e.comment_count]}):(0,n.jsx)("span",{"aria-hidden":"true",className:"h-11 w-11 shrink-0 sm:h-6 sm:w-10"})]},e.id)})})}),(0,n.jsxs)("div",{className:"flex min-h-11 items-center justify-between border-t px-4 text-xs text-muted-foreground sm:px-5",children:[(0,n.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true","aria-label":0===m.length?"当前没有可显示的 Issue,共 ".concat(v.total," 条 Issue"):"当前显示第 ".concat(v.offset+1," 至 ").concat(Math.min(v.offset+m.length,v.total)," 条,共 ").concat(v.total," 条 Issue"),children:0===m.length?"0 / ".concat(v.total):"".concat(v.offset+1,"-").concat(Math.min(v.offset+m.length,v.total)," / ").concat(v.total)}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"上一页","aria-controls":"localapp-issue-results",disabled:0===w.offset,onClick:()=>eB(Math.max(0,w.offset-w.limit)),children:(0,n.jsx)(tq.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"下一页","aria-controls":"localapp-issue-results",disabled:w.offset+w.limit>=v.total,onClick:()=>eB(w.offset+w.limit),children:(0,n.jsx)(tU.A,{className:"h-4 w-4"})})]})]})]})]})}var t4=s(7528),t3=s(507),t5=s(760),t8=s(289);function t6(e,t){var s,n;let a=new Map(t.map(e=>[e.id,e])).get(e);return a?{...a,displayName:(null==(s=a.displayName)?void 0:s.trim())||(null==(n=a.name)?void 0:n.trim())||a.id||"未知用户",avatarUrl:a.avatarUrl||null}:{id:e,displayName:e||"未知用户",avatarUrl:null}}function t7(e){var t,s;let{identity:a,timestamp:r,timestampHref:i,timestampSuffix:o,badge:c,action:d}=e,u=(null==(t=a.displayName)?void 0:t.trim())||(null==(s=a.name)?void 0:s.trim())||a.id||"未知用户",m="Author"===c?"作者":c,p=(0,l.isValidElement)(o)&&"edited"===o.props.children?(0,l.cloneElement)(o,{children:"已编辑"}):o;return(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[a.avatarUrl?(0,n.jsx)("img",{src:a.avatarUrl,alt:"",className:"h-8 w-8 shrink-0 rounded-full object-cover"}):(0,n.jsx)("span",{"aria-hidden":"true",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground",children:function(e){var t,s;if(!e.id.trim())return"?";let n=(null==(t=e.displayName)?void 0:t.trim())||(null==(s=e.name)?void 0:s.trim())||e.id.trim();return n?Array.from(n)[0].toLocaleUpperCase():"?"}(a)}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 text-xs leading-5",children:[(0,n.jsxs)("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2",children:[(0,n.jsx)("strong",{className:"break-words text-sm font-semibold text-foreground",children:u}),(0,n.jsxs)("span",{className:"break-all text-muted-foreground",children:["@",a.id||"未知"]}),m&&(0,n.jsx)("span",{className:"shrink-0 rounded-full border px-1.5 text-[10px] font-medium leading-4 text-muted-foreground",children:m})]}),r&&(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-1.5",children:[(0,n.jsx)(tB,{timestamp:r,href:i,className:"text-muted-foreground hover:underline"}),p]})]}),d&&(0,n.jsx)("div",{"data-localapp-issue-actor-action":!0,className:"shrink-0 self-start",children:d})]})}function t9(e){let{label:t,accessibleLabel:s,items:a,selectedIds:r,disabled:i=!1,onToggle:o}=e,[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(""),[p,h]=(0,l.useState)(null),[f,b]=(0,l.useState)(null),g=(0,l.useRef)(null),v=(0,l.useRef)(null),y=(0,l.useRef)(null),w=(0,l.useRef)([]),j=(0,l.useId)(),N=null!=s?s:"Labels"===t?"标签":"Assignees"===t?"负责人":t,k="编辑".concat(N),S="选择".concat(N),A="搜索".concat(N),C=(0,l.useMemo)(()=>new Set(r),[r]),E=(0,l.useMemo)(()=>{let e=u.trim().toLocaleLowerCase();return e?a.filter(t=>{var s;return"".concat(t.label,"\n").concat(t.id,"\n").concat(null!=(s=t.description)?s:"").toLocaleLowerCase().includes(e)}):a},[a,u]);(0,l.useEffect)(()=>{if(!c)return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=y.current)?void 0:e.focus()}),t=e=>{var t;(null==(t=g.current)?void 0:t.contains(e.target))||d(!1)};return document.addEventListener("mousedown",t),()=>{window.cancelAnimationFrame(e),document.removeEventListener("mousedown",t)}},[c]);let _=async e=>{if(!p&&!i){b(null),h(e.id);try{await o(e.id,!C.has(e.id))}catch(e){b(e instanceof Error?e.message:"".concat(N,"更新失败"))}finally{h(null)}}};return(0,n.jsxs)("div",{ref:g,className:"relative",children:[(0,n.jsx)(x.$,{ref:v,type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-7 sm:w-7","aria-label":k,title:k,"aria-haspopup":"dialog","aria-expanded":c,"aria-controls":c?j:void 0,disabled:i,onClick:()=>{d(e=>!e),m(""),b(null)},children:(0,n.jsx)(td.A,{className:"h-3.5 w-3.5"})}),c&&(0,n.jsxs)("div",{id:j,role:"dialog","aria-label":S,onKeyDown:e=>{var t;if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),d(!1),m(""),b(null),window.requestAnimationFrame(()=>{var e;return null==(e=v.current)?void 0:e.focus()});return}if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key)||0===E.length)return;let s=w.current.findIndex(e=>e===document.activeElement),n=s;n="Home"===e.key?0:"End"===e.key?E.length-1:"ArrowDown"===e.key?s<0?0:(s+1)%E.length:s<0?E.length-1:(s-1+E.length)%E.length,e.preventDefault(),null==(t=w.current[n])||t.focus()},className:"absolute right-0 top-12 z-40 w-[min(320px,calc(100vw-2rem))] overflow-hidden rounded-[6px] border bg-popover text-popover-foreground shadow-lg sm:top-8",children:[(0,n.jsxs)("div",{className:"relative border-b p-2",children:[(0,n.jsx)(tE.A,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)("input",{ref:y,type:"search",role:"searchbox","aria-label":A,value:u,onChange:e=>m(e.target.value),className:"h-11 w-full rounded border bg-background pl-8 pr-2 text-sm outline-none focus:ring-2 focus:ring-ring sm:h-8"})]}),f&&(0,n.jsx)("div",{role:"alert",className:"mx-2 mt-2 rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:f}),(0,n.jsx)("div",{className:"max-h-64 overflow-y-auto p-1",children:0===E.length?(0,n.jsx)("p",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:"没有匹配项"}):E.map((e,t)=>(0,n.jsxs)("label",{className:"flex min-h-11 cursor-pointer items-center gap-2 rounded px-2 py-1.5 hover:bg-muted focus-within:bg-muted focus-within:ring-2 focus-within:ring-ring",children:[(0,n.jsx)("input",{ref:e=>{w.current[t]=e},type:"checkbox",className:"sr-only","aria-label":e.label,checked:C.has(e.id),disabled:i||null!==p,onChange:()=>void _(e)}),(0,n.jsx)("span",{"aria-hidden":"true",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",children:C.has(e.id)&&(0,n.jsx)(I.A,{className:"h-3 w-3"})}),e.leading,(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block truncate text-sm font-medium",children:e.label}),(0,n.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description||e.id})]})]},e.id))})]})]})}var se=s(2914),st=s(535),ss=s(8210);let sn={"+1":"\uD83D\uDC4D","-1":"\uD83D\uDC4E",laugh:"\uD83D\uDE04",hooray:"\uD83C\uDF89",confused:"\uD83D\uDE15",heart:"❤️",rocket:"\uD83D\uDE80",eyes:"\uD83D\uDC40"};function sa(e){let{reactions:t,commentId:s=0,currentUserId:a,disabled:r=!1,additionsDisabled:i=!1,onToggle:o}=e,[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),[p,h]=(0,l.useState)(""),f=(0,l.useRef)(null),b=(0,l.useRef)(null),g=(0,l.useRef)([]),v=t.filter(e=>e.comment_id===s),y=ed.map(e=>({content:e,entries:v.filter(t=>t.content===e)})).filter(e=>e.entries.length>0),w=async(e,t)=>{m(e),h("");try{await o(e,t,0===s?void 0:s),j(!0)}catch(e){h(e instanceof Error?e.message:"表态更新失败")}finally{m(null)}},j=e=>{d(!1),h(""),e&&window.requestAnimationFrame(()=>{var e;return null==(e=b.current)?void 0:e.focus()})};return((0,l.useEffect)(()=>{(i||!a)&&d(!1),(i||!a)&&h("")},[i,a]),(0,l.useEffect)(()=>{if(!c)return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=g.current[0])?void 0:e.focus()}),t=e=>{var t;e.target instanceof Node&&!(null==(t=f.current)?void 0:t.contains(e.target))&&j(!0)};return document.addEventListener("mousedown",t),()=>{window.cancelAnimationFrame(e),document.removeEventListener("mousedown",t)}},[c]),a||0!==y.length)?(0,n.jsxs)("div",{ref:f,className:"relative mt-3 flex flex-wrap items-center gap-1.5","data-localapp-issue-reactions":!0,children:[p&&(0,n.jsx)("p",{role:"alert",className:"w-full text-xs text-destructive",children:p}),y.map(e=>{let{content:t,entries:s}=e,l=!!(a&&s.some(e=>e.user_id===a)),o="".concat(sn[t]," ").concat(s.length," 个表态");return a?(0,n.jsxs)(x.$,{type:"button",variant:l?"secondary":"outline",size:"sm",className:"h-11 min-w-11 gap-1 rounded-full px-3 text-xs sm:h-7 sm:min-w-10 sm:px-2.5","aria-label":o,"aria-pressed":l,disabled:r||null!==u||i&&!l,onClick:()=>void w(t,!l),children:[(0,n.jsx)("span",{"aria-hidden":"true",children:sn[t]}),(0,n.jsx)("span",{children:s.length})]},t):(0,n.jsxs)("span",{"aria-label":o,className:"inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-full border px-3 text-xs sm:h-7 sm:min-w-10 sm:px-2.5",children:[(0,n.jsx)("span",{"aria-hidden":"true",children:sn[t]}),(0,n.jsx)("span",{children:s.length})]},t)}),a&&!i&&(0,n.jsx)(x.$,{ref:b,type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 rounded-full sm:h-7 sm:w-7","aria-label":"添加表态","aria-haspopup":"menu","aria-expanded":c,disabled:r||null!==u,onClick:()=>d(e=>!e),children:(0,n.jsx)(ss.A,{className:"h-4 w-4"})}),c&&a&&!i&&(0,n.jsx)("div",{className:"absolute bottom-12 left-0 z-20 grid grid-cols-4 gap-1 rounded-md border bg-popover p-1.5 shadow-lg sm:bottom-9",role:"menu","aria-label":"选择表态",onKeyDown:e=>{var t;if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),j(!0);return}if(!["ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(e.key))return;let s=g.current.filter(e=>!!(e&&!e.disabled));if(!s.length)return;let n=Math.max(0,s.indexOf(document.activeElement)),a="ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:"ArrowDown"===e.key?4:"ArrowUp"===e.key?-4:0,l="Home"===e.key?0:"End"===e.key?s.length-1:(n+a+s.length)%s.length;e.preventDefault(),e.stopPropagation(),null==(t=s[l])||t.focus()},children:ed.map((e,t)=>{let s=v.some(t=>t.content===e&&t.user_id===a);return(0,n.jsx)("button",{ref:e=>{g.current[t]=e},type:"button",role:"menuitemcheckbox","aria-checked":s,"aria-label":"".concat(s?"取消":"添加"," ").concat(sn[e]," 表态"),disabled:r||null!==u,className:"flex h-11 w-11 items-center justify-center rounded outline-none hover:bg-muted focus:bg-muted focus:ring-2 focus:ring-ring sm:h-8 sm:w-8 ".concat(s?"bg-muted":""),onClick:()=>void w(e,!s),children:sn[e]},e)})})]}):null}let sl="localappIssueId",sr="localappIssueNumber",si="localappIssueCommentId",so="localappIssues";function sc(e,t){let s=e.searchParams.get(t);if(!s||!/^\d+$/.test(s))return null;let n=Number(s);return Number.isSafeInteger(n)&&n>0?n:null}function sd(e){return"1"===e.searchParams.get(so)||null!==sc(e,sl)||null!==sc(e,sr)}function su(e,t){let s=new URL(e.href);return t?s.searchParams.set(so,"1"):(s.searchParams.delete(so),s.searchParams.delete(sl),s.searchParams.delete(sr),s.searchParams.delete(si)),s}function sm(e,t){let s=new URL(e.href);return s.searchParams.set(so,"1"),null===t?s.searchParams.delete(sl):s.searchParams.set(sl,String(t)),s.searchParams.delete(sr),s.searchParams.delete(si),s}function sp(e,t){let s=new URL(e.href);return s.searchParams.set(so,"1"),s.searchParams.delete(sl),s.searchParams.set(sr,String(t)),s.searchParams.delete(si),s}function sh(e,t,s){let n=new URL(e.href);return n.searchParams.set(so,"1"),n.searchParams.set(sl,String(t)),n.searchParams.delete(sr),n.searchParams.set(si,String(s)),n}async function sf(e){var t;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;if(!(()=>{let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let s="function"==typeof document.execCommand&&document.execCommand("copy");return t.remove(),s})()){if(!(null==(t=navigator.clipboard)?void 0:t.writeText))throw Error("Clipboard write failed");await Promise.race([navigator.clipboard.writeText(e),new Promise((e,t)=>window.setTimeout(()=>t(Error("Clipboard write timed out")),s))])}}function sx(e,t){let s=function(e){if(!e.includes("/api/issues/attachments/"))return new Set;let t=(0,X.l)().use(Q.A).use(W.A).parse(e),s=new Set,n=e=>{var t;if(("image"===e.type||"link"===e.type)&&"string"==typeof e.url){let t=function(e){try{let t=new URL(e,"https://localapp.local"),s=/^\/api\/issues\/attachments\/([^/]+)$/.exec(t.pathname);return s?decodeURIComponent(s[1]):null}catch(e){return null}}(e.url);t&&s.add(t)}for(let s of null!=(t=e.children)?t:[])n(s)};return n(t),s}(e);return 0===s.size?[...t]:t.filter(e=>!s.has(e.id))}var sb=s(5230);function sg(e){let{reference:t,actorName:s,href:a,onOpen:l}=e,r="来源 Issue #".concat(t.source_issue_number," ").concat(t.source_issue_title).concat(null===t.source_comment_id?"":",评论 ".concat(t.source_comment_id));return(0,n.jsx)("li",{"data-localapp-issue-cross-reference":!0,className:"relative min-w-0 py-2 pl-3 text-xs text-muted-foreground before:absolute before:bottom-0 before:left-[19px] before:top-0 before:w-px before:bg-border",children:(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,n.jsx)("span",{className:"relative z-10 mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-card",children:(0,n.jsx)(sb.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("p",{className:"break-words",children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:s})," 在 ",(0,n.jsxs)("a",{href:a,"aria-label":r,className:"font-semibold text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:e=>{!l||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),l(t.source_issue_number,t.source_comment_id))},children:["#",t.source_issue_number," ",t.source_issue_title]})," 中提到了此 Issue ",(0,n.jsx)(tB,{timestamp:t.created_at})]}),t.excerpt&&(0,n.jsx)("p",{className:"mt-1 line-clamp-2 break-words border-l-2 pl-2 text-muted-foreground",children:t.excerpt})]})]})})}function sv(e,t){try{let s=JSON.parse(e)[t];return"number"==typeof s&&Number.isSafeInteger(s)?s:null}catch(e){return null}}function sy(e,t){var s,n,a,l,r,i,o,c,d,u,m,p;let h=e.event;if("opened"===h.event_type)return"打开了此 Issue";if("closed"===h.event_type)try{return(null==(s=JSON.parse(h.payload_json))?void 0:s.stateReason)==="not_planned"?"以不计划处理关闭了此 Issue":"以已完成关闭了此 Issue"}catch(e){return"以已完成关闭了此 Issue"}if("reopened"===h.event_type)return"重新打开了此 Issue";if("edited"===h.event_type)return"编辑了此 Issue";if("labels_changed"===h.event_type)return"更新了标签";if("assignees_changed"===h.event_type){let{added:e,removed:s}=function(e){try{let t=JSON.parse(e),s=Array.isArray(t.from)?t.from.filter(e=>"string"==typeof e).slice(0,20):[],n=Array.isArray(t.to)?t.to.filter(e=>"string"==typeof e).slice(0,20):[];return{added:n.filter(e=>!s.includes(e)),removed:s.filter(e=>!n.includes(e))}}catch(e){return{added:[],removed:[]}}}(h.payload_json);return 1===e.length&&0===s.length?"将 ".concat(t6(e[0],t).displayName," 设为负责人"):1===s.length&&0===e.length?"取消了 ".concat(t6(s[0],t).displayName," 的负责人"):"更新了负责人"}if("subscribed"===h.event_type)return"订阅了此 Issue";if("unsubscribed"===h.event_type)return"取消订阅了此 Issue";if("locked"===h.event_type)try{let e=null==(n=JSON.parse(h.payload_json))?void 0:n.reason;return e&&eo[e]?"锁定了对话(".concat(eo[e],")"):"锁定了对话"}catch(e){return"锁定了对话"}return"unlocked"===h.event_type?"解锁了对话":"pinned"===h.event_type?"置顶了此 Issue":"unpinned"===h.event_type?"取消置顶了此 Issue":"comment_pinned"===h.event_type?"置顶了评论 #".concat(null!=(a=sv(h.payload_json,"commentId"))?a:"?"):"comment_unpinned"===h.event_type?"取消置顶了评论 #".concat(null!=(l=sv(h.payload_json,"commentId"))?l:"?"):"comment_minimized"===h.event_type?"最小化了评论 #".concat(null!=(r=sv(h.payload_json,"commentId"))?r:"?"):"comment_unminimized"===h.event_type?"恢复了评论 #".concat(null!=(i=sv(h.payload_json,"commentId"))?i:"?"):"sub_issue_added"===h.event_type?"添加了 Sub-issue #".concat(null!=(o=sv(h.payload_json,"childIssueNumber"))?o:"?"):"sub_issue_removed"===h.event_type?"移除了 Sub-issue #".concat(null!=(c=sv(h.payload_json,"childIssueNumber"))?c:"?"):"parent_added"===h.event_type?"设置了父 Issue #".concat(null!=(d=sv(h.payload_json,"parentIssueNumber"))?d:"?"):"parent_removed"===h.event_type?"移除了父 Issue #".concat(null!=(u=sv(h.payload_json,"parentIssueNumber"))?u:"?"):"marked_as_duplicate"===h.event_type?"将此 Issue 标记为 #".concat(null!=(m=sv(h.payload_json,"canonicalIssueNumber"))?m:"?"," 的重复项"):"unmarked_as_duplicate"===h.event_type?"撤销了与 #".concat(null!=(p=sv(h.payload_json,"canonicalIssueNumber"))?p:"?"," 的重复关系"):"更新了此 Issue"}function sw(e){let{type:t}=e;return"closed"===t?(0,n.jsx)(M.A,{className:"h-4 w-4","aria-hidden":"true"}):"reopened"===t?(0,n.jsx)(se.A,{className:"h-4 w-4","aria-hidden":"true"}):"labels_changed"===t?(0,n.jsx)(w.A,{className:"h-4 w-4","aria-hidden":"true"}):"assignees_changed"===t?(0,n.jsx)(tT.A,{className:"h-4 w-4","aria-hidden":"true"}):"subscribed"===t||"unsubscribed"===t?(0,n.jsx)(t3.A,{className:"h-4 w-4","aria-hidden":"true"}):"locked"===t?(0,n.jsx)(tz.A,{className:"h-4 w-4","aria-hidden":"true"}):"unlocked"===t?(0,n.jsx)(t8.A,{className:"h-4 w-4","aria-hidden":"true"}):"pinned"===t||"unpinned"===t||"comment_pinned"===t||"comment_unpinned"===t?(0,n.jsx)(tR.A,{className:"h-4 w-4","aria-hidden":"true"}):(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"})}function sj(e){let{pagePath:t,attachments:s,onRemove:a}=e;return s.length?(0,n.jsx)("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:s.map(e=>{let s=em(t,e.id);return(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-1",children:[eu(e.mime_type)?(0,n.jsx)("a",{href:s,target:"_blank",rel:"noreferrer","aria-label":"在新标签页打开附件 ".concat(e.file_name),className:"block min-w-0 flex-1 overflow-hidden rounded border",children:(0,n.jsx)("img",{src:s,alt:e.file_name,loading:"lazy",decoding:"async",className:"max-h-64 w-full object-contain"})}):(0,n.jsxs)("a",{href:s,target:"_blank",rel:"noreferrer","aria-label":"在新标签页打开附件 ".concat(e.file_name),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded border px-3 py-2 text-xs text-primary hover:underline",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.file_name}),(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground",children:ep(e.size_bytes)})]}),a&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"移除现有附件 ".concat(e.file_name),onClick:()=>a(e.id),children:(0,n.jsx)(K.A,{className:"h-4 w-4"})})]},e.id)})}):null}function sN(e){let{item:t,identities:s}=e,[a,r]=(0,l.useState)(!1),i=t6(t.actorId,s).displayName;return(0,n.jsxs)("li",{"data-localapp-issue-event-group":!0,className:"relative min-w-0 py-2 pl-3 text-xs text-muted-foreground before:absolute before:bottom-0 before:left-[19px] before:top-0 before:w-px before:bg-border",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{className:"relative z-10 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-card",children:(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("button",{type:"button","aria-expanded":a,"aria-controls":"".concat(t.key,"-events"),className:"flex min-w-0 items-center gap-1 rounded text-left hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>r(e=>!e),children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:i}),(0,n.jsxs)("span",{children:["编辑了此 Issue ",t.events.length," 次"]}),(0,n.jsx)(st.A,{className:"h-3.5 w-3.5 transition-transform motion-reduce:transition-none ".concat(a?"rotate-180":""),"aria-hidden":"true"})]})]}),a&&(0,n.jsx)("ol",{id:"".concat(t.key,"-events"),"aria-label":"".concat(i," 的编辑事件"),className:"ml-6 mt-2 space-y-1 border-l pl-3",children:t.events.map(e=>(0,n.jsx)("li",{children:(0,n.jsx)(tB,{timestamp:e.created_at,precise:!0})},e.id))})]})}function sk(e){let{item:t,identities:s}=e,[a,r]=(0,l.useState)(!1),i=t.actorId?t6(t.actorId,s).displayName:null;return(0,n.jsxs)("li",{"data-localapp-issue-history-group":!0,className:"relative min-w-0 py-2 pl-3 text-xs text-muted-foreground before:absolute before:bottom-0 before:left-[19px] before:top-0 before:w-px before:bg-border",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{className:"relative z-10 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-card",children:(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("button",{type:"button","aria-expanded":a,"aria-controls":"".concat(t.key,"-events"),className:"flex min-w-0 items-center gap-1 rounded text-left hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>r(e=>!e),children:[i&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:i}),(0,n.jsx)("span",{children:"进行了"})]}),(0,n.jsxs)("span",{children:[t.events.length," 项历史更新"]}),(0,n.jsx)(st.A,{className:"h-3.5 w-3.5 shrink-0 transition-transform motion-reduce:transition-none ".concat(a?"rotate-180":""),"aria-hidden":"true"})]})]}),a&&(0,n.jsx)("ol",{id:"".concat(t.key,"-events"),"aria-label":"历史更新明细,共 ".concat(t.events.length," 项"),className:"ml-6 mt-2 space-y-2 border-l pl-3",children:t.events.map(e=>(0,n.jsxs)("li",{className:"flex min-w-0 items-start gap-2",children:[(0,n.jsx)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center",children:(0,n.jsx)(sw,{type:e.event_type})}),(0,n.jsxs)("span",{className:"min-w-0 break-words",children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:t6(e.actor_id,s).displayName})," ",sy({kind:"event",event:e},s)," ",(0,n.jsx)(tB,{timestamp:e.created_at,precise:!0})]})]},e.id))})]})}function sI(e,t){let s=e.trim().split(/\r?\n/).map(e=>"> ".concat(e)).join("\n");return"".concat(s,"\n\n@").concat(t," ")}function sS(e){let{issueId:t,reporterId:s,pagePath:a,timeline:r,attachments:i,identities:o,currentUserId:c,reactions:d,commentDraftPrefix:u,onToggleReaction:m,onEditComment:p,onDeleteComment:h,onQuoteComment:f,onReferenceComment:b,selectedCommentId:g,getCommentHref:v,getIssueReferenceHref:y,onOpenIssueReference:w,onCopyCommentLink:j,onViewHistory:N,savingTaskTarget:k,onToggleCommentTask:I,interactionsLocked:S=!1,canManageCommentPins:A=!1,onToggleCommentPin:C,canManageCommentMinimization:E=!1,onToggleCommentMinimized:_}=e,T=(0,l.useRef)(null),L=(0,l.useRef)(null),[R,D]=(0,l.useState)(null),z=(0,l.useRef)(null),[q,U]=(0,l.useState)(null),[F,P]=(0,l.useState)(null),$=(0,l.useRef)(null),M=(0,l.useRef)(null),O=(0,l.useRef)(null),[K,B]=(0,l.useState)(""),[H,W]=(0,l.useState)(null),[V,X]=(0,l.useState)(null),[Q,Z]=(0,l.useState)(()=>new Set),[G,Y]=(0,l.useState)(null),[ee,et]=(0,l.useState)("off-topic"),[es,en]=(0,l.useState)(null),[el,er]=(0,l.useState)(!1),[ei,eo]=(0,l.useState)("all"),[ed,eu]=(0,l.useState)(20),em="all"===ei?[...r]:r.filter(e=>"comments"===ei?"comment"===e.kind:"comment"!==e.kind),ep=em.find(e=>"comment"===e.kind&&!!e.comment.pinned_at&&!e.comment.deleted_at);ep&&(em.splice(em.indexOf(ep),1),em.unshift(ep));let eh=function(e){let t=[];for(let s=0;s<e.length;){let n=e[s];if("event"!==n.kind){t.push(n),s+=1;continue}if("edited"!==n.event.event_type){let a=[n.event],l=s+1;for(;l<e.length;){let t=e[l];if("event"!==t.kind||"edited"===t.event.event_type)break;a.push(t.event),l+=1}if(a.length<4)t.push(...e.slice(s,l));else{let e=a.every(e=>e.actor_id===a[0].actor_id)?a[0].actor_id:null;t.push({kind:"event-group",groupType:"history",key:"history-".concat(a[0].id,"-").concat(a.at(-1).id),actorId:e,events:a})}s=l;continue}let a=[n.event],l=s+1;for(;l<e.length;){let t=e[l];if("event"!==t.kind||"edited"!==t.event.event_type||t.event.actor_id!==n.event.actor_id)break;a.push(t.event),l+=1}a.length<2?t.push(n):t.push({kind:"event-group",groupType:"edited",key:"edited-".concat(a[0].id,"-").concat(a.at(-1).id),actorId:n.event.actor_id,events:a}),s=l}return t}(em),ef=g?eh.findIndex(e=>"comment"===e.kind&&e.comment.id===g):-1,ex=Math.max(0,eh.length-ed),eb=ef>=0?Math.min(ex,ef):ex,eg=eh.slice(eb),ev={all:r.length,comments:r.filter(e=>"comment"===e.kind).length,history:r.filter(e=>"comment"!==e.kind).length},ey=[{value:"all",label:"全部"},{value:"comments",label:"评论"},{value:"history",label:"历史"}],ew=!!(g&&r.some(e=>"comment"===e.kind&&e.comment.id===g&&!e.comment.deleted_at)),ej=(e,t)=>u?"".concat(u,":").concat(e,":").concat(t):void 0,eN=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{["body","version"].forEach(t=>{let s=ej(e,t);s&&window.sessionStorage.removeItem(s)})}catch(e){}let s=ej(e,"body");t?ty(a,s):tg(s)};(0,l.useEffect)(()=>{eo("all"),eu(20),Z(new Set),Y(null)},[t]),(0,l.useEffect)(()=>{eu(20)},[ei]),(0,l.useEffect)(()=>{ew&&eo("comments")},[g,ew]),(0,l.useEffect)(()=>{var e;let t=z.current;if(z.current=null!=(e=null==R?void 0:R.id)?e:null,null===t||null!==R)return;let s=window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector('[data-testid="issue-comment-'.concat(t,'"]')))?void 0:e.focus()});return()=>window.cancelAnimationFrame(s)},[R]),(0,l.useEffect)(()=>{if(!R)return;let e=r.find(e=>"comment"===e.kind&&e.comment.id===R.id);(!e||e.comment.deleted_at)&&(D(null),B("评论已被删除,编辑已结束"))},[R,r]),(0,l.useEffect)(()=>{if(!ew||"comments"!==ei)return;let e=window.requestAnimationFrame(()=>{var e;let t=document.querySelector('[data-testid="issue-comment-'.concat(g,'"]:not([data-deleted="true"])'));t&&(null==(e=t.scrollIntoView)||e.call(t,{block:"center"}),t.focus({preventScroll:!0}))});return()=>window.cancelAnimationFrame(e)},[ei,g,ew,r]),(0,l.useEffect)(()=>{if(null===F)return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=M.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[F]),(0,l.useEffect)(()=>{if(null===F)return;let e=r.find(e=>"comment"===e.kind&&e.comment.id===F);(!e||e.comment.deleted_at)&&(P(null),window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector('[data-testid="issue-comment-'.concat(F,'"]')))?void 0:e.focus()}))},[F,r]);let ek=()=>{P(null),window.requestAnimationFrame(()=>{var e;return null==(e=$.current)?void 0:e.focus()})},eI=async e=>{U(e);try{await h(e),P(null),B("评论已删除");let t=function(e,t){let s=new URL(e.href);return(void 0===t||sc(s,si)===t)&&s.searchParams.delete(si),s}(new URL(window.location.href),e);t.href!==window.location.href&&window.history.replaceState(window.history.state,"",t),window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-testid="issue-comment-'.concat(e,'"]')))?void 0:t.focus()})}catch(e){}finally{U(null)}},eS=e=>{var t,s;if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),ek();return}"Tab"===e.key&&(e.shiftKey&&document.activeElement===M.current?(e.preventDefault(),null==(t=O.current)||t.focus()):e.shiftKey||document.activeElement!==O.current||(e.preventDefault(),null==(s=M.current)||s.focus()))};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true","aria-label":"时间线操作状态",className:"sr-only",children:K}),(0,n.jsxs)("div",{className:"mb-3 flex min-w-0 flex-col items-stretch gap-2 border-y py-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[(0,n.jsx)("span",{className:"shrink-0 whitespace-nowrap text-xs font-medium text-muted-foreground",children:"活动"}),(0,n.jsx)("div",{role:"radiogroup","aria-label":"筛选时间线活动",className:"grid w-full grid-cols-3 rounded-md border bg-muted/20 p-0.5 sm:w-auto",children:ey.map((e,t)=>(0,n.jsxs)("button",{type:"button",role:"radio","aria-checked":ei===e.value,tabIndex:ei===e.value?0:-1,onClick:()=>eo(e.value),onKeyDown:e=>{let s;if("Home"===e.key)s=0;else if("End"===e.key)s=ey.length-1;else if(["ArrowLeft","ArrowUp"].includes(e.key))s=(t-1+ey.length)%ey.length;else{if(!["ArrowRight","ArrowDown"].includes(e.key))return;s=(t+1)%ey.length}e.preventDefault();let n=ey[s];eo(n.value),window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector('[data-issue-activity-filter="'.concat(n.value,'"]')))?void 0:e.focus()})},"data-issue-activity-filter":e.value,className:"h-11 rounded px-2.5 text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-7 ".concat(ei===e.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.label," ",ev[e.value]]},e.value))})]}),0===eh.length?(0,n.jsx)("div",{role:"status",className:"rounded-md border border-dashed px-4 py-8 text-center text-sm text-muted-foreground",children:"comments"===ei?"还没有评论":"history"===ei?"还没有历史活动":"还没有活动"}):(0,n.jsxs)("ol",{ref:T,tabIndex:-1,"aria-label":"Issue 时间线",className:"space-y-3 outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[eb>0&&(0,n.jsx)("li",{className:"relative z-10 flex justify-center bg-background py-1",children:(0,n.jsxs)("button",{ref:L,type:"button","aria-label":"显示更早的 ".concat(eb," 条活动"),className:"h-11 rounded-md border px-3 text-xs font-medium text-muted-foreground hover:bg-muted/30 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-8",onClick:()=>{let e=eb<=20;eu(e=>e+20),window.requestAnimationFrame(()=>{var t,s;e?null==(t=T.current)||t.focus():null==(s=L.current)||s.focus()})},children:["显示更早活动 \xb7 ",eb]})}),eg.map(e=>{var t,l;return"event-group"===e.kind?"edited"===e.groupType?(0,n.jsx)(sN,{item:e,identities:o},e.key):(0,n.jsx)(sk,{item:e,identities:o},e.key):"event"===e.kind?(0,n.jsxs)("li",{"data-localapp-issue-event":!0,"data-testid":"issue-event-".concat(e.event.id),className:"relative flex min-w-0 items-center gap-2 py-2 pl-3 text-xs text-muted-foreground before:absolute before:bottom-0 before:left-[19px] before:top-0 before:w-px before:bg-border",children:[(0,n.jsx)("span",{className:"relative z-10 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-card",children:(0,n.jsx)(sw,{type:e.event.event_type})}),(0,n.jsxs)("span",{className:"min-w-0 break-words",children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:t6(e.event.actor_id,o).displayName})," ",sy(e,o)," ",(0,n.jsx)(tB,{timestamp:e.event.created_at})]})]},"event-".concat(e.event.id)):"cross_reference"===e.kind?(0,n.jsx)(sg,{reference:e.crossReference,actorName:t6(e.crossReference.actor_id,o).displayName,href:(()=>{var t;let s=null!=(t=null==y?void 0:y(e.crossReference.source_issue_number))?t:"#";if(null===e.crossReference.source_comment_id||"#"===s)return s;let n=new URL(s,window.location.origin);return n.searchParams.set("localappIssueCommentId",String(e.crossReference.source_comment_id)),"".concat(n.pathname).concat(n.search).concat(n.hash)})(),onOpen:(e,t)=>null==w?void 0:w(e,t)},"cross-reference-".concat(e.crossReference.id)):(0,n.jsxs)("li",{id:"issuecomment-".concat(e.comment.id),"data-localapp-issue-comment-card":!0,"data-localapp-issue-comment-pinned":e.comment.pinned_at?"true":void 0,"data-testid":"issue-comment-".concat(e.comment.id),"data-deleted":e.comment.deleted_at?"true":void 0,tabIndex:-1,"aria-current":g!==e.comment.id||e.comment.deleted_at?void 0:"location",className:"min-w-0 overflow-hidden rounded-[6px] border bg-card outline-none ".concat(e.comment.pinned_at?"border-primary/50":""," ").concat(g!==e.comment.id||e.comment.deleted_at?"":"ring-2 ring-primary ring-offset-2"),children:[e.comment.pinned_at&&(0,n.jsxs)("div",{className:"flex min-h-9 items-center gap-2 border-b border-primary/20 bg-primary/5 px-4 py-2 text-xs font-medium text-foreground",children:[(0,n.jsx)(tR.A,{className:"h-3.5 w-3.5 text-primary","aria-hidden":"true"}),(0,n.jsx)("span",{children:"置顶评论"}),(0,n.jsxs)("span",{className:"text-muted-foreground",children:["由 ",t6(null!=(t=e.comment.pinned_by)?t:"",o).displayName," 置顶 ",(0,n.jsx)(tB,{timestamp:e.comment.pinned_at})]})]}),(0,n.jsx)("div",{className:"border-b bg-muted/20 px-4 py-3",children:(0,n.jsx)(t7,{identity:t6(e.comment.author_id,o),timestamp:e.comment.created_at,timestampHref:e.comment.deleted_at?void 0:v(e.comment.id),timestampSuffix:!e.comment.deleted_at&&e.comment.revision_count?(0,n.jsx)("button",{type:"button","aria-label":"查看评论编辑历史,".concat(e.comment.revision_count," 次修改"),className:"-my-2 inline-flex h-11 items-center px-1 text-muted-foreground hover:underline sm:-my-0 sm:h-6",onClick:t=>N(e.comment.id,t.currentTarget),children:"edited"}):void 0,badge:e.comment.author_id===s?"Author":void 0,action:e.comment.deleted_at?void 0:(0,n.jsx)(tX,{label:"评论操作",items:[{label:"复制评论链接",onSelect:()=>{B(""),j(e.comment.id).then(()=>B("评论链接已复制")).catch(()=>B("无法复制评论链接"))}},...A&&C?[{label:e.comment.pinned_at?"取消置顶评论":"置顶评论",disabled:null!==H,restoreFocus:!1,onSelect:async()=>{X(null),W(e.comment.id);try{await C(e.comment.id,!e.comment.pinned_at),window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-testid="issue-comment-'.concat(e.comment.id,'"]')))?void 0:t.focus()})}catch(e){X(e instanceof Error?e.message:"无法更新置顶评论")}finally{W(null)}}}]:[],...E&&_?[{label:e.comment.minimized_at?"取消最小化评论":"最小化评论",restoreFocus:!1,disabled:el,onSelect:t=>{e.comment.minimized_at?(er(!0),_(e.comment.id,null).then(()=>window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-testid="issue-comment-'.concat(e.comment.id,'"]')))?void 0:t.focus()})).catch(e=>B(e instanceof Error?e.message:"无法恢复评论")).finally(()=>er(!1))):($.current=t,et("off-topic"),en(null),Y(e.comment.id))}}]:[],...c?[{label:"引用到新 Issue",restoreFocus:!1,onSelect:t=>b(e.comment.id,e.comment.body,e.comment.author_id,t)}]:[],...c&&!S?[{label:"引用回复",restoreFocus:!1,onSelect:()=>f(e.comment.body,e.comment.author_id)}]:[],...c===e.comment.author_id?[{label:"编辑评论",restoreFocus:!1,disabled:q===e.comment.id||F===e.comment.id,onSelect:()=>{let t=ej(e.comment.id,"version"),s=ej(e.comment.id,"body"),n=e.comment.updated_at,a=!1;try{let e=t&&window.sessionStorage.getItem(t);a=!!(e||s&&window.sessionStorage.getItem(s)),n=e||n,t&&window.sessionStorage.setItem(t,n)}catch(e){}D({id:e.comment.id,expectedUpdatedAt:n,restoredDraft:a,draftId:crypto.randomUUID(),removedAttachmentIds:[]})}},{label:"删除评论",restoreFocus:!1,destructive:!0,disabled:q===e.comment.id,onSelect:t=>{$.current=t,P(e.comment.id)}}]:[]]})})}),(0,n.jsxs)("div",{className:"px-3 py-3",children:[G===e.comment.id&&(0,n.jsxs)("div",{role:"alertdialog","aria-label":"最小化评论",className:"mb-3 rounded-md border bg-muted/20 p-3",children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:"选择最小化原因"}),(0,n.jsx)("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:Object.entries(ec).map(t=>{let[s,a]=t;return(0,n.jsxs)("label",{className:"flex min-h-11 items-center gap-2 rounded border px-3 py-2 text-sm",children:[(0,n.jsx)("input",{type:"radio",name:"minimize-reason-".concat(e.comment.id),value:s,checked:ee===s,onChange:()=>et(s)}),a]},s)})}),es&&(0,n.jsx)("p",{role:"alert",className:"mt-3 text-sm text-destructive",children:es}),(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:el,onClick:()=>{Y(null),en(null),window.requestAnimationFrame(()=>{var e;return null==(e=$.current)?void 0:e.focus()})},children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:el,onClick:()=>{_&&(er(!0),en(null),_(e.comment.id,ee).then(()=>{Y(null),window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-testid="issue-comment-'.concat(e.comment.id,'"]')))?void 0:t.focus()})}).catch(e=>en(e instanceof Error?e.message:"无法最小化评论")).finally(()=>er(!1)))},children:"最小化评论"})]})]}),F===e.comment.id&&(0,n.jsxs)("div",{role:"alertdialog","aria-label":"删除评论确认","aria-describedby":"delete-comment-".concat(e.comment.id,"-description"),onKeyDown:eS,className:"mb-3 rounded-md border border-destructive/30 bg-destructive/5 p-3",children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:"确定删除这条评论吗?"}),(0,n.jsx)("p",{id:"delete-comment-".concat(e.comment.id,"-description"),className:"mt-1 text-xs text-muted-foreground",children:"删除后评论内容将不再显示。"}),(0,n.jsxs)("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:M,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:q===e.comment.id,onClick:ek,children:"取消删除"}),(0,n.jsx)(x.$,{ref:O,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:q===e.comment.id,onClick:()=>void eI(e.comment.id),children:"确认删除评论"})]})]}),e.comment.deleted_at?(0,n.jsx)("p",{className:"text-sm italic text-muted-foreground",children:"此评论已删除。"}):e.comment.minimized_at&&!Q.has(e.comment.id)?(0,n.jsxs)("div",{"data-localapp-issue-comment-minimized":!0,className:"flex min-h-11 flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsxs)("span",{children:["此评论已最小化 \xb7 ",ec[null!=(l=e.comment.minimized_reason)?l:"off-topic"]]}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",onClick:()=>Z(t=>new Set(t).add(e.comment.id)),children:"显示评论"})]}):(null==R?void 0:R.id)===e.comment.id?(0,n.jsxs)(n.Fragment,{children:[R.expectedUpdatedAt!==e.comment.updated_at&&(0,n.jsxs)("div",{role:"status",className:"mb-3 flex items-center justify-between gap-3 rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{children:"此评论有新变更,当前草稿尚未被覆盖。"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-8",onClick:()=>{eN(e.comment.id,!0),D(null)},children:"加载最新内容"})]}),R.restoredDraft&&(0,n.jsxs)("div",{role:"status",className:"mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{children:"已恢复上次未完成的编辑"}),(0,n.jsx)(J,{triggerLabel:"丢弃已恢复草稿",onConfirm:()=>{eN(e.comment.id,!0),D(null)},focusAfterConfirm:()=>{var t;return null==(t=document.getElementById("issuecomment-".concat(e.comment.id)))?void 0:t.focus()}})]}),(0,n.jsx)(tN,{pagePath:a,draftId:R.draftId,persistenceKey:ej(e.comment.id,"body"),preferPersistedDraft:!0,initialBody:e.comment.body,textareaLabel:"编辑评论内容",placeholder:"更新评论",submitLabel:"保存评论",allowEmpty:i.some(t=>t.comment_id===e.comment.id&&!R.removedAttachmentIds.includes(t.id)),mentionCandidates:o,onCancel:()=>{eN(e.comment.id,!0),D(null)},onSubmit:async t=>{let{body:s,attachmentIds:n,draftId:a}=t;await p(e.comment.id,s,R.expectedUpdatedAt,a,n,R.removedAttachmentIds),eN(e.comment.id),D(null)}},"edit-comment-".concat(e.comment.id,"-").concat(R.expectedUpdatedAt)),(0,n.jsx)(sj,{pagePath:a,attachments:i.filter(t=>t.comment_id===e.comment.id&&!R.removedAttachmentIds.includes(t.id)),onRemove:e=>D(t=>t?{...t,removedAttachmentIds:[...t.removedAttachmentIds,e]}:t)})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ea,{tasksDisabled:S||k===e.comment.id,onToggleTask:c===e.comment.author_id&&I?(t,s)=>{I(e.comment.id,t,s).catch(()=>void 0)}:void 0,getIssueReferenceHref:y,onOpenIssueReference:w,children:e.comment.body}),(0,n.jsx)(sj,{pagePath:a,attachments:sx(e.comment.body,i.filter(t=>t.comment_id===e.comment.id))}),(0,n.jsx)(sa,{reactions:d,commentId:e.comment.id,currentUserId:c,additionsDisabled:S,onToggle:m})]})]})]},"comment-".concat(e.comment.id))})]})]})}let sA=Object.entries(eo);function sC(e){let{saving:t,error:s,onCancel:a,onConfirm:r}=e,[i,o]=(0,l.useState)("resolved"),c=(0,l.useRef)(null),d=(0,l.useRef)(null);return(0,l.useEffect)(()=>{var e;null==(e=d.current)||e.focus()},[]),(0,n.jsx)("div",{"data-localapp-issue-lock-layer":!0,className:"absolute inset-0 z-[80] flex items-center justify-center bg-black/45 p-4",onMouseDown:e=>{e.target!==e.currentTarget||t||a()},children:(0,n.jsxs)("div",{ref:c,role:"dialog","aria-modal":"true","aria-labelledby":"issue-lock-title","aria-describedby":"issue-lock-description",onKeyDown:e=>{var s,n;if("Escape"===e.key&&!t){e.preventDefault(),e.stopPropagation(),a();return}if("Tab"!==e.key)return;let l=Array.from(null!=(n=null==(s=c.current)?void 0:s.querySelectorAll("button:not([disabled]), select:not([disabled])"))?n:[]);if(0===l.length)return;let r=l[0],i=l[l.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),r.focus())},className:"w-full max-w-md overflow-hidden rounded-[6px] border bg-card shadow-2xl",children:[(0,n.jsxs)("header",{className:"flex items-center gap-3 border-b px-4 py-3",children:[(0,n.jsx)(tz.A,{className:"h-4 w-4","aria-hidden":"true"}),(0,n.jsx)("h3",{id:"issue-lock-title",className:"min-w-0 flex-1 text-sm font-semibold",children:"锁定对话"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"取消锁定",disabled:t,onClick:a,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(0,n.jsxs)("div",{className:"space-y-4 p-4",children:[(0,n.jsx)("p",{id:"issue-lock-description",className:"text-sm text-muted-foreground",children:"锁定后,参与者无法新增评论、表态或勾选任务。现有内容仍然可见。"}),s&&(0,n.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:s}),(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:["锁定原因",(0,n.jsx)("select",{ref:d,"aria-label":"锁定原因",value:i,disabled:t,onChange:e=>o(e.target.value),className:"block h-11 w-full rounded-md border bg-background px-3 text-sm outline-none focus:ring-2 focus:ring-ring sm:h-9",children:sA.map(e=>{let[t,s]=e;return(0,n.jsx)("option",{value:t,children:s},t)})})]})]}),(0,n.jsxs)("footer",{className:"flex justify-end gap-2 border-t px-4 py-3",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:t,onClick:a,children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:t,onClick:()=>{r(i).catch(()=>void 0)},children:t?"正在锁定...":"确认锁定"})]})]})})}var sE=s(2415),s_=s(5246),sT=s(3930),sL=s(6758);function sR(e){var t,s;let{pagePath:a="",detail:r,identities:i,canManage:c,saving:d,getIssueHref:u,onOpenIssue:m,onCreate:p,onLink:h,onRemove:f,onReprioritize:b,loadChildren:g}=e,[v,y]=(0,l.useState)(!1),[w,N]=(0,l.useState)(""),[k,I]=(0,l.useState)(null),[S,E]=(0,l.useState)(""),[_,T]=(0,l.useState)(null),L=(0,l.useRef)(null),R=(0,l.useRef)(null),D=(0,l.useRef)(new Map),[z,q]=(0,l.useState)(()=>new Set),[U,F]=(0,l.useState)({}),P=null!=(t=r.subIssueSummary)?t:{total:0,completed:0,percent:0},$=null!=(s=r.subIssues)?s:[],O=(0,l.useCallback)(async function(e){var t,s;let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!n&&(null==(t=U[e])?void 0:t.status)==="loaded")return;null==(s=D.current.get(e))||s.abort();let l=new AbortController;D.current.set(e,l),F(t=>{var s,n;return{...t,[e]:{status:"loading",items:null!=(n=null==(s=t[e])?void 0:s.items)?n:[]}}});try{let t=await (g?g(e,l.signal):eX(a,e,l.signal));l.signal.aborted||F(s=>({...s,[e]:{status:"loaded",items:t.items}}))}catch(t){l.signal.aborted||F(s=>{var n,a;return{...s,[e]:{status:"error",items:null!=(a=null==(n=s[e])?void 0:n.items)?a:[],error:t instanceof Error?t.message:"无法加载子层级"}}})}},[U,g,a]),K=e=>{q(t=>{let s=new Set(t);return s.has(e)?s.delete(e):(s.add(e),O(e)),s})};(0,l.useEffect)(()=>()=>{D.current.forEach(e=>e.abort())},[]),(0,l.useEffect)(()=>{for(let e of z)O(e,!0)},[r]),(0,l.useEffect)(()=>{if(null===L.current||d)return;let e=L.current;L.current=null,window.requestAnimationFrame(()=>{var t;return null==(t=document.querySelector('[data-localapp-sub-issue-id="'.concat(e,'"] button[aria-label^="重排 Sub-issue"]')))?void 0:t.focus()})},[d,$]);let J=async(e,t)=>{let s=$.findIndex(t=>t.id===e);I(null);try{var n,a;L.current=e,await b(e,t);let l=$.filter(t=>t.id!==e),r=null===t?1:l.findIndex(e=>e.id===t)+2;E("Sub-issue #".concat(null!=(a=null==(n=$[s])?void 0:n.issue_number)?a:e," 已移动到第 ").concat(r," 位"))}catch(e){L.current=null,I(e instanceof Error?e.message:"无法重排 Sub-issue")}},B=async()=>{let e=Number(w.replace(/^#/,""));if(!Number.isSafeInteger(e)||e<1)return void I("请输入有效的 Issue 编号");I(null);try{await h(e),N(""),y(!1),window.requestAnimationFrame(()=>{var e;return null==(e=R.current)?void 0:e.focus()})}catch(e){I(e instanceof Error?e.message:"无法关联 Sub-issue")}},H=(e,t,s)=>(0,n.jsx)("ul",{role:"group",className:"border-t bg-muted/10",children:e.map(e=>{var a,l,r;let i=(null!=(a=e.child_count)?a:0)>0,c=z.has(e.id),d=U[e.id],p=s.has(e.id)||t>=8,h=new Set(s).add(e.id);return(0,n.jsxs)("li",{role:"treeitem","aria-level":t,"aria-expanded":i&&!p?c:void 0,"data-localapp-sub-issue-id":e.id,children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2 py-2.5 pr-4",style:{paddingLeft:"".concat(20*Math.min(t,8),"px")},children:[i&&!p?(0,n.jsx)("button",{type:"button",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"".concat(c?"折叠":"展开"," Sub-issue #").concat(e.issue_number),onClick:()=>K(e.id),onKeyDown:t=>{"ArrowRight"!==t.key||c?"ArrowLeft"===t.key&&c&&(t.preventDefault(),K(e.id)):(t.preventDefault(),K(e.id))},children:c?(0,n.jsx)(st.A,{className:"h-4 w-4"}):(0,n.jsx)(tU.A,{className:"h-4 w-4"})}):(0,n.jsx)("span",{className:"h-8 w-8 shrink-0"}),"closed"===e.status?(0,n.jsx)(M.A,{className:"h-4 w-4 shrink-0 text-violet-600","aria-label":"已关闭"}):(0,n.jsx)(o.A,{className:"h-4 w-4 shrink-0 text-emerald-700","aria-label":"开启"}),(0,n.jsxs)("a",{href:null!=(l=null==u?void 0:u(e.issue_number))?l:"#","aria-label":"#".concat(e.issue_number," ").concat(e.title),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 py-2 font-medium hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:t=>{!m||0!==t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),m(e.issue_number))},children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words",children:e.title}),(0,n.jsxs)("span",{className:"shrink-0 text-xs font-normal text-muted-foreground",children:["#",e.issue_number]})]}),i&&(0,n.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground",children:[null!=(r=e.completed_child_count)?r:0,"/",e.child_count]})]}),c&&(null==d?void 0:d.status)==="loading"&&(0,n.jsxs)("div",{role:"status",className:"flex items-center gap-2 py-3 pr-4 text-sm text-muted-foreground",style:{paddingLeft:"".concat(20*Math.min(t+1,8),"px")},children:[(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin"}),"正在加载子项"]}),c&&(null==d?void 0:d.status)==="error"&&(0,n.jsxs)("div",{role:"alert",className:"flex items-center gap-2 py-3 pr-4 text-sm text-destructive",style:{paddingLeft:"".concat(20*Math.min(t+1,8),"px")},children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:d.error}),(0,n.jsxs)(x.$,{type:"button",variant:"ghost",size:"sm",className:"gap-1",onClick:()=>void O(e.id,!0),children:[(0,n.jsx)(sE.A,{className:"h-4 w-4"}),"重试"]})]}),c&&(null==d?void 0:d.status)==="loaded"&&d.items.length>0&&H(d.items.filter(e=>!h.has(e.id)),t+1,h),c&&(null==d?void 0:d.status)==="loaded"&&0===d.items.length&&(0,n.jsx)("div",{className:"py-3 pr-4 text-sm text-muted-foreground",style:{paddingLeft:"".concat(20*Math.min(t+1,8),"px")},children:"没有更多子项"})]},e.id)})});return(0,n.jsxs)("section",{"data-localapp-sub-issues":!0,"aria-labelledby":"issue-sub-issues-title",className:"mt-5 overflow-hidden rounded-[6px] border bg-card",children:[(0,n.jsx)("span",{className:"sr-only","aria-live":"polite",children:S}),(0,n.jsxs)("header",{className:"flex min-w-0 flex-wrap items-center gap-3 border-b bg-muted/20 px-4 py-3",children:[(0,n.jsx)(sb.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h4",{id:"issue-sub-issues-title",className:"text-sm font-semibold",children:"Sub-issues"}),(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[P.completed," / ",P.total," 已完成"]})]}),c&&(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsxs)(x.$,{ref:R,type:"button",variant:"ghost",size:"sm",className:"h-11 gap-1.5 sm:h-8",disabled:d,"aria-expanded":v,onClick:()=>{I(null),y(e=>!e)},children:[(0,n.jsx)(s_.A,{className:"h-4 w-4"}),"关联"]}),(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 gap-1.5 sm:h-8",disabled:d,onClick:p,children:[(0,n.jsx)(j.A,{className:"h-4 w-4"}),"创建子 Issue"]})]})]}),P.total>0&&(0,n.jsx)("div",{className:"h-1 bg-muted",role:"progressbar","aria-label":"Sub-issues 完成进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":P.percent,children:(0,n.jsx)("div",{className:"h-full bg-emerald-600",style:{width:"".concat(P.percent,"%")}})}),v&&(0,n.jsxs)("form",{className:"flex flex-col gap-2 border-b px-4 py-3 sm:flex-row",onSubmit:e=>{e.preventDefault(),B()},children:[(0,n.jsx)(C.p,{autoFocus:!0,"aria-label":"要关联的 Issue 编号",placeholder:"#123",value:w,onChange:e=>N(e.target.value),className:"h-11 min-w-0 flex-1 sm:h-9"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",className:"h-11 sm:h-9",onClick:()=>{y(!1),I(null),window.requestAnimationFrame(()=>{var e;return null==(e=R.current)?void 0:e.focus()})},children:"取消"}),(0,n.jsx)(x.$,{type:"submit",className:"h-11 sm:h-9",disabled:d,children:"关联 Issue"})]}),k&&(0,n.jsx)("p",{role:"alert",className:"basis-full text-sm text-destructive",children:k})]}),0===$.length?(0,n.jsx)("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"还没有 Sub-issue"}):(0,n.jsxs)("ul",{role:"tree","aria-label":"Sub-issues",className:"divide-y",onDragOver:e=>{c&&null!==_&&e.preventDefault()},onDrop:e=>{c&&null!==_&&e.target===e.currentTarget&&(e.preventDefault(),J(_,null),T(null))},children:[null!==_&&(0,n.jsx)("li",{"data-localapp-sub-issue-drop-first":!0,className:"h-3 bg-primary/10","aria-hidden":"true",onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),e.stopPropagation(),J(_,null),T(null)}}),$.map((e,t)=>{var s,a,l,p;let h=null!=(a=null==u?void 0:u(e.issue_number))?a:"#",b=t<=1?null:$[t-2].id,g=t<$.length-1?$[t+1].id:e.id,v=null!=(l=null==(s=$.at(-1))?void 0:s.id)?l:e.id,y=(null!=(p=e.child_count)?p:0)>0,w=z.has(e.id),j=U[e.id];return(0,n.jsxs)("li",{role:"treeitem","aria-level":1,"aria-expanded":y?w:void 0,"data-localapp-sub-issue-id":e.id,className:_===e.id?"opacity-60":"",onDragOver:t=>{c&&null!==_&&_!==e.id&&t.preventDefault()},onDrop:t=>{c&&null!==_&&_!==e.id&&(t.preventDefault(),t.stopPropagation(),J(_,e.id),T(null))},children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-3 py-2.5 sm:gap-3 sm:px-4",children:[c&&(0,n.jsx)("button",{type:"button",draggable:!d,"aria-label":"拖动 Sub-issue #".concat(e.issue_number),title:"拖动重排",disabled:d,className:"hidden h-8 w-8 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:flex",onDragStart:t=>{T(e.id),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",String(e.id))},onDragEnd:()=>T(null),children:(0,n.jsx)(sT.A,{className:"h-4 w-4"})}),y?(0,n.jsx)("button",{type:"button",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"".concat(w?"折叠":"展开"," Sub-issue #").concat(e.issue_number),onClick:()=>K(e.id),onKeyDown:t=>{"ArrowRight"!==t.key||w?"ArrowLeft"===t.key&&w&&(t.preventDefault(),K(e.id)):(t.preventDefault(),K(e.id))},children:w?(0,n.jsx)(st.A,{className:"h-4 w-4"}):(0,n.jsx)(tU.A,{className:"h-4 w-4"})}):(0,n.jsx)("span",{className:"h-8 w-8 shrink-0"}),"closed"===e.status?(0,n.jsx)(M.A,{className:"h-4 w-4 shrink-0 text-violet-600","aria-label":"已关闭"}):(0,n.jsx)(o.A,{className:"h-4 w-4 shrink-0 text-emerald-700","aria-label":"开启"}),(0,n.jsxs)("a",{href:h,"aria-label":"#".concat(e.issue_number," ").concat(e.title),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 py-2 font-medium hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:t=>{!m||0!==t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),m(e.issue_number))},children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words",children:e.title}),(0,n.jsxs)("span",{className:"shrink-0 text-xs font-normal text-muted-foreground",children:["#",e.issue_number]})]}),e.assignee_ids.slice(0,3).map(e=>{var t;let s=t6(e,i);return(0,n.jsx)("span",{title:"".concat(s.displayName," @").concat(e),"aria-label":"负责人 ".concat(s.displayName),className:"hidden h-7 w-7 shrink-0 items-center justify-center rounded-full border bg-muted text-[10px] font-semibold sm:flex",children:(null==(t=Array.from(s.displayName)[0])?void 0:t.toLocaleUpperCase())||"?"},e)}),c&&(0,n.jsx)(tX,{label:"重排 Sub-issue #".concat(e.issue_number),items:[{label:"移到顶部",disabled:d||0===t,restoreFocus:!1,onSelect:()=>void J(e.id,null)},{label:"上移",disabled:d||0===t,restoreFocus:!1,onSelect:()=>void J(e.id,b)},{label:"下移",disabled:d||t===$.length-1,restoreFocus:!1,onSelect:()=>void J(e.id,g)},{label:"移到底部",disabled:d||t===$.length-1,restoreFocus:!1,onSelect:()=>void J(e.id,v)}]}),c&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8",disabled:d,"aria-label":"移除 Sub-issue #".concat(e.issue_number),onClick:()=>{I(null),f(e.id).catch(e=>I(e instanceof Error?e.message:"无法移除 Sub-issue"))},children:(0,n.jsx)(sL.A,{className:"h-4 w-4"})})]}),w&&(null==j?void 0:j.status)==="loading"&&(0,n.jsxs)("div",{role:"status",className:"flex items-center gap-2 border-t px-12 py-3 text-sm text-muted-foreground",children:[(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin"}),"正在加载子项"]}),w&&(null==j?void 0:j.status)==="error"&&(0,n.jsxs)("div",{role:"alert",className:"flex items-center gap-2 border-t px-12 py-3 text-sm text-destructive",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:j.error}),(0,n.jsxs)(x.$,{type:"button",variant:"ghost",size:"sm",className:"gap-1",onClick:()=>void O(e.id,!0),children:[(0,n.jsx)(sE.A,{className:"h-4 w-4"}),"重试"]})]}),w&&(null==j?void 0:j.status)==="loaded"&&j.items.length>0&&H(j.items.filter(t=>t.id!==r.issue.id&&t.id!==e.id),2,new Set([r.issue.id,e.id]))]},e.id)})]}),k&&!v&&(0,n.jsx)("p",{role:"alert",className:"border-t px-4 py-2 text-sm text-destructive",children:k})]})}function sD(e){let{initialTitle:t,saving:s,error:a,onCancel:r,onConfirm:i}=e,[o,c]=(0,l.useState)(t),d=(0,l.useRef)(null),u=(0,l.useRef)(null),m=Array.from(o).length,p=!o.trim()||m>256;return(0,l.useEffect)(()=>{var e,t;null==(e=u.current)||e.focus(),null==(t=u.current)||t.select()},[]),(0,n.jsx)("div",{"data-localapp-issue-task-convert-layer":!0,className:"absolute inset-0 z-[80] flex items-center justify-center bg-black/45 p-4",onMouseDown:e=>{e.target!==e.currentTarget||s||r()},children:(0,n.jsxs)("div",{ref:d,role:"alertdialog","aria-modal":"true","aria-labelledby":"issue-task-convert-title","aria-describedby":"issue-task-convert-description",onKeyDown:e=>{var t,n;if("Escape"===e.key&&!s){e.preventDefault(),e.stopPropagation(),r();return}if("Tab"!==e.key)return;let a=Array.from(null!=(n=null==(t=d.current)?void 0:t.querySelectorAll("input:not([disabled]), button:not([disabled])"))?n:[]);if(!a.length)return;let l=a[0],i=a[a.length-1];e.shiftKey&&document.activeElement===l?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),l.focus())},className:"w-full max-w-lg overflow-hidden rounded-[6px] border bg-card shadow-2xl",children:[(0,n.jsxs)("header",{className:"flex items-center gap-3 border-b px-4 py-3",children:[(0,n.jsx)(V.A,{className:"h-4 w-4","aria-hidden":"true"}),(0,n.jsx)("h3",{id:"issue-task-convert-title",className:"min-w-0 flex-1 text-sm font-semibold",children:"转换为 Sub-issue"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"取消转换",disabled:s,onClick:r,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(0,n.jsxs)("div",{className:"space-y-4 p-4",children:[(0,n.jsx)("p",{id:"issue-task-convert-description",className:"text-sm text-muted-foreground",children:"将创建一个新的 Sub-issue,并把当前任务替换为可追踪的 Issue 引用。"}),a&&(0,n.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:a}),(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsxs)("span",{className:"flex justify-between gap-3",children:[(0,n.jsx)("span",{children:"Sub-issue 标题"}),(0,n.jsxs)("span",{className:m>256?"text-destructive":"text-muted-foreground",children:[m," / 256"]})]}),(0,n.jsx)("input",{ref:u,"aria-label":"Sub-issue 标题","aria-invalid":p||void 0,value:o,disabled:s,onChange:e=>c(e.target.value),className:"block h-11 w-full rounded-md border bg-background px-3 text-sm outline-none focus:ring-2 focus:ring-ring"})]})]}),(0,n.jsxs)("footer",{className:"flex justify-end gap-2 border-t px-4 py-3",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:s,onClick:r,children:"取消"}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 sm:h-8",disabled:s||p,onClick:()=>{i(o.trim()).catch(()=>void 0)},children:s?"正在创建...":"创建 Sub-issue"})]})]})})}var sz=s(9927);function sq(e){var t,s,a;let{detail:r,identities:i,canManage:c,saving:d,getIssueHref:u,onOpenIssue:m,onAdd:p,onRemove:h}=e,[f,b]=(0,l.useState)(null),[g,v]=(0,l.useState)(""),[y,w]=(0,l.useState)(null),j=(0,l.useRef)({blockedBy:null,blocking:null}),N=null!=(t=r.dependencySummary)?t:{blockedBy:0,blocking:0,unresolvedBlockers:0,isBlocked:!1},k=async()=>{if(!f)return;let e=Number(g.replace(/^#/,""));if(!Number.isSafeInteger(e)||e<1)return void w("请输入有效的 Issue 编号");w(null);try{await p(f,e),v(""),b(null),window.requestAnimationFrame(()=>{var e;return null==(e=j.current[f])?void 0:e.focus()})}catch(e){w(e instanceof Error?e.message:"无法添加 Issue 依赖")}},I=[{direction:"blockedBy",title:"被以下 Issue 阻塞",empty:"没有 blocker",items:null!=(s=r.blockedBy)?s:[]},{direction:"blocking",title:"正在阻塞",empty:"没有阻塞其他 Issue",items:null!=(a=r.blocking)?a:[]}];return(0,n.jsxs)("section",{"data-localapp-issue-dependencies":!0,"aria-labelledby":"issue-dependencies-title",className:"mt-5 overflow-hidden rounded-[6px] border bg-card",children:[(0,n.jsxs)("header",{className:"flex min-w-0 items-center gap-3 border-b bg-muted/20 px-4 py-3",children:[(0,n.jsx)(sz.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h4",{id:"issue-dependencies-title",className:"text-sm font-semibold",children:"Relationships"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:N.unresolvedBlockers?"".concat(N.unresolvedBlockers," 个未解决 blocker"):"当前未被阻塞"})]})]}),I.map(e=>(0,n.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,n.jsxs)("div",{className:"flex min-h-11 items-center gap-2 px-4 py-2",children:[(0,n.jsx)("h5",{className:"min-w-0 flex-1 text-xs font-semibold text-muted-foreground",children:e.title}),c&&(0,n.jsxs)(x.$,{ref:t=>{j.current[e.direction]=t},type:"button",variant:"ghost",size:"sm",className:"h-11 gap-1.5 sm:h-8",disabled:d,"aria-expanded":f===e.direction,onClick:()=>{w(null),v(""),b(t=>t===e.direction?null:e.direction)},children:[(0,n.jsx)(s_.A,{className:"h-4 w-4"}),"添加"]})]}),f===e.direction&&(0,n.jsxs)("form",{className:"flex flex-col gap-2 border-t px-4 py-3 sm:flex-row",onSubmit:e=>{e.preventDefault(),k()},children:[(0,n.jsx)(C.p,{autoFocus:!0,"aria-label":"".concat(e.title,"的 Issue 编号"),placeholder:"#123",value:g,onChange:e=>v(e.target.value),className:"h-11 min-w-0 flex-1 sm:h-9"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",className:"h-11 sm:h-9",onClick:()=>{b(null),w(null),window.requestAnimationFrame(()=>{var t;return null==(t=j.current[e.direction])?void 0:t.focus()})},children:"取消"}),(0,n.jsx)(x.$,{type:"submit",className:"h-11 sm:h-9",disabled:d,children:"添加依赖"})]}),y&&(0,n.jsx)("p",{role:"alert",className:"basis-full text-sm text-destructive",children:y})]}),0===e.items.length?(0,n.jsx)("p",{className:"border-t px-4 py-3 text-xs text-muted-foreground",children:e.empty}):(0,n.jsx)("ul",{"aria-label":e.title,className:"divide-y border-t",children:e.items.map(t=>{var s;return(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-3 px-4 py-2.5",children:["closed"===t.status?(0,n.jsx)(M.A,{className:"h-4 w-4 shrink-0 text-violet-600","aria-label":"已关闭"}):(0,n.jsx)(o.A,{className:"h-4 w-4 shrink-0 text-emerald-700","aria-label":"开启"}),(0,n.jsxs)("a",{href:null!=(s=null==u?void 0:u(t.issue_number))?s:"#",className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 py-2 font-medium hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:e=>{!m||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),m(t.issue_number))},children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words",children:t.title}),(0,n.jsxs)("span",{className:"shrink-0 text-xs font-normal text-muted-foreground",children:["#",t.issue_number]})]}),t.assignee_ids.slice(0,3).map(e=>{var t;let s=t6(e,i);return(0,n.jsx)("span",{title:"".concat(s.displayName," @").concat(e),className:"hidden h-7 w-7 shrink-0 items-center justify-center rounded-full border bg-muted text-[10px] font-semibold sm:flex",children:(null==(t=Array.from(s.displayName)[0])?void 0:t.toLocaleUpperCase())||"?"},e)}),c&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8",disabled:d,"aria-label":"移除依赖 #".concat(t.issue_number),onClick:()=>{w(null),h(e.direction,t.id).catch(e=>w(e instanceof Error?e.message:"无法移除 Issue 依赖"))},children:(0,n.jsx)(sL.A,{className:"h-4 w-4"})})]},t.id)})})]},e.direction)),y&&!f&&(0,n.jsx)("p",{role:"alert",className:"border-t px-4 py-2 text-sm text-destructive",children:y})]})}function sU(e){let{issue:t,prefix:s,getIssueHref:a,onOpenIssue:l}=e;return(0,n.jsxs)("a",{href:a(t.issue_number),"aria-label":"".concat(s," Issue #").concat(t.issue_number," ").concat(t.title),className:"flex min-h-11 min-w-0 items-center gap-2 rounded px-3 py-2 text-sm hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:min-h-9",onClick:e=>{!l||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),l(t.issue_number))},children:[(0,n.jsxs)("span",{className:"shrink-0 text-muted-foreground",children:["#",t.issue_number]}),(0,n.jsx)("span",{className:"min-w-0 flex-1 break-words font-medium",children:t.title})]})}function sF(e){let{duplicateOf:t,duplicates:s=[],canManage:a,getIssueHref:r,onOpenIssue:i,onUnmark:o}=e,[c,d]=(0,l.useState)(!1),[u,m]=(0,l.useState)(null),p=(0,l.useRef)(null);if(!t&&0===s.length)return null;let h=async()=>{if(!t||c)return;d(!0),m(null);let e=!1;try{await o(t.id),e=!0}catch(e){m(e instanceof Error?e.message:"撤销重复标记失败")}finally{d(!1),requestAnimationFrame(()=>{var t;return null==(t=e?document.querySelector("[data-localapp-issue-title]"):p.current)?void 0:t.focus()})}};return(0,n.jsxs)("section",{"aria-label":"Duplicate Issues",className:"mt-5 overflow-hidden rounded-[6px] border bg-card",children:[t&&(0,n.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 border-b bg-muted/20 px-3 py-2",children:[(0,n.jsx)(S.A,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)("span",{className:"text-sm",children:"此 Issue 是重复项:"}),(0,n.jsxs)("a",{href:r(t.issue_number),"aria-label":"Canonical Issue #".concat(t.issue_number," ").concat(t.title),className:"min-h-11 min-w-0 flex-1 break-words rounded py-2 text-sm font-medium hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:min-h-8 sm:py-1",onClick:e=>{!i||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i(t.issue_number))},children:["#",t.issue_number," ",t.title]}),a&&(0,n.jsx)(x.$,{ref:p,type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-8",disabled:c,onClick:()=>void h(),children:c?"撤销中...":"撤销重复标记"})]}),u&&(0,n.jsx)("p",{role:"alert",className:"border-b px-3 py-2 text-sm text-destructive",children:u}),s.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("h4",{className:"px-3 pt-3 text-sm font-semibold",children:"重复 Issue"}),(0,n.jsx)("p",{className:"px-3 pb-1 text-xs text-muted-foreground",children:"以下 Issue 已标记为当前 Issue 的重复项"}),(0,n.jsx)("ul",{"aria-label":"重复 Issues",className:"divide-y",children:s.map(e=>(0,n.jsx)("li",{children:(0,n.jsx)(sU,{issue:e,prefix:"重复",getIssueHref:r,onOpenIssue:i})},e.id))})]})]})}function sP(e){let{pagePath:t,attachments:s,onRemove:a}=e;return s.length?(0,n.jsx)("div",{className:"mt-4 grid min-w-0 gap-2 sm:grid-cols-2",children:s.map(e=>{let s=em(t,e.id);return(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-1",children:[eu(e.mime_type)?(0,n.jsx)("a",{href:s,target:"_blank",rel:"noreferrer","aria-label":"在新标签页打开附件 ".concat(e.file_name),className:"block min-w-0 flex-1 overflow-hidden rounded-[6px] border",children:(0,n.jsx)("img",{src:s,alt:e.file_name,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full object-contain"})}):(0,n.jsxs)("a",{href:s,target:"_blank",rel:"noreferrer","aria-label":"在新标签页打开附件 ".concat(e.file_name),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-[6px] border px-3 py-2 text-xs text-primary hover:underline",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.file_name}),(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground",children:ep(e.size_bytes)})]}),a&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"移除现有附件 ".concat(e.file_name),onClick:()=>a(e.id),children:(0,n.jsx)(K.A,{className:"h-4 w-4"})})]},e.id)})}):null}function s$(e){let{participantIds:t,identities:s}=e,a=t.slice(0,8),l=Math.max(0,t.length-a.length);return(0,n.jsxs)("ul",{"aria-label":"Issue 参与者",className:"flex flex-wrap gap-1.5",children:[a.map(e=>{var t;let a=t6(e,s),l="".concat(a.displayName," @").concat(a.id);return(0,n.jsx)("li",{children:(0,n.jsx)("span",{"aria-label":l,title:l,className:"flex h-7 w-7 items-center justify-center overflow-hidden rounded-full border bg-muted text-[10px] font-semibold text-muted-foreground",children:a.avatarUrl?(0,n.jsx)("img",{src:a.avatarUrl,alt:"",className:"h-full w-full object-cover"}):(null==(t=Array.from(a.displayName)[0])?void 0:t.toLocaleUpperCase())||"?"})},e)}),l>0&&(0,n.jsx)("li",{children:(0,n.jsxs)("span",{"aria-label":"另外 ".concat(l," 位参与者"),title:"另外 ".concat(l," 位参与者"),className:"flex h-7 min-w-7 items-center justify-center rounded-full border bg-muted px-1 text-[10px] font-semibold text-muted-foreground",children:["+",l]})})]})}function sM(e){var t,s,a,r,i,o,c,d,u,m,p;let{detail:h,identities:f,availableLabels:b,availableMilestones:g,currentUserId:v,canManage:y,saving:w,onToggleLabel:j,onSetIssueType:N,onToggleAssignee:k,onSetMilestone:I,onToggleSubscription:S,canManageLock:A,onToggleLock:C,canManagePin:E,onTogglePin:_}=e,[T,L]=(0,l.useState)(null),[R,D]=(0,l.useState)(!1),z=(0,l.useRef)(null),q=h.collaboration,U=Array.from(new Set([h.issue.reporter_id,...null!=(s=null==q?void 0:q.participant_ids)?s:[],...null!=(a=h.issue.participant_ids)?a:[],...h.timeline.flatMap(e=>"comment"===e.kind?[e.comment.author_id]:"event"===e.kind?[e.event.actor_id]:[e.crossReference.actor_id])])).filter(Boolean),F=t6(h.issue.reporter_id,f),P=null!=(r=null==q?void 0:q.labels.map(e=>e.id))?r:[],$=Array.from(new Map([...null!=(i=null==q?void 0:q.labels)?i:[],...b].map(e=>[e.id,e])).values()),M=null!=(o=null==q?void 0:q.assignee_ids)?o:[],O=Array.from(new Set([...M,...f.map(e=>e.id)])).map(e=>t6(e,f)),K=!!(v&&(null==q?void 0:q.subscriber_ids.includes(v))),J=async e=>{if(e){L(null);try{await e}catch(e){throw L(e instanceof Error?e.message:"Issue 元数据更新失败"),e}}},B=()=>{D(!1),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>{var e;return null==(e=z.current)?void 0:e.focus()}))};return(0,n.jsxs)("div",{className:"space-y-5 text-sm",children:[T&&!R&&(0,n.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:T}),(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"创建者"}),(0,n.jsx)(t7,{identity:F})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold text-muted-foreground",children:"类型"}),y&&(0,n.jsxs)("select",{"aria-label":"设置 Issue 类型",className:"h-11 rounded-md border bg-background px-2 text-xs sm:h-8",disabled:w,value:null!=(c=h.issue.issue_type)?c:h.issue.label,onChange:e=>void J(null==N?void 0:N(e.target.value)),children:[(0,n.jsx)("option",{value:"task",children:"任务"}),(0,n.jsx)("option",{value:"bug",children:"缺陷"}),(0,n.jsx)("option",{value:"feature",children:"功能"})]})]}),(0,n.jsx)("p",{className:"text-xs font-medium text-foreground",children:ei[null!=(d=h.issue.issue_type)?d:h.issue.label]})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold text-muted-foreground",children:"标签"}),y&&(0,n.jsx)(t9,{label:"Labels",items:$.map(e=>({id:e.id,label:e.name,description:e.description||e.id,leading:(0,n.jsx)("span",{"aria-hidden":"true",className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:"#".concat(e.color)}})})),selectedIds:P,disabled:w,onToggle:(e,t)=>null==j?void 0:j(e,t)})]}),(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:(null!=(u=null==q?void 0:q.labels)?u:[]).map(e=>(0,n.jsx)(tF,{label:e},e.id))})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold text-muted-foreground",children:"负责人"}),y&&(0,n.jsx)(t9,{label:"Assignees",items:O.map(e=>{var t;return{id:e.id,label:e.displayName,description:"@".concat(e.id),leading:(0,n.jsx)("span",{"aria-hidden":"true",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold",children:(null==(t=Array.from(e.displayName)[0])?void 0:t.toLocaleUpperCase())||"?"})}}),selectedIds:M,disabled:w,onToggle:(e,t)=>null==k?void 0:k(e,t)})]}),M.length>0?(0,n.jsx)("div",{className:"space-y-2",children:M.map(e=>(0,n.jsx)(t7,{identity:t6(e,f)},e))}):(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"尚未分配"})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold text-muted-foreground",children:"里程碑"}),y&&(0,n.jsxs)("select",{"aria-label":"设置里程碑",className:"h-11 min-w-0 max-w-[170px] rounded-md border bg-background px-2 text-xs sm:h-8",disabled:w,value:null!=(m=h.issue.milestone_id)?m:"",onChange:e=>void J(null==I?void 0:I(e.target.value?Number(e.target.value):null)),children:[(0,n.jsx)("option",{value:"",children:"无里程碑"}),g.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title,"closed"===e.state?"(已关闭)":""]},e.id))]})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:null!=(p=null==(t=g.find(e=>e.id===h.issue.milestone_id))?void 0:t.title)?p:h.issue.milestone_id?"里程碑 #".concat(h.issue.milestone_id):"尚未设置"})]}),v&&(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"通知"}),(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 w-full justify-start gap-2 sm:h-8",disabled:w,"aria-label":K?"取消订阅":"订阅 Issue",onClick:()=>J(null==S?void 0:S(!K)),children:[K?(0,n.jsx)(t4.A,{className:"h-4 w-4"}):(0,n.jsx)(t3.A,{className:"h-4 w-4"}),K?"取消订阅":"订阅 Issue"]})]}),E&&(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"置顶"}),(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 w-full justify-start gap-2 sm:h-8",disabled:w,"aria-label":h.issue.pinned_at?"取消置顶":"置顶 Issue",onClick:()=>{J(null==_?void 0:_(!h.issue.pinned_at)).catch(()=>void 0)},children:[h.issue.pinned_at?(0,n.jsx)(t5.A,{className:"h-4 w-4"}):(0,n.jsx)(tR.A,{className:"h-4 w-4"}),h.issue.pinned_at?"取消置顶":"置顶 Issue"]})]}),A&&(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"对话"}),(0,n.jsxs)(x.$,{ref:z,type:"button",variant:"outline",size:"sm",className:"h-11 w-full justify-start gap-2 sm:h-8",disabled:w,"aria-label":h.issue.locked_at?"解锁对话":"锁定对话",onClick:()=>h.issue.locked_at?J(null==C?void 0:C(!1)):D(!0),children:[h.issue.locked_at?(0,n.jsx)(t8.A,{className:"h-4 w-4"}):(0,n.jsx)(tz.A,{className:"h-4 w-4"}),h.issue.locked_at?"解锁对话":"锁定对话"]})]}),(0,n.jsxs)("section",{children:[(0,n.jsx)("h4",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"参与者"}),(0,n.jsx)(s$,{participantIds:U,identities:f})]}),R&&(0,n.jsx)(sC,{saving:w,error:T,onCancel:B,onConfirm:async e=>{await J(null==C?void 0:C(!0,e)),B()}})]})}function sO(e){var t,s,a,r,i,c,d,u;let{pagePath:m,detail:p,identities:h,currentUserId:f,availableLabels:x=[],availableMilestones:b=[],canManageMetadata:g=!1,metadataSaving:v=!1,headerAction:y,bodyAction:w,statusAction:j,composer:N,commentDraftPrefix:k,onEditComment:I,onDeleteComment:S,canManageCommentPins:A=!1,onToggleCommentPin:C,canManageCommentMinimization:E=!1,onToggleCommentMinimized:_,onQuoteComment:T,onReferenceComment:L,selectedCommentId:R,getCommentHref:D,getIssueHref:z,getIssueReferenceHref:q,onOpenIssueReference:U,onCopyCommentLink:F,onViewIssueHistory:P,onViewCommentHistory:$,onToggleLabel:O,onSetIssueType:K,onToggleAssignee:J,onSetMilestone:B,onToggleSubscription:H,canManageLock:W=!1,onToggleLock:V,canManagePin:X=!1,onTogglePin:Q,canManageSubIssues:Z=!1,onCreateSubIssue:G,onLinkSubIssue:Y,onRemoveSubIssue:ee,onReprioritizeSubIssue:et,canManageDependencies:es=!1,onAddDependency:en,onRemoveDependency:el,canManageDuplicates:er=!1,onUnmarkDuplicate:ei,onToggleReaction:eo,savingTaskTarget:ec,onToggleIssueTask:ed,onConvertIssueTask:eu,onToggleCommentTask:em}=e,[ep,eh]=(0,l.useState)(null),[ef,ex]=(0,l.useState)(!1),[eb,eg]=(0,l.useState)(null),[ev,ey]=(0,l.useState)(null),ew=t6(p.issue.reporter_id,h),ej=sx(p.issue.description,p.attachments.filter(e=>null===e.comment_id)),eN=p.timeline.filter(e=>"comment"===e.kind&&!e.comment.deleted_at),ek=eN[0],eI="open"===p.issue.status,eS=!eI&&"not_planned"===p.issue.state_reason,eA=null!=(r=null==(t=p.collaboration)?void 0:t.labels.length)?r:0,eC=null!=(i=null==(s=p.collaboration)?void 0:s.assignee_ids.length)?i:0,eE="".concat(eA," 个标签 \xb7 ").concat(eC?"".concat(eC," 位负责人"):"未分配").concat(p.issue.locked_at?" \xb7 已锁定":"");return(0,l.useEffect)(()=>{if(null===ev)return;let e=0,t=0,s=()=>{let n=document.querySelector('[data-localapp-issue-reference="'.concat(ev,'"]'));if(null==n||n.focus(),n&&document.activeElement===n)return void ey(null);e++<10&&(t=window.setTimeout(s,30))};return t=window.setTimeout(s,0),()=>window.clearTimeout(t)},[p.issue.description,ev]),(0,n.jsxs)("section",{"data-localapp-issue-detail":!0,"data-testid":"issue-detail-workspace",className:"relative grid min-w-0 grid-cols-1 lg:grid-cols-[minmax(0,3fr)_minmax(240px,1fr)] lg:gap-6",children:[(0,n.jsx)("span",{"aria-label":"Issue 元数据状态","aria-live":"polite",className:"sr-only",children:v?"正在更新 Issue 元数据":"Issue 元数据已同步"}),(0,n.jsx)("span",{"aria-live":"polite",className:"sr-only",children:null!=ec?"正在保存任务状态":""}),(0,n.jsxs)("header",{className:"min-w-0 border-b pb-5 lg:col-span-2",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,n.jsxs)("h3",{"data-localapp-issue-title":!0,tabIndex:-1,"aria-label":p.issue.title,className:"min-w-0 flex-1 break-words text-2xl font-normal leading-8 tracking-normal outline-none sm:text-[32px] sm:leading-10",children:[p.issue.title," ",(0,n.jsxs)("span",{className:"whitespace-nowrap text-muted-foreground",children:["#",p.issue.issue_number]})]}),y]}),(0,n.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 font-medium text-white ".concat(eI?"bg-emerald-700":"bg-violet-600"),children:[eI?(0,n.jsx)(o.A,{className:"h-4 w-4","aria-hidden":"true"}):eS?(0,n.jsx)(tC.A,{className:"h-4 w-4","aria-hidden":"true"}):(0,n.jsx)(M.A,{className:"h-4 w-4","aria-hidden":"true"}),eI?"开启":"not_planned"===p.issue.state_reason?"已关闭 \xb7 不计划处理":"已关闭 \xb7 已完成"]}),(0,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("strong",{className:"font-semibold text-foreground",children:ew.displayName})," 打开了此 Issue ",(0,n.jsx)(tB,{timestamp:p.issue.created_at})]}),(0,n.jsxs)("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[(0,n.jsx)("span",{className:"hidden sm:inline","aria-hidden":"true",children:"\xb7"}),ek?(0,n.jsxs)("a",{href:D(ek.comment.id),className:"-my-2 inline-flex h-11 items-center px-1 font-medium text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:-my-0 sm:h-6",children:[eN.length," 条评论"]}):(0,n.jsx)("span",{children:"0 条评论"})]}),p.issue.locked_at&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 font-medium text-foreground",children:[(0,n.jsx)(tz.A,{className:"h-4 w-4","aria-hidden":"true"}),"已锁定"]})]}),p.parent&&(0,n.jsxs)("a",{href:null!=(c=null==q?void 0:q(p.parent.issue_number))?c:"#",className:"mt-2 inline-flex min-h-11 items-center text-sm font-medium text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:min-h-7",onClick:e=>{!U||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),U(p.parent.issue_number))},children:["父 Issue:#",p.parent.issue_number," ",p.parent.title]})]}),(p.duplicateOf||(null==(a=p.duplicates)?void 0:a.length))&&(0,n.jsx)("div",{className:"min-w-0 lg:col-span-2",children:(0,n.jsx)(sF,{duplicateOf:p.duplicateOf,duplicates:p.duplicates,canManage:er,getIssueHref:e=>{var t;return null!=(t=null==q?void 0:q(e))?t:"#"},onOpenIssue:U,onUnmark:null!=ei?ei:async()=>void 0})}),(0,n.jsxs)("details",{"data-localapp-issue-metadata":!0,"data-testid":"issue-metadata-mobile",className:"border-b py-3 lg:hidden",children:[(0,n.jsx)("summary",{className:"min-h-11 cursor-pointer py-3 text-sm font-semibold",children:(0,n.jsxs)("span",{className:"inline-flex w-[calc(100%-1.25rem)] items-center justify-between gap-3 align-middle",children:[(0,n.jsx)("span",{children:"Issue 详情"}),(0,n.jsx)("span",{"data-localapp-issue-metadata-summary":!0,className:"min-w-0 truncate text-xs font-normal text-muted-foreground",children:eE})]})}),(0,n.jsx)("div",{className:"pt-4",children:(0,n.jsx)(sM,{detail:p,identities:h,availableLabels:x,availableMilestones:b,currentUserId:f,canManage:g,saving:v,onToggleLabel:O,onSetIssueType:K,onToggleAssignee:J,onSetMilestone:B,onToggleSubscription:H,canManageLock:W,onToggleLock:V,canManagePin:X,onTogglePin:Q})})]}),(0,n.jsxs)("main",{"data-localapp-issue-discussion":!0,"data-testid":"issue-discussion",className:"min-w-0 py-6",children:[(0,n.jsxs)("article",{"data-localapp-issue-body-card":!0,"data-testid":"issue-body-card",className:"min-w-0 overflow-hidden rounded-[6px] border bg-card",children:[(0,n.jsx)("header",{className:"border-b bg-muted/20 px-4 py-3",children:(0,n.jsx)(t7,{identity:ew,timestamp:p.issue.created_at,timestampHref:z(),timestampSuffix:p.issue.revision_count?(0,n.jsx)("button",{type:"button","aria-label":"查看 Issue 编辑历史,".concat(p.issue.revision_count," 次修改"),className:"-my-2 inline-flex h-11 items-center px-1 text-muted-foreground hover:underline sm:-my-0 sm:h-6",onClick:e=>P(e.currentTarget),children:"edited"}):void 0,badge:"Author",action:w})}),(0,n.jsxs)("div",{className:"min-w-0 px-4 py-4",children:[(0,n.jsx)(ea,{tasksDisabled:!!p.issue.locked_at||"issue"===ec||ef,onToggleTask:ed?(e,t)=>{ed(e,t).catch(()=>void 0)}:void 0,onConvertTask:eu&&!p.issue.locked_at?(e,t,s)=>{eg(null),eh({index:e,title:t,trigger:s})}:void 0,getIssueReferenceHref:q,onOpenIssueReference:U,children:p.issue.description.trim()||"未提供描述。"}),(0,n.jsx)(sP,{pagePath:m,attachments:ej}),(0,n.jsx)(sa,{reactions:null!=(d=p.reactions)?d:[],currentUserId:f,additionsDisabled:!!p.issue.locked_at,onToggle:eo})]})]}),(0,n.jsx)(sR,{pagePath:m,detail:p,identities:h,canManage:Z,saving:v,getIssueHref:q,onOpenIssue:U,onCreate:null!=G?G:()=>void 0,onLink:null!=Y?Y:async()=>void 0,onRemove:null!=ee?ee:async()=>void 0,onReprioritize:null!=et?et:async()=>void 0}),(0,n.jsx)(sq,{detail:p,identities:h,canManage:es,saving:v,getIssueHref:q,onOpenIssue:U,onAdd:null!=en?en:async()=>void 0,onRemove:null!=el?el:async()=>void 0}),(0,n.jsx)("div",{className:"mt-5",children:(0,n.jsx)(sS,{issueId:p.issue.id,reporterId:p.issue.reporter_id,pagePath:m,timeline:p.timeline,attachments:p.attachments,identities:h,currentUserId:f,reactions:null!=(u=p.reactions)?u:[],commentDraftPrefix:k,onToggleReaction:eo,onEditComment:I,onDeleteComment:S,canManageCommentPins:A,onToggleCommentPin:C,canManageCommentMinimization:E,onToggleCommentMinimized:_,onQuoteComment:T,onReferenceComment:L,selectedCommentId:R,getCommentHref:D,getIssueReferenceHref:q,onOpenIssueReference:U,onCopyCommentLink:F,onViewHistory:$,savingTaskTarget:"number"==typeof ec?ec:null,onToggleCommentTask:em,interactionsLocked:!!p.issue.locked_at})}),j&&(0,n.jsx)("div",{className:"mt-4 flex justify-end",children:j}),N&&(0,n.jsx)("div",{className:"mt-6 border-t pt-5",children:N})]}),(0,n.jsx)("aside",{"data-localapp-issue-metadata":!0,"data-testid":"issue-metadata-desktop",className:"max-lg:hidden min-w-0 border-l py-6 pl-6",children:(0,n.jsx)(sM,{detail:p,identities:h,availableLabels:x,availableMilestones:b,currentUserId:f,canManage:g,saving:v,onToggleLabel:O,onSetIssueType:K,onToggleAssignee:J,onSetMilestone:B,onToggleSubscription:H,canManageLock:W,onToggleLock:V,canManagePin:X,onTogglePin:Q})}),ep&&(0,n.jsx)(sD,{initialTitle:ep.title,saving:ef,error:eb,onCancel:()=>{let e=ep.trigger;eh(null),eg(null),window.requestAnimationFrame(()=>e.focus())},onConfirm:async e=>{ex(!0),eg(null);try{let t=await eu(ep.index,e);ey(t),eh(null)}catch(e){throw eg(e instanceof Error?e.message:"无法转换任务"),e}finally{ex(!1)}}})]})}function sK(e){let{pagePath:t,issueId:s,commentId:a,currentTitle:r,currentBody:i,currentUpdatedAt:o,identities:c,returnFocus:d,onClose:u}=e,[m,p]=(0,l.useState)([]),[h,f]=(0,l.useState)(!0),[b,g]=(0,l.useState)(null),v=(0,l.useRef)(null),y=(0,l.useCallback)(async()=>{f(!0),g(null);try{p(await eG(t,s,a))}catch(e){g(e instanceof Error?e.message:"无法加载编辑历史")}finally{f(!1)}},[a,s,t]);(0,l.useEffect)(()=>{y()},[y]),(0,l.useEffect)(()=>{var e;return null==(e=v.current)||e.focus(),()=>{(null==d?void 0:d.isConnected)&&d.focus()}},[d]);let w=()=>u(),j=m[0]?t6(m[0].editor_id,c):null;return(0,n.jsx)("div",{"data-localapp-issue-history-layer":!0,className:"absolute inset-0 z-[70] flex items-center justify-center bg-black/45 p-0 sm:p-4",onMouseDown:e=>{e.target===e.currentTarget&&w()},children:(0,n.jsxs)("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":"issue-history-title","aria-describedby":"issue-history-target",tabIndex:-1,onKeyDown:e=>{if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),w();return}if("Tab"!==e.key||!v.current)return;e.stopPropagation();let t=Array.from(v.current.querySelectorAll("button:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])"));if(!t.length){e.preventDefault(),v.current.focus();return}let s=t[0],n=t[t.length-1];e.shiftKey&&(document.activeElement===s||document.activeElement===v.current)?(e.preventDefault(),n.focus()):e.shiftKey||document.activeElement!==n||(e.preventDefault(),s.focus())},className:"flex h-full w-full max-w-4xl flex-col overflow-hidden bg-card shadow-2xl outline-none sm:h-[min(760px,calc(100%-2rem))] sm:rounded-lg sm:border",children:[(0,n.jsxs)("header",{className:"flex min-h-14 items-center gap-3 border-b px-4 py-3 sm:px-5",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h3",{id:"issue-history-title",className:"truncate text-sm font-semibold",children:"编辑历史"}),(0,n.jsx)("p",{id:"issue-history-target",className:"truncate text-xs text-muted-foreground",children:void 0===a?"Issue #".concat(s):"评论 #".concat(a)})]}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"关闭编辑历史",onClick:w,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-5",children:h?(0,n.jsx)("p",{role:"status",className:"py-12 text-center text-sm text-muted-foreground",children:"正在加载编辑历史..."}):b?(0,n.jsxs)("div",{role:"alert",className:"mx-auto max-w-md rounded-[6px] border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:[(0,n.jsx)("p",{children:b}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"mt-3 h-11 sm:h-8",onClick:()=>void y(),children:"重试"})]}):(0,n.jsxs)("ol",{"aria-label":"编辑历史版本",className:"space-y-4",children:[(0,n.jsxs)("li",{className:"overflow-hidden rounded-[6px] border",children:[(0,n.jsxs)("header",{className:"border-b bg-muted/20 px-4 py-2.5 text-xs",children:[(0,n.jsx)("strong",{children:"当前版本"}),(0,n.jsxs)("span",{className:"ml-2 text-muted-foreground",children:[new Date(o).toLocaleString(),j?" \xb7 ".concat(j.displayName||j.name||j.id):""]})]}),(0,n.jsxs)("div",{className:"min-w-0 px-4 py-4",children:[void 0!==r&&(0,n.jsx)("h4",{className:"mb-3 break-words text-base font-semibold",children:r}),(0,n.jsx)(ea,{children:i.trim()||"未提供内容。"})]})]}),m.map(e=>{let t=t6(e.editor_id,c);return(0,n.jsxs)("li",{className:"overflow-hidden rounded-[6px] border",children:[(0,n.jsxs)("header",{className:"border-b bg-muted/20 px-4 py-2.5 text-xs",children:[(0,n.jsx)("strong",{children:"编辑前版本"}),(0,n.jsxs)("span",{className:"ml-2 text-muted-foreground",children:[new Date(e.created_at).toLocaleString()," \xb7 ",t.displayName||t.name||t.id]})]}),(0,n.jsxs)("div",{className:"min-w-0 px-4 py-4",children:[null!==e.title&&(0,n.jsx)("h4",{className:"mb-3 break-words text-base font-semibold",children:e.title}),(0,n.jsx)(ea,{children:e.body.trim()||"未提供内容。"})]})]},e.id)})]})})]})})}function sJ(){return(0,n.jsxs)("div",{role:"status","aria-label":"正在加载 Issue 详情",className:"min-h-0 flex-1 overflow-hidden px-5 py-5 sm:px-6",children:[(0,n.jsx)("span",{className:"sr-only",children:"正在加载 Issue 详情"}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,3fr)_minmax(240px,1fr)]",children:[(0,n.jsxs)("div",{className:"space-y-3 border-b pb-5 lg:col-span-2",children:[(0,n.jsx)("div",{className:"h-9 w-2/3 rounded bg-muted motion-safe:animate-pulse"}),(0,n.jsx)("div",{className:"h-7 w-56 rounded bg-muted/70 motion-safe:animate-pulse"})]}),(0,n.jsxs)("main",{className:"space-y-5",children:[(0,n.jsxs)("div",{className:"overflow-hidden rounded-[6px] border",children:[(0,n.jsx)("div",{className:"h-14 border-b bg-muted/30 motion-safe:animate-pulse"}),(0,n.jsxs)("div",{className:"space-y-3 p-4",children:[(0,n.jsx)("div",{className:"h-4 w-full rounded bg-muted motion-safe:animate-pulse"}),(0,n.jsx)("div",{className:"h-4 w-5/6 rounded bg-muted motion-safe:animate-pulse"}),(0,n.jsx)("div",{className:"h-4 w-1/2 rounded bg-muted motion-safe:animate-pulse"})]})]}),Array.from({length:2},(e,t)=>(0,n.jsx)("div",{className:"h-20 rounded-[6px] border bg-muted/20 motion-safe:animate-pulse"},t))]}),(0,n.jsx)("aside",{className:"hidden space-y-6 border-l pl-6 lg:block",children:Array.from({length:4},(e,t)=>(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("div",{className:"h-3 w-20 rounded bg-muted"}),(0,n.jsx)("div",{className:"h-7 w-32 rounded bg-muted/70 motion-safe:animate-pulse"})]},t))})]})]})}function sB(e){let{message:t,onRetry:s,onBack:a}=e,r=(0,l.useRef)(null),i=(0,l.useId)(),o=(0,l.useId)();return(0,l.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{var e;return null==(e=r.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[]),(0,n.jsxs)("div",{role:"alert","aria-labelledby":i,"aria-describedby":o,className:"flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center",children:[(0,n.jsx)(tD.A,{className:"h-10 w-10 text-destructive","aria-hidden":"true"}),(0,n.jsx)("h3",{ref:r,id:i,tabIndex:-1,className:"mt-3 text-base font-semibold outline-none",children:"无法加载 Issue 详情"}),(0,n.jsx)("p",{id:o,className:"mt-1 max-w-md text-sm text-muted-foreground",children:t}),(0,n.jsxs)("div",{className:"mt-4 flex gap-2",children:[(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8","aria-label":"从错误页返回 Issue 列表",onClick:a,children:"返回列表"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8","aria-label":"重试加载 Issue 详情",onClick:s,children:"重试"})]})]})}function sH(e){let{candidates:t,loading:s,error:a,getIssueHref:l,onOpenIssue:r,onRetry:i}=e;return s||a||0!==t.length?(0,n.jsxs)("section",{"data-localapp-potential-duplicates":!0,"aria-labelledby":"potential-duplicates-title",className:"overflow-hidden rounded-[6px] border bg-muted/10",children:[(0,n.jsxs)("header",{className:"flex min-h-11 items-center gap-2 border-b px-3 py-2",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h3",{id:"potential-duplicates-title",className:"text-sm font-semibold",children:"可能重复的 Issue"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"提交前检查是否已有相同问题"})]}),s&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin text-muted-foreground motion-reduce:animate-none","aria-label":"正在查找潜在重复 Issue"})]}),a?(0,n.jsxs)("div",{role:"alert",className:"flex min-h-11 items-center gap-3 px-3 py-2 text-sm text-destructive",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:a}),(0,n.jsxs)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 shrink-0 gap-1.5 sm:h-8",onClick:i,children:[(0,n.jsx)(O.A,{className:"h-4 w-4"}),"重试"]})]}):t.length>0&&(0,n.jsx)("ul",{"aria-label":"潜在重复 Issues",className:"divide-y",children:t.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("a",{href:l(e.issue_number),className:"flex min-h-11 min-w-0 items-start gap-3 px-3 py-2.5 hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:t=>{0!==t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),r(e.issue_number))},children:["closed"===e.status?(0,n.jsx)(M.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-label":"已关闭"}):(0,n.jsx)(o.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-700","aria-label":"开启"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block break-words text-sm font-medium",children:e.title}),(0,n.jsxs)("span",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsxs)("span",{children:["#",e.issue_number]}),(0,n.jsx)("span",{children:"活动于"}),(0,n.jsx)(tB,{timestamp:e.last_activity_at})]})]})]})},e.id))})]}):null}function sW(e){let{templates:t,loading:s,error:a,onSelect:l,onBlank:r,onRetry:i}=e;return(0,n.jsx)("main",{"data-testid":"issue-template-chooser",className:"min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8",children:(0,n.jsxs)("div",{className:"mx-auto w-full max-w-4xl",children:[(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("h3",{className:"text-base font-semibold",children:"选择 Issue 模板"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"选择最符合当前工作的模板,或从空白 Issue 开始。"})]}),a&&(0,n.jsxs)("div",{role:"alert",className:"mb-4 flex min-h-11 flex-wrap items-center gap-3 rounded-md border border-destructive/40 bg-destructive/5 px-4 py-3 text-sm text-destructive",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:a}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 sm:h-8",onClick:i,children:"重试"})]}),s&&0===t.length?(0,n.jsx)("p",{role:"status",className:"py-10 text-center text-sm text-muted-foreground",children:"正在加载 Issue 模板..."}):(0,n.jsx)("ul",{"aria-label":"Issue 模板",className:"divide-y rounded-md border bg-background",children:t.map(e=>(0,n.jsxs)("li",{className:"flex min-w-0 flex-col gap-3 px-4 py-4 sm:flex-row sm:items-center",children:[(0,n.jsx)("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border bg-muted",children:(0,n.jsx)($.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("strong",{className:"block break-words text-sm",children:e.name}),(0,n.jsx)("span",{className:"mt-1 block break-words text-sm text-muted-foreground",children:e.description})]}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 w-full shrink-0 sm:h-8 sm:w-auto",onClick:()=>l(e),children:"开始"})]},e.id))}),(0,n.jsxs)("div",{className:"mt-5 flex min-w-0 flex-col gap-3 rounded-md border border-dashed px-4 py-4 sm:flex-row sm:items-center",children:[(0,n.jsx)("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md border bg-muted",children:(0,n.jsx)(j.A,{className:"h-4 w-4","aria-hidden":"true"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("strong",{className:"block text-sm",children:"空白 Issue"}),(0,n.jsx)("span",{className:"mt-1 block text-sm text-muted-foreground",children:"不使用模板,自由填写标题和描述。"})]}),(0,n.jsx)(x.$,{type:"button",size:"sm",className:"h-11 w-full shrink-0 sm:h-8 sm:w-auto",onClick:r,children:"打开空白 Issue"})]})]})})}let sV=/!?\[[^\]]*\]\((?:https?:\/\/[^)]+)?\/api\/issues\/attachments\/[^)]+\)/gi;function sX(e){return Array.from(e.trim()).length}function sQ(e,t){try{t?window.sessionStorage.setItem(e,JSON.stringify(t)):window.sessionStorage.removeItem(e)}catch(e){}}function sZ(){var e,t,s;return null!=(s=null==(t=globalThis.crypto)||null==(e=t.randomUUID)?void 0:e.call(t))?s:"issue-draft-".concat(Date.now(),"-").concat(Math.random())}function sG(e,t){return"localapp:issues:draft:v1:".concat(encodeURIComponent(e),":").concat(encodeURIComponent(t))}function sY(e){try{var t,s;let n=JSON.parse(null!=(t=window.sessionStorage.getItem(e))?t:"null"),a=null!=(s=null==n?void 0:n.issueType)?s:null==n?void 0:n.label;return{title:"string"==typeof(null==n?void 0:n.title)?n.title:"",issueType:"feature"===a?"feature":"bug"===a?"bug":"task",labelIds:Array.isArray(null==n?void 0:n.labelIds)?n.labelIds.filter(e=>"string"==typeof e&&"bug"!==e&&"feature"!==e):[],assigneeIds:Array.isArray(null==n?void 0:n.assigneeIds)?n.assigneeIds.filter(e=>"string"==typeof e):[],milestoneId:"number"==typeof(null==n?void 0:n.milestoneId)&&Number.isSafeInteger(null==n?void 0:n.milestoneId)&&n.milestoneId>0?n.milestoneId:null}}catch(e){return{title:"",issueType:"task",labelIds:[],assigneeIds:[],milestoneId:null}}}function s0(e){try{let t=sY(e);return!!(t.title||"task"!==t.issueType||t.labelIds.length||t.assigneeIds.length||null!==t.milestoneId||window.sessionStorage.getItem("".concat(e,":body"))||window.sessionStorage.getItem("".concat(e,":body:attachments")))}catch(e){return!1}}function s1(e,t,s){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;try{t||"task"!==s||n.length>0||a.length>0||null!==l?window.sessionStorage.setItem(e,JSON.stringify({title:t,issueType:s,labelIds:n,assigneeIds:a,milestoneId:l})):window.sessionStorage.removeItem(e)}catch(e){}}function s2(e){var t;let{pagePath:s,pageName:a,user:r,onClose:i,onIssuesChanged:o,selectedIssueId:c,selectedIssueNumber:d,onIssueNavigate:u}=e,[m,p]=(0,l.useState)({kind:"list"}),[h,f]=(0,l.useState)(()=>ej(new URL(window.location.href))),[b,g]=(0,l.useState)(()=>{let e=ej(new URL(window.location.href));return tJ(e.q,e.searchIn)}),[_,T]=(0,l.useState)([]),[L,R]=(0,l.useState)([]),[D,z]=(0,l.useState)({total:0,open:0,closed:0,limit:25,offset:0}),[q,U]=(0,l.useState)(!0),[F,P]=(0,l.useState)(null),[$,M]=(0,l.useState)(null),[O,K]=(0,l.useState)(!1),[B,H]=(0,l.useState)(!1),[W,V]=(0,l.useState)(null),X=(0,l.useRef)(null),Q=(0,l.useRef)(null),Z=(0,l.useRef)(null),[G,ee]=(0,l.useState)(null),[et,es]=(0,l.useState)(""),[en,ea]=(0,l.useState)(""),[el,er]=(0,l.useState)(""),[ec,ed]=(0,l.useState)(!1),[eu,em]=(0,l.useState)([]),[ep,ef]=(0,l.useState)(!1),[ev,ey]=(0,l.useState)(!0),[ew,ek]=(0,l.useState)(null),[eS,eC]=(0,l.useState)(0),[eE,eT]=(0,l.useState)(null),[eX,eG]=(0,l.useState)([]),[ti,to]=(0,l.useState)(!1),[tc,td]=(0,l.useState)(null),[tu,tm]=(0,l.useState)(!1),[tp,th]=(0,l.useState)(0),[tf,tx]=(0,l.useState)(null),[tb,tg]=(0,l.useState)([]),[tv,tw]=(0,l.useState)(!1),[tj,tk]=(0,l.useState)(null),[tS,tC]=(0,l.useState)(0),[tE,t_]=(0,l.useState)("task"),[tT,tL]=(0,l.useState)([]),[tR,tD]=(0,l.useState)([]),[tz,tq]=(0,l.useState)(null),[tU,tP]=(0,l.useState)(sZ),[t$,tM]=(0,l.useState)(sZ),[tB,tH]=(0,l.useState)(null),[tW,tV]=(0,l.useState)(null),[tQ,tZ]=(0,l.useState)([]),[tG,tY]=(0,l.useState)(!1),[t0,t1]=(0,l.useState)(!1),[t4,t3]=(0,l.useState)(0),[t5,t8]=(0,l.useState)([]),[se,st]=(0,l.useState)(!1),[ss,sn]=(0,l.useState)(!1),[sa,sl]=(0,l.useState)(0),[sr,so]=(0,l.useState)(!1),[sd,su]=(0,l.useState)(null),[sx,sb]=(0,l.useState)([]),[sg,sv]=(0,l.useState)(!1),[sy,sw]=(0,l.useState)(!1),[sj,sN]=(0,l.useState)(!1),[sk,sS]=(0,l.useState)(0),[sA,sC]=(0,l.useState)(!1),[sE,s_]=(0,l.useState)(null),[sT,sL]=(0,l.useState)(!1),[sR,sD]=(0,l.useState)("completed"),[sz,sq]=(0,l.useState)(!1),[sU,sF]=(0,l.useState)(null),[s$,sM]=(0,l.useState)(!1),[s2,s4]=(0,l.useState)(!1),[s3,s5]=(0,l.useState)(!1),[s8,s6]=(0,l.useState)(!1),[s7,s9]=(0,l.useState)(!1),[ne,nt]=(0,l.useState)(!1),ns=r?sG(s,r.id):null,nn=ns?"".concat(ns,":").concat("create"===m.kind&&m.reference?"reference-comment:".concat(m.reference.detail.issue.id,":").concat(m.reference.commentId):"create"):null,na=s.split("/",1)[0],nl=sc(new URL(window.location.href),si),nr=(0,l.useRef)(null),ni=(0,l.useRef)(null),no=(0,l.useRef)(i),nc=(0,l.useRef)(u),nd=(0,l.useRef)(0),nu=(0,l.useRef)(null),nm=(0,l.useRef)(0),np=(0,l.useRef)(null),nh=(0,l.useRef)(null),nf=(0,l.useRef)(null),nx=(0,l.useRef)(null),nb=(0,l.useRef)(!1),ng=(0,l.useRef)(null),nv=(0,l.useRef)(null),ny=(0,l.useRef)(!1),nw=(0,l.useRef)(!1),nj=(0,l.useRef)(!1),nN=(0,l.useRef)(0),nk=(0,l.useRef)(null),nI=(0,l.useRef)(new Set),nS=(0,l.useRef)(m),nA=(0,l.useRef)(null),nC=(0,l.useRef)(h),nE=(0,l.useRef)("undefined"!=typeof document&&document.activeElement instanceof HTMLElement?document.activeElement:null);no.current=i,nc.current=u,nS.current=m,nC.current=h;let n_="edit"===m.kind?m.detail.issue.id:null;(0,l.useEffect)(()=>{let e=nA.current;if(nA.current=n_,null===e||null!==n_)return;let t=window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector('[data-testid="issue-body-card"] button[aria-label="Issue 操作"]'))?void 0:e.focus()});return()=>window.cancelAnimationFrame(t)},[n_]);let nT=(0,l.useCallback)(()=>{var e;(null==(e=nE.current)?void 0:e.isConnected)&&nE.current.focus()},[]),nL=(0,l.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"push";f(s=>{let n=function(e,t){let s={...t};for(let e of eN)"string"==typeof s[e]&&(s[e]=s[e].trim());let n={...e,...s};return"open"===n.status&&(n.reason=""),Object.keys(s).some(t=>"offset"!==t&&e[t]!==n[t])&&(n.offset=0),n}(s,e),a=function(e,t){let s=new URL(e.href);for(let e of(s.searchParams.set("localappIssues","1"),Object.values(eg)))s.searchParams.delete(e);for(let[e,n,a]of[[eg.q,t.q,eh.q],[eg.searchIn,t.searchIn,eh.searchIn],[eg.status,t.status,eh.status],[eg.label,t.label,eh.label],[eg.issueType,t.issueType,eh.issueType],[eg.author,t.author,eh.author],[eg.participant,t.participant,eh.participant],[eg.assignee,t.assignee,eh.assignee],[eg.milestone,t.milestone,eh.milestone],[eg.reason,"closed"===t.status?t.reason:"",eh.reason],[eg.subscribed,+!!t.subscribed,0],[eg.mentioned,+!!t.mentioned,0],[eg.locked,t.locked,eh.locked],[eg.sort,t.sort,eh.sort],[eg.direction,t.direction,eh.direction],[eg.offset,t.offset,eh.offset]])n!==a&&""!==n&&s.searchParams.set(e,String(n));return s}(new URL(window.location.href),n);return a.href!==window.location.href&&window.history["push"===t?"pushState":"replaceState"](null,"",a),n})},[]);(0,l.useEffect)(()=>{let e=()=>{let e=ej(new URL(window.location.href));f(e),g(tJ(e.q,e.searchIn))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let nR=(0,l.useCallback)(()=>{var e,t;let s=null==(e=nr.current)?void 0:e.querySelector('[data-localapp-issue-attachment-queue][aria-busy="true"]');if(s){s.focus(),null==(t=s.scrollIntoView)||t.call(s,{block:"nearest"});return}nT(),no.current()},[nT]),nD=(0,l.useCallback)(function(e,t){var n,a,l;let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];M(null),eT(null);let o=r?sG(s,r.id)+":create":null,c=o?sY(o):{title:"",issueType:"task",labelIds:[],assigneeIds:[],milestoneId:null},d=!!o&&s0(o);ed(d);let u=t&&!d?t.labels.filter(e=>t5.some(t=>t.id===e)):[],m=t&&!d?t.labels.filter(e=>!t5.some(t=>t.id===e)):[];es(d?c.title:null!=(n=null==t?void 0:t.titlePrefix)?n:"");let h=d?"":null!=(a=null==t?void 0:t.body)?a:"";er(h),ea(h),t_(d?c.issueType:null!=(l=null==t?void 0:t.type)?l:"task"),tL(d?c.labelIds:u),tD(c.assigneeIds),tq(c.milestoneId),m.length>0&&eT("模板中的标签已不可用:".concat(m.join("、"))),tP(sZ()),p({kind:"create",...void 0===e?{}:{parentIssueId:e},...i?{returnToTemplates:!0}:{}})},[t5,s,r]),nz=(0,l.useCallback)(()=>{let e=r?"".concat(sG(s,r.id),":create"):null;return e&&s0(e)?void nD():!ep||ev||ew||eu.length>0?void p({kind:"templates"}):void nD()},[eu.length,ew,ep,ev,s,nD,r]);(0,l.useEffect)(()=>{let e=new AbortController;return ey(!0),ek(null),eR(s,e.signal).then(e=>{em(e),ef(!0)}).catch(t=>{e.signal.aborted||(ek(t instanceof Error?t.message:"Issue 模板暂不可用"),ef(!0))}).finally(()=>{e.signal.aborted||ey(!1)}),()=>e.abort()},[eS,s]),(0,l.useEffect)(()=>{if(!r){eG([]),to(!1),td(null),tx(null);return}let e=new AbortController;return to(!0),td(null),eD(s,e.signal).then(eG).catch(t=>{e.signal.aborted||td(t instanceof Error?t.message:"保存视图加载失败")}).finally(()=>{e.signal.aborted||to(!1)}),()=>e.abort()},[s,tp,null==r?void 0:r.id]),(0,l.useEffect)(()=>{var e,t;null!==tf&&eX.some(e=>e.id===tf)||tx(null!=(t=null==(e=eX.find(e=>eb(e.query,h)))?void 0:e.id)?t:null)},[tf,h,eX]),(0,l.useEffect)(()=>{if("create"!==m.kind||!et.trim()||Array.from(en).length<100){tg([]),tw(!1),tk(null);return}let e=new AbortController;tg([]),tk(null),tw(!0);let t=window.setTimeout(()=>{eM(s,et.trim(),en,e.signal).then(tg).catch(t=>{e.signal.aborted||t instanceof Error&&"AbortError"===t.name||tk("重复项建议暂不可用")}).finally(()=>{e.signal.aborted||tw(!1)})},400);return()=>{window.clearTimeout(t),e.abort()}},[en,et,s,tS,m.kind]),(0,l.useEffect)(()=>{"create"===m.kind&&nn&&s1(nn,et,tE,tT,tR,tz)},[tR,tE,tT,tz,et,ns,m.kind]),(0,l.useEffect)(()=>{"create"===m.kind&&sg&&null!==tz&&!sx.some(e=>e.id===tz)&&tq(null)},[tz,sx,sg,m.kind]);let nq=(0,l.useCallback)(async e=>{var t;let n=++nd.current;null==(t=nu.current)||t.abort();let a=new AbortController;nu.current=a,U(!0),P(null);try{let t=await e$(s,e,a.signal);if(nd.current!==n)return;T(t.data),R(t.pinned),z(t.meta)}catch(e){if(nd.current!==n||e instanceof DOMException&&"AbortError"===e.name)return;P(e instanceof Error?e.message:"Issue 服务暂不可用")}finally{nd.current===n&&U(!1)}},[s]);(0,l.useEffect)(()=>{if("undefined"==typeof EventSource)return;let e=new URLSearchParams({pagePath:s}),t=null,n=!0,a=e=>{try{var t;let n=JSON.parse(e.data);if((null==(t=n.data)?void 0:t.pagePath)!==s)return;let a="number"==typeof n.data.issueId?n.data.issueId:null;nI.current.add(a),null!==nk.current&&window.clearTimeout(nk.current),nk.current=window.setTimeout(()=>{nk.current=null;let e=new Set(nI.current);nI.current.clear(),nq(nC.current);let t=nS.current;if("edit"===t.kind){(e.has(null)||e.has(t.detail.issue.id))&&s4(!0);return}if("detail"!==t.kind||!e.has(null)&&!e.has(t.detail.issue.id))return;let n=t.detail.issue.id;eQ(s,n).then(e=>{let s=e.issue.updated_at!==t.detail.issue.updated_at||e.timeline.length!==t.detail.timeline.length;p(t=>"detail"===t.kind&&t.detail.issue.id===n?{kind:"detail",detail:e}:t),s&&nt(!0),s4(!1)}).then(()=>s6(!1)).catch(()=>{s6(!0),M("无法同步最新 Issue,当前内容可能已过期")})},120)}catch(e){}},l=()=>{null==t||t.close(),t=null},r=l=>{if("hidden"===document.visibilityState||!n||t||((t=new EventSource("/api/issues/events?".concat(e.toString()))).addEventListener("issue:changed",a),!l))return;nq(nC.current);let r=nS.current;if("detail"===r.kind){let e=r.detail.issue.id;eQ(s,e).then(t=>{p(s=>"detail"===s.kind&&s.detail.issue.id===e?{kind:"detail",detail:t}:s),s6(!1)}).catch(()=>s6(!0))}},i=()=>"hidden"===document.visibilityState?l():r(!0),o=()=>{n=!1,l()},c=()=>{n=!0,r(!0)};return r(!1),document.addEventListener("visibilitychange",i),window.addEventListener("blur",o),window.addEventListener("focus",c),window.addEventListener("pagehide",o),window.addEventListener("pageshow",c),()=>{document.removeEventListener("visibilitychange",i),window.removeEventListener("blur",o),window.removeEventListener("focus",c),window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",c),l(),null!==nk.current&&window.clearTimeout(nk.current),nI.current.clear()}},[nq,s]),(0,l.useEffect)(()=>(nq(h),()=>{var e;return null==(e=nu.current)?void 0:e.abort()}),[nq,h]),(0,l.useEffect)(()=>{if(!r){tY(!1),t1(!1);return}let e=new AbortController,t=!0;return tY(!1),t1(!0),eI(()=>eL(e.signal),e.signal).then(e=>{t&&(tZ(e),tY(!1))}).catch(e=>{!(e instanceof Error&&"AbortError"===e.name)&&t&&tY(!0)}).finally(()=>{t&&t1(!1)}),()=>{t=!1,e.abort()}},[null==r?void 0:r.id,t4]),(0,l.useEffect)(()=>{let e=new AbortController,t=!0;return st(!1),sn(!0),eI(()=>eY(s,e.signal),e.signal).then(e=>{t&&(t8(e),st(!1))}).catch(e=>{t&&!(e instanceof Error&&"AbortError"===e.name)&&st(!0)}).finally(()=>{t&&sn(!1)}),()=>{t=!1,e.abort(new DOMException("Superseded","AbortError"))}},[sa,s]),(0,l.useEffect)(()=>{let e=new AbortController,t=!0;return sw(!1),sN(!0),eI(()=>e1(s,e.signal),e.signal).then(e=>{t&&(sb(e),sv(!0),sw(!1))}).catch(e=>{t&&!(e instanceof Error&&"AbortError"===e.name)&&sw(!0)}).finally(()=>{t&&sN(!1)}),()=>{t=!1,e.abort(new DOMException("Superseded","AbortError"))}},[sk,s]),(0,l.useEffect)(()=>{if(b.trim()===tJ(h.q,h.searchIn))return;let e=[...r?[{id:r.id,name:r.name,displayName:r.name}]:[],...tQ];if(tO(b,b.length,{currentUserId:null==r?void 0:r.id,labels:t5,users:e}).items.length>0)return;let t=window.setTimeout(()=>{nL(tK(b,{currentUserId:null==r?void 0:r.id,labels:t5,milestones:sx}),"replace")},250);return()=>window.clearTimeout(t)},[nL,t5,sx,tQ,h.q,h.searchIn,b,r]),(0,l.useEffect)(()=>{if("list"!==m.kind||q||null===np.current)return;let e=np.current,t=window.requestAnimationFrame(()=>{var t;let s=document.querySelector('[data-testid="issue-row-'.concat(e,'"] a'));null==(t=null!=s?s:ni.current)||t.focus(),np.current=null});return()=>window.cancelAnimationFrame(t)},[_,q,m.kind]),(0,l.useEffect)(()=>{var e;null==(e=nr.current)||e.focus();let t=e=>{var t,s,n,a,l;let i=e.target,o=i instanceof Element&&i.closest('[role="dialog"]')!==nr.current;if(o)return;if("Escape"===e.key){e.preventDefault(),nR();return}let c=i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName));if("/"===e.key&&(e.metaKey||e.ctrlKey)&&"list"===m.kind&&!c){e.preventDefault(),null==(s=ni.current)||s.focus();return}if("/"===e.key&&"list"===m.kind&&!c){e.preventDefault(),null==(n=ni.current)||n.focus();return}if("c"===e.key.toLowerCase()&&"list"===m.kind&&r&&!c&&!e.metaKey&&!e.ctrlKey&&!e.altKey){e.preventDefault(),nz();return}if("r"===e.key.toLowerCase()&&"detail"===m.kind&&r&&(null==(t=nr.current)?void 0:t.querySelector("[data-localapp-issue-comment-composer]"))&&!c&&!o&&!e.metaKey&&!e.ctrlKey&&!e.altKey){e.preventDefault(),(()=>{var e,t,s,n;let a=null==(e=nr.current)?void 0:e.querySelector("[data-localapp-issue-comment-composer] textarea");null==a||null==(n=a.scrollIntoView)||n.call(a,{block:"center",behavior:(null==(t=(s=window).matchMedia)?void 0:t.call(s,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth"}),window.requestAnimationFrame(()=>null==a?void 0:a.focus())})();return}let d={u:"按创建者筛选",l:"按标签筛选",m:"按里程碑筛选",a:"按负责人筛选"}[e.key.toLowerCase()];if(d&&"list"===m.kind&&!c&&!o&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&nr.current){let t=nr.current.querySelector('select[aria-label="'.concat(d,'"]'));if(t){e.preventDefault();let s=t.closest("#localapp-issue-advanced-filters");(null==s?void 0:s.classList.contains("hidden"))&&(null==(a=nr.current.querySelector('[aria-controls="localapp-issue-advanced-filters"]'))||a.click()),window.requestAnimationFrame(()=>t.focus());return}}if("o"===e.key.toLowerCase()&&"list"===m.kind&&!c&&!o&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&document.activeElement instanceof HTMLAnchorElement&&document.activeElement.matches("[data-localapp-issue-link]")){e.preventDefault(),document.activeElement.click();return}let u=e.key.toLowerCase(),p="j"===u||"ArrowDown"===e.key?1:"k"===u||"ArrowUp"===e.key?-1:0;if(0!==p&&"list"===m.kind&&!c&&!o&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&nr.current){let t=Array.from(nr.current.querySelectorAll("[data-localapp-issue-link]")),s=t.indexOf(document.activeElement),n="ArrowDown"===e.key||"ArrowUp"===e.key;if(t.length>0&&(!n||t.includes(document.activeElement))){e.preventDefault();let n=s<0?p>0?0:t.length-1:(s+p+t.length)%t.length;null==(l=t[n])||l.focus();return}}if("ArrowLeft"===e.key&&e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&"list"!==m.kind&&!c&&!o){e.preventDefault(),nV();return}if("Tab"!==e.key||!nr.current)return;let h=Array.from(nr.current.querySelectorAll("button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])")).filter(e=>(function(e,t){for(let s=e;s&&!s.hidden&&"true"!==s.getAttribute("aria-hidden");s=s.parentElement){let e=window.getComputedStyle(s);if("none"===e.display||"hidden"===e.visibility)break;if(s===t)return!0}return!1})(e,nr.current));if(!h.length){e.preventDefault(),nr.current.focus();return}let f=h[0],x=h[h.length-1];e.shiftKey&&(document.activeElement===f||document.activeElement===nr.current)?(e.preventDefault(),x.focus()):e.shiftKey||document.activeElement!==x&&document.activeElement!==nr.current||(e.preventDefault(),f.focus())};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t),nT()}},[nz,nR,nT,r,m.kind]);let nU=(0,l.useCallback)(async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=++nm.current;M(null),s6(!1),nt(!1),ee(null),p({kind:"detail-loading",issueId:e,lookupByNumber:n});try{let t=await (n?eZ(s,e):eQ(s,e));if(nm.current!==a)return;if(n){var l;null==(l=nc.current)||l.call(nc,t.issue.id,"replace");let e=nf.current;if(nf.current=null,null!==e){let s=sh(new URL(window.location.href),t.issue.id,e);window.history.replaceState(window.history.state,"",s)}}ee(null),tM(sZ()),p({kind:"detail",detail:t})}catch(e){if(nm.current!==a)return;ee(null!=t?t:null),M(e instanceof Error?e.message:"Issue 服务暂不可用")}},[s]);(0,l.useEffect)(()=>{if(void 0!==c){if(null===c){if(null!=d)return;++nm.current,p(e=>"detail"===e.kind||"detail-loading"===e.kind||"edit"===e.kind?{kind:"list"}:e);return}("detail"===m.kind||"edit"===m.kind?m.detail.issue.id:"detail-loading"!==m.kind||m.lookupByNumber?null:m.issueId)!==c&&nU(c)}},[nU,c,d,m]),(0,l.useEffect)(()=>{null!=d&&("detail"===m.kind||"edit"===m.kind?m.detail.issue.issue_number:"detail-loading"===m.kind&&m.lookupByNumber?m.issueId:null)!==d&&nU(d,void 0,!0)},[nU,d,m]);let nF=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;nf.current=t,nU(e,void 0,!0)},nP=e=>sm(new URL(window.location.href),e),n$=e=>{let t=nP(e);return"".concat(t.pathname).concat(t.search).concat(t.hash)},nM=e=>{let t=sp(new URL(window.location.href),e);return"".concat(t.pathname).concat(t.search).concat(t.hash)},nO=(e,t)=>sh(new URL(window.location.href),e,t),nK=(e,t)=>{let s=nO(e,t);return"".concat(s.pathname).concat(s.search).concat(s.hash)},nJ=async e=>{M(null);try{await sf(nP(e).href),sM(!0)}catch(e){sM(!1),M("无法复制 Issue 链接,请从浏览器地址栏复制")}},nB=async e=>{p({kind:"detail",detail:await eQ(s,e)}),s6(!1)},nH=async()=>{let e=nS.current;if(!s7&&"detail"===e.kind){s9(!0);try{await nB(e.detail.issue.id),M(null)}catch(e){s6(!0),M("无法同步最新 Issue,当前内容可能已过期")}finally{s9(!1)}}},nW=async()=>{let e=nS.current;if(!s3&&"edit"===e.kind){s5(!0);try{let t=await eQ(s,e.detail.issue.id);if(ns){sQ("".concat(ns,":edit:").concat(e.detail.issue.id,":meta"),null);try{window.sessionStorage.removeItem("".concat(ns,":edit:").concat(e.detail.issue.id,":body"))}catch(e){}}p({kind:"detail",detail:t}),s4(!1)}catch(e){M("无法加载最新 Issue")}finally{s5(!1)}}},nV=e=>{let t=nS.current;"create"===t.kind&&(ny.current=!0),("detail"===t.kind||"edit"===t.kind)&&null===np.current&&(np.current=t.detail.issue.id),++nm.current,e&&nL({status:e}),p({kind:"list"}),nt(!1),null==u||u(null)};(0,l.useEffect)(()=>{if("list"!==m.kind||!ny.current)return;ny.current=!1;let e=window.requestAnimationFrame(()=>{var e;return null==(e=nv.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[m.kind]),(0,l.useEffect)(()=>{if("list"!==m.kind||q||F||!nw.current)return;nw.current=!1;let e=window.requestAnimationFrame(()=>{var e;return null==(e=ni.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[F,q,m.kind]);let nX=ss||t0||sj;(0,l.useEffect)(()=>{if(nj.current&&!nX&&!se&&!tG&&!sy){nj.current=!1;let e=nS.current,t="list"===e.kind?null:"create"===e.kind?"#issue-title":"edit"===e.kind?"#issue-edit-title":"[data-localapp-issue-title]";window.requestAnimationFrame(()=>{var e;return null==(e=t?document.querySelector(t):ni.current)?void 0:e.focus()})}},[nX,se,sy,tG]);let nQ=null!=(t=eX.find(e=>e.id===tf))?t:null,nZ=!!(nQ&&!eb(nQ.query,h)),nG=async(e,t)=>{tm(!0),td(null);try{let n=await eq(s,e,t,h);eG(e=>[...e,n]),tx(n.id)}finally{tm(!1)}},nY=async(e,t)=>{tm(!0),td(null);try{let n=await eU(s,e,t);eG(t=>t.map(t=>t.id===e?n:t))}finally{tm(!1)}},n0=async e=>{tm(!0),td(null);try{let t=await eF(s,e);eG(e=>[...e,t])}finally{tm(!1)}},n1=async e=>{tm(!0),td(null);try{await eP(s,e),eG(t=>t.filter(t=>t.id!==e)),tf===e&&tx(null)}finally{tm(!1)}},n2=async e=>{let{body:t,attachmentIds:n,draftId:a}=e;if(et.trim()){M(null);try{let e=await e9({pagePath:s,title:et.trim(),description:t,issueType:tE,draftId:a,attachmentIds:n,...(null==r?void 0:r.id)===na?{labelIds:tT,assigneeIds:tR,...null===tz?{}:{milestoneId:tz},..."create"===m.kind&&void 0!==m.parentIssueId?{parentIssueId:m.parentIssueId}:{}}:{}});es(""),er(""),ea(""),ed(!1),t_("task"),tL([]),tD([]),tq(null),ns&&s1(null!=nn?nn:"".concat(ns,":create"),"","task",[],[],null),tP(sZ()),g(""),nL({...eh},"replace"),null==o||o(),null==u||u(e.id),await nU(e.id,e)}catch(e){throw e}}},n4=async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.draftId?"composer":"workspace";M(null);try{let a=void 0!==t.title||void 0!==t.description;await te(s,e.issue.id,{...t,...a&&void 0===t.expectedUpdatedAt?{expectedUpdatedAt:e.issue.updated_at}:{}}),await Promise.all([nB(e.issue.id),nq(h)]),n&&(null==o||o())}catch(e){throw e instanceof eA&&s4(!0),"workspace"===a&&M(e instanceof Error?e.message:"Issue 服务暂不可用"),e}},n3=async(e,t)=>{M(null);try{let n=await tt(s,e.issue.id,t),a=new Set(e.timeline.flatMap(e=>"comment"===e.kind?[e.comment.id]:[])),l=n.timeline.find(e=>"comment"===e.kind&&!a.has(e.comment.id));if((null==l?void 0:l.kind)==="comment"){let t=sh(new URL(window.location.href),e.issue.id,l.comment.id);window.history.replaceState(window.history.state,"",t)}tM(sZ()),p({kind:"detail",detail:n}),await nq(h),t.statusAction&&(null==o||o())}catch(e){throw e}},n5="detail"===m.kind||"edit"===m.kind?m.detail:null,n8=sX(et),n6=n8>256,n7=n5?sX(n5.issue.title):0,n9=n7>256;(0,l.useEffect)(()=>{if(tW)return;if("list"===m.kind||"create"===m.kind||"detail-loading"===m.kind){ng.current=null;return}if("detail"!==m.kind||!n5||ng.current===n5.issue.id||(ng.current=n5.issue.id,nl))return;let e=window.requestAnimationFrame(()=>{var e;return null==(e=document.querySelector("[data-localapp-issue-title]"))?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[null==n5?void 0:n5.issue.id,tW,nl,m.kind]),(0,l.useEffect)(()=>{if("detail"!==m.kind||null===nh.current)return;let e=nh.current,t=0,s=0,n=()=>{var a,l;if(null==(a=nr.current)?void 0:a.querySelector('[role="alertdialog"]')){t++<20&&(s=window.setTimeout(n,30));return}let r=null==(l=nr.current)?void 0:l.querySelector('[data-localapp-issue-reference="'.concat(e,'"]'));if(null==r||r.focus(),r&&document.activeElement===r){nh.current=null;return}t++<10&&(s=window.setTimeout(n,30))};return s=window.setTimeout(n,0),()=>window.clearTimeout(s)},[null==n5?void 0:n5.issue.description,m.kind]),(0,l.useEffect)(()=>{if(sT||!nb.current)return;nb.current=!1;let e=window.requestAnimationFrame(()=>{var e;return null==(e=nx.current)?void 0:e.focus()});return()=>window.cancelAnimationFrame(e)},[null==n5?void 0:n5.issue.status,sT]);let ae=!!(n5&&r&&(r.id===n5.issue.reporter_id||r.id===na)),at=!!(n5&&(null==r?void 0:r.id)===na),as=n5&&ns?"".concat(ns,":edit:").concat(n5.issue.id,":meta"):null,an=n5&&ns?"".concat(ns,":edit:").concat(n5.issue.id,":body"):void 0,aa=e=>{if(as&&sQ(as,null),an)try{window.sessionStorage.removeItem(an)}catch(e){}ty(s,an),s4(!1),p({kind:"detail",detail:e.originalDetail})},al=!!(r&&r.id===na),ar="edit"===m.kind?m.detail.attachments.filter(e=>e.issue_id===m.detail.issue.id&&null===e.comment_id&&!m.removedAttachmentIds.includes(e.id)):[],ai="edit"===m.kind&&m.removedAttachmentIds.length>0?(()=>{let e=m.removedAttachmentIds.at(-1),t=m.originalDetail.attachments.find(t=>t.id===e);return t?{id:e,url:t.url}:null})():null,ao=Array.from(new Map([...r?[{id:r.id,name:r.name,displayName:r.name,avatarUrl:null}]:[],...tQ].map(e=>[e.id,e])).values()),ac=ao.filter(e=>e.id),ad=async e=>{sq(!0),M(null);try{let t=await e();p({kind:"detail",detail:t}),await nq(h)}catch(e){throw e}finally{sq(!1)}},au=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"completed";nb.current=!0,sL(!0);try{await n4(e,"open"===e.issue.status?{status:"closed",stateReason:t}:{status:"open",stateReason:null},!0)}catch(e){}finally{sL(!1)}},am=n5?"Issue #".concat(n5.issue.issue_number," \xb7 ").concat(n5.issue.title):null,ap="templates"===m.kind?"新建 Issue":"create"===m.kind?void 0===m.parentIssueId?"新建 Issue":"新建 Sub-issue":"labels"===m.kind?"标签":"milestones"===m.kind?"里程碑":"detail-loading"===m.kind?"Issue #".concat(m.issueId):null!=am?am:"Issues";return(0,n.jsxs)("div",{"data-localapp-issues-layer":!0,className:"absolute inset-0 z-50 flex items-center justify-center p-0 sm:p-2",children:[(0,n.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-black/45","aria-hidden":"true"}),(0,n.jsxs)("div",{ref:nr,role:"dialog","aria-modal":"true","aria-labelledby":"issues-dialog-title",tabIndex:-1,"data-localapp-issues-workspace":!0,className:"relative flex h-full w-full flex-col overflow-hidden bg-card shadow-2xl outline-none sm:rounded-lg sm:border",children:[(0,n.jsxs)("header",{className:"flex min-h-14 items-center gap-3 border-b px-4 py-3 sm:px-5",children:["list"!==m.kind&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"create"===m.kind&&void 0!==m.parentIssueId?"返回父 Issue":"create"===m.kind&&m.returnToTemplates?"返回模板选择":"返回 Issue 列表","aria-keyshortcuts":"Alt+ArrowLeft",onClick:()=>{"create"===m.kind&&void 0!==m.parentIssueId?(null==u||u(m.parentIssueId),nU(m.parentIssueId)):"create"===m.kind&&m.returnToTemplates?p({kind:"templates"}):nV()},children:(0,n.jsx)(v.A,{className:"h-4 w-4"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h2",{id:"issues-dialog-title",title:null!=am?am:void 0,className:"min-w-0 truncate text-sm font-semibold",children:ap}),(0,n.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:a})]}),"list"===m.kind&&(null==r?void 0:r.id)===na&&(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 gap-1.5 sm:h-8","aria-label":"管理 Issue 里程碑",onClick:()=>{s_(null),p({kind:"milestones"}),e1(s).then(sb).catch(e=>s_(e instanceof Error?e.message:"里程碑加载失败"))},children:[(0,n.jsx)(y.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden md:inline",children:"里程碑"})]}),"list"===m.kind&&(null==r?void 0:r.id)===na&&(0,n.jsxs)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 gap-1.5 sm:h-8","aria-label":"管理 Issue 标签",onClick:()=>{su(null),p({kind:"labels"})},children:[(0,n.jsx)(w.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"标签"})]}),"list"===m.kind&&r&&(0,n.jsxs)(x.$,{ref:nv,type:"button",size:"sm",className:"h-11 shrink-0 gap-1.5 sm:h-8","aria-label":"新建 Issue","aria-keyshortcuts":"C",onClick:nz,children:[(0,n.jsx)(j.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"新建 Issue"})]}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-8 sm:w-8","aria-label":"关闭 Issue 面板","aria-keyshortcuts":"Escape",onClick:nR,children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),(se||tG||sy)&&!("list"===m.kind&&F&&0===_.length)&&(0,n.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center justify-between gap-3 border-b border-amber-500/30 bg-amber-500/10 px-5 py-2.5 text-sm",children:[(0,n.jsx)("span",{children:Number(se)+Number(tG)+Number(sy)>1?"元数据目录加载失败,正在显示可用的本地信息":se?"标签目录暂不可用":tG?"负责人目录加载失败,正在显示已知用户":"里程碑目录加载失败,正在显示已知里程碑"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-7",disabled:nX,"aria-label":Number(se)+Number(tG)+Number(sy)>1?"重试元数据目录":se?"重试标签目录":tG?"重试负责人目录":"重试里程碑目录",onClick:()=>{nj.current=!0,se&&sl(e=>e+1),tG&&t3(e=>e+1),sy&&sS(e=>e+1)},children:nX?"正在重试...":"重试"})]}),$&&"list"!==m.kind&&"detail-loading"!==m.kind&&(0,n.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center justify-between gap-3 border-b border-destructive/20 bg-destructive/10 px-5 py-2.5 text-sm text-destructive",children:[(0,n.jsx)("span",{children:$}),s8&&(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-7",disabled:s7,onClick:()=>void nH(),children:s7?"正在同步...":"重新同步"})]}),ne&&"detail"===m.kind&&(0,n.jsxs)("div",{role:"status","aria-label":"Issue 协作更新",className:"flex min-h-11 items-center gap-3 border-b bg-muted/60 px-5 py-2 text-sm",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:"已同步最新协作活动"}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 shrink-0 sm:h-7 sm:w-7","aria-label":"关闭协作更新提示",onClick:()=>nt(!1),children:(0,n.jsx)(N.A,{className:"h-4 w-4"})})]}),s2&&"edit"===m.kind&&(0,n.jsxs)("div",{role:"status",className:"flex flex-wrap items-center justify-between gap-3 border-b bg-muted px-5 py-2.5 text-sm",children:[(0,n.jsx)("span",{children:"此 Issue 有新变更,你的编辑内容尚未被覆盖。"}),(0,n.jsx)(x.$,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 sm:h-8",disabled:s3,onClick:()=>{nW()},children:s3?"正在加载...":"放弃草稿并加载最新"})]}),"list"===m.kind&&(0,n.jsx)(t2,{currentUserId:null==r?void 0:r.id,error:F,issues:_,pinnedIssues:L,labels:t5,milestones:sx,users:ao,loading:q,meta:D,query:h,searchInput:b,searchInputRef:ni,onOpenIssue:e=>{np.current=e.id,null==u||u(e.id),nU(e.id,e)},getIssueHref:e=>n$(e.id),onQueryChange:e=>nL(e),onReset:()=>{g(""),nL({q:"",searchIn:"",label:"",author:"",participant:"",assignee:"",milestone:"",subscribed:!1,mentioned:!1,locked:"",offset:0})},onRetry:()=>{nw.current=!0,nq(h)},onSearchInputChange:g,onSubmitSearch:()=>{var e;let t=tK(b,{currentUserId:null==r?void 0:r.id,labels:t5,milestones:sx});g(tJ(t.q,null!=(e=t.searchIn)?e:"")),nL(t)},savedViews:eX,savedViewsLoading:ti,savedViewsError:tc,savedViewsSaving:tu,activeSavedViewId:tf,savedViewDirty:nZ,onApplySavedView:e=>{let t=ex(e.query);tx(e.id),g(tJ(t.q,t.searchIn)),nL(t)},onCreateSavedView:nG,onUpdateSavedView:nY,onCopySavedView:n0,onDeleteSavedView:n1,onRetrySavedViews:()=>th(e=>e+1),onLeaveSavedView:()=>tx(null),canBulkManage:!!(r&&r.id===s.split("/",1)[0]),onBulkStatus:async(e,t)=>{let n=await Promise.allSettled(e.map(e=>te(s,e,{status:t}))),a=e.filter((e,t)=>"rejected"===n[t].status);return await nq(h),n.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:n.length-a.length,failedIds:a}},onBulkIssueType:async(e,t)=>{let n=await Promise.allSettled(e.map(e=>te(s,e,{issueType:t}))),a=e.filter((e,t)=>"rejected"===n[t].status);return await nq(h),n.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:n.length-a.length,failedIds:a}},onBulkLabel:async(e,t,n)=>{let a=await Promise.allSettled(e.map(e=>{var a,l;let r=_.find(t=>t.id===e),i=null!=(l=null==r||null==(a=r.labels)?void 0:a.map(e=>e.id))?l:[];return e3(s,e,n?Array.from(new Set([...i,t])):i.filter(e=>e!==t))})),l=e.filter((e,t)=>"rejected"===a[t].status);return await nq(h),a.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:a.length-l.length,failedIds:l}},onBulkAssignee:async(e,t,n)=>{let a=await Promise.allSettled(e.map(e=>{var a,l;let r=null!=(l=null==(a=_.find(t=>t.id===e))?void 0:a.assignee_ids)?l:[];return e5(s,e,n?Array.from(new Set([...r,t])):r.filter(e=>e!==t))})),l=e.filter((e,t)=>"rejected"===a[t].status);return await nq(h),a.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:a.length-l.length,failedIds:l}},onBulkMilestone:async(e,t)=>{let n=await Promise.allSettled(e.map(e=>e8(s,e,t))),a=e.filter((e,t)=>"rejected"===n[t].status);return await nq(h),n.some(e=>"fulfilled"===e.status)&&(null==o||o()),{succeeded:n.length-a.length,failedIds:a}}}),"labels"===m.kind&&(0,n.jsx)(tI,{labels:t5,saving:sr,error:sd,onCreate:async e=>{so(!0),su(null);try{await e_("/api/issues/labels",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:s,...e})}),t8(await eY(s))}catch(e){throw su(e instanceof Error?e.message:"标签保存失败"),e}finally{so(!1)}},onUpdate:async(e,t)=>{so(!0),su(null);try{await e_("/api/issues/labels/".concat(encodeURIComponent(e)),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:s,...t})}),t8(await eY(s))}catch(e){throw su(e instanceof Error?e.message:"标签保存失败"),e}finally{so(!1)}},onDelete:async e=>{so(!0),su(null);try{await e0(s,e),t8(await eY(s)),await nq(h)}catch(e){throw su(e instanceof Error?e.message:"标签删除失败"),e}finally{so(!1)}}}),"milestones"===m.kind&&(0,n.jsx)(tA,{milestones:sx,saving:sA,error:sE,onCreate:async e=>{sC(!0),s_(null);try{await e_("/api/issues/milestones",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:s,...e})}),sb(await e1(s))}catch(e){throw s_(e instanceof Error?e.message:"里程碑保存失败"),e}finally{sC(!1)}},onUpdate:async(e,t)=>{sC(!0),s_(null);try{await e_("/api/issues/milestones/".concat(e),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:s,...t})}),sb(await e1(s))}catch(e){throw s_(e instanceof Error?e.message:"里程碑保存失败"),e}finally{sC(!1)}},onDelete:async e=>{sC(!0),s_(null);try{await e2(s,e),sb(await e1(s));let t=h.milestone===String(e)?{...h,milestone:"none",offset:0}:h;t!==h&&nL({milestone:"none"}),await nq(t)}catch(e){throw s_(e instanceof Error?e.message:"里程碑删除失败"),e}finally{sC(!1)}}}),"detail-loading"===m.kind&&($?(0,n.jsx)(sB,{message:$,onRetry:()=>void nU(m.issueId,null!=G?G:void 0,m.lookupByNumber),onBack:()=>nV()}):(0,n.jsx)(sJ,{})),n5&&("detail"===m.kind||"edit"===m.kind)&&(0,n.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:[O&&(0,n.jsxs)("div",{role:"alertdialog","aria-label":"删除 Issue 确认","aria-describedby":"delete-issue-description",onKeyDown:e=>{if("Escape"!==e.key||B){if("Tab"===e.key){let t=Q.current,s=Z.current;t&&s&&e.shiftKey&&document.activeElement===t?(e.preventDefault(),s.focus()):t&&s&&!e.shiftKey&&document.activeElement===s&&(e.preventDefault(),t.focus())}}else e.preventDefault(),K(!1),V(null),window.requestAnimationFrame(()=>{var e;return null==(e=X.current)?void 0:e.focus()})},className:"mb-4 rounded-md border border-destructive/30 bg-destructive/5 p-4",children:[(0,n.jsx)("p",{className:"font-medium",children:"确定永久删除此 Issue 吗?"}),(0,n.jsx)("p",{id:"delete-issue-description",className:"mt-1 text-sm text-muted-foreground",children:"评论、编辑历史、表态和附件都将被永久删除,此操作无法撤销。"}),W&&(0,n.jsx)("p",{role:"alert",className:"mt-3 text-sm text-destructive",children:W}),(0,n.jsxs)("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[(0,n.jsx)(x.$,{ref:Q,type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",disabled:B,onClick:()=>{K(!1),V(null),window.requestAnimationFrame(()=>{var e;return null==(e=X.current)?void 0:e.focus()})},children:"取消删除"}),(0,n.jsx)(x.$,{ref:Z,type:"button",variant:"destructive",size:"sm",className:"h-11 sm:h-8",disabled:B,onClick:()=>{H(!0),V(null),tr(s,n5.issue.id).then(async()=>{K(!1),nV(),await nq(h),null==o||o()}).catch(e=>V(e instanceof Error?e.message:"Issue 服务暂不可用")).finally(()=>H(!1))},children:"确认删除 Issue"})]})]}),"edit"===m.kind?(0,n.jsxs)("div",{className:"space-y-4",children:[m.restoredDraft&&(0,n.jsxs)("div",{role:"status",className:"flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{children:"已恢复上次未完成的编辑"}),(0,n.jsx)(J,{triggerLabel:"丢弃已恢复草稿",onConfirm:()=>aa(m),focusAfterConfirm:()=>{var e;return null==(e=document.querySelector("[data-localapp-issue-title]"))?void 0:e.focus()}})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsx)(E.J,{htmlFor:"issue-edit-title",children:"Issue 标题"}),(0,n.jsxs)("span",{className:"text-xs ".concat(n9?"text-destructive":"text-muted-foreground"),children:[n7," / ",256]})]}),(0,n.jsx)(C.p,{id:"issue-edit-title","aria-label":"Issue 标题","aria-invalid":n9||void 0,"aria-describedby":n9?"issue-edit-title-error":void 0,className:"h-11 sm:h-10",value:n5.issue.title,onChange:e=>{var t;let s=e.target.value;as&&sQ(as,{title:s,issueType:null!=(t=n5.issue.issue_type)?t:n5.issue.label,expectedUpdatedAt:m.expectedUpdatedAt}),p({...m,detail:{...n5,issue:{...n5.issue,title:s}}})}}),n9&&(0,n.jsx)("p",{id:"issue-edit-title-error",role:"alert",className:"text-sm text-destructive",children:"Issue 标题不能超过 256 个字符"})]}),al&&(0,n.jsxs)("fieldset",{className:"space-y-1.5",children:[(0,n.jsx)("legend",{className:"text-sm font-medium",children:"类型"}),(0,n.jsx)("div",{className:"inline-flex rounded-md border bg-background p-0.5",children:["task","bug","feature"].map(e=>{var t,s;return(0,n.jsx)("button",{type:"button","aria-pressed":(null!=(t=n5.issue.issue_type)?t:n5.issue.label)===e,onClick:()=>{as&&sQ(as,{title:n5.issue.title,issueType:e,expectedUpdatedAt:m.expectedUpdatedAt}),p({...m,detail:{...n5,issue:{...n5.issue,issue_type:e,label:e}}})},className:"h-11 rounded px-3 text-xs font-medium sm:h-8 ".concat((null!=(s=n5.issue.issue_type)?s:n5.issue.label)===e?"bg-accent text-foreground":"text-muted-foreground"),children:ei[e]},e)})})]}),(0,n.jsx)(tN,{pagePath:s,draftId:m.draftId,persistenceKey:an,preferPersistedDraft:!0,initialBody:n5.issue.description,textareaLabel:"Issue 描述",placeholder:"更新 Issue 描述",submitLabel:"保存 Issue",mentionCandidates:ao,removeTextRequest:ai,allowEmpty:!0,submitDisabled:!n5.issue.title.trim()||n9,onCancel:()=>aa(m),onSubmit:async e=>{var t;let{body:s,attachmentIds:n,draftId:a}=e;await n4(n5,{title:n5.issue.title.trim(),description:s,...al?{issueType:null!=(t=n5.issue.issue_type)?t:n5.issue.label}:{},expectedUpdatedAt:m.expectedUpdatedAt,draftId:a,attachmentIds:n,removedAttachmentIds:m.removedAttachmentIds}),as&&sQ(as,null)}},"edit-".concat(n5.issue.id,"-").concat(m.expectedUpdatedAt)),(0,n.jsx)(sP,{pagePath:s,attachments:ar,onRemove:e=>p({...m,removedAttachmentIds:[...m.removedAttachmentIds,e]})})]}):(0,n.jsx)(sO,{pagePath:s,detail:n5,identities:ao,currentUserId:null==r?void 0:r.id,availableLabels:t5,availableMilestones:sx,canManageMetadata:!!(r&&r.id===na),canManageLock:ae,canManagePin:!!(r&&r.id===na),metadataSaving:sz,savingTaskTarget:sU,headerAction:(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[r&&!n5.issue.locked_at&&(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":"添加评论","aria-keyshortcuts":"R",title:"添加评论",onClick:()=>{var e,t,s,n;let a=null==(e=nr.current)?void 0:e.querySelector("[data-localapp-issue-comment-composer] textarea");null==a||null==(n=a.scrollIntoView)||n.call(a,{block:"center",behavior:(null==(t=(s=window).matchMedia)?void 0:t.call(s,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth"}),window.requestAnimationFrame(()=>null==a?void 0:a.focus())},children:(0,n.jsx)(k.A,{className:"h-4 w-4"})}),(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-11 sm:h-8 sm:w-8","aria-label":s$?"已复制 Issue 链接":"复制 Issue 链接",title:s$?"已复制":"复制 Issue 链接",onClick:()=>void nJ(n5.issue.id),children:s$?(0,n.jsx)(I.A,{className:"h-4 w-4"}):(0,n.jsx)(S.A,{className:"h-4 w-4"})})]}),bodyAction:ae||at||r&&!n5.issue.locked_at&&n5.issue.description.trim()?(0,n.jsx)(tX,{label:"Issue 操作",items:[...ae?[{label:"编辑 Issue",restoreFocus:!1,onSelect:()=>(e=>{var t,s;let n=ns?function(e){try{var t,s;let n=JSON.parse(null!=(t=window.sessionStorage.getItem(e))?t:"null"),a=null!=(s=null==n?void 0:n.issueType)?s:null==n?void 0:n.label;return n&&"string"==typeof n.title&&("task"===a||"bug"===a||"feature"===a)&&"string"==typeof n.expectedUpdatedAt?{title:n.title,issueType:a,expectedUpdatedAt:n.expectedUpdatedAt}:null}catch(e){return null}}("".concat(ns,":edit:").concat(e.issue.id,":meta")):null,a=null!=(t=null==n?void 0:n.expectedUpdatedAt)?t:e.issue.updated_at;ns&&!n&&sQ("".concat(ns,":edit:").concat(e.issue.id,":meta"),{title:e.issue.title,issueType:null!=(s=e.issue.issue_type)?s:e.issue.label,expectedUpdatedAt:a}),s4(!!(n&&n.expectedUpdatedAt!==e.issue.updated_at)),p({kind:"edit",originalDetail:e,expectedUpdatedAt:a,restoredDraft:!!n,draftId:sZ(),removedAttachmentIds:[],detail:n?{...e,issue:{...e.issue,title:n.title,issue_type:n.issueType,label:n.issueType}}:e})})(n5)}]:[],...r&&!n5.issue.locked_at&&n5.issue.description.trim()?[{label:"引用回复",restoreFocus:!1,onSelect:()=>tH({id:++nN.current,text:sI(n5.issue.description,n5.issue.reporter_id)})}]:[],...at?[{label:"删除 Issue",destructive:!0,restoreFocus:!1,onSelect:e=>{X.current=e,V(null),K(!0),window.requestAnimationFrame(()=>{var e;return null==(e=Q.current)?void 0:e.focus()})}}]:[]]}):void 0,statusAction:ae?"open"===n5.issue.status?(0,n.jsxs)("div",{role:"group","aria-label":"关闭 Issue",className:"grid w-full grid-cols-2 gap-2 sm:flex sm:w-fit sm:items-center sm:justify-end",children:[(0,n.jsxs)("label",{className:"inline-flex h-11 min-w-0 items-center justify-center rounded-md border bg-background px-2 text-xs text-muted-foreground focus-within:ring-2 focus-within:ring-ring sm:h-8",children:[(0,n.jsx)("span",{className:"sr-only",children:"关闭原因"}),(0,n.jsxs)("select",{"aria-label":"关闭原因",value:sR,disabled:sT,onChange:e=>sD(e.target.value),className:"h-full min-w-0 bg-transparent outline-none",children:[(0,n.jsx)("option",{value:"completed",children:"已完成"}),(0,n.jsx)("option",{value:"not_planned",children:"不计划处理"})]})]}),(0,n.jsxs)(x.$,{ref:nx,type:"button",variant:"outline",size:"sm",className:"h-11 min-w-[6.5rem] shrink-0 gap-1.5 sm:h-8",disabled:sT,"aria-busy":sT||void 0,onClick:()=>void au(n5,sR),children:[sT&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"关闭 Issue"]})]}):(0,n.jsxs)(x.$,{ref:nx,type:"button",variant:"outline",size:"sm",className:"h-11 min-w-[7.5rem] gap-1.5 sm:h-8",disabled:sT,"aria-busy":sT||void 0,"aria-label":"重新打开 Issue",onClick:()=>void au(n5),children:[sT&&(0,n.jsx)(A.A,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"重新打开 Issue"]}):void 0,composer:n5.issue.locked_at?(0,n.jsxs)("div",{role:"status",className:"flex items-start gap-2 rounded-md border bg-muted/30 px-4 py-3 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"对话已锁定"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:n5.issue.locked_by?"@".concat(n5.issue.locked_by," 锁定了此 Issue").concat(n5.issue.lock_reason?"(".concat(eo[n5.issue.lock_reason],")"):"",",解锁后可继续评论。"):"解锁后可继续评论。"})]}):r?(0,n.jsx)("div",{"data-localapp-issue-comment-composer":!0,children:(0,n.jsx)(tN,{pagePath:s,draftId:t$,persistenceKey:"".concat(ns,":comment:").concat(n5.issue.id,":body"),showRestoredDraftNotice:!0,textareaLabel:"评论内容",placeholder:"留下评论",submitLabel:"评论",status:ae?n5.issue.status:void 0,closeReason:sR,mentionCandidates:ao,savedReplies:!0,insertRequest:tB,onInsertRequestApplied:e=>tH(t=>(null==t?void 0:t.id)===e?null:t),onSubmit:async e=>n3(n5,e)},"comment-".concat(n5.issue.id))}):void 0,commentDraftPrefix:ns?"".concat(ns,":edit-comment"):void 0,onEditComment:async(e,t,n,a,l,r)=>{try{await ts(s,n5.issue.id,e,t,n,a,l,r),await Promise.all([nB(n5.issue.id),nq(h)])}catch(e){throw e instanceof eA&&await nB(n5.issue.id).catch(()=>void 0),e}},onDeleteComment:async e=>{try{await tn(s,n5.issue.id,e),await Promise.all([nB(n5.issue.id),nq(h)])}catch(e){throw M(e instanceof Error?e.message:"Issue 服务暂不可用"),e}},canManageCommentPins:!!(r&&r.id===na),onToggleCommentPin:async(e,t)=>{try{await ta(s,n5.issue.id,e,t),await Promise.all([nB(n5.issue.id),nq(h)])}catch(e){throw M(e instanceof Error?e.message:"无法更新置顶评论"),e}},canManageCommentMinimization:!!(r&&r.id===na),onToggleCommentMinimized:async(e,t)=>{try{await tl(s,n5.issue.id,e,t),await Promise.all([nB(n5.issue.id),nq(h)])}catch(e){throw M(e instanceof Error?e.message:"无法更新评论最小化状态"),e}},onQuoteComment:(e,t)=>tH({id:++nN.current,text:sI(e,t)}),onReferenceComment:(e,t,s,n)=>((e,t,s,n,a)=>{if(!r||!ns)return;let l="".concat(ns,":reference-comment:").concat(e.issue.id,":").concat(t),i=sY(l),o=s0(l),c=o?"":function(e,t,s,n){let a=e.replace(sV,"").replace(/[ \t]+$/gm,"").trim(),l=Array.from(a),r=((l.length>500?"".concat(l.slice(0,499).join(""),"…"):a)||"@".concat(t," 的附件评论")).split(/\r?\n/).map(e=>"> ".concat(e)).join("\n");return"".concat(r,"\n\n来源:#").concat(s,"\n\n[查看 @").concat(t," 的原评论](").concat(n,")")}(s,n,e.issue.issue_number,nK(e.issue.id,t));M(null),eT(null),ed(o),es(o?i.title:""),er(c),ea(c),t_(o?i.issueType:"task"),tL(o?i.labelIds:[]),tD(o?i.assigneeIds:[]),tq(o?i.milestoneId:null),tP(sZ()),p({kind:"create",reference:{detail:e,commentId:t,trigger:a}})})(n5,e,t,s,n),selectedCommentId:nl,getCommentHref:e=>nK(n5.issue.id,e),getIssueHref:()=>n$(n5.issue.id),getIssueReferenceHref:nM,onOpenIssueReference:nF,onCopyCommentLink:async e=>{M(null);try{await sf(nO(n5.issue.id,e).href)}catch(e){throw M("无法复制评论链接,请从浏览器地址栏复制"),Error("无法复制评论链接")}},onViewIssueHistory:e=>tV({title:n5.issue.title,body:n5.issue.description,updatedAt:n5.issue.updated_at,returnFocus:e}),onViewCommentHistory:(e,t)=>{let s=n5.timeline.find(t=>"comment"===t.kind&&t.comment.id===e);(null==s?void 0:s.kind)==="comment"&&tV({commentId:e,body:s.comment.body,updatedAt:s.comment.updated_at,returnFocus:t})},onToggleLabel:async(e,t)=>{var n,a;let l=null!=(a=null==(n=n5.collaboration)?void 0:n.labels.map(e=>e.id))?a:[],r=t?Array.from(new Set([...l,e])):l.filter(t=>t!==e);await ad(()=>e3(s,n5.issue.id,r))},onSetIssueType:async e=>ad(async()=>(await te(s,n5.issue.id,{issueType:e}),eQ(s,n5.issue.id))),onToggleAssignee:async(e,t)=>{var n,a;let l=null!=(a=null==(n=n5.collaboration)?void 0:n.assignee_ids)?a:[],r=t?Array.from(new Set([...l,e])):l.filter(t=>t!==e);await ad(()=>e5(s,n5.issue.id,r))},onSetMilestone:async e=>ad(()=>e8(s,n5.issue.id,e)),onToggleSubscription:async e=>ad(()=>e4(s,n5.issue.id,"subscription",{subscribed:e})),onToggleLock:async(e,t)=>ad(()=>e6(s,n5.issue.id,e,t)),onTogglePin:async e=>{await ad(()=>eO(s,n5.issue.id,e)),await nq(h)},canManageSubIssues:(null==r?void 0:r.id)===na,onCreateSubIssue:()=>nD(n5.issue.id),onLinkSubIssue:async e=>{let t=await eZ(s,e);await ad(()=>eK(s,n5.issue.id,t.issue.id))},onRemoveSubIssue:async e=>ad(()=>eJ(s,n5.issue.id,e)),onReprioritizeSubIssue:async(e,t)=>ad(()=>eB(s,n5.issue.id,e,t)),canManageDependencies:(null==r?void 0:r.id)===na,onAddDependency:async(e,t)=>{let n=await eZ(s,t);await ad(()=>"blockedBy"===e?eW(s,n5.issue.id,n.issue.id):eW(s,n.issue.id,n5.issue.id)),await nq(h)},onRemoveDependency:async(e,t)=>{await ad(()=>"blockedBy"===e?eV(s,n5.issue.id,t):eV(s,t,n5.issue.id)),await nq(h)},canManageDuplicates:(null==r?void 0:r.id)===na,onUnmarkDuplicate:async e=>{await ad(()=>ez(s,n5.issue.id,e)),await nq(h)},onConvertIssueTask:(null==r?void 0:r.id)!==na||n5.issue.locked_at?void 0:async(e,t)=>{M(null);try{var n,a;let l=new Set((null!=(n=n5.subIssues)?n:[]).map(e=>e.id)),r=await eH(s,n5.issue.id,e,n5.issue.updated_at,t),i=(null!=(a=r.subIssues)?a:[]).find(e=>!l.has(e.id));if(!i)throw Error("Sub-issue 已创建,但无法定位新引用");for(let e of(nh.current=i.issue_number,p({kind:"detail",detail:r}),await nq(h),[100,300,600]))window.setTimeout(()=>{var e,t;return null==(t=nr.current)||null==(e=t.querySelector('[data-localapp-issue-reference="'.concat(i.issue_number,'"]')))?void 0:e.focus()},e);return i.issue_number}catch(e){throw M(e instanceof Error?e.message:"无法转换任务"),e}},onToggleIssueTask:ae&&!n5.issue.locked_at?async(e,t)=>{sF("issue"),M(null);try{let n=Y(n5.issue.description,e,t);await te(s,n5.issue.id,{description:n,expectedUpdatedAt:n5.issue.updated_at}),await Promise.all([nB(n5.issue.id),nq(h)])}catch(e){throw await nB(n5.issue.id).catch(()=>void 0),M(e instanceof Error?e.message:"任务状态更新失败"),e}finally{sF(null)}}:void 0,onToggleCommentTask:n5.issue.locked_at?void 0:async(e,t,n)=>{let a=n5.timeline.find(t=>"comment"===t.kind&&t.comment.id===e);if(a&&"comment"===a.kind&&a.comment.author_id===(null==r?void 0:r.id)){sF(e),M(null);try{let l=Y(a.comment.body,t,n),r=await ts(s,n5.issue.id,e,l,a.comment.updated_at);p({kind:"detail",detail:r}),await nq(h)}catch(e){throw await nB(n5.issue.id).catch(()=>void 0),M(e instanceof Error?e.message:"任务状态更新失败"),e}finally{sF(null)}}},onToggleReaction:async(e,t,n)=>{M(null);try{let a=await e7(s,n5.issue.id,e,t,n);p({kind:"detail",detail:a}),await nq(h)}catch(e){throw M(e instanceof Error?e.message:"Issue 服务暂不可用"),e}}})]}),"templates"===m.kind&&(0,n.jsx)(sW,{templates:eu,loading:ev,error:ew,onSelect:e=>nD(void 0,e,!0),onBlank:()=>nD(void 0,void 0,!0),onRetry:()=>eC(e=>e+1)}),"create"===m.kind&&(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:(0,n.jsxs)("div",{"data-testid":"issue-create-workspace",className:"grid min-w-0 gap-5 lg:grid-cols-[minmax(0,3fr)_minmax(240px,1fr)] lg:gap-6",children:[(0,n.jsxs)("div",{"data-testid":"issue-create-main",className:"min-w-0 space-y-4",children:[m.reference&&(0,n.jsxs)("div",{role:"status",className:"rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,n.jsxs)("strong",{children:["引用自 #",m.reference.detail.issue.issue_number," 评论"]}),(0,n.jsx)("p",{className:"mt-1 text-muted-foreground",children:"原评论保持不变,提交后将创建独立 Issue。"})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsx)(E.J,{htmlFor:"issue-title",children:"标题"}),(0,n.jsxs)("span",{className:"text-xs ".concat(n6?"text-destructive":"text-muted-foreground"),children:[n8," / ",256]})]}),(0,n.jsx)(C.p,{id:"issue-title","aria-label":"标题","aria-invalid":n6||void 0,"aria-describedby":n6?"issue-title-error":void 0,value:et,onChange:e=>es(e.target.value),placeholder:"简要描述问题或需求",className:"h-11 sm:h-10",autoFocus:!0,required:!0}),n6&&(0,n.jsx)("p",{id:"issue-title-error",role:"alert",className:"text-sm text-destructive",children:"Issue 标题不能超过 256 个字符"})]}),eE&&(0,n.jsx)("p",{role:"status","aria-label":"Issue 模板提示",className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm",children:eE}),(0,n.jsx)(sH,{candidates:tb,loading:tv,error:tj,getIssueHref:nM,onOpenIssue:nF,onRetry:()=>tC(e=>e+1)}),(0,n.jsx)(tN,{pagePath:s,draftId:tU,initialBody:el,persistenceKey:nn?"".concat(nn,":body"):void 0,showRestoredDraftNotice:!0,restoredDraft:ec,onDiscardRestoredDraft:()=>{es(""),er(""),ea(""),ed(!1),t_("task"),tL([]),tD([]),tq(null),eT(null),ns&&s1(null!=nn?nn:"".concat(ns,":create"),"","task",[],[],null)},onBodyChange:ea,textareaLabel:"描述",placeholder:"详细描述问题、复现步骤或期望结果",submitLabel:"提交 Issue",mentionCandidates:ao,allowEmpty:!0,submitDisabled:!et.trim()||n6,onSubmit:n2},tU)]}),(0,n.jsxs)("aside",{"data-testid":"issue-create-triage","aria-label":"Issue 分诊",className:"min-w-0 space-y-4 border-t pt-4 lg:border-l lg:border-t-0 lg:pl-5 lg:pt-0",children:[(0,n.jsxs)("fieldset",{className:"space-y-1.5",children:[(0,n.jsx)("legend",{className:"text-sm font-medium",children:"类型"}),(0,n.jsx)("div",{className:"inline-flex rounded-md border bg-background p-0.5",children:["task","bug","feature"].map(e=>(0,n.jsx)("button",{type:"button","aria-pressed":tE===e,onClick:()=>t_(e),className:"h-11 rounded px-3 text-xs font-medium sm:h-8 ".concat(tE===e?"bg-accent text-foreground":"text-muted-foreground"),children:ei[e]},e))})]}),(null==r?void 0:r.id)===na&&(0,n.jsxs)("div",{"data-localapp-create-metadata":!0,className:"space-y-4 border-t pt-4",children:[(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex min-h-7 items-center justify-between",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"附加标签"}),(0,n.jsx)(t9,{label:"附加标签",items:t5.map(e=>({id:e.id,label:e.name,description:e.description||e.id,leading:(0,n.jsx)("span",{"aria-hidden":"true",className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:"#".concat(e.color)}})})),selectedIds:tT,onToggle:(e,t)=>tL(s=>t?Array.from(new Set([...s,e])):s.filter(t=>t!==e))})]}),tT.length>0?(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:tT.map(e=>t5.find(t=>t.id===e)).filter(e=>!!e).map(e=>(0,n.jsx)(tF,{label:e},e.id))}):(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"未添加附加标签"})]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mb-2 flex min-h-7 items-center justify-between",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"负责人"}),(0,n.jsx)(t9,{label:"负责人",items:ac.map(e=>({id:e.id,label:e.displayName||e.name||e.id,description:"@".concat(e.id)})),selectedIds:tR,onToggle:(e,t)=>tD(s=>t?Array.from(new Set([...s,e])):s.filter(t=>t!==e))})]}),tR.length>0?(0,n.jsx)("div",{className:"space-y-2",children:tR.map(e=>(0,n.jsx)(t7,{identity:t6(e,ao)},e))}):(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"尚未分配"})]}),(0,n.jsxs)("section",{children:[(0,n.jsx)("label",{className:"mb-2 block text-sm font-medium",htmlFor:"issue-create-milestone",children:"里程碑"}),(0,n.jsxs)("select",{id:"issue-create-milestone","aria-label":"里程碑",className:"h-11 w-full rounded-md border bg-background px-3 text-sm sm:h-9",value:null!=tz?tz:"",onChange:e=>tq(e.target.value?Number(e.target.value):null),children:[(0,n.jsx)("option",{value:"",children:"无里程碑"}),sx.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title,"closed"===e.state?"(已关闭)":""]},e.id))]})]})]})]}),(0,n.jsx)("div",{className:"flex justify-end border-t pt-4 lg:col-span-2",children:(0,n.jsx)(x.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 sm:h-8",onClick:()=>{if("create"===m.kind&&m.reference){let{detail:e,commentId:t,trigger:s}=m.reference;p({kind:"detail",detail:e});let n=nO(e.issue.id,t);window.history.replaceState(null,"",n),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>{var e;return(null==s?void 0:s.isConnected)?s.focus():null==(e=document.querySelector('[data-testid="issue-comment-'.concat(t,'"] button[aria-label="评论操作"]')))?void 0:e.focus()}));return}"create"===m.kind&&m.returnToTemplates?p({kind:"templates"}):nV()},children:"取消"})})]})}),n5&&tW&&(0,n.jsx)(sK,{pagePath:s,issueId:n5.issue.id,commentId:tW.commentId,currentTitle:tW.title,currentBody:tW.body,currentUpdatedAt:tW.updatedAt,identities:ao,returnFocus:tW.returnFocus,onClose:()=>tV(null)})]})]})}var s4=s(1659);let s3="localapp-ai-sidebar-width";function s5(e){var t;let{open:s,onClose:a,messages:r,isRunning:i,error:o,onSend:c}=e,[d,u]=(0,l.useState)(()=>{let e=localStorage.getItem(s3);if(!e)return 380;let t=parseInt(e,10);return Number.isNaN(t)?380:Math.min(600,Math.max(280,t))}),[m,p]=(0,l.useState)(""),[h,f]=(0,l.useState)(!1),b=(0,l.useRef)(null),g=(0,l.useRef)({startX:0,startWidth:0}),v=(0,l.useRef)(d);v.current=d,(0,l.useEffect)(()=>{let e=b.current;e&&(e.scrollTop=e.scrollHeight)},[r]);let y=(0,l.useCallback)(e=>{e.preventDefault(),f(!0),g.current={startX:e.clientX,startWidth:d}},[d]);(0,l.useEffect)(()=>{if(h)return document.body.style.userSelect="none",window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)};function e(e){let t=g.current.startX-e.clientX;u(Math.min(600,Math.max(280,g.current.startWidth+t)))}function t(){f(!1),document.body.style.userSelect="",localStorage.setItem(s3,String(v.current))}},[h,d]);let w=()=>{let e=m.trim();e&&!i&&(c(e),p(""))};return(0,n.jsxs)("div",{className:"absolute right-0 top-0 bottom-0 z-50 flex flex-col border-l bg-background shadow-lg transition-transform duration-300 ease-in-out",style:{width:d,transform:s?"translateX(0)":"translateX(100%)"},children:[(0,n.jsx)("div",{className:"absolute left-0 top-0 bottom-0 cursor-col-resize group",style:{width:8,marginLeft:-4},onMouseDown:y,children:(0,n.jsx)("div",{className:"h-full w-1 mx-auto rounded-full transition-colors group-hover:bg-primary/30",style:h?{backgroundColor:"var(--color-primary)"}:void 0})}),(0,n.jsxs)("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[(0,n.jsx)("span",{className:"text-sm font-medium",children:"AI 助手"}),(0,n.jsx)(x.$,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:a,children:(0,n.jsx)(N.A,{className:"h-3.5 w-3.5"})})]}),o&&(0,n.jsx)("div",{className:"border-b bg-destructive/10 px-3 py-2 text-xs text-destructive",children:o}),(0,n.jsxs)("div",{ref:b,className:"flex-1 overflow-y-auto px-3 py-2 space-y-3 text-sm",children:[0===r.length&&(0,n.jsx)("p",{className:"py-8 text-center text-muted-foreground text-xs",children:"发送消息开始对话"}),r.map((e,t)=>"user"===e.role?(0,n.jsx)(s8,{text:e.content},t):(0,n.jsx)(s6,{text:e.content,toolCalls:e.toolCalls},t)),i&&(null==(t=r[r.length-1])?void 0:t.role)==="user"&&(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)(A.A,{className:"h-3 w-3 animate-spin"}),"思考中..."]})]}),(0,n.jsx)("div",{className:"border-t px-3 py-2",children:(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("input",{className:"flex-1 rounded-md border bg-transparent px-3 py-1.5 text-sm outline-none focus:ring-1 focus:ring-primary",placeholder:"输入消息...",value:m,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),w())},disabled:i}),(0,n.jsx)(x.$,{size:"icon",className:"h-8 w-8 flex-shrink-0",onClick:w,disabled:!m.trim()||i,children:(0,n.jsx)(s4.A,{className:"h-3.5 w-3.5"})})]})})]})}function s8(e){let{text:t}=e;return(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)("div",{className:"max-w-[80%] rounded-2xl rounded-br-sm bg-primary px-3 py-2 text-sm text-primary-foreground whitespace-pre-wrap",children:t})})}function s6(e){let{text:t,toolCalls:s}=e;return(0,n.jsx)("div",{className:"flex justify-start",children:(0,n.jsxs)("div",{className:"max-w-[80%] space-y-1.5",children:[t&&(0,n.jsx)("div",{className:"rounded-2xl rounded-bl-sm bg-muted px-3 py-2 text-sm leading-relaxed prose prose-sm max-w-none",children:(0,n.jsx)(H.oz,{remarkPlugins:[W.A],children:t})}),null==s?void 0:s.map(e=>(0,n.jsx)(s7,{tc:e},e.id))]})})}function s7(e){let{tc:t}=e,s="completed"===t.status||"timeout"===t.status,a=t.args&&Object.keys(t.args).length>0,[r,i]=(0,l.useState)(!s);(0,l.useEffect)(()=>{s&&i(!1)},[s]);let o=void 0!==t.result?"string"==typeof t.result?t.result:JSON.stringify(t.result):"",c=o.slice(0,60),d="running"===t.status?"⏳":t.isError?"✗":"✓",u=t.isError?"text-destructive":"text-primary";return(0,n.jsxs)("div",{className:"rounded-md bg-primary/5 px-2.5 py-1.5 text-xs",onClick:s?()=>i(e=>!e):void 0,style:{cursor:s?"pointer":"default"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 font-medium ".concat(u),children:[(0,n.jsx)("span",{children:d}),(0,n.jsx)("span",{children:t.name}),!r&&c&&(0,n.jsxs)("span",{className:"flex-1 truncate font-normal text-muted-foreground",children:[c,o.length>60?"…":""]}),s&&(0,n.jsx)("span",{className:"ml-auto flex-shrink-0 font-normal text-muted-foreground text-[10px]",children:r?"▲ 折叠":"▼ 展开"})]}),r&&(0,n.jsxs)(n.Fragment,{children:[a&&(0,n.jsx)("pre",{className:"mt-1 text-[11px] text-muted-foreground whitespace-pre-wrap",children:JSON.stringify(t.args,null,2)}),void 0!==t.result&&(0,n.jsx)("pre",{className:"mt-1 text-[11px] whitespace-pre-wrap ".concat(t.isError?"text-destructive":"text-green-700"),children:"string"==typeof t.result?t.result:JSON.stringify(t.result,null,2)})]})]})}let s9={all:"全部",important:"仅重要",muted:"静音"};function ne(e){var t;let{pagePath:s,pageName:a,ownerName:r,user:o,meta:c}=e,{openLogin:d}=(0,b.M)(),[u,m]=(0,l.useState)(null),[p,h]=(0,l.useState)(0),[f,g]=(0,l.useState)(!1);if((null==c||null==(t=c.notify)?void 0:t.enabled)!==!0)return null;let v=(0,l.useCallback)(async()=>{if(!o){m(null),h(0);return}try{var e,t,s,n;let[l,i]=await Promise.all([fetch("/api/subscriptions/".concat(r,"/").concat(a,"/status"),{credentials:"include"}).then(e=>e.json()),fetch("/api/inbox/unread-count",{credentials:"include"}).then(e=>e.json())]);l.success&&m(null!=(s=null==(e=l.data)?void 0:e.level)?s:null),i.success&&h(null!=(n=null==(t=i.data)?void 0:t.count)?n:0)}catch(e){}},[o,r,a]);(0,l.useEffect)(()=>{v()},[v]);let y=async e=>{if(!o)return void d();try{let t=await fetch("/api/subscriptions",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_owner:r,app_name:a,level:e})});(await t.json()).success&&m(e)}catch(e){}g(!1)},w=o?u?"已订阅(".concat(s9[u],")\xb7 点击查看收件箱"):"订阅此应用通知":"登录后订阅此应用通知";return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)(x.$,{variant:"ghost",size:"icon",className:"h-7 w-7 ".concat(u?"text-primary":"text-muted-foreground"),title:w,onClick:()=>{if(!o)return void d();u?window.location.href="/inbox":g(e=>!e)},children:[(0,n.jsx)(t3.A,{className:"h-4 w-4"}),p>0&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-red-500 px-1 text-[9px] font-bold text-white",children:p>99?"99+":p})]}),f&&o&&(0,n.jsxs)("div",{className:"absolute right-0 top-9 z-50 w-44 rounded-md border bg-popover p-1 text-sm shadow-md",children:[(0,n.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"选择订阅等级"}),["all","important","muted"].map(e=>(0,n.jsxs)("button",{className:"flex w-full items-center justify-between rounded px-2 py-1.5 hover:bg-accent",onClick:()=>y(e),children:[(0,n.jsx)("span",{children:s9[e]}),u===e&&(0,n.jsx)("span",{className:"text-xs text-primary",children:"✓"})]},e)),(0,n.jsx)("div",{className:"my-1 border-t"}),(0,n.jsx)(i(),{href:"/inbox",className:"block rounded px-2 py-1.5 hover:bg-accent",children:"查看收件箱"})]})]})}let nt=[{name:"getCurrentUser",description:"Return the current signed-in user id and name, or null when unauthenticated.",parameters:{type:"object",properties:{}}}],ns=new Set(nt.map(e=>e.name));async function nn(e,t,s){try{if("getCurrentUser"===e){let e=await fetch("/api/me",{credentials:"include"}),t=await e.json();if(!t.success||!t.data)return{result:null};return{result:{id:t.data.id,name:t.data.name}}}return{result:"Unknown system tool: ".concat(e),isError:!0}}catch(e){return{result:e instanceof Error?e.message:String(e),isError:!0}}}async function na(e,t){let s=new TextDecoder,n="",a=[],l="";for(;;){let{done:m,value:p}=await e.read();if(m)break;let h=(l+=s.decode(p,{stream:!0})).split("\n");for(let e of(l=h.pop()||"",h)){if(!e.startsWith("data: "))continue;let s=e.slice(6).trim();if("[DONE]"!==s)try{var r,i,o,c,d,u;let e=null==(i=JSON.parse(s).choices)||null==(r=i[0])?void 0:r.delta;if(!e)continue;if(e.content&&(n+=e.content),e.tool_calls){for(let t of e.tool_calls)if(t.id)a.push({id:t.id,name:(null==(o=t.function)?void 0:o.name)||"",args:(null==(c=t.function)?void 0:c.arguments)||""});else if(a.length>0){let e=a[a.length-1];(null==(d=t.function)?void 0:d.arguments)&&(e.args+=t.function.arguments),(null==(u=t.function)?void 0:u.name)&&(e.name=t.function.name)}}t(n,a)}catch(e){}}}return{content:n,toolCalls:a}}var nl=s(409),nr=s(4045),ni=s(1580);let no=["@font-face","@keyframes","@-webkit-keyframes","@property","@page"],nc="/_localapp/raw";function nd(e){return e.endsWith("/")?e:"".concat(e,"/")}function nu(e,t){if(!t)return"";if(/^https?:\/\//i.test(t)||t.startsWith("/serve/")||t.startsWith("".concat(nc,"/")))return t;let s=nd(e);return t.startsWith("/assets/")?"".concat(s.slice(0,-1)).concat(t):new URL(t,"http://localapp.local".concat(s)).pathname}function nm(e){let{peers:t}=e,s=(0,l.useRef)(null),[a,r]=(0,l.useState)([]),i=(0,l.useMemo)(()=>(function(e){let t=new Map;for(let a of e){var s,n;if(!np(a.editing.surfaceId)||a.editing.fieldId&&!np(a.editing.fieldId))continue;let e="".concat(a.editing.surfaceId,"\0").concat(null!=(s=a.editing.fieldId)?s:""),l=null!=(n=t.get(e))?n:[];l.some(e=>e.clientId===a.clientId)||l.push(a),t.set(e,l)}return t})(t.filter(e=>!1!==e.overlay)),[t]);return(0,l.useEffect)(()=>{var e;let t=0,n=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>{let e=s.current,t=null==e?void 0:e.closest("[data-localapp-app-area]"),n=null==t?void 0:t.querySelector("[data-localapp-app-root]");if(!e||!t||!n)return void r([]);let a=t.getBoundingClientRect(),l=[];for(let[e,t]of i){let s=function(e,t){var s;let n=[...e.querySelectorAll("[data-localapp-edit-surface]")].find(e=>e.dataset.localappEditSurface===t.editing.surfaceId);return n&&t.editing.fieldId?null!=(s=[...n.querySelectorAll("[data-localapp-edit-field]")].find(e=>e.dataset.localappEditField===t.editing.fieldId))?s:n:null!=n?n:null}(n,t[0]);if(!s)continue;let r=s.getBoundingClientRect(),i=Math.max(r.left,a.left),o=Math.max(r.top,a.top),c=Math.min(r.right,a.right),d=Math.min(r.bottom,a.bottom);c<=i||d<=o||r.width<=0||r.height<=0||l.push({key:e,maskId:function(e){var t;return"".concat(encodeURIComponent(e.editing.surfaceId),":").concat(encodeURIComponent(null!=(t=e.editing.fieldId)?t:""))}(t[0]),left:i-a.left,top:o-a.top,width:c-i,height:d-o,peers:t})}r(l)})};n();let a=null==(e=s.current)?void 0:e.closest("[data-localapp-app-area]"),l=null==a?void 0:a.querySelector("[data-localapp-app-root]"),o="undefined"==typeof ResizeObserver?null:new ResizeObserver(n);o&&a&&o.observe(a),o&&l&&o.observe(l);let c="undefined"!=typeof MutationObserver&&l?new MutationObserver(n):null;return c&&l&&c.observe(l,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","class","hidden","data-localapp-edit-surface","data-localapp-edit-field"]}),window.addEventListener("resize",n),document.addEventListener("scroll",n,!0),()=>{cancelAnimationFrame(t),null==o||o.disconnect(),null==c||c.disconnect(),window.removeEventListener("resize",n),document.removeEventListener("scroll",n,!0)}},[i]),(0,n.jsxs)("div",{ref:s,className:"pointer-events-none absolute inset-0 z-30 overflow-hidden","data-localapp-editing-awareness-overlay":!0,"aria-live":"polite",children:[a.map(e=>{var t;let s=e.peers[0],a=(t=s.user.color,/^(#[0-9a-f]{6}|hsl\(\d{1,3} 72% 48%\))$/i.test(t)?t:"#2563eb"),l=e.peers.map(nh),r=s.editing.label;return(0,n.jsx)("div",{className:"absolute rounded-sm border-2 motion-safe:transition-[top,left,width,height] motion-safe:duration-100",style:{left:e.left,top:e.top,width:e.width,height:e.height,borderColor:a,background:"color-mix(in srgb, ".concat(a," 10%, transparent)"),boxShadow:"inset 0 0 0 1px color-mix(in srgb, ".concat(a," 28%, transparent)")},"data-localapp-editing-mask":e.maskId,children:(0,n.jsxs)("div",{className:"absolute left-0 top-0 flex max-w-[min(22rem,90vw)] -translate-y-full items-center gap-1 overflow-hidden rounded-t px-1.5 py-0.5 text-[11px] font-medium leading-4 text-white shadow-sm",style:{backgroundColor:a},children:[(0,n.jsx)("span",{className:"truncate",children:l.join("、")}),r&&(0,n.jsxs)("span",{className:"shrink-0 opacity-80",children:["\xb7 ",r]})]})},e.key)}),(0,n.jsx)("span",{className:"sr-only",children:a.map(e=>{var t,s;return"".concat(e.peers.map(nh).join("、"),"正在编辑").concat(null!=(s=null!=(t=e.peers[0].editing.label)?t:e.peers[0].editing.fieldId)?s:e.peers[0].editing.surfaceId)}).join(";")})]})}function np(e){return/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}$/.test(e)}function nh(e){var t;return(null==(t=e.user.displayName)?void 0:t.trim())||e.user.name||"协作者"}function nf(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function nx(e){return!!nf(e)&&"string"==typeof e.clientId&&!!nf(e.user)&&!!nf(e.editing)&&"string"==typeof e.user.id&&"string"==typeof e.user.name&&(null===e.user.displayName||"string"==typeof e.user.displayName)&&"string"==typeof e.user.color&&"string"==typeof e.editing.surfaceId&&(void 0===e.editing.fieldId||"string"==typeof e.editing.fieldId)}function nb(e){return nf(e)&&"localapp:platform_request"===e.type&&"string"==typeof e.id&&"string"==typeof e.capability}let ng="__localapp_platform_tool_registry__",nv="__localapp_platform_edit_session_registry__",ny="localapp:crdt-editing-awareness";function nw(e){return nf(e)?e:{}}function nj(e){let{userId:t,name:s}=e,r=(0,a.useRouter)(),{openLogin:i}=(0,b.M)(),[o,c]=(0,l.useState)(null),[d,u]=(0,l.useState)(!1),[m,p]=(0,l.useState)(null),[h,f]=(0,l.useState)(0),[v,y]=(0,l.useState)(!1),[w,j]=(0,l.useState)(()=>sc(new URL(window.location.href),sl)),[N,k]=(0,l.useState)(()=>sc(new URL(window.location.href),sr)),[I,S]=(0,l.useState)(()=>sd(new URL(window.location.href))),A=(0,l.useRef)(w),C=(0,l.useRef)(N);A.current=w,C.current=N;let[E,_]=(0,l.useState)(null),[T,L]=(0,l.useState)(null),[R,D]=(0,l.useState)(null),[z,q]=(0,l.useState)(null),[U,F]=(0,l.useState)({}),[P,$]=(0,l.useState)(null),M=(0,l.useRef)(0),O="".concat(t,"/").concat(s),K=function(e,t){let s=!function(e){try{return new URL(e).pathname.startsWith("/platform-shell/")}catch(e){return!1}}(window.location.href)?"/serve":nc;return nd("".concat(s,"/").concat(e))}(O),J="".concat(K,"|").concat(O),B=(null==m?void 0:m.name)===s&&(null==m?void 0:m.userId)===t,H=B&&"online"===m.lifecycleStatus,W=B&&"offline"===m.lifecycleStatus,V=(null==o?void 0:o.id)===t,X=Object.values(U).flat(),[Q,Z]=(0,l.useState)(null),[G,Y]=(0,l.useState)(!1),ee=(0,l.useRef)(null),et=(0,l.useRef)([]),es=(0,l.useRef)(new Map),en=(0,l.useRef)(""),ea=(0,l.useRef)(null),el=(0,l.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"push",s=sm(new URL(window.location.href),e);window.history["push"===t?"pushState":"replaceState"](window.history.state,"",s),j(e),k(null),S(null!==e||I)},[I]),er=(0,l.useCallback)(()=>{let e=su(new URL(window.location.href),!1);window.history.replaceState(window.history.state,"",e),j(null),k(null),S(!1)},[]),ei=(0,l.useCallback)(()=>{let e=su(new URL(window.location.href),!0);window.history.pushState(window.history.state,"",e),S(!0)},[]);(0,l.useEffect)(()=>{let e=()=>{let e=new URL(window.location.href),t=sd(e);if(!t&&function(){var e;let t=document.querySelector('[data-localapp-issues-workspace] [data-localapp-issue-attachment-queue][aria-busy="true"]');return!!t&&(t.focus(),null==(e=t.scrollIntoView)||e.call(t,{block:"nearest"}),!0)}()){let t=function(e,t,s){let n=su(e,!0);return null!==t?sm(n,t):null!==s?sp(n,s):n}(e,A.current,C.current);window.history.pushState(window.history.state,"",t);return}let s=sc(e,sl),n=sc(e,sr);j(s),k(n),S(t)};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let eo=(0,l.useCallback)(e=>{let t=es.current.get(e.toolName);if(!t)return void window.dispatchEvent(new MessageEvent("message",{data:{type:"localapp:tool_result",callId:e.callId,result:"Unknown tool: ".concat(e.toolName),isError:!0},origin:window.location.origin}));Promise.resolve(t(e.args)).then(t=>{window.dispatchEvent(new MessageEvent("message",{data:{type:"localapp:tool_result",callId:e.callId,result:t,isError:!1},origin:window.location.origin}))}).catch(t=>{window.dispatchEvent(new MessageEvent("message",{data:{type:"localapp:tool_result",callId:e.callId,result:t instanceof Error?t.message:String(t),isError:!0},origin:window.location.origin}))})},[]),{chatMessages:ec,isRunning:ed,aiError:eu,agentSend:em,handleToolResult:ep}=function(e){let{appName:t,userName:s,pagePath:n,postToolCall:a,registeredToolsRef:r,systemHintRef:i}=e,[o,c]=(0,l.useState)([]),[d,u]=(0,l.useState)(!1),[m,p]=(0,l.useState)(null),h=(0,l.useRef)(new Map),f=(0,l.useCallback)((e,t,s)=>new Promise(n=>{let l=setTimeout(()=>{h.current.delete(e),n({result:"工具执行超时",isError:!0}),c(t=>t.map(t=>"assistant"===t.role&&t.toolCalls?{...t,toolCalls:t.toolCalls.map(t=>t.id===e?{...t,result:"工具执行超时",isError:!0,status:"timeout"}:t)}:t))},3e4);h.current.set(e,{resolve:(e,t)=>n({result:e,isError:t}),timeout:l}),a({type:"localapp:tool_call",callId:e,toolName:t,args:s})}),[a]),x=(0,l.useCallback)((e,t,s)=>{let n=h.current.get(e);n&&(clearTimeout(n.timeout),h.current.delete(e),n.resolve(t,s),c(n=>n.map(n=>"assistant"===n.role&&n.toolCalls?{...n,toolCalls:n.toolCalls.map(n=>n.id===e?{...n,result:t,isError:s,status:"completed"}:n)}:n)))},[]),b=(0,l.useCallback)(async e=>{let t=await Promise.all(e.map(async e=>{let t,s={};try{s=JSON.parse(e.args)}catch(e){}return t=ns.has(e.name)?await nn(e.name,s,n):await f(e.id,e.name,s),{id:e.id,name:e.name,result:String(t.result),isError:t.isError}}));for(let e of t)ns.has(e.name)&&c(t=>t.map(t=>"assistant"===t.role&&t.toolCalls?{...t,toolCalls:t.toolCalls.map(t=>t.id===e.id?{...t,result:e.result,isError:e.isError,status:"completed"}:t)}:t));return t},[n,f]),g=(0,l.useCallback)(async e=>{var n,a;c(t=>[...t,{role:"user",content:e}]),u(!0),p(null);let l=[{role:"user",content:e}],o=[...nt.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.parameters}})),...(null!=(n=r.current)?n:[]).map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.parameters}}))],d=["你是一个运行在 LocalApp 应用中的 AI 助手。","当前应用: ".concat(t),"当前用户: ".concat(null!=s?s:"未登录"),i.current,"当用户的需求可以映射到工具操作时,必须调用工具执行。","请用中文回复用户。"].filter(Boolean).join("\n");try{let e=0;for(;e<5;){let t=await fetch("/api/llm/chat",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"system",content:d},...l],...o.length>0?{tools:o}:{}})});if(!t.ok)throw Error("LLM 请求失败: ".concat(t.status));let s=null==(a=t.body)?void 0:a.getReader();if(!s)throw Error("无响应体");e>0&&c(e=>[...e,{role:"assistant",content:"",toolCalls:[]}]);let{content:n,toolCalls:r}=await na(s,0===e?e=>{c(t=>{let s=t[t.length-1];return(null==s?void 0:s.role)==="assistant"?[...t.slice(0,-1),{...s,content:e}]:[...t,{role:"assistant",content:e,toolCalls:[]}]})}:e=>{c(t=>{let s=t[t.length-1];return(null==s?void 0:s.role)==="assistant"?[...t.slice(0,-1),{...s,content:e}]:t})}),i=r.map(e=>{let t={};try{t=JSON.parse(e.args)}catch(e){}return{id:e.id,name:e.name,args:t,status:"running"}});if(c(e=>{let t=e[e.length-1];return(null==t?void 0:t.role)==="assistant"?[...e.slice(0,-1),{...t,content:n,toolCalls:i.length>0?i:t.toolCalls}]:[...e,{role:"assistant",content:n,toolCalls:i}]}),0===r.length)break;let u=await b(r);for(let e of(l.push({role:"assistant",content:n||"",tool_calls:r.map(e=>({id:e.id,type:"function",function:{name:e.name,arguments:e.args}}))}),u))l.push({role:"tool",content:JSON.stringify(e),tool_call_id:e.id});e++}0===e&&c(e=>{let t=e[e.length-1];return(null==t?void 0:t.role)==="assistant"?e:[...e,{role:"assistant",content:"",toolCalls:[]}]})}catch(e){p(e instanceof Error?e.message:"未知错误")}finally{u(!1)}},[t,s,r,i,b]);return{chatMessages:o,setChatMessages:c,isRunning:d,aiError:m,agentSend:g,handleToolResult:x}}({appName:s,userName:null==o?void 0:o.name,pagePath:O,postToolCall:eo,registeredToolsRef:et,systemHintRef:en});(0,l.useEffect)(()=>{let e=!1;return u(!1),p(null),Promise.all([fetch("/api/me",{credentials:"include"}).then(e=>e.json()).catch(()=>null),fetch("/api/pages/".concat(t,"/").concat(s,"/meta"),{credentials:"include"}).then(e=>e.json()).catch(()=>null)]).then(t=>{let[s,n]=t;e||((null==s?void 0:s.success)&&s.data&&c(s.data),(null==n?void 0:n.success)&&n.data&&p(n.data),u(!0))}),()=>{e=!0}},[t,s]),(0,l.useEffect)(()=>{let e=globalThis,t=e[ng];return e[ng]={registerTools:(e,t,s)=>(et.current=e,es.current=new Map(Object.entries(t)),en.current=s||"",Z("system"),()=>{et.current=[],es.current=new Map,en.current=""})},()=>{e[ng]=null!=t?t:null}},[]),(0,l.useEffect)(()=>{let e=globalThis,t=e[nv];return e[nv]={registerEditSession:e=>(ea.current=e,D(e),()=>{ea.current===e&&(ea.current=null,D(null))})},()=>{e[nv]=null!=t?t:null,ea.current=null,D(null)}},[]),(0,l.useEffect)(()=>{function e(e){let t=ea.current;if(!t||t.busy)return;let s=e.key.toLowerCase();if(e.ctrlKey||e.metaKey){if("s"===s&&t.canSave){e.preventDefault(),t.onSave();return}if(!function(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName.toLowerCase();return"input"===t||"textarea"===t||"select"===t}(e.target)){if("z"===s&&e.shiftKey&&t.canRedo){e.preventDefault(),t.onRedo();return}if("z"===s&&!e.shiftKey&&t.canUndo){e.preventDefault(),t.onUndo();return}"y"===s&&t.canRedo&&(e.preventDefault(),t.onRedo())}}}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,l.useEffect)(()=>{fetch("/api/favorites/count?pagePath=".concat(encodeURIComponent(O)),{credentials:"include"}).then(e=>e.json()).then(e=>{var t,s;e.success&&f(null!=(s=null==(t=e.data)?void 0:t.count)?s:0)}).catch(()=>{})},[O]);let ef=(0,l.useCallback)(async()=>{let e=++M.current;try{let t=await e$(O,{...eh,status:"open",limit:1});if(e!==M.current)return;let s=t.meta.open;$("number"==typeof s&&Number.isFinite(s)&&s>=0?s:t.data.length)}catch(e){}},[O]);(0,l.useEffect)(()=>{ef()},[ef]),(0,l.useEffect)(()=>{o&&fetch("/api/favorites/check?pagePath=".concat(encodeURIComponent(O)),{credentials:"include"}).then(e=>e.json()).then(e=>{var t,s;e.success&&y(null!=(s=null==(t=e.data)?void 0:t.favorited)&&s)}).catch(()=>{})},[O,o]),(0,l.useEffect)(()=>{var e,t,s;if(!d||!H||"undefined"==typeof EventSource)return;let n=null!=(s=null==(t=globalThis.crypto)||null==(e=t.randomUUID)?void 0:e.call(t))?s:"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2)),a=JSON.stringify({clientId:n}),l="/serve/".concat(O,"/api/presence/heartbeat"),r="/serve/".concat(O,"/api/presence/leave"),i=null,o=!0;function c(e){try{var t,s,n;let a=JSON.parse(e.data),l=null==(t=a.data)?void 0:t.count,r=null==(s=a.data)?void 0:s.anonymousCount,i=null==(n=a.data)?void 0:n.authenticatedUsers;Number.isFinite(l)&&Number.isFinite(r)&&Array.isArray(i)&&q({count:Math.max(0,Number(l)),anonymousCount:Math.max(0,Number(r)),authenticatedUsers:i})}catch(e){}}let u=()=>{null==i||i.close(),i=null},m=()=>{fetch(l,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}).catch(()=>{})},p=()=>{var e,t;let s=new Blob([a],{type:"application/json"});null!=(e=(t=navigator).sendBeacon)&&e.call(t,r,s)||fetch(r,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}).catch(()=>{})},h=()=>{"hidden"!==document.visibilityState&&o&&!i&&(i=new EventSource("/serve/".concat(O,"/api/presence/events?clientId=").concat(encodeURIComponent(n)))).addEventListener("presence:snapshot",c)},f=()=>{m(),"hidden"===document.visibilityState?u():h()},x=()=>{o=!1,m(),u()},b=()=>{o=!0,m(),h()},g=()=>{o=!1,u(),p()},v=()=>{o=!0,m(),h()};m(),h();let y=window.setInterval(m,3e4);return document.addEventListener("visibilitychange",f),window.addEventListener("blur",x),window.addEventListener("focus",b),window.addEventListener("pagehide",g),window.addEventListener("pageshow",v),()=>{window.clearInterval(y),document.removeEventListener("visibilitychange",f),window.removeEventListener("blur",x),window.removeEventListener("focus",b),window.removeEventListener("pagehide",g),window.removeEventListener("pageshow",v),u(),p()}},[H,O,d]),(0,l.useEffect)(()=>{if(F({}),!d||!H)return;let e=e=>{let t=e.detail;if(!nf(t)||"string"!=typeof t.sourceId||t.sourceId.length>400||!Array.isArray(t.peers))return;let s=t.sourceId,n=t.peers.filter(nx).slice(0,128);F(e=>{if(0===n.length){if(!(s in e))return e;let t={...e};return delete t[s],t}return s in e||!(Object.keys(e).length>=128)?{...e,[s]:n}:e})};return window.addEventListener(ny,e),()=>window.removeEventListener(ny,e)},[H,O,d]),(0,l.useEffect)(()=>{if(!d||!H||ee.current===J)return;ee.current=J,L(null);let e=!1,t=[];return async function(){try{var s,n;let a=await fetch(K,{credentials:"include"});if(!a.ok)throw Error("App index request failed: ".concat(a.status));let l=await a.text();if(e)return;let r=new DOMParser().parseFromString(l,"text/html"),i=Array.from(r.querySelectorAll('link[rel="stylesheet"][href]')),o=Array.from(r.querySelectorAll('script[type="module"][src]'));for(let e of i){let n=nu(K,null!=(s=e.getAttribute("href"))?s:"");if(!n||document.querySelector('[data-localapp-app-asset="'.concat(n,'"]')))continue;let a=await fetch(n,{credentials:"include"});if(!a.ok)throw Error("App stylesheet request failed: ".concat(a.status));let l=await a.text(),r=document.createElement("style");r.textContent=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:":where([data-localapp-app-root])";return function e(t,s){let n="",a=0;for(;a<t.length;){let l=t.indexOf("{",a);if(-1===l){n+=t.slice(a);break}let r=function(e,t){let s=0,n=null;for(let a=t;a<e.length;a++){let t=e[a],l=e[a-1];if(n){t===n&&"\\"!==l&&(n=null);continue}if('"'===t||"'"===t){n=t;continue}if("{"===t&&s++,"}"===t&&0==--s)return a}return -1}(t,l);if(-1===r){n+=t.slice(a);break}let i=t.slice(a,l),o=t.slice(l+1,r),c=i.trimStart().toLowerCase();n+=function(e,t,s){return s.startsWith("@")?e:(function(e){let t=[],s=0,n=0,a=null;for(let l=0;l<e.length;l++){let r=e[l],i=e[l-1];if(a){r===a&&"\\"!==i&&(a=null);continue}if('"'===r||"'"===r){a=r;continue}("("===r||"["===r||"{"===r)&&n++,(")"===r||"]"===r||"}"===r)&&(n=Math.max(0,n-1)),","===r&&0===n&&(t.push(e.slice(s,l)),s=l+1)}return t.push(e.slice(s)),t})(e).map(e=>(function(e,t){var s,n,a,l;let r=null!=(a=null==(s=e.match(/^\s*/))?void 0:s[0])?a:"",i=null!=(l=null==(n=e.match(/\s*$/))?void 0:n[0])?l:"",o=e.trim();return!o||o.startsWith(t)?e:/^(html|body|:root)\b/.test(o)?"".concat(r).concat(o.replace(/^(html|body|:root)\b/,t)).concat(i):"".concat(r).concat(t," ").concat(o).concat(i)})(e,t)).join(",")}(i,s,c),n+="{",n+=!function(e){return!!e.startsWith("@")&&!no.some(t=>e.startsWith(t))}(c)?o:e(o,s),n+="}",a=r+1}return n}(e,t)}(function(e,t){return e.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(e,s,n)=>{let a=n.trim();if(!a||a.startsWith("#")||a.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(a))return e;try{return"url(".concat(s).concat(new URL(a,t).toString()).concat(s,")")}catch(t){return e}})}(l,n)),r.setAttribute("data-localapp-app-asset",n),r.setAttribute("data-localapp-app-stylesheet","true"),document.head.appendChild(r),t.push(r)}for(let e of o){let s=nu(K,null!=(n=e.getAttribute("src"))?n:"");if(!s)continue;let a=document.createElement("script");a.type="module",a.src=s,a.setAttribute("data-localapp-app-asset",s),document.body.appendChild(a),t.push(a)}0===o.length&&L("App entry module not found in uploaded index.html")}catch(t){e||L(t instanceof Error?t.message:String(t))}}(),()=>{for(let s of(e=!0,t))s.remove()}},[H,J,K,d]);let ex=(0,l.useCallback)((e,t,s,n)=>{window.dispatchEvent(new MessageEvent("message",{data:{type:"localapp:platform_response",id:e,ok:t,...t?{result:s}:{error:n}},origin:window.location.origin}))},[]),eb=(0,l.useCallback)(async e=>{try{switch(e.capability){case"getCurrentUser":ex(e.id,!0,o);break;case"getServerTime":{let t=await fetch("/serve/".concat(O,"/api/time"),{credentials:"include"}),s=await t.json();if(!t.ok||!s.success)throw Error(s.error||"Server time request failed: ".concat(t.status));ex(e.id,!0,s.data);break}case"copyText":{let t=nw(e.payload),s="string"==typeof t.text?t.text:"";await navigator.clipboard.writeText(s),ex(e.id,!0,{success:!0});break}case"downloadFile":!function(e){let t=nw(e),s="string"==typeof t.filename&&t.filename.trim()?t.filename:"download",n="string"==typeof t.mimeType?t.mimeType:"application/octet-stream",a=t.data,l=a instanceof Blob?a:a instanceof ArrayBuffer?new Blob([a],{type:n}):new Blob(["string"==typeof a?a:JSON.stringify(null!=a?a:"")],{type:n}),r=URL.createObjectURL(l);try{let e=document.createElement("a");e.href=r,e.download=s,e.rel="noopener",document.body.appendChild(e),e.click(),e.remove()}finally{setTimeout(()=>URL.revokeObjectURL(r),0)}}(e.payload),ex(e.id,!0,{success:!0});break;case"confirm":{let t=nw(e.payload);_({id:e.id,title:"string"==typeof t.title&&t.title.trim()?t.title:"确认操作",message:"string"==typeof t.message?t.message:"",confirmText:"string"==typeof t.confirmText&&t.confirmText.trim()?t.confirmText:"确认",cancelText:"string"==typeof t.cancelText&&t.cancelText.trim()?t.cancelText:"取消",tone:"danger"===t.tone?"danger":"default"});break}case"openRoute":{let t=nw(e.payload),s="string"==typeof t.href?t.href:"";if(!s)throw Error("openRoute requires href");/^https?:\/\//i.test(s)?window.open(s,"_blank","noopener,noreferrer"):r.push(s),ex(e.id,!0,{success:!0});break}case"auth.login":i({returnTo:"".concat(window.location.pathname).concat(window.location.search).concat(window.location.hash)}),ex(e.id,!0,{success:!0});break;case"ai.open":Z(e=>null!=e?e:"system"),Y(!0),ex(e.id,!0,{success:!0});break;case"ai.close":Y(!1),ex(e.id,!0,{success:!0});break;case"ai.toggle":Z(e=>null!=e?e:"system"),Y(e=>!e),ex(e.id,!0,{success:!0});break;default:throw Error("Unknown platform capability: ".concat(e.capability))}}catch(t){ex(e.id,!1,void 0,t instanceof Error?t.message:String(t))}},[i,O,ex,r,o]);(0,l.useEffect)(()=>{function e(e){var t,s,n,a;(null==(t=e.data)?void 0:t.type)&&(!e.origin||e.origin===window.location.origin)&&(nf(s=e.data)&&"localapp:register_tools"===s.type?(Z("system"),et.current=e.data.tools,en.current=e.data.systemHint||""):nf(n=e.data)&&"localapp:ai_custom_mode"===n.type?Z("custom"):nf(a=e.data)&&"localapp:tool_result"===a.type?ep(e.data.callId,e.data.result,e.data.isError):nb(e.data)&&eb(e.data))}function t(e){let t=e.detail;nb(t)&&(e.preventDefault(),eb(t))}return window.addEventListener("message",e),window.addEventListener("localapp:platform_request",t),()=>{window.removeEventListener("message",e),window.removeEventListener("localapp:platform_request",t)}},[eb,ep]);let eg=(0,l.useCallback)(async()=>{if(!o)return void i();try{if(v){let e=await fetch("/api/favorites/".concat(encodeURIComponent(O)),{method:"DELETE",credentials:"include"});(await e.json()).success&&(y(!1),f(e=>Math.max(0,e-1)))}else{let e=await fetch("/api/favorites",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pagePath:O,pageName:s,ownerName:t})});(await e.json()).success&&(y(!0),f(e=>e+1))}}catch(e){}},[v,O,s,t,o,i]),ev=(0,l.useCallback)(e=>{E&&(ex(E.id,!0,e),_(null))},[E,ex]);return d?(0,n.jsxs)("div",{className:"flex h-screen flex-col bg-background","data-localapp-native-shell":!0,"data-localapp-app-resource-base":K,children:[(0,n.jsx)("div",{"data-localapp-shell-nav-background":!0,"data-testid":"shell-nav-background",inert:I?"true":void 0,"aria-hidden":!!I||void 0,className:"shrink-0",children:(0,n.jsx)(g,{pageName:s,user:o,favCount:h,isFavorited:v,onToggleFavorite:eg,onOpenIssues:ei,openIssueCount:P,aiMode:Q,aiOpen:G,onToggleAI:()=>Y(e=>!e),editSession:R,presenceSnapshot:z,bell:(0,n.jsx)(ne,{pagePath:O,pageName:s,ownerName:t,user:o,meta:m})})}),(0,n.jsxs)("div",{className:"relative flex-1 overflow-hidden","data-localapp-app-area":!0,children:[(0,n.jsxs)("div",{"data-localapp-app-background":!0,"data-testid":"app-background",inert:I?"true":void 0,"aria-hidden":!!I||void 0,className:"absolute inset-0",children:[(0,n.jsx)("div",{className:"h-full overflow-auto","data-localapp-app-container":!0,children:W?(0,n.jsx)("main",{className:"flex min-h-full items-center justify-center px-6 py-12","data-localapp-offline-state":!0,children:(0,n.jsxs)("section",{className:"w-full max-w-lg text-center",children:[(0,n.jsx)(nl.A,{className:"mx-auto size-10 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)("p",{className:"mt-5 text-sm font-medium text-muted-foreground",children:s}),(0,n.jsx)("h1",{className:"mt-2 text-xl font-semibold text-foreground",children:"应用暂时下线"}),(0,n.jsx)("p",{className:"mx-auto mt-2 max-w-md text-sm leading-6 text-muted-foreground",children:"应用当前不可访问,数据和设置均已保留。重新上线后即可继续使用。"}),(0,n.jsxs)("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-2",children:[(0,n.jsxs)(x.$,{variant:"outline",size:"sm",onClick:()=>window.location.reload(),children:[(0,n.jsx)(nr.A,{}),"刷新状态"]}),V&&(0,n.jsxs)(x.$,{size:"sm",onClick:()=>r.push("/my/apps/".concat(encodeURIComponent(s),"/settings?tab=manage")),children:[(0,n.jsx)(ni.A,{}),"应用设置"]})]})]})}):H?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{id:"root","data-localapp-app-root":!0,className:"min-h-full"}),T&&(0,n.jsx)("div",{className:"p-4 text-sm text-destructive",children:T})]}):(0,n.jsx)("main",{className:"flex min-h-full items-center justify-center px-6 py-12","data-localapp-load-unavailable":!0,children:(0,n.jsxs)("section",{className:"w-full max-w-lg text-center",children:[(0,n.jsx)(tD.A,{className:"mx-auto size-10 text-muted-foreground","aria-hidden":"true"}),(0,n.jsx)("p",{className:"mt-5 text-sm font-medium text-muted-foreground",children:s}),(0,n.jsx)("h1",{className:"mt-2 text-xl font-semibold text-foreground",children:"暂时无法加载应用"}),(0,n.jsx)("p",{className:"mx-auto mt-2 max-w-md text-sm leading-6 text-muted-foreground",children:"平台暂时无法确认应用状态。为保护应用数据,内容加载已暂停。"}),(0,n.jsx)("div",{className:"mt-6 flex justify-center",children:(0,n.jsxs)(x.$,{variant:"outline",size:"sm",onClick:()=>window.location.reload(),children:[(0,n.jsx)(nr.A,{}),"重新加载"]})})]})})}),"system"===Q&&(0,n.jsx)(s5,{open:G,onClose:()=>Y(!1),messages:ec,isRunning:ed,error:eu,onSend:em})]}),H&&(0,n.jsx)(nm,{peers:X}),I&&(0,n.jsx)(s2,{pagePath:O,pageName:s,user:o,onIssuesChanged:ef,selectedIssueId:w,selectedIssueNumber:N,onIssueNavigate:el,onClose:er})]}),E&&(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4",children:(0,n.jsxs)("div",{className:"w-full max-w-sm rounded-lg border bg-card p-5 shadow-lg",children:[(0,n.jsx)("h2",{className:"text-base font-semibold text-foreground",children:E.title}),E.message&&(0,n.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-sm leading-6 text-muted-foreground",children:E.message}),(0,n.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,n.jsx)(x.$,{variant:"ghost",size:"sm",onClick:()=>ev(!1),children:E.cancelText}),(0,n.jsx)(x.$,{variant:"danger"===E.tone?"destructive":"default",size:"sm",onClick:()=>ev(!0),children:E.confirmText})]})]})})]}):null}function nN(e){let t=window.location.pathname.match(/^\/platform-shell\/([^/]+)\/([^/]+)\/?$/);return t?"userId"===e?t[1]:t[2]:null}function nk(){var e,t,s,l,r,i;let o=(0,a.useParams)(),c=(0,a.useSearchParams)(),d=decodeURIComponent(null!=(s=null!=(t=null!=(e=c.get("userId"))?e:o.userId)?t:nN("userId"))?s:"placeholder"),u=decodeURIComponent(null!=(i=null!=(r=null!=(l=c.get("name"))?l:o.name)?r:nN("name"))?i:"placeholder");return(0,n.jsx)(nj,{userId:d,name:u})}},9561:(e,t,s)=>{"use strict";s.d(t,{J:()=>c});var n=s(6472),a=s(2212),l=s(9443),r=s(2770),i=s(3906);let o=(0,r.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=a.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,n.jsx)(l.b,{ref:t,className:(0,i.cn)(o(),s),...a})});c.displayName=l.b.displayName}}]);
|