@testver/testver 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE +88 -69
  2. package/README.md +6 -2
  3. package/bin/testver.js +9 -1
  4. package/dist/index.js +52650 -35771
  5. package/package.json +179 -178
  6. package/src/ui/static/agents/antigravity.svg +76 -0
  7. package/src/ui/static/agents/codex.svg +3 -0
  8. package/src/ui/static/agents/gemini.svg +1 -0
  9. package/src/ui/static/agents/opencode.svg +4 -0
  10. package/src/ui/static/agents/vscode.svg +17 -0
  11. package/src/ui/static/assets/AIPanel-RWO8Cd9w.js +32 -0
  12. package/src/ui/static/assets/AIRecordPanel-DnreS585.js +40 -0
  13. package/src/ui/static/assets/AIStreamUI-C1gHJtlF.js +9 -0
  14. package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-C8bWUelu.js} +5 -5
  15. package/src/ui/static/assets/APITestingPage-DwL67hqL.js +19 -0
  16. package/src/ui/static/assets/AboutPage-CynLB95E.js +1 -0
  17. package/src/ui/static/assets/AccessTokensTab-BdevOmpE.js +1 -0
  18. package/src/ui/static/assets/AdvancedPage-BeM7aB8b.js +3 -0
  19. package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-C5ddYfRk.js} +1 -1
  20. package/src/ui/static/assets/AuditLogPage-DYcUdJoj.js +1 -0
  21. package/src/ui/static/assets/ChangesSummary-BjNMwGIZ.js +3 -0
  22. package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-BQOEtv-R.js} +3 -3
  23. package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-D_N9188T.js} +1 -1
  24. package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-8bDSphY1.js} +2 -2
  25. package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-C7_JADb7.js} +1 -1
  26. package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-B22yRPyV.js} +1 -1
  27. package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-Arv4Ac-b.js} +72 -72
  28. package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-BShNSbLf.js} +1 -1
  29. package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-xrS_AnfS.js} +1 -1
  30. package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-Bcr9T1jW.js} +18 -18
  31. package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-DXL2Sv40.js} +12 -12
  32. package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-BcjzRd7T.js} +36 -36
  33. package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DNYU9Ce0.js} +1 -1
  34. package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BKlWqjgN.js} +1 -1
  35. package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-1LlyEDEe.js} +1 -1
  36. package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
  37. package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-Dyy_iHl9.js} +1 -1
  38. package/src/ui/static/assets/MobileRunPicker-Cf5rm469.js +1 -0
  39. package/src/ui/static/assets/MobileRunTarget-C4M4YJJh.js +6 -0
  40. package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-BKVbxFZK.js} +1 -1
  41. package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Bi-28tJi.js} +1 -1
  42. package/src/ui/static/assets/PipelinesPanel-BtO3iSJ4.js +1 -0
  43. package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BgZ4VDC-.js} +1 -1
  44. package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-BVGbmVP7.js} +1 -1
  45. package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-dzPInzgb.js} +1 -1
  46. package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-LOf1PXlb.js} +2 -2
  47. package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-Ce4OI8lf.js} +1 -1
  48. package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-DFxCQ8cY.js} +48 -48
  49. package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DD-uj8gk.js} +115 -115
  50. package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-DDwFB4tA.js} +1 -1
  51. package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CkIpY3v3.js} +1 -1
  52. package/src/ui/static/assets/ScriptMappingPage-DQQoR6sR.js +1 -0
  53. package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-CenIxD7b.js} +1 -1
  54. package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-DAV_0y0m.js} +83 -83
  55. package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-CqSLFKT1.js} +1 -1
  56. package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BvqC9oKw.js} +14 -14
  57. package/src/ui/static/assets/TestExplorerPage-Bdnll77k.js +7 -0
  58. package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-CCNE688A.js} +10 -10
  59. package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-T6D25i6-.js} +5 -5
  60. package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
  61. package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CoDk5eAS.js} +1 -1
  62. package/src/ui/static/assets/TestverMcpPage-Dte0qSXp.js +34 -0
  63. package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-BNroxCoo.js} +2 -2
  64. package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-BU4MuDJZ.js} +10 -10
  65. package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BP5k7AqE.js} +83 -83
  66. package/src/ui/static/assets/clipboard-BIEd7Ccc.js +1 -0
  67. package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-BPORgy-e.js} +1 -1
  68. package/src/ui/static/assets/index-BlA8ntjb.js +47 -0
  69. package/src/ui/static/assets/index-Co4_SlGD.css +1 -0
  70. package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
  71. package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-B9ZRW6ts.js} +1 -1
  72. package/src/ui/static/assets/runSelected-BoPm1sz-.js +1 -0
  73. package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
  74. package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
  75. package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-B4Otsv-N.js} +1 -1
  76. package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector--JZhbYrT.js} +1 -1
  77. package/src/ui/static/assets/{useOwnership-U0AfKBRo.js → useOwnership-BhPOiYzy.js} +1 -1
  78. package/src/ui/static/assets/useSuites-GN_K2mHc.js +1 -0
  79. package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
  80. package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-BGhkGHKy.js} +1 -1
  81. package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-DX5ES6x8.js} +1 -1
  82. package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-ommXjx0q.js} +2 -2
  83. package/src/ui/static/assets/useTestResults-DWjvm8gm.js +1 -0
  84. package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
  85. package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
  86. package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-Cm92aSc5.js} +1426 -1421
  87. package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
  88. package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
  89. package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
  90. package/src/ui/static/index.html +479 -479
  91. package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
  92. package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
  93. package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
  94. package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
  95. package/src/ui/static/assets/AboutPage-CjEqKB-q.js +0 -1
  96. package/src/ui/static/assets/AdvancedPage-4kAcpE8Y.js +0 -3
  97. package/src/ui/static/assets/AuditLogPage-BQjOzQje.js +0 -1
  98. package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
  99. package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
  100. package/src/ui/static/assets/MobileRunPicker-0h-N2c6d.js +0 -1
  101. package/src/ui/static/assets/MobileRunTarget-Bo_xekig.js +0 -6
  102. package/src/ui/static/assets/PipelinesPanel-PmmPu8pj.js +0 -1
  103. package/src/ui/static/assets/ScriptMappingPage-7vHuvhQw.js +0 -1
  104. package/src/ui/static/assets/TestExplorerPage-gYLhCD4d.js +0 -7
  105. package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
  106. package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
  107. package/src/ui/static/assets/runSelected-WlgnZcSF.js +0 -1
  108. package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
  109. package/src/ui/static/assets/useTestResults-D5EwGIX9.js +0 -1
  110. package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
@@ -1,72 +1,72 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-quill-W-RoQfb6.js","assets/vendor-react-CTbHBddL.js","assets/vendor-quill-CTpA5PSA.css"])))=>i.map(i=>d[i]);
2
- import{b as tn,fy as br,a8 as yr,b4 as sn}from"./index-BYVxKLrT.js";import{r as M,R as He,j as e}from"./vendor-react-CTbHBddL.js";import"./vendor-quill-W-RoQfb6.js";import{a as Ke,u as rn,b as nn}from"./useTabParam-ChbOedP1.js";import{u as an}from"./useDebouncedValue-BsHptIvX.js";import{E as on}from"./ExportButton-Dt5RhL-h.js";import{ay as Vs,az as ln,aA as cn,aB as vr,aC as dn,aD as un,J as mn,F as pn,aE as xn,aF as fn,aG as hn,aH as gn}from"./useTestManagement-Xm4Bcx3u.js";import{u as jr}from"./vendor-query-BrzmPFT3.js";import{u as Nr,f as bn,d as yn,e as vn,g as jn,c as Nn}from"./useJiraConnector-D5ysBBvz.js";import{e as Ts,b4 as wr,v as Tr,c7 as wn,c8 as Tn,t as _n,r as An,X as Qe,bb as _s,b7 as Xt,q as _r,al as As,_ as qt,u as Ar,bd as Sn,g as Ss,a0 as Nt,b0 as Cn,o as kn,ah as En,aa as Js,bw as Ks,aJ as Dn,a5 as Xs,dj as Rn,a6 as Sr,y as Cr}from"./vendor-icons-BKPiFyYV.js";/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */function Qs(s,n){(n==null||n>s.length)&&(n=s.length);for(var u=0,p=Array(n);u<n;u++)p[u]=s[u];return p}function On(s){if(Array.isArray(s))return s}function In(s,n){var u=s==null?null:typeof Symbol<"u"&&s[Symbol.iterator]||s["@@iterator"];if(u!=null){var p,f,y,b,g=[],R=!0,H=!1;try{if(y=(u=u.call(s)).next,n!==0)for(;!(R=(p=y.call(u)).done)&&(g.push(p.value),g.length!==n);R=!0);}catch(j){H=!0,f=j}finally{try{if(!R&&u.return!=null&&(b=u.return(),Object(b)!==b))return}finally{if(H)throw f}}return g}}function Ln(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function Pn(s,n){return On(s)||In(s,n)||Mn(s,n)||Ln()}function Mn(s,n){if(s){if(typeof s=="string")return Qs(s,n);var u={}.toString.call(s).slice(8,-1);return u==="Object"&&s.constructor&&(u=s.constructor.name),u==="Map"||u==="Set"?Array.from(s):u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u)?Qs(s,n):void 0}}const kr=Object.entries,Zs=Object.setPrototypeOf,zn=Object.isFrozen,Er=Object.getPrototypeOf,Dr=Object.getOwnPropertyDescriptor;let re=Object.freeze,ae=Object.seal,vt=Object.create,Rr=typeof Reflect<"u"&&Reflect,Cs=Rr.apply,ks=Rr.construct;re||(re=function(n){return n});ae||(ae=function(n){return n});Cs||(Cs=function(n,u){for(var p=arguments.length,f=new Array(p>2?p-2:0),y=2;y<p;y++)f[y-2]=arguments[y];return n.apply(u,f)});ks||(ks=function(n){for(var u=arguments.length,p=new Array(u>1?u-1:0),f=1;f<u;f++)p[f-1]=arguments[f];return new n(...p)});const qe=V(Array.prototype.forEach),Un=V(Array.prototype.lastIndexOf),er=V(Array.prototype.pop),Mt=V(Array.prototype.push),Fn=V(Array.prototype.slice),$n=V(Array.prototype.splice),jt=Array.isArray,xs=Or(Set),fs=V(Set.prototype.add),zt=V(Set.prototype.has),ct=V(String.prototype.toLowerCase),hs=V(String.prototype.toString),tr=V(String.prototype.match),Ut=V(String.prototype.replace),sr=V(String.prototype.indexOf),qn=V(String.prototype.trim),Bn=V(Number.prototype.toString),Hn=V(Boolean.prototype.toString),rr=typeof BigInt>"u"?null:V(BigInt.prototype.toString),nr=typeof Symbol>"u"?null:V(Symbol.prototype.toString),ge=V(Object.prototype.hasOwnProperty),Ft=V(Object.prototype.toString),ne=V(RegExp.prototype.test),Be=Or(TypeError);function V(s){return function(n){n instanceof RegExp&&(n.lastIndex=0);for(var u=arguments.length,p=new Array(u>1?u-1:0),f=1;f<u;f++)p[f-1]=arguments[f];return Cs(s,n,p)}}function Or(s){return function(){for(var n=arguments.length,u=new Array(n),p=0;p<n;p++)u[p]=arguments[p];return ks(s,u)}}function L(s,n){let u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ct;if(Zs&&Zs(s,null),!jt(n))return s;let p=n.length;for(;p--;){let f=n[p];if(typeof f=="string"){const y=u(f);y!==f&&(zn(n)||(n[p]=y),f=y)}s[f]=!0}return s}function Wn(s){for(let n=0;n<s.length;n++)ge(s,n)||(s[n]=null);return s}function je(s){const n=vt(null);for(const p of kr(s)){var u=Pn(p,2);const f=u[0],y=u[1];ge(s,f)&&(jt(y)?n[f]=Wn(y):y&&typeof y=="object"&&y.constructor===Object?n[f]=je(y):n[f]=y)}return n}function Gn(s){switch(typeof s){case"string":return s;case"number":return Bn(s);case"boolean":return Hn(s);case"bigint":return rr?rr(s):"0";case"symbol":return nr?nr(s):"Symbol()";case"undefined":return Ft(s);case"function":case"object":{if(s===null)return Ft(s);const n=s,u=we(n,"toString");if(typeof u=="function"){const p=u(n);return typeof p=="string"?p:Ft(p)}return Ft(s)}default:return Ft(s)}}function we(s,n){for(;s!==null;){const p=Dr(s,n);if(p){if(p.get)return V(p.get);if(typeof p.value=="function")return V(p.value)}s=Er(s)}function u(){return null}return u}function Yn(s,n){for(;s!==null;){const u=Dr(s,n);if(u)return u.get?V(u.get):null;s=Er(s)}return null}function Vn(s){try{return ne(s,""),!0}catch{return!1}}const ar=re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),gs=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),bs=re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Jn=re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ys=re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Kn=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ir=re(["#text"]),or=re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),vs=re(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),lr=re(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Vt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Xn=ae(/{{[\w\W]*|^[\w\W]*}}/g),Qn=ae(/<%[\w\W]*|^[\w\W]*%>/g),Zn=ae(/\${[\w\W]*/g),ea=ae(/^data-[\-\w.\u00B7-\uFFFF]+$/),ta=ae(/^aria-[\-\w]+$/),cr=ae(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),sa=ae(/^(?:\w+script|data):/i),ra=ae(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),na=ae(/^html$/i),aa=ae(/^[a-z][.\w]*(-[.\w]+)+$/i),js=ae(/<[/\w!]/g),dr=ae(/<[/\w]/g),ia=ae(/<\/no(script|embed|frames)/i),ur=ae(/\/>/i),Z={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},oa=re(L({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),la=function(){return typeof window>"u"?null:window},ca=function(n,u){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let p=null;const f="data-tt-policy-suffix";u&&u.hasAttribute(f)&&(p=u.getAttribute(f));const y="dompurify"+(p?"#"+p:"");try{return n.createPolicy(y,{createHTML(b){return b},createScriptURL(b){return b}})}catch{return console.warn("TrustedTypes policy "+y+" could not be created."),null}},mr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Xe=function(n,u,p,f){return ge(n,u)&&jt(n[u])?L(f.base?je(f.base):{},n[u],f.transform):p},Ns=function(n,u,p){const f=ge(n,u)?n[u]:void 0;return f&&typeof f=="object"?je(f):p()};function Ir(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:la();const n=c=>Ir(c);if(n.version="3.4.17",n.removed=[],!s||!s.document||s.document.nodeType!==Z.document||!s.Element)return n.isSupported=!1,n;let u=s.document;const p=u,f=p.currentScript;s.DocumentFragment;const y=s.HTMLTemplateElement,b=s.Node,g=s.Element,R=s.NodeFilter;s.NamedNodeMap===void 0&&(s.NamedNodeMap||s.MozNamedAttrMap),s.HTMLFormElement;const H=s.DOMParser,j=s.trustedTypes,_=g.prototype,T=we(_,"cloneNode"),E=we(_,"remove"),F=we(_,"removeAttributeNode"),J=we(_,"nextSibling"),X=we(_,"childNodes"),K=we(_,"parentNode"),Q=we(_,"shadowRoot"),de=we(_,"attributes"),O=b&&b.prototype?we(b.prototype,"nodeType"):null,Y=b&&b.prototype?we(b.prototype,"nodeName"):null,d=b&&b.prototype?we(b.prototype,"ownerDocument"):null,D=function(t){return O?O(t):t.nodeType},z=function(t){return Y?Y(t):t.nodeName},me=Yn(_,"namespaceURI"),Ee=function(t){return me?me(t):t.namespaceURI};if(typeof y=="function"){const c=u.createElement("template");c.content&&c.content.ownerDocument&&(u=c.content.ownerDocument)}let m,A="",ie,pe=!1,Pe=0;const Ze=function(){if(Pe>0)throw Be('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},be=function(t){Ze(),Pe++;try{return m.createHTML(t)}finally{Pe--}},et=function(t){Ze(),Pe++;try{return m.createScriptURL(t)}finally{Pe--}},De=function(){return pe||(ie=ca(j,f),pe=!0),ie},Re=u,tt=Re.implementation,Te=Re.createNodeIterator,Me=Re.createDocumentFragment,st=Re.getElementsByTagName,wt=p.importNode;let W=mr();n.isSupported=typeof kr=="function"&&typeof K=="function"&&tt&&tt.createHTMLDocument!==void 0;const Os=Xn,Is=Qn,Tt=Zn,ts=ea,ss=ta,rt=sa,Bt=ra,nt=aa;let rs=cr,U=null;const ut=L({},[...ar,...gs,...bs,...ys,...ir]);let $=null;const ze=L({},[...or,...vs,...lr,...Vt]);let ye=Object.seal(vt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Oe=null,Ne=null;const ve=Object.seal(vt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let _e=!0,Ue=!0,xe=!1,at=!0,oe=!1,I=!0,Ae=!1,Ie=!1,le=null,it=null,mt=!1,We=!1,ot=!1,Se=!1,_t=!0,At=!1;const Ht="user-content-";let St=!0,Ct=!1,Fe=null,Ge={},$e=null;const kt=L({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Et=null;const Dt=L({},["audio","video","img","source","image","track"]);let Rt=null;const Ot=L({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),pt="http://www.w3.org/1998/Math/MathML",l="http://www.w3.org/2000/svg",h="http://www.w3.org/1999/xhtml";let S=h,G=!1,C=null;const P=L({},[pt,l,h],hs),lt=re(["mi","mo","mn","ms","mtext"]);let Ye=L({},lt);const xt=re(["annotation-xml"]);let Ce=L({},xt);const a=L({},["title","style","font","a","script"]);let te=null;const x=["application/xhtml+xml","text/html"],ce="text/html";let q=null,w=null;const It=u.createElement("form"),ft=function(t){return t instanceof RegExp||t instanceof Function},ns=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(w&&w===t)return;(!t||typeof t!="object")&&(t={}),t=je(t),te=x.indexOf(t.PARSER_MEDIA_TYPE)===-1?ce:t.PARSER_MEDIA_TYPE,q=te==="application/xhtml+xml"?hs:ct,U=Xe(t,"ALLOWED_TAGS",ut,{transform:q}),$=Xe(t,"ALLOWED_ATTR",ze,{transform:q}),C=Xe(t,"ALLOWED_NAMESPACES",P,{transform:hs}),Rt=Xe(t,"ADD_URI_SAFE_ATTR",Ot,{transform:q,base:Ot}),Et=Xe(t,"ADD_DATA_URI_TAGS",Dt,{transform:q,base:Dt}),$e=Xe(t,"FORBID_CONTENTS",kt,{transform:q}),Oe=Xe(t,"FORBID_TAGS",je({}),{transform:q}),Ne=Xe(t,"FORBID_ATTR",je({}),{transform:q}),Ge=ge(t,"USE_PROFILES")?t.USE_PROFILES&&typeof t.USE_PROFILES=="object"?je(t.USE_PROFILES):t.USE_PROFILES:!1,_e=t.ALLOW_ARIA_ATTR!==!1,Ue=t.ALLOW_DATA_ATTR!==!1,xe=t.ALLOW_UNKNOWN_PROTOCOLS||!1,at=t.ALLOW_SELF_CLOSE_IN_ATTR!==!1,oe=t.SAFE_FOR_TEMPLATES||!1,I=t.SAFE_FOR_XML!==!1,Ae=t.WHOLE_DOCUMENT||!1,We=t.RETURN_DOM||!1,ot=t.RETURN_DOM_FRAGMENT||!1,Se=t.RETURN_TRUSTED_TYPE||!1,mt=t.FORCE_BODY||!1,_t=t.SANITIZE_DOM!==!1,At=t.SANITIZE_NAMED_PROPS||!1,St=t.KEEP_CONTENT!==!1,Ct=t.IN_PLACE||!1,rs=Vn(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:cr,S=typeof t.NAMESPACE=="string"?t.NAMESPACE:h,Ye=Ns(t,"MATHML_TEXT_INTEGRATION_POINTS",()=>L({},lt)),Ce=Ns(t,"HTML_INTEGRATION_POINTS",()=>L({},xt));const r=Ns(t,"CUSTOM_ELEMENT_HANDLING",()=>vt(null));if(ye=vt(null),ge(r,"tagNameCheck")&&ft(r.tagNameCheck)&&(ye.tagNameCheck=r.tagNameCheck),ge(r,"attributeNameCheck")&&ft(r.attributeNameCheck)&&(ye.attributeNameCheck=r.attributeNameCheck),ge(r,"allowCustomizedBuiltInElements")&&typeof r.allowCustomizedBuiltInElements=="boolean"&&(ye.allowCustomizedBuiltInElements=r.allowCustomizedBuiltInElements),ae(ye),oe&&(Ue=!1),ot&&(We=!0),Ge&&(U=L({},ir),$=vt(null),Ge.html===!0&&(L(U,ar),L($,or)),Ge.svg===!0&&(L(U,gs),L($,vs),L($,Vt)),Ge.svgFilters===!0&&(L(U,bs),L($,vs),L($,Vt)),Ge.mathMl===!0&&(L(U,ys),L($,lr),L($,Vt))),ve.tagCheck=null,ve.attributeCheck=null,ge(t,"ADD_TAGS")&&(typeof t.ADD_TAGS=="function"?ve.tagCheck=t.ADD_TAGS:jt(t.ADD_TAGS)&&(U===ut&&(U=je(U)),L(U,t.ADD_TAGS,q))),ge(t,"ADD_ATTR")&&(typeof t.ADD_ATTR=="function"?ve.attributeCheck=t.ADD_ATTR:jt(t.ADD_ATTR)&&($===ze&&($=je($)),L($,t.ADD_ATTR,q))),ge(t,"ADD_FORBID_CONTENTS")&&jt(t.ADD_FORBID_CONTENTS)&&($e===kt&&($e=je($e)),L($e,t.ADD_FORBID_CONTENTS,q)),St&&(U["#text"]=!0),Ae&&L(U,["html","head","body"]),U.table&&(L(U,["tbody"]),delete Oe.tbody),t.TRUSTED_TYPES_POLICY){if(typeof t.TRUSTED_TYPES_POLICY.createHTML!="function")throw Be('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof t.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Be('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const i=m;m=t.TRUSTED_TYPES_POLICY;try{A=be("")}catch(o){throw m=i,o}}else t.TRUSTED_TYPES_POLICY===null?(m=void 0,A=""):(m===void 0&&(m=De()),m&&typeof A=="string"&&(A=be("")));re&&re(t),w=t},Ls=L({},[...gs,...bs,...Jn]),Ps=L({},[...ys,...Kn]),Fr=function(t,r,i){return r.namespaceURI===h?t==="svg":r.namespaceURI===pt?t==="svg"&&(i==="annotation-xml"||Ye[i]):!!Ls[t]},$r=function(t,r,i){return r.namespaceURI===h?t==="math":r.namespaceURI===l?t==="math"&&Ce[i]:!!Ps[t]},qr=function(t,r,i){return r.namespaceURI===l&&!Ce[i]||r.namespaceURI===pt&&!Ye[i]?!1:!Ps[t]&&(a[t]||!Ls[t])},Br=function(t){const r=Ee(t),i=ct(z(t)),o=K(t);let v,N;return o&&D(o)===Z.element?(v={namespaceURI:Ee(o)},N=ct(z(o))):(v={namespaceURI:S},N="template"),C[r]?r===l?Fr(i,v,N):r===pt?$r(i,v,N):r===h?qr(i,v,N):!!(te==="application/xhtml+xml"&&C[r]):!1},Ve=function(t){Mt(n.removed,{element:t});try{K(t).removeChild(t)}catch{if(E(t),!K(t))throw Be("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ms=function(t,r,i){try{F(t,r)}catch{try{t.removeAttribute(i)}catch{}}},as=function(t){os(t);const r=X(t);r&&qe(Fn(r),o=>{try{E(o)}catch{}});const i=D(t)===Z.element?de(t):null;if(i)for(let o=i.length-1;o>=0;--o){const v=i[o],N=v&&v.name;typeof N=="string"&&Ms(t,v,N)}},ht=function(t,r,i){if(!i)try{i=r.getAttributeNode(t)}catch{i=null}Mt(n.removed,{attribute:i||null,from:r});try{i?F(r,i):r.removeAttribute(t)}catch{try{r.removeAttribute(t)}catch{}}if(t==="is")if(We||ot)try{Ve(r)}catch{}else try{r.setAttribute(t,"")}catch{}},zs=function(t){const r=de(t);if(r)for(let i=r.length-1;i>=0;--i){const o=r[i],v=o&&o.name;typeof v!="string"||$[q(v)]||Ms(t,o,v)}},is=function(t,r){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const o=[t];for(;o.length>0;){const v=o.pop();if(r(v)===!1)continue;if(i&&D(v)===Z.element){const k=Q(v);Je(k)&&o.push(k)}const N=X(v);if(N)for(let k=N.length-1;k>=0;--k)o.push(N[k])}},os=function(t){is(t,r=>{D(r)===Z.element&&zs(r)})},ls=function(t){const r=[];return is(t,i=>{r.push(i)},!0),r},Hr=function(t,r){const i=xs();qe(ls(t),o=>{D(o)===Z.element&&fs(i,o)}),qe(r,o=>{D(o)===Z.element&&!zt(i,o)&&zs(o)})},Us=function(t,r){let i=!1;return qe(n.removed,o=>{o.element&&(i=i||o.element===t,os(o.element))}),Hr(t,r),i},Wr=8,Gr=function(t,r){const i=Fe;let o=null;const v=()=>(o||(o=xs(),qe(r,N=>{fs(o,N)})),o);for(let N=0;;N++){const k=ls(t),ee=[t];let Le=!1;if(qe(k,ue=>{D(ue)===Z.documentFragment?Mt(ee,ue):!Le&&!zt(i,ue)&&(Le=zt(v(),ue))}),!Le)return;if(N>=Wr)throw Be("the tree kept changing during in-place sanitization; refusing to return it");qe(ee,(ue,fe)=>{Yr(ue,fe>0,t,v())})}},Yr=function(t,r,i,o){const v=cs(t);let N;for(;N=v.nextNode();)!zt(o,N)||zt(Fe,N)||(r&&ke(W.uponSanitizeShadowNode,N,null),us(N,i),ms(N,i),Je(N.content)&&Pt(N.content))},Vr=function(t){Fe&&fs(Fe,t)},Fs=function(t,r){return I?t==="patchsrc"?!0:t==="for"&&r!=="label"&&r!=="output":!1},Jr=function(t){I&&is(t,r=>{const i=D(r);if(i===Z.processingInstruction||i===Z.comment&&ne(dr,r.data)){try{E(r)}catch{}return!1}if(i===Z.element){const o=r,v=q(z(r));try{o.hasAttribute&&o.hasAttribute("patchsrc")&&o.removeAttribute("patchsrc"),o.hasAttribute&&o.hasAttribute("for")&&Fs("for",v)&&o.removeAttribute("for")}catch{}}return!0})},$s=function(t){let r=null,i=null;if(mt)t="<remove></remove>"+t;else{const N=tr(t,/^[\r\n\t ]+/);i=N&&N[0]}te==="application/xhtml+xml"&&S===h&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const o=m?be(t):t;if(S===h)try{r=new H().parseFromString(o,te)}catch{}if(!r||!r.documentElement){r=tt.createDocument(S,"template",null);try{r.documentElement.innerHTML=G?A:o}catch{}}const v=r.body||r.documentElement;return t&&i&&v.insertBefore(u.createTextNode(i),v.childNodes[0]||null),S===h?st.call(r,Ae?"html":"body")[0]:Ae?r.documentElement:v},cs=function(t){const r=d?d(t):t.ownerDocument;return Te.call(r||t,t,R.SHOW_ELEMENT|R.SHOW_COMMENT|R.SHOW_TEXT|R.SHOW_PROCESSING_INSTRUCTION|R.SHOW_CDATA_SECTION,null)},Wt=function(t){return t=Ut(t,Os," "),t=Ut(t,Is," "),t=Ut(t,Tt," "),t},ds=function(t){var r;qs(t);const i=(r=t.querySelectorAll)===null||r===void 0?void 0:r.call(t,"template");i&&qe(i,o=>{Je(o.content)&&ds(o.content)})},qs=function(t){t.normalize();const r=d?d(t):t.ownerDocument,i=Te.call(r||t,t,R.SHOW_TEXT|R.SHOW_COMMENT|R.SHOW_CDATA_SECTION|R.SHOW_PROCESSING_INSTRUCTION,null);let o=i.nextNode();for(;o;)o.data=Wt(o.data),o=i.nextNode()},Gt=function(t){const r=Y?Y(t):null;return typeof r!="string"||q(r)!=="form"?!1:typeof t.nodeName!="string"||typeof t.textContent!="string"||typeof t.removeChild!="function"||t.attributes!==de(t)||typeof t.removeAttribute!="function"||typeof t.removeAttributeNode!="function"||typeof t.getAttributeNode!="function"||typeof t.setAttribute!="function"||typeof t.namespaceURI!="string"||typeof t.insertBefore!="function"||typeof t.hasChildNodes!="function"||t.nodeType!==O(t)||t.childNodes!==X(t)},Je=function(t){if(!O||typeof t!="object"||t===null)return!1;try{return O(t)===Z.documentFragment}catch{return!1}},Lt=function(t){if(!O||typeof t!="object"||t===null)return!1;try{return typeof O(t)=="number"}catch{return!1}};function ke(c,t,r){c.length!==0&&qe(c,i=>{i.call(n,t,r,w)})}const Kr=function(t,r){return!!(I&&t.hasChildNodes()&&!Lt(t.firstElementChild)&&ne(js,t.textContent)&&ne(js,t.innerHTML)||I&&oa[r]&&D(t)===Z.element&&Ee(t)===h&&(Lt(t.firstElementChild)||typeof t.textContent=="string"&&ne(js,t.textContent))||t.nodeType===Z.processingInstruction||I&&t.nodeType===Z.comment&&ne(dr,t.data))},Yt=function(t,r){if(t instanceof RegExp)return ne(t,r);if(t instanceof Function){for(var i=arguments.length,o=new Array(i>2?i-2:0),v=2;v<i;v++)o[v-2]=arguments[v];return!!t(r,...o)}return!1},Xr=function(t,r,i){if(!Oe[r]&&Ws(r)&&Yt(ye.tagNameCheck,r))return!1;if(St&&!$e[r]&&!$e[ct(r)]){const o=K(t),v=X(t);if(v&&o){const N=v.length;for(let k=N-1;k>=0;--k){const ee=t===i?T(v[k],!0):v[k];o.insertBefore(ee,J(t))}}}return Ve(t),!0},Bs=function(t,r,i,o){return t.length===0?r:r===i||r===o?je(r):r},gt=function(t,r){return t===r||K(t)!==null?!1:(Ct&&os(t),!0)},us=function(t,r){if(Vr(t),ke(W.beforeSanitizeElements,t,null),gt(t,r))return!0;if(Gt(t))return Ve(t),!0;const i=q(z(t));if(U=Bs(W.uponSanitizeElement,U,ut,le),ke(W.uponSanitizeElement,t,{tagName:i,allowedTags:U}),gt(t,r))return!0;if(Kr(t,i))return Ve(t),!0;if(Oe[i]||!(ve.tagCheck instanceof Function&&ve.tagCheck(i))&&!U[i]){const o=Xr(t,i,r);return o===!1&&(ke(W.afterSanitizeElements,t,null),gt(t,r))?!0:o}if(D(t)===Z.element&&!Br(t)||(i==="noscript"||i==="noembed"||i==="noframes")&&ne(ia,t.innerHTML))return Ve(t),!0;if(oe&&t.nodeType===Z.text){const o=Wt(t.textContent);t.textContent!==o&&(Mt(n.removed,{element:t.cloneNode()}),t.textContent=o)}return ke(W.afterSanitizeElements,t,null),gt(t,r)},Hs=function(t,r,i){if(Ne[r]||Fs(r,t)||_t&&(r==="id"||r==="name")&&(i in u||i in It))return!1;const o=$[r]||ve.attributeCheck instanceof Function&&ve.attributeCheck(r,t);return Ue&&ne(ts,r)||_e&&ne(ss,r)?!0:o?Rt[r]||ne(rs,Ut(i,Bt,""))||(r==="src"||r==="xlink:href"||r==="href")&&t!=="script"&&sr(i,"data:")===0&&Et[t]||xe&&!ne(rt,Ut(i,Bt,""))?!0:!i:Ws(t)&&Yt(ye.tagNameCheck,t)&&Yt(ye.attributeNameCheck,r,t)||r==="is"&&ye.allowCustomizedBuiltInElements&&Yt(ye.tagNameCheck,i)},Qr=L({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ws=function(t){return!Qr[ct(t)]&&ne(nt,t)},Zr=function(t,r,i,o){if(m&&typeof j=="object"&&typeof j.getAttributeType=="function"&&!i)switch(j.getAttributeType(t,r)){case"TrustedHTML":return be(o);case"TrustedScriptURL":return et(o)}return o},en=function(t,r,i,o){try{return i?t.setAttributeNS(i,r,o):t.setAttribute(r,o),Gt(t)?(Ve(t),!1):!0}catch{return ht(r,t),!1}},Gs=function(t,r){return I&&ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,r)?!0:ct(t)==="attributename"&&tr(r,"href")!==null},ms=function(t,r){if(ke(W.beforeSanitizeAttributes,t,null),gt(t,r))return;const i=t.attributes;if(!i||Gt(t))return;$=Bs(W.uponSanitizeAttribute,$,ze,it);const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$,forceKeepAttr:void 0};let v=i.length;const N=q(t.nodeName);for(;v--;){const k=i[v],ee=k.name,Le=k.namespaceURI,ue=k.value,fe=q(ee),bt=ue;let he=ee==="value"?bt:qn(bt),Ys=!1;if(o.attrName=fe,o.attrValue=he,o.keepAttr=!0,o.forceKeepAttr=void 0,ke(W.uponSanitizeAttribute,t,o),he=o.attrValue,At&&(fe==="id"||fe==="name")&&sr(he,Ht)!==0&&(ht(ee,t,k),he=Ht+he,Ys=!0),Gs(ee,he)){ht(ee,t,k);continue}if(!o.forceKeepAttr){if(!o.keepAttr){ht(ee,t,k);continue}if(!at&&ne(ur,he)){ht(ee,t,k);continue}if(oe&&(he=Wt(he)),!Hs(N,fe,he)){ht(ee,t,k);continue}he=Zr(N,fe,Le,he),he!==bt&&en(t,ee,Le,he)&&Ys&&er(n.removed)}}ke(W.afterSanitizeAttributes,t,null),gt(t,r)},Pt=function(t){let r=null;const i=cs(t);for(ke(W.beforeSanitizeShadowDOM,t,null);r=i.nextNode();)if(ke(W.uponSanitizeShadowNode,r,null),us(r,t),ms(r,t),Je(r.content)&&Pt(r.content),D(r)===Z.element){const o=Q(r);Je(o)&&(ps(o),Pt(o))}oe&&qs(t),ke(W.afterSanitizeShadowDOM,t,null)},ps=function(t){const r=[{node:t,shadow:null}];for(;r.length>0;){const i=r.pop();if(i.shadow){Pt(i.shadow);continue}const o=i.node,v=D(o)===Z.element,N=X(o);if(N)for(let k=N.length-1;k>=0;--k)r.push({node:N[k],shadow:null});if(v){const k=Y?Y(o):null;if(typeof k=="string"&&q(k)==="template"){const ee=o.content;Je(ee)&&r.push({node:ee,shadow:null})}}if(v){const k=Q(o);Je(k)&&r.push({node:null,shadow:k},{node:k,shadow:null})}}};return n.sanitize=function(c){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=null,i=null,o=null,v=null;if(G=!c,G&&(c="<!-->"),typeof c!="string"&&!Lt(c)&&(c=Gn(c),typeof c!="string"))throw Be("dirty is not a string, aborting");if(!n.isSupported)return c;Ie?(U=le,$=it):ns(t),(W.uponSanitizeElement.length>0||W.uponSanitizeAttribute.length>0)&&(U=je(U)),W.uponSanitizeAttribute.length>0&&($=je($)),n.removed=[];const N=Ct&&typeof c!="string"&&Lt(c);let k=[];const ee=Fe;if(N){Jr(c);const fe=z(c);if(typeof fe=="string"){const bt=q(fe);if(!U[bt]||Oe[bt])throw as(c),Be("root node is forbidden and cannot be sanitized in-place")}if(Gt(c))throw as(c),Be("root node is clobbered and cannot be sanitized in-place");k=ls(c),Fe=xs()}else if(Lt(c))r=$s("<!---->"),i=r.ownerDocument.importNode(c,!0),i.nodeType===Z.element&&i.nodeName==="BODY"||i.nodeName==="HTML"?r=i:r.appendChild(i),ps(r);else{if(!We&&!oe&&!Ae&&c.indexOf("<")===-1)return m&&Se?be(c):c;if(r=$s(c),!r)return We?null:Se?A:""}r&&mt&&Ve(r.firstChild);const Le=N?c:r;try{N&&ps(c);const fe=cs(Le);for(;o=fe.nextNode();)us(o,Le),ms(o,Le),Je(o.content)&&Pt(o.content);N&&Gr(c,k)}catch(fe){throw N&&(as(c),Us(c,k)),fe}finally{Fe=ee}if(N){if(Us(c,k))throw Be("a node selected for removal could not be safely returned; refusing to sanitize in place");return oe&&ds(c),c}if(We){if(oe&&ds(r),ot)for(v=Me.call(r.ownerDocument);r.firstChild;)v.appendChild(r.firstChild);else v=r;return($.shadowroot||$.shadowrootmode)&&(v=wt.call(p,v,!0)),v}let ue=Ae?r.outerHTML:r.innerHTML;return Ae&&U["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&ne(na,r.ownerDocument.doctype.name)&&(ue="<!DOCTYPE "+r.ownerDocument.doctype.name+`>
4
- `+ue),oe&&(ue=Wt(ue)),m&&Se?be(ue):ue},n.setConfig=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ns(c),Ie=!0,le=U,it=$},n.clearConfig=function(){w=null,Ie=!1,le=null,it=null,m=ie,A=""},n.isValidAttribute=function(c,t,r){w||ns({});const i=q(c),o=q(t);return typeof r=="string"&&(Gs(t,r)||!at&&ne(ur,r))?!1:Hs(i,o,r)},n.addHook=function(c,t){typeof t=="function"&&ge(W,c)&&Mt(W[c],t)},n.removeHook=function(c,t){if(ge(W,c)){if(t!==void 0){const r=Un(W[c],t);return r===-1?void 0:$n(W[c],r,1)[0]}return er(W[c])}},n.removeHooks=function(c){ge(W,c)&&(W[c]=[])},n.removeAllHooks=function(){W=mr()},n}var da=Ir();function ua(s){return da.sanitize(s??"",{USE_PROFILES:{html:!0},FORBID_TAGS:["style","form","input","button","textarea","select"]})}const Lr=["blocker","critical","major","minor","trivial"],Es=["open","in_progress","resolved","closed","rejected"],ma={blocker:"bg-red-500/20 text-red-500",critical:"bg-red-400/20 text-red-400",major:"bg-orange-400/20 text-orange-400",minor:"bg-amber-400/20 text-amber-400",trivial:"bg-gray-400/20 text-gray-400"},pa={open:"bg-red-500/20 text-red-400",in_progress:"bg-blue-500/20 text-blue-400",resolved:"bg-emerald-500/20 text-emerald-400",closed:"bg-gray-500/20 text-gray-400",rejected:"bg-slate-500/20 text-slate-400"},Qt=["p1","p2","p3","p4"],dt={p1:"P1-Critical",p2:"P2-High",p3:"P3-Medium",p4:"P4-Low"},Ds={p1:"bg-red-500/20 text-red-400",p2:"bg-orange-400/20 text-orange-400",p3:"bg-blue-400/20 text-blue-400",p4:"bg-gray-400/20 text-gray-400"},pr={blocker:"bg-red-300",critical:"bg-rose-200",major:"bg-orange-200",minor:"bg-amber-200",trivial:"bg-gray-300"},xr=["open","in_progress","resolved","closed"],yt=["blocker","critical","major","minor","trivial"],Zt={p1:"P1",p2:"P2",p3:"P3",p4:"P4"},es={open:"in_progress",in_progress:"resolved",resolved:"closed"},fr={blocker:"bg-red-700",critical:"bg-red-400",major:"bg-orange-400",minor:"bg-amber-400",trivial:"bg-gray-400"};function ws(s){return s.createdAt?Math.max(0,Math.ceil((Date.now()-new Date(s.createdAt).getTime())/864e5)):0}function hr(s){return s<3?"bg-emerald-500/15 text-emerald-400":s<=7?"bg-amber-500/15 text-amber-400":"bg-red-500/15 text-red-400"}function Jt(s){return!!s.dueDate&&new Date(s.dueDate).getTime()<Date.now()&&s.status!=="closed"&&s.status!=="rejected"}function Pr(s){const n=s.trim().split(/\s+/).filter(Boolean);return n.length===0?"?":((n[0][0]||"")+(n.length>1&&n[n.length-1][0]||"")).toUpperCase()}function Mr(s){const n=["bg-indigo-600","bg-teal-600","bg-violet-600","bg-cyan-700","bg-rose-600","bg-emerald-600"];let u=0;for(const p of s)u=u*31+p.charCodeAt(0)>>>0;return n[u%n.length]}function gr({name:s,size:n=19}){const u={width:n,height:n,fontSize:Math.max(8,n*.45)};return s?e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-gray-300 min-w-0",children:[e.jsx("span",{style:u,className:`rounded-full ${Mr(s)} text-white font-bold flex items-center justify-center shrink-0`,children:Pr(s)}),e.jsx("span",{className:"truncate",children:s})]}):e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 min-w-0",children:[e.jsx("span",{style:u,className:"rounded-full border border-dashed border-gray-400/60 bg-surface-2 text-gray-400 flex items-center justify-center shrink-0",children:"?"}),e.jsx("span",{className:"truncate",children:"Unassigned"})]})}function $t({label:s,value:n,options:u,display:p,onChange:f,onClear:y}){const b=!!n;return e.jsxs("span",{className:`relative inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs cursor-pointer select-none transition-colors ${b?"bg-brand-600 border-brand-600 text-white":"bg-surface-1 border-white/10 text-gray-300 hover:border-gray-400/40"}`,children:[e.jsxs("span",{children:[s,b&&e.jsxs(e.Fragment,{children:[": ",e.jsx("b",{className:"font-semibold",children:p||n})]})]}),!b&&e.jsx(Cr,{size:10,className:"opacity-60"}),e.jsxs("select",{value:n,onChange:g=>g.target.value?f(g.target.value):y(),className:"absolute inset-0 opacity-0 cursor-pointer w-full text-gray-900 dark:text-gray-200","aria-label":s,children:[e.jsx("option",{value:"",children:"All"}),u.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))]}),b&&e.jsx("button",{onClick:g=>{g.preventDefault(),g.stopPropagation(),y()},className:"relative z-10 opacity-70 hover:opacity-100 -mr-0.5",title:`Clear ${s.toLowerCase()} filter`,children:e.jsx(Qe,{size:11})})]})}function B(s){return s.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function zr(s){return s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}function Kt(s){return s?new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function xa(){return{title:"",description:"",priority:"p3",severity:"major",status:"open",expectedResult:"",actualResult:"",stepsToReproduce:"",environment:"",assignedTo:"",reporter:"",dueDate:"",tags:"",externalId:"",externalUrl:"",testCaseId:""}}function Oa(){const[s,n,u]=Ke("search"),[p,f,y]=Ke("status"),[b,g,R]=Ke("severity"),[H,j]=M.useState(!1),[_,T]=M.useState(null),[E,F]=M.useState(null),[J,X]=rn("view",["table","board"],"board"),[K]=Ke("defectId"),Q=nn(),[de,O]=M.useState(null),[Y,d,D]=Ke("priority"),[z,me,Ee]=Ke("assignee"),[m,A,ie]=Ke("overdue"),[pe,Pe,Ze]=Ke("sort"),be=pe||"oldest",[et,De]=M.useState({closed:!1,rejected:!1}),[Re,tt]=M.useState(null),[Te,Me]=M.useState(new Set),[st,wt]=M.useState(null);He.useEffect(()=>{if(!Re)return;const l=h=>{var S,G;(G=(S=h.target)==null?void 0:S.closest)!=null&&G.call(S,"[data-assign-root]")||tt(null)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[Re]);const{toast:W}=tn(),[Os,Is]=M.useState(!1),Tt=an(s,250),ts=M.useMemo(()=>({...p?{status:p}:{},...b?{severity:b}:{},...Tt?{search:Tt}:{}}),[p,b,Tt]),ss=l=>l?n(l):u(),{data:rt,isLoading:Bt}=Vs(ts),{data:nt}=Vs({}),{data:rs}=ln(),{data:U}=jr({queryKey:["users"],queryFn:br}),ut=M.useMemo(()=>((U==null?void 0:U.users)||[]).map(h=>h.displayName||h.username).filter(Boolean),[U]),$=cn(),ze=vr(),ye=dn(),Oe=un(),{user:Ne}=yr(),ve=(Ne==null?void 0:Ne.displayName)||"",{data:_e}=mn(),Ue=Array.isArray(rt)?rt:(rt==null?void 0:rt.defects)??[],xe=Array.isArray(nt)?nt:(nt==null?void 0:nt.defects)??[],at=Array.isArray(_e)?_e:(_e==null?void 0:_e.folders)??(_e==null?void 0:_e.tree)??[],oe=M.useMemo(()=>{let l=[...Ue];Y&&(l=l.filter(C=>C.priority===Y)),z&&(l=z==="__unassigned__"?l.filter(C=>!C.assignedTo):l.filter(C=>C.assignedTo===z)),m&&(l=l.filter(Jt));const h=C=>{const P=yt.indexOf(C.severity);return P<0?99:P},S=C=>{const P=Qt.indexOf(C.priority);return P<0?99:P},G=C=>new Date(C.createdAt||0).getTime();switch(be){case"newest":l.sort((C,P)=>G(P)-G(C));break;case"priority":l.sort((C,P)=>S(C)-S(P)||G(C)-G(P));break;case"severity":l.sort((C,P)=>h(C)-h(P)||G(C)-G(P));break;case"due":l.sort((C,P)=>(C.dueDate?new Date(C.dueDate).getTime():1/0)-(P.dueDate?new Date(P.dueDate).getTime():1/0));break;default:l.sort((C,P)=>G(C)-G(P))}return l},[Ue,Y,z,m,be]),I=M.useMemo(()=>{const l=Date.now()-6048e5,h=xe.filter(x=>x.status!=="closed"&&x.status!=="rejected"),S=xe.filter(x=>x.status==="open"),G=xe.filter(x=>x.status==="in_progress"),C=h.filter(x=>x.severity==="blocker"),P=h.filter(Jt),lt=xe.filter(x=>x.resolvedAt&&new Date(x.resolvedAt).getTime()>=l).length,Ye=xe.filter(x=>x.createdAt&&new Date(x.createdAt).getTime()>=l).length,xt=S.filter(x=>x.createdAt&&new Date(x.createdAt).getTime()>=l).length,Ce={};for(const x of yt)Ce[x]=0;for(const x of xe)Ce[x.severity]!==void 0&&Ce[x.severity]++;const a=xe.filter(x=>x.resolvedAt&&x.createdAt).map(x=>(new Date(x.resolvedAt).getTime()-new Date(x.createdAt).getTime())/864e5).filter(x=>x>=0),te=a.length?a.reduce((x,ce)=>x+ce,0)/a.length:null;return{total:xe.length,activeCount:h.length,open:S.length,openNewThisWeek:xt,inProgress:G.length,inProgressAssigned:G.filter(x=>x.assignedTo).length,blockers:C.length,blockersUnassigned:C.filter(x=>!x.assignedTo).length,overdue:P.length,overdueOldest:P.length?Math.max(...P.map(ws)):0,resolvedThisWeek:lt,createdThisWeek:Ye,netThisWeek:Ye-lt,sevMix:Ce,avgResolutionDays:te}},[xe]),Ae=M.useMemo(()=>{const l=new Set;for(const h of xe)h.assignedTo&&l.add(h.assignedTo);for(const h of ut)l.add(h);return Array.from(l).sort()},[xe,ut]),Ie=M.useMemo(()=>{if(!K)return null;const l=K.toLowerCase();return Ue.find(h=>{var S;return((S=h.id)==null?void 0:S.toLowerCase())===l})??null},[Ue,K]);function le(l){W("success",l)}M.useMemo(()=>{const l=[];function h(S,G){var C;for(const P of S)l.push({id:P.id,name:P.name,depth:G}),(C=P.children)!=null&&C.length&&h(P.children,G+1)}return Array.isArray(at)&&h(at,0),l},[at]);function it(){T(null),j(!0)}function mt(l){T(l),j(!0)}async function We(l){try{_?(await ze.mutateAsync({id:_.id,data:{...l,performedBy:ve||(Ne==null?void 0:Ne.username)||"Unknown"}}),le("Defect updated successfully")):(await $.mutateAsync(l),le("Defect created successfully")),j(!1),T(null)}catch{}}function ot(l){O({title:"Delete Defect",message:"Are you sure you want to delete this defect? This action cannot be undone.",onConfirm:async()=>{O(null);try{await ye.mutateAsync(l),Q({defectId:null}),le("Defect deleted")}catch{}}})}const Se=ve||(Ne==null?void 0:Ne.username)||"Unknown";async function _t(l,h){try{await Oe.mutateAsync({id:l,status:h,performedBy:Se}),le(`${l} → ${B(h)}`)}catch{}}async function At(l,h){tt(null);try{await ze.mutateAsync({id:l,data:{assignedTo:h,performedBy:Se}}),le(h?`${l} assigned to ${h}`:`${l} unassigned`)}catch{}}async function Ht(l){try{await $.mutateAsync({title:`Copy of ${l.title}`,description:l.description||"",priority:l.priority||"p3",severity:l.severity||"major",expectedResult:l.expectedResult||"",actualResult:l.actualResult||"",stepsToReproduce:l.stepsToReproduce||"",environment:l.environment||"",assignedTo:l.assignedTo||"",reporter:Se,tags:l.tags||"",testCaseId:l.testCaseId||""}),le("Defect duplicated")}catch{}}async function St(l){const h=Array.from(Te);try{await Promise.all(h.map(S=>ze.mutateAsync({id:S,data:{assignedTo:l,performedBy:Se}}))),le(l?`${h.length} assigned to ${l}`:`${h.length} unassigned`),Me(new Set)}catch{}}async function Ct(l){const h=Array.from(Te);try{await Promise.all(h.map(S=>Oe.mutateAsync({id:S,status:l,performedBy:Se}))),le(`${h.length} moved to ${B(l)}`),Me(new Set)}catch{}}async function Fe(l){const h=Array.from(Te);try{await Promise.all(h.map(S=>ze.mutateAsync({id:S,data:{priority:l,performedBy:Se}}))),le(`${h.length} set to ${dt[l]||l}`),Me(new Set)}catch{}}function Ge(){const l=Array.from(Te);O({title:`Delete ${l.length} Defect${l.length===1?"":"s"}`,message:"Are you sure you want to delete the selected defects? This action cannot be undone.",onConfirm:async()=>{O(null);try{await Promise.all(l.map(h=>ye.mutateAsync(h))),le(`${l.length} defect${l.length===1?"":"s"} deleted`),Me(new Set)}catch{}}})}function $e(l,h){l.dataTransfer.setData("text/plain",h.id),l.dataTransfer.effectAllowed="move"}function kt(l,h){l.preventDefault(),l.dataTransfer.dropEffect="move",st!==h&&wt(h)}function Et(l){const h=l.relatedTarget;(!h||!l.currentTarget.contains(h))&&wt(null)}function Dt(l,h){l.preventDefault(),wt(null);const S=l.dataTransfer.getData("text/plain");if(!S)return;const G=Ue.find(C=>C.id===S);G&&G.status!==h&&_t(S,h)}function Rt(){Q({status:null,severity:null,priority:null,assignee:null,overdue:null,search:null})}function Ot(l){p===l?y():f(l)}return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:pt()}),H&&e.jsx(ga,{defect:_,onSave:We,onClose:()=>{j(!1),T(null)},saving:$.isPending||ze.isPending,currentUserName:ve}),de&&e.jsx(Ur,{title:de.title,message:de.message,onConfirm:de.onConfirm,onCancel:()=>O(null)}),Ie&&e.jsx(ya,{defect:Ie,onClose:()=>Q({defectId:null}),onEdit:()=>{mt(Ie)},onDuplicate:()=>{Ht(Ie)},onDelete:()=>{ot(Ie.id),Q({defectId:null})},onTransition:async l=>{try{await Oe.mutateAsync({id:Ie.id,status:l,performedBy:ve||"System"}),le(`Defect transitioned to ${B(l)}`)}catch{}},transitioning:Oe.isPending})]});function pt(){var Ce;const l=[{value:"oldest",label:"Oldest first"},{value:"newest",label:"Newest first"},{value:"priority",label:"Priority"},{value:"severity",label:"Severity"},{value:"due",label:"Due date"}],h=((Ce=l.find(a=>a.value===be))==null?void 0:Ce.label)||"Oldest first",S=a=>e.jsxs("button",{onClick:a.onClick,className:`relative text-left bg-surface-1 border rounded-xl px-4 py-3 transition-colors ${a.active?"border-brand-500 ring-1 ring-inset ring-brand-500":"border-white/10 hover:border-gray-400/40"}`,children:[a.active&&e.jsx("span",{className:"absolute top-2 right-2.5 text-[9px] font-bold uppercase tracking-wide bg-brand-600 text-white px-1.5 py-0.5 rounded-full",children:"filtering"}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${a.dot}`}),a.label]}),e.jsx("span",{className:`block text-2xl font-bold mt-0.5 ${a.valueCls||"text-gray-100"}`,children:a.value}),e.jsx("span",{className:"block text-[11px] text-gray-500 mt-0.5",children:a.delta})]}),G=Math.max(1,I.total),C=!!(p||b||Y||z||m),P=[{status:"open",collapsed:!1},{status:"in_progress",collapsed:!1},{status:"resolved",collapsed:!1},{status:"closed",collapsed:!et.closed},{status:"rejected",collapsed:!et.rejected}],lt=P.map(a=>a.collapsed?"44px":"1fr").join(" "),Ye={open:{dot:"bg-red-400",head:"from-red-500/10",cnt:"bg-red-500/15 text-red-400"},in_progress:{dot:"bg-blue-400",head:"from-blue-500/10",cnt:"bg-blue-500/15 text-blue-400"},resolved:{dot:"bg-emerald-400",head:"from-emerald-500/10",cnt:"bg-emerald-500/15 text-emerald-400"},closed:{dot:"bg-gray-400",head:"from-gray-500/10",cnt:"bg-gray-500/15 text-gray-400"},rejected:{dot:"bg-slate-400",head:"from-slate-500/10",cnt:"bg-slate-500/15 text-slate-400"}},xt=a=>{const te=ws(a),x=Jt(a),ce=es[a.status],q=a.status==="resolved"||a.status==="closed"||a.status==="rejected";return e.jsxs("div",{draggable:!0,onDragStart:w=>$e(w,a),onClick:()=>Q({defectId:a.id}),className:`group relative bg-surface-1 border border-white/10 rounded-xl px-3 py-2.5 cursor-grab active:cursor-grabbing transition-all hover:border-gray-400/40 hover:shadow-md hover:shadow-black/10 hover:-translate-y-px ${q?"opacity-85":""} ${Re===a.id?"z-40":""}`,children:[e.jsxs("div",{"data-assign-root":!0,className:"absolute top-1.5 right-1.5 hidden group-hover:flex items-center gap-0.5 bg-surface-1 border border-white/10 rounded-lg p-0.5 shadow-lg z-10",onClick:w=>w.stopPropagation(),children:[e.jsx("button",{title:"Assign",onClick:()=>tt(Re===a.id?null:a.id),className:"w-6 h-6 flex items-center justify-center rounded-md text-gray-400 hover:text-gray-200 hover:bg-white/10",children:e.jsx(_r,{size:12})}),ce&&e.jsx("button",{title:`Move to ${B(ce)}`,onClick:()=>_t(a.id,ce),className:"w-6 h-6 flex items-center justify-center rounded-md text-gray-400 hover:text-gray-200 hover:bg-white/10",children:e.jsx(As,{size:12})}),e.jsx("button",{title:"Open",onClick:()=>Q({defectId:a.id}),className:"w-6 h-6 flex items-center justify-center rounded-md text-gray-400 hover:text-gray-200 hover:bg-white/10",children:e.jsx(qt,{size:12})})]}),Re===a.id&&e.jsx(e.Fragment,{children:e.jsxs("div",{"data-assign-root":!0,className:"absolute top-8 right-1.5 z-30 w-44 max-h-52 overflow-y-auto bg-surface-1 border border-white/10 rounded-lg shadow-xl py-1",onClick:w=>w.stopPropagation(),children:[e.jsx("button",{onClick:()=>At(a.id,""),className:"w-full text-left px-3 py-1.5 text-xs text-gray-400 hover:bg-white/5",children:"Unassigned"}),Ae.map(w=>e.jsxs("button",{onClick:()=>At(a.id,w),className:"w-full text-left px-3 py-1.5 text-xs text-gray-200 hover:bg-white/5 flex items-center gap-2",children:[e.jsx("span",{className:`w-4 h-4 rounded-full ${Mr(w)} text-white text-[8px] font-bold flex items-center justify-center`,children:Pr(w)}),e.jsx("span",{className:"truncate",children:w})]},w))]})}),e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1.5",children:[e.jsx("p",{className:"text-[13px] font-normal text-gray-200 leading-snug line-clamp-2",children:a.title}),e.jsx("span",{className:"text-[11px] font-mono text-gray-500 shrink-0",children:a.id})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap mb-2",children:[e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${Ds[a.priority]||"bg-gray-500/15 text-gray-400"}`,title:dt[a.priority],children:Zt[a.priority]||"P3"}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded-md border bg-transparent ${a.severity==="blocker"?"border-red-600 text-red-400 font-semibold":a.severity==="critical"?"border-red-400/60 text-red-400":a.severity==="major"?"border-orange-400/60 text-orange-500 dark:text-orange-400":a.severity==="minor"?"border-amber-400/60 text-amber-400":"border-gray-400/50 text-gray-400"}`,children:B(a.severity||"unknown")}),a.testCaseId&&e.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-surface-2 text-gray-500",children:a.testCaseId}),a.externalId&&e.jsx(Rs,{externalId:a.externalId}),x&&e.jsxs("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded-md bg-red-500/15 text-red-400 flex items-center gap-1",children:[e.jsx(Ar,{size:9})," overdue"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-1.5 border-t border-white/[0.06]",children:[e.jsx(gr,{name:a.assignedTo}),e.jsxs("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${hr(te)}`,children:[te,"d"]})]})]},a.id)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-brand-600 text-white flex items-center justify-center",children:e.jsx(Ts,{size:18})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-gray-100 leading-tight",children:"Defects"}),e.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-2",children:[I.activeCount," active · ",I.resolvedThisWeek," resolved this week",I.netThisWeek!==0&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-0.5 rounded-full ${I.netThisWeek<0?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:[I.netThisWeek<0?"▼":"▲"," ",Math.abs(I.netThisWeek)," net this week"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{type:"defect-report",formats:["docx","xlsx","csv"],label:"Export"}),e.jsxs("button",{onClick:it,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium flex items-center gap-2 transition-colors",children:[e.jsx(wr,{size:16})," New Defect"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-[repeat(5,1fr)_1.6fr] gap-2.5",children:[S({label:"Total",value:I.total,dot:"bg-gray-500",delta:"all time",active:!1,onClick:Rt}),S({label:"Open",value:I.open,dot:"bg-red-400",delta:I.openNewThisWeek?`+${I.openNewThisWeek} this week`:"none new this week",active:p==="open",onClick:()=>Ot("open"),valueCls:"text-red-400"}),S({label:"In Progress",value:I.inProgress,dot:"bg-blue-400",delta:`${I.inProgressAssigned} assigned`,active:p==="in_progress",onClick:()=>Ot("in_progress"),valueCls:"text-blue-400"}),S({label:"Blockers",value:I.blockers,dot:"bg-red-700",delta:I.blockersUnassigned?"needs triage":I.blockers?"all assigned":"—",active:b==="blocker",onClick:()=>b==="blocker"?R():g("blocker"),valueCls:"text-red-500"}),S({label:"Overdue",value:I.overdue,dot:"bg-amber-400",delta:I.overdue?`oldest ${I.overdueOldest}d`:"—",active:!!m,onClick:()=>m?ie():A("1"),valueCls:"text-amber-400"}),e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl px-4 py-3 col-span-2 md:col-span-3 xl:col-span-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-semibold uppercase tracking-wide text-gray-500 mb-2",children:[e.jsx("span",{children:"Severity mix"}),e.jsxs("span",{className:"normal-case font-normal",children:["avg resolution ",e.jsx("b",{className:"font-semibold text-gray-100",children:I.avgResolutionDays!=null?`${I.avgResolutionDays.toFixed(1)}d`:"—"})]})]}),e.jsx("div",{className:"flex h-2.5 rounded-md overflow-hidden mb-2 bg-surface-2",children:yt.map(a=>(I.sevMix[a]||0)>0&&e.jsx("span",{className:pr[a],style:{width:`${I.sevMix[a]/G*100}%`},title:`${B(a)}: ${I.sevMix[a]}`},a))}),e.jsx("div",{className:"flex items-center gap-3 flex-wrap text-[10.5px] text-gray-500",children:yt.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${pr[a]}`}),e.jsx("b",{className:"font-semibold text-gray-300",children:I.sevMix[a]||0})," ",a]},a))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px] max-w-sm",children:[e.jsx(Tr,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search defects...",value:s||"",onChange:a=>ss(a.target.value),className:"w-full bg-surface-1 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]}),e.jsx($t,{label:"Status",value:p||"",display:B(p||""),options:Es.map(a=>({value:a,label:B(a)})),onChange:f,onClear:y}),e.jsx($t,{label:"Severity",value:b||"",display:B(b||""),options:Lr.map(a=>({value:a,label:B(a)})),onChange:g,onClear:R}),e.jsx($t,{label:"Priority",value:Y||"",display:Zt[Y||""]||"",options:Qt.map(a=>({value:a,label:dt[a]})),onChange:d,onClear:D}),e.jsx($t,{label:"Assignee",value:z||"",display:z==="__unassigned__"?"Unassigned":z||"",options:[{value:"__unassigned__",label:"Unassigned"},...Ae.map(a=>({value:a,label:a}))],onChange:me,onClear:Ee}),e.jsx($t,{label:"Sort",value:pe||"",display:h,options:l,onChange:Pe,onClear:Ze}),C&&e.jsx("button",{onClick:Rt,className:"text-xs text-gray-500 hover:text-gray-300 underline underline-offset-2",children:"Clear all"}),e.jsxs("div",{className:"ml-auto flex items-center bg-surface-2 border border-white/10 rounded-lg p-0.5",children:[e.jsxs("button",{onClick:()=>X("board"),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${J==="board"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(wn,{size:14})," Board"]}),e.jsxs("button",{onClick:()=>X("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${J==="table"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(Tn,{size:14})," List"]})]})]}),Bt?e.jsx(fa,{message:"Loading defects..."}):oe.length===0?e.jsx(ha,{icon:e.jsx(Ts,{size:40,className:"text-gray-600"}),title:"No defects found",subtitle:"Create a defect or adjust your filters"}):J==="board"?e.jsx("div",{className:"grid gap-3 items-start",style:{gridTemplateColumns:lt},children:P.map(({status:a,collapsed:te})=>{const x=Ye[a],ce=oe.filter(w=>w.status===a),q=yt.filter(w=>ce.some(It=>It.severity===w)).slice(0,3);return te?e.jsxs("div",{onClick:()=>De(w=>({...w,[a]:!0})),onDragOver:w=>kt(w,a),onDragLeave:Et,onDrop:w=>Dt(w,a),className:`rounded-xl border bg-surface-1/50 min-h-[420px] flex flex-col items-center pt-3 gap-2.5 cursor-pointer transition-colors ${st===a?"border-brand-500":"border-white/10 hover:border-gray-400/40"}`,title:`Expand ${B(a)}`,children:[e.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded-full ${x.cnt}`,children:ce.length}),e.jsx("span",{className:"text-[10.5px] font-bold tracking-widest uppercase text-gray-500",style:{writingMode:"vertical-rl"},children:B(a)})]},a):e.jsxs("div",{onDragOver:w=>kt(w,a),onDragLeave:Et,onDrop:w=>Dt(w,a),className:`rounded-xl border bg-surface-1/50 flex flex-col min-h-[420px] transition-colors ${st===a?"border-brand-500 ring-1 ring-inset ring-brand-500":"border-white/10"}`,children:[e.jsxs("div",{className:`px-3.5 py-2.5 bg-gradient-to-b ${x.head} to-transparent rounded-t-xl border-b border-white/5 flex items-center justify-between`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${x.dot}`}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-gray-200",children:B(a)}),(a==="closed"||a==="rejected")&&e.jsx("button",{onClick:()=>De(w=>({...w,[a]:!1})),className:"text-gray-500 hover:text-gray-300",title:"Collapse column",children:e.jsx(_n,{size:12})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[q.length>0&&e.jsx("span",{className:"flex gap-1",children:q.map(w=>e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${fr[w]}`,title:B(w)},w))}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full ${x.cnt}`,children:ce.length})]})]}),e.jsxs("div",{className:"p-2 space-y-2 flex-1 overflow-y-auto max-h-[640px]",children:[ce.map(xt),ce.length===0&&st!==a&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-gray-600",children:[e.jsx(An,{size:16,className:"mb-1.5"}),e.jsx("span",{className:"text-[11px]",children:"No defects"})]}),st===a&&e.jsxs("div",{className:"pointer-events-none border-2 border-dashed border-gray-400/60 rounded-xl py-4 text-center text-xs font-semibold text-gray-500 bg-surface-2/50",children:["Drop to move to ",B(a)]}),a==="open"&&e.jsx("button",{onClick:it,className:"w-full border-[1.5px] border-dashed border-gray-400/30 rounded-lg py-1.5 text-xs text-gray-500 hover:text-gray-300 hover:border-gray-400/60 transition-colors",children:"+ Add defect"})]})]},a)})}):e.jsxs("div",{className:"space-y-2.5",children:[Te.size>0&&e.jsxs("div",{className:"flex items-center gap-2.5 bg-brand-700 text-white rounded-xl px-4 py-2 text-xs",children:[e.jsxs("b",{className:"font-semibold",children:[Te.size," selected"]}),e.jsx("span",{className:"opacity-40",children:"·"}),e.jsxs("select",{defaultValue:"",onChange:a=>{a.target.value&&(St(a.target.value==="__unassigned__"?"":a.target.value),a.target.value="")},className:"bg-brand-600 border border-brand-500 text-white rounded-md px-2 py-1 text-xs cursor-pointer",style:{colorScheme:"dark"},children:[e.jsx("option",{value:"",disabled:!0,children:"Assign…"}),e.jsx("option",{value:"__unassigned__",children:"Unassigned"}),Ae.map(a=>e.jsx("option",{value:a,children:a},a))]}),e.jsxs("select",{defaultValue:"",onChange:a=>{a.target.value&&(Ct(a.target.value),a.target.value="")},className:"bg-brand-600 border border-brand-500 text-white rounded-md px-2 py-1 text-xs cursor-pointer",style:{colorScheme:"dark"},children:[e.jsx("option",{value:"",disabled:!0,children:"Set status…"}),Es.map(a=>e.jsx("option",{value:a,children:B(a)},a))]}),e.jsxs("select",{defaultValue:"",onChange:a=>{a.target.value&&(Fe(a.target.value),a.target.value="")},className:"bg-brand-600 border border-brand-500 text-white rounded-md px-2 py-1 text-xs cursor-pointer",style:{colorScheme:"dark"},children:[e.jsx("option",{value:"",disabled:!0,children:"Set priority…"}),Qt.map(a=>e.jsx("option",{value:a,children:dt[a]},a))]}),e.jsx("button",{onClick:Ge,className:"text-red-300 hover:underline",children:"Delete"}),e.jsxs("button",{onClick:()=>Me(new Set),className:"ml-auto opacity-70 hover:opacity-100 flex items-center gap-1",children:[e.jsx(Qe,{size:12})," Clear"]})]}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left text-gray-400 text-xs uppercase tracking-wide",children:[e.jsx("th",{className:"px-3 py-2.5 w-9",children:e.jsx("input",{type:"checkbox",checked:oe.length>0&&oe.every(a=>Te.has(a.id)),onChange:a=>Me(a.target.checked?new Set(oe.map(te=>te.id)):new Set),className:"accent-brand-600 cursor-pointer"})}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-16",children:"ID"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold",children:"Title"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-20",children:"Priority"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-28",children:"Status"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-36",children:"Assignee"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-24",children:"Linked TC"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-24",children:"Due"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-16",children:"Age"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-16"})]})}),e.jsx("tbody",{children:yt.map(a=>{const te=oe.filter(x=>x.severity===a);return te.length===0?null:e.jsxs(He.Fragment,{children:[e.jsx("tr",{className:"bg-surface-2/60",children:e.jsxs("td",{colSpan:10,className:"px-3 py-1.5 text-[10.5px] font-bold uppercase tracking-widest text-gray-300",children:[e.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full mr-2 ${fr[a]}`}),B(a)," — ",te.length]})}),te.map(x=>{const ce=ws(x),q=Jt(x);return e.jsxs("tr",{className:"border-b border-white/5 hover:bg-white/[0.03] transition-colors cursor-pointer",onClick:()=>Q({defectId:x.id}),children:[e.jsx("td",{className:"px-3 py-2.5",onClick:w=>w.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:Te.has(x.id),onChange:w=>Me(It=>{const ft=new Set(It);return w.target.checked?ft.add(x.id):ft.delete(x.id),ft}),className:"accent-brand-600 cursor-pointer"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:"text-xs font-mono text-gray-500",children:x.id})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-gray-200 font-medium text-[13px] leading-snug",children:x.title}),(x.testCaseTitle||x.environment)&&e.jsx("span",{className:"text-[11px] text-gray-500 truncate max-w-md",children:[x.testCaseTitle,x.environment].filter(Boolean).join(" · ")})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${Ds[x.priority]||"bg-gray-500/15 text-gray-400"}`,title:dt[x.priority],children:Zt[x.priority]||"P3"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${pa[x.status]||"bg-gray-500/20 text-gray-400"}`,children:B(x.status||"unknown")}),x.externalId&&e.jsx(Rs,{externalId:x.externalId})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx(gr,{name:x.assignedTo})}),e.jsx("td",{className:"px-3 py-2.5",children:x.testCaseId?e.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-surface-2 text-gray-500",children:x.testCaseId}):e.jsx("span",{className:"text-gray-600 text-xs",children:"—"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:`text-xs ${q?"text-red-400 font-semibold":"text-gray-400"}`,children:x.dueDate?zr(x.dueDate):"—"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${hr(ce)}`,children:[ce,"d"]})}),e.jsx("td",{className:"px-3 py-2.5",onClick:w=>w.stopPropagation(),children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>mt(x),className:"p-1 text-gray-400 hover:text-gray-200 transition-colors",title:"Edit",children:e.jsx(_s,{size:14})}),e.jsx("button",{onClick:()=>ot(x.id),className:"p-1 text-gray-400 hover:text-red-400 transition-colors",title:"Delete",children:e.jsx(Xt,{size:14})})]})})]},x.id)})]},a)})})]})})]})]})}}function fa({message:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-gray-400",children:[e.jsx(Nt,{size:32,className:"animate-spin mb-3 text-brand-300"}),e.jsx("span",{className:"text-sm",children:s})]})}function ha({icon:s,title:n,subtitle:u}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s,e.jsx("h3",{className:"text-sm font-medium text-gray-300 mt-3",children:n}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:u})]})}function ga({defect:s,onSave:n,onClose:u,saving:p,currentUserName:f}){const{data:y}=pn({limit:5e3}),b=Array.isArray(y)?y:(y==null?void 0:y.testCases)??[],[g,R]=M.useState(()=>({...s?{title:s.title||"",description:s.description||"",priority:s.priority||"p3",severity:s.severity||"major",status:s.status||"open",expectedResult:s.expectedResult||"",actualResult:s.actualResult||"",stepsToReproduce:s.stepsToReproduce||"",environment:s.environment||"",assignedTo:s.assignedTo||"",reporter:s.reporter||f||"",dueDate:s.dueDate?new Date(s.dueDate).toISOString().split("T")[0]:"",tags:s.tags?Array.isArray(s.tags)?s.tags.join(", "):s.tags:"",externalId:s.externalId||"",externalUrl:s.externalUrl||"",testCaseId:s.testCaseId||""}:{...xa(),reporter:f||""},attachments:s!=null&&s.attachments?typeof s.attachments=="string"?(()=>{try{return JSON.parse(s.attachments)}catch{return[]}})():s.attachments:[],referenceLinks:s!=null&&s.referenceLinks?typeof s.referenceLinks=="string"?(()=>{try{return JSON.parse(s.referenceLinks)}catch{return[]}})():s.referenceLinks:[]})),[H,j]=M.useState(""),[_,T]=M.useState(""),E=(d,D)=>R(z=>({...z,[d]:D})),F="w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",J=d=>{const D=d.target.files;if(D){for(const z of Array.from(D)){if(z.size>10*1024*1024)continue;const me=new FileReader;me.onload=()=>{const Ee=me.result.split(",")[1]||"";R(m=>({...m,attachments:[...m.attachments,{fileName:z.name,fileType:z.type,fileSize:z.size,fileData:Ee}]}))},me.readAsDataURL(z)}d.target.value=""}},X=d=>{R(D=>({...D,attachments:D.attachments.filter((z,me)=>me!==d)}))},K=()=>{_.trim()&&(R(d=>({...d,referenceLinks:[...d.referenceLinks,{title:H.trim()||_.trim(),url:_.trim()}]})),j(""),T(""))},Q=d=>{R(D=>({...D,referenceLinks:D.referenceLinks.filter((z,me)=>me!==d)}))},de=d=>d<1024?`${d} B`:d<1024*1024?`${(d/1024).toFixed(1)} KB`:`${(d/(1024*1024)).toFixed(1)} MB`,O=He.useMemo(()=>He.lazy(()=>sn(()=>import("./vendor-quill-W-RoQfb6.js"),__vite__mapDeps([0,1,2]))),[]),Y=He.useMemo(()=>({toolbar:[[{header:[1,2,3,!1]}],["bold","italic","underline","strike"],[{list:"ordered"},{list:"bullet"}],["code-block","blockquote"],["link","image"],["clean"]]}),[]);return e.jsx(va,{onClose:u,children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 w-full max-w-6xl max-h-[90vh] overflow-y-auto shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-white/5",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ts,{size:20,className:"text-brand-300"}),s?"Edit Defect":"New Defect"]}),e.jsx("button",{onClick:u,className:"p-1 text-gray-400 hover:text-gray-200 transition-colors",children:e.jsx(Qe,{size:20})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsx(se,{label:"Title *",children:e.jsx("input",{type:"text",value:g.title,onChange:d=>E("title",d.target.value),placeholder:"Defect title",className:F})}),e.jsx(se,{label:"Description",children:e.jsx("textarea",{value:g.description,onChange:d=>E("description",d.target.value),rows:3,placeholder:"Describe the defect...",className:`${F} resize-y`})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(se,{label:"Priority",children:e.jsx("select",{value:g.priority,onChange:d=>E("priority",d.target.value),className:F,children:Qt.map(d=>e.jsx("option",{value:d,children:dt[d]},d))})}),e.jsx(se,{label:"Severity",children:e.jsx("select",{value:g.severity,onChange:d=>E("severity",d.target.value),className:F,children:Lr.map(d=>e.jsx("option",{value:d,children:B(d)},d))})}),e.jsx(se,{label:"Status",children:e.jsx("select",{value:g.status,onChange:d=>E("status",d.target.value),className:F,children:Es.map(d=>e.jsx("option",{value:d,children:B(d)},d))})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"Expected Result",children:e.jsx("textarea",{value:g.expectedResult,onChange:d=>E("expectedResult",d.target.value),rows:2,placeholder:"What should happen...",className:`${F} resize-y`})}),e.jsx(se,{label:"Actual Result",children:e.jsx("textarea",{value:g.actualResult,onChange:d=>E("actualResult",d.target.value),rows:2,placeholder:"What actually happens...",className:`${F} resize-y`})})]}),e.jsx(se,{label:"Steps to Reproduce",children:e.jsx(He.Suspense,{fallback:e.jsx("textarea",{value:g.stepsToReproduce,onChange:d=>E("stepsToReproduce",d.target.value),rows:4,placeholder:`1. Navigate to...
5
- 2. Click on...
6
- 3. Observe that...`,className:`${F} resize-y font-mono`}),children:e.jsxs("div",{className:"defect-quill-editor",children:[e.jsx("style",{children:`
7
- .defect-quill-editor .ql-toolbar { background: var(--surface-2, #1e1e2e); border-color: rgba(255,255,255,0.1) !important; border-radius: 0.5rem 0.5rem 0 0; }
8
- .defect-quill-editor .ql-toolbar button { color: #9ca3af !important; }
9
- .defect-quill-editor .ql-toolbar button:hover { color: #e5e7eb !important; }
10
- .defect-quill-editor .ql-toolbar .ql-stroke { stroke: #9ca3af !important; }
11
- .defect-quill-editor .ql-toolbar .ql-fill { fill: #9ca3af !important; }
12
- .defect-quill-editor .ql-toolbar button:hover .ql-stroke { stroke: #e5e7eb !important; }
13
- .defect-quill-editor .ql-toolbar button:hover .ql-fill { fill: #e5e7eb !important; }
14
- .defect-quill-editor .ql-toolbar .ql-picker-label { color: #9ca3af !important; }
15
- .defect-quill-editor .ql-toolbar .ql-picker-options { background: var(--surface-2, #1e1e2e) !important; border-color: rgba(255,255,255,0.1) !important; }
16
- .defect-quill-editor .ql-toolbar .ql-picker-item { color: #d1d5db !important; }
17
- .defect-quill-editor .ql-container { background: var(--surface-2, #1e1e2e); border-color: rgba(255,255,255,0.1) !important; border-radius: 0 0 0.5rem 0.5rem; min-height: 120px; color: var(--text-primary, #e5e7eb); font-size: 0.875rem; }
18
- .defect-quill-editor .ql-editor { min-height: 120px; color: var(--text-primary, #e5e7eb); }
19
- .defect-quill-editor .ql-editor.ql-blank::before { color: #6b7280 !important; font-style: normal !important; }
20
- .light .defect-quill-editor .ql-container,
21
- .light .defect-quill-editor .ql-editor { color: #1f2937 !important; background: #f9fafb !important; }
22
- .light .defect-quill-editor .ql-toolbar { background: #f3f4f6 !important; border-color: #d1d5db !important; }
23
- .light .defect-quill-editor .ql-toolbar button { color: #374151 !important; }
24
- .light .defect-quill-editor .ql-toolbar .ql-stroke { stroke: #374151 !important; }
25
- .light .defect-quill-editor .ql-toolbar .ql-fill { fill: #374151 !important; }
26
- .light .defect-quill-editor .ql-toolbar .ql-picker-label { color: #374151 !important; }
27
- .light .defect-quill-editor .ql-toolbar .ql-picker-options { background: #f9fafb !important; border-color: #d1d5db !important; }
28
- .light .defect-quill-editor .ql-container { background: #f9fafb !important; border-color: #d1d5db !important; }
29
- .light .defect-quill-editor .ql-editor.ql-blank::before { color: #9ca3af !important; }
30
- .defect-quill-editor .ql-editor pre.ql-syntax { background: rgba(0,0,0,0.3) !important; color: #e5e7eb !important; border-radius: 0.375rem; }
31
- .defect-quill-editor .ql-editor blockquote { border-left: 3px solid rgba(139,92,246,0.5); color: #d1d5db; }
32
- .defect-quill-editor .ql-snow .ql-tooltip { background: var(--surface-1, #161625) !important; border-color: rgba(255,255,255,0.1) !important; color: #e5e7eb !important; }
33
- /* Long-text wrapping. Quill's default rules don't
34
- break unbreakable strings (long URLs, stack traces),
35
- so a single long line forces the editor to scroll
36
- horizontally. Force wrap on every block. */
37
- .defect-quill-editor .ql-container { overflow-x: hidden; }
38
- .defect-quill-editor .ql-editor,
39
- .defect-quill-editor .ql-editor p,
40
- .defect-quill-editor .ql-editor li,
41
- .defect-quill-editor .ql-editor h1,
42
- .defect-quill-editor .ql-editor h2,
43
- .defect-quill-editor .ql-editor h3 {
44
- word-break: break-word;
45
- overflow-wrap: anywhere;
46
- white-space: normal;
47
- }
48
- /* Step-heading spacing. Generated defects use <h3>
49
- for the "Step N — status" line; Quill preserves
50
- <h3> through edits but its default top-margin is 0.
51
- Restore one so each step block reads as a distinct
52
- unit even after the user reformats. */
53
- .defect-quill-editor .ql-editor h3 {
54
- margin-top: 1.1em;
55
- margin-bottom: 0.35em;
56
- font-size: 1rem;
57
- font-weight: 700;
58
- }
59
- .defect-quill-editor .ql-editor h3:first-child {
60
- margin-top: 0.25em;
61
- }
62
- /* Slight bottom-margin on paragraphs so consecutive
63
- "Action / Expected / Actual" lines breathe a little
64
- instead of stacking edge-to-edge. */
65
- .defect-quill-editor .ql-editor p {
66
- margin: 0 0 0.25em 0;
67
- }
68
- `}),e.jsx(O,{theme:"snow",value:g.stepsToReproduce,onChange:d=>E("stepsToReproduce",d),modules:Y,placeholder:`1. Navigate to...
69
- 2. Click on...
70
- 3. Observe that...`})]})})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"Environment",children:e.jsx("input",{type:"text",value:g.environment,onChange:d=>E("environment",d.target.value),placeholder:"e.g., Chrome 120, Windows 11",className:F})}),e.jsx(se,{label:"Assigned To",children:e.jsx(ja,{value:g.assignedTo,onChange:d=>E("assignedTo",d),inputCls:F})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"Reporter",children:e.jsx("input",{type:"text",value:g.reporter,onChange:d=>E("reporter",d.target.value),placeholder:"Reporter name",className:F})}),e.jsx(se,{label:"Due Date",children:e.jsx("input",{type:"date",value:g.dueDate,onChange:d=>E("dueDate",d.target.value),className:F})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"Tags",children:e.jsx("input",{type:"text",value:g.tags,onChange:d=>E("tags",d.target.value),placeholder:"Comma-separated tags",className:F})}),e.jsx(se,{label:"Linked Test Case",children:e.jsx(ba,{testCases:b,value:g.testCaseId,onChange:d=>E("testCaseId",d),inputCls:F})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"External ID",children:e.jsx("input",{type:"text",value:g.externalId,onChange:d=>E("externalId",d.target.value),placeholder:"e.g., JIRA-1234",className:F})}),e.jsx(se,{label:"External URL",children:e.jsx("input",{type:"text",value:g.externalUrl,onChange:d=>E("externalUrl",d.target.value),placeholder:"https://...",className:F})})]}),e.jsx(se,{label:"Attachments",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 px-4 py-2 bg-surface-2 border border-dashed border-white/20 rounded-lg cursor-pointer hover:border-brand-500/50 transition-colors text-sm text-gray-400",children:[e.jsx(Sn,{size:16}),e.jsx("span",{children:"Upload screenshots, documents, or files (max 10MB each)"}),e.jsx("input",{type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.txt,.log,.har,.json,.xml,.csv",onChange:J,className:"hidden"})]}),g.attachments.length>0&&e.jsx("div",{className:"space-y-1",children:g.attachments.map((d,D)=>{var z;return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-surface-2 rounded-lg border border-white/5",children:[(z=d.fileType)!=null&&z.startsWith("image/")?e.jsx("img",{src:`data:${d.fileType};base64,${d.fileData}`,alt:d.fileName,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-surface-0 flex items-center justify-center",children:e.jsx(Ss,{size:16,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:d.fileName}),e.jsx("p",{className:"text-xs text-gray-500",children:de(d.fileSize)})]}),e.jsx("button",{onClick:()=>X(D),className:"p-1 text-gray-400 hover:text-red-400 transition-colors",children:e.jsx(Qe,{size:14})})]},D)})})]})}),e.jsx(se,{label:"Reference Links",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:H,onChange:d=>j(d.target.value),placeholder:"Link title (optional)",className:`${F} flex-1`}),e.jsx("input",{type:"text",value:_,onChange:d=>T(d.target.value),placeholder:"https://...",className:`${F} flex-[2]`,onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),K())}}),e.jsxs("button",{onClick:K,disabled:!_.trim(),className:"px-3 py-2 bg-brand-600 hover:bg-brand-500 text-white rounded-lg text-sm font-medium transition-colors disabled:opacity-50 flex items-center gap-1 whitespace-nowrap",children:[e.jsx(wr,{size:14})," Add"]})]}),g.referenceLinks.length>0&&e.jsx("div",{className:"space-y-1",children:g.referenceLinks.map((d,D)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-surface-2 rounded-lg border border-white/5",children:[e.jsx(qt,{size:14,className:"text-brand-300 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:d.title||d.url}),e.jsx("p",{className:"text-xs text-gray-500 truncate",children:d.url})]}),e.jsx("button",{onClick:()=>Q(D),className:"p-1 text-gray-400 hover:text-red-400 transition-colors",children:e.jsx(Qe,{size:14})})]},D))})]})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:u,className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsxs("button",{onClick:()=>{const d={...g,attachments:JSON.stringify(g.attachments),referenceLinks:JSON.stringify(g.referenceLinks)};n(d)},disabled:p||!g.title.trim(),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium flex items-center gap-2 transition-colors disabled:opacity-50",children:[p?e.jsx(Nt,{size:16,className:"animate-spin"}):e.jsx(Cn,{size:16}),s?"Update":"Create"]})]})]})})}function ba({testCases:s,value:n,onChange:u,inputCls:p}){const[f,y]=M.useState(""),[b,g]=M.useState(!1),R=He.useRef(null),H=s.filter(T=>{if(!f.trim())return!0;const E=f.toLowerCase();return(T.title||"").toLowerCase().includes(E)||(T.id||"").toLowerCase().includes(E)}),j=s.find(T=>T.id===n),_=j?j.title||j.id:n;return He.useEffect(()=>{const T=E=>{R.current&&!R.current.contains(E.target)&&g(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),e.jsxs("div",{className:"relative",ref:R,children:[e.jsxs("div",{className:`${p} cursor-pointer flex items-center justify-between`,onClick:()=>g(!b),children:[e.jsx("span",{className:n?"text-gray-200":"text-gray-500",children:n?_:"Select test case..."}),e.jsx(Cr,{size:14,className:"text-gray-400 shrink-0"})]}),b&&e.jsxs("div",{className:"absolute z-[70] top-full left-0 right-0 mt-1 bg-surface-1 border border-white/10 rounded-lg shadow-xl max-h-64 overflow-hidden flex flex-col",children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx(Tr,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:f,onChange:T=>y(T.target.value),placeholder:"Search test cases...",className:`${p} pl-8 py-1.5 text-xs`,autoFocus:!0,onClick:T=>T.stopPropagation()})]})}),e.jsxs("div",{className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:"px-3 py-2 text-sm text-gray-400 hover:bg-white/5 cursor-pointer",onClick:()=>{u(""),g(!1),y("")},children:"None"}),H.length===0?e.jsx("div",{className:"px-3 py-4 text-xs text-gray-500 text-center",children:"No test cases found"}):H.map(T=>e.jsxs("div",{className:`px-3 py-2 text-sm cursor-pointer hover:bg-white/5 flex items-center gap-2 ${T.id===n?"bg-brand-600/10 text-brand-300":"text-gray-200"}`,onClick:()=>{u(T.id),g(!1),y("")},children:[e.jsx("span",{className:"truncate",children:T.title||T.id}),e.jsxs("span",{className:"text-xs text-gray-500 shrink-0 font-mono",children:["#",T.id]})]},T.id))]})]})]})}function ya({defect:s,onClose:n,onEdit:u,onDuplicate:p,onDelete:f,onTransition:y,transitioning:b}){const[g,R]=M.useState("details"),[H,j]=M.useState(""),[_,T]=M.useState(null),[E,F]=M.useState(null),{user:J}=yr(),{data:X}=xn(s.id),{data:K}=fn(s.id),Q=hn(),de=gn(),O=Array.isArray(X)?X:(X==null?void 0:X.activity)??[],Y=Array.isArray(K)?K:(K==null?void 0:K.comments)??[],d=s.createdAt?Math.ceil((Date.now()-new Date(s.createdAt).getTime())/864e5):0,D=s.resolvedAt&&s.createdAt?Math.round((new Date(s.resolvedAt).getTime()-new Date(s.createdAt).getTime())/36e5):null;async function z(){if(H.trim())try{await Q.mutateAsync({defectId:s.id,content:H.trim(),author:(J==null?void 0:J.displayName)||"Unknown"}),j("")}catch{}}function me(m){F({title:"Delete Comment",message:"Are you sure you want to delete this comment?",onConfirm:async()=>{F(null);try{await de.mutateAsync({defectId:s.id,commentId:m,deletedBy:(J==null?void 0:J.displayName)||(J==null?void 0:J.username)||""})}catch{}}})}const Ee=xr.indexOf(s.status);return e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:n}),e.jsxs("div",{className:"relative bg-surface-1 w-full max-w-5xl border-l border-white/10 animate-slide-in-right overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-1 border-b border-white/5",children:[e.jsxs("div",{className:"px-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-mono bg-surface-2 text-gray-300 px-2 py-1 rounded-md",children:s.id}),e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${Ds[s.priority]||"bg-gray-500/20 text-gray-400"}`,title:dt[s.priority],children:Zt[s.priority]||"P3"}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${ma[s.severity]||"bg-gray-500/20 text-gray-400"}`,children:B(s.severity||"unknown")}),s.externalId&&e.jsx(Rs,{externalId:s.externalId})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:u,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium text-gray-400 hover:text-gray-200 transition-colors rounded-lg hover:bg-white/5 border border-white/10",title:"Edit",children:[e.jsx(_s,{size:13})," Edit"]}),e.jsxs("button",{onClick:p,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium text-gray-400 hover:text-gray-200 transition-colors rounded-lg hover:bg-white/5 border border-white/10",title:"Duplicate — creates a copy without the JIRA link",children:[e.jsx(En,{size:13})," Duplicate"]}),e.jsx("button",{onClick:f,className:"p-1.5 text-gray-400 hover:text-red-400 transition-colors rounded-lg hover:bg-white/5",title:"Delete",children:e.jsx(Xt,{size:16})}),e.jsx("button",{onClick:n,className:"p-1.5 text-gray-400 hover:text-gray-200 transition-colors rounded-lg hover:bg-white/5",children:e.jsx(Qe,{size:18})})]})]}),e.jsx("h2",{className:"text-lg font-semibold text-gray-100",children:s.title})]}),e.jsx("div",{className:"px-6 pb-4",children:e.jsxs("div",{className:"flex items-center gap-0 flex-wrap",children:[xr.map((m,A)=>{const ie=s.status===m,pe=Ee>=0&&A<Ee;return e.jsxs(He.Fragment,{children:[A>0&&e.jsx("span",{className:`w-6 h-0.5 mx-1.5 rounded ${pe||ie?"bg-emerald-400/60":"bg-gray-400/30"}`}),e.jsxs("button",{onClick:()=>{!ie&&!b&&y(m)},disabled:ie||b,className:`flex items-center gap-1.5 text-[11.5px] font-semibold transition-colors disabled:cursor-default ${ie?"text-blue-400":pe?"text-emerald-400":"text-gray-500 hover:text-gray-300"}`,title:ie?"Current status":`Move to ${B(m)}`,children:[e.jsx("span",{className:`w-[22px] h-[22px] rounded-full border-2 flex items-center justify-center text-[10px] font-bold ${pe?"bg-emerald-400/20 border-emerald-400 text-emerald-400":ie?"border-blue-400 text-blue-400 ring-2 ring-blue-400/20 bg-blue-400/10":"border-gray-400/40 text-gray-500"}`,children:pe?"✓":A+1}),B(m)]})]},m)}),e.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[s.status!=="rejected"&&e.jsx("button",{onClick:()=>{b||y("rejected")},disabled:b,className:"text-[11.5px] text-gray-500 hover:text-red-400 transition-colors",children:"Reject"}),s.status==="rejected"?e.jsx("span",{className:"text-xs font-semibold text-slate-400 bg-slate-500/15 px-3 py-1.5 rounded-lg",children:"Rejected"}):es[s.status]?e.jsxs("button",{onClick:()=>{b||y(es[s.status])},disabled:b,className:"flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs font-semibold px-3.5 py-1.5 rounded-lg transition-colors disabled:opacity-60",children:[b?e.jsx(Nt,{size:12,className:"animate-spin"}):null,"Mark ",B(es[s.status])," ",e.jsx(As,{size:12})]}):e.jsx("span",{className:"text-xs font-semibold text-emerald-400 bg-emerald-500/15 px-3 py-1.5 rounded-lg",children:"Closed"})]})]})})]}),e.jsx("div",{className:"border-b border-white/5",children:e.jsx("div",{className:"px-6 flex gap-1",children:["details","activity","comments"].map(m=>e.jsxs("button",{onClick:()=>R(m),className:`px-4 py-2.5 text-xs font-medium border-b-2 transition-colors flex items-center gap-1.5 ${g===m?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200"}`,children:[m==="details"&&e.jsx(Js,{size:13}),m==="activity"&&e.jsx(Ar,{size:13}),m==="comments"&&e.jsx(Ks,{size:13}),B(m),m==="comments"&&Y.length>0&&e.jsx("span",{className:"bg-surface-2 text-gray-400 text-[10px] px-1.5 py-0.5 rounded-full",children:Y.length})]},m))})}),e.jsxs("div",{className:"px-6 py-4",children:[g==="details"&&e.jsxs("div",{className:"grid md:grid-cols-[1fr_250px] gap-6 items-start",children:[e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Linked Items"}),e.jsxs("div",{className:"space-y-2",children:[s.testCaseId&&e.jsxs("a",{href:`/test-cases?tcId=${encodeURIComponent(s.testCaseId)}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-3 border border-white/10 rounded-lg px-3 py-2.5 bg-surface-2/40 hover:border-brand-400/50 transition-colors group",children:[e.jsxs("span",{className:"text-sm text-gray-300 truncate",children:[e.jsx(Ss,{size:13,className:"inline mr-2 text-gray-500"}),e.jsx("b",{className:"font-mono text-gray-200",children:s.testCaseId}),s.testCaseTitle&&e.jsxs("span",{className:"text-gray-400",children:[" — ",s.testCaseTitle]})]}),e.jsx("span",{className:"text-xs font-semibold text-blue-400 shrink-0 group-hover:underline",children:"Open in Test Cases ↗"})]}),s.executionId&&e.jsxs("div",{className:"flex items-center gap-2 border border-white/10 rounded-lg px-3 py-2.5 bg-surface-2/40 text-xs text-gray-500",children:[e.jsx(Dn,{size:13,className:"text-gray-600"}),"Found in cycle execution ",e.jsx("span",{className:"font-mono text-gray-400",children:s.executionId})]}),!s.testCaseId&&!s.executionId&&e.jsxs("div",{className:"border border-dashed border-white/10 rounded-lg px-3 py-2.5 text-xs text-gray-500",children:["No linked items — use ",e.jsx("b",{className:"text-gray-400",children:"Edit"})," to link this defect to a test case."]})]})]}),s.description&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Description"}),e.jsx("p",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:s.description})]}),s.expectedResult&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Expected Result"}),e.jsx("p",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:s.expectedResult})]}),s.actualResult&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Actual Result"}),e.jsx("p",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:s.actualResult})]}),s.stepsToReproduce&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Steps to Reproduce"}),e.jsx("div",{className:"text-sm text-gray-300 bg-surface-2 rounded-lg p-3 border border-white/5 prose prose-invert prose-sm max-w-none break-words [&_*]:break-words [&_img]:max-w-full [&_img]:rounded-lg [&_ol]:list-decimal [&_ol]:pl-5 [&_ul]:list-disc [&_ul]:pl-5 [&_pre]:bg-black/30 [&_pre]:rounded [&_pre]:p-2 [&_pre]:whitespace-pre-wrap [&_blockquote]:border-l-2 [&_blockquote]:border-brand-500/50 [&_blockquote]:pl-3 [&_blockquote]:italic [&_a]:text-brand-300 [&_a]:break-all [&_h3]:mt-4 [&_h3]:mb-1 [&_h3]:text-base [&_h3]:font-semibold [&_h3:first-child]:mt-0 [&_p]:mb-1",dangerouslySetInnerHTML:{__html:ua(s.stepsToReproduce)}})]}),s.tags&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:(Array.isArray(s.tags)?s.tags:String(s.tags).split(",").map(m=>m.trim()).filter(Boolean)).map((m,A)=>e.jsx("span",{className:"text-xs bg-surface-2 text-gray-300 px-2 py-0.5 rounded",children:m},A))})]}),(()=>{const m=typeof s.attachments=="string"?(()=>{try{return JSON.parse(s.attachments)}catch{return[]}})():Array.isArray(s.attachments)?s.attachments:[];return m.length>0?e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:["Attachments (",m.length,")"]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:m.map((A,ie)=>{var be,et;const pe=`data:${A.fileType};base64,${A.fileData}`,Pe=()=>{const De=document.createElement("a");De.href=pe,De.download=A.fileName,document.body.appendChild(De),De.click(),document.body.removeChild(De)},Ze=()=>{T({src:pe,name:A.fileName})};return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-surface-2 rounded-lg border border-white/5",children:[(be=A.fileType)!=null&&be.startsWith("image/")?e.jsx("img",{src:pe,alt:A.fileName,className:"w-14 h-14 rounded object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:Ze,title:"Click to view full size"}):e.jsx("div",{className:"w-14 h-14 rounded bg-surface-0 flex items-center justify-center",children:e.jsx(Ss,{size:18,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:A.fileName}),e.jsx("p",{className:"text-xs text-gray-500",children:A.fileSize<1024?`${A.fileSize} B`:A.fileSize<1048576?`${(A.fileSize/1024).toFixed(1)} KB`:`${(A.fileSize/1048576).toFixed(1)} MB`}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[((et=A.fileType)==null?void 0:et.startsWith("image/"))&&e.jsxs("button",{onClick:Ze,className:"text-xs text-brand-300 hover:text-brand-200 flex items-center gap-1",children:[e.jsx(Js,{size:12})," View"]}),e.jsxs("button",{onClick:Pe,className:"text-xs text-brand-300 hover:text-brand-200 flex items-center gap-1",children:[e.jsx(Xs,{size:12})," Download"]})]})]})]},ie)})})]}):null})(),(()=>{const m=typeof s.referenceLinks=="string"?(()=>{try{return JSON.parse(s.referenceLinks)}catch{return[]}})():Array.isArray(s.referenceLinks)?s.referenceLinks:[];return m.length>0?e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:["Reference Links (",m.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.map((A,ie)=>e.jsxs("a",{href:A.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-2 bg-surface-2 rounded-lg border border-white/5 hover:border-brand-400/50 transition-colors group",children:[e.jsx(qt,{size:14,className:"text-brand-300 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 group-hover:text-brand-600 dark:group-hover:text-brand-300 truncate font-medium",children:A.title||A.url}),A.title&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:A.url})]})]},ie))})]}):null})(),!s.description&&!s.stepsToReproduce&&!s.expectedResult&&!s.actualResult&&e.jsx("div",{className:"text-center py-8 text-sm text-gray-500",children:"No details provided"})]}),e.jsxs("div",{className:"bg-surface-2/60 border border-white/10 rounded-xl px-4 py-3 text-[12.5px] md:sticky md:top-40",children:[[["Assignee",s.assignedTo||"—"],["Reporter",s.reporter||"—"],["Created",Kt(s.createdAt)],["Updated",Kt(s.updatedAt)],["Due date",s.dueDate?zr(s.dueDate):"—"],["Environment",s.environment||"—"],["Age",`${d} day${d!==1?"s":""}`],["Time to resolve",D?`${D}h`:"—"]].map(([m,A])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5 border-b border-white/5 last:border-0",children:[e.jsx("span",{className:"text-gray-500",children:m}),e.jsx("span",{className:"font-medium text-gray-200 text-right truncate",children:A})]},m)),e.jsx("div",{className:"pt-2.5",children:s.externalUrl||s.externalId?e.jsxs("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"text-brand-600 dark:text-brand-300 hover:underline flex items-center gap-1.5 text-xs",children:[e.jsx(qt,{size:12}),s.externalId||s.externalUrl]}):e.jsx(Na,{defect:s})})]})]}),g==="activity"&&e.jsx("div",{className:"space-y-0",children:O.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-gray-500",children:"No activity recorded"}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-[11px] top-2 bottom-2 w-px bg-white/5"}),O.map((m,A)=>e.jsxs("div",{className:"relative flex gap-3 pb-4",children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center shrink-0 z-10 ${m.action==="status_change"?"bg-blue-500/20 text-blue-400":m.action==="comment"?"bg-emerald-500/20 text-emerald-400":m.action==="comment_deleted"?"bg-red-500/20 text-red-400":m.action==="created"?"bg-violet-500/20 text-violet-400":"bg-gray-500/20 text-gray-400"}`,children:m.action==="status_change"?e.jsx(As,{size:12}):m.action==="comment"?e.jsx(Ks,{size:12}):m.action==="comment_deleted"?e.jsx(Xt,{size:12}):m.action==="created"?e.jsx(Rn,{size:12}):e.jsx(_s,{size:12})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-gray-200",children:[e.jsx("span",{className:"font-medium",children:m.performedBy||"System"}),m.action==="status_change"?e.jsxs("span",{className:"text-gray-400",children:[" changed status from ",e.jsx("span",{className:"text-gray-300",children:B(m.oldValue||"")})," to ",e.jsx("span",{className:"text-gray-300",children:B(m.newValue||"")})]}):m.action==="comment"?e.jsx("span",{className:"text-gray-400",children:" added a comment"}):m.action==="comment_deleted"?e.jsxs("span",{className:"text-gray-400",children:[" deleted a comment",m.oldValue?e.jsxs("span",{className:"text-gray-500 italic",children:[' — "',m.oldValue,'"']}):""]}):m.action==="created"?e.jsx("span",{className:"text-gray-400",children:" created this defect"}):e.jsxs("span",{className:"text-gray-400",children:[" updated ",e.jsx("span",{className:"text-gray-300",children:B(m.fieldName||"")})]})]}),e.jsx("span",{className:"text-xs text-gray-500",children:Kt(m.createdAt)})]})]},A))]})}),g==="comments"&&e.jsxs("div",{className:"space-y-4",children:[Y.length===0&&e.jsx("div",{className:"text-center py-8 text-sm text-gray-500",children:"No comments yet"}),Y.map(m=>e.jsxs("div",{className:"bg-surface-2 rounded-lg p-3 border border-white/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-brand-600/20 flex items-center justify-center",children:e.jsx(_r,{size:12,className:"text-brand-300"})}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:m.author||"Unknown"}),e.jsx("span",{className:"text-xs text-gray-500",children:Kt(m.createdAt)})]}),e.jsx("button",{onClick:()=>me(m.id),className:"p-1 text-gray-500 hover:text-red-400 transition-colors",title:"Delete comment",children:e.jsx(Xt,{size:12})})]}),e.jsx("p",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:m.content})]},m.id)),e.jsxs("div",{className:"border-t border-white/5 pt-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("textarea",{value:H,onChange:m=>j(m.target.value),placeholder:"Add a comment...",rows:2,className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 resize-none",onKeyDown:m=>{m.key==="Enter"&&(m.ctrlKey||m.metaKey)&&z()}}),e.jsxs("button",{onClick:z,disabled:!H.trim()||Q.isPending,className:"self-end bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-2 text-sm font-medium flex items-center gap-1.5 transition-colors disabled:opacity-50",children:[Q.isPending?e.jsx(Nt,{size:14,className:"animate-spin"}):e.jsx(Sr,{size:14}),"Send"]})]}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-1",children:"Ctrl+Enter to send"})]})]})]})]}),E&&e.jsx(Ur,{title:E.title,message:E.message,onConfirm:E.onConfirm,onCancel:()=>F(null)}),_&&e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",onClick:()=>T(null),children:[e.jsx("div",{className:"absolute inset-0 bg-black/80 backdrop-blur-sm"}),e.jsxs("div",{className:"relative z-10 max-w-[90vw] max-h-[90vh] flex flex-col items-center",onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between w-full mb-3 px-1",children:[e.jsx("span",{className:"text-sm text-white font-medium truncate max-w-[70%]",children:_.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{const m=document.createElement("a");m.href=_.src,m.download=_.name,document.body.appendChild(m),m.click(),document.body.removeChild(m)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white rounded-lg text-xs font-medium flex items-center gap-1 transition-colors",children:[e.jsx(Xs,{size:12})," Download"]}),e.jsx("button",{onClick:()=>T(null),className:"p-1.5 bg-white/10 hover:bg-white/20 text-white rounded-lg transition-colors",children:e.jsx(Qe,{size:16})})]})]}),e.jsx("img",{src:_.src,alt:_.name,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})]})]})]})}function va({children:s,onClose:n}){return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:n}),e.jsx("div",{className:"relative z-10 w-full max-w-6xl mx-auto px-4 flex items-center justify-center",children:s})]})}function Ur({title:s,message:n,onConfirm:u,onCancel:p,confirmLabel:f,confirmColor:y}){return e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:p}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/10 flex items-center justify-center shrink-0",children:e.jsx(kn,{size:20,className:"text-red-400"})}),e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:s})]}),e.jsx("div",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-300",children:n})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:p,className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:u,className:`px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors ${y||"bg-red-600 hover:bg-red-500"}`,children:f||"Delete"})]})]})]})}function ja({value:s,onChange:n,inputCls:u}){const[p,f]=M.useState(!1),[y,b]=M.useState(s),{data:g}=jr({queryKey:["users"],queryFn:br}),R=M.useMemo(()=>{const j=(g==null?void 0:g.users)||[];return Array.isArray(j)?j:[]},[g]),H=M.useMemo(()=>{if(!y)return R;const j=y.toLowerCase();return R.filter(_=>(_.displayName||"").toLowerCase().includes(j)||(_.username||"").toLowerCase().includes(j)||(_.email||"").toLowerCase().includes(j))},[R,y]);return e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:y,onChange:j=>{b(j.target.value),n(j.target.value),f(!0)},onFocus:()=>f(!0),onBlur:()=>setTimeout(()=>f(!1),200),placeholder:"Search or type name...",className:u}),p&&H.length>0&&e.jsx("div",{className:"absolute z-50 top-full left-0 right-0 mt-1 bg-surface-1 border border-white/10 rounded-lg shadow-xl max-h-48 overflow-y-auto",children:H.map(j=>e.jsxs("button",{type:"button",onMouseDown:_=>{_.preventDefault();const T=j.displayName||j.username;b(T),n(T),f(!1)},className:"w-full flex items-center gap-3 px-3 py-2 text-left hover:bg-white/[0.05] transition-colors",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/20 flex items-center justify-center text-brand-300 text-xs font-semibold shrink-0",children:(j.displayName||j.username||"?").charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-gray-200 truncate",children:j.displayName}),e.jsxs("div",{className:"text-[10px] text-gray-500 truncate",children:["@",j.username,j.email?` · ${j.email}`:""]})]})]},j.id))})]})}function se({label:s,children:n}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-400 mb-1.5",children:s}),n]})}function Rs({externalId:s}){var H,j,_,T,E;const{connectorId:n}=Nr(),u=s!=null&&s.match(/^[A-Z][A-Z0-9]+-\d+$/i)?s:null,{data:p,isLoading:f,refetch:y}=bn(n,u),b=(j=(H=p==null?void 0:p.fields)==null?void 0:H.status)==null?void 0:j.name,g=(E=(T=(_=p==null?void 0:p.fields)==null?void 0:_.status)==null?void 0:T.statusCategory)==null?void 0:E.name;if(!n||!u)return null;const R={"To Do":"bg-gray-500/15 text-gray-400 border-gray-500/20","In Progress":"bg-blue-500/15 text-blue-400 border-blue-500/20",Done:"bg-emerald-500/15 text-emerald-400 border-emerald-500/20"};return e.jsx("span",{className:"inline-flex items-center gap-1",children:f?e.jsx(Nt,{size:12,className:"animate-spin text-gray-500"}):b?e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border ${R[g||""]||"bg-gray-500/15 text-gray-400 border-gray-500/20"}`,children:["JIRA: ",b]}):null})}function Na({defect:s}){var de;const{connectorId:n,isConfigured:u,baseUrl:p}=Nr(),{data:f}=yn(n),{data:y}=vn(n),b=jn(),g=vr(),[R,H]=M.useState(!1),[j,_]=M.useState(""),[T,E]=M.useState("Bug");if(!u)return null;const F=(f==null?void 0:f.projects)||[],J=(y==null?void 0:y.types)||[],X=J.filter(O=>["Bug","Task","Story","Sub-task","Defect"].some(Y=>(O.name||"").toLowerCase().includes(Y.toLowerCase())));X.length===0&&J.length>0&&X.push(...J.slice(0,5));const K=()=>{if(!n||!j)return;const O=[s.description&&`Description: ${s.description}`,s.stepsToReproduce&&`Steps to Reproduce: ${(s.stepsToReproduce||"").replace(/<[^>]+>/g," ").trim()}`,s.expectedResult&&`Expected Result: ${s.expectedResult}`,s.actualResult&&`Actual Result: ${s.actualResult}`,s.environment&&`Environment: ${s.environment}`,`Severity: ${s.severity} | Priority: ${s.priority}`,`Source: Testver Defect ${s.id}`].filter(Boolean).join(`
71
-
72
- `),Y={p1:"Highest",p2:"High",p3:"Medium",p4:"Low"};b.mutate({connectorId:n,data:{projectKey:j,issueType:T,summary:s.title,description:O,priority:Y[s.priority]||"Medium",labels:["testver",s.severity].filter(Boolean)}},{onSuccess:d=>{const D=d.key;g.mutate({id:s.id,data:{externalId:D,externalUrl:Nn(p,D)}}),H(!1)}})},Q="w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 text-sm focus:outline-none focus:ring-1 focus:ring-brand-500";return e.jsx("div",{children:R?e.jsxs("div",{className:"bg-blue-500/5 border border-blue-500/20 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-blue-300",children:"Create JIRA Issue from Defect"}),e.jsx("button",{onClick:()=>H(!1),className:"text-gray-500 hover:text-gray-300",children:e.jsx(Qe,{size:14})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Project"}),e.jsxs("select",{value:j,onChange:O=>_(O.target.value),className:Q,children:[e.jsx("option",{value:"",children:"Select project..."}),F.map(O=>e.jsxs("option",{value:O.key,children:[O.key," — ",O.name]},O.key))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Issue Type"}),e.jsx("select",{value:T,onChange:O=>E(O.target.value),className:Q,children:X.map(O=>e.jsx("option",{value:O.name,children:O.name},O.id||O.name))})]})]}),e.jsxs("div",{className:"text-xs text-gray-400 bg-surface-2 rounded-lg p-2",children:[e.jsx("strong",{className:"text-gray-300",children:"Will create:"})," ",s.title]}),e.jsxs("button",{onClick:K,disabled:!j||b.isPending,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-lg disabled:opacity-50 transition-colors",children:[b.isPending?e.jsx(Nt,{size:14,className:"animate-spin"}):e.jsx(Sr,{size:14}),"Create in JIRA"]}),b.isError&&e.jsx("p",{className:"text-xs text-red-400",children:((de=b.error)==null?void 0:de.message)||"Failed to create"})]}):e.jsxs("button",{onClick:()=>H(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-blue-400 bg-blue-500/10 hover:bg-blue-500/20 rounded-lg border border-blue-500/20 transition-colors",children:[e.jsx(qt,{size:12})," Push to JIRA"]})})}export{Oa as DefectsPage};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-quill-xJF2Jvjc.js","assets/vendor-react-DOVfxdUy.js","assets/vendor-quill-CTpA5PSA.css"])))=>i.map(i=>d[i]);
2
+ import{b as tn,fL as br,ae as yr,bf as sn}from"./index-BlA8ntjb.js";import{r as M,R as He,j as e}from"./vendor-react-DOVfxdUy.js";import"./vendor-quill-xJF2Jvjc.js";import{a as Ke,u as rn,b as nn}from"./useTabParam-CyYAP90W.js";import{u as an}from"./useDebouncedValue-C9odz7b2.js";import{E as on}from"./ExportButton-xrS_AnfS.js";import{ay as Vs,az as ln,aA as cn,aB as vr,aC as dn,aD as un,J as mn,F as pn,aE as xn,aF as fn,aG as hn,aH as gn}from"./useTestManagement-ommXjx0q.js";import{u as jr}from"./vendor-query-DkZSMtfn.js";import{u as Nr,f as bn,d as yn,e as vn,g as jn,c as Nn}from"./useJiraConnector--JZhbYrT.js";import{g as Ts,b5 as wr,w as Tr,ca as wn,cb as Tn,u as _n,s as An,X as Qe,bc as _s,b8 as Xt,r as _r,am as As,$ as qt,v as Ar,be as Sn,j as Ss,a1 as Nt,b1 as Cn,p as kn,ai as En,ab as Js,bx as Ks,aK as Dn,a6 as Xs,dk as Rn,a7 as Sr,z as Cr}from"./vendor-icons-Cm92aSc5.js";/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */function Qs(s,n){(n==null||n>s.length)&&(n=s.length);for(var u=0,p=Array(n);u<n;u++)p[u]=s[u];return p}function On(s){if(Array.isArray(s))return s}function In(s,n){var u=s==null?null:typeof Symbol<"u"&&s[Symbol.iterator]||s["@@iterator"];if(u!=null){var p,f,y,b,g=[],R=!0,H=!1;try{if(y=(u=u.call(s)).next,n!==0)for(;!(R=(p=y.call(u)).done)&&(g.push(p.value),g.length!==n);R=!0);}catch(j){H=!0,f=j}finally{try{if(!R&&u.return!=null&&(b=u.return(),Object(b)!==b))return}finally{if(H)throw f}}return g}}function Ln(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function Pn(s,n){return On(s)||In(s,n)||Mn(s,n)||Ln()}function Mn(s,n){if(s){if(typeof s=="string")return Qs(s,n);var u={}.toString.call(s).slice(8,-1);return u==="Object"&&s.constructor&&(u=s.constructor.name),u==="Map"||u==="Set"?Array.from(s):u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u)?Qs(s,n):void 0}}const kr=Object.entries,Zs=Object.setPrototypeOf,zn=Object.isFrozen,Er=Object.getPrototypeOf,Dr=Object.getOwnPropertyDescriptor;let re=Object.freeze,ae=Object.seal,vt=Object.create,Rr=typeof Reflect<"u"&&Reflect,Cs=Rr.apply,ks=Rr.construct;re||(re=function(n){return n});ae||(ae=function(n){return n});Cs||(Cs=function(n,u){for(var p=arguments.length,f=new Array(p>2?p-2:0),y=2;y<p;y++)f[y-2]=arguments[y];return n.apply(u,f)});ks||(ks=function(n){for(var u=arguments.length,p=new Array(u>1?u-1:0),f=1;f<u;f++)p[f-1]=arguments[f];return new n(...p)});const qe=V(Array.prototype.forEach),Un=V(Array.prototype.lastIndexOf),er=V(Array.prototype.pop),Mt=V(Array.prototype.push),Fn=V(Array.prototype.slice),$n=V(Array.prototype.splice),jt=Array.isArray,xs=Or(Set),fs=V(Set.prototype.add),zt=V(Set.prototype.has),ct=V(String.prototype.toLowerCase),hs=V(String.prototype.toString),tr=V(String.prototype.match),Ut=V(String.prototype.replace),sr=V(String.prototype.indexOf),qn=V(String.prototype.trim),Bn=V(Number.prototype.toString),Hn=V(Boolean.prototype.toString),rr=typeof BigInt>"u"?null:V(BigInt.prototype.toString),nr=typeof Symbol>"u"?null:V(Symbol.prototype.toString),ge=V(Object.prototype.hasOwnProperty),Ft=V(Object.prototype.toString),ne=V(RegExp.prototype.test),Be=Or(TypeError);function V(s){return function(n){n instanceof RegExp&&(n.lastIndex=0);for(var u=arguments.length,p=new Array(u>1?u-1:0),f=1;f<u;f++)p[f-1]=arguments[f];return Cs(s,n,p)}}function Or(s){return function(){for(var n=arguments.length,u=new Array(n),p=0;p<n;p++)u[p]=arguments[p];return ks(s,u)}}function L(s,n){let u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ct;if(Zs&&Zs(s,null),!jt(n))return s;let p=n.length;for(;p--;){let f=n[p];if(typeof f=="string"){const y=u(f);y!==f&&(zn(n)||(n[p]=y),f=y)}s[f]=!0}return s}function Wn(s){for(let n=0;n<s.length;n++)ge(s,n)||(s[n]=null);return s}function je(s){const n=vt(null);for(const p of kr(s)){var u=Pn(p,2);const f=u[0],y=u[1];ge(s,f)&&(jt(y)?n[f]=Wn(y):y&&typeof y=="object"&&y.constructor===Object?n[f]=je(y):n[f]=y)}return n}function Gn(s){switch(typeof s){case"string":return s;case"number":return Bn(s);case"boolean":return Hn(s);case"bigint":return rr?rr(s):"0";case"symbol":return nr?nr(s):"Symbol()";case"undefined":return Ft(s);case"function":case"object":{if(s===null)return Ft(s);const n=s,u=we(n,"toString");if(typeof u=="function"){const p=u(n);return typeof p=="string"?p:Ft(p)}return Ft(s)}default:return Ft(s)}}function we(s,n){for(;s!==null;){const p=Dr(s,n);if(p){if(p.get)return V(p.get);if(typeof p.value=="function")return V(p.value)}s=Er(s)}function u(){return null}return u}function Yn(s,n){for(;s!==null;){const u=Dr(s,n);if(u)return u.get?V(u.get):null;s=Er(s)}return null}function Vn(s){try{return ne(s,""),!0}catch{return!1}}const ar=re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),gs=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),bs=re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Jn=re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ys=re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Kn=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ir=re(["#text"]),or=re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),vs=re(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),lr=re(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Vt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Xn=ae(/{{[\w\W]*|^[\w\W]*}}/g),Qn=ae(/<%[\w\W]*|^[\w\W]*%>/g),Zn=ae(/\${[\w\W]*/g),ea=ae(/^data-[\-\w.\u00B7-\uFFFF]+$/),ta=ae(/^aria-[\-\w]+$/),cr=ae(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),sa=ae(/^(?:\w+script|data):/i),ra=ae(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),na=ae(/^html$/i),aa=ae(/^[a-z][.\w]*(-[.\w]+)+$/i),js=ae(/<[/\w!]/g),dr=ae(/<[/\w]/g),ia=ae(/<\/no(script|embed|frames)/i),ur=ae(/\/>/i),Z={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},oa=re(L({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),la=function(){return typeof window>"u"?null:window},ca=function(n,u){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let p=null;const f="data-tt-policy-suffix";u&&u.hasAttribute(f)&&(p=u.getAttribute(f));const y="dompurify"+(p?"#"+p:"");try{return n.createPolicy(y,{createHTML(b){return b},createScriptURL(b){return b}})}catch{return console.warn("TrustedTypes policy "+y+" could not be created."),null}},mr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Xe=function(n,u,p,f){return ge(n,u)&&jt(n[u])?L(f.base?je(f.base):{},n[u],f.transform):p},Ns=function(n,u,p){const f=ge(n,u)?n[u]:void 0;return f&&typeof f=="object"?je(f):p()};function Ir(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:la();const n=c=>Ir(c);if(n.version="3.4.17",n.removed=[],!s||!s.document||s.document.nodeType!==Z.document||!s.Element)return n.isSupported=!1,n;let u=s.document;const p=u,f=p.currentScript;s.DocumentFragment;const y=s.HTMLTemplateElement,b=s.Node,g=s.Element,R=s.NodeFilter;s.NamedNodeMap===void 0&&(s.NamedNodeMap||s.MozNamedAttrMap),s.HTMLFormElement;const H=s.DOMParser,j=s.trustedTypes,_=g.prototype,T=we(_,"cloneNode"),E=we(_,"remove"),F=we(_,"removeAttributeNode"),J=we(_,"nextSibling"),X=we(_,"childNodes"),K=we(_,"parentNode"),Q=we(_,"shadowRoot"),de=we(_,"attributes"),O=b&&b.prototype?we(b.prototype,"nodeType"):null,Y=b&&b.prototype?we(b.prototype,"nodeName"):null,d=b&&b.prototype?we(b.prototype,"ownerDocument"):null,D=function(t){return O?O(t):t.nodeType},z=function(t){return Y?Y(t):t.nodeName},me=Yn(_,"namespaceURI"),Ee=function(t){return me?me(t):t.namespaceURI};if(typeof y=="function"){const c=u.createElement("template");c.content&&c.content.ownerDocument&&(u=c.content.ownerDocument)}let m,A="",ie,pe=!1,Pe=0;const Ze=function(){if(Pe>0)throw Be('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},be=function(t){Ze(),Pe++;try{return m.createHTML(t)}finally{Pe--}},et=function(t){Ze(),Pe++;try{return m.createScriptURL(t)}finally{Pe--}},De=function(){return pe||(ie=ca(j,f),pe=!0),ie},Re=u,tt=Re.implementation,Te=Re.createNodeIterator,Me=Re.createDocumentFragment,st=Re.getElementsByTagName,wt=p.importNode;let W=mr();n.isSupported=typeof kr=="function"&&typeof K=="function"&&tt&&tt.createHTMLDocument!==void 0;const Os=Xn,Is=Qn,Tt=Zn,ts=ea,ss=ta,rt=sa,Bt=ra,nt=aa;let rs=cr,U=null;const ut=L({},[...ar,...gs,...bs,...ys,...ir]);let $=null;const ze=L({},[...or,...vs,...lr,...Vt]);let ye=Object.seal(vt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Oe=null,Ne=null;const ve=Object.seal(vt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let _e=!0,Ue=!0,xe=!1,at=!0,oe=!1,I=!0,Ae=!1,Ie=!1,le=null,it=null,mt=!1,We=!1,ot=!1,Se=!1,_t=!0,At=!1;const Ht="user-content-";let St=!0,Ct=!1,Fe=null,Ge={},$e=null;const kt=L({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Et=null;const Dt=L({},["audio","video","img","source","image","track"]);let Rt=null;const Ot=L({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),pt="http://www.w3.org/1998/Math/MathML",l="http://www.w3.org/2000/svg",h="http://www.w3.org/1999/xhtml";let S=h,G=!1,C=null;const P=L({},[pt,l,h],hs),lt=re(["mi","mo","mn","ms","mtext"]);let Ye=L({},lt);const xt=re(["annotation-xml"]);let Ce=L({},xt);const a=L({},["title","style","font","a","script"]);let te=null;const x=["application/xhtml+xml","text/html"],ce="text/html";let q=null,w=null;const It=u.createElement("form"),ft=function(t){return t instanceof RegExp||t instanceof Function},ns=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(w&&w===t)return;(!t||typeof t!="object")&&(t={}),t=je(t),te=x.indexOf(t.PARSER_MEDIA_TYPE)===-1?ce:t.PARSER_MEDIA_TYPE,q=te==="application/xhtml+xml"?hs:ct,U=Xe(t,"ALLOWED_TAGS",ut,{transform:q}),$=Xe(t,"ALLOWED_ATTR",ze,{transform:q}),C=Xe(t,"ALLOWED_NAMESPACES",P,{transform:hs}),Rt=Xe(t,"ADD_URI_SAFE_ATTR",Ot,{transform:q,base:Ot}),Et=Xe(t,"ADD_DATA_URI_TAGS",Dt,{transform:q,base:Dt}),$e=Xe(t,"FORBID_CONTENTS",kt,{transform:q}),Oe=Xe(t,"FORBID_TAGS",je({}),{transform:q}),Ne=Xe(t,"FORBID_ATTR",je({}),{transform:q}),Ge=ge(t,"USE_PROFILES")?t.USE_PROFILES&&typeof t.USE_PROFILES=="object"?je(t.USE_PROFILES):t.USE_PROFILES:!1,_e=t.ALLOW_ARIA_ATTR!==!1,Ue=t.ALLOW_DATA_ATTR!==!1,xe=t.ALLOW_UNKNOWN_PROTOCOLS||!1,at=t.ALLOW_SELF_CLOSE_IN_ATTR!==!1,oe=t.SAFE_FOR_TEMPLATES||!1,I=t.SAFE_FOR_XML!==!1,Ae=t.WHOLE_DOCUMENT||!1,We=t.RETURN_DOM||!1,ot=t.RETURN_DOM_FRAGMENT||!1,Se=t.RETURN_TRUSTED_TYPE||!1,mt=t.FORCE_BODY||!1,_t=t.SANITIZE_DOM!==!1,At=t.SANITIZE_NAMED_PROPS||!1,St=t.KEEP_CONTENT!==!1,Ct=t.IN_PLACE||!1,rs=Vn(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:cr,S=typeof t.NAMESPACE=="string"?t.NAMESPACE:h,Ye=Ns(t,"MATHML_TEXT_INTEGRATION_POINTS",()=>L({},lt)),Ce=Ns(t,"HTML_INTEGRATION_POINTS",()=>L({},xt));const r=Ns(t,"CUSTOM_ELEMENT_HANDLING",()=>vt(null));if(ye=vt(null),ge(r,"tagNameCheck")&&ft(r.tagNameCheck)&&(ye.tagNameCheck=r.tagNameCheck),ge(r,"attributeNameCheck")&&ft(r.attributeNameCheck)&&(ye.attributeNameCheck=r.attributeNameCheck),ge(r,"allowCustomizedBuiltInElements")&&typeof r.allowCustomizedBuiltInElements=="boolean"&&(ye.allowCustomizedBuiltInElements=r.allowCustomizedBuiltInElements),ae(ye),oe&&(Ue=!1),ot&&(We=!0),Ge&&(U=L({},ir),$=vt(null),Ge.html===!0&&(L(U,ar),L($,or)),Ge.svg===!0&&(L(U,gs),L($,vs),L($,Vt)),Ge.svgFilters===!0&&(L(U,bs),L($,vs),L($,Vt)),Ge.mathMl===!0&&(L(U,ys),L($,lr),L($,Vt))),ve.tagCheck=null,ve.attributeCheck=null,ge(t,"ADD_TAGS")&&(typeof t.ADD_TAGS=="function"?ve.tagCheck=t.ADD_TAGS:jt(t.ADD_TAGS)&&(U===ut&&(U=je(U)),L(U,t.ADD_TAGS,q))),ge(t,"ADD_ATTR")&&(typeof t.ADD_ATTR=="function"?ve.attributeCheck=t.ADD_ATTR:jt(t.ADD_ATTR)&&($===ze&&($=je($)),L($,t.ADD_ATTR,q))),ge(t,"ADD_FORBID_CONTENTS")&&jt(t.ADD_FORBID_CONTENTS)&&($e===kt&&($e=je($e)),L($e,t.ADD_FORBID_CONTENTS,q)),St&&(U["#text"]=!0),Ae&&L(U,["html","head","body"]),U.table&&(L(U,["tbody"]),delete Oe.tbody),t.TRUSTED_TYPES_POLICY){if(typeof t.TRUSTED_TYPES_POLICY.createHTML!="function")throw Be('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof t.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Be('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const i=m;m=t.TRUSTED_TYPES_POLICY;try{A=be("")}catch(o){throw m=i,o}}else t.TRUSTED_TYPES_POLICY===null?(m=void 0,A=""):(m===void 0&&(m=De()),m&&typeof A=="string"&&(A=be("")));re&&re(t),w=t},Ls=L({},[...gs,...bs,...Jn]),Ps=L({},[...ys,...Kn]),Fr=function(t,r,i){return r.namespaceURI===h?t==="svg":r.namespaceURI===pt?t==="svg"&&(i==="annotation-xml"||Ye[i]):!!Ls[t]},$r=function(t,r,i){return r.namespaceURI===h?t==="math":r.namespaceURI===l?t==="math"&&Ce[i]:!!Ps[t]},qr=function(t,r,i){return r.namespaceURI===l&&!Ce[i]||r.namespaceURI===pt&&!Ye[i]?!1:!Ps[t]&&(a[t]||!Ls[t])},Br=function(t){const r=Ee(t),i=ct(z(t)),o=K(t);let v,N;return o&&D(o)===Z.element?(v={namespaceURI:Ee(o)},N=ct(z(o))):(v={namespaceURI:S},N="template"),C[r]?r===l?Fr(i,v,N):r===pt?$r(i,v,N):r===h?qr(i,v,N):!!(te==="application/xhtml+xml"&&C[r]):!1},Ve=function(t){Mt(n.removed,{element:t});try{K(t).removeChild(t)}catch{if(E(t),!K(t))throw Be("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ms=function(t,r,i){try{F(t,r)}catch{try{t.removeAttribute(i)}catch{}}},as=function(t){os(t);const r=X(t);r&&qe(Fn(r),o=>{try{E(o)}catch{}});const i=D(t)===Z.element?de(t):null;if(i)for(let o=i.length-1;o>=0;--o){const v=i[o],N=v&&v.name;typeof N=="string"&&Ms(t,v,N)}},ht=function(t,r,i){if(!i)try{i=r.getAttributeNode(t)}catch{i=null}Mt(n.removed,{attribute:i||null,from:r});try{i?F(r,i):r.removeAttribute(t)}catch{try{r.removeAttribute(t)}catch{}}if(t==="is")if(We||ot)try{Ve(r)}catch{}else try{r.setAttribute(t,"")}catch{}},zs=function(t){const r=de(t);if(r)for(let i=r.length-1;i>=0;--i){const o=r[i],v=o&&o.name;typeof v!="string"||$[q(v)]||Ms(t,o,v)}},is=function(t,r){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const o=[t];for(;o.length>0;){const v=o.pop();if(r(v)===!1)continue;if(i&&D(v)===Z.element){const k=Q(v);Je(k)&&o.push(k)}const N=X(v);if(N)for(let k=N.length-1;k>=0;--k)o.push(N[k])}},os=function(t){is(t,r=>{D(r)===Z.element&&zs(r)})},ls=function(t){const r=[];return is(t,i=>{r.push(i)},!0),r},Hr=function(t,r){const i=xs();qe(ls(t),o=>{D(o)===Z.element&&fs(i,o)}),qe(r,o=>{D(o)===Z.element&&!zt(i,o)&&zs(o)})},Us=function(t,r){let i=!1;return qe(n.removed,o=>{o.element&&(i=i||o.element===t,os(o.element))}),Hr(t,r),i},Wr=8,Gr=function(t,r){const i=Fe;let o=null;const v=()=>(o||(o=xs(),qe(r,N=>{fs(o,N)})),o);for(let N=0;;N++){const k=ls(t),ee=[t];let Le=!1;if(qe(k,ue=>{D(ue)===Z.documentFragment?Mt(ee,ue):!Le&&!zt(i,ue)&&(Le=zt(v(),ue))}),!Le)return;if(N>=Wr)throw Be("the tree kept changing during in-place sanitization; refusing to return it");qe(ee,(ue,fe)=>{Yr(ue,fe>0,t,v())})}},Yr=function(t,r,i,o){const v=cs(t);let N;for(;N=v.nextNode();)!zt(o,N)||zt(Fe,N)||(r&&ke(W.uponSanitizeShadowNode,N,null),us(N,i),ms(N,i),Je(N.content)&&Pt(N.content))},Vr=function(t){Fe&&fs(Fe,t)},Fs=function(t,r){return I?t==="patchsrc"?!0:t==="for"&&r!=="label"&&r!=="output":!1},Jr=function(t){I&&is(t,r=>{const i=D(r);if(i===Z.processingInstruction||i===Z.comment&&ne(dr,r.data)){try{E(r)}catch{}return!1}if(i===Z.element){const o=r,v=q(z(r));try{o.hasAttribute&&o.hasAttribute("patchsrc")&&o.removeAttribute("patchsrc"),o.hasAttribute&&o.hasAttribute("for")&&Fs("for",v)&&o.removeAttribute("for")}catch{}}return!0})},$s=function(t){let r=null,i=null;if(mt)t="<remove></remove>"+t;else{const N=tr(t,/^[\r\n\t ]+/);i=N&&N[0]}te==="application/xhtml+xml"&&S===h&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const o=m?be(t):t;if(S===h)try{r=new H().parseFromString(o,te)}catch{}if(!r||!r.documentElement){r=tt.createDocument(S,"template",null);try{r.documentElement.innerHTML=G?A:o}catch{}}const v=r.body||r.documentElement;return t&&i&&v.insertBefore(u.createTextNode(i),v.childNodes[0]||null),S===h?st.call(r,Ae?"html":"body")[0]:Ae?r.documentElement:v},cs=function(t){const r=d?d(t):t.ownerDocument;return Te.call(r||t,t,R.SHOW_ELEMENT|R.SHOW_COMMENT|R.SHOW_TEXT|R.SHOW_PROCESSING_INSTRUCTION|R.SHOW_CDATA_SECTION,null)},Wt=function(t){return t=Ut(t,Os," "),t=Ut(t,Is," "),t=Ut(t,Tt," "),t},ds=function(t){var r;qs(t);const i=(r=t.querySelectorAll)===null||r===void 0?void 0:r.call(t,"template");i&&qe(i,o=>{Je(o.content)&&ds(o.content)})},qs=function(t){t.normalize();const r=d?d(t):t.ownerDocument,i=Te.call(r||t,t,R.SHOW_TEXT|R.SHOW_COMMENT|R.SHOW_CDATA_SECTION|R.SHOW_PROCESSING_INSTRUCTION,null);let o=i.nextNode();for(;o;)o.data=Wt(o.data),o=i.nextNode()},Gt=function(t){const r=Y?Y(t):null;return typeof r!="string"||q(r)!=="form"?!1:typeof t.nodeName!="string"||typeof t.textContent!="string"||typeof t.removeChild!="function"||t.attributes!==de(t)||typeof t.removeAttribute!="function"||typeof t.removeAttributeNode!="function"||typeof t.getAttributeNode!="function"||typeof t.setAttribute!="function"||typeof t.namespaceURI!="string"||typeof t.insertBefore!="function"||typeof t.hasChildNodes!="function"||t.nodeType!==O(t)||t.childNodes!==X(t)},Je=function(t){if(!O||typeof t!="object"||t===null)return!1;try{return O(t)===Z.documentFragment}catch{return!1}},Lt=function(t){if(!O||typeof t!="object"||t===null)return!1;try{return typeof O(t)=="number"}catch{return!1}};function ke(c,t,r){c.length!==0&&qe(c,i=>{i.call(n,t,r,w)})}const Kr=function(t,r){return!!(I&&t.hasChildNodes()&&!Lt(t.firstElementChild)&&ne(js,t.textContent)&&ne(js,t.innerHTML)||I&&oa[r]&&D(t)===Z.element&&Ee(t)===h&&(Lt(t.firstElementChild)||typeof t.textContent=="string"&&ne(js,t.textContent))||t.nodeType===Z.processingInstruction||I&&t.nodeType===Z.comment&&ne(dr,t.data))},Yt=function(t,r){if(t instanceof RegExp)return ne(t,r);if(t instanceof Function){for(var i=arguments.length,o=new Array(i>2?i-2:0),v=2;v<i;v++)o[v-2]=arguments[v];return!!t(r,...o)}return!1},Xr=function(t,r,i){if(!Oe[r]&&Ws(r)&&Yt(ye.tagNameCheck,r))return!1;if(St&&!$e[r]&&!$e[ct(r)]){const o=K(t),v=X(t);if(v&&o){const N=v.length;for(let k=N-1;k>=0;--k){const ee=t===i?T(v[k],!0):v[k];o.insertBefore(ee,J(t))}}}return Ve(t),!0},Bs=function(t,r,i,o){return t.length===0?r:r===i||r===o?je(r):r},gt=function(t,r){return t===r||K(t)!==null?!1:(Ct&&os(t),!0)},us=function(t,r){if(Vr(t),ke(W.beforeSanitizeElements,t,null),gt(t,r))return!0;if(Gt(t))return Ve(t),!0;const i=q(z(t));if(U=Bs(W.uponSanitizeElement,U,ut,le),ke(W.uponSanitizeElement,t,{tagName:i,allowedTags:U}),gt(t,r))return!0;if(Kr(t,i))return Ve(t),!0;if(Oe[i]||!(ve.tagCheck instanceof Function&&ve.tagCheck(i))&&!U[i]){const o=Xr(t,i,r);return o===!1&&(ke(W.afterSanitizeElements,t,null),gt(t,r))?!0:o}if(D(t)===Z.element&&!Br(t)||(i==="noscript"||i==="noembed"||i==="noframes")&&ne(ia,t.innerHTML))return Ve(t),!0;if(oe&&t.nodeType===Z.text){const o=Wt(t.textContent);t.textContent!==o&&(Mt(n.removed,{element:t.cloneNode()}),t.textContent=o)}return ke(W.afterSanitizeElements,t,null),gt(t,r)},Hs=function(t,r,i){if(Ne[r]||Fs(r,t)||_t&&(r==="id"||r==="name")&&(i in u||i in It))return!1;const o=$[r]||ve.attributeCheck instanceof Function&&ve.attributeCheck(r,t);return Ue&&ne(ts,r)||_e&&ne(ss,r)?!0:o?Rt[r]||ne(rs,Ut(i,Bt,""))||(r==="src"||r==="xlink:href"||r==="href")&&t!=="script"&&sr(i,"data:")===0&&Et[t]||xe&&!ne(rt,Ut(i,Bt,""))?!0:!i:Ws(t)&&Yt(ye.tagNameCheck,t)&&Yt(ye.attributeNameCheck,r,t)||r==="is"&&ye.allowCustomizedBuiltInElements&&Yt(ye.tagNameCheck,i)},Qr=L({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ws=function(t){return!Qr[ct(t)]&&ne(nt,t)},Zr=function(t,r,i,o){if(m&&typeof j=="object"&&typeof j.getAttributeType=="function"&&!i)switch(j.getAttributeType(t,r)){case"TrustedHTML":return be(o);case"TrustedScriptURL":return et(o)}return o},en=function(t,r,i,o){try{return i?t.setAttributeNS(i,r,o):t.setAttribute(r,o),Gt(t)?(Ve(t),!1):!0}catch{return ht(r,t),!1}},Gs=function(t,r){return I&&ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,r)?!0:ct(t)==="attributename"&&tr(r,"href")!==null},ms=function(t,r){if(ke(W.beforeSanitizeAttributes,t,null),gt(t,r))return;const i=t.attributes;if(!i||Gt(t))return;$=Bs(W.uponSanitizeAttribute,$,ze,it);const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$,forceKeepAttr:void 0};let v=i.length;const N=q(t.nodeName);for(;v--;){const k=i[v],ee=k.name,Le=k.namespaceURI,ue=k.value,fe=q(ee),bt=ue;let he=ee==="value"?bt:qn(bt),Ys=!1;if(o.attrName=fe,o.attrValue=he,o.keepAttr=!0,o.forceKeepAttr=void 0,ke(W.uponSanitizeAttribute,t,o),he=o.attrValue,At&&(fe==="id"||fe==="name")&&sr(he,Ht)!==0&&(ht(ee,t,k),he=Ht+he,Ys=!0),Gs(ee,he)){ht(ee,t,k);continue}if(!o.forceKeepAttr){if(!o.keepAttr){ht(ee,t,k);continue}if(!at&&ne(ur,he)){ht(ee,t,k);continue}if(oe&&(he=Wt(he)),!Hs(N,fe,he)){ht(ee,t,k);continue}he=Zr(N,fe,Le,he),he!==bt&&en(t,ee,Le,he)&&Ys&&er(n.removed)}}ke(W.afterSanitizeAttributes,t,null),gt(t,r)},Pt=function(t){let r=null;const i=cs(t);for(ke(W.beforeSanitizeShadowDOM,t,null);r=i.nextNode();)if(ke(W.uponSanitizeShadowNode,r,null),us(r,t),ms(r,t),Je(r.content)&&Pt(r.content),D(r)===Z.element){const o=Q(r);Je(o)&&(ps(o),Pt(o))}oe&&qs(t),ke(W.afterSanitizeShadowDOM,t,null)},ps=function(t){const r=[{node:t,shadow:null}];for(;r.length>0;){const i=r.pop();if(i.shadow){Pt(i.shadow);continue}const o=i.node,v=D(o)===Z.element,N=X(o);if(N)for(let k=N.length-1;k>=0;--k)r.push({node:N[k],shadow:null});if(v){const k=Y?Y(o):null;if(typeof k=="string"&&q(k)==="template"){const ee=o.content;Je(ee)&&r.push({node:ee,shadow:null})}}if(v){const k=Q(o);Je(k)&&r.push({node:null,shadow:k},{node:k,shadow:null})}}};return n.sanitize=function(c){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=null,i=null,o=null,v=null;if(G=!c,G&&(c="<!-->"),typeof c!="string"&&!Lt(c)&&(c=Gn(c),typeof c!="string"))throw Be("dirty is not a string, aborting");if(!n.isSupported)return c;Ie?(U=le,$=it):ns(t),(W.uponSanitizeElement.length>0||W.uponSanitizeAttribute.length>0)&&(U=je(U)),W.uponSanitizeAttribute.length>0&&($=je($)),n.removed=[];const N=Ct&&typeof c!="string"&&Lt(c);let k=[];const ee=Fe;if(N){Jr(c);const fe=z(c);if(typeof fe=="string"){const bt=q(fe);if(!U[bt]||Oe[bt])throw as(c),Be("root node is forbidden and cannot be sanitized in-place")}if(Gt(c))throw as(c),Be("root node is clobbered and cannot be sanitized in-place");k=ls(c),Fe=xs()}else if(Lt(c))r=$s("<!---->"),i=r.ownerDocument.importNode(c,!0),i.nodeType===Z.element&&i.nodeName==="BODY"||i.nodeName==="HTML"?r=i:r.appendChild(i),ps(r);else{if(!We&&!oe&&!Ae&&c.indexOf("<")===-1)return m&&Se?be(c):c;if(r=$s(c),!r)return We?null:Se?A:""}r&&mt&&Ve(r.firstChild);const Le=N?c:r;try{N&&ps(c);const fe=cs(Le);for(;o=fe.nextNode();)us(o,Le),ms(o,Le),Je(o.content)&&Pt(o.content);N&&Gr(c,k)}catch(fe){throw N&&(as(c),Us(c,k)),fe}finally{Fe=ee}if(N){if(Us(c,k))throw Be("a node selected for removal could not be safely returned; refusing to sanitize in place");return oe&&ds(c),c}if(We){if(oe&&ds(r),ot)for(v=Me.call(r.ownerDocument);r.firstChild;)v.appendChild(r.firstChild);else v=r;return($.shadowroot||$.shadowrootmode)&&(v=wt.call(p,v,!0)),v}let ue=Ae?r.outerHTML:r.innerHTML;return Ae&&U["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&ne(na,r.ownerDocument.doctype.name)&&(ue="<!DOCTYPE "+r.ownerDocument.doctype.name+`>
4
+ `+ue),oe&&(ue=Wt(ue)),m&&Se?be(ue):ue},n.setConfig=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ns(c),Ie=!0,le=U,it=$},n.clearConfig=function(){w=null,Ie=!1,le=null,it=null,m=ie,A=""},n.isValidAttribute=function(c,t,r){w||ns({});const i=q(c),o=q(t);return typeof r=="string"&&(Gs(t,r)||!at&&ne(ur,r))?!1:Hs(i,o,r)},n.addHook=function(c,t){typeof t=="function"&&ge(W,c)&&Mt(W[c],t)},n.removeHook=function(c,t){if(ge(W,c)){if(t!==void 0){const r=Un(W[c],t);return r===-1?void 0:$n(W[c],r,1)[0]}return er(W[c])}},n.removeHooks=function(c){ge(W,c)&&(W[c]=[])},n.removeAllHooks=function(){W=mr()},n}var da=Ir();function ua(s){return da.sanitize(s??"",{USE_PROFILES:{html:!0},FORBID_TAGS:["style","form","input","button","textarea","select"]})}const Lr=["blocker","critical","major","minor","trivial"],Es=["open","in_progress","resolved","closed","rejected"],ma={blocker:"bg-red-500/20 text-red-500",critical:"bg-red-400/20 text-red-400",major:"bg-orange-400/20 text-orange-400",minor:"bg-amber-400/20 text-amber-400",trivial:"bg-gray-400/20 text-gray-400"},pa={open:"bg-red-500/20 text-red-400",in_progress:"bg-blue-500/20 text-blue-400",resolved:"bg-emerald-500/20 text-emerald-400",closed:"bg-gray-500/20 text-gray-400",rejected:"bg-slate-500/20 text-slate-400"},Qt=["p1","p2","p3","p4"],dt={p1:"P1-Critical",p2:"P2-High",p3:"P3-Medium",p4:"P4-Low"},Ds={p1:"bg-red-500/20 text-red-400",p2:"bg-orange-400/20 text-orange-400",p3:"bg-blue-400/20 text-blue-400",p4:"bg-gray-400/20 text-gray-400"},pr={blocker:"bg-red-300",critical:"bg-rose-200",major:"bg-orange-200",minor:"bg-amber-200",trivial:"bg-gray-300"},xr=["open","in_progress","resolved","closed"],yt=["blocker","critical","major","minor","trivial"],Zt={p1:"P1",p2:"P2",p3:"P3",p4:"P4"},es={open:"in_progress",in_progress:"resolved",resolved:"closed"},fr={blocker:"bg-red-700",critical:"bg-red-400",major:"bg-orange-400",minor:"bg-amber-400",trivial:"bg-gray-400"};function ws(s){return s.createdAt?Math.max(0,Math.ceil((Date.now()-new Date(s.createdAt).getTime())/864e5)):0}function hr(s){return s<3?"bg-emerald-500/15 text-emerald-400":s<=7?"bg-amber-500/15 text-amber-400":"bg-red-500/15 text-red-400"}function Jt(s){return!!s.dueDate&&new Date(s.dueDate).getTime()<Date.now()&&s.status!=="closed"&&s.status!=="rejected"}function Pr(s){const n=s.trim().split(/\s+/).filter(Boolean);return n.length===0?"?":((n[0][0]||"")+(n.length>1&&n[n.length-1][0]||"")).toUpperCase()}function Mr(s){const n=["bg-indigo-600","bg-teal-600","bg-violet-600","bg-cyan-700","bg-rose-600","bg-emerald-600"];let u=0;for(const p of s)u=u*31+p.charCodeAt(0)>>>0;return n[u%n.length]}function gr({name:s,size:n=19}){const u={width:n,height:n,fontSize:Math.max(8,n*.45)};return s?e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-gray-300 min-w-0",children:[e.jsx("span",{style:u,className:`rounded-full ${Mr(s)} text-white font-bold flex items-center justify-center shrink-0`,children:Pr(s)}),e.jsx("span",{className:"truncate",children:s})]}):e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 min-w-0",children:[e.jsx("span",{style:u,className:"rounded-full border border-dashed border-gray-400/60 bg-surface-2 text-gray-400 flex items-center justify-center shrink-0",children:"?"}),e.jsx("span",{className:"truncate",children:"Unassigned"})]})}function $t({label:s,value:n,options:u,display:p,onChange:f,onClear:y}){const b=!!n;return e.jsxs("span",{className:`relative inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs cursor-pointer select-none transition-colors ${b?"bg-brand-600 border-brand-600 text-white":"bg-surface-1 border-white/10 text-gray-300 hover:border-gray-400/40"}`,children:[e.jsxs("span",{children:[s,b&&e.jsxs(e.Fragment,{children:[": ",e.jsx("b",{className:"font-semibold",children:p||n})]})]}),!b&&e.jsx(Cr,{size:10,className:"opacity-60"}),e.jsxs("select",{value:n,onChange:g=>g.target.value?f(g.target.value):y(),className:"absolute inset-0 opacity-0 cursor-pointer w-full text-gray-900 dark:text-gray-200","aria-label":s,children:[e.jsx("option",{value:"",children:"All"}),u.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))]}),b&&e.jsx("button",{onClick:g=>{g.preventDefault(),g.stopPropagation(),y()},className:"relative z-10 opacity-70 hover:opacity-100 -mr-0.5",title:`Clear ${s.toLowerCase()} filter`,children:e.jsx(Qe,{size:11})})]})}function B(s){return s.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function zr(s){return s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}function Kt(s){return s?new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function xa(){return{title:"",description:"",priority:"p3",severity:"major",status:"open",expectedResult:"",actualResult:"",stepsToReproduce:"",environment:"",assignedTo:"",reporter:"",dueDate:"",tags:"",externalId:"",externalUrl:"",testCaseId:""}}function Oa(){const[s,n,u]=Ke("search"),[p,f,y]=Ke("status"),[b,g,R]=Ke("severity"),[H,j]=M.useState(!1),[_,T]=M.useState(null),[E,F]=M.useState(null),[J,X]=rn("view",["table","board"],"board"),[K]=Ke("defectId"),Q=nn(),[de,O]=M.useState(null),[Y,d,D]=Ke("priority"),[z,me,Ee]=Ke("assignee"),[m,A,ie]=Ke("overdue"),[pe,Pe,Ze]=Ke("sort"),be=pe||"oldest",[et,De]=M.useState({closed:!1,rejected:!1}),[Re,tt]=M.useState(null),[Te,Me]=M.useState(new Set),[st,wt]=M.useState(null);He.useEffect(()=>{if(!Re)return;const l=h=>{var S,G;(G=(S=h.target)==null?void 0:S.closest)!=null&&G.call(S,"[data-assign-root]")||tt(null)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[Re]);const{toast:W}=tn(),[Os,Is]=M.useState(!1),Tt=an(s,250),ts=M.useMemo(()=>({...p?{status:p}:{},...b?{severity:b}:{},...Tt?{search:Tt}:{}}),[p,b,Tt]),ss=l=>l?n(l):u(),{data:rt,isLoading:Bt}=Vs(ts),{data:nt}=Vs({}),{data:rs}=ln(),{data:U}=jr({queryKey:["users"],queryFn:br}),ut=M.useMemo(()=>((U==null?void 0:U.users)||[]).map(h=>h.displayName||h.username).filter(Boolean),[U]),$=cn(),ze=vr(),ye=dn(),Oe=un(),{user:Ne}=yr(),ve=(Ne==null?void 0:Ne.displayName)||"",{data:_e}=mn(),Ue=Array.isArray(rt)?rt:(rt==null?void 0:rt.defects)??[],xe=Array.isArray(nt)?nt:(nt==null?void 0:nt.defects)??[],at=Array.isArray(_e)?_e:(_e==null?void 0:_e.folders)??(_e==null?void 0:_e.tree)??[],oe=M.useMemo(()=>{let l=[...Ue];Y&&(l=l.filter(C=>C.priority===Y)),z&&(l=z==="__unassigned__"?l.filter(C=>!C.assignedTo):l.filter(C=>C.assignedTo===z)),m&&(l=l.filter(Jt));const h=C=>{const P=yt.indexOf(C.severity);return P<0?99:P},S=C=>{const P=Qt.indexOf(C.priority);return P<0?99:P},G=C=>new Date(C.createdAt||0).getTime();switch(be){case"newest":l.sort((C,P)=>G(P)-G(C));break;case"priority":l.sort((C,P)=>S(C)-S(P)||G(C)-G(P));break;case"severity":l.sort((C,P)=>h(C)-h(P)||G(C)-G(P));break;case"due":l.sort((C,P)=>(C.dueDate?new Date(C.dueDate).getTime():1/0)-(P.dueDate?new Date(P.dueDate).getTime():1/0));break;default:l.sort((C,P)=>G(C)-G(P))}return l},[Ue,Y,z,m,be]),I=M.useMemo(()=>{const l=Date.now()-6048e5,h=xe.filter(x=>x.status!=="closed"&&x.status!=="rejected"),S=xe.filter(x=>x.status==="open"),G=xe.filter(x=>x.status==="in_progress"),C=h.filter(x=>x.severity==="blocker"),P=h.filter(Jt),lt=xe.filter(x=>x.resolvedAt&&new Date(x.resolvedAt).getTime()>=l).length,Ye=xe.filter(x=>x.createdAt&&new Date(x.createdAt).getTime()>=l).length,xt=S.filter(x=>x.createdAt&&new Date(x.createdAt).getTime()>=l).length,Ce={};for(const x of yt)Ce[x]=0;for(const x of xe)Ce[x.severity]!==void 0&&Ce[x.severity]++;const a=xe.filter(x=>x.resolvedAt&&x.createdAt).map(x=>(new Date(x.resolvedAt).getTime()-new Date(x.createdAt).getTime())/864e5).filter(x=>x>=0),te=a.length?a.reduce((x,ce)=>x+ce,0)/a.length:null;return{total:xe.length,activeCount:h.length,open:S.length,openNewThisWeek:xt,inProgress:G.length,inProgressAssigned:G.filter(x=>x.assignedTo).length,blockers:C.length,blockersUnassigned:C.filter(x=>!x.assignedTo).length,overdue:P.length,overdueOldest:P.length?Math.max(...P.map(ws)):0,resolvedThisWeek:lt,createdThisWeek:Ye,netThisWeek:Ye-lt,sevMix:Ce,avgResolutionDays:te}},[xe]),Ae=M.useMemo(()=>{const l=new Set;for(const h of xe)h.assignedTo&&l.add(h.assignedTo);for(const h of ut)l.add(h);return Array.from(l).sort()},[xe,ut]),Ie=M.useMemo(()=>{if(!K)return null;const l=K.toLowerCase();return Ue.find(h=>{var S;return((S=h.id)==null?void 0:S.toLowerCase())===l})??null},[Ue,K]);function le(l){W("success",l)}M.useMemo(()=>{const l=[];function h(S,G){var C;for(const P of S)l.push({id:P.id,name:P.name,depth:G}),(C=P.children)!=null&&C.length&&h(P.children,G+1)}return Array.isArray(at)&&h(at,0),l},[at]);function it(){T(null),j(!0)}function mt(l){T(l),j(!0)}async function We(l){try{_?(await ze.mutateAsync({id:_.id,data:{...l,performedBy:ve||(Ne==null?void 0:Ne.username)||"Unknown"}}),le("Defect updated successfully")):(await $.mutateAsync(l),le("Defect created successfully")),j(!1),T(null)}catch{}}function ot(l){O({title:"Delete Defect",message:"Are you sure you want to delete this defect? This action cannot be undone.",onConfirm:async()=>{O(null);try{await ye.mutateAsync(l),Q({defectId:null}),le("Defect deleted")}catch{}}})}const Se=ve||(Ne==null?void 0:Ne.username)||"Unknown";async function _t(l,h){try{await Oe.mutateAsync({id:l,status:h,performedBy:Se}),le(`${l} → ${B(h)}`)}catch{}}async function At(l,h){tt(null);try{await ze.mutateAsync({id:l,data:{assignedTo:h,performedBy:Se}}),le(h?`${l} assigned to ${h}`:`${l} unassigned`)}catch{}}async function Ht(l){try{await $.mutateAsync({title:`Copy of ${l.title}`,description:l.description||"",priority:l.priority||"p3",severity:l.severity||"major",expectedResult:l.expectedResult||"",actualResult:l.actualResult||"",stepsToReproduce:l.stepsToReproduce||"",environment:l.environment||"",assignedTo:l.assignedTo||"",reporter:Se,tags:l.tags||"",testCaseId:l.testCaseId||""}),le("Defect duplicated")}catch{}}async function St(l){const h=Array.from(Te);try{await Promise.all(h.map(S=>ze.mutateAsync({id:S,data:{assignedTo:l,performedBy:Se}}))),le(l?`${h.length} assigned to ${l}`:`${h.length} unassigned`),Me(new Set)}catch{}}async function Ct(l){const h=Array.from(Te);try{await Promise.all(h.map(S=>Oe.mutateAsync({id:S,status:l,performedBy:Se}))),le(`${h.length} moved to ${B(l)}`),Me(new Set)}catch{}}async function Fe(l){const h=Array.from(Te);try{await Promise.all(h.map(S=>ze.mutateAsync({id:S,data:{priority:l,performedBy:Se}}))),le(`${h.length} set to ${dt[l]||l}`),Me(new Set)}catch{}}function Ge(){const l=Array.from(Te);O({title:`Delete ${l.length} Defect${l.length===1?"":"s"}`,message:"Are you sure you want to delete the selected defects? This action cannot be undone.",onConfirm:async()=>{O(null);try{await Promise.all(l.map(h=>ye.mutateAsync(h))),le(`${l.length} defect${l.length===1?"":"s"} deleted`),Me(new Set)}catch{}}})}function $e(l,h){l.dataTransfer.setData("text/plain",h.id),l.dataTransfer.effectAllowed="move"}function kt(l,h){l.preventDefault(),l.dataTransfer.dropEffect="move",st!==h&&wt(h)}function Et(l){const h=l.relatedTarget;(!h||!l.currentTarget.contains(h))&&wt(null)}function Dt(l,h){l.preventDefault(),wt(null);const S=l.dataTransfer.getData("text/plain");if(!S)return;const G=Ue.find(C=>C.id===S);G&&G.status!==h&&_t(S,h)}function Rt(){Q({status:null,severity:null,priority:null,assignee:null,overdue:null,search:null})}function Ot(l){p===l?y():f(l)}return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:pt()}),H&&e.jsx(ga,{defect:_,onSave:We,onClose:()=>{j(!1),T(null)},saving:$.isPending||ze.isPending,currentUserName:ve}),de&&e.jsx(Ur,{title:de.title,message:de.message,onConfirm:de.onConfirm,onCancel:()=>O(null)}),Ie&&e.jsx(ya,{defect:Ie,onClose:()=>Q({defectId:null}),onEdit:()=>{mt(Ie)},onDuplicate:()=>{Ht(Ie)},onDelete:()=>{ot(Ie.id),Q({defectId:null})},onTransition:async l=>{try{await Oe.mutateAsync({id:Ie.id,status:l,performedBy:ve||"System"}),le(`Defect transitioned to ${B(l)}`)}catch{}},transitioning:Oe.isPending})]});function pt(){var Ce;const l=[{value:"oldest",label:"Oldest first"},{value:"newest",label:"Newest first"},{value:"priority",label:"Priority"},{value:"severity",label:"Severity"},{value:"due",label:"Due date"}],h=((Ce=l.find(a=>a.value===be))==null?void 0:Ce.label)||"Oldest first",S=a=>e.jsxs("button",{onClick:a.onClick,className:`relative text-left bg-surface-1 border rounded-xl px-4 py-3 transition-colors ${a.active?"border-brand-500 ring-1 ring-inset ring-brand-500":"border-white/10 hover:border-gray-400/40"}`,children:[a.active&&e.jsx("span",{className:"absolute top-2 right-2.5 text-[9px] font-bold uppercase tracking-wide bg-brand-600 text-white px-1.5 py-0.5 rounded-full",children:"filtering"}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${a.dot}`}),a.label]}),e.jsx("span",{className:`block text-2xl font-bold mt-0.5 ${a.valueCls||"text-gray-100"}`,children:a.value}),e.jsx("span",{className:"block text-[11px] text-gray-500 mt-0.5",children:a.delta})]}),G=Math.max(1,I.total),C=!!(p||b||Y||z||m),P=[{status:"open",collapsed:!1},{status:"in_progress",collapsed:!1},{status:"resolved",collapsed:!1},{status:"closed",collapsed:!et.closed},{status:"rejected",collapsed:!et.rejected}],lt=P.map(a=>a.collapsed?"44px":"1fr").join(" "),Ye={open:{dot:"bg-red-400",head:"from-red-500/10",cnt:"bg-red-500/15 text-red-400"},in_progress:{dot:"bg-blue-400",head:"from-blue-500/10",cnt:"bg-blue-500/15 text-blue-400"},resolved:{dot:"bg-emerald-400",head:"from-emerald-500/10",cnt:"bg-emerald-500/15 text-emerald-400"},closed:{dot:"bg-gray-400",head:"from-gray-500/10",cnt:"bg-gray-500/15 text-gray-400"},rejected:{dot:"bg-slate-400",head:"from-slate-500/10",cnt:"bg-slate-500/15 text-slate-400"}},xt=a=>{const te=ws(a),x=Jt(a),ce=es[a.status],q=a.status==="resolved"||a.status==="closed"||a.status==="rejected";return e.jsxs("div",{draggable:!0,onDragStart:w=>$e(w,a),onClick:()=>Q({defectId:a.id}),className:`group relative bg-surface-1 border border-white/10 rounded-xl px-3 py-2.5 cursor-grab active:cursor-grabbing transition-all hover:border-gray-400/40 hover:shadow-md hover:shadow-black/10 hover:-translate-y-px ${q?"opacity-85":""} ${Re===a.id?"z-40":""}`,children:[e.jsxs("div",{"data-assign-root":!0,className:"absolute top-1.5 right-1.5 hidden group-hover:flex items-center gap-0.5 bg-surface-1 border border-white/10 rounded-lg p-0.5 shadow-lg z-10",onClick:w=>w.stopPropagation(),children:[e.jsx("button",{title:"Assign",onClick:()=>tt(Re===a.id?null:a.id),className:"w-6 h-6 flex items-center justify-center rounded-md text-gray-400 hover:text-gray-200 hover:bg-white/10",children:e.jsx(_r,{size:12})}),ce&&e.jsx("button",{title:`Move to ${B(ce)}`,onClick:()=>_t(a.id,ce),className:"w-6 h-6 flex items-center justify-center rounded-md text-gray-400 hover:text-gray-200 hover:bg-white/10",children:e.jsx(As,{size:12})}),e.jsx("button",{title:"Open",onClick:()=>Q({defectId:a.id}),className:"w-6 h-6 flex items-center justify-center rounded-md text-gray-400 hover:text-gray-200 hover:bg-white/10",children:e.jsx(qt,{size:12})})]}),Re===a.id&&e.jsx(e.Fragment,{children:e.jsxs("div",{"data-assign-root":!0,className:"absolute top-8 right-1.5 z-30 w-44 max-h-52 overflow-y-auto bg-surface-1 border border-white/10 rounded-lg shadow-xl py-1",onClick:w=>w.stopPropagation(),children:[e.jsx("button",{onClick:()=>At(a.id,""),className:"w-full text-left px-3 py-1.5 text-xs text-gray-400 hover:bg-white/5",children:"Unassigned"}),Ae.map(w=>e.jsxs("button",{onClick:()=>At(a.id,w),className:"w-full text-left px-3 py-1.5 text-xs text-gray-200 hover:bg-white/5 flex items-center gap-2",children:[e.jsx("span",{className:`w-4 h-4 rounded-full ${Mr(w)} text-white text-[8px] font-bold flex items-center justify-center`,children:Pr(w)}),e.jsx("span",{className:"truncate",children:w})]},w))]})}),e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1.5",children:[e.jsx("p",{className:"text-[13px] font-normal text-gray-200 leading-snug line-clamp-2",children:a.title}),e.jsx("span",{className:"text-[11px] font-mono text-gray-500 shrink-0",children:a.id})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap mb-2",children:[e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${Ds[a.priority]||"bg-gray-500/15 text-gray-400"}`,title:dt[a.priority],children:Zt[a.priority]||"P3"}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded-md border bg-transparent ${a.severity==="blocker"?"border-red-600 text-red-400 font-semibold":a.severity==="critical"?"border-red-400/60 text-red-400":a.severity==="major"?"border-orange-400/60 text-orange-500 dark:text-orange-400":a.severity==="minor"?"border-amber-400/60 text-amber-400":"border-gray-400/50 text-gray-400"}`,children:B(a.severity||"unknown")}),a.testCaseId&&e.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-surface-2 text-gray-500",children:a.testCaseId}),a.externalId&&e.jsx(Rs,{externalId:a.externalId}),x&&e.jsxs("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded-md bg-red-500/15 text-red-400 flex items-center gap-1",children:[e.jsx(Ar,{size:9})," overdue"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-1.5 border-t border-white/[0.06]",children:[e.jsx(gr,{name:a.assignedTo}),e.jsxs("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${hr(te)}`,children:[te,"d"]})]})]},a.id)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-brand-600 text-white flex items-center justify-center",children:e.jsx(Ts,{size:18})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-gray-100 leading-tight",children:"Defects"}),e.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-2",children:[I.activeCount," active · ",I.resolvedThisWeek," resolved this week",I.netThisWeek!==0&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-semibold px-2 py-0.5 rounded-full ${I.netThisWeek<0?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:[I.netThisWeek<0?"▼":"▲"," ",Math.abs(I.netThisWeek)," net this week"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{type:"defect-report",formats:["docx","xlsx","csv"],label:"Export"}),e.jsxs("button",{onClick:it,className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium flex items-center gap-2 transition-colors",children:[e.jsx(wr,{size:16})," New Defect"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-[repeat(5,1fr)_1.6fr] gap-2.5",children:[S({label:"Total",value:I.total,dot:"bg-gray-500",delta:"all time",active:!1,onClick:Rt}),S({label:"Open",value:I.open,dot:"bg-red-400",delta:I.openNewThisWeek?`+${I.openNewThisWeek} this week`:"none new this week",active:p==="open",onClick:()=>Ot("open"),valueCls:"text-red-400"}),S({label:"In Progress",value:I.inProgress,dot:"bg-blue-400",delta:`${I.inProgressAssigned} assigned`,active:p==="in_progress",onClick:()=>Ot("in_progress"),valueCls:"text-blue-400"}),S({label:"Blockers",value:I.blockers,dot:"bg-red-700",delta:I.blockersUnassigned?"needs triage":I.blockers?"all assigned":"—",active:b==="blocker",onClick:()=>b==="blocker"?R():g("blocker"),valueCls:"text-red-500"}),S({label:"Overdue",value:I.overdue,dot:"bg-amber-400",delta:I.overdue?`oldest ${I.overdueOldest}d`:"—",active:!!m,onClick:()=>m?ie():A("1"),valueCls:"text-amber-400"}),e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl px-4 py-3 col-span-2 md:col-span-3 xl:col-span-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-semibold uppercase tracking-wide text-gray-500 mb-2",children:[e.jsx("span",{children:"Severity mix"}),e.jsxs("span",{className:"normal-case font-normal",children:["avg resolution ",e.jsx("b",{className:"font-semibold text-gray-100",children:I.avgResolutionDays!=null?`${I.avgResolutionDays.toFixed(1)}d`:"—"})]})]}),e.jsx("div",{className:"flex h-2.5 rounded-md overflow-hidden mb-2 bg-surface-2",children:yt.map(a=>(I.sevMix[a]||0)>0&&e.jsx("span",{className:pr[a],style:{width:`${I.sevMix[a]/G*100}%`},title:`${B(a)}: ${I.sevMix[a]}`},a))}),e.jsx("div",{className:"flex items-center gap-3 flex-wrap text-[10.5px] text-gray-500",children:yt.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${pr[a]}`}),e.jsx("b",{className:"font-semibold text-gray-300",children:I.sevMix[a]||0})," ",a]},a))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px] max-w-sm",children:[e.jsx(Tr,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search defects...",value:s||"",onChange:a=>ss(a.target.value),className:"w-full bg-surface-1 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"})]}),e.jsx($t,{label:"Status",value:p||"",display:B(p||""),options:Es.map(a=>({value:a,label:B(a)})),onChange:f,onClear:y}),e.jsx($t,{label:"Severity",value:b||"",display:B(b||""),options:Lr.map(a=>({value:a,label:B(a)})),onChange:g,onClear:R}),e.jsx($t,{label:"Priority",value:Y||"",display:Zt[Y||""]||"",options:Qt.map(a=>({value:a,label:dt[a]})),onChange:d,onClear:D}),e.jsx($t,{label:"Assignee",value:z||"",display:z==="__unassigned__"?"Unassigned":z||"",options:[{value:"__unassigned__",label:"Unassigned"},...Ae.map(a=>({value:a,label:a}))],onChange:me,onClear:Ee}),e.jsx($t,{label:"Sort",value:pe||"",display:h,options:l,onChange:Pe,onClear:Ze}),C&&e.jsx("button",{onClick:Rt,className:"text-xs text-gray-500 hover:text-gray-300 underline underline-offset-2",children:"Clear all"}),e.jsxs("div",{className:"ml-auto flex items-center bg-surface-2 border border-white/10 rounded-lg p-0.5",children:[e.jsxs("button",{onClick:()=>X("board"),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${J==="board"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(wn,{size:14})," Board"]}),e.jsxs("button",{onClick:()=>X("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${J==="table"?"bg-brand-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(Tn,{size:14})," List"]})]})]}),Bt?e.jsx(fa,{message:"Loading defects..."}):oe.length===0?e.jsx(ha,{icon:e.jsx(Ts,{size:40,className:"text-gray-600"}),title:"No defects found",subtitle:"Create a defect or adjust your filters"}):J==="board"?e.jsx("div",{className:"grid gap-3 items-start",style:{gridTemplateColumns:lt},children:P.map(({status:a,collapsed:te})=>{const x=Ye[a],ce=oe.filter(w=>w.status===a),q=yt.filter(w=>ce.some(It=>It.severity===w)).slice(0,3);return te?e.jsxs("div",{onClick:()=>De(w=>({...w,[a]:!0})),onDragOver:w=>kt(w,a),onDragLeave:Et,onDrop:w=>Dt(w,a),className:`rounded-xl border bg-surface-1/50 min-h-[420px] flex flex-col items-center pt-3 gap-2.5 cursor-pointer transition-colors ${st===a?"border-brand-500":"border-white/10 hover:border-gray-400/40"}`,title:`Expand ${B(a)}`,children:[e.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded-full ${x.cnt}`,children:ce.length}),e.jsx("span",{className:"text-[10.5px] font-bold tracking-widest uppercase text-gray-500",style:{writingMode:"vertical-rl"},children:B(a)})]},a):e.jsxs("div",{onDragOver:w=>kt(w,a),onDragLeave:Et,onDrop:w=>Dt(w,a),className:`rounded-xl border bg-surface-1/50 flex flex-col min-h-[420px] transition-colors ${st===a?"border-brand-500 ring-1 ring-inset ring-brand-500":"border-white/10"}`,children:[e.jsxs("div",{className:`px-3.5 py-2.5 bg-gradient-to-b ${x.head} to-transparent rounded-t-xl border-b border-white/5 flex items-center justify-between`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${x.dot}`}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-gray-200",children:B(a)}),(a==="closed"||a==="rejected")&&e.jsx("button",{onClick:()=>De(w=>({...w,[a]:!1})),className:"text-gray-500 hover:text-gray-300",title:"Collapse column",children:e.jsx(_n,{size:12})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[q.length>0&&e.jsx("span",{className:"flex gap-1",children:q.map(w=>e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${fr[w]}`,title:B(w)},w))}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full ${x.cnt}`,children:ce.length})]})]}),e.jsxs("div",{className:"p-2 space-y-2 flex-1 overflow-y-auto max-h-[640px]",children:[ce.map(xt),ce.length===0&&st!==a&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-gray-600",children:[e.jsx(An,{size:16,className:"mb-1.5"}),e.jsx("span",{className:"text-[11px]",children:"No defects"})]}),st===a&&e.jsxs("div",{className:"pointer-events-none border-2 border-dashed border-gray-400/60 rounded-xl py-4 text-center text-xs font-semibold text-gray-500 bg-surface-2/50",children:["Drop to move to ",B(a)]}),a==="open"&&e.jsx("button",{onClick:it,className:"w-full border-[1.5px] border-dashed border-gray-400/30 rounded-lg py-1.5 text-xs text-gray-500 hover:text-gray-300 hover:border-gray-400/60 transition-colors",children:"+ Add defect"})]})]},a)})}):e.jsxs("div",{className:"space-y-2.5",children:[Te.size>0&&e.jsxs("div",{className:"flex items-center gap-2.5 bg-brand-700 text-white rounded-xl px-4 py-2 text-xs",children:[e.jsxs("b",{className:"font-semibold",children:[Te.size," selected"]}),e.jsx("span",{className:"opacity-40",children:"·"}),e.jsxs("select",{defaultValue:"",onChange:a=>{a.target.value&&(St(a.target.value==="__unassigned__"?"":a.target.value),a.target.value="")},className:"bg-brand-600 border border-brand-500 text-white rounded-md px-2 py-1 text-xs cursor-pointer",style:{colorScheme:"dark"},children:[e.jsx("option",{value:"",disabled:!0,children:"Assign…"}),e.jsx("option",{value:"__unassigned__",children:"Unassigned"}),Ae.map(a=>e.jsx("option",{value:a,children:a},a))]}),e.jsxs("select",{defaultValue:"",onChange:a=>{a.target.value&&(Ct(a.target.value),a.target.value="")},className:"bg-brand-600 border border-brand-500 text-white rounded-md px-2 py-1 text-xs cursor-pointer",style:{colorScheme:"dark"},children:[e.jsx("option",{value:"",disabled:!0,children:"Set status…"}),Es.map(a=>e.jsx("option",{value:a,children:B(a)},a))]}),e.jsxs("select",{defaultValue:"",onChange:a=>{a.target.value&&(Fe(a.target.value),a.target.value="")},className:"bg-brand-600 border border-brand-500 text-white rounded-md px-2 py-1 text-xs cursor-pointer",style:{colorScheme:"dark"},children:[e.jsx("option",{value:"",disabled:!0,children:"Set priority…"}),Qt.map(a=>e.jsx("option",{value:a,children:dt[a]},a))]}),e.jsx("button",{onClick:Ge,className:"text-red-300 hover:underline",children:"Delete"}),e.jsxs("button",{onClick:()=>Me(new Set),className:"ml-auto opacity-70 hover:opacity-100 flex items-center gap-1",children:[e.jsx(Qe,{size:12})," Clear"]})]}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left text-gray-400 text-xs uppercase tracking-wide",children:[e.jsx("th",{className:"px-3 py-2.5 w-9",children:e.jsx("input",{type:"checkbox",checked:oe.length>0&&oe.every(a=>Te.has(a.id)),onChange:a=>Me(a.target.checked?new Set(oe.map(te=>te.id)):new Set),className:"accent-brand-600 cursor-pointer"})}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-16",children:"ID"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold",children:"Title"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-20",children:"Priority"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-28",children:"Status"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-36",children:"Assignee"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-24",children:"Linked TC"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-24",children:"Due"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-16",children:"Age"}),e.jsx("th",{className:"px-3 py-2.5 font-semibold w-16"})]})}),e.jsx("tbody",{children:yt.map(a=>{const te=oe.filter(x=>x.severity===a);return te.length===0?null:e.jsxs(He.Fragment,{children:[e.jsx("tr",{className:"bg-surface-2/60",children:e.jsxs("td",{colSpan:10,className:"px-3 py-1.5 text-[10.5px] font-bold uppercase tracking-widest text-gray-300",children:[e.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full mr-2 ${fr[a]}`}),B(a)," — ",te.length]})}),te.map(x=>{const ce=ws(x),q=Jt(x);return e.jsxs("tr",{className:"border-b border-white/5 hover:bg-white/[0.03] transition-colors cursor-pointer",onClick:()=>Q({defectId:x.id}),children:[e.jsx("td",{className:"px-3 py-2.5",onClick:w=>w.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:Te.has(x.id),onChange:w=>Me(It=>{const ft=new Set(It);return w.target.checked?ft.add(x.id):ft.delete(x.id),ft}),className:"accent-brand-600 cursor-pointer"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:"text-xs font-mono text-gray-500",children:x.id})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-gray-200 font-medium text-[13px] leading-snug",children:x.title}),(x.testCaseTitle||x.environment)&&e.jsx("span",{className:"text-[11px] text-gray-500 truncate max-w-md",children:[x.testCaseTitle,x.environment].filter(Boolean).join(" · ")})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${Ds[x.priority]||"bg-gray-500/15 text-gray-400"}`,title:dt[x.priority],children:Zt[x.priority]||"P3"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${pa[x.status]||"bg-gray-500/20 text-gray-400"}`,children:B(x.status||"unknown")}),x.externalId&&e.jsx(Rs,{externalId:x.externalId})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx(gr,{name:x.assignedTo})}),e.jsx("td",{className:"px-3 py-2.5",children:x.testCaseId?e.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-md bg-surface-2 text-gray-500",children:x.testCaseId}):e.jsx("span",{className:"text-gray-600 text-xs",children:"—"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:`text-xs ${q?"text-red-400 font-semibold":"text-gray-400"}`,children:x.dueDate?zr(x.dueDate):"—"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${hr(ce)}`,children:[ce,"d"]})}),e.jsx("td",{className:"px-3 py-2.5",onClick:w=>w.stopPropagation(),children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>mt(x),className:"p-1 text-gray-400 hover:text-gray-200 transition-colors",title:"Edit",children:e.jsx(_s,{size:14})}),e.jsx("button",{onClick:()=>ot(x.id),className:"p-1 text-gray-400 hover:text-red-400 transition-colors",title:"Delete",children:e.jsx(Xt,{size:14})})]})})]},x.id)})]},a)})})]})})]})]})}}function fa({message:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-gray-400",children:[e.jsx(Nt,{size:32,className:"animate-spin mb-3 text-brand-300"}),e.jsx("span",{className:"text-sm",children:s})]})}function ha({icon:s,title:n,subtitle:u}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s,e.jsx("h3",{className:"text-sm font-medium text-gray-300 mt-3",children:n}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:u})]})}function ga({defect:s,onSave:n,onClose:u,saving:p,currentUserName:f}){const{data:y}=pn({limit:5e3}),b=Array.isArray(y)?y:(y==null?void 0:y.testCases)??[],[g,R]=M.useState(()=>({...s?{title:s.title||"",description:s.description||"",priority:s.priority||"p3",severity:s.severity||"major",status:s.status||"open",expectedResult:s.expectedResult||"",actualResult:s.actualResult||"",stepsToReproduce:s.stepsToReproduce||"",environment:s.environment||"",assignedTo:s.assignedTo||"",reporter:s.reporter||f||"",dueDate:s.dueDate?new Date(s.dueDate).toISOString().split("T")[0]:"",tags:s.tags?Array.isArray(s.tags)?s.tags.join(", "):s.tags:"",externalId:s.externalId||"",externalUrl:s.externalUrl||"",testCaseId:s.testCaseId||""}:{...xa(),reporter:f||""},attachments:s!=null&&s.attachments?typeof s.attachments=="string"?(()=>{try{return JSON.parse(s.attachments)}catch{return[]}})():s.attachments:[],referenceLinks:s!=null&&s.referenceLinks?typeof s.referenceLinks=="string"?(()=>{try{return JSON.parse(s.referenceLinks)}catch{return[]}})():s.referenceLinks:[]})),[H,j]=M.useState(""),[_,T]=M.useState(""),E=(d,D)=>R(z=>({...z,[d]:D})),F="w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50",J=d=>{const D=d.target.files;if(D){for(const z of Array.from(D)){if(z.size>10*1024*1024)continue;const me=new FileReader;me.onload=()=>{const Ee=me.result.split(",")[1]||"";R(m=>({...m,attachments:[...m.attachments,{fileName:z.name,fileType:z.type,fileSize:z.size,fileData:Ee}]}))},me.readAsDataURL(z)}d.target.value=""}},X=d=>{R(D=>({...D,attachments:D.attachments.filter((z,me)=>me!==d)}))},K=()=>{_.trim()&&(R(d=>({...d,referenceLinks:[...d.referenceLinks,{title:H.trim()||_.trim(),url:_.trim()}]})),j(""),T(""))},Q=d=>{R(D=>({...D,referenceLinks:D.referenceLinks.filter((z,me)=>me!==d)}))},de=d=>d<1024?`${d} B`:d<1024*1024?`${(d/1024).toFixed(1)} KB`:`${(d/(1024*1024)).toFixed(1)} MB`,O=He.useMemo(()=>He.lazy(()=>sn(()=>import("./vendor-quill-xJF2Jvjc.js"),__vite__mapDeps([0,1,2]))),[]),Y=He.useMemo(()=>({toolbar:[[{header:[1,2,3,!1]}],["bold","italic","underline","strike"],[{list:"ordered"},{list:"bullet"}],["code-block","blockquote"],["link","image"],["clean"]]}),[]);return e.jsx(va,{onClose:u,children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 w-full max-w-6xl max-h-[90vh] overflow-y-auto shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-white/5",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ts,{size:20,className:"text-brand-300"}),s?"Edit Defect":"New Defect"]}),e.jsx("button",{onClick:u,className:"p-1 text-gray-400 hover:text-gray-200 transition-colors",children:e.jsx(Qe,{size:20})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsx(se,{label:"Title *",children:e.jsx("input",{type:"text",value:g.title,onChange:d=>E("title",d.target.value),placeholder:"Defect title",className:F})}),e.jsx(se,{label:"Description",children:e.jsx("textarea",{value:g.description,onChange:d=>E("description",d.target.value),rows:3,placeholder:"Describe the defect...",className:`${F} resize-y`})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(se,{label:"Priority",children:e.jsx("select",{value:g.priority,onChange:d=>E("priority",d.target.value),className:F,children:Qt.map(d=>e.jsx("option",{value:d,children:dt[d]},d))})}),e.jsx(se,{label:"Severity",children:e.jsx("select",{value:g.severity,onChange:d=>E("severity",d.target.value),className:F,children:Lr.map(d=>e.jsx("option",{value:d,children:B(d)},d))})}),e.jsx(se,{label:"Status",children:e.jsx("select",{value:g.status,onChange:d=>E("status",d.target.value),className:F,children:Es.map(d=>e.jsx("option",{value:d,children:B(d)},d))})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"Expected Result",children:e.jsx("textarea",{value:g.expectedResult,onChange:d=>E("expectedResult",d.target.value),rows:2,placeholder:"What should happen...",className:`${F} resize-y`})}),e.jsx(se,{label:"Actual Result",children:e.jsx("textarea",{value:g.actualResult,onChange:d=>E("actualResult",d.target.value),rows:2,placeholder:"What actually happens...",className:`${F} resize-y`})})]}),e.jsx(se,{label:"Steps to Reproduce",children:e.jsx(He.Suspense,{fallback:e.jsx("textarea",{value:g.stepsToReproduce,onChange:d=>E("stepsToReproduce",d.target.value),rows:4,placeholder:`1. Navigate to...
5
+ 2. Click on...
6
+ 3. Observe that...`,className:`${F} resize-y font-mono`}),children:e.jsxs("div",{className:"defect-quill-editor",children:[e.jsx("style",{children:`
7
+ .defect-quill-editor .ql-toolbar { background: var(--surface-2, #1e1e2e); border-color: rgba(255,255,255,0.1) !important; border-radius: 0.5rem 0.5rem 0 0; }
8
+ .defect-quill-editor .ql-toolbar button { color: #9ca3af !important; }
9
+ .defect-quill-editor .ql-toolbar button:hover { color: #e5e7eb !important; }
10
+ .defect-quill-editor .ql-toolbar .ql-stroke { stroke: #9ca3af !important; }
11
+ .defect-quill-editor .ql-toolbar .ql-fill { fill: #9ca3af !important; }
12
+ .defect-quill-editor .ql-toolbar button:hover .ql-stroke { stroke: #e5e7eb !important; }
13
+ .defect-quill-editor .ql-toolbar button:hover .ql-fill { fill: #e5e7eb !important; }
14
+ .defect-quill-editor .ql-toolbar .ql-picker-label { color: #9ca3af !important; }
15
+ .defect-quill-editor .ql-toolbar .ql-picker-options { background: var(--surface-2, #1e1e2e) !important; border-color: rgba(255,255,255,0.1) !important; }
16
+ .defect-quill-editor .ql-toolbar .ql-picker-item { color: #d1d5db !important; }
17
+ .defect-quill-editor .ql-container { background: var(--surface-2, #1e1e2e); border-color: rgba(255,255,255,0.1) !important; border-radius: 0 0 0.5rem 0.5rem; min-height: 120px; color: var(--text-primary, #e5e7eb); font-size: 0.875rem; }
18
+ .defect-quill-editor .ql-editor { min-height: 120px; color: var(--text-primary, #e5e7eb); }
19
+ .defect-quill-editor .ql-editor.ql-blank::before { color: #6b7280 !important; font-style: normal !important; }
20
+ .light .defect-quill-editor .ql-container,
21
+ .light .defect-quill-editor .ql-editor { color: #1f2937 !important; background: #f9fafb !important; }
22
+ .light .defect-quill-editor .ql-toolbar { background: #f3f4f6 !important; border-color: #d1d5db !important; }
23
+ .light .defect-quill-editor .ql-toolbar button { color: #374151 !important; }
24
+ .light .defect-quill-editor .ql-toolbar .ql-stroke { stroke: #374151 !important; }
25
+ .light .defect-quill-editor .ql-toolbar .ql-fill { fill: #374151 !important; }
26
+ .light .defect-quill-editor .ql-toolbar .ql-picker-label { color: #374151 !important; }
27
+ .light .defect-quill-editor .ql-toolbar .ql-picker-options { background: #f9fafb !important; border-color: #d1d5db !important; }
28
+ .light .defect-quill-editor .ql-container { background: #f9fafb !important; border-color: #d1d5db !important; }
29
+ .light .defect-quill-editor .ql-editor.ql-blank::before { color: #9ca3af !important; }
30
+ .defect-quill-editor .ql-editor pre.ql-syntax { background: rgba(0,0,0,0.3) !important; color: #e5e7eb !important; border-radius: 0.375rem; }
31
+ .defect-quill-editor .ql-editor blockquote { border-left: 3px solid rgba(139,92,246,0.5); color: #d1d5db; }
32
+ .defect-quill-editor .ql-snow .ql-tooltip { background: var(--surface-1, #161625) !important; border-color: rgba(255,255,255,0.1) !important; color: #e5e7eb !important; }
33
+ /* Long-text wrapping. Quill's default rules don't
34
+ break unbreakable strings (long URLs, stack traces),
35
+ so a single long line forces the editor to scroll
36
+ horizontally. Force wrap on every block. */
37
+ .defect-quill-editor .ql-container { overflow-x: hidden; }
38
+ .defect-quill-editor .ql-editor,
39
+ .defect-quill-editor .ql-editor p,
40
+ .defect-quill-editor .ql-editor li,
41
+ .defect-quill-editor .ql-editor h1,
42
+ .defect-quill-editor .ql-editor h2,
43
+ .defect-quill-editor .ql-editor h3 {
44
+ word-break: break-word;
45
+ overflow-wrap: anywhere;
46
+ white-space: normal;
47
+ }
48
+ /* Step-heading spacing. Generated defects use <h3>
49
+ for the "Step N — status" line; Quill preserves
50
+ <h3> through edits but its default top-margin is 0.
51
+ Restore one so each step block reads as a distinct
52
+ unit even after the user reformats. */
53
+ .defect-quill-editor .ql-editor h3 {
54
+ margin-top: 1.1em;
55
+ margin-bottom: 0.35em;
56
+ font-size: 1rem;
57
+ font-weight: 700;
58
+ }
59
+ .defect-quill-editor .ql-editor h3:first-child {
60
+ margin-top: 0.25em;
61
+ }
62
+ /* Slight bottom-margin on paragraphs so consecutive
63
+ "Action / Expected / Actual" lines breathe a little
64
+ instead of stacking edge-to-edge. */
65
+ .defect-quill-editor .ql-editor p {
66
+ margin: 0 0 0.25em 0;
67
+ }
68
+ `}),e.jsx(O,{theme:"snow",value:g.stepsToReproduce,onChange:d=>E("stepsToReproduce",d),modules:Y,placeholder:`1. Navigate to...
69
+ 2. Click on...
70
+ 3. Observe that...`})]})})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"Environment",children:e.jsx("input",{type:"text",value:g.environment,onChange:d=>E("environment",d.target.value),placeholder:"e.g., Chrome 120, Windows 11",className:F})}),e.jsx(se,{label:"Assigned To",children:e.jsx(ja,{value:g.assignedTo,onChange:d=>E("assignedTo",d),inputCls:F})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"Reporter",children:e.jsx("input",{type:"text",value:g.reporter,onChange:d=>E("reporter",d.target.value),placeholder:"Reporter name",className:F})}),e.jsx(se,{label:"Due Date",children:e.jsx("input",{type:"date",value:g.dueDate,onChange:d=>E("dueDate",d.target.value),className:F})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"Tags",children:e.jsx("input",{type:"text",value:g.tags,onChange:d=>E("tags",d.target.value),placeholder:"Comma-separated tags",className:F})}),e.jsx(se,{label:"Linked Test Case",children:e.jsx(ba,{testCases:b,value:g.testCaseId,onChange:d=>E("testCaseId",d),inputCls:F})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(se,{label:"External ID",children:e.jsx("input",{type:"text",value:g.externalId,onChange:d=>E("externalId",d.target.value),placeholder:"e.g., JIRA-1234",className:F})}),e.jsx(se,{label:"External URL",children:e.jsx("input",{type:"text",value:g.externalUrl,onChange:d=>E("externalUrl",d.target.value),placeholder:"https://...",className:F})})]}),e.jsx(se,{label:"Attachments",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 px-4 py-2 bg-surface-2 border border-dashed border-white/20 rounded-lg cursor-pointer hover:border-brand-500/50 transition-colors text-sm text-gray-400",children:[e.jsx(Sn,{size:16}),e.jsx("span",{children:"Upload screenshots, documents, or files (max 10MB each)"}),e.jsx("input",{type:"file",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.txt,.log,.har,.json,.xml,.csv",onChange:J,className:"hidden"})]}),g.attachments.length>0&&e.jsx("div",{className:"space-y-1",children:g.attachments.map((d,D)=>{var z;return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-surface-2 rounded-lg border border-white/5",children:[(z=d.fileType)!=null&&z.startsWith("image/")?e.jsx("img",{src:`data:${d.fileType};base64,${d.fileData}`,alt:d.fileName,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-surface-0 flex items-center justify-center",children:e.jsx(Ss,{size:16,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:d.fileName}),e.jsx("p",{className:"text-xs text-gray-500",children:de(d.fileSize)})]}),e.jsx("button",{onClick:()=>X(D),className:"p-1 text-gray-400 hover:text-red-400 transition-colors",children:e.jsx(Qe,{size:14})})]},D)})})]})}),e.jsx(se,{label:"Reference Links",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:H,onChange:d=>j(d.target.value),placeholder:"Link title (optional)",className:`${F} flex-1`}),e.jsx("input",{type:"text",value:_,onChange:d=>T(d.target.value),placeholder:"https://...",className:`${F} flex-[2]`,onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),K())}}),e.jsxs("button",{onClick:K,disabled:!_.trim(),className:"px-3 py-2 bg-brand-600 hover:bg-brand-500 text-white rounded-lg text-sm font-medium transition-colors disabled:opacity-50 flex items-center gap-1 whitespace-nowrap",children:[e.jsx(wr,{size:14})," Add"]})]}),g.referenceLinks.length>0&&e.jsx("div",{className:"space-y-1",children:g.referenceLinks.map((d,D)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-surface-2 rounded-lg border border-white/5",children:[e.jsx(qt,{size:14,className:"text-brand-300 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:d.title||d.url}),e.jsx("p",{className:"text-xs text-gray-500 truncate",children:d.url})]}),e.jsx("button",{onClick:()=>Q(D),className:"p-1 text-gray-400 hover:text-red-400 transition-colors",children:e.jsx(Qe,{size:14})})]},D))})]})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:u,className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsxs("button",{onClick:()=>{const d={...g,attachments:JSON.stringify(g.attachments),referenceLinks:JSON.stringify(g.referenceLinks)};n(d)},disabled:p||!g.title.trim(),className:"bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium flex items-center gap-2 transition-colors disabled:opacity-50",children:[p?e.jsx(Nt,{size:16,className:"animate-spin"}):e.jsx(Cn,{size:16}),s?"Update":"Create"]})]})]})})}function ba({testCases:s,value:n,onChange:u,inputCls:p}){const[f,y]=M.useState(""),[b,g]=M.useState(!1),R=He.useRef(null),H=s.filter(T=>{if(!f.trim())return!0;const E=f.toLowerCase();return(T.title||"").toLowerCase().includes(E)||(T.id||"").toLowerCase().includes(E)}),j=s.find(T=>T.id===n),_=j?j.title||j.id:n;return He.useEffect(()=>{const T=E=>{R.current&&!R.current.contains(E.target)&&g(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),e.jsxs("div",{className:"relative",ref:R,children:[e.jsxs("div",{className:`${p} cursor-pointer flex items-center justify-between`,onClick:()=>g(!b),children:[e.jsx("span",{className:n?"text-gray-200":"text-gray-500",children:n?_:"Select test case..."}),e.jsx(Cr,{size:14,className:"text-gray-400 shrink-0"})]}),b&&e.jsxs("div",{className:"absolute z-[70] top-full left-0 right-0 mt-1 bg-surface-1 border border-white/10 rounded-lg shadow-xl max-h-64 overflow-hidden flex flex-col",children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsxs("div",{className:"relative",children:[e.jsx(Tr,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:f,onChange:T=>y(T.target.value),placeholder:"Search test cases...",className:`${p} pl-8 py-1.5 text-xs`,autoFocus:!0,onClick:T=>T.stopPropagation()})]})}),e.jsxs("div",{className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:"px-3 py-2 text-sm text-gray-400 hover:bg-white/5 cursor-pointer",onClick:()=>{u(""),g(!1),y("")},children:"None"}),H.length===0?e.jsx("div",{className:"px-3 py-4 text-xs text-gray-500 text-center",children:"No test cases found"}):H.map(T=>e.jsxs("div",{className:`px-3 py-2 text-sm cursor-pointer hover:bg-white/5 flex items-center gap-2 ${T.id===n?"bg-brand-600/10 text-brand-300":"text-gray-200"}`,onClick:()=>{u(T.id),g(!1),y("")},children:[e.jsx("span",{className:"truncate",children:T.title||T.id}),e.jsxs("span",{className:"text-xs text-gray-500 shrink-0 font-mono",children:["#",T.id]})]},T.id))]})]})]})}function ya({defect:s,onClose:n,onEdit:u,onDuplicate:p,onDelete:f,onTransition:y,transitioning:b}){const[g,R]=M.useState("details"),[H,j]=M.useState(""),[_,T]=M.useState(null),[E,F]=M.useState(null),{user:J}=yr(),{data:X}=xn(s.id),{data:K}=fn(s.id),Q=hn(),de=gn(),O=Array.isArray(X)?X:(X==null?void 0:X.activity)??[],Y=Array.isArray(K)?K:(K==null?void 0:K.comments)??[],d=s.createdAt?Math.ceil((Date.now()-new Date(s.createdAt).getTime())/864e5):0,D=s.resolvedAt&&s.createdAt?Math.round((new Date(s.resolvedAt).getTime()-new Date(s.createdAt).getTime())/36e5):null;async function z(){if(H.trim())try{await Q.mutateAsync({defectId:s.id,content:H.trim(),author:(J==null?void 0:J.displayName)||"Unknown"}),j("")}catch{}}function me(m){F({title:"Delete Comment",message:"Are you sure you want to delete this comment?",onConfirm:async()=>{F(null);try{await de.mutateAsync({defectId:s.id,commentId:m,deletedBy:(J==null?void 0:J.displayName)||(J==null?void 0:J.username)||""})}catch{}}})}const Ee=xr.indexOf(s.status);return e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:n}),e.jsxs("div",{className:"relative bg-surface-1 w-full max-w-5xl border-l border-white/10 animate-slide-in-right overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-1 border-b border-white/5",children:[e.jsxs("div",{className:"px-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-mono bg-surface-2 text-gray-300 px-2 py-1 rounded-md",children:s.id}),e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md ${Ds[s.priority]||"bg-gray-500/20 text-gray-400"}`,title:dt[s.priority],children:Zt[s.priority]||"P3"}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${ma[s.severity]||"bg-gray-500/20 text-gray-400"}`,children:B(s.severity||"unknown")}),s.externalId&&e.jsx(Rs,{externalId:s.externalId})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:u,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium text-gray-400 hover:text-gray-200 transition-colors rounded-lg hover:bg-white/5 border border-white/10",title:"Edit",children:[e.jsx(_s,{size:13})," Edit"]}),e.jsxs("button",{onClick:p,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium text-gray-400 hover:text-gray-200 transition-colors rounded-lg hover:bg-white/5 border border-white/10",title:"Duplicate — creates a copy without the JIRA link",children:[e.jsx(En,{size:13})," Duplicate"]}),e.jsx("button",{onClick:f,className:"p-1.5 text-gray-400 hover:text-red-400 transition-colors rounded-lg hover:bg-white/5",title:"Delete",children:e.jsx(Xt,{size:16})}),e.jsx("button",{onClick:n,className:"p-1.5 text-gray-400 hover:text-gray-200 transition-colors rounded-lg hover:bg-white/5",children:e.jsx(Qe,{size:18})})]})]}),e.jsx("h2",{className:"text-lg font-semibold text-gray-100",children:s.title})]}),e.jsx("div",{className:"px-6 pb-4",children:e.jsxs("div",{className:"flex items-center gap-0 flex-wrap",children:[xr.map((m,A)=>{const ie=s.status===m,pe=Ee>=0&&A<Ee;return e.jsxs(He.Fragment,{children:[A>0&&e.jsx("span",{className:`w-6 h-0.5 mx-1.5 rounded ${pe||ie?"bg-emerald-400/60":"bg-gray-400/30"}`}),e.jsxs("button",{onClick:()=>{!ie&&!b&&y(m)},disabled:ie||b,className:`flex items-center gap-1.5 text-[11.5px] font-semibold transition-colors disabled:cursor-default ${ie?"text-blue-400":pe?"text-emerald-400":"text-gray-500 hover:text-gray-300"}`,title:ie?"Current status":`Move to ${B(m)}`,children:[e.jsx("span",{className:`w-[22px] h-[22px] rounded-full border-2 flex items-center justify-center text-[10px] font-bold ${pe?"bg-emerald-400/20 border-emerald-400 text-emerald-400":ie?"border-blue-400 text-blue-400 ring-2 ring-blue-400/20 bg-blue-400/10":"border-gray-400/40 text-gray-500"}`,children:pe?"✓":A+1}),B(m)]})]},m)}),e.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[s.status!=="rejected"&&e.jsx("button",{onClick:()=>{b||y("rejected")},disabled:b,className:"text-[11.5px] text-gray-500 hover:text-red-400 transition-colors",children:"Reject"}),s.status==="rejected"?e.jsx("span",{className:"text-xs font-semibold text-slate-400 bg-slate-500/15 px-3 py-1.5 rounded-lg",children:"Rejected"}):es[s.status]?e.jsxs("button",{onClick:()=>{b||y(es[s.status])},disabled:b,className:"flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs font-semibold px-3.5 py-1.5 rounded-lg transition-colors disabled:opacity-60",children:[b?e.jsx(Nt,{size:12,className:"animate-spin"}):null,"Mark ",B(es[s.status])," ",e.jsx(As,{size:12})]}):e.jsx("span",{className:"text-xs font-semibold text-emerald-400 bg-emerald-500/15 px-3 py-1.5 rounded-lg",children:"Closed"})]})]})})]}),e.jsx("div",{className:"border-b border-white/5",children:e.jsx("div",{className:"px-6 flex gap-1",children:["details","activity","comments"].map(m=>e.jsxs("button",{onClick:()=>R(m),className:`px-4 py-2.5 text-xs font-medium border-b-2 transition-colors flex items-center gap-1.5 ${g===m?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200"}`,children:[m==="details"&&e.jsx(Js,{size:13}),m==="activity"&&e.jsx(Ar,{size:13}),m==="comments"&&e.jsx(Ks,{size:13}),B(m),m==="comments"&&Y.length>0&&e.jsx("span",{className:"bg-surface-2 text-gray-400 text-[10px] px-1.5 py-0.5 rounded-full",children:Y.length})]},m))})}),e.jsxs("div",{className:"px-6 py-4",children:[g==="details"&&e.jsxs("div",{className:"grid md:grid-cols-[1fr_250px] gap-6 items-start",children:[e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Linked Items"}),e.jsxs("div",{className:"space-y-2",children:[s.testCaseId&&e.jsxs("a",{href:`/test-cases?tcId=${encodeURIComponent(s.testCaseId)}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-3 border border-white/10 rounded-lg px-3 py-2.5 bg-surface-2/40 hover:border-brand-400/50 transition-colors group",children:[e.jsxs("span",{className:"text-sm text-gray-300 truncate",children:[e.jsx(Ss,{size:13,className:"inline mr-2 text-gray-500"}),e.jsx("b",{className:"font-mono text-gray-200",children:s.testCaseId}),s.testCaseTitle&&e.jsxs("span",{className:"text-gray-400",children:[" — ",s.testCaseTitle]})]}),e.jsx("span",{className:"text-xs font-semibold text-blue-400 shrink-0 group-hover:underline",children:"Open in Test Cases ↗"})]}),s.executionId&&e.jsxs("div",{className:"flex items-center gap-2 border border-white/10 rounded-lg px-3 py-2.5 bg-surface-2/40 text-xs text-gray-500",children:[e.jsx(Dn,{size:13,className:"text-gray-600"}),"Found in cycle execution ",e.jsx("span",{className:"font-mono text-gray-400",children:s.executionId})]}),!s.testCaseId&&!s.executionId&&e.jsxs("div",{className:"border border-dashed border-white/10 rounded-lg px-3 py-2.5 text-xs text-gray-500",children:["No linked items — use ",e.jsx("b",{className:"text-gray-400",children:"Edit"})," to link this defect to a test case."]})]})]}),s.description&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Description"}),e.jsx("p",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:s.description})]}),s.expectedResult&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Expected Result"}),e.jsx("p",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:s.expectedResult})]}),s.actualResult&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Actual Result"}),e.jsx("p",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:s.actualResult})]}),s.stepsToReproduce&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Steps to Reproduce"}),e.jsx("div",{className:"text-sm text-gray-300 bg-surface-2 rounded-lg p-3 border border-white/5 prose prose-invert prose-sm max-w-none break-words [&_*]:break-words [&_img]:max-w-full [&_img]:rounded-lg [&_ol]:list-decimal [&_ol]:pl-5 [&_ul]:list-disc [&_ul]:pl-5 [&_pre]:bg-black/30 [&_pre]:rounded [&_pre]:p-2 [&_pre]:whitespace-pre-wrap [&_blockquote]:border-l-2 [&_blockquote]:border-brand-500/50 [&_blockquote]:pl-3 [&_blockquote]:italic [&_a]:text-brand-300 [&_a]:break-all [&_h3]:mt-4 [&_h3]:mb-1 [&_h3]:text-base [&_h3]:font-semibold [&_h3:first-child]:mt-0 [&_p]:mb-1",dangerouslySetInnerHTML:{__html:ua(s.stepsToReproduce)}})]}),s.tags&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:(Array.isArray(s.tags)?s.tags:String(s.tags).split(",").map(m=>m.trim()).filter(Boolean)).map((m,A)=>e.jsx("span",{className:"text-xs bg-surface-2 text-gray-300 px-2 py-0.5 rounded",children:m},A))})]}),(()=>{const m=typeof s.attachments=="string"?(()=>{try{return JSON.parse(s.attachments)}catch{return[]}})():Array.isArray(s.attachments)?s.attachments:[];return m.length>0?e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:["Attachments (",m.length,")"]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:m.map((A,ie)=>{var be,et;const pe=`data:${A.fileType};base64,${A.fileData}`,Pe=()=>{const De=document.createElement("a");De.href=pe,De.download=A.fileName,document.body.appendChild(De),De.click(),document.body.removeChild(De)},Ze=()=>{T({src:pe,name:A.fileName})};return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-surface-2 rounded-lg border border-white/5",children:[(be=A.fileType)!=null&&be.startsWith("image/")?e.jsx("img",{src:pe,alt:A.fileName,className:"w-14 h-14 rounded object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:Ze,title:"Click to view full size"}):e.jsx("div",{className:"w-14 h-14 rounded bg-surface-0 flex items-center justify-center",children:e.jsx(Ss,{size:18,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:A.fileName}),e.jsx("p",{className:"text-xs text-gray-500",children:A.fileSize<1024?`${A.fileSize} B`:A.fileSize<1048576?`${(A.fileSize/1024).toFixed(1)} KB`:`${(A.fileSize/1048576).toFixed(1)} MB`}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[((et=A.fileType)==null?void 0:et.startsWith("image/"))&&e.jsxs("button",{onClick:Ze,className:"text-xs text-brand-300 hover:text-brand-200 flex items-center gap-1",children:[e.jsx(Js,{size:12})," View"]}),e.jsxs("button",{onClick:Pe,className:"text-xs text-brand-300 hover:text-brand-200 flex items-center gap-1",children:[e.jsx(Xs,{size:12})," Download"]})]})]})]},ie)})})]}):null})(),(()=>{const m=typeof s.referenceLinks=="string"?(()=>{try{return JSON.parse(s.referenceLinks)}catch{return[]}})():Array.isArray(s.referenceLinks)?s.referenceLinks:[];return m.length>0?e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-2",children:["Reference Links (",m.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.map((A,ie)=>e.jsxs("a",{href:A.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-2 bg-surface-2 rounded-lg border border-white/5 hover:border-brand-400/50 transition-colors group",children:[e.jsx(qt,{size:14,className:"text-brand-300 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 group-hover:text-brand-600 dark:group-hover:text-brand-300 truncate font-medium",children:A.title||A.url}),A.title&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:A.url})]})]},ie))})]}):null})(),!s.description&&!s.stepsToReproduce&&!s.expectedResult&&!s.actualResult&&e.jsx("div",{className:"text-center py-8 text-sm text-gray-500",children:"No details provided"})]}),e.jsxs("div",{className:"bg-surface-2/60 border border-white/10 rounded-xl px-4 py-3 text-[12.5px] md:sticky md:top-40",children:[[["Assignee",s.assignedTo||"—"],["Reporter",s.reporter||"—"],["Created",Kt(s.createdAt)],["Updated",Kt(s.updatedAt)],["Due date",s.dueDate?zr(s.dueDate):"—"],["Environment",s.environment||"—"],["Age",`${d} day${d!==1?"s":""}`],["Time to resolve",D?`${D}h`:"—"]].map(([m,A])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5 border-b border-white/5 last:border-0",children:[e.jsx("span",{className:"text-gray-500",children:m}),e.jsx("span",{className:"font-medium text-gray-200 text-right truncate",children:A})]},m)),e.jsx("div",{className:"pt-2.5",children:s.externalUrl||s.externalId?e.jsxs("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"text-brand-600 dark:text-brand-300 hover:underline flex items-center gap-1.5 text-xs",children:[e.jsx(qt,{size:12}),s.externalId||s.externalUrl]}):e.jsx(Na,{defect:s})})]})]}),g==="activity"&&e.jsx("div",{className:"space-y-0",children:O.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-gray-500",children:"No activity recorded"}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-[11px] top-2 bottom-2 w-px bg-white/5"}),O.map((m,A)=>e.jsxs("div",{className:"relative flex gap-3 pb-4",children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center shrink-0 z-10 ${m.action==="status_change"?"bg-blue-500/20 text-blue-400":m.action==="comment"?"bg-emerald-500/20 text-emerald-400":m.action==="comment_deleted"?"bg-red-500/20 text-red-400":m.action==="created"?"bg-violet-500/20 text-violet-400":"bg-gray-500/20 text-gray-400"}`,children:m.action==="status_change"?e.jsx(As,{size:12}):m.action==="comment"?e.jsx(Ks,{size:12}):m.action==="comment_deleted"?e.jsx(Xt,{size:12}):m.action==="created"?e.jsx(Rn,{size:12}):e.jsx(_s,{size:12})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-gray-200",children:[e.jsx("span",{className:"font-medium",children:m.performedBy||"System"}),m.action==="status_change"?e.jsxs("span",{className:"text-gray-400",children:[" changed status from ",e.jsx("span",{className:"text-gray-300",children:B(m.oldValue||"")})," to ",e.jsx("span",{className:"text-gray-300",children:B(m.newValue||"")})]}):m.action==="comment"?e.jsx("span",{className:"text-gray-400",children:" added a comment"}):m.action==="comment_deleted"?e.jsxs("span",{className:"text-gray-400",children:[" deleted a comment",m.oldValue?e.jsxs("span",{className:"text-gray-500 italic",children:[' — "',m.oldValue,'"']}):""]}):m.action==="created"?e.jsx("span",{className:"text-gray-400",children:" created this defect"}):e.jsxs("span",{className:"text-gray-400",children:[" updated ",e.jsx("span",{className:"text-gray-300",children:B(m.fieldName||"")})]})]}),e.jsx("span",{className:"text-xs text-gray-500",children:Kt(m.createdAt)})]})]},A))]})}),g==="comments"&&e.jsxs("div",{className:"space-y-4",children:[Y.length===0&&e.jsx("div",{className:"text-center py-8 text-sm text-gray-500",children:"No comments yet"}),Y.map(m=>e.jsxs("div",{className:"bg-surface-2 rounded-lg p-3 border border-white/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-brand-600/20 flex items-center justify-center",children:e.jsx(_r,{size:12,className:"text-brand-300"})}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:m.author||"Unknown"}),e.jsx("span",{className:"text-xs text-gray-500",children:Kt(m.createdAt)})]}),e.jsx("button",{onClick:()=>me(m.id),className:"p-1 text-gray-500 hover:text-red-400 transition-colors",title:"Delete comment",children:e.jsx(Xt,{size:12})})]}),e.jsx("p",{className:"text-sm text-gray-300 whitespace-pre-wrap",children:m.content})]},m.id)),e.jsxs("div",{className:"border-t border-white/5 pt-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("textarea",{value:H,onChange:m=>j(m.target.value),placeholder:"Add a comment...",rows:2,className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 resize-none",onKeyDown:m=>{m.key==="Enter"&&(m.ctrlKey||m.metaKey)&&z()}}),e.jsxs("button",{onClick:z,disabled:!H.trim()||Q.isPending,className:"self-end bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-2 text-sm font-medium flex items-center gap-1.5 transition-colors disabled:opacity-50",children:[Q.isPending?e.jsx(Nt,{size:14,className:"animate-spin"}):e.jsx(Sr,{size:14}),"Send"]})]}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-1",children:"Ctrl+Enter to send"})]})]})]})]}),E&&e.jsx(Ur,{title:E.title,message:E.message,onConfirm:E.onConfirm,onCancel:()=>F(null)}),_&&e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",onClick:()=>T(null),children:[e.jsx("div",{className:"absolute inset-0 bg-black/80 backdrop-blur-sm"}),e.jsxs("div",{className:"relative z-10 max-w-[90vw] max-h-[90vh] flex flex-col items-center",onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between w-full mb-3 px-1",children:[e.jsx("span",{className:"text-sm text-white font-medium truncate max-w-[70%]",children:_.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{const m=document.createElement("a");m.href=_.src,m.download=_.name,document.body.appendChild(m),m.click(),document.body.removeChild(m)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white rounded-lg text-xs font-medium flex items-center gap-1 transition-colors",children:[e.jsx(Xs,{size:12})," Download"]}),e.jsx("button",{onClick:()=>T(null),className:"p-1.5 bg-white/10 hover:bg-white/20 text-white rounded-lg transition-colors",children:e.jsx(Qe,{size:16})})]})]}),e.jsx("img",{src:_.src,alt:_.name,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})]})]})]})}function va({children:s,onClose:n}){return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:n}),e.jsx("div",{className:"relative z-10 w-full max-w-6xl mx-auto px-4 flex items-center justify-center",children:s})]})}function Ur({title:s,message:n,onConfirm:u,onCancel:p,confirmLabel:f,confirmColor:y}){return e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:p}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/10 flex items-center justify-center shrink-0",children:e.jsx(kn,{size:20,className:"text-red-400"})}),e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:s})]}),e.jsx("div",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-300",children:n})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:p,className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:u,className:`px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors ${y||"bg-red-600 hover:bg-red-500"}`,children:f||"Delete"})]})]})]})}function ja({value:s,onChange:n,inputCls:u}){const[p,f]=M.useState(!1),[y,b]=M.useState(s),{data:g}=jr({queryKey:["users"],queryFn:br}),R=M.useMemo(()=>{const j=(g==null?void 0:g.users)||[];return Array.isArray(j)?j:[]},[g]),H=M.useMemo(()=>{if(!y)return R;const j=y.toLowerCase();return R.filter(_=>(_.displayName||"").toLowerCase().includes(j)||(_.username||"").toLowerCase().includes(j)||(_.email||"").toLowerCase().includes(j))},[R,y]);return e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:y,onChange:j=>{b(j.target.value),n(j.target.value),f(!0)},onFocus:()=>f(!0),onBlur:()=>setTimeout(()=>f(!1),200),placeholder:"Search or type name...",className:u}),p&&H.length>0&&e.jsx("div",{className:"absolute z-50 top-full left-0 right-0 mt-1 bg-surface-1 border border-white/10 rounded-lg shadow-xl max-h-48 overflow-y-auto",children:H.map(j=>e.jsxs("button",{type:"button",onMouseDown:_=>{_.preventDefault();const T=j.displayName||j.username;b(T),n(T),f(!1)},className:"w-full flex items-center gap-3 px-3 py-2 text-left hover:bg-white/[0.05] transition-colors",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/20 flex items-center justify-center text-brand-300 text-xs font-semibold shrink-0",children:(j.displayName||j.username||"?").charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-gray-200 truncate",children:j.displayName}),e.jsxs("div",{className:"text-[10px] text-gray-500 truncate",children:["@",j.username,j.email?` · ${j.email}`:""]})]})]},j.id))})]})}function se({label:s,children:n}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-400 mb-1.5",children:s}),n]})}function Rs({externalId:s}){var H,j,_,T,E;const{connectorId:n}=Nr(),u=s!=null&&s.match(/^[A-Z][A-Z0-9]+-\d+$/i)?s:null,{data:p,isLoading:f,refetch:y}=bn(n,u),b=(j=(H=p==null?void 0:p.fields)==null?void 0:H.status)==null?void 0:j.name,g=(E=(T=(_=p==null?void 0:p.fields)==null?void 0:_.status)==null?void 0:T.statusCategory)==null?void 0:E.name;if(!n||!u)return null;const R={"To Do":"bg-gray-500/15 text-gray-400 border-gray-500/20","In Progress":"bg-blue-500/15 text-blue-400 border-blue-500/20",Done:"bg-emerald-500/15 text-emerald-400 border-emerald-500/20"};return e.jsx("span",{className:"inline-flex items-center gap-1",children:f?e.jsx(Nt,{size:12,className:"animate-spin text-gray-500"}):b?e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border ${R[g||""]||"bg-gray-500/15 text-gray-400 border-gray-500/20"}`,children:["JIRA: ",b]}):null})}function Na({defect:s}){var de;const{connectorId:n,isConfigured:u,baseUrl:p}=Nr(),{data:f}=yn(n),{data:y}=vn(n),b=jn(),g=vr(),[R,H]=M.useState(!1),[j,_]=M.useState(""),[T,E]=M.useState("Bug");if(!u)return null;const F=(f==null?void 0:f.projects)||[],J=(y==null?void 0:y.types)||[],X=J.filter(O=>["Bug","Task","Story","Sub-task","Defect"].some(Y=>(O.name||"").toLowerCase().includes(Y.toLowerCase())));X.length===0&&J.length>0&&X.push(...J.slice(0,5));const K=()=>{if(!n||!j)return;const O=[s.description&&`Description: ${s.description}`,s.stepsToReproduce&&`Steps to Reproduce: ${(s.stepsToReproduce||"").replace(/<[^>]+>/g," ").trim()}`,s.expectedResult&&`Expected Result: ${s.expectedResult}`,s.actualResult&&`Actual Result: ${s.actualResult}`,s.environment&&`Environment: ${s.environment}`,`Severity: ${s.severity} | Priority: ${s.priority}`,`Source: Testver Defect ${s.id}`].filter(Boolean).join(`
71
+
72
+ `),Y={p1:"Highest",p2:"High",p3:"Medium",p4:"Low"};b.mutate({connectorId:n,data:{projectKey:j,issueType:T,summary:s.title,description:O,priority:Y[s.priority]||"Medium",labels:["testver",s.severity].filter(Boolean)}},{onSuccess:d=>{const D=d.key;g.mutate({id:s.id,data:{externalId:D,externalUrl:Nn(p,D)}}),H(!1)}})},Q="w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-gray-200 text-sm focus:outline-none focus:ring-1 focus:ring-brand-500";return e.jsx("div",{children:R?e.jsxs("div",{className:"bg-blue-500/5 border border-blue-500/20 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-blue-300",children:"Create JIRA Issue from Defect"}),e.jsx("button",{onClick:()=>H(!1),className:"text-gray-500 hover:text-gray-300",children:e.jsx(Qe,{size:14})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Project"}),e.jsxs("select",{value:j,onChange:O=>_(O.target.value),className:Q,children:[e.jsx("option",{value:"",children:"Select project..."}),F.map(O=>e.jsxs("option",{value:O.key,children:[O.key," — ",O.name]},O.key))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Issue Type"}),e.jsx("select",{value:T,onChange:O=>E(O.target.value),className:Q,children:X.map(O=>e.jsx("option",{value:O.name,children:O.name},O.id||O.name))})]})]}),e.jsxs("div",{className:"text-xs text-gray-400 bg-surface-2 rounded-lg p-2",children:[e.jsx("strong",{className:"text-gray-300",children:"Will create:"})," ",s.title]}),e.jsxs("button",{onClick:K,disabled:!j||b.isPending,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium text-white bg-blue-600 hover:bg-blue-500 rounded-lg disabled:opacity-50 transition-colors",children:[b.isPending?e.jsx(Nt,{size:14,className:"animate-spin"}):e.jsx(Sr,{size:14}),"Create in JIRA"]}),b.isError&&e.jsx("p",{className:"text-xs text-red-400",children:((de=b.error)==null?void 0:de.message)||"Failed to create"})]}):e.jsxs("button",{onClick:()=>H(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-blue-400 bg-blue-500/10 hover:bg-blue-500/20 rounded-lg border border-blue-500/20 transition-colors",children:[e.jsx(qt,{size:12})," Push to JIRA"]})})}export{Oa as DefectsPage};