@rudderhq/server 0.6.6-canary.21 → 0.6.6-canary.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +14 -14
- package/ui-dist/assets/LibraryLiveSurface-CC-trIKx.js +1 -0
- package/ui-dist/assets/{abnfDiagram-VRR7QNED-H2QkzWSq.js → abnfDiagram-VRR7QNED-CpS8IVc5.js} +1 -1
- package/ui-dist/assets/{arc-BIrLdSup.js → arc-CSCK8iV0.js} +1 -1
- package/ui-dist/assets/{architectureDiagram-ZJ3FMSHR-C68uQC9x.js → architectureDiagram-ZJ3FMSHR-DgchGibw.js} +1 -1
- package/ui-dist/assets/{blockDiagram-677ZJIJ3-DolMzRCT.js → blockDiagram-677ZJIJ3-RcmQaGjR.js} +1 -1
- package/ui-dist/assets/{c4Diagram-LMCZKHZV-U6f3_L6P.js → c4Diagram-LMCZKHZV-3LVUEu2z.js} +1 -1
- package/ui-dist/assets/channel-CDcsjmaQ.js +1 -0
- package/ui-dist/assets/{chunk-2Q5K7J3B-BRJijXIZ.js → chunk-2Q5K7J3B-0JGaHnsd.js} +1 -1
- package/ui-dist/assets/{chunk-32BRIVSS-Belug4Vy.js → chunk-32BRIVSS-CGkRax1W.js} +1 -1
- package/ui-dist/assets/{chunk-5VM5RSS4-BAP9C4WC.js → chunk-5VM5RSS4-BpywkdEH.js} +1 -1
- package/ui-dist/assets/{chunk-EX3LRPZG-BorLutQY.js → chunk-EX3LRPZG-o1_ffD5w.js} +1 -1
- package/ui-dist/assets/{chunk-JWPE2WC7-MCTTrlhK.js → chunk-JWPE2WC7-D7Ue-HKh.js} +1 -1
- package/ui-dist/assets/{chunk-MOJQB5TN-BEBLFyze.js → chunk-MOJQB5TN-CpFP7eCO.js} +1 -1
- package/ui-dist/assets/{chunk-RYQCIY6F-gzlBaUJ5.js → chunk-RYQCIY6F-efyzHhXO.js} +1 -1
- package/ui-dist/assets/{chunk-V7JOEXUC-Djyk9uKC.js → chunk-V7JOEXUC-CJXq5HRc.js} +1 -1
- package/ui-dist/assets/{chunk-VR4S4FIN-lxRoHimg.js → chunk-VR4S4FIN-CTUrf8cQ.js} +1 -1
- package/ui-dist/assets/{chunk-XXDRQBXY-Ceus5xtJ.js → chunk-XXDRQBXY-BCk-sgKb.js} +1 -1
- package/ui-dist/assets/classDiagram-OUVF2IWQ-B0QG_aVA.js +1 -0
- package/ui-dist/assets/classDiagram-v2-EOCWNBFH-B0QG_aVA.js +1 -0
- package/ui-dist/assets/{cose-bilkent-JH36ORCC-8gSFuEzG.js → cose-bilkent-JH36ORCC-Ckigcsjs.js} +1 -1
- package/ui-dist/assets/{cynefin-VYW2F7L2-Sr3yYkcO.js → cynefin-VYW2F7L2-BUrdFOtH.js} +1 -1
- package/ui-dist/assets/{cynefinDiagram-TSTJHNR4-BrgLR8Pm.js → cynefinDiagram-TSTJHNR4-6q9peCDZ.js} +1 -1
- package/ui-dist/assets/{dagre-VKFMJZFB-BH4QYWTM.js → dagre-VKFMJZFB-x5UHgN9A.js} +1 -1
- package/ui-dist/assets/{diagram-FQU43EPY-hpkOd3am.js → diagram-FQU43EPY-3RuRrVWO.js} +1 -1
- package/ui-dist/assets/{diagram-G47NLZAW-CSBB9Flk.js → diagram-G47NLZAW-Csfuklxs.js} +1 -1
- package/ui-dist/assets/{diagram-NH7WQ7WH-CgNJflW8.js → diagram-NH7WQ7WH-Cs5Xevve.js} +1 -1
- package/ui-dist/assets/{diagram-OA4YK3LP-DqQFUFQv.js → diagram-OA4YK3LP-XYFi9LaE.js} +1 -1
- package/ui-dist/assets/{diagram-WEI45ONY-QAnSfiw3.js → diagram-WEI45ONY-DKP5NbFJ.js} +1 -1
- package/ui-dist/assets/{ebnfDiagram-CCIWWBDH--YVRXF7-.js → ebnfDiagram-CCIWWBDH-BfVD77_T.js} +1 -1
- package/ui-dist/assets/{erDiagram-Q63AITRT-CRH_K_mE.js → erDiagram-Q63AITRT-D2AjDim7.js} +1 -1
- package/ui-dist/assets/{flowDiagram-23GEKE2U-CwyXvJ5b.js → flowDiagram-23GEKE2U-NhUkM87P.js} +1 -1
- package/ui-dist/assets/{ganttDiagram-NO4QXBWP-B41Y9cwF.js → ganttDiagram-NO4QXBWP-C8s1Ta28.js} +1 -1
- package/ui-dist/assets/{gitGraphDiagram-IHSO6WYX-CW7LKrym.js → gitGraphDiagram-IHSO6WYX-CPcIqO4u.js} +1 -1
- package/ui-dist/assets/{graph-B2oDVjJO.js → graph-CnYlPxal.js} +1 -1
- package/ui-dist/assets/{index-_QsesMkH.js → index-BH9LwKXk.js} +1 -1
- package/ui-dist/assets/{index-CS_SCGq-.js → index-C-4Zo7dp.js} +1 -1
- package/ui-dist/assets/{index-Df6CE5HD.js → index-CFUDXhV8.js} +1 -1
- package/ui-dist/assets/{index-CRRh2Q50.js → index-CLvaLbgc.js} +1 -1
- package/ui-dist/assets/{index-Z1lC3yRm.js → index-CQiu3CXd.js} +1 -1
- package/ui-dist/assets/{index-CJ8Y6mRU.js → index-Cm_HvF4F.js} +1 -1
- package/ui-dist/assets/{index-DhMy-JmC.js → index-DFr2tnOE.js} +1 -1
- package/ui-dist/assets/{index-3zFxfIXc.js → index-DGOowJrI.js} +5 -5
- package/ui-dist/assets/{index-BDWwQIJI.js → index-DVJpqZtD.js} +1 -1
- package/ui-dist/assets/{index-BzBuqR8a.js → index-DacDSgdg.js} +1 -1
- package/ui-dist/assets/{index-D7jFNS5a.js → index-DfScGbDG.js} +1 -1
- package/ui-dist/assets/{index-CWZ6QjAd.js → index-DrRUMUXa.js} +1 -1
- package/ui-dist/assets/{index-BOLgWo9p.js → index-DrWke90U.js} +1 -1
- package/ui-dist/assets/{index-DQRYID5z.js → index-Du9mXfo2.js} +1 -1
- package/ui-dist/assets/{index-DEdvpket.js → index-DzECL1TA.js} +1 -1
- package/ui-dist/assets/{index-BdhCuwEn.js → index-VuYeSyL5.js} +1 -1
- package/ui-dist/assets/{index-CiBZqJye.js → index-b048gRJ5.js} +1 -1
- package/ui-dist/assets/{index-CNJdbN2c.js → index-vGVwOJ8z.js} +1 -1
- package/ui-dist/assets/{infoDiagram-FWYZ7A6U-DyzTlql6.js → infoDiagram-FWYZ7A6U-DXOi6lpc.js} +1 -1
- package/ui-dist/assets/{ishikawaDiagram-FXEZZL3T-B9FXEgF4.js → ishikawaDiagram-FXEZZL3T-C_CBdFTL.js} +1 -1
- package/ui-dist/assets/{journeyDiagram-5HDEW3XC-BG_Kqf0Y.js → journeyDiagram-5HDEW3XC-BiGmQkky.js} +1 -1
- package/ui-dist/assets/{kanban-definition-HUTT4EX6-CIZgF9a-.js → kanban-definition-HUTT4EX6-_f-vDZiV.js} +1 -1
- package/ui-dist/assets/{layout-ua-GqVIZ.js → layout-BEaMOBHC.js} +1 -1
- package/ui-dist/assets/{linear-CQqDskaQ.js → linear-3_jkX0FV.js} +1 -1
- package/ui-dist/assets/{map-DFw_ZSS_.js → map-BbFfUJKf.js} +1 -1
- package/ui-dist/assets/{mermaid.core-BVJ3bsf4.js → mermaid.core-tC71IlYD.js} +4 -4
- package/ui-dist/assets/{mindmap-definition-LN4V7U3C-Dp1UsqtW.js → mindmap-definition-LN4V7U3C-tEF6XQAm.js} +1 -1
- package/ui-dist/assets/{pegDiagram-2B236MQR-BDUL53zP.js → pegDiagram-2B236MQR-Bv2KeFJD.js} +1 -1
- package/ui-dist/assets/{pieDiagram-ENE6RG2P-CgSzQLOQ.js → pieDiagram-ENE6RG2P-vnh6PHg2.js} +1 -1
- package/ui-dist/assets/{quadrantDiagram-ABIIQ3AL-B0YmTMhz.js → quadrantDiagram-ABIIQ3AL-BaiCya0x.js} +1 -1
- package/ui-dist/assets/{railroadDiagram-RFXS5EU6-BvTcxcz9.js → railroadDiagram-RFXS5EU6-CAuyf2vt.js} +1 -1
- package/ui-dist/assets/{requirementDiagram-TGXJPOKE-fkKI0lRC.js → requirementDiagram-TGXJPOKE-CuQSl6eY.js} +1 -1
- package/ui-dist/assets/{sankeyDiagram-HTMAVEWB-BSOcxgQK.js → sankeyDiagram-HTMAVEWB-DLOK1Q6H.js} +1 -1
- package/ui-dist/assets/{sequenceDiagram-DBY2YBRQ-DrAQ-gvA.js → sequenceDiagram-DBY2YBRQ-MW6w_CIR.js} +1 -1
- package/ui-dist/assets/{sizeCapture-X5ZJPWSS-CdXaDJu7.js → sizeCapture-X5ZJPWSS-BtlklXMq.js} +1 -1
- package/ui-dist/assets/{stateDiagram-2N3HPSRC-CPtjImOw.js → stateDiagram-2N3HPSRC-B_NAS0W9.js} +1 -1
- package/ui-dist/assets/stateDiagram-v2-6OUMAXLB-BdaEp1wC.js +1 -0
- package/ui-dist/assets/{swimlanes-5IMT3BWC-BiAgJ_7N.js → swimlanes-5IMT3BWC-Ba4CysrZ.js} +2 -2
- package/ui-dist/assets/swimlanesDiagram-G3AALYLV-C2WqNAM4.js +8 -0
- package/ui-dist/assets/{timeline-definition-FHXFAJF6-Biw5JBPT.js → timeline-definition-FHXFAJF6-Q_30QcXS.js} +1 -1
- package/ui-dist/assets/{vennDiagram-L72KCM5P-B2sQcNFx.js → vennDiagram-L72KCM5P-Br0Ry7R1.js} +1 -1
- package/ui-dist/assets/{wardleyDiagram-EHGQE667-CKi9r9aK.js → wardleyDiagram-EHGQE667-Dp1Fyojl.js} +1 -1
- package/ui-dist/assets/{xychartDiagram-FW5EYKEG-D-0Bf_Kv.js → xychartDiagram-FW5EYKEG-DC64NQfH.js} +1 -1
- package/ui-dist/index.html +1 -1
- package/ui-dist/assets/LibraryLiveSurface-Cd6wYgzJ.js +0 -1
- package/ui-dist/assets/channel-B_YTptSv.js +0 -1
- package/ui-dist/assets/classDiagram-OUVF2IWQ-iR-TAS1r.js +0 -1
- package/ui-dist/assets/classDiagram-v2-EOCWNBFH-iR-TAS1r.js +0 -1
- package/ui-dist/assets/stateDiagram-v2-6OUMAXLB-BntLUyuz.js +0 -1
- package/ui-dist/assets/swimlanesDiagram-G3AALYLV-BwiyiniO.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CLvaLbgc.js","assets/index-BH9LwKXk.js","assets/index-DacDSgdg.js","assets/index-DVJpqZtD.js","assets/index-DrWke90U.js","assets/index-CQiu3CXd.js","assets/index-DrRUMUXa.js","assets/index-DzECL1TA.js","assets/dockerfile-BKs6k2Af.js","assets/simple-mode-GW_nhZxv.js","assets/factor-kuTfRLto.js","assets/nsis-LdVXkNf5.js","assets/pug-DeIclll2.js","assets/javascript-iXu5QeM3.js","assets/index-VuYeSyL5.js","assets/index-DFr2tnOE.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var mft=Object.defineProperty;var m2e=e=>{throw TypeError(e)};var pft=(e,t,n)=>t in e?mft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ai=(e,t,n)=>pft(e,typeof t!="symbol"?t+"":t,n),_H=(e,t,n)=>t.has(e)||m2e("Cannot "+n);var Oe=(e,t,n)=>(_H(e,t,"read from private field"),n?n.call(e):t.get(e)),tn=(e,t,n)=>t.has(e)?m2e("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),_t=(e,t,n,r)=>(_H(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ds=(e,t,n)=>(_H(e,t,"access private method"),n);var WD=(e,t,n,r)=>({set _(s){_t(e,t,s,n)},get _(){return Oe(e,t,r)}});function lIe(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const a=Object.getOwnPropertyDescriptor(r,s);a&&Object.defineProperty(e,s,a.get?a:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();var p2e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function DO(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var MH={exports:{}},nC={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -1594,7 +1594,7 @@ Error generating stack: `+P.message+`
|
|
|
1594
1594
|
`))),s=[])};for(const c of n){const d=c.match(/^[ \t]{0,3}(`{3,}|~{3,})/u);if(d){const u=(l=d[1])==null?void 0:l[0];if(!a){o(),a=u??null,r.push(c);continue}if(u===a){r.push(c),a=null;continue}}a?r.push(c):s.push(c)}return o(),r.join(`
|
|
1595
1595
|
`)}function WEt(e,t,n){const r=[{length:0,link:-1,firstEnd:n.rawStart-1,next:new Map}];let s=0;for(let c=n.rawStart;c<n.rawEnd;c+=1){const d=r.length;r.push({length:r[s].length+1,link:0,firstEnd:c,next:new Map});let u=s;const f=e[c];for(;u>=0&&!r[u].next.has(f);)r[u].next.set(f,d),u=r[u].link;if(u>=0){const A=r[u].next.get(f);if(r[u].length+1===r[A].length)r[d].link=A;else{const h=r.length;for(r.push({length:r[u].length+1,link:r[A].link,firstEnd:r[A].firstEnd,next:new Map(r[A].next)});u>=0&&r[u].next.get(f)===A;)r[u].next.set(f,h),u=r[u].link;r[A].link=h,r[d].link=h}}s=d}let a=0,o=0,l=null;for(let c=n.renderedStart;c<n.renderedEnd;c+=1){const d=t[c];for(;a!==0&&!r[a].next.has(d);)a=r[a].link,o=Math.min(o,r[a].length);const u=r[a].next.get(d);if(u===void 0){a=0,o=0;continue}a=u,o+=1;const A=r[a].firstEnd-o+1,h=c-o+1;(!l||o>l.length||o===l.length&&(h<l.renderedStart||h===l.renderedStart&&A<l.rawStart))&&(l={rawStart:A,renderedStart:h,length:o})}return l}function ZEt(e,t){const n=[],r=[{rawStart:0,rawEnd:e.length,renderedStart:0,renderedEnd:t.length}];for(;r.length>0;){const s=r.pop();let{rawStart:a,rawEnd:o,renderedStart:l,renderedEnd:c}=s,d=0;for(;a+d<o&&l+d<c&&e[a+d]===t[l+d];)d+=1;d>0&&(n.push({rawStart:a,renderedStart:l,length:d}),a+=d,l+=d);let u=0;for(;o-u>a&&c-u>l&&e[o-u-1]===t[c-u-1];)u+=1;if(u>0&&(o-=u,c-=u,n.push({rawStart:o,renderedStart:c,length:u})),a>=o||l>=c)continue;const f=WEt(e,t,{rawStart:a,rawEnd:o,renderedStart:l,renderedEnd:c});if(!f||f.length===0)continue;n.push(f),a<f.rawStart&&l<f.renderedStart&&r.push({rawStart:a,rawEnd:f.rawStart,renderedStart:l,renderedEnd:f.renderedStart});const A=f.rawStart+f.length,h=f.renderedStart+f.length;A<o&&h<c&&r.push({rawStart:A,rawEnd:o,renderedStart:h,renderedEnd:c})}return n.sort((s,a)=>s.renderedStart-a.renderedStart||s.rawStart-a.rawStart).reduce((s,a)=>{const o=s.at(-1);return o&&o.rawStart+o.length===a.rawStart&&o.renderedStart+o.length===a.renderedStart?o.length+=a.length:s.push({...a}),s},[])}function Ove(e,t,n,r,s){const a=n-t,o=s-r;if(o===0){e[r]=n;return}for(let l=0;l<=o;l+=1)e[r+l]=t+Math.round(l/o*a)}function HEt(e,t){const n=Array(t.length+1).fill(0);let r=0,s=0;for(const a of ZEt(e,t)){Ove(n,r,a.rawStart,s,a.renderedStart);for(let o=0;o<=a.length;o+=1)n[a.renderedStart+o]=a.rawStart+o;r=a.rawStart+a.length,s=a.renderedStart+a.length}Ove(n,r,e.length,s,t.length),n[0]=0,n[t.length]=e.length;for(let a=1;a<n.length;a+=1)n[a]=Math.max(n[a-1],Math.min(e.length,n[a]));return{rawSource:e,renderedSource:t,renderedBoundaryToRaw:n}}function ws({...e}){return i.jsx(E_,{"data-slot":"dialog",...e})}function aFe({...e}){return i.jsx(WIe,{"data-slot":"dialog-trigger",...e})}function oFe({...e}){return i.jsx(D_,{"data-slot":"dialog-portal",...e})}function XEt({...e}){return i.jsx($O,{"data-slot":"dialog-close",...e})}function GEt({className:e,...t}){return i.jsx(R_,{"data-slot":"dialog-overlay",className:q("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-[rgb(31_27_23/0.22)] duration-200 dark:bg-[rgb(10_11_14/0.46)]",e),...t})}function Ps({className:e,children:t,overlayClassName:n,showCloseButton:r=!0,...s}){return i.jsxs(oFe,{"data-slot":"dialog-portal",children:[i.jsx(GEt,{className:n}),i.jsxs(zO,{"data-slot":"dialog-content",className:q("glass-modal motion-modal fixed top-[max(0.75rem,env(safe-area-inset-top))] md:top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-1.5rem)] translate-x-[-50%] translate-y-0 gap-4 rounded-md border bg-card p-6 shadow-[0_32px_90px_-46px_rgb(20_20_20/0.34)] outline-none md:translate-y-[-50%] sm:max-w-lg dark:shadow-[0_36px_96px_-48px_rgb(0_0_0/0.58)]",e),...s,children:[t,r&&i.jsxs($O,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[i.jsx(Ls,{}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ai({className:e,...t}){return i.jsx("div",{"data-slot":"dialog-header",className:q("flex flex-col gap-2 text-center sm:text-left",e),...t})}function aa({className:e,showCloseButton:t=!1,children:n,...r}){return i.jsxs("div",{"data-slot":"dialog-footer",className:q("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r,children:[n,t&&i.jsx($O,{asChild:!0,children:i.jsx(ie,{variant:"outline",children:"Close"})})]})}function Js({className:e,...t}){return i.jsx(L_,{"data-slot":"dialog-title",className:q("text-lg leading-none font-semibold",e),...t})}function wi({className:e,...t}){return i.jsx(ZIe,{"data-slot":"dialog-description",className:q("text-muted-foreground text-sm",e),...t})}const YEt={info:4e3,success:3500,warn:8e3,error:1e4},JEt=1500,eDt=15e3,tDt=5,nDt=3500,rDt=2e4,Hue=m.createContext(null);function sDt(e,t){const n=YEt[t];return typeof e!="number"||!Number.isFinite(e)?n:Math.max(JEt,Math.min(eDt,Math.floor(e)))}function iDt(){return`toast_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function aDt({children:e}){const[t,n]=m.useState([]),r=m.useRef(new Map),s=m.useRef(new Map),a=m.useCallback(u=>{const f=r.current.get(u);f!==void 0&&(window.clearTimeout(f),r.current.delete(u))},[]),o=m.useCallback(u=>{a(u),n(f=>f.filter(A=>A.id!==u))},[a]),l=m.useCallback(()=>{for(const u of r.current.values())window.clearTimeout(u);r.current.clear(),n([])},[]),c=m.useCallback(u=>{var v,w;const f=Date.now(),A=u.tone??"info",h=sDt(u.ttlMs,A),g=u.dedupeKey??u.id??`${A}|${u.title}|${u.body??""}|${((v=u.action)==null?void 0:v.href)??((w=u.action)==null?void 0:w.label)??""}`;for(const[k,O]of s.current.entries())f-O>rDt&&s.current.delete(k);const x=s.current.get(g);if(x&&f-x<nDt)return null;s.current.set(g,f);const y=u.id??iDt();if(a(y),n(k=>{const O={id:y,title:u.title,body:u.body,tone:A,ttlMs:h,persistent:u.persistent,icon:u.icon,action:u.action,createdAt:f},j=k.filter(C=>C.id!==y);return[O,...j].slice(0,tDt)}),!u.persistent){const k=window.setTimeout(()=>{o(y)},h);r.current.set(y,k)}return y},[a,o]);m.useEffect(()=>()=>{for(const u of r.current.values())window.clearTimeout(u);r.current.clear()},[]);const d=m.useMemo(()=>({toasts:t,pushToast:c,dismissToast:o,clearToasts:l}),[t,c,o,l]);return i.jsx(Hue.Provider,{value:d,children:e})}function As(){const e=m.useContext(Hue);if(!e)throw new Error("useToast must be used within a ToastProvider");return e}function l9(){return m.useContext(Hue)}function c9(e){return!!(e!=null&&e.toLowerCase().startsWith("image/"))}const oDt=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/i;function g7(e,t){const n=e==null?void 0:e.trim();if(n)return c9(n);const r=t.split(/[?#]/u,1)[0]??t;return oDt.test(r)}function lDt(e){switch(e.toLowerCase().split(";")[0]){case"image/jpeg":case"image/jpg":return".jpg";case"image/gif":return".gif";case"image/webp":return".webp";case"image/svg+xml":return".svg";case"image/png":default:return".png"}}function lFe(e,t,n="image"){const r=e.trim()||n;return/\.[a-z0-9]{2,8}$/i.test(r)?r:`${r}${lDt(t)}`}async function cDt(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let r="";const s=32768;for(let a=0;a<n.length;a+=s)r+=String.fromCharCode(...n.subarray(a,a+s));return btoa(r)}async function cFe(e,t,n="image"){const r=e.type||"image/png";return{filename:lFe(t,r,n),contentType:r,base64:await cDt(e)}}async function Xue(e){const t=await fetch(e,{credentials:"include"});if(!t.ok)throw new Error(`Unable to load image (${t.status}).`);const n=await t.blob();if(!c9(n.type))throw new Error("The selected asset is not an image.");return n}async function dDt(e){var n;const t=typeof ClipboardItem>"u"?null:ClipboardItem;if(!((n=navigator.clipboard)!=null&&n.write)||!t)throw new Error("Copy Image is only available in the desktop app or a clipboard-enabled browser.");await navigator.clipboard.write([new t({[e.type||"image/png"]:e})])}async function dFe(e,t){const n=await Xue(e),r=Pn();if(r!=null&&r.copyImage){await r.copyImage(await cFe(n,t));return}await dDt(n)}async function uFe(e,t){const n=Pn();if(!(n!=null&&n.showImageInFolder))throw new Error("Show in folder is available in the desktop app.");const r=await Xue(e);await n.showImageInFolder(await cFe(r,t))}function fFe(){var e;return!!((e=Pn())!=null&&e.showImageInFolder)}async function AFe(e,t){const n=await Xue(e),r=URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=lFe(t,n.type||"image/png"),document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(r)}const jve=24,uDt=1440,fDt=48,Cve=8,ADt=8,hDt=32,mDt=4,pDt=8,gDt=32;function Tre(e){return!!(e&&e.width>0&&e.height>0)}function qq(e){return{alt:e.alt,naturalSize:e.naturalWidth>0&&e.naturalHeight>0?{width:e.naturalWidth,height:e.naturalHeight}:null,src:e.currentSrc||e.src}}function Kq(e,t,n=typeof window>"u"?"http://localhost":window.location.href){var s;const r=e==null?void 0:e.trim();if(r)return r;try{const o=(s=new URL(t,n).pathname.split("/").filter(Boolean).at(-1))==null?void 0:s.trim();if(o)return decodeURIComponent(o)}catch{}return"Image preview"}function xDt(e){const t=Math.max(0,Math.floor(e)),n=t>0?pDt+t*hDt+(t-1)*mDt:0;return Cve+n+(n>0?ADt:0)+gDt+Cve}function Gue(e,t){return{maxWidth:Math.max(0,Math.min(e-jve,uDt)),maxHeight:Math.max(0,t-jve)}}function bDt(e,t,n){const r=Gue(t,n);if(!Tre(e)||r.maxWidth===0||r.maxHeight===0)return{width:0,height:0};const s=Math.min(r.maxWidth/e.width,r.maxHeight/e.height,1);return{width:Math.max(1,Math.floor(e.width*s)),height:Math.max(1,Math.floor(e.height*s))}}function yDt(e,t,n,r=2){const s=Gue(t,n);return{width:Math.min(s.maxWidth,Math.max(e.width,xDt(r))),height:Math.min(s.maxHeight,Math.max(e.height,fDt))}}const vDt=190,wDt=178;function hFe(e,t){return typeof window>"u"?{left:e,top:t}:{left:Math.min(e,Math.max(8,window.innerWidth-vDt)),top:Math.min(t,Math.max(8,window.innerHeight-wDt))}}function Yue(e,t,n){const r=qq(e);return{...r,name:Kq(e.getAttribute("alt"),r.src),position:hFe(t,n)}}function kDt(e){return e instanceof Error?e.message:String(e)}function Wq({name:e,onClose:t,onOpen:n,position:r,portalContainer:s,src:a,testId:o="markdown-image-context-menu"}){const l=l9(),c=m.useRef(null),d=fFe();m.useEffect(()=>{const f=h=>{var g;(g=c.current)!=null&&g.contains(h.target)||t()},A=h=>{h.key==="Escape"&&t()};return document.addEventListener("pointerdown",f),document.addEventListener("keydown",A),()=>{document.removeEventListener("pointerdown",f),document.removeEventListener("keydown",A)}},[t]);const u=async(f,A,h)=>{t();try{await A(),h&&(l==null||l.pushToast({title:h,tone:"success"}))}catch(g){l==null||l.pushToast({title:f,body:kDt(g),tone:"error"})}};return typeof document>"u"?null:qa.createPortal(i.jsxs("div",{ref:c,"data-testid":o,role:"menu",className:`motion-chat-composer-menu-pop surface-overlay z-50 min-w-[190px] rounded-[var(--radius-lg)] border p-1.5 text-foreground shadow-[var(--shadow-lg)] ${s?"absolute":"fixed"}`,style:r,children:[n?i.jsxs("button",{type:"button",role:"menuitem",className:"chat-composer-menu-row w-full",onClick:()=>{t(),n()},children:[i.jsx(La,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Open Image"})]}):null,i.jsxs("button",{type:"button",role:"menuitem",className:"chat-composer-menu-row w-full",onClick:()=>u("Copy Image failed",()=>dFe(a,e),"Image copied"),children:[i.jsx(sl,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Copy Image"})]}),i.jsxs("button",{type:"button",role:"menuitem",className:"chat-composer-menu-row w-full",onClick:()=>u("Download Image failed",()=>AFe(a,e)),children:[i.jsx(pg,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Download Image"})]}),d?i.jsxs("button",{type:"button",role:"menuitem",className:"chat-composer-menu-row w-full",onClick:()=>u("Show in folder failed",()=>uFe(a,e)),children:[i.jsx(ho,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Show in folder"})]}):null]}),s??document.body)}function Nve(){return typeof window>"u"?{width:1440,height:900}:{width:window.innerWidth,height:window.innerHeight}}function SDt({preview:e,onOpenChange:t,testId:n,titleFallback:r}){const s=l9(),a=m.useRef(null),[o,l]=m.useState((e==null?void 0:e.naturalSize)??null),[c,d]=m.useState(()=>Nve()),[u,f]=m.useState(null),A=fFe();m.useEffect(()=>{if(f(null),!e){l(null);return}if(l(Tre(e.naturalSize)?e.naturalSize:null),!e.src||Tre(e.naturalSize))return;const v=new window.Image;return v.onload=()=>{l({width:v.naturalWidth,height:v.naturalHeight})},v.onerror=()=>{l(null)},v.src=e.src,()=>{v.onload=null,v.onerror=null}},[e]),m.useEffect(()=>{if(!e||typeof window>"u")return;const v=()=>{d(Nve())};return v(),window.addEventListener("resize",v),()=>{window.removeEventListener("resize",v)}},[e]);const h=m.useMemo(()=>o?bDt(o,c.width,c.height):null,[o,c.height,c.width]),g=m.useMemo(()=>Gue(c.width,c.height),[c.height,c.width]),x=m.useMemo(()=>yDt(h??{width:0,height:0},c.width,c.height,A?3:2),[A,h,c.height,c.width]),y=async(v,w,k)=>{if(e)try{await w(),k&&(s==null||s.pushToast({title:k,tone:"success"}))}catch(O){s==null||s.pushToast({title:v,body:O instanceof Error?O.message:String(O),tone:"error"})}};return i.jsx(ws,{open:e!==null,onOpenChange:t,children:i.jsxs(Ps,{ref:a,"aria-describedby":void 0,showCloseButton:!1,className:"rudder-markdown-editor-image-preview-panel top-[50%] w-fit translate-y-[-50%] border-0 bg-transparent p-0 shadow-none",style:{maxWidth:`${g.maxWidth}px`,width:`${x.width}px`},children:[i.jsx(Js,{className:"sr-only",children:(e==null?void 0:e.name)??r}),e?i.jsxs("div",{"data-testid":n,className:"rudder-markdown-editor-image-preview-media relative flex w-fit max-w-full items-center justify-center overflow-hidden",style:{width:`${x.width}px`,height:`${x.height}px`},children:[i.jsxs(XEt,{className:"absolute right-2 top-2 z-10 flex size-8 items-center justify-center rounded-sm bg-black/55 text-white shadow-[0_6px_18px_rgb(0_0_0/0.28)] transition-colors hover:bg-black/70 focus:outline-none focus:ring-2 focus:ring-white/80",children:[i.jsx(Ls,{className:"size-4","aria-hidden":"true"}),i.jsx("span",{className:"sr-only",children:"Close image preview"})]}),i.jsxs("div",{className:"absolute left-2 top-2 z-10 flex items-center gap-1 rounded-sm bg-black/55 p-1 text-white shadow-[0_6px_18px_rgb(0_0_0/0.28)]",children:[i.jsxs("button",{type:"button",className:"rudder-image-preview-action",title:"Copy Image",onClick:()=>y("Copy Image failed",()=>dFe(e.src,e.name),"Image copied"),children:[i.jsx(sl,{className:"size-4","aria-hidden":"true"}),i.jsx("span",{className:"sr-only",children:"Copy Image"})]}),i.jsxs("button",{type:"button",className:"rudder-image-preview-action",title:"Download Image",onClick:()=>y("Download Image failed",()=>AFe(e.src,e.name)),children:[i.jsx(pg,{className:"size-4","aria-hidden":"true"}),i.jsx("span",{className:"sr-only",children:"Download Image"})]}),A?i.jsxs("button",{type:"button",className:"rudder-image-preview-action",title:"Show in folder",onClick:()=>y("Show in folder failed",()=>uFe(e.src,e.name)),children:[i.jsx(ho,{className:"size-4","aria-hidden":"true"}),i.jsx("span",{className:"sr-only",children:"Show in folder"})]}):null]}),i.jsx("img",{src:e.src,alt:e.alt,className:"chat-attachment-preview-image",style:h?{width:"100%",height:"100%"}:void 0,onContextMenu:v=>{var O;v.preventDefault(),v.stopPropagation();const w=Yue(v.currentTarget,v.clientX,v.clientY),k=(O=a.current)==null?void 0:O.getBoundingClientRect();f(k?{...w,position:{left:w.position.left-k.left,top:w.position.top-k.top}}:w)}}),u?i.jsx(Wq,{name:u.name,onClose:()=>f(null),position:u.position,portalContainer:a.current,src:u.src,testId:"image-preview-context-menu"}):null]}):null]})})}const ODt={closeImagePreview:()=>{},openImagePreview:()=>{}},mFe=m.createContext(ODt);function jDt({children:e}){const t=br(),[n,r]=m.useState(null),s=m.useCallback(()=>r(null),[]),a=m.useCallback(l=>r(l),[]),o=m.useMemo(()=>({closeImagePreview:s,openImagePreview:a}),[s,a]);return m.useEffect(()=>{s()},[s,t.hash,t.pathname,t.search]),i.jsxs(mFe.Provider,{value:o,children:[e,i.jsx(SDt,{preview:n,onOpenChange:l=>{l||s()},testId:(n==null?void 0:n.testId)??"global-image-preview-dialog",titleFallback:(n==null?void 0:n.titleFallback)??"Image preview"})]})}function OM(){return m.useContext(mFe)}function H2({alt:e,className:t,name:n,previewTestId:r,previewTitleFallback:s,showInspectOverlay:a=!0,src:o,triggerClassName:l,wrapperClassName:c,...d}){const{openImagePreview:u}=OM(),f=m.useRef(null),[A,h]=m.useState(null),g=m.useCallback(()=>h(null),[]),x=()=>{const w=f.current;w&&u({...qq(w),name:n,testId:r,titleFallback:s})},y=w=>{w.preventDefault(),w.stopPropagation(),x()},v=w=>{w.preventDefault(),w.stopPropagation(),h(hFe(w.clientX,w.clientY))};return i.jsxs("span",{className:`rudder-inspectable-image${c?` ${c}`:""}`,children:[i.jsxs("button",{type:"button",className:`rudder-inspectable-image-trigger${l?` ${l}`:""}`,"aria-label":`Open image preview: ${n}`,title:"Open image preview",onClick:y,onDoubleClick:y,onContextMenu:v,children:[i.jsx("img",{...d,ref:f,src:o,alt:e??"",className:t,onContextMenu:v}),a?i.jsx("span",{className:"rudder-inspectable-image-overlay","aria-hidden":"true",children:i.jsx(k2,{className:"size-3.5"})}):null]}),A?i.jsx(Wq,{name:n,onClose:g,onOpen:x,position:A,src:o}):null]})}const CDt=700;function NDt(e){if(!e||typeof window>"u")return null;try{const t=window.sessionStorage.getItem(e);if(t===null)return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}catch{return null}}function PDt(e,t){if(!(!e||typeof window>"u"))try{window.sessionStorage.setItem(e,String(t))}catch{}}function vs(e){const t=m.useRef(null),n=m.useRef(null);return m.useCallback(r=>{var o;if((o=t.current)==null||o.call(t),t.current=null,n.current&&(clearTimeout(n.current),n.current=null),!r)return;const s=NDt(e);s!==null&&requestAnimationFrame(()=>{r.scrollTop=s});const a=()=>{r.classList.add("is-scrolling"),PDt(e,r.scrollTop),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{r.classList.remove("is-scrolling"),n.current=null},CDt)};r.addEventListener("scroll",a,{passive:!0}),t.current=()=>{r.removeEventListener("scroll",a),n.current&&(clearTimeout(n.current),n.current=null),r.classList.remove("is-scrolling")}},[e])}const IDt="rudder.libraryEntryCache",Pve=300*1e3,TDt="rudder.selectedOrganizationId",AN=new Map;function pFe(e,t){return`${e}:library-entry:${t}`}function _re(){return Date.now()}function gFe(e){return!!(e&&e.expiresAt>_re())}function _Dt(e,t){return`${IDt}.${e}.${t}`}function MDt(e){return typeof e=="string"&&e.trim().length>0?e:null}function EDt(e,t){var n;if(typeof window>"u")return null;try{const r=(n=window.sessionStorage)==null?void 0:n.getItem(_Dt(e,t));if(!r)return null;const s=JSON.parse(r),a=MDt(s==null?void 0:s.currentPath);return a?{currentPath:a}:null}catch{return null}}function DDt(){var e;return typeof window>"u"||typeof((e=window.localStorage)==null?void 0:e.getItem)!="function"?null:window.localStorage.getItem(TDt)}function RDt(e,t){if(!e||!t)return null;const n=AN.get(pFe(e,t));return gFe(n)&&(n!=null&&n.entry)?n.entry:EDt(e,t)}function xFe(e,t){const n=pFe(e,t),r=AN.get(n);if(gFe(r)){if(r!=null&&r.entry)return Promise.resolve(r.entry);if(r!=null&&r.promise)return r.promise}const s=En.getLibraryEntry(e,t).then(a=>(AN.set(n,{entry:a,expiresAt:_re()+Pve}),a)).catch(a=>{throw AN.delete(n),a});return AN.set(n,{promise:s,expiresAt:_re()+Pve}),s}function LDt(e,t){!e||!t||xFe(e,t).catch(()=>{})}const zDt={backlog:"text-orange-500 dark:text-orange-400",todo:"text-muted-foreground",in_progress:"text-yellow-600 dark:text-yellow-400",in_review:"text-violet-600 dark:text-violet-400",done:"text-green-600 dark:text-green-400",cancelled:"text-neutral-500 dark:text-neutral-400",blocked:"text-red-600 dark:text-red-400"},$Dt="text-muted-foreground",uC={backlog:"text-muted-foreground",todo:"text-blue-600 dark:text-blue-400",in_progress:"text-yellow-600 dark:text-yellow-400",in_review:"text-violet-600 dark:text-violet-400",done:"text-green-600 dark:text-green-400"},jM={active:"border-green-200/80 bg-green-100/85 text-green-800 dark:border-green-700/50 dark:bg-green-900/30 dark:text-green-200",running:"border-cyan-200/80 bg-cyan-100/85 text-cyan-800 dark:border-cyan-700/50 dark:bg-cyan-900/30 dark:text-cyan-200",paused:"border-orange-200/80 bg-orange-100/85 text-orange-800 dark:border-orange-700/50 dark:bg-orange-900/30 dark:text-orange-200",idle:"border-yellow-200/80 bg-yellow-100/85 text-yellow-800 dark:border-yellow-700/50 dark:bg-yellow-900/30 dark:text-yellow-200",archived:"border-[color:var(--border-soft)] bg-muted text-muted-foreground",planned:"border-[color:var(--border-soft)] bg-muted text-muted-foreground",achieved:"border-green-200/80 bg-green-100/85 text-green-800 dark:border-green-700/50 dark:bg-green-900/30 dark:text-green-200",completed:"border-green-200/80 bg-green-100/85 text-green-800 dark:border-green-700/50 dark:bg-green-900/30 dark:text-green-200",failed:"border-red-200/80 bg-red-100/85 text-red-800 dark:border-red-700/50 dark:bg-red-900/30 dark:text-red-200",timed_out:"border-orange-200/80 bg-orange-100/85 text-orange-800 dark:border-orange-700/50 dark:bg-orange-900/30 dark:text-orange-200",succeeded:"border-green-200/80 bg-green-100/85 text-green-800 dark:border-green-700/50 dark:bg-green-900/30 dark:text-green-200",error:"border-red-200/80 bg-red-100/85 text-red-800 dark:border-red-700/50 dark:bg-red-900/30 dark:text-red-200",terminated:"border-red-200/80 bg-red-100/85 text-red-800 dark:border-red-700/50 dark:bg-red-900/30 dark:text-red-200",pending:"border-yellow-200/80 bg-yellow-100/85 text-yellow-800 dark:border-yellow-700/50 dark:bg-yellow-900/30 dark:text-yellow-200",pending_approval:"border-amber-200/80 bg-amber-100/85 text-amber-800 dark:border-amber-700/50 dark:bg-amber-900/30 dark:text-amber-200",revision_requested:"border-amber-200/80 bg-amber-100/85 text-amber-800 dark:border-amber-700/50 dark:bg-amber-900/30 dark:text-amber-200",approved:"border-green-200/80 bg-green-100/85 text-green-800 dark:border-green-700/50 dark:bg-green-900/30 dark:text-green-200",rejected:"border-red-200/80 bg-red-100/85 text-red-800 dark:border-red-700/50 dark:bg-red-900/30 dark:text-red-200",backlog:"border-[color:var(--border-soft)] bg-muted text-muted-foreground",todo:"border-blue-200/80 bg-blue-100/85 text-blue-800 dark:border-blue-700/50 dark:bg-blue-900/30 dark:text-blue-200",in_progress:"border-yellow-200/80 bg-yellow-100/85 text-yellow-800 dark:border-yellow-700/50 dark:bg-yellow-900/30 dark:text-yellow-200",in_review:"border-violet-200/80 bg-violet-100/85 text-violet-800 dark:border-violet-700/50 dark:bg-violet-900/30 dark:text-violet-200",blocked:"border-red-200/80 bg-red-100/85 text-red-800 dark:border-red-700/50 dark:bg-red-900/30 dark:text-red-200",done:"border-green-200/80 bg-green-100/85 text-green-800 dark:border-green-700/50 dark:bg-green-900/30 dark:text-green-200",cancelled:"border-[color:var(--border-soft)] bg-muted text-muted-foreground"},CM="border-[color:var(--border-soft)] bg-muted text-muted-foreground",FDt={running:"bg-cyan-400 animate-pulse",active:"bg-green-400",paused:"bg-yellow-400",idle:"bg-yellow-400",pending_approval:"bg-amber-400",error:"bg-red-400",archived:"bg-neutral-400"},BDt="bg-neutral-400",mR={critical:"text-orange-600 dark:text-orange-400",high:"text-orange-500 dark:text-orange-400",medium:"text-orange-400 dark:text-orange-300/80",low:"text-orange-300 dark:text-orange-300/55"},SI={critical:{value:"critical",label:"Urgent",level:4,color:mR.critical,menuLabelClassName:"font-medium text-orange-700 dark:text-orange-300"},high:{value:"high",label:"High",level:3,color:mR.high,menuLabelClassName:"font-medium text-orange-600 dark:text-orange-300"},medium:{value:"medium",label:"Medium",level:2,color:mR.medium,menuLabelClassName:"font-medium text-foreground"},low:{value:"low",label:"Low",level:1,color:mR.low,menuLabelClassName:"font-medium text-muted-foreground"}},bFe=["critical","high","medium","low"],QDt=bFe.map(e=>SI[e]);function UDt(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function yFe(e){return SI[e]??SI.medium}function sd(e){var t;return((t=SI[e])==null?void 0:t.label)??UDt(e)}function Sf({className:e,size:t="default",...n}){return i.jsx(pht,{"data-slot":"avatar","data-size":t,className:q("group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6 data-[size=xs]:size-5",e),...n})}function VDt({className:e,...t}){return i.jsx(ght,{"data-slot":"avatar-image",className:q("aspect-square size-full",e),...t})}function Of({className:e,...t}){return i.jsx(xht,{"data-slot":"avatar-fallback",className:q("bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs group-data-[size=xs]/avatar:text-[10px]",e),...t})}function vFe({className:e,...t}){return i.jsx("div",{"data-slot":"avatar-group",className:q("*:data-[slot=avatar]:ring-background group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2",e),...t})}function wFe({className:e,...t}){return i.jsx("div",{"data-slot":"avatar-group-count",className:q("bg-muted text-muted-foreground ring-background relative flex size-8 shrink-0 items-center justify-center rounded-full text-sm ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",e),...t})}const qDt={xs:"text-sm",sm:"text-xs",default:"text-sm",lg:"text-sm"},KDt={xs:"h-3 w-3 text-[10px]",sm:"h-3 w-3 text-xs",default:"h-4 w-4 text-sm",lg:"h-4.5 w-4.5 text-base"};function gg({icon:e,role:t,fallbackSeed:n,className:r,style:s}){const o=ym(e)??Due(t),l=s9(o)??Mue(n);if(l){const d=nB(o);return i.jsx("img",{src:l,alt:"",className:q("inline-flex rounded-full object-cover",r),style:{background:d==="oreo"?void 0:xk(o).background,...Eue(o),...s},loading:"lazy"})}const c=Rue(o);return i.jsx(c,{className:r})}function uu({name:e,icon:t,role:n,size:r="default",className:s}){const a=ym(t)??Due(n),o=s9(a)??Mue(e);return i.jsxs("span",{className:q("inline-flex gap-1.5",r==="xs"?"items-baseline gap-1":"items-center",r==="lg"&&"gap-2",s),children:[i.jsx(Sf,{size:r,className:r==="xs"?"relative -top-px":void 0,children:o?i.jsx(gg,{icon:a,fallbackSeed:e,className:"size-full"}):i.jsx(Of,{children:i.jsx(gg,{icon:a,className:KDt[r]})})}),i.jsx("span",{className:q("truncate",qDt[r]),children:e})]})}function es({...e}){return i.jsx(qV,{"data-slot":"popover",...e})}function bs({...e}){return i.jsx(Mgt,{"data-slot":"popover-trigger",...e})}function ts({className:e,align:t="center",sideOffset:n=4,disablePortal:r=!1,...s}){const a=i.jsx(lMe,{"data-slot":"popover-content",align:t,sideOffset:n,className:q("motion-surface-pop bg-popover text-popover-foreground z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...s});return r?a:i.jsx(KV,{children:a})}function aB({...e}){return i.jsx(oMe,{"data-slot":"popover-anchor",...e})}const WDt=["h-1","h-1.5","h-2.5","h-3.5"],kFe="w-48 rounded-lg border-[color:var(--border-base)] bg-[color:var(--surface-overlay)] p-1.5 shadow-[var(--shadow-md)]";function Zq({priority:e,className:t}){const n=yFe(e);return i.jsx("span",{"data-slot":"priority-bars-icon",className:q("inline-flex h-3.5 w-4 items-end gap-[2px]",n.color,t),"aria-hidden":"true",children:WDt.map((r,s)=>i.jsx("span",{className:q("w-[3px] rounded-[1px] bg-current",r,s>=n.level&&"opacity-25")},r))})}function SFe({priority:e,selected:t,onSelect:n}){const r=SI[e];return i.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":t,className:q("group flex h-8 w-full items-center justify-between gap-3 rounded-md px-2 text-left text-sm transition-colors hover:bg-[color:var(--surface-active)] focus-visible:bg-[color:var(--surface-active)] focus-visible:outline-none",t&&"bg-[color:color-mix(in_oklab,var(--surface-active)_72%,transparent)] text-foreground"),onClick:()=>n(e),children:[i.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[i.jsx(Zq,{priority:e,className:"shrink-0"}),i.jsx("span",{className:q("truncate",r.menuLabelClassName),children:r.label})]}),t?i.jsx(Zi,{"data-slot":"priority-menu-check",className:"h-4 w-4 shrink-0 text-muted-foreground"}):i.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"})]})}function ql({priority:e,onChange:t,className:n,showLabel:r}){const[s,a]=m.useState(!1),o=yFe(e),l=i.jsx("span",{className:q("inline-flex items-center justify-center shrink-0",t&&!r&&"cursor-pointer",n),children:i.jsx(Zq,{priority:e})});if(!t)return r?i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l,i.jsx("span",{className:"text-sm",children:o.label})]}):l;const c=r?i.jsxs("button",{type:"button","aria-label":`Edit priority, current priority ${o.label}`,className:"-mx-1 inline-flex cursor-pointer items-center gap-1.5 rounded-md px-1 py-0.5 transition-colors hover:bg-[color:var(--surface-active)]",children:[l,i.jsx("span",{className:"text-sm",children:o.label})]}):l;return i.jsxs(es,{open:s,onOpenChange:a,children:[i.jsx(bs,{asChild:!0,children:c}),i.jsx(ts,{className:kFe,align:"start",role:"menu","aria-label":"Issue priority",children:bFe.map(d=>{const u=d===e;return i.jsx(SFe,{priority:d,selected:u,onSelect:f=>{t(f),a(!1)}},d)})})]})}const ZDt="linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%)",HDt=/^#[0-9a-fA-F]{6}$/,XDt=/^#[0-9a-fA-F]{3}$/,GDt=/^linear-gradient\(\s*(?:\d{1,3}deg|to\s+(?:top|bottom|left|right)(?:\s+(?:top|bottom|left|right))?)\s*,\s*#[0-9a-fA-F]{6}(?:\s+\d{1,3}%?)?\s*,\s*#[0-9a-fA-F]{6}(?:\s+\d{1,3}%?)?\s*\)$/;function YDt(e){const t=e.slice(1).toLowerCase();return`#${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`}function Jue(e,t=ZDt){const n=e==null?void 0:e.trim();return n?HDt.test(n)?n.toLowerCase():XDt.test(n)?YDt(n):GDt.test(n)?n:t:t}function JDt(e){return{background:Jue(e)}}function eRt(e){var r;const n=(r=Jue(e).match(/#[0-9a-fA-F]{6}/))==null?void 0:r[0];return(n==null?void 0:n.toLowerCase())??"#6366f1"}function efe(e){return{"--project-color":Jue(e),"--project-accent-color":eRt(e)}}const tRt={xs:"h-4 w-4 rounded-[calc(var(--radius-sm)-3px)]",sm:"h-5 w-5 rounded-[calc(var(--radius-sm)-2px)]",md:"h-6 w-6 rounded-[calc(var(--radius-sm)-1px)]",lg:"h-9 w-9 rounded-[var(--radius-sm)]"},nRt={xs:"h-4 w-4",sm:"h-[18px] w-[18px]",md:"h-5 w-5",lg:"h-7 w-7"};function Ao({color:e,icon:t,size:n="sm",className:r,iconClassName:s,label:a,testId:o}){const l=Uq(t);return i.jsx("span",{"data-testid":o,className:q("inline-flex shrink-0 items-center justify-center text-[color:var(--project-accent-color)]",tRt[n],r),style:efe(e),"aria-label":a,"aria-hidden":a?void 0:!0,children:i.jsx(l,{className:q(nRt[n],s),strokeWidth:2.3})})}const tfe=m.forwardRef(({projectColor:e,projectIcon:t,label:n,className:r,title:s,...a},o)=>i.jsx("button",{...a,ref:o,type:"button",className:q("inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-[calc(var(--radius-sm)-1px)] outline-none transition-[box-shadow,transform] hover:scale-[1.03] focus-visible:ring-2 focus-visible:ring-ring",r),"aria-label":n,title:s??n,children:i.jsx(Ao,{color:e,icon:t,size:"lg"})}));tfe.displayName="ProjectIdentityTriggerButton";function OFe({color:e,icon:t,onColorChange:n,onIconChange:r,className:s}){const a=Qq(t);return i.jsxs("div",{className:q("w-72 space-y-3 p-2",s),style:efe(e),children:[i.jsx("div",{className:"grid grid-cols-6 gap-1.5","aria-label":"Project colors",children:KN.map(o=>{const l=o===e;return i.jsx("button",{type:"button",className:q("relative h-7 w-7 rounded-[calc(var(--radius-sm)-1px)] outline-none transition-[box-shadow,transform] hover:scale-[1.04] focus-visible:ring-2 focus-visible:ring-ring",l?"ring-2 ring-foreground ring-offset-1 ring-offset-background":"ring-1 ring-[color:color-mix(in_oklab,var(--border-base)_72%,transparent)]"),style:JDt(o),"aria-label":"Select project color","aria-pressed":l,onClick:()=>n(o)},o)})}),i.jsx(rRt,{icon:a,onIconChange:r}),i.jsxs("div",{className:"flex items-center gap-2 rounded-[calc(var(--radius-sm)-1px)] border border-border/70 bg-muted/35 px-2 py-1.5",children:[i.jsx(Ao,{color:e,icon:a||sq,size:"lg"}),i.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:a})]})]})}function rRt({icon:e,selectedIcon:t,onIconChange:n,ariaLabel:r="Project icons"}){const s=t===null?null:Qq(t??e);return i.jsx("div",{className:"grid grid-cols-6 gap-1.5","aria-label":r,children:G_.map(a=>{const o=Uq(a),l=a===s;return i.jsxs("button",{type:"button",className:q("relative inline-flex h-9 w-9 items-center justify-center rounded-[calc(var(--radius-sm)-1px)] border text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",l?"border-[color:color-mix(in_oklab,var(--project-accent-color)_54%,var(--border-base))] bg-muted/55 text-[color:var(--project-accent-color)]":"border-border/70 bg-transparent"),"aria-label":`Select ${a} project icon`,"aria-pressed":l,onClick:()=>n(a),children:[i.jsx(o,{className:"h-5 w-5",strokeWidth:2.2}),l?i.jsx(Zi,{className:"absolute h-2.5 w-2.5 translate-x-3 translate-y-3 text-[color:var(--project-accent-color)]"}):null]},a)})})}const jFe=["backlog","todo","in_progress","in_review","done","cancelled","blocked"],sRt="w-48 rounded-lg border-[color:var(--border-base)] bg-[color:var(--surface-overlay)] p-1.5 shadow-[var(--shadow-md)]";function Mre(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function CFe({status:e,className:t,dataSlot:n="issue-status-icon"}){const r=zDt[e]??$Dt,s=jFe.includes(e)?e:"default";return i.jsx("span",{"data-slot":n,"data-status":e,className:q("inline-flex h-4 w-4 shrink-0 items-center justify-center",r,t),"aria-hidden":"true",children:i.jsxs("svg",{viewBox:"0 0 16 16",className:"h-full w-full overflow-visible text-current",fill:"none",children:[s==="backlog"&&i.jsx("circle",{"data-slot":"status-backlog-ring",cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"1 3",strokeLinecap:"round"}),s==="todo"&&i.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"2"}),s==="in_progress"&&i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"2",opacity:"0.22"}),i.jsx("path",{"data-slot":"status-progress-arc",d:"M8 2.5a5.5 5.5 0 0 1 5.5 5.5",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round"}),i.jsx("path",{d:"M13.5 8a5.5 5.5 0 0 1-5.5 5.5",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",opacity:"0.72"})]}),s==="in_review"&&i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"2"}),i.jsx("circle",{"data-slot":"status-review-dot",cx:"8",cy:"8",r:"2",fill:"currentColor"})]}),s==="done"&&i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"8",cy:"8",r:"6.5",fill:"currentColor"}),i.jsx("path",{"data-slot":"status-done-check",d:"M4.75 8.25 7 10.5l4.25-5",stroke:"var(--background)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),s==="cancelled"&&i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"currentColor",opacity:"0.16"}),i.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"2"}),i.jsx("path",{"data-slot":"status-cancel-mark",d:"m5.25 5.25 5.5 5.5m0-5.5-5.5 5.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),s==="blocked"&&i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M5.1 2.25h5.8l3.05 3.05v5.4l-3.05 3.05H5.1L2.05 10.7V5.3Z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),i.jsx("path",{"data-slot":"status-blocked-mark",d:"m5.25 5.25 5.5 5.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),s==="default"&&i.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"2"})]})})}function iRt({status:e,selected:t,onSelect:n}){return i.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":t,className:q("group flex h-8 w-full items-center justify-between gap-3 rounded-md px-2 text-left text-sm transition-colors hover:bg-[color:var(--surface-active)] focus-visible:bg-[color:var(--surface-active)] focus-visible:outline-none",t&&"bg-[color:color-mix(in_oklab,var(--surface-active)_72%,transparent)] text-foreground"),onClick:()=>n(e),children:[i.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[i.jsx(CFe,{status:e}),i.jsx("span",{className:"truncate",children:Mre(e)})]}),t?i.jsx(Zi,{"data-slot":"status-menu-check",className:"h-4 w-4 shrink-0 text-muted-foreground"}):i.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"})]})}function ni({status:e,onChange:t,className:n,showLabel:r,dataSlot:s}){const[a,o]=m.useState(!1),l=i.jsx(CFe,{status:e,className:n,dataSlot:s});if(!t)return r?i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l,i.jsx("span",{className:"text-sm",children:Mre(e)})]}):l;const c=r?i.jsxs("button",{type:"button",className:"-mx-1 inline-flex cursor-pointer items-center gap-1.5 rounded-md px-1 py-0.5 transition-colors hover:bg-[color:var(--surface-active)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",children:[l,i.jsx("span",{className:"text-sm",children:Mre(e)})]}):i.jsx("button",{type:"button",className:"inline-flex cursor-pointer items-center justify-center rounded-sm transition-colors hover:bg-[color:var(--surface-active)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",children:l});return i.jsxs(es,{open:a,onOpenChange:o,children:[i.jsx(bs,{asChild:!0,children:c}),i.jsx(ts,{className:sRt,align:"start",role:"menu","aria-label":"Issue status",children:jFe.map(d=>i.jsx(iRt,{status:d,selected:d===e,onSelect:u=>{t(u),o(!1)}},d))})]})}const aRt=600*1e3,Ive=1e3,oRt=160,lRt=new Map,cRt=new Map;function dRt(){return DDt()}function ZS(e){return e?e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase()):null}function NFe(e,t=220){const n=(e==null?void 0:e.replace(/\s+/g," ").trim())??"";return n?n.length>t?`${n.slice(0,t-1).trimEnd()}...`:n:null}function Hq(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=t.split(/\n\s*\n/u).map(s=>s.trim()).filter(Boolean),r=n.find(s=>!/^#{1,6}\s+/u.test(s))??n[0]??t;return NFe(r.replace(/^#{1,6}\s+/gm,""))}function PFe(e){return((e==null?void 0:e.split("/").filter(Boolean))??[]).at(-1)??e??"Library item"}function IFe(e){return e?e.length>8?e.slice(0,8):e:null}function TFe(e,t,n,r=aRt){const s=Date.now(),a=e.get(t);if(a&&a.expiresAt>s)return a.promise;const o=n().catch(l=>{throw e.delete(t),l});return e.set(t,{expiresAt:s+r,promise:o}),o}function _Fe(e,t){return TFe(cRt,`${t}:agent:${e}`,()=>_n.get(e,t))}function uRt(e,t){return e.kind==="issue"?`${t}:issue:${e.issueId}:${e.commentId??""}`:e.kind==="agent"?`${t}:agent:${e.agentId}`:e.kind==="project"?`${t}:project:${e.projectId}`:e.kind==="library_doc"?`${t}:library_doc:${e.documentId}`:e.kind==="library_entry"?`${t}:library_entry:${e.entryId}`:e.kind==="library_file"?`${t}:library_file:${e.filePath}`:`${t}:library_directory:${e.directoryPath}`}async function Tve(e,t){if(!e)return null;try{const n=await _Fe(e,t);return{name:n.name,icon:n.icon,role:n.role}}catch{return{name:`agent ${IFe(e)}`,icon:null,role:null}}}async function fRt(e,t){var l,c;const[n,r]=await Promise.all([fr.getComment(e.issueId,e.commentId),fr.get(e.issueId).catch(()=>null)]),s=e.ref??"Issue",a=((l=r==null?void 0:r.title)==null?void 0:l.trim())||s,o=((c=n.body)==null?void 0:c.trim())||null;return{kind:"issue_comment",eyebrow:`${s} comment`,title:a,rows:[],summary:o?null:"No comment body.",body:o}}async function ARt(e,t){if(e.commentId)return fRt(e);const n=await fr.get(e.issueId),r=n.project,[s,a,o]=await Promise.all([Tve(n.assigneeAgentId,t),Tve(n.reviewerAgentId,t),r!=null&&r.color||r!=null&&r.icon?Promise.resolve(r):n.projectId&&!(r!=null&&r.name)?Ii.get(n.projectId,t).catch(()=>null):Promise.resolve(null)]),l=(r==null?void 0:r.name)??(o==null?void 0:o.name)??null,c=o??r??null;return{kind:"issue",eyebrow:n.identifier??e.ref??"Issue",title:n.title,status:n.status,rows:[{label:"Status",value:ZS(n.status),issueStatus:n.status},{label:"Priority",value:sd(n.priority),priority:n.priority},{label:"Project",value:l,project:l?{color:(c==null?void 0:c.color)??null,icon:(c==null?void 0:c.icon)??null}:void 0},{label:"Assignee",value:s==null?void 0:s.name,agent:s?{icon:s.icon,role:s.role}:void 0},{label:"Reviewer",value:a==null?void 0:a.name,agent:a?{icon:a.icon,role:a.role}:void 0}],summary:Hq(n.description)}}function hRt(e){return{kind:"agent",eyebrow:"Agent",title:e.name,subtitle:e.title??ZS(e.role),status:ZS(e.status)??e.status,icon:e.icon,role:e.role,summary:NFe(e.capabilities)}}function mRt(e,t){return{kind:"agent",eyebrow:"Agent",title:t.replace(/^@(?=\S)/,"")||`Agent ${IFe(e.agentId)??""}`.trim(),subtitle:null,status:"",icon:e.icon,role:null,summary:null}}function pRt(e){var r;const t=e.goals.length>0?e.goals.map(s=>s.title).slice(0,2).join(", "):null,n=((r=e.primaryWorkspace)==null?void 0:r.cwd)??e.codebase.repoName??e.codebase.repoUrl??e.codebase.effectiveLocalFolder??null;return{kind:"project",eyebrow:"Project",title:e.name,color:e.color,icon:e.icon,rows:[{label:"Status",value:ZS(e.status)},{label:"Goal",value:t},{label:"Context",value:n}],summary:Hq(e.description)}}function gRt(e){return e.previewKind==="text"?Hq(e.content)??(e.truncated?"Text preview is truncated.":null):e.previewKind==="image"?"Image file.":e.previewKind==="pdf"?"PDF file.":e.message??"Preview is not available for this file type."}function xRt(e){return{kind:"library",eyebrow:"Library document",title:e.title??"Untitled document",icon:"file",rows:[{label:"Revision",value:String(e.latestRevisionNumber)},{label:"Format",value:ZS(e.format)}],summary:Hq(e.body)}}function _ve(e,t){return{kind:"library",eyebrow:e.previewKind==="text"?"Library file":"Library asset",title:t??PFe(e.filePath),icon:"file",rows:[{label:"Path",value:e.filePath},{label:"Type",value:e.contentType}],summary:gRt(e)}}async function bRt(e,t,n){if(e.kind==="issue")return ARt(e,n);if(e.kind==="agent")return hRt(await _Fe(e.agentId,n));if(e.kind==="project")return pRt(await Ii.get(e.projectId,n));if(e.kind==="library_doc")return xRt(await En.getLibraryDocument(n,e.documentId));if(e.kind==="library_entry"){const r=await xFe(n,e.entryId);return r.status!=="active"||!r.currentPath?{kind:"library",eyebrow:"Library file",title:r.title||t,icon:"file",rows:[{label:"Path",value:r.currentPath??e.path},{label:"Status",value:ZS(r.status)}],summary:"This Library reference is not currently readable."}:_ve(await En.readWorkspaceFile(n,r.currentPath),r.title)}return e.kind==="library_file"?_ve(await En.readWorkspaceFile(n,e.filePath),e.title):{kind:"library",eyebrow:"Library folder",title:e.title??PFe(e.directoryPath),icon:"folder",rows:[{label:"Path",value:e.directoryPath}],summary:"Open the folder to inspect its files."}}function yRt(e,t,n){return TFe(lRt,uRt(e,n),()=>bRt(e,t,n))}function vRt({row:e}){return e.issueStatus?i.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center","aria-hidden":"true",children:i.jsx(ni,{status:e.issueStatus,className:"size-3.5"})}):e.priority?i.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center","aria-hidden":"true",children:i.jsx(ql,{priority:e.priority,className:"h-3.5 w-4"})}):e.agent?i.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center","aria-hidden":"true",children:i.jsx(gg,{icon:e.agent.icon,role:e.agent.role,fallbackSeed:e.value,className:"size-4 rounded-full"})}):e.project?i.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center","aria-hidden":"true",children:i.jsx(Ao,{color:e.project.color,icon:e.project.icon,size:"xs"})}):null}function Mve({rows:e}){const t=e.filter(n=>n.value);return t.length===0?null:i.jsx("span",{className:"rudder-entity-preview-rows",children:t.map(n=>i.jsxs("span",{className:"rudder-entity-preview-row",children:[i.jsx("span",{className:"rudder-entity-preview-row-label",children:n.label}),i.jsxs("span",{className:"rudder-entity-preview-row-value",children:[i.jsx(vRt,{row:n}),i.jsx("span",{className:"rudder-entity-preview-row-value-text",children:n.value})]})]},n.label))})}function wRt({preview:e}){if(e.kind==="agent")return i.jsx(gg,{icon:e.icon,role:e.role,fallbackSeed:e.title,className:"rudder-entity-preview-main-icon rudder-entity-preview-main-icon--agent"});if(e.kind==="issue")return i.jsx(ni,{status:e.status,className:"rudder-entity-preview-main-icon"});if(e.kind==="issue_comment")return i.jsx("span",{className:"rudder-entity-preview-main-icon rudder-entity-preview-main-icon--comment","data-slot":"issue-comment-preview-icon",children:i.jsx(fM,{className:"size-4","aria-hidden":"true"})});if(e.kind==="project")return i.jsx(Ao,{color:e.color,icon:e.icon,size:"sm",className:"rudder-entity-preview-main-icon--project"});const t=e.icon==="folder"?ho:Fi;return i.jsx("span",{className:"rudder-entity-preview-main-icon rudder-entity-preview-main-icon--library",children:i.jsx(t,{className:"size-4","aria-hidden":"true"})})}function EX({preview:e}){return i.jsxs("span",{className:"rudder-entity-preview-head",children:[i.jsx(wRt,{preview:e}),i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"rudder-entity-preview-eyebrow",children:e.eyebrow}),i.jsx("span",{className:"rudder-entity-preview-title",children:e.title}),e.kind==="agent"&&e.subtitle?i.jsx("span",{className:"rudder-entity-preview-subtitle",children:e.subtitle}):null]})]})}const MFe={a:({node:e,href:t,children:n,...r})=>{const s=SRt(t);return s?i.jsx("a",{...r,href:s,target:s.startsWith("http")?"_blank":void 0,rel:"noreferrer",children:n}):i.jsx("span",{children:n})},img:({node:e,src:t,alt:n,...r})=>{const s=t??"";return i.jsx(H2,{...r,src:s,alt:n??"",name:Kq(n,s),loading:"lazy",previewTestId:"entity-image-preview-dialog",previewTitleFallback:"Image preview"})}};function kRt(){return typeof window>"u"?null:Ng(window.location.pathname)}function SRt(e){const t=e==null?void 0:e.trim();if(!t)return null;const n=$c(t);if(n)return Yc(w6(n),kRt());if(t.startsWith("/")||t.startsWith("#")||!/^[a-z][a-z\d+.-]*:/iu.test(t)&&!t.startsWith("//"))return t;try{const r=new URL(t);if(r.protocol==="http:"||r.protocol==="https:")return t}catch{return null}return null}function ORt({body:e}){const t=vs(),n=Zue(e);return i.jsx("div",{ref:t,className:"rudder-entity-preview-comment-body scrollbar-auto-hide","data-testid":"issue-comment-preview-body",children:i.jsx(Oue,{remarkPlugins:[Lq],components:MFe,urlTransform:r=>r,children:n})})}function DX({summary:e}){const t=vs(),n=Zue(e);return i.jsx("div",{ref:t,className:"rudder-entity-preview-summary scrollbar-auto-hide",children:i.jsx(Oue,{remarkPlugins:[Lq],components:MFe,urlTransform:r=>r,children:n})})}function jRt({preview:e}){return e.kind==="agent"?i.jsxs(i.Fragment,{children:[i.jsx(EX,{preview:e}),i.jsx(Mve,{rows:[{label:"Status",value:e.status}]}),e.summary?i.jsx(DX,{summary:e.summary}):null]}):e.kind==="issue_comment"?i.jsxs(i.Fragment,{children:[i.jsx(EX,{preview:e}),e.body?i.jsx(ORt,{body:e.body}):null,e.summary?i.jsx(DX,{summary:e.summary}):null]}):i.jsxs(i.Fragment,{children:[i.jsx(EX,{preview:e}),i.jsx(Mve,{rows:e.rows}),e.summary?i.jsx(DX,{summary:e.summary}):null]})}function Xq({mention:e,label:t,children:n}){const[r,s]=m.useState(!1),[a,o]=m.useState(!1),[l,c]=m.useState({status:"idle"}),d=m.useRef(!1),u=m.useRef(null),f=m.useRef(null),A=m.useRef(null),h=m.useMemo(dRt,[]);m.useEffect(()=>{e.kind==="library_entry"&&LDt(h,e.entryId)},[e,h]);const g=()=>{u.current&&(clearTimeout(u.current),u.current=null)},x=()=>{f.current&&(clearTimeout(f.current),f.current=null)};m.useEffect(()=>{if(!r||d.current)return;if(d.current=!0,!h){c({status:"error",message:"Preview unavailable outside an organization."});return}let O=!1;return e.kind==="agent"?c({status:"ready",preview:mRt(e,t)}):c({status:"loading"}),yRt(e,t,h).then(j=>{O||c({status:"ready",preview:j})}).catch(()=>{O||c({status:"error",message:"Preview unavailable."})}),()=>{O=!0}},[r,t,e,h]),m.useEffect(()=>()=>{u.current&&clearTimeout(u.current),f.current&&clearTimeout(f.current)},[]),m.useEffect(()=>{if(!a)return;const O=j=>{var I;const C=j.target;if(!(C instanceof Node))return;if((I=A.current)!=null&&I.contains(C)){x();return}if(Array.from(document.querySelectorAll(".rudder-entity-preview-card")).some(E=>E.contains(C))){x();return}w()};return window.addEventListener("mousemove",O),()=>{window.removeEventListener("mousemove",O)}},[a]);const y=()=>{g(),x(),s(!0),o(!0)},v=()=>{g(),x(),u.current=setTimeout(()=>{u.current=null,y()},Ive)},w=()=>{if(g(),x(),!a){o(!1);return}f.current=setTimeout(()=>{f.current=null,o(!1)},oRt)},k=()=>{g(),x(),o(!1)};return i.jsx(id,{delayDuration:Ive,skipDelayDuration:0,children:i.jsxs(Hi,{open:a,onOpenChange:O=>{O||g(),O?y():w()},children:[i.jsx(Xi,{asChild:!0,children:i.jsx("span",{ref:A,className:"rudder-entity-preview-wrap",onMouseEnter:v,onMouseLeave:w,onFocusCapture:y,onBlurCapture:k,children:n})}),r?i.jsx(Gi,{side:"bottom",align:"center",sideOffset:8,collisionPadding:16,className:q("rudder-entity-preview-card motion-entity-preview-pop",l.status==="loading"&&"rudder-entity-preview-card--loading"),onMouseEnter:y,onMouseLeave:w,children:l.status==="ready"?i.jsx(jRt,{preview:l.preview}):l.status==="error"?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"rudder-entity-preview-eyebrow",children:t}),i.jsx("span",{className:"rudder-entity-preview-empty",children:l.message})]}):i.jsxs(i.Fragment,{children:[i.jsx(Fi,{className:"size-3.5","aria-hidden":"true"}),i.jsx("span",{children:"Loading preview..."})]})}):null]})})}const jv="data-chat-annotation-source",oB="data-chat-annotation-block",D3="data-chat-annotation-ignore",NM="data-chat-annotation-text-ignore",EFe=new WeakMap;function CRt(e,t){EFe.set(e,t)}function NRt(e){return EFe.get(e)??null}const PRt=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home"]);function DFe(e){return e instanceof KeyboardEvent&&e.type==="keyup"&&e.shiftKey&&PRt.has(e.key)}async function Lw(e){const t=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}function U7(e,t){const n=e instanceof HTMLElement?e:e.parentElement;return(n==null?void 0:n.closest(`[${t}]`))??null}const IRt=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DIV","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","LI","MAIN","NAV","P","PRE","SECTION","TR"]);function nfe(e,t,n={value:0}){if(e instanceof Element&&(e.hasAttribute(D3)||e.hasAttribute(NM)))return"";if(e.nodeType===Node.TEXT_NODE){const s=e.textContent??"";return s&&t&&t.push({node:e,start:n.value,end:n.value+s.length}),n.value+=s.length,s}if(e instanceof HTMLBRElement)return n.value+=1,`
|
|
1596
1596
|
`;const r=Array.from(e.childNodes).map(s=>nfe(s,t,n)).join("");return e instanceof HTMLElement&&IRt.has(e.tagName)&&r.length>0?(n.value+=1,`${r}
|
|
1597
|
-
`):r}function j2(e){const t=e.cloneNode(!0);return nfe(t).replace(/^\n+|\n+$/gu,"")}function RFe(e){var a;const t=[],n=nfe(e,t),r=((a=n.match(/^\n+/u))==null?void 0:a[0].length)??0,s=n.replace(/^\n+|\n+$/gu,"").length;return t.map(o=>({...o,start:o.start-r,end:o.end-r})).filter(o=>o.end>0&&o.start<s).map(o=>({...o,start:Math.max(0,o.start),end:Math.min(s,o.end)}))}function LFe(e,t,n){const r=RFe(e);if(t.nodeType===Node.TEXT_NODE){const o=r.find(l=>l.node===t);return o?Math.max(o.start,Math.min(o.end,o.start+n)):null}if(!(t instanceof Element||t instanceof DocumentFragment))return null;const s=t.childNodes[n]??null;if(s){const o=r.find(l=>s===l.node||s.contains(l.node));if(o)return o.start}const a=n>0?t.childNodes[n-1]??null:null;if(a){const o=[...r].reverse().find(l=>a===l.node||a.contains(l.node));if(o)return o.end}return t===e&&n===0?0:t===e&&n===e.childNodes.length?j2(e).length:null}function zFe(e,t,n){const r=LFe(e,t,n);if(r!==null)return j2(e).slice(0,r);const s=document.createRange();s.selectNodeContents(e);try{s.setEnd(t,n)}catch{return null}return j2(s.cloneContents())}function $Fe(e){return j2(e.cloneContents())}function TRt(e,t){var a;if(e[t]!=="&")return null;const n=(a=e.slice(t).match(/^&(?:#[xX][\da-fA-F]+|#\d+|[a-zA-Z][a-zA-Z\d]+);/u))==null?void 0:a[0];if(!n||typeof document>"u")return null;const r=document.createElement("textarea");r.innerHTML=n;const s=r.value;return s.length===1?{decoded:s,length:n.length}:null}function _Rt(e){const t=Array(e.length).fill(!0),n=(r,s)=>{for(let a=r;a<s;a+=1)t[a]=!1};for(const r of e.matchAll(/!?\[[^\]\n]*\]\[[^\]\n]*\]/gu)){const s=r[0],a=r.index,o=s.indexOf("]");s.startsWith("!")?n(a,a+s.length):(n(a,a+1),o>=0&&n(a+o,a+s.length))}for(const r of e.matchAll(/!?\[[^\]\n]*\]\((?:\\.|[^)\n])*\)/gu)){const s=r[0],a=r.index,o=s.indexOf("]");o>=0&&n(a+o,a+s.length),n(a,a+(s.startsWith("!")?2:1))}for(const r of e.matchAll(/!\[[^\]\n]*\](?![\[(])/gu))n(r.index,r.index+r[0].length);for(const r of e.matchAll(/^[\t ]*\[[^\]\n]+\]:[^\n]*$/gmu))n(r.index,r.index+r[0].length);for(const r of e.matchAll(/<\/?[a-zA-Z][^>\n]*>/gu))n(r.index,r.index+r[0].length);return t}function PM(e,t,n=0){const r=[],s=r3t(t,e),a=_Rt(t);let o=0;for(let l=0;l<e.length;l+=1){const c=e[l],d=Math.max(o,s.renderedBoundaryToRaw[l+1]-1);let u=-1,f=-1,A=Number.POSITIVE_INFINITY;const h=(g,x)=>{const y=Math.abs(g-d);(y<A||y===A&&(g>u||g===u&&x>f))&&(u=g,f=x,A=y)};for(let g=t.indexOf(c,o);g>=0&&!(a[g]&&(h(g,g+1),g>=d));g=t.indexOf(c,g+1));for(let g=t.indexOf("&",o);g>=0;g=t.indexOf("&",g+1)){const x=TRt(t,g);if(a[g]&&(x==null?void 0:x.decoded)===c&&(h(g,g+x.length),g>=d))break}if(u<0)return Array.from({length:e.length},(g,x)=>({start:n+s.renderedBoundaryToRaw[x],end:n+s.renderedBoundaryToRaw[x+1]}));r.push({start:n+u,end:n+f}),o=f}return r}function MRt(e,t){const n=e instanceof HTMLElement?e:e.parentElement,r=(n==null?void 0:n.closest("[data-markdown-source-start][data-markdown-source-end]"))??null;return r&&t.contains(r)?r:null}function FFe(e,t){const n=Number(e.dataset.markdownSourceStart),r=Number(e.dataset.markdownSourceEnd);return!Number.isInteger(n)||!Number.isInteger(r)||n<0||r<=n||r>t?null:{start:n,end:r}}function ERt(e,t,n){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(o){return U7(o,D3)||U7(o,NM)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let s=t,a=null;for(let o=r.nextNode();o;o=r.nextNode()){const l=o;a=l;const c=l.data.length;if(s<c||s===c&&n==="end")return{container:l,offset:s};s-=c}return s===0&&a?{container:a,offset:a.data.length}:null}function DRt(e,t,n,r){return Array.from(e.querySelectorAll("[data-markdown-source-start][data-markdown-source-end]")).map(a=>({element:a,bounds:FFe(a,t)})).filter(a=>!!a.bounds).filter(({bounds:a})=>r==="start"?a.start<=n&&n<a.end:a.start<n&&n<=a.end).sort((a,o)=>a.bounds.end-a.bounds.start-(o.bounds.end-o.bounds.start))[0]??null}function Eve(e,t,n,r){const s=DRt(e,t.length,n,r);if(!s)return null;const a=j2(s.element),o=PM(a,t.slice(s.bounds.start,s.bounds.end),s.bounds.start);if(!o)return null;const l=r==="start"?o.findIndex(c=>c.end>n):o.findLastIndex(c=>c.start<n)+1;return l<0?null:ERt(s.element,l,r)}function BFe(e){if(e.start<0||e.end<=e.start||e.end>e.source.length)return null;const t=Eve(e.sourceRoot,e.source,e.start,"start"),n=Eve(e.sourceRoot,e.source,e.end,"end");if(!t||!n)return null;const r=document.createRange();try{r.setStart(t.container,t.offset),r.setEnd(n.container,n.offset)}catch{return null}return r.collapsed?null:r}function RRt(e,t=document){return Array.from(t.querySelectorAll(`[${jv}]`)).find(r=>!r.isConnected||r.dataset.messageId!==e.sourceMessageId||r.dataset.annotationSurface!==e.surface?!1:e.surface==="assistant_body"?!0:r.dataset.transcriptKind===e.transcriptKind&&r.dataset.generationId===e.generationId&&Number(r.dataset.generationSeqStart)===e.generationSeqStart&&Number(r.dataset.generationSeqEnd)===e.generationSeqEnd)??null}function Ere(e){const t=RRt(e.anchor,e.searchRoot);if(!t)return null;const n=BFe({sourceRoot:t,source:e.source,start:e.anchor.start,end:e.anchor.end});return n?{range:n,sourceRoot:t}:null}function Dve(e,t,n,r,s){var u,f;const a=MRt(n,e);if(!a)return null;const o=FFe(a,t.length);if(!o)return null;const l=zFe(a,n,r);if(l===null)return null;const c=j2(a),d=PM(c,t.slice(o.start,o.end),o.start);return d?s==="start"?l.length===d.length?o.end:((u=d[l.length])==null?void 0:u.start)??null:l.length===0?o.start:((f=d[l.length-1])==null?void 0:f.end)??null:null}function Rve(e){var x,y;const{range:t,sourceRoot:n}=e;if(t.collapsed||!n.contains(t.startContainer)||!n.contains(t.endContainer))return null;const r=n.getAttribute(jv),s=U7(t.startContainer,jv),a=U7(t.endContainer,jv);if(!r||s!==n||a!==n||Array.from(n.querySelectorAll(`[${D3}]`)).some(v=>{try{return t.intersectsNode(v)}catch{return!1}}))return null;if(e.surface==="process_transcript"){const v=U7(t.startContainer,oB),w=U7(t.endContainer,oB);if(!v||v!==w)return null}const l=$Fe(t);if(!l)return null;const c=zFe(n,t.startContainer,t.startOffset);if(c===null)return null;const d=Dve(n,e.source,t.startContainer,t.startOffset,"start"),u=Dve(n,e.source,t.endContainer,t.endOffset,"end");let f=d??void 0,A=u??void 0;if(f===void 0||A===void 0){const v=j2(n),w=PM(v,e.source);if(!w)return null;const k=c.length,O=k+l.length;if(k<0||O>w.length||O<=k)return null;f??(f=(x=w[k])==null?void 0:x.start),A??(A=(y=w[O-1])==null?void 0:y.end)}if(f===void 0||A===void 0||A<=f)return null;for(;f<A&&new RegExp("\\p{White_Space}","u").test(e.source[f]??"")&&!l.startsWith(e.source[f]??"");)f+=1;const h=Math.min(160,Math.max(0,e.contextLength??160)),g={selectedText:l,sourceConversationId:e.sourceConversationId,sourceMessageId:e.sourceMessageId,sourceHash:e.sourceHash,start:f,end:A,prefix:e.source.slice(Math.max(0,f-h),f),suffix:e.source.slice(A,A+h)};return e.surface==="process_transcript"?{...g,surface:e.surface,transcriptKind:e.transcriptKind,generationId:e.generationId,generationSeqStart:e.generationSeqStart,generationSeqEnd:e.generationSeqEnd}:{...g,surface:e.surface}}function rfe({label:e,preview:t,fallbackOpenHref:n,sourceAttributes:r,onOpen:s}){var x,y,v,w,k,O;const a=((x=t==null?void 0:t.displayName)==null?void 0:x.trim())||e,o=((y=t==null?void 0:t.description)==null?void 0:y.trim())||null,l=((v=t==null?void 0:t.categoryLabel)==null?void 0:v.trim())||null,c=((w=t==null?void 0:t.locationLabel)==null?void 0:w.trim())||null,d=((k=t==null?void 0:t.detailsHref)==null?void 0:k.trim())||null,u=(n==null?void 0:n.trim())||((O=t==null?void 0:t.openHref)==null?void 0:O.trim())||null,f=!!(o||l||c||d),A=vs(),h=s?u??d:d,g=h?i.jsx("a",{className:"rudder-skill-token","data-skill-token":"true",href:h,"aria-label":`${a} skill`,style:sB(),...r,onClick:j=>s==null?void 0:s(j,h,a),children:e}):i.jsx("span",{className:"rudder-skill-token","data-skill-token":"true",tabIndex:f?0:void 0,"aria-label":f?`${a} skill`:void 0,style:sB(),...r,children:e});return i.jsxs("span",{className:q("rudder-skill-token-wrap",f&&"rudder-skill-token-wrap--preview"),children:[g,f?i.jsxs("span",{ref:A,className:"rudder-skill-hover-card scrollbar-auto-hide",role:"tooltip",[NM]:"",children:[i.jsxs("span",{className:"flex items-start gap-3",children:[i.jsx("span",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-[var(--radius-md)] bg-[#2f80ed]/10 text-[#2f80ed]",children:i.jsx(Lc,{className:"h-4 w-4","aria-hidden":!0})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block break-words text-sm font-medium leading-5 text-foreground",children:a}),l||c?i.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[l?i.jsx("span",{className:"inline-flex items-center rounded-[var(--radius-sm)] border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium leading-none text-muted-foreground",children:l}):null,c?i.jsx("span",{className:"min-w-0 break-all text-[11px] leading-4 text-muted-foreground",children:c}):null]}):null,o?i.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:o}):null]})]}),d?i.jsxs("a",{className:"rudder-skill-hover-card-action",href:d,children:[i.jsx("span",{children:"View details"}),i.jsx(Y1,{className:"h-3.5 w-3.5","aria-hidden":!0})]}):null]}):null]})}let RX=null;function LRt(){return RX||(RX=Wt(()=>import("./mermaid.core-BVJ3bsf4.js").then(e=>e.bo),[]).then(e=>e.default)),RX}function zw(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(t=>zw(t)).join(""):m.isValidElement(e)?zw(e.props.children):""}function pR(e){return(e==null?void 0:e.trim().replace(/\/+$/u,"").toLowerCase())??""}function s0(e){const t=(e==null?void 0:e.trim())??"";if(!t)return"item";const n=t.split(/[-/]/u).find(Boolean);return n&&n.length>=6?n.slice(0,12):t.length>12?t.slice(0,12):t}function LX(e){return((e==null?void 0:e.trim().replace(/\/+$/u,""))??"").split("/").filter(Boolean).at(-1)??""}function zX(e){var t,n,r,s,a,o,l;return e.kind==="agent"?s0(e.agentId):e.kind==="project"?s0(e.projectId):e.kind==="automation"?((t=e.title)==null?void 0:t.trim())||s0(e.automationId):e.kind==="issue"?((n=e.ref)==null?void 0:n.trim())||s0(e.issueId):e.kind==="chat"?((r=e.title)==null?void 0:r.trim())||s0(e.conversationId):e.kind==="library_doc"?((s=e.title)==null?void 0:s.trim())||s0(e.documentId):e.kind==="library_entry"?((a=e.title)==null?void 0:a.trim())||LX(e.path)||s0(e.entryId):e.kind==="library_file"?((o=e.title)==null?void 0:o.trim())||LX(e.filePath)||s0(e.filePath):((l=e.title)==null?void 0:l.trim())||LX(e.directoryPath)||s0(e.directoryPath)}function zRt(e){if(!/[&][#a-z\d]+;/iu.test(e)||typeof document>"u")return e;const t=document.createElement("textarea");return t.innerHTML=e,t.value}function $X(e){return zRt(e).replace(/\s+/gu," ").trim()}function $Rt(){return typeof window>"u"?null:Ng(window.location.pathname)}function FRt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function BRt(e){return e.replace(/([\\[\]])/g,"\\$1")}function QRt(e){return e.trim().replace(/^@+/u,"")}function URt(e){return/^[^\s@,!?.]+$/u.test(e)}function FX(e,t,n){const r=e.indexOf(t,n);return r>=0?r:null}function VRt(e,t){let n=!1;for(let r=t;r<e.length;r+=1){const s=e[r];if(n){n=!1;continue}if(s==="\\"){n=!0;continue}if(s===")")return r}return null}function qRt(e){var o;const t=[];let n=0,r=0;function s(l){l>r&&t.push({text:e.slice(r,l),protected:!1})}function a(l){s(n),t.push({text:e.slice(n,l),protected:!0}),n=l,r=l}for(;n<e.length;){const l=e[n];if(l==="`"){const d=((o=e.slice(n).match(/^`+/u))==null?void 0:o[0])??"`",u=FX(e,d,n+d.length);if(u!==null){a(u+d.length);continue}}const c=l==="["?n:l==="!"&&e[n+1]==="["?n+1:null;if(c!==null){const d=FX(e,"]",c+1);if(d!==null&&e[d+1]==="("){const u=VRt(e,d+2);if(u!==null){a(u+1);continue}}}if(l==="<"){const d=FX(e,">",n+1);if(d!==null){a(d+1);continue}}n+=1}return s(e.length),t}function KRt(e,t){if(!e.includes("@")||!(t!=null&&t.length))return e;const n=t.map(o=>({...o,name:QRt(o.name)})).filter(o=>o.name&&o.agentId&&URt(o.name)).sort((o,l)=>l.name.length-o.name.length);if(n.length===0)return e;const r=new RegExp(`(^|[^\\w/[\\]\`])@(${n.map(o=>FRt(o.name)).join("|")})(?=$|[\\s@,!?.])`,"giu"),s=/^(```|~~~)/;let a=!1;return e.split(/(\n)/).map(o=>o===`
|
|
1597
|
+
`):r}function j2(e){const t=e.cloneNode(!0);return nfe(t).replace(/^\n+|\n+$/gu,"")}function RFe(e){var a;const t=[],n=nfe(e,t),r=((a=n.match(/^\n+/u))==null?void 0:a[0].length)??0,s=n.replace(/^\n+|\n+$/gu,"").length;return t.map(o=>({...o,start:o.start-r,end:o.end-r})).filter(o=>o.end>0&&o.start<s).map(o=>({...o,start:Math.max(0,o.start),end:Math.min(s,o.end)}))}function LFe(e,t,n){const r=RFe(e);if(t.nodeType===Node.TEXT_NODE){const o=r.find(l=>l.node===t);return o?Math.max(o.start,Math.min(o.end,o.start+n)):null}if(!(t instanceof Element||t instanceof DocumentFragment))return null;const s=t.childNodes[n]??null;if(s){const o=r.find(l=>s===l.node||s.contains(l.node));if(o)return o.start}const a=n>0?t.childNodes[n-1]??null:null;if(a){const o=[...r].reverse().find(l=>a===l.node||a.contains(l.node));if(o)return o.end}return t===e&&n===0?0:t===e&&n===e.childNodes.length?j2(e).length:null}function zFe(e,t,n){const r=LFe(e,t,n);if(r!==null)return j2(e).slice(0,r);const s=document.createRange();s.selectNodeContents(e);try{s.setEnd(t,n)}catch{return null}return j2(s.cloneContents())}function $Fe(e){return j2(e.cloneContents())}function TRt(e,t){var a;if(e[t]!=="&")return null;const n=(a=e.slice(t).match(/^&(?:#[xX][\da-fA-F]+|#\d+|[a-zA-Z][a-zA-Z\d]+);/u))==null?void 0:a[0];if(!n||typeof document>"u")return null;const r=document.createElement("textarea");r.innerHTML=n;const s=r.value;return s.length===1?{decoded:s,length:n.length}:null}function _Rt(e){const t=Array(e.length).fill(!0),n=(r,s)=>{for(let a=r;a<s;a+=1)t[a]=!1};for(const r of e.matchAll(/!?\[[^\]\n]*\]\[[^\]\n]*\]/gu)){const s=r[0],a=r.index,o=s.indexOf("]");s.startsWith("!")?n(a,a+s.length):(n(a,a+1),o>=0&&n(a+o,a+s.length))}for(const r of e.matchAll(/!?\[[^\]\n]*\]\((?:\\.|[^)\n])*\)/gu)){const s=r[0],a=r.index,o=s.indexOf("]");o>=0&&n(a+o,a+s.length),n(a,a+(s.startsWith("!")?2:1))}for(const r of e.matchAll(/!\[[^\]\n]*\](?![\[(])/gu))n(r.index,r.index+r[0].length);for(const r of e.matchAll(/^[\t ]*\[[^\]\n]+\]:[^\n]*$/gmu))n(r.index,r.index+r[0].length);for(const r of e.matchAll(/<\/?[a-zA-Z][^>\n]*>/gu))n(r.index,r.index+r[0].length);return t}function PM(e,t,n=0){const r=[],s=r3t(t,e),a=_Rt(t);let o=0;for(let l=0;l<e.length;l+=1){const c=e[l],d=Math.max(o,s.renderedBoundaryToRaw[l+1]-1);let u=-1,f=-1,A=Number.POSITIVE_INFINITY;const h=(g,x)=>{const y=Math.abs(g-d);(y<A||y===A&&(g>u||g===u&&x>f))&&(u=g,f=x,A=y)};for(let g=t.indexOf(c,o);g>=0&&!(a[g]&&(h(g,g+1),g>=d));g=t.indexOf(c,g+1));for(let g=t.indexOf("&",o);g>=0;g=t.indexOf("&",g+1)){const x=TRt(t,g);if(a[g]&&(x==null?void 0:x.decoded)===c&&(h(g,g+x.length),g>=d))break}if(u<0)return Array.from({length:e.length},(g,x)=>({start:n+s.renderedBoundaryToRaw[x],end:n+s.renderedBoundaryToRaw[x+1]}));r.push({start:n+u,end:n+f}),o=f}return r}function MRt(e,t){const n=e instanceof HTMLElement?e:e.parentElement,r=(n==null?void 0:n.closest("[data-markdown-source-start][data-markdown-source-end]"))??null;return r&&t.contains(r)?r:null}function FFe(e,t){const n=Number(e.dataset.markdownSourceStart),r=Number(e.dataset.markdownSourceEnd);return!Number.isInteger(n)||!Number.isInteger(r)||n<0||r<=n||r>t?null:{start:n,end:r}}function ERt(e,t,n){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(o){return U7(o,D3)||U7(o,NM)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let s=t,a=null;for(let o=r.nextNode();o;o=r.nextNode()){const l=o;a=l;const c=l.data.length;if(s<c||s===c&&n==="end")return{container:l,offset:s};s-=c}return s===0&&a?{container:a,offset:a.data.length}:null}function DRt(e,t,n,r){return Array.from(e.querySelectorAll("[data-markdown-source-start][data-markdown-source-end]")).map(a=>({element:a,bounds:FFe(a,t)})).filter(a=>!!a.bounds).filter(({bounds:a})=>r==="start"?a.start<=n&&n<a.end:a.start<n&&n<=a.end).sort((a,o)=>a.bounds.end-a.bounds.start-(o.bounds.end-o.bounds.start))[0]??null}function Eve(e,t,n,r){const s=DRt(e,t.length,n,r);if(!s)return null;const a=j2(s.element),o=PM(a,t.slice(s.bounds.start,s.bounds.end),s.bounds.start);if(!o)return null;const l=r==="start"?o.findIndex(c=>c.end>n):o.findLastIndex(c=>c.start<n)+1;return l<0?null:ERt(s.element,l,r)}function BFe(e){if(e.start<0||e.end<=e.start||e.end>e.source.length)return null;const t=Eve(e.sourceRoot,e.source,e.start,"start"),n=Eve(e.sourceRoot,e.source,e.end,"end");if(!t||!n)return null;const r=document.createRange();try{r.setStart(t.container,t.offset),r.setEnd(n.container,n.offset)}catch{return null}return r.collapsed?null:r}function RRt(e,t=document){return Array.from(t.querySelectorAll(`[${jv}]`)).find(r=>!r.isConnected||r.dataset.messageId!==e.sourceMessageId||r.dataset.annotationSurface!==e.surface?!1:e.surface==="assistant_body"?!0:r.dataset.transcriptKind===e.transcriptKind&&r.dataset.generationId===e.generationId&&Number(r.dataset.generationSeqStart)===e.generationSeqStart&&Number(r.dataset.generationSeqEnd)===e.generationSeqEnd)??null}function Ere(e){const t=RRt(e.anchor,e.searchRoot);if(!t)return null;const n=BFe({sourceRoot:t,source:e.source,start:e.anchor.start,end:e.anchor.end});return n?{range:n,sourceRoot:t}:null}function Dve(e,t,n,r,s){var u,f;const a=MRt(n,e);if(!a)return null;const o=FFe(a,t.length);if(!o)return null;const l=zFe(a,n,r);if(l===null)return null;const c=j2(a),d=PM(c,t.slice(o.start,o.end),o.start);return d?s==="start"?l.length===d.length?o.end:((u=d[l.length])==null?void 0:u.start)??null:l.length===0?o.start:((f=d[l.length-1])==null?void 0:f.end)??null:null}function Rve(e){var x,y;const{range:t,sourceRoot:n}=e;if(t.collapsed||!n.contains(t.startContainer)||!n.contains(t.endContainer))return null;const r=n.getAttribute(jv),s=U7(t.startContainer,jv),a=U7(t.endContainer,jv);if(!r||s!==n||a!==n||Array.from(n.querySelectorAll(`[${D3}]`)).some(v=>{try{return t.intersectsNode(v)}catch{return!1}}))return null;if(e.surface==="process_transcript"){const v=U7(t.startContainer,oB),w=U7(t.endContainer,oB);if(!v||v!==w)return null}const l=$Fe(t);if(!l)return null;const c=zFe(n,t.startContainer,t.startOffset);if(c===null)return null;const d=Dve(n,e.source,t.startContainer,t.startOffset,"start"),u=Dve(n,e.source,t.endContainer,t.endOffset,"end");let f=d??void 0,A=u??void 0;if(f===void 0||A===void 0){const v=j2(n),w=PM(v,e.source);if(!w)return null;const k=c.length,O=k+l.length;if(k<0||O>w.length||O<=k)return null;f??(f=(x=w[k])==null?void 0:x.start),A??(A=(y=w[O-1])==null?void 0:y.end)}if(f===void 0||A===void 0||A<=f)return null;for(;f<A&&new RegExp("\\p{White_Space}","u").test(e.source[f]??"")&&!l.startsWith(e.source[f]??"");)f+=1;const h=Math.min(160,Math.max(0,e.contextLength??160)),g={selectedText:l,sourceConversationId:e.sourceConversationId,sourceMessageId:e.sourceMessageId,sourceHash:e.sourceHash,start:f,end:A,prefix:e.source.slice(Math.max(0,f-h),f),suffix:e.source.slice(A,A+h)};return e.surface==="process_transcript"?{...g,surface:e.surface,transcriptKind:e.transcriptKind,generationId:e.generationId,generationSeqStart:e.generationSeqStart,generationSeqEnd:e.generationSeqEnd}:{...g,surface:e.surface}}function rfe({label:e,preview:t,fallbackOpenHref:n,sourceAttributes:r,onOpen:s}){var x,y,v,w,k,O;const a=((x=t==null?void 0:t.displayName)==null?void 0:x.trim())||e,o=((y=t==null?void 0:t.description)==null?void 0:y.trim())||null,l=((v=t==null?void 0:t.categoryLabel)==null?void 0:v.trim())||null,c=((w=t==null?void 0:t.locationLabel)==null?void 0:w.trim())||null,d=((k=t==null?void 0:t.detailsHref)==null?void 0:k.trim())||null,u=(n==null?void 0:n.trim())||((O=t==null?void 0:t.openHref)==null?void 0:O.trim())||null,f=!!(o||l||c||d),A=vs(),h=s?u??d:d,g=h?i.jsx("a",{className:"rudder-skill-token","data-skill-token":"true",href:h,"aria-label":`${a} skill`,style:sB(),...r,onClick:j=>s==null?void 0:s(j,h,a),children:e}):i.jsx("span",{className:"rudder-skill-token","data-skill-token":"true",tabIndex:f?0:void 0,"aria-label":f?`${a} skill`:void 0,style:sB(),...r,children:e});return i.jsxs("span",{className:q("rudder-skill-token-wrap",f&&"rudder-skill-token-wrap--preview"),children:[g,f?i.jsxs("span",{ref:A,className:"rudder-skill-hover-card scrollbar-auto-hide",role:"tooltip",[NM]:"",children:[i.jsxs("span",{className:"flex items-start gap-3",children:[i.jsx("span",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-[var(--radius-md)] bg-[#2f80ed]/10 text-[#2f80ed]",children:i.jsx(Lc,{className:"h-4 w-4","aria-hidden":!0})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block break-words text-sm font-medium leading-5 text-foreground",children:a}),l||c?i.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[l?i.jsx("span",{className:"inline-flex items-center rounded-[var(--radius-sm)] border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium leading-none text-muted-foreground",children:l}):null,c?i.jsx("span",{className:"min-w-0 break-all text-[11px] leading-4 text-muted-foreground",children:c}):null]}):null,o?i.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:o}):null]})]}),d?i.jsxs("a",{className:"rudder-skill-hover-card-action",href:d,children:[i.jsx("span",{children:"View details"}),i.jsx(Y1,{className:"h-3.5 w-3.5","aria-hidden":!0})]}):null]}):null]})}let RX=null;function LRt(){return RX||(RX=Wt(()=>import("./mermaid.core-tC71IlYD.js").then(e=>e.bo),[]).then(e=>e.default)),RX}function zw(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(t=>zw(t)).join(""):m.isValidElement(e)?zw(e.props.children):""}function pR(e){return(e==null?void 0:e.trim().replace(/\/+$/u,"").toLowerCase())??""}function s0(e){const t=(e==null?void 0:e.trim())??"";if(!t)return"item";const n=t.split(/[-/]/u).find(Boolean);return n&&n.length>=6?n.slice(0,12):t.length>12?t.slice(0,12):t}function LX(e){return((e==null?void 0:e.trim().replace(/\/+$/u,""))??"").split("/").filter(Boolean).at(-1)??""}function zX(e){var t,n,r,s,a,o,l;return e.kind==="agent"?s0(e.agentId):e.kind==="project"?s0(e.projectId):e.kind==="automation"?((t=e.title)==null?void 0:t.trim())||s0(e.automationId):e.kind==="issue"?((n=e.ref)==null?void 0:n.trim())||s0(e.issueId):e.kind==="chat"?((r=e.title)==null?void 0:r.trim())||s0(e.conversationId):e.kind==="library_doc"?((s=e.title)==null?void 0:s.trim())||s0(e.documentId):e.kind==="library_entry"?((a=e.title)==null?void 0:a.trim())||LX(e.path)||s0(e.entryId):e.kind==="library_file"?((o=e.title)==null?void 0:o.trim())||LX(e.filePath)||s0(e.filePath):((l=e.title)==null?void 0:l.trim())||LX(e.directoryPath)||s0(e.directoryPath)}function zRt(e){if(!/[&][#a-z\d]+;/iu.test(e)||typeof document>"u")return e;const t=document.createElement("textarea");return t.innerHTML=e,t.value}function $X(e){return zRt(e).replace(/\s+/gu," ").trim()}function $Rt(){return typeof window>"u"?null:Ng(window.location.pathname)}function FRt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function BRt(e){return e.replace(/([\\[\]])/g,"\\$1")}function QRt(e){return e.trim().replace(/^@+/u,"")}function URt(e){return/^[^\s@,!?.]+$/u.test(e)}function FX(e,t,n){const r=e.indexOf(t,n);return r>=0?r:null}function VRt(e,t){let n=!1;for(let r=t;r<e.length;r+=1){const s=e[r];if(n){n=!1;continue}if(s==="\\"){n=!0;continue}if(s===")")return r}return null}function qRt(e){var o;const t=[];let n=0,r=0;function s(l){l>r&&t.push({text:e.slice(r,l),protected:!1})}function a(l){s(n),t.push({text:e.slice(n,l),protected:!0}),n=l,r=l}for(;n<e.length;){const l=e[n];if(l==="`"){const d=((o=e.slice(n).match(/^`+/u))==null?void 0:o[0])??"`",u=FX(e,d,n+d.length);if(u!==null){a(u+d.length);continue}}const c=l==="["?n:l==="!"&&e[n+1]==="["?n+1:null;if(c!==null){const d=FX(e,"]",c+1);if(d!==null&&e[d+1]==="("){const u=VRt(e,d+2);if(u!==null){a(u+1);continue}}}if(l==="<"){const d=FX(e,">",n+1);if(d!==null){a(d+1);continue}}n+=1}return s(e.length),t}function KRt(e,t){if(!e.includes("@")||!(t!=null&&t.length))return e;const n=t.map(o=>({...o,name:QRt(o.name)})).filter(o=>o.name&&o.agentId&&URt(o.name)).sort((o,l)=>l.name.length-o.name.length);if(n.length===0)return e;const r=new RegExp(`(^|[^\\w/[\\]\`])@(${n.map(o=>FRt(o.name)).join("|")})(?=$|[\\s@,!?.])`,"giu"),s=/^(```|~~~)/;let a=!1;return e.split(/(\n)/).map(o=>o===`
|
|
1598
1598
|
`?o:s.test(o.trimStart())?(a=!a,o):a?o:qRt(o).map(l=>l.protected?l.text:l.text.replace(r,(c,d,u)=>{const f=n.find(h=>h.name.toLowerCase()===u.toLowerCase());if(!f)return c;const A=Z_(f.agentId,f.agentIcon);return`${d}[@${BRt(f.name)}](${A})`})).join("")).join("")}function WRt(e){const t=(e==null?void 0:e.trim())??"";if(!t)return!1;if(t.startsWith("//"))return!0;if(!/^[a-z][a-z\d+.-]*:/iu.test(t))return!1;try{const n=new URL(t);return typeof window<"u"&&(n.protocol==="http:"||n.protocol==="https:")&&n.origin===window.location.origin?!1:n.protocol==="http:"||n.protocol==="https:"||n.protocol==="mailto:"}catch{return!1}}function QFe(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=t.startsWith("//")?`${typeof window>"u"?"https:":window.location.protocol}${t}`:t;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"||typeof window<"u"&&r.origin===window.location.origin?null:r}catch{return null}}function ZRt(e){const t=e.trim();return/^(?:https?:\/\/|www\.|\/\/)/iu.test(t)}function HRt(e){const t=(e==null?void 0:e.trim())??"";return t.startsWith("//")||/^[a-z][a-z\d+.-]*:/iu.test(t)}function XRt(e){var n,r;const t=((r=(n=e.split(/[\\/]/u).at(-1))==null?void 0:n.toLowerCase().match(/\.([^.]+)$/u))==null?void 0:r[1])??"";return["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"].includes(t)?"image":["zip","tar","gz","tgz","bz2","xz","7z","rar"].includes(t)?"archive":["csv","tsv","xls","xlsx","ods"].includes(t)?"spreadsheet":["ts","tsx","js","jsx","mjs","cjs","py","rb","go","rs","java","kt","kts","c","cc","cpp","h","hpp","cs","swift","php","sh","bash","zsh","fish","html","css","scss","less","json","jsonc","yaml","yml","toml","xml","sql","vue","svelte"].includes(t)?"code":["md","mdx","txt","pdf","doc","docx","rtf"].includes(t)?"document":"file"}function GRt({filePath:e}){const t=XRt(e),n=t==="image"?qLe:t==="archive"?i7t:t==="spreadsheet"?b7t:t==="code"?b6:t==="document"?Fi:WLe;return i.jsx(n,{className:"mr-1 inline-block size-[0.95em] align-[-0.12em]","data-local-file-icon":t,"aria-hidden":"true"})}const Lve=new Set(["agents","automations","dashboard","goals","inbox","issues","library","messenger","organization","projects","settings","skills"]);function YRt(e){return e.button===0&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey}function zve(e,t){if(typeof window>"u")return null;try{const n=new URL(e,window.location.href);if(n.origin!==window.location.origin)return null;const r=n.pathname.split("/").filter(Boolean);return(r[0]&&Lve.has(r[0])?r[0]:r[1]&&Lve.has(r[1])?r[1]:null)?Yc(`${n.pathname}${n.search}${n.hash}`,t):null}catch{return null}}function $ve(e){if(!e||typeof window>"u")return null;try{const t=new URL(e,window.location.href);if(t.origin!==window.location.origin)return null;const n=t.pathname.split("/").filter(Boolean),r=n.findIndex(a=>a.toLowerCase()==="issues");if(r<0)return null;const s=n[r+1];return s?decodeURIComponent(s):null}catch{return null}}function T8(e,t){const n=e==null?void 0:e.trim().toLowerCase();return n?t.find(r=>{var o;if(r.kind!=="issue"||!r.issueId)return!1;const s=r.issueId.toLowerCase(),a=((o=r.issueIdentifier)==null?void 0:o.toLowerCase())??"";return s===n||a===n||n.length>=6&&s.startsWith(n)})??null:null}function Fve({mention:e,label:t,targetHref:n,sourceAttributes:r,onClick:s}){const a=sFe(e),o=i.jsx("a",{href:n,className:q("rudder-mention-chip rudder-mention-chip--issue",a.status&&"rudder-mention-chip--with-status-icon"),"data-mention-kind":"issue","data-mention-comment":a.commentId?"true":void 0,"data-mention-status":a.status??void 0,...r,onClick:s,children:t});return i.jsx(Xq,{mention:a,label:t,children:o})}function JRt(e){if(typeof window>"u")return;const t=`${window.location.pathname}${window.location.search}${window.location.hash}`;e!==t&&(window.history.pushState(window.history.state,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state})))}const x7=new Map,BX=new Map;function eLt(e){let t;try{t=typeof e=="string"?new URL(e):e}catch{return null}const n=qO(t);if(n)return n.iconDataUrl;const r=x7.get(t.href);return(r==null?void 0:r.status)==="ready"?r.iconUrl:null}function tLt(e){const t=e.href,n=qO(e),[r,s]=m.useState(()=>n?{status:"ready",iconUrl:n.iconDataUrl}:x7.get(t)??{status:"idle",iconUrl:null});return m.useEffect(()=>{if(n){const d={status:"ready",iconUrl:n.iconDataUrl};x7.set(t,d),s(d);return}const a=x7.get(t);if(a&&a.status!=="loading"){s(a);return}const o={status:"loading",iconUrl:null};x7.set(t,o);let l=!1;const c=BX.get(t)??Promise.resolve(u_t.get(t)).then(d=>d!=null&&d.iconUrl?{status:"ready",iconUrl:d.iconUrl}:{status:"none",iconUrl:null}).catch(()=>({status:"error",iconUrl:null})).finally(()=>{BX.delete(t)});return BX.set(t,c),c.then(d=>{x7.set(t,d),l||s(d)}),()=>{l=!0}},[t,n]),r}function sfe({url:e}){const t=tLt(e),n=qO(e),[r,s]=m.useState(()=>new Set),a=t.status==="ready"&&!r.has(t.iconUrl)?t.iconUrl:null;return a?i.jsx("span",{className:"rudder-website-link-icon","aria-hidden":"true","data-website-icon":"metadata",children:i.jsx("img",{src:a,alt:"",className:"rudder-website-link-logo","aria-hidden":"true","data-website-icon":"metadata","data-dark-mode":n==null?void 0:n.darkMode,referrerPolicy:"no-referrer",onError:()=>s(o=>new Set(o).add(a))})}):i.jsx("span",{className:"rudder-website-link-icon","aria-hidden":"true","data-website-icon":"generic",children:i.jsx(Vm,{className:"rudder-website-link-generic","aria-hidden":"true"})})}function nLt(e){if(!m.isValidElement(e))return null;const t=e.props;return typeof t.className!="string"||!/\blanguage-mermaid\b/i.test(t.className)?null:zw(t.children).replace(/\n$/,"")}function Bve(e){return zw(e).replace(/\n$/,"")}function rLt(e){var r;if(!m.isValidElement(e))return null;const t=e.props;if(typeof t.className!="string")return null;const n=(r=t.className.match(/\blanguage-([^\s]+)/i))==null?void 0:r[1];return(n==null?void 0:n.toLowerCase())??null}function sLt(e){return e==="diff"||e==="patch"||e==="udiff"}function iLt(e){return/^(?:diff --git|index |new file mode |deleted file mode |old mode |new mode |rename from |rename to |similarity index )/.test(e)?"meta":e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")?"file":e.startsWith("+")?"add":e.startsWith("-")?"remove":"context"}function aLt({source:e,preProps:t,sourceAttributes:n}){const r=e.split(`
|
|
1599
1599
|
`);return i.jsx("pre",{...t,...n,className:q(typeof t.className=="string"?t.className:null,"rudder-markdown-patch-block"),children:i.jsx("code",{children:r.map((s,a)=>{const o=iLt(s),l=o==="add"||o==="remove",c=l?s.slice(0,1):"",d=l?s.slice(1):s;return i.jsxs("span",{className:q("rudder-markdown-patch-line",`rudder-markdown-patch-line--${o}`),children:[i.jsx("span",{className:"rudder-markdown-patch-line-marker","aria-hidden":!c,children:c}),i.jsx("span",{className:"rudder-markdown-patch-line-content",children:d})]},`${a}-${o}`)})})})}async function oLt(e){var r,s;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.select();const n=(s=document.execCommand)==null?void 0:s.call(document,"copy");if(t.remove(),!n)throw new Error("Clipboard write failed.")}function lLt(e,t,n=0){var c,d;const r=e==null?void 0:e.position,s=(c=r==null?void 0:r.start)==null?void 0:c.offset,a=(d=r==null?void 0:r.end)==null?void 0:d.offset;if(typeof s!="number"||typeof a!="number")return{};const o=n+((t==null?void 0:t.renderedBoundaryToRaw[s])??s),l=n+((t==null?void 0:t.renderedBoundaryToRaw[a])??a);return{"data-markdown-source-start":String(o),"data-markdown-source-end":String(l),"data-markdown-rendered-source-start":String(s),"data-markdown-rendered-source-end":String(a)}}function Qve(e){const t=e instanceof HTMLElement?e:(e==null?void 0:e.parentElement)??null;return(t==null?void 0:t.closest("[data-markdown-rendered-source-start][data-markdown-rendered-source-end]"))??null}function cLt(e,t){const n=Number(t.dataset.markdownRenderedSourceStart),r=Number(t.dataset.markdownRenderedSourceEnd);return!Number.isFinite(n)||!Number.isFinite(r)||r<=n?null:e.slice(n,r)}function dLt(e,t,n){const r=Qve(t.anchorNode),s=Qve(t.focusNode);if(r&&r===s)return cLt(n,r);const a=t.getRangeAt(0),o=Array.from(e.querySelectorAll("[data-markdown-rendered-source-start][data-markdown-rendered-source-end]")).filter(f=>{try{return a.intersectsNode(f)}catch{return!1}}),c=o.filter(f=>!o.some(A=>A!==f&&A.contains(f))).map(f=>({start:Number(f.dataset.markdownRenderedSourceStart),end:Number(f.dataset.markdownRenderedSourceEnd)})).filter(f=>Number.isFinite(f.start)&&Number.isFinite(f.end)&&f.end>f.start);if(c.length===0)return null;const d=Math.min(...c.map(f=>f.start)),u=Math.max(...c.map(f=>f.end));return n.slice(d,u)}const uLt=m.memo(function({source:t,darkMode:n}){const r=m.useId().replace(/[^a-zA-Z0-9_-]/g,""),[s,a]=m.useState(null),[o,l]=m.useState(null);return m.useEffect(()=>{let c=!0;return a(null),l(null),LRt().then(async d=>{d.initialize({startOnLoad:!1,securityLevel:"strict",theme:n?"dark":"default",fontFamily:"inherit",suppressErrorRendering:!0});const u=await d.render(`rudder-mermaid-${r}`,t);c&&a(u.svg)}).catch(d=>{if(!c)return;const u=d instanceof Error&&d.message?d.message:"Failed to render Mermaid diagram.";l(u)}),()=>{c=!1}},[n,r,t]),i.jsx("div",{className:"rudder-mermaid",children:s?i.jsx("div",{dangerouslySetInnerHTML:{__html:s}}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:q("rudder-mermaid-status",o&&"rudder-mermaid-status-error"),children:o?`Unable to render Mermaid diagram: ${o}`:"Rendering Mermaid diagram..."}),i.jsx("pre",{className:"rudder-mermaid-source",children:i.jsx("code",{className:"language-mermaid",children:t})})]})})});function Uve({children:e,copyText:t,preProps:n,sourceAttributes:r,block:s}){const[a,o]=m.useState("idle"),l=m.useRef(void 0),c=a==="copied"?"Copied":a==="failed"?"Copy failed":"Copy code";m.useEffect(()=>()=>clearTimeout(l.current),[]);const d=m.useCallback(async()=>{clearTimeout(l.current);try{await oLt(t),o("copied")}catch{o("failed")}l.current=setTimeout(()=>o("idle"),1600)},[t]);return i.jsxs("div",{className:"rudder-code-block-copy-wrap",children:[s??i.jsx("pre",{...n,...r,children:e}),i.jsx(id,{delayDuration:120,children:i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx("button",{type:"button",className:"rudder-code-block-copy-button","aria-label":c,"data-copy-state":a,onClick:()=>void d(),children:a==="copied"?i.jsx(Zi,{className:"h-3.5 w-3.5","aria-hidden":"true"}):i.jsx(sl,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),i.jsx(Gi,{side:"left",sideOffset:8,children:c})]})})]})}function Bo({children:e,className:t,resolveImageSrc:n,onLinkClick:r,agentMentions:s,skillReferences:a,enableImagePreview:o=!0,copyMarkdownOnCopy:l=!1,enableCodeBlockCopy:c=!1,sourceOffsetBase:d=0}){const{resolvedTheme:u}=Kue(),{mentions:f}=que(),A=new Map(f.filter(z=>z.kind==="agent").map(z=>[z.agentId??z.id.replace(/^agent:/,""),z])),h=new Map(f.filter(z=>z.kind==="project"&&z.projectId).map(z=>[z.projectId,z])),g=new Map(f.filter(z=>z.kind==="issue"&&z.issueId).map(z=>[z.issueId,z])),x=f.filter(z=>z.kind==="issue"&&z.issueId),y=new Map(f.filter(z=>z.kind==="automation"&&z.automationId).map(z=>[z.automationId,z])),v=new Map(f.filter(z=>z.kind==="chat"&&z.chatConversationId).map(z=>[z.chatConversationId,z])),w=new Map(f.filter(z=>z.kind==="library_doc"&&z.libraryDocumentId).map(z=>[z.libraryDocumentId,z])),k=new Map(f.filter(z=>z.kind==="library_file"&&z.libraryEntryId).map(z=>[z.libraryEntryId,z])),O=new Map(f.filter(z=>z.kind==="library_file"&&z.libraryFilePath).map(z=>[z.libraryFilePath,z])),j=new Map(f.filter(z=>z.kind==="library_directory"&&z.libraryDirectoryPath).map(z=>[z.libraryDirectoryPath,z])),C=new Map((a??[]).map(z=>[pR(z.href),z]).filter(([z])=>z.length>0)),N=new Map((a??[]).map(z=>[pR(z.label),z]).filter(([z])=>z.length>0)),I=$Rt(),{normalizedChildren:E,sourceMap:_}=m.useMemo(()=>{const z=KRt(Zue(e),s);return{normalizedChildren:z,sourceMap:HEt(e,z)}},[s,e]),T=m.useCallback(z=>lLt(z,_,d),[_,d]),R=m.useCallback(({node:z,children:H,...J})=>i.jsx("li",{...J,...T(z),children:H}),[T]),M=z=>{if(!l)return;const H=window.getSelection();if(!H||H.rangeCount===0||H.isCollapsed||!z.currentTarget.contains(H.anchorNode)||!z.currentTarget.contains(H.focusNode))return;const J=dLt(z.currentTarget,H,E)??E;z.clipboardData.setData("text/plain",J),z.preventDefault()},L=(z,H,J,F)=>{if(r==null?void 0:r({event:z,href:H,label:J,sourceHref:F})){z.preventDefault();return}if(z.defaultPrevented||!YRt(z))return;const W=zve(H,I);W&&(z.preventDefault(),JRt(W))},U=m.useCallback(({node:z,children:H,...J})=>{const F=nLt(H);if(F)return i.jsx(uLt,{source:F,darkMode:u==="dark"});const Q=T(z),W=rLt(H),$=sLt(W)?Bve(H):null;if($!==null){const ee=i.jsx(aLt,{source:$,preProps:J,sourceAttributes:Q});return c?i.jsx(Uve,{copyText:$,preProps:{},sourceAttributes:{},block:ee}):ee}return c?i.jsx(Uve,{copyText:Bve(H),preProps:J,sourceAttributes:Q,children:H}):i.jsx("pre",{...J,...Q,children:H})},[c,u,T]),B={p:({node:z,children:H,...J})=>i.jsx("p",{...J,...T(z),children:H}),h1:({node:z,children:H,...J})=>i.jsx("h1",{...J,...T(z),children:H}),h2:({node:z,children:H,...J})=>i.jsx("h2",{...J,...T(z),children:H}),h3:({node:z,children:H,...J})=>i.jsx("h3",{...J,...T(z),children:H}),h4:({node:z,children:H,...J})=>i.jsx("h4",{...J,...T(z),children:H}),h5:({node:z,children:H,...J})=>i.jsx("h5",{...J,...T(z),children:H}),h6:({node:z,children:H,...J})=>i.jsx("h6",{...J,...T(z),children:H}),strong:({node:z,children:H,...J})=>i.jsx("strong",{...J,...T(z),children:H}),em:({node:z,children:H,...J})=>i.jsx("em",{...J,...T(z),children:H}),del:({node:z,children:H,...J})=>i.jsx("del",{...J,...T(z),children:H}),code:({node:z,children:H,...J})=>i.jsx("code",{...J,...T(z),children:H}),li:R,table:({node:z,children:H,...J})=>i.jsx("div",{className:"rudder-markdown-table-scroll",children:i.jsx("table",{...J,...T(z),children:H})}),pre:U,a:({node:z,href:H,children:J})=>{const F=H?$c(H):null;if(F){const he=$X(E3(zw(J))),we=(()=>{var oe;if(F.kind==="agent")return{...F,icon:((oe=A.get(F.agentId))==null?void 0:oe.agentIcon)??F.icon};if(F.kind==="project"){const fe=h.get(F.projectId);return{...F,color:(fe==null?void 0:fe.projectColor)??F.color,icon:(fe==null?void 0:fe.projectIcon)??F.icon}}if(F.kind==="issue"){const fe=g.get(F.issueId)??T8(F.issueId,x)??T8(F.ref,x)??T8($ve(H),x);return{...F,issueId:F.issueId,ref:(fe==null?void 0:fe.issueIdentifier)??F.ref,status:(fe==null?void 0:fe.issueStatus)??F.status}}return F})(),Ue=(()=>{var oe,fe,Ie,ue,be,at,ve,me,ye,qe,Ce;if(we.kind==="agent")return((oe=A.get(we.agentId))==null?void 0:oe.name)??he;if(we.kind==="project")return((fe=h.get(we.projectId))==null?void 0:fe.name)??he;if(we.kind==="issue"){const X=g.get(we.issueId)??T8(we.issueId,x)??T8(we.ref,x);return((X==null?void 0:X.name)??he??((Ie=we.ref)==null?void 0:Ie.trim())??"")||((ue=we.ref)==null?void 0:ue.trim())||zX(we)}return we.kind==="automation"?((be=y.get(we.automationId))==null?void 0:be.name)??((at=we.title)==null?void 0:at.trim())??he:we.kind==="chat"?((ve=v.get(we.conversationId))==null?void 0:ve.name)??he:we.kind==="library_doc"?((me=w.get(we.documentId))==null?void 0:me.name)??he:we.kind==="library_entry"?((ye=k.get(we.entryId))==null?void 0:ye.name)??he:we.kind==="library_file"?((qe=O.get(we.filePath))==null?void 0:qe.name)??he:we.kind==="library_directory"?((Ce=j.get(we.directoryPath))==null?void 0:Ce.name)??he:he})()||zX(we),je=$X(Ue),ke=Yc(w6(we),I);if(we.kind==="issue")return i.jsx(Fve,{mention:we,label:je,targetHref:ke,sourceAttributes:T(z),onClick:oe=>{L(oe,ke,je)}});const Se=i.jsx("a",{href:ke,className:q("rudder-mention-chip",`rudder-mention-chip--${we.kind}`,we.kind==="project"&&"rudder-project-mention-chip"),"data-mention-kind":we.kind,style:i9(we),...T(z),onClick:oe=>{L(oe,ke,je)},children:je});return we.kind==="automation"||we.kind==="chat"?Se:i.jsx(Xq,{mention:we,label:je,children:Se})}const Q=UA(H,zw(J));if(Q){const he=C.get(pR(Q.href))??N.get(pR(Q.label))??null,we=Ov(he==null?void 0:he.label)||Q.label;return i.jsx(rfe,{label:we,preview:he,fallbackOpenHref:Fue(Q.href)??(he==null?void 0:he.openHref)??"#",sourceAttributes:T(z),onOpen:r?(Ue,je,ke)=>{L(Ue,je,ke,Q.href)}:void 0})}const W=zw(J),$=WRt(H),ee=QFe(H),re=iFe(H),ne=$&&ZRt(W),te=H?zve(H,I):null,ce=T8($ve(H),x);if(ce&&te){const he={kind:"issue",issueId:ce.issueId,ref:ce.issueIdentifier??null,commentId:null,status:ce.issueStatus??null},we=$X(ce.name||W||zX(he));return i.jsx(Fve,{mention:he,label:we,targetHref:te,sourceAttributes:T(z),onClick:Ue=>{L(Ue,te,we)}})}const se=te&&!HRt(H)?te:H;return ee?i.jsxs("a",{href:H,target:"_blank",rel:"noreferrer noopener",title:ne?H:void 0,className:"rudder-website-link",...T(z),onClick:he=>{H&&L(he,H,W)},children:[i.jsx(sfe,{url:ee}),i.jsx("span",{className:"rudder-website-link-label",children:J})]}):re?i.jsxs("a",{href:H,className:"rudder-local-file-link",...T(z),onClick:he=>{H&&L(he,H,W)},children:[i.jsx(GRt,{filePath:re}),J]}):i.jsx("a",{href:se,target:$?"_blank":void 0,rel:$?"noreferrer noopener":"noreferrer",title:ne?H:void 0,...T(z),onClick:he=>{H&&L(he,te??H,W)},children:J})}};return B.img=({node:z,src:H,alt:J,...F})=>{const W=(H&&n?n(H):null)??H??"";return o&&W?i.jsx(H2,{...F,src:W,alt:J??"",name:(J==null?void 0:J.trim())||"Markdown image",previewTestId:"markdown-body-image-preview-dialog",previewTitleFallback:"Image preview"}):i.jsx("img",{...F,src:W,alt:J??""})},i.jsx(i.Fragment,{children:i.jsx("div",{className:q("rudder-markdown prose prose-sm max-w-none break-words overflow-hidden",u==="dark"&&"prose-invert",t),onCopyCapture:M,"data-copy-markdown-source":l?"true":void 0,children:i.jsx(Oue,{remarkPlugins:[Lq],components:B,urlTransform:z=>z,children:E})})})}const Es={listSavedViews:(e,t={})=>{const n=new URLSearchParams({visibility:t.visibility??"visible"});return t.limit!==void 0&&n.set("limit",String(t.limit)),t.offset!==void 0&&n.set("offset",String(t.offset)),t.primaryRailPinned!==void 0&&n.set("primaryRailPinned",String(t.primaryRailPinned)),Me.get(`/orgs/${e}/messenger/saved-views?${n.toString()}`)},getSavedView:(e,t)=>Me.get(`/orgs/${e}/messenger/saved-views/${t}`),keepSavedView:(e,t)=>Me.post(`/orgs/${e}/messenger/saved-views/keep`,t),createSavedView:(e,t)=>Me.post(`/orgs/${e}/messenger/saved-views`,t),updateSavedView:(e,t,n)=>Me.patch(`/orgs/${e}/messenger/saved-views/${t}`,n),reorderSavedViews:(e,t)=>Me.patch(`/orgs/${e}/messenger/saved-views/reorder`,{ids:t}),deleteSavedView:(e,t)=>Me.delete(`/orgs/${e}/messenger/saved-views/${t}`),listThreads:e=>Me.get(`/orgs/${e}/messenger/threads`),listThreadPage:(e,t={})=>{const n=new URLSearchParams;t.cursor&&n.set("cursor",t.cursor),typeof t.limit=="number"&&n.set("limit",String(t.limit)),t.splitIssues&&n.set("splitIssues","true");const r=n.toString();return Me.get(`/orgs/${e}/messenger/threads${r?`?${r}`:""}`)},markThreadRead:(e,t,n)=>Me.post(`/orgs/${e}/messenger/threads/${encodeURIComponent(t)}/read`,n?{lastReadAt:n}:{}),dismissUnreads:e=>Me.post(`/orgs/${e}/messenger/unreads/dismiss`,{}),updateThreadUserState:(e,t,n)=>Me.post(`/orgs/${e}/messenger/threads/${encodeURIComponent(t)}/user-state`,n),getIssuesThread:(e,t={})=>{const n=new URLSearchParams;t.cursor&&n.set("cursor",t.cursor),typeof t.limit=="number"&&n.set("limit",String(t.limit));const r=n.toString();return Me.get(`/orgs/${e}/messenger/issues${r?`?${r}`:""}`)},getApprovalsThread:e=>Me.get(`/orgs/${e}/messenger/approvals`),getSystemThread:(e,t)=>Me.get(`/orgs/${e}/messenger/system/${t}`),listCustomGroups:e=>Me.get(`/orgs/${e}/messenger/groups`),createCustomGroup:(e,t)=>Me.post(`/orgs/${e}/messenger/groups`,t),createCustomGroupWithEntries:(e,t)=>Me.post(`/orgs/${e}/messenger/groups/merge`,t),updateCustomGroup:(e,t,n)=>Me.patch(`/orgs/${e}/messenger/groups/${t}`,n),regenerateCustomGroupTitle:(e,t)=>Me.post(`/orgs/${e}/messenger/groups/${t}/title/regenerate`,{}),separateCustomGroup:(e,t)=>Me.post(`/orgs/${e}/messenger/groups/${t}/separate`,{}),deleteCustomGroup:(e,t)=>Me.delete(`/orgs/${e}/messenger/groups/${t}`),reorderCustomGroups:(e,t)=>Me.patch(`/orgs/${e}/messenger/groups/reorder`,{groupIds:t}),assignCustomGroupEntry:(e,t,n)=>Me.post(`/orgs/${e}/messenger/groups/${t}/entries`,{itemKey:n}),removeCustomGroupEntry:(e,t)=>Me.delete(`/orgs/${e}/messenger/groups/entries/${encodeURIComponent(t)}`),reorderCustomGroupEntries:(e,t,n)=>Me.patch(`/orgs/${e}/messenger/groups/${t}/entries/reorder`,{itemKeys:n})},fLt=400,ALt=2e3;function Gq(e){return e==="starting"||e==="stopping"?fLt:e==="running"?ALt:!1}function ife(e,t){return e.desktopInstallationId===t.desktopInstallationId&&e.appPublicId===t.appPublicId&&e.localBindingId===t.localBindingId}function UFe(e){return["A Local App could not open in Rudder Desktop.",`Local App label (context only): ${e.trim().replace(/[\r\n]+/g," ").slice(0,160)||"this Local App"}`,"Help me diagnose the startup issue. Ask for any error details or logs you need; I will review them before sharing."].join(`
|
|
1600
1600
|
|
|
@@ -1678,7 +1678,7 @@ When you submit the join request, use:
|
|
|
1678
1678
|
- \`agentRuntimeType: "openclaw_gateway"\`
|
|
1679
1679
|
- \`agentDefaultsPayload.url\` 填你的 \`ws://\` 或 \`wss://\` gateway URL
|
|
1680
1680
|
- \`agentDefaultsPayload.headers["x-openclaw-token"]\` 填你的 gateway token
|
|
1681
|
-
- (兼容旧字段)\`agentDefaultsPayload.headers["x-openclaw-auth"]\``,"organizationSettings.packages.description":"在不同 Rudder 安装之间迁移组织配置与工作数据。","organizationSettings.packages.export":"导出","organizationSettings.packages.import":"导入","organizationSettings.danger.description":"归档这个 organization 后,它会从侧边栏中隐藏。这个状态会持久化到数据库。","organizationSettings.danger.confirm":"要归档 organization “{{name}}” 吗?它会从侧边栏中隐藏。","organizationSettings.danger.archiving":"归档中...","organizationSettings.danger.alreadyArchived":"已归档","organizationSettings.danger.archive":"归档 organization","organizationSettings.danger.failed":"归档 organization 失败","settings.eyebrow.system":"系统设置","settings.eyebrow.labs":"实验室","app.instanceSetupRequired":"需要完成实例初始化","app.bootstrapInvite.active":"当前还没有实例管理员。引导邀请已经激活。请查看 Rudder 启动日志中的首个管理员邀请链接,或运行下面的命令重新生成:","app.bootstrapInvite.inactive":"当前还没有实例管理员。请在 Rudder 运行环境中执行下面的命令生成首个管理员邀请链接:","app.failedToLoadAppState":"加载应用状态失败","app.addAnotherAgentToOrganization":"为 {{name}} 再添加一个智能体","app.createAnotherOrganization":"创建另一个组织","app.createFirstOrganization":"创建你的第一个组织","app.onboarding.addAgentDescription":"再次运行引导,为这个组织添加一个智能体和一个初始任务。","app.onboarding.createAnotherDescription":"再次运行引导,创建另一个组织并初始化它的第一个智能体。","app.onboarding.createFirstDescription":"从创建一个组织和你的第一个智能体开始。","app.addAgent":"添加智能体","app.startOnboarding":"开始引导","app.noCompaniesDescription":"从创建一个组织开始。","app.newOrganization":"新建组织","general.title":"通用","general.description":"这台设备上的核心应用偏好。","general.updateFailed":"更新通用设置失败。","general.loadLoading":"正在加载通用设置...","general.loadFailed":"加载通用设置失败。","general.language.title":"语言","general.language.description":"选择这个 Rudder 实例在控制台界面中使用的语言。","general.language.label":"界面语言","general.language.help":"这是实例级界面语言,会影响所有使用这个实例的用户看到的控制台外壳和设置页面。","general.language.option.en.label":"英语","general.language.option.en.description":"默认产品语言","general.language.option.zh-CN.label":"简体中文","general.language.option.zh-CN.description":"中文界面","general.language.preview.en.primary":"Hello","general.language.preview.en.secondary":"Board UI","general.language.preview.zh-CN.primary":"你好","general.language.preview.zh-CN.secondary":"控制台界面","general.basics.title":"基础","general.productTour.title":"工作台教程","general.productTour.description":"重新播放引导教程。","general.productTour.start":"开始教程","general.logs.title":"操作日志","general.logs.description":"调整界面中面向操作员展示的输出方式。","general.logs.censor.title":"对日志中的用户名做脱敏","general.logs.censor.description":"对日志中显示的主目录路径用户名做脱敏。","general.updates.title":"桌面应用","general.updates.description":"选择这台机器安装 Rudder Desktop 时使用哪个发布渠道。","general.updates.loadFailed":"加载桌面更新设置失败。","general.updates.updateFailed":"更新桌面更新设置失败。","general.updates.unavailable":"当前环境不支持桌面更新设置。","general.updates.canary.title":"接收桌面测试版更新","general.updates.canary.disabledDescription":"安装最新正式版;当测试版更新时也纳入检测。","general.updates.canary.enabledDescription":"这台机器会同时检查正式版和更新的测试版。","general.diagnostics.developer.title":"显示开发诊断信息","general.diagnostics.developer.description":"在 transcript 中显示 Rudder 内部运行时、workspace、session 和 adapter 诊断信息。","general.developer.title":"开发者","general.appearance.title":"外观","general.appearance.description":"选择这个设备上的 Rudder 外观。视觉风格遵循低眩光、克制的 Claude 风格界面。","general.appearance.colorMode":"颜色模式","general.appearance.light.label":"浅色","general.appearance.light.description":"暖色纸面风格","general.appearance.system.label":"自动","general.appearance.system.description":"跟随系统外观","general.appearance.dark.label":"深色","general.appearance.dark.description":"低眩光工作区","general.appearance.designStyle":"设计风格","general.appearance.defaultStyle.label":"Classic","general.appearance.defaultStyle.description":"平衡的低眩光界面","general.appearance.mira.label":"Compact","general.appearance.mira.description":"紧凑卡片与控件","general.appearance.luma.label":"Rudder","general.appearance.luma.description":"柔和宽松的控件","general.appearance.baseColor":"基础色","general.appearance.base.neutral.label":"Neutral","general.appearance.base.neutral.description":"平衡的中性灰界面","general.appearance.base.stone.label":"Stone","general.appearance.base.stone.description":"暖调石色界面","general.appearance.base.zinc.label":"Zinc","general.appearance.base.zinc.description":"冷调灰色界面","general.appearance.base.mauve.label":"Mauve","general.appearance.base.mauve.description":"低饱和玫瑰灰界面","general.appearance.base.olive.label":"Olive","general.appearance.base.olive.description":"低饱和橄榄色界面","general.appearance.base.mist.label":"Mist","general.appearance.base.mist.description":"柔和蓝灰界面","general.appearance.base.taupe.label":"Taupe","general.appearance.base.taupe.description":"暖调灰褐界面","general.appearance.themeColor":"主题色","general.appearance.theme.neutral.label":"Neutral","general.appearance.theme.neutral.description":"单色操作状态","general.appearance.theme.amber.label":"Amber","general.appearance.theme.amber.description":"琥珀色操作状态","general.appearance.theme.blue.label":"Blue","general.appearance.theme.blue.description":"蓝色操作状态","general.appearance.theme.cyan.label":"Cyan","general.appearance.theme.cyan.description":"青色操作状态","general.appearance.theme.emerald.label":"Rudder","general.appearance.theme.emerald.description":"Rudder 绿色操作状态","general.appearance.theme.fuchsia.label":"Fuchsia","general.appearance.theme.fuchsia.description":"紫红色操作状态","general.appearance.theme.green.label":"Green","general.appearance.theme.green.description":"绿色操作状态","general.appearance.theme.indigo.label":"Indigo","general.appearance.theme.indigo.description":"靛蓝色操作状态","general.appearance.theme.lime.label":"Lime","general.appearance.theme.lime.description":"青柠色操作状态","general.appearance.theme.orange.label":"Orange","general.appearance.theme.orange.description":"橙色操作状态","general.appearance.theme.pink.label":"Pink","general.appearance.theme.pink.description":"粉色操作状态","notifications.title":"通知","notifications.description":"管理这个 Rudder 实例的未读 inbox 提醒。","notifications.loadFailed":"加载通知设置失败。","notifications.updateFailed":"更新通知设置失败。","notifications.support.available":"可用","notifications.support.unavailable":"不可用","notifications.permission.title":"权限","notifications.permission.description":"通知权限由操作系统或浏览器掌控,所以 Rudder 需要同时展示当前状态和修复入口。","notifications.permission.requestFailed":"请求通知权限失败。","notifications.permission.openSettingsFailed":"打开通知设置失败。","notifications.permission.access.title":"通知访问权限","notifications.permission.access.summary":"权限:{{permission}}。提醒:{{notificationsSupport}}。","notifications.permission.access.summaryDesktop":"权限:{{permission}}。原生提醒:{{notificationsSupport}}。","notifications.permission.access.default":"Rudder 还没有请求通知权限,因此未读 inbox 提醒可能不会出现。","notifications.permission.access.denied.desktop":"通知权限已被操作系统拦截。请在系统通知设置中重新允许 Rudder,才能恢复 macOS 提醒。","notifications.permission.access.denied.browser":"通知权限已被浏览器拦截。请在浏览器站点通知设置中重新允许 Rudder,才能在 `pnpm dev` 里预览 inbox 提醒。","notifications.permission.access.requesting":"请求中...","notifications.permission.access.enable":"开启通知","notifications.permission.access.desktopHelp":"这里能触发原生通知,但真正的允许/阻止状态由 macOS 管理。如果没有弹出通知,请打开系统设置并检查 {{appName}}。","notifications.permission.access.desktopHelpProd":"真正的允许/阻止状态由 macOS 管理。如果没有弹出通知,请打开系统设置并检查 {{appName}}。","notifications.permission.access.openSettings":"打开通知设置","notifications.environment.title":"当前环境","notifications.environment.desktop":"当前运行在 Electron 桌面壳中。","notifications.environment.browser":"当前运行在浏览器预览模式中。","notifications.environment.desktopHelp":"这里可以使用原生系统通知来提示未读 inbox 变化。","notifications.environment.browserHelp":"浏览器模式可以通过 Web Notifications API 预览未读 inbox 提醒。","notifications.behavior.title":"行为","notifications.behavior.description":"选择 Rudder 是否提示未读 inbox 活动。","notifications.behavior.inbox.title":"Inbox 活动提醒","notifications.behavior.inbox.description":"当未读 inbox 数量增加时显示提醒。","notifications.behavior.inbox.toggle":"切换 inbox 通知","systemPermissions.title":"系统权限","systemPermissions.description":"管理本地自动化、文件访问和 inbox 提醒所需的系统权限。","systemPermissions.section.title":"权限","systemPermissions.section.description":"Rudder 会尽量打开对应系统设置;最终状态仍以操作系统为准。","systemPermissions.status.authorized":"已授权","systemPermissions.status.needsAccess":"需要授权","systemPermissions.status.blocked":"已阻止","systemPermissions.status.checking":"检查中","systemPermissions.status.desktopOnly":"仅桌面应用","systemPermissions.status.perApp":"按应用授权","systemPermissions.status.unknown":"未知","systemPermissions.status.unavailable":"不可用","systemPermissions.action.openSettings":"打开设置","systemPermissions.action.desktopOnly":"仅桌面可用","systemPermissions.action.browserManaged":"由浏览器管理","systemPermissions.openSettingsFailed":"打开系统设置失败。","systemPermissions.permission.fullDiskAccess.title":"完全磁盘访问权限","systemPermissions.permission.fullDiskAccess.description":"在需要更广文件访问时读取本地项目文件和工作区元数据。","systemPermissions.permission.accessibility.title":"辅助功能","systemPermissions.permission.accessibility.description":"让 Rudder 驱动的桌面自动化在需要时观察并控制应用界面。","systemPermissions.permission.automation.title":"自动化","systemPermissions.permission.automation.description":"macOS 会按目标应用分别授权自动化;可打开此面板查看具体应用条目。","systemPermissions.permission.notifications.title":"通知","systemPermissions.permission.notifications.description":"Rudder 通知的系统访问权限。Issue 和 chat 通知可以在下方分别控制。","systemPermissions.permission.notifications.inboxLabel":"Inbox 活动提醒","systemPermissions.notifications.title":"通知","systemPermissions.notifications.description":"系统通知权限可用后,选择 Rudder 哪些事件需要提醒你。","systemPermissions.notifications.system.title":"系统通知访问权限","systemPermissions.notifications.system.description":"如果 Rudder 通知被阻止或没有出现,可以打开系统通知设置检查。","systemPermissions.notifications.issue.title":"Issue 通知","systemPermissions.notifications.issue.description":"当 issue 被创建、更新、评论或重新打开时提醒。","systemPermissions.notifications.issue.toggle":"切换 issue 通知","systemPermissions.notifications.chat.title":"Chat 通知","systemPermissions.notifications.chat.description":"当 assistant chat 回复、提议 issue 或操作时提醒。","systemPermissions.notifications.chat.toggle":"切换 chat 通知","about.title":"关于","about.version.title":"版本","about.version.description":"这里显示当前机器上运行的 Rudder 构建版本。","about.version.current":"版本","about.desktop.title":"桌面应用","about.desktop.description":"这个壳层连接到与控制台、CLI 以及其他本地 Rudder 界面共用的同一份本地实例数据。","about.desktop.profile":"环境","about.desktop.instance":"实例 ID","about.desktop.runtime":"运行时","about.desktop.owner":"拥有者","about.desktop.instanceDataPath":"实例数据路径","about.actions.title":"操作","about.actions.description":"这些动作属于应用生命周期,不应该埋在通用偏好里。","about.notifications.description":"Inbox 提醒、角标行为和权限修复入口现在都集中在独立的通知设置页中管理。","about.notifications.open":"打开通知设置","about.updates.title":"检查更新","about.updates.description":"将当前桌面构建与所选 GitHub Release 策略做对比。","about.updates.check":"检查更新","about.updates.install":"更新","about.updates.download":"下载更新","about.updates.installing":"正在更新...","about.updates.channel.stable":"正式版","about.updates.channel.canary":"正式版 + Canary","about.updates.available.inline":"发现 {{channel}} 新版本:{{latestVersion}}。","about.updates.current.inline":"{{channel}} 当前已经是最新版本:{{currentVersion}}。","about.updates.unavailable.inline":"暂时无法完成 {{channel}} 版本对比。","about.updates.available.toastTitle":"发现新版本","about.updates.available.toastBody":"{{latestVersion}} 已可下载。","about.updates.installStarted.toastTitle":"已开始更新","about.updates.installStarted.toastBody":"Rudder 会在安装 {{latestVersion}} 后关闭并重新打开。","about.updates.installWaiting.toastTitle":"更新已排队","about.updates.installWaiting.toastBody":"安装包正在下载。Rudder 会在 {{totalRuns}} 个活跃运行结束后自动更新。","about.updates.installBlocked.toastTitle":"更新已暂停","about.updates.installUnavailable":"当前构建不支持应用内安装更新。","about.updates.installFailed":"无法开始更新。","about.updates.installFailedToastTitle":"无法开始更新","about.updates.progress.title":"正在更新到 {{version}}","about.updates.progress.readyTitle":"更新已准备好","about.updates.progress.completeTitle":"重启交接已完成","about.updates.progress.detailsTitle":"更新进度详情","about.updates.progress.failedTitle":"更新失败","about.updates.progress.retry":"重试","about.updates.progress.restartToUpdate":"退出并更新","about.updates.progress.updateWhenIdle":"空闲时更新","about.updates.progress.forceRestartToUpdate":"停止运行并立即更新","about.updates.progress.blockersTitle":"正在延迟更新的运行","about.updates.progress.blockerRun":"{{organization}} · {{agent}} · 运行 {{runId}}","about.updates.progress.automaticApply":"这些运行结束后,Rudder 会自动完成更新。","about.updates.progress.openReleases":"打开发布页","about.updates.progress.dismiss":"关闭更新状态","about.updates.progress.phase.starting":"正在开始更新...","about.updates.progress.phase.resolving_release":"正在解析发布版本...","about.updates.progress.phase.downloading_checksums":"正在下载校验文件...","about.updates.progress.phase.downloading_asset":"正在下载桌面安装包...","about.updates.progress.phase.verifying_checksum":"正在校验安装包...","about.updates.progress.phase.ready_to_install":"安装包已下载并校验完成,正在检查运行状态...","about.updates.progress.phase.waiting_for_active_runs":"正在等待运行结束...","about.updates.progress.phase.preparing_restart":"正在准备重启...","about.updates.progress.phase.closing":"Rudder 将关闭并重新打开以完成更新。","about.updates.progress.phase.complete":"Rudder Desktop 启动交接已完成。","about.updates.progress.phase.failed":"更新失败。","about.updates.current.toastTitle":"已经是最新版本","about.updates.current.toastBody":"当前桌面构建已经是 {{currentVersion}}。","about.updates.unavailable.toastTitle":"暂时无法检查更新","about.updates.unavailable.toastBody":"当前无法把这个构建与最新桌面版本进行对比。","about.updates.browserFallback.toastTitle":"已打开发布页","about.updates.browserFallback.toastBody":"桌面更新检查只能在打包后的应用内运行,因此已改为打开发布页面。","about.updates.failed":"检查更新失败。","about.updates.failedToastTitle":"检查更新失败","about.feedback.title":"发送反馈","about.feedback.description":"打开默认邮件应用,并创建一封发往 Rudder 维护者邮箱的草稿。","about.feedback.send":"发送反馈","about.feedback.toastTitle":"正在打开邮件应用","about.feedback.toastBody":"正在为 Rudder 维护者邮箱创建新邮件草稿。","about.feedback.failed":"打开反馈邮件草稿失败。","about.feedback.failedToastTitle":"发送反馈失败","profile.title":"个人资料与账号","profile.description":"管理你的操作员资料、Rudder Account 和已登录设备。","profile.loadLoading":"正在加载个人资料设置...","profile.loadFailed":"加载个人资料设置失败。","profile.updateFailed":"更新个人资料设置失败。","profile.toastSaved.title":"个人资料已保存","profile.toastSaved.body":"你的操作员资料已更新。","profile.toastSaveFailed.title":"保存个人资料失败","profile.about.title":"关于你","profile.about.description":"这里沿用类似 ChatGPT 的轻量个人上下文结构:一个偏好的称呼,加上一些可选的工作背景信息。","profile.nickname.label":"你的称呼","profile.nickname.placeholder":"Rudder 应该怎么称呼你?","profile.nickname.help":"如果填写了,内置聊天助手可以用它来称呼你。","profile.moreAboutYou.label":"更多关于你","profile.moreAboutYou.placeholder":"补充一些长期有效的背景信息,帮助内置聊天助手更好理解你的请求。","profile.moreAboutYou.help":"Rudder 只会把这段内容注入内置聊天助手。如果留空,则不会追加到聊天系统提示词中。","profile.import.helper.title":"从其他 AI 导入 memories","profile.import.helper.description":"把这段提示词复制到 ChatGPT、Claude 或其他 AI provider,再把导出的 memory 粘贴到下面。","profile.import.copyPrompt":"复制 memory 导入提示词","profile.import.copiedButton":"已复制","profile.import.copied.title":"提示词已复制","profile.import.copied.body":"把结果粘贴到“更多关于你”,再编辑并保存。","profile.import.copyFailed.title":"提示词未复制","profile.import.copyFailed.body":"请手动选中提示词文本并复制。","profile.save":"保存资料","profile.saving":"保存中...","productTour.checklist.title":"完成首次工作闭环","productTour.checklist.workspace":"读懂控制台","productTour.checklist.create":"创建小任务","productTour.checklist.issues":"使用 issue 结构","productTour.checklist.inspect":"检查工作输出","productTour.checklist.settings":"再次找到教程","productTour.stepCounter":"{{current}} / {{total}}","productTour.step.workspace.title":"Rudder 是 agent work 的控制台","productTour.step.workspace.body":"主导航把关键工作面放在一起:Messenger、Dashboard、Issues、Agents、Organization、Automations 和 Calendar。用它在行动、检查和 review 之间切换。","productTour.step.create.title":"从一个 agent 真能推进的小任务开始","productTour.step.create.body":"创建菜单是新 Chat、issue、agent 和 project 的入口。第一次闭环可以选择边界清楚、结果可 review 的小 Chat 或 issue。","productTour.step.issues.title":"Issue 增加明确的工作流结构","productTour.step.issues.body":"Issue 页面展示哪些工作在等待、执行、阻塞或完成。Chat 是并列的对话式路径;需要明确 owner、状态、优先级、依赖或 review 时,再使用 issue。","productTour.step.inspect.title":"先检查工作,再审批或继续推进","productTour.step.inspect.body":"Dashboard 会展示当前页面、详情、transcript、产出和审批入口。Rudder 应该让你清楚看到发生了什么,以及哪里需要你介入。","productTour.step.settings.title":"你可以从 Settings 重新播放教程","productTour.step.settings.body":"第一次导览结束后,Rudder 会保持安静。以后想重新查看时,打开系统设置,再进入通用即可再次运行。","productTour.back":"上一步","productTour.next":"下一步","productTour.finish":"完成","productTour.skip":"跳过教程","heartbeats.title":"心跳","heartbeats.description":"查看所有组织的定时心跳配置。你可以在这里看到哪些已调度、哪些只是已配置,并直接按行启停心跳。","heartbeats.loadLoading":"正在加载调度心跳...","heartbeats.loadFailed":"加载调度心跳失败。","heartbeats.updateFailed":"更新心跳失败。","heartbeats.disableAllFailed":"批量关闭所有心跳失败。","heartbeats.summary.scheduled":"已调度","heartbeats.summary.configuredInactive":"已配置未激活","heartbeats.summary.disabled":"已关闭","heartbeats.summary.organization":"个组织","heartbeats.summary.organizations":"个组织","heartbeats.disableAll":"全部关闭","heartbeats.disabling":"关闭中...","heartbeats.confirmDisableAll.one":"确定要关闭全部 {{count}} 个已启用智能体的定时心跳吗?","heartbeats.confirmDisableAll.many":"确定要关闭全部 {{count}} 个已启用智能体的定时心跳吗?","heartbeats.empty":"没有符合当前条件的调度心跳。","heartbeats.section.title":"已调度智能体","heartbeats.section.description":"按组织分组展示已启用心跳的智能体,方便你统一查看归属、频率与最近心跳状态。","heartbeats.table.agent":"智能体","heartbeats.table.role":"角色","heartbeats.table.scheduler":"调度状态","heartbeats.table.interval":"间隔","heartbeats.table.lastHeartbeat":"最近心跳","heartbeats.table.actions":"操作","heartbeats.scheduler.scheduled":"已调度","heartbeats.scheduler.configuredInactive":"已配置,未激活","heartbeats.scheduler.disabled":"已关闭","heartbeats.never":"从未","heartbeats.fullAgentConfig":"完整智能体配置","heartbeats.timerState":"定时心跳状态","heartbeats.on":"开","heartbeats.off":"关","chat.annotations.selectionUnavailable":"选区已不可用","chat.annotations.selectionUnavailableBody":"请重新选择回复中的文字后再试。","chat.annotations.couldNotAdd":"无法添加批注","chat.annotations.added":"已添加批注","chat.annotations.removed":"已移除批注"},ZFe=["placeholder","title","aria-label"],OLt=["code","pre","script","style","textarea","[contenteditable='true']",".cm-editor",".cm-content",".mdxeditor","[data-i18n-ignore='true']"].join(", "),Wve=new WeakMap,Zve=new WeakMap;function HFe(e){return e?e.closest(OLt)!=null:!0}function XFe(e,t){const n=e.parentElement;if(!n||HFe(n))return;const r=e.textContent??"";let s=Wve.get(e);s?r!==s.rendered&&r!==s.source&&(s.source=r):(s={source:r,rendered:r},Wve.set(e,s));const a=UO(t,s.source);s.rendered=a,r!==a&&(e.textContent=a)}function GFe(e,t,n){if(!e.hasAttribute(t)||HFe(e))return;const r=e.getAttribute(t)??"";let s=Zve.get(e);s||(s=new Map,Zve.set(e,s));let a=s.get(t);a?r!==a.rendered&&r!==a.source&&(a.source=r):(a={source:r,rendered:r},s.set(t,a));const o=UO(n,a.source);a.rendered=o,r!==o&&e.setAttribute(t,o)}function Dre(e,t){if(e.nodeType===Node.TEXT_NODE){XFe(e,t);return}if(e.nodeType!==Node.ELEMENT_NODE)return;const n=e;for(const r of ZFe)GFe(n,r,t);for(const r of Array.from(n.childNodes))Dre(r,t)}function jLt({locale:e}){return m.useEffect(()=>{if(typeof document>"u")return;const t=document.body;if(!t)return;Dre(t,e);const n=new MutationObserver(r=>{for(const s of r){if(s.type==="characterData"){XFe(s.target,e);continue}if(s.type==="attributes"){GFe(s.target,s.attributeName,e);continue}for(const a of Array.from(s.addedNodes))Dre(a,e)}});return n.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[...ZFe]}),()=>n.disconnect()},[e]),null}const CLt={en:WFe,"zh-CN":SLt},YFe=m.createContext(null);function NLt(e,t){return t?e.replaceAll(/\{\{(\w+)\}\}/g,(n,r)=>{const s=t[r];return s==null?n:String(s)}):e}function PLt(e,t,n){const r=CLt[e][t]??WFe[t];return NLt(r,n)}function ILt({children:e}){var a;const n=((a=Te({queryKey:V.health,queryFn:()=>FA.get(),retry:!1}).data)==null?void 0:a.uiLocale)??"en";m.useEffect(()=>{typeof document>"u"||(document.documentElement.lang=n)},[n]);const r=m.useCallback((o,l)=>PLt(n,o,l),[n]),s=m.useMemo(()=>({locale:n,t:r}),[n,r]);return i.jsxs(YFe.Provider,{value:s,children:[i.jsx(jLt,{locale:n}),e]})}function as(){const e=m.useContext(YFe);if(!e)throw new Error("useI18n must be used within I18nProvider");return e}const tv="about:blank";function TLt(e){try{return new URL(e).hostname||e}catch{return e}}function _Lt(e){const t=TLt(e.url);return e.code==="ERR_CONNECTION_REFUSED"?{summary:`${t} refused to connect.`,suggestions:["Checking the connection","Checking the proxy and firewall"]}:e.code==="ERR_NAME_NOT_RESOLVED"?{summary:`${t}'s server IP address could not be found.`,suggestions:["Checking the address","Checking the connection"]}:e.code==="ERR_TIMED_OUT"?{summary:`${t} took too long to respond.`,suggestions:["Checking the connection","Trying again later"]}:{summary:`The page at ${t} could not be loaded.`,suggestions:["Checking the address","Trying again later"]}}function MLt(e){var r;return!e||e.type==="keyUp"||!(((r=e.key)==null?void 0:r.toLowerCase())==="w"||e.code==="KeyW")||e.alt||e.shift?!1:navigator.platform.toLowerCase().includes("mac")?!!e.meta&&!e.control:!!e.control&&!e.meta}function xR(e){return`https://www.google.com/search?q=${encodeURIComponent(e)}`}function ELt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function DLt(e){try{return new URL(e).toString()}catch{return e.trim()}}function RLt(e){return decodeURIComponent(e.pathname).replace(/\/+$/g,"").split("/").filter(Boolean).at(-1)||"File"}function LLt(e,t){try{const n=decodeURIComponent(t.pathname);return/^file:\/\/\//i.test(e)&&t.protocol==="file:"&&t.hostname===""&&n.startsWith("/")&&!/^\/[\\/]/.test(n)}catch{return!1}}function z5(e){const t=e.trim();if(!t||t===tv)return"New tab";try{const n=new URL(t);return n.protocol==="file:"?RLt(n):n.hostname||n.protocol.replace(":","")||"Browser"}catch{return t}}function zLt(e){const t=e.trim();if(!t||/^about:blank$/i.test(t))return tv;if(/^(https?|file):/i.test(t))try{const n=new URL(t);return n.protocol==="http:"||n.protocol==="https:"||LLt(t,n)?n.toString():xR(t)}catch{return xR(t)}return/^(localhost|\d{1,3}(?:\.\d{1,3}){3})(:\d+)?(\/.*)?$/i.test(t)?`http://${t}`:/^[a-z][a-z0-9+.-]*:/i.test(t)||/\s/.test(t)?xR(t):t.includes(".")?`https://${t}`:xR(t)}function E4(e=tv,t={newTab:!0}){return{kind:"browser",url:e,label:z5(e),tabId:ELt(),...t.favicon?{favicon:t.favicon}:{},...t.newTab===!1?{dedupeKey:DLt(e)}:{}}}const QX=[.25,.33,.5,.67,.75,.8,.9,1,1.1,1.25,1.5,1.75,2,2.5,3,4,5],JFe="rudder.browser.side-panel-onboarding.dismissed.v1",eBe="rudder.browser.side-panel-onboarding.session-dismissed.v1",UX="rudder:browser-side-panel-onboarding-dismissed";function $Lt(){if(typeof window>"u")return!0;try{if(window.localStorage.getItem(JFe)==="true")return!0}catch{}try{return window.sessionStorage.getItem(eBe)==="true"}catch{return!1}}function FLt(e){if(typeof e!="string")return null;const t=e.trim();if(!t||t.length>J_)return null;if(t.startsWith("data:image/"))return t;try{const n=new URL(t);return n.protocol==="http:"||n.protocol==="https:"?t:null}catch{return null}}function tBe({active:e,canOpenNewTab:t,surface:n,target:r,targetKey:s,onOpenBrowserSettings:a,onOpenTarget:o,onReplaceTarget:l,onCloseTarget:c,onCycleTab:d,onWebContentsIdChange:u,onRegisterShortcutController:f}){const{t:A}=as(),h=m.useRef(null),g=m.useRef(null),x=m.useRef(!1),y=m.useRef(r.url),v=m.useRef(r.url),w=m.useRef(r),k=m.useRef(l),O=m.useRef(c),j=m.useRef(d),C=m.useRef(u),N=m.useRef(e),I=m.useRef(null),[E,_]=m.useState(null),T=m.useRef(1),[R,M]=m.useState(r.url===tv?"":r.url),[L,U]=m.useState(r.url),[B,z]=m.useState(r.url),[H,J]=m.useState(!1),[F,Q]=m.useState({canGoBack:!1,canGoForward:!1}),[W,$]=m.useState(null),[ee,re]=m.useState(!1),[ne,te]=m.useState(()=>!$Lt()),ce=L===tv,se=W?_Lt(W):null;v.current=L,w.current=r,k.current=l,O.current=c,j.current=d,C.current=u,N.current=e;const he=m.useCallback((me,ye)=>{const qe=g.current;if(!x.current||!qe||qe.tagName.toLowerCase()!=="webview")return ye;try{return me(qe)}catch{return ye}},[]),we=m.useCallback(me=>he(ye=>{var qe;return((qe=ye.getURL)==null?void 0:qe.call(ye))??me},me),[he]),Ue=m.useCallback(()=>{Q({canGoBack:he(me=>{var ye;return!!((ye=me.canGoBack)!=null&&ye.call(me))},!1),canGoForward:he(me=>{var ye;return!!((ye=me.canGoForward)!=null&&ye.call(me))},!1)})},[he]),je=m.useCallback(me=>{he(qe=>qe.setZoomFactor?(qe.setZoomFactor(me),!0):!1,!1)&&(T.current=me)},[he]),ke=m.useCallback(me=>{const ye=T.current;let qe=0,Ce=Number.POSITIVE_INFINITY;QX.forEach((G,Ae)=>{const Je=Math.abs(G-ye);Je<Ce&&(Ce=Je,qe=Ae)});const X=Math.max(0,Math.min(QX.length-1,qe+me));je(QX[X]??1)},[je]),Se=m.useCallback(me=>{var ye,qe;if(e)switch(me){case"new_tab":t&&o(E4());return;case"focus_location":(ye=h.current)==null||ye.focus(),(qe=h.current)==null||qe.select();return;case"reload":ce||he(Ce=>{var X;return(X=Ce.reload)==null?void 0:X.call(Ce)},void 0);return;case"reload_ignoring_cache":ce||he(Ce=>{var X;return(X=Ce.reloadIgnoringCache)==null?void 0:X.call(Ce)},void 0);return;case"go_back":ce||he(Ce=>{var X,G;(X=Ce.canGoBack)!=null&&X.call(Ce)&&((G=Ce.goBack)==null||G.call(Ce))},void 0);return;case"go_forward":ce||he(Ce=>{var X,G;(X=Ce.canGoForward)!=null&&X.call(Ce)&&((G=Ce.goForward)==null||G.call(Ce))},void 0);return;case"zoom_in":ce||ke(1);return;case"zoom_out":ce||ke(-1);return;case"zoom_reset":ce||je(1)}},[e,je,t,ce,o,he,ke]);I.current=Se,m.useEffect(()=>(f(s,Se),()=>f(s,null)),[Se,f,s]);const oe=m.useCallback((me,ye=z5(me))=>{const qe=w.current.url!==me,Ce={...w.current,url:me,label:ye,favicon:qe?void 0:w.current.favicon};v.current=me,w.current=Ce,U(me),M(me===tv?"":me),y.current=me,k.current(s,Ce)},[s]);m.useEffect(()=>{const me=y.current!==r.url;y.current=r.url,v.current=r.url,w.current=r,U(r.url),M(r.url===tv?"":r.url),me&&(z(r.url),$(null),re(!1)),x.current?Ue():Q({canGoBack:!1,canGoForward:!1})},[r.label,r.url,Ue]),m.useEffect(()=>{const me=E;if(!me||me.tagName.toLowerCase()!=="webview")return;const ye=()=>{J(!0),$(null),re(!1)},qe=ft=>{const dt=!("isMainFrame"in ft)||ft.isMainFrame!==!1,yt="url"in ft&&typeof ft.url=="string"?ft.url:"";dt&&yt&&yt!==v.current&&oe(yt,z5(yt))},Ce=()=>{J(!1);const ft=we("");ft&&ft!==v.current&&oe(ft,z5(ft)),Ue()},X=ft=>{const dt="url"in ft&&typeof ft.url=="string"?ft.url:we("");dt&&oe(dt,z5(dt)),Ue()},G=ft=>{const dt=we(v.current),yt="title"in ft&&typeof ft.title=="string"&&ft.title.trim()?ft.title.trim():z5(dt),Mt={...w.current,url:dt,label:yt};w.current=Mt,k.current(s,Mt)},Ae=ft=>{const yt=("favicons"in ft&&Array.isArray(ft.favicons)?ft.favicons:[]).map(FLt).find(Xe=>!!Xe);if(!yt||yt===w.current.favicon)return;const Mt={...w.current,favicon:yt};w.current=Mt,k.current(s,Mt)},Je=ft=>{const dt="errorDescription"in ft&&typeof ft.errorDescription=="string"?ft.errorDescription:"Could not load this page.",yt="validatedURL"in ft&&typeof ft.validatedURL=="string"&&ft.validatedURL?ft.validatedURL:v.current;(!("isMainFrame"in ft)||ft.isMainFrame!==!1)&&dt!=="ERR_ABORTED"&&(J(!1),$({code:dt,url:yt}),re(!1)),Ue()},ht=()=>{var dt,yt;x.current=!0;const ft=(dt=me.getWebContentsId)==null?void 0:dt.call(me);typeof ft=="number"&&Number.isFinite(ft)&&((yt=C.current)==null||yt.call(C,ft)),T.current!==1&&he(Mt=>{var Xe;return(Xe=Mt.setZoomFactor)==null?void 0:Xe.call(Mt,T.current)},void 0),Ue()},De=ft=>{var At,it;const dt=ft,yt=dt.input;if(yt&&yt.type!=="keyUp"&&(yt.key==="Tab"||yt.code==="Tab")&&!!yt.control&&!yt.meta&&!yt.alt&&N.current&&j.current){ft.preventDefault(),j.current(yt.shift?-1:1);return}if((At=Pn())!=null&&At.onBrowserShortcut)return;if(MLt(dt.input)){ft.preventDefault(),O.current(w.current);return}if(!dt.input||!N.current)return;const Xe=WEe(dt.input,{isMac:navigator.platform.toLowerCase().includes("mac")});Xe&&(ft.preventDefault(),(it=I.current)==null||it.call(I,Xe))};return me.addEventListener("dom-ready",ht),me.addEventListener("before-input-event",De),me.addEventListener("did-start-loading",ye),me.addEventListener("did-start-navigation",qe),me.addEventListener("did-stop-loading",Ce),me.addEventListener("did-navigate",X),me.addEventListener("did-navigate-in-page",X),me.addEventListener("page-title-updated",G),me.addEventListener("page-favicon-updated",Ae),me.addEventListener("did-fail-load",Je),Ue(),()=>{me.removeEventListener("dom-ready",ht),me.removeEventListener("before-input-event",De),me.removeEventListener("did-start-loading",ye),me.removeEventListener("did-start-navigation",qe),me.removeEventListener("did-stop-loading",Ce),me.removeEventListener("did-navigate",X),me.removeEventListener("did-navigate-in-page",X),me.removeEventListener("page-title-updated",G),me.removeEventListener("page-favicon-updated",Ae),me.removeEventListener("did-fail-load",Je)}},[oe,we,he,s,Ue,E]);const fe=m.useCallback(me=>{g.current=me,x.current=!1,_(me),me||Q({canGoBack:!1,canGoForward:!1})},[]);m.useEffect(()=>()=>{var me;(me=C.current)==null||me.call(C,null)},[]),m.useEffect(()=>{const me=()=>te(!1);return window.addEventListener(UX,me),()=>{window.removeEventListener(UX,me)}},[]);const Ie=()=>{te(!1);try{window.localStorage.setItem(JFe,"true")}catch{}try{window.sessionStorage.setItem(eBe,"true")}catch{}window.dispatchEvent(new Event(UX))},ue=m.useCallback(me=>{const ye=zLt(me);$(null),re(!1),z(ye),oe(ye,z5(ye))},[oe]),be=m.useCallback(()=>{re(!1),he(me=>{var ye;(ye=me.reload)==null||ye.call(me)},void 0)},[he]),at=me=>{me.preventDefault();const qe=new FormData(me.currentTarget).get("browser-url");ue(typeof qe=="string"?qe:R)},ve=()=>{var ye;if(ce)return;const me=Pn();if(me){((ye=me.forceOpenExternal)==null?void 0:ye.call(me,L))??me.openExternal(L);return}window.open(L,"_blank","noopener,noreferrer")};return i.jsxs("div",{className:"flex min-h-full flex-col bg-[color:var(--surface-elevated)]","data-testid":e?"chat-side-panel-browser-view":"chat-side-panel-browser-view-hidden","data-browser-tab-id":r.tabId,"data-active":e?"true":"false",children:[i.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-2 py-2","data-testid":"chat-side-panel-browser-toolbar",children:[i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Back",disabled:!F.canGoBack,onClick:()=>he(me=>{var ye;(ye=me.goBack)==null||ye.call(me)},void 0),children:i.jsx(yx,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Forward",disabled:!F.canGoForward,onClick:()=>he(me=>{var ye;(ye=me.goForward)==null||ye.call(me)},void 0),children:i.jsx(j4,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Reload",disabled:ce,onClick:be,children:i.jsx(s2,{className:q("h-3.5 w-3.5",H&&"animate-spin")})}),i.jsx("form",{className:"min-w-0 flex-1",onSubmit:at,children:i.jsx(Vn,{ref:h,"aria-label":"Browser URL",name:"browser-url",value:R,onChange:me=>M(me.currentTarget.value),placeholder:"Enter a URL",className:"h-8 rounded-[var(--radius-md)] bg-[color:var(--surface-inset)] font-mono text-xs"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open new browser tab",title:t?"Open new browser tab":"Browser tab limit reached",disabled:!t,onClick:()=>o(E4()),children:i.jsx(Ur,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open browser page externally",disabled:ce,onClick:ve,children:i.jsx(La,{className:"h-3.5 w-3.5"})})]}),i.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col bg-[color:var(--surface-inset)]","data-testid":"chat-side-panel-browser-content",children:[e&&n==="side_panel"&&ne?i.jsx(KFe,{testId:"browser-side-panel-onboarding",className:"absolute right-3 top-3 z-20 w-[min(24rem,calc(100%-1.5rem))] shadow-[var(--shadow-lg)]",icon:i.jsx(oue,{"aria-hidden":"true"}),title:A("browser.onboarding.title"),description:A("browser.onboarding.description"),stackActions:!0,actions:i.jsxs(i.Fragment,{children:[a?i.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:()=>{Ie(),a()},children:A("browser.onboarding.settings")}):null,i.jsx(ie,{type:"button",size:"sm",onClick:Ie,children:A("browser.onboarding.dismiss")})]})}):null,ce?i.jsx("div",{className:"flex min-h-[44vh] flex-1 items-center justify-center px-6 text-center","data-testid":"chat-side-panel-browser-start",children:i.jsxs("div",{className:"max-w-[18rem]",children:[i.jsx(Vm,{className:"mx-auto h-12 w-12 text-muted-foreground"}),i.jsx("h3",{className:"mt-4 text-base font-semibold text-foreground",children:"Start browsing"}),i.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Enter a URL to open a page."})]})}):i.jsxs("div",{className:"relative flex min-h-[52vh] flex-1",children:[m.createElement("webview",{ref:fe,src:B,className:q("min-h-[52vh] flex-1 bg-[color:var(--surface-elevated)]",W&&"invisible"),"data-testid":e?"chat-side-panel-browser-webview":"chat-side-panel-browser-webview-hidden","data-browser-tab-id":r.tabId,"data-active":e?"true":"false",allowpopups:"true"}),W?i.jsx("div",{role:"alert","data-testid":"chat-side-panel-browser-error",className:"absolute inset-0 flex overflow-y-auto bg-[color:var(--surface-elevated)] px-8 py-10",children:i.jsxs("div",{className:"m-auto w-full max-w-[32rem]",children:[i.jsx(u7t,{className:"h-12 w-12 text-muted-foreground","aria-hidden":"true"}),i.jsx("h3",{className:"mt-6 text-xl font-semibold text-foreground",children:"This site can't be reached"}),i.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:se==null?void 0:se.summary}),i.jsxs("div",{className:"mt-5 text-sm text-muted-foreground",children:[i.jsx("p",{children:"Try:"}),i.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-6",children:se==null?void 0:se.suggestions.map(me=>i.jsx("li",{children:me},me))})]}),i.jsx("p",{className:"mt-5 font-mono text-xs text-muted-foreground",children:W.code}),ee?i.jsx("p",{className:"mt-4 break-all rounded-[var(--radius-md)] border border-[color:var(--border-soft)] bg-[color:var(--surface-inset)] px-3 py-2 font-mono text-xs text-muted-foreground",children:W.url}):null,i.jsxs("div",{className:"mt-7 flex items-center justify-between gap-3",children:[i.jsx(ie,{type:"button",variant:"outline",size:"sm","aria-expanded":ee,onClick:()=>re(me=>!me),children:"Details"}),i.jsxs(ie,{type:"button",size:"sm",onClick:be,children:[i.jsx(s2,{className:"h-3.5 w-3.5"}),"Reload"]})]})]})}):null]})]})]})}function wf(e,t){return(e==null?void 0:e.trim())||t}function dB(e,t){return e.split("/").filter(Boolean).at(-1)??t}function nBe(e){try{return new URL(e,"http://rudder.local")}catch{return null}}function rBe(e){return(e.searchParams.get("messageId")??e.searchParams.get("targetMessageId")??"").trim()||null}function BLt(e){const t=decodeURIComponent(e.hash.replace(/^#/,"")).trim();return t.startsWith("comment-")&&t.slice(8).trim()||null}function Rre(e){return e.kind==="issue"?`issue:${e.issueId}:${e.commentId??""}`:e.kind==="issue_proposal"?`issue-proposal:${e.conversationId}:${e.messageId}`:e.kind==="automation"?`automation:${e.automationId}`:e.kind==="chat"?`chat:${e.conversationId}:${e.messageId??""}`:e.kind==="subagents"?`subagents:${e.conversationId}`:e.kind==="subagent"?`subagent:${e.threadId}`:e.kind==="side_chat"?e.conversationId?`side-chat:${e.conversationId}`:`side-chat:draft:${e.clientMutationId}`:e.kind==="library_document"?`library-document:${e.documentId}`:e.kind==="library_entry"?`library-entry:${e.entryId}:${e.path??""}`:e.kind==="library_file"?`library-file:${e.filePath}`:e.kind==="local_file"?`local-file:${e.filePath}`:e.kind==="organization_skill_file"?`organization-skill-file:${e.skillId}:${e.filePath}`:e.kind==="local_apps"?"local-apps":e.kind==="local_app"?`local-app:${encodeURIComponent(e.desktopInstallationId)}:${encodeURIComponent(e.appPublicId)}:${encodeURIComponent(e.localBindingId)}`:e.kind==="library_directory"?`library-directory:${e.directoryPath}`:e.kind==="browser"?`browser-tab:${e.tabId}`:`placeholder:${e.targetKind}`}function _f(e){return e.kind==="automation"||e.kind==="library_document"||e.kind==="library_entry"||e.kind==="library_file"||e.kind==="library_directory"||e.kind==="browser"||e.kind==="local_app"}function gs(e){const t=Rre(e);return e.kind==="browser"||!_f(e)||!e.viewInstanceId?t:`${t}:view:${e.viewInstanceId}`}function QLt(e,t){var l,c,d;const n=nBe(e);if(!n||n.origin!=="http://rudder.local")return null;const r=n.pathname.split("/").filter(Boolean).map(u=>{try{return decodeURIComponent(u)}catch{return u}}),s=r.length>=2&&r.at(-2)==="issues"?(l=r.at(-1))==null?void 0:l.trim():"";if(s)return{kind:"issue",issueId:s,ref:(t==null?void 0:t.trim())||null,commentId:BLt(n),label:wf(t,"Issue")};const a=r.length>=2&&r.at(-2)==="automations"?(c=r.at(-1))==null?void 0:c.trim():"";if(a)return{kind:"automation",automationId:a,label:wf(t,n.searchParams.get("t")??n.searchParams.get("title")??"Automation")};const o=r.length>=2&&r.at(-2)==="chat"?(d=r.at(-1))==null?void 0:d.trim():"";if(o)return{kind:"chat",conversationId:o,messageId:rBe(n),label:wf(t,"Chat")};if(r.at(-1)==="library"){const u=(n.searchParams.get("skill")??"").trim();if(u)return{kind:"organization_skill_file",skillId:u,filePath:(n.searchParams.get("skillFile")??"SKILL.md").trim()||"SKILL.md",label:wf(t,"Skill")};const f=(n.searchParams.get("document")??n.searchParams.get("doc")??"").trim();if(f)return{kind:"library_document",documentId:f,label:wf(t,n.searchParams.get("t")??n.searchParams.get("title")??"Library document")};const A=(n.searchParams.get("path")??"").trim();if(A)return{kind:"library_file",filePath:A,label:wf(t,dB(A,"Library file"))};const h=(n.searchParams.get("directory")??"").trim();if(h)return{kind:"library_directory",directoryPath:h,label:wf(t,dB(h,"Library directory"))};const g=(n.searchParams.get("entry")??"").trim();if(g)return{kind:"library_entry",entryId:g,path:A||null,label:wf(t,g)}}return null}function ULt(e,t){const n=$c(e);if(!n)return QLt(e,t);if(n.kind==="issue")return{kind:"issue",issueId:n.issueId,ref:n.ref??(t==null?void 0:t.trim())??null,commentId:n.commentId,label:wf(t,n.ref??"Issue")};if(n.kind==="automation")return{kind:"automation",automationId:n.automationId,label:wf(t,n.title??"Automation")};if(n.kind==="chat"){const r=nBe(e);return{kind:"chat",conversationId:n.conversationId,messageId:r?rBe(r):null,label:wf(t,n.title??"Chat")}}return n.kind==="library_doc"?{kind:"library_document",documentId:n.documentId,label:wf(t,n.title??"Library document")}:n.kind==="library_entry"?{kind:"library_entry",entryId:n.entryId,path:n.path,label:wf(t,n.title??n.path??"Library entry")}:n.kind==="library_file"?{kind:"library_file",filePath:n.filePath,label:wf(t,n.title??dB(n.filePath,"Library file"))}:n.kind==="library_directory"?{kind:"library_directory",directoryPath:n.directoryPath,label:wf(t,n.title??dB(n.directoryPath,"Library directory"))}:null}const VLt=m.lazy(async()=>({default:(await Wt(async()=>{const{AutomationDetail:e}=await Promise.resolve().then(()=>gNn);return{AutomationDetail:e}},void 0)).AutomationDetail})),qLt=m.lazy(async()=>({default:(await Wt(async()=>{const{LibraryLiveSurface:e}=await import("./LibraryLiveSurface-Cd6wYgzJ.js");return{LibraryLiveSurface:e}},[])).LibraryLiveSurface})),lfe=m.createContext(null);function uB(e){var n;const t=((n=e.viewInstanceId)==null?void 0:n.trim())||(e.kind==="browser"?e.tabId.trim():"");if(!t)throw new Error(`${e.kind} live surface requires a viewInstanceId`);return t}function jI(e,t){return JSON.stringify([e.trim(),t.kind,uB(t)])}function sBe(e){try{const t=JSON.parse(e);return Array.isArray(t)&&typeof t[0]=="string"?t[0]:""}catch{return""}}function VX(e,t){return e.kind===t.kind&&uB(e)===uB(t)}function Lre(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,l)=>Lre(o,t[l]));const n=e,r=t,s=Object.keys(n).filter(o=>n[o]!==void 0),a=Object.keys(r).filter(o=>r[o]!==void 0);return s.length===a.length&&s.every(o=>Object.hasOwn(r,o)&&Lre(n[o],r[o]))}function iBe(e){return e.startsWith("main:")?"workbench":"side_panel"}function zre(e){if(!aBe(e))return!1;const t=e.element.getBoundingClientRect();return t.width>0&&t.height>0}function aBe(e){return!!(e!=null&&e.active&&e.element.isConnected)}function KLt({children:e}){const t=m.useRef(new Map),n=m.useRef(new Map),[r,s]=m.useState(0),a=m.useCallback(()=>{s(T=>T+1)},[]),o=m.useCallback(T=>{const R=t.current.get(T.runtimeId);if(R&&!VX(R.target,T.target))return()=>{};const M=R??{interactionLocked:!1,leaseOwnerId:null,owners:new Map,renderSurface:T.renderSurface??null,runtimeId:T.runtimeId,shortcutController:null,target:T.target,webContentsId:null};return M.owners.set(T.ownerId,T),T.renderSurface&&(M.renderSurface=T.renderSurface),t.current.set(T.runtimeId,M),a(),()=>{const L=t.current.get(T.runtimeId);L&&(L.owners.delete(T.ownerId),L.leaseOwnerId===T.ownerId&&(L.leaseOwnerId=null),a())}},[a]),l=m.useCallback(T=>{const R=t.current.get(T.runtimeId);if(!R||!VX(R.target,T.target))return;const M=R.owners.get(T.ownerId);if(!M)return;const L=!Lre(M.target,T.target);(M.active!==T.active||M.callbacks!==T.callbacks||M.element!==T.element||M.hostId!==T.hostId||M.renderSurface!==T.renderSurface||L)&&(R.owners.set(T.ownerId,T),L&&R.leaseOwnerId===T.ownerId&&!R.interactionLocked&&(R.target=T.target),T.renderSurface&&(R.renderSurface=T.renderSurface),a())},[a]),c=m.useCallback((T,R)=>{const M=t.current.get(T),L=M==null?void 0:M.owners.get(R);return!M||!zre(L)?!1:(M.leaseOwnerId===R||(M.leaseOwnerId=R,a()),!0)},[a]),d=m.useCallback((T,R)=>{const M=t.current.get(T),L=M==null?void 0:M.owners.get(R);return!M||!aBe(L)||M.leaseOwnerId&&M.leaseOwnerId!==R?!1:(M.leaseOwnerId===R||(M.leaseOwnerId=R,a()),!0)},[a]),u=m.useCallback(async(T,R,M=5e3)=>{var U;const L=Date.now();for(;Date.now()-L<=M;){const B=(U=t.current.get(T))==null?void 0:U.owners.get(R);if(zre(B))return!0;await new Promise(z=>{window.setTimeout(z,16)})}return!1},[]),f=m.useCallback((T,R)=>{const M=t.current.get(T);!M||M.interactionLocked===R||(M.interactionLocked=R,a())},[a]),A=m.useCallback((T,R)=>{const M=t.current.get(T);return!M||!VX(M.target,R)?!1:(M.target=R,a(),!0)},[a]),h=m.useCallback(T=>{const R=t.current.get(T);R&&(R.webContentsId!==null&&n.current.delete(R.webContentsId),t.current.delete(T),a())},[a]),g=m.useCallback((T,R)=>{const M=t.current.get(T);!M||M.webContentsId===R||(M.webContentsId!==null&&n.current.delete(M.webContentsId),M.webContentsId=R,R!==null&&n.current.set(R,T))},[]),x=m.useCallback(T=>{const R=n.current.get(T),M=R?t.current.get(R):null,L=M!=null&&M.leaseOwnerId?M.owners.get(M.leaseOwnerId):null;return!M||!L?null:{hostId:L.hostId,ownerId:L.ownerId,runtimeId:M.runtimeId,surface:iBe(L.ownerId),targetKind:M.target.kind}},[]),y=m.useCallback((T,R)=>{const M=n.current.get(T),L=M?t.current.get(M):null,U=L!=null&&L.leaseOwnerId?L.owners.get(L.leaseOwnerId):null;return U!=null&&U.callbacks.onOpenTarget?(U.callbacks.onOpenTarget(R),!0):!1},[]),v=m.useCallback(T=>{const R=t.current.get(T),M=R!=null&&R.leaseOwnerId?R.owners.get(R.leaseOwnerId):null;return!R||!(M!=null&&M.callbacks.onCloseTarget)?!1:(M.callbacks.onCloseTarget(R.target),!0)},[]),w=m.useCallback(T=>{const R=n.current.get(T);return R?v(R):!1},[v]),k=m.useCallback((T,R)=>{const M=t.current.get(T);!M||M.target.kind!=="browser"||(M.shortcutController=R)},[]),O=m.useCallback((T,R)=>{const M=t.current.get(T);return!M||M.target.kind!=="browser"||!M.leaseOwnerId||!M.shortcutController?!1:(M.shortcutController(R),!0)},[]),j=m.useCallback((T,R)=>{const M=n.current.get(T);return M?O(M,R):!1},[O]),C=m.useCallback(T=>Array.from(t.current.values()).filter(R=>R.target.kind==="browser"&&sBe(R.runtimeId)===T).length,[]),N=m.useCallback(T=>{var R;return((R=t.current.get(T))==null?void 0:R.target)??null},[]),I=m.useCallback(T=>t.current.has(T),[]),E=m.useCallback(()=>Array.from(t.current.values()),[]),_=m.useMemo(()=>({autoClaimSurface:d,claimSurface:c,closeTargetForGuest:w,closeTargetForRuntime:v,dispatchBrowserShortcutForGuest:j,dispatchBrowserShortcutForRuntime:O,disposeSurface:h,getGuestOwner:x,getLiveBrowserCount:C,getRuntimeTarget:N,hasSurface:I,listRecords:E,openTargetForGuest:y,registerBrowserShortcutController:k,registerOwner:o,registerWebContentsId:g,revision:r,setInteractionLocked:f,updateOwner:l,updateTarget:A,waitForOwner:u}),[d,c,w,v,j,O,h,x,C,N,I,E,y,k,o,g,r,f,l,A,u]);return i.jsx(lfe.Provider,{value:_,children:e})}function IM(){const e=m.useContext(lfe);if(!e)throw new Error("useLiveSurfaceRuntime must be used inside LiveSurfaceRuntimeProvider");return e}function cfe(){return m.useContext(lfe)}function oBe({active:e,autoClaim:t=!0,callbacks:n={},hostId:r,ownerId:s,renderSurface:a,runtimeId:o,target:l,...c}){const{autoClaimSurface:d,registerOwner:u,updateOwner:f}=IM(),A=m.useRef(null),h=m.useRef(n);h.current=n;const g=m.useMemo(()=>({get annotationConversationId(){return h.current.annotationConversationId},get canOpenNewTab(){return h.current.canOpenNewTab},get savedViewId(){return h.current.savedViewId},onCloseTarget:x=>{var y,v;return(v=(y=h.current).onCloseTarget)==null?void 0:v.call(y,x)},onCycleTab:x=>{var y,v;return(v=(y=h.current).onCycleTab)==null?void 0:v.call(y,x)},onLocalAppTitleChange:x=>{var y,v;return(v=(y=h.current).onLocalAppTitleChange)==null?void 0:v.call(y,x)},onOpenBrowserSettings:()=>{var x,y;return(y=(x=h.current).onOpenBrowserSettings)==null?void 0:y.call(x)},onOpenTarget:x=>{var y,v;return(v=(y=h.current).onOpenTarget)==null?void 0:v.call(y,x)},onRegisterShortcutController:(x,y)=>{var v,w;return(w=(v=h.current).onRegisterShortcutController)==null?void 0:w.call(v,x,y)},onReplaceTarget:x=>{var y,v;return(v=(y=h.current).onReplaceTarget)==null?void 0:v.call(y,x)}}),[]);return m.useLayoutEffect(()=>{const x=A.current;if(x)return u({active:e,callbacks:g,element:x,hostId:r,ownerId:s,renderSurface:a,runtimeId:o,target:l})},[r,s,u,o]),m.useLayoutEffect(()=>{const x=A.current;if(!x)return;f({active:e,callbacks:g,element:x,hostId:r,ownerId:s,renderSurface:a,runtimeId:o,target:l}),e&&t&&d(o,s)},[e,t,d,r,s,a,o,g,l,f]),i.jsx("div",{...c,ref:A,"data-owner-id":s})}function WLt({record:e,owner:t,visible:n}){var f;const r=IM(),s=e.target,a=t==null?void 0:t.callbacks,o=t?iBe(t.ownerId):"side_panel",l=A=>{var h;(h=a==null?void 0:a.onCloseTarget)==null||h.call(a,A)},c=A=>{var h;(h=a==null?void 0:a.onOpenTarget)==null||h.call(a,A)},d=A=>{var h;(A.kind==="automation"||A.kind==="browser"||A.kind==="library_directory"||A.kind==="library_document"||A.kind==="library_entry"||A.kind==="library_file"||A.kind==="local_app")&&r.updateTarget(e.runtimeId,A),e.interactionLocked||(h=a==null?void 0:a.onReplaceTarget)==null||h.call(a,A)},u=(f=e.renderSurface)==null?void 0:f.call(e,{active:n,closeTarget:l,openTarget:c,replaceTarget:d,surface:o,target:s});return s.kind==="browser"?i.jsx(tBe,{active:n,canOpenNewTab:(a==null?void 0:a.canOpenNewTab)??!1,surface:o,target:s,targetKey:gs(s),onCloseTarget:l,onCycleTab:a==null?void 0:a.onCycleTab,onOpenBrowserSettings:a==null?void 0:a.onOpenBrowserSettings,onOpenTarget:c,onRegisterShortcutController:(A,h)=>{var g;r.registerBrowserShortcutController(e.runtimeId,h),(g=a==null?void 0:a.onRegisterShortcutController)==null||g.call(a,A,h)},onReplaceTarget:(A,h)=>d(h),onWebContentsIdChange:A=>{r.registerWebContentsId(e.runtimeId,A)}}):s.kind==="local_app"?i.jsx(qFe,{active:n,savedViewId:a==null?void 0:a.savedViewId,target:s,onTitleChange:a==null?void 0:a.onLocalAppTitleChange}):u!==void 0?i.jsx(i.Fragment,{children:u}):s.kind==="automation"?i.jsx(m.Suspense,{fallback:i.jsx("div",{className:"h-full"}),children:i.jsx(VLt,{automationId:s.automationId,onClose:()=>l(s),surface:o})}):i.jsx(m.Suspense,{fallback:i.jsx("div",{className:"h-full"}),children:i.jsx(qLt,{active:n,annotationConversationId:a==null?void 0:a.annotationConversationId,organizationId:sBe(e.runtimeId),onOpenTarget:c,surface:o,target:s})})}function ZLt(){const e=IM(),t=e.listRecords(),[,n]=m.useState(0);return m.useEffect(()=>{const r=()=>n(a=>a+1);window.addEventListener("resize",r),window.addEventListener("scroll",r,!0);const s=typeof ResizeObserver>"u"?null:new ResizeObserver(r);for(const a of e.listRecords())for(const o of a.owners.values())s==null||s.observe(o.element);return()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0),s==null||s.disconnect()}},[e]),i.jsx("div",{className:"pointer-events-none fixed inset-0","data-testid":"live-surface-runtime-layer","aria-label":"Live workspace surfaces",children:t.map(r=>{const s=r.leaseOwnerId?r.owners.get(r.leaseOwnerId)??null:null,a=zre(s),o=a?s.element.getBoundingClientRect():null,l=!a||r.interactionLocked;return i.jsx("div",{"data-testid":"live-surface-runtime-host","data-host-id":s==null?void 0:s.hostId,"data-owner-id":s==null?void 0:s.ownerId,"data-runtime-id":r.runtimeId,"data-target-kind":r.target.kind,"data-view-instance-id":uB(r.target),"aria-hidden":!a,hidden:!a,inert:l?!0:void 0,className:`fixed flex min-h-0 flex-col overflow-hidden bg-[color:var(--surface-panel)] ${s!=null&&s.ownerId.startsWith("side:")?"rounded-[var(--desktop-workspace-radius)]":s!=null&&s.ownerId.startsWith("main:")?r.target.kind==="browser"?"rounded-[var(--desktop-workspace-radius)]":"rounded-b-[var(--desktop-workspace-radius)]":""}`,style:{height:o?`${o.height}px`:"0px",left:o?`${o.left}px`:"0px",pointerEvents:l?"none":"auto",top:o?`${o.top}px`:"0px",width:o?`${o.width}px`:"0px",zIndex:s!=null&&s.ownerId.startsWith("side:")?70:40},children:i.jsx(WLt,{record:r,owner:s,visible:a&&!r.interactionLocked})},r.runtimeId)})})}const wk=[{actionId:"commandPalette.open",label:"Open command palette",description:"Search and jump across Rudder.",scope:"Global",defaultBindings:[{key:"k",code:"KeyK",metaKey:!0},{key:"k",code:"KeyK",ctrlKey:!0}],defaultBindingsByPlatform:{mac:[{key:"k",code:"KeyK",metaKey:!0}],nonMac:[{key:"k",code:"KeyK",ctrlKey:!0}]},configurable:!0,disableable:!0},{actionId:"settings.open",label:"Open settings",description:"Open System Settings.",scope:"Global",defaultBindings:[{key:",",metaKey:!0},{key:",",ctrlKey:!0}],defaultBindingsByPlatform:{mac:[{key:",",metaKey:!0}],nonMac:[{key:",",ctrlKey:!0}]},configurable:!0,disableable:!0},{actionId:"chat.create",label:"New chat",description:"Open the new chat composer.",scope:"Global",defaultBindings:[{key:"s",code:"KeyS",metaKey:!0,altKey:!0},{key:"s",code:"KeyS",ctrlKey:!0,altKey:!0}],defaultBindingsByPlatform:{mac:[{key:"s",code:"KeyS",metaKey:!0,altKey:!0}],nonMac:[{key:"s",code:"KeyS",ctrlKey:!0,altKey:!0}]},configurable:!0,disableable:!0},{actionId:"issue.create",label:"Create issue",description:"Open the new issue dialog.",scope:"Global",defaultBindings:[{key:"n",code:"KeyN",metaKey:!0},{key:"n",code:"KeyN",ctrlKey:!0}],defaultBindingsByPlatform:{mac:[{key:"n",code:"KeyN",metaKey:!0}],nonMac:[{key:"n",code:"KeyN",ctrlKey:!0}]},configurable:!0,disableable:!0},{actionId:"sidebar.toggle",label:"Toggle sidebar",description:"Show or hide the workspace sidebar.",scope:"Global",defaultBindings:[{key:"["}],configurable:!0,disableable:!0},{actionId:"panel.toggle",label:"Toggle panel",description:"Show or hide the context panel.",scope:"Global",defaultBindings:[{key:"]"}],configurable:!0,disableable:!0},{actionId:"system.escapeBack",label:"Navigate back / close detail",description:"System Escape behavior is read-only in this version.",scope:"System",defaultBindings:[{key:"Escape"}],configurable:!1,disableable:!1}],HLt=new Set(wk.filter(e=>e.configurable).map(e=>e.actionId)),XLt=new Set(["Alt","Control","Meta","Shift"]),Hve=new Set(["meta+n","meta+shift+o"]);function TM(){var n,r,s;if(typeof navigator>"u")return"nonMac";const e=navigator,t=((r=(n=e.userAgentData)==null?void 0:n.platform)==null?void 0:r.trim())||((s=e.platform)==null?void 0:s.trim())||"";return/mac|iphone|ipad|ipod/i.test(t)?"mac":"nonMac"}function lBe(e,t=TM()){var n;return(((n=e.defaultBindingsByPlatform)==null?void 0:n[t])??e.defaultBindings).map(S6)}function cBe(e){return e.length===1?e.toLowerCase():e}function S6(e){return{key:cBe(e.key.trim()),...e.code?{code:e.code.trim()}:{},...e.metaKey?{metaKey:!0}:{},...e.ctrlKey?{ctrlKey:!0}:{},...e.altKey?{altKey:!0}:{},...e.shiftKey?{shiftKey:!0}:{}}}function $re(e){const t=S6(e);return[t.metaKey?"meta":"",t.ctrlKey?"ctrl":"",t.altKey?"alt":"",t.shiftKey?"shift":"",t.key].filter(Boolean).join("+")}function dBe(e){if(!(e instanceof HTMLElement)||GLt(e))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||!!e.closest('[contenteditable="true"], [contenteditable="plaintext-only"]')}function GLt(e){let t=e;for(;t;){if(t.hidden||t.getAttribute("aria-hidden")==="true")return!0;const n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden"||n.visibility==="collapse")return!0;t=t.parentElement}return!1}function YLt(e){return XLt.has(e.key)?null:S6({key:e.key,code:e.code||void 0,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey})}function JLt(e,t){const n=S6(t);return(n.code&&e.code?e.code===n.code:cBe(e.key)===n.key)&&e.metaKey===!!n.metaKey&&e.ctrlKey===!!n.ctrlKey&&e.altKey===!!n.altKey&&e.shiftKey===!!n.shiftKey}function dfe(e,t=TM()){const n={};for(const r of wk)HLt.has(r.actionId)&&(n[r.actionId]=lBe(r,t));for(const r of(e==null?void 0:e.shortcuts)??[]){const s=wk.find(a=>a.actionId===r.actionId);if(s!=null&&s.configurable){if(r.disabled===!0){n[r.actionId]=[];continue}if(r.bindings&&r.bindings.length>0){const a=r.bindings.map(S6);if(ezt(r.actionId,a))continue;n[r.actionId]=a}}}return n}function ezt(e,t){return e!=="chat.create"||t.length!==Hve.size?!1:t.every(n=>Hve.has($re(n)))}function b7(e,t,n,r){return n===void 0?!1:(dfe(n,r)[t]??[]).some(a=>JLt(e,a))}function Xve(e,t=TM()){const n=S6(e),r=[];return n.ctrlKey&&r.push(t==="mac"?"⌃":"Ctrl"),n.altKey&&r.push(t==="mac"?"⌥":"Alt"),n.shiftKey&&r.push(t==="mac"?"⇧":"Shift"),n.metaKey&&r.push(t==="mac"?"⌘":"Meta"),r.push(tzt(n.key)),t==="mac"?r.join(""):r.join("+")}function tzt(e){return e===" "?"Space":e==="Escape"?"Esc":e.length===1?e.toUpperCase():e}function nzt(e){const t=S6(e),n=t.key.toLowerCase();return t.metaKey||t.ctrlKey?["l","r","w","q"].includes(n):!1}function rzt(e,t,n,r){const s=$re(t),a=dfe(n,r);for(const[o,l]of Object.entries(a))if(o!==e&&l.some(c=>$re(c)===s))return o;return null}function bR(e,t,n){const r=e.shortcuts.filter(s=>s.actionId!==t);return n&&r.push({actionId:t,...n}),{shortcuts:r}}const ufe=m.createContext(null),hN="global",eP=8;function k5(e){return(e==null?void 0:e.trim())||hN}function a1(){return{activeKey:null,hasPanelState:!1,open:!1,tabs:[]}}function qX(e){return!!(e&&(e.hasPanelState||e.tabs.length>0||e.activeKey!==null))}function Gve(e){return e instanceof Element&&!!e.closest("[data-testid='messenger-main-workbench'],[data-testid='live-surface-runtime-host'][data-owner-id^='main:']")}function szt(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`view-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function KX(e,t,n){if(!_f(t))return t;if(t.kind==="browser")return{...t,viewInstanceId:t.viewInstanceId??t.tabId};if(!n&&t.viewInstanceId)return t;if(!n){const r=Rre(t),s=e.find(a=>_f(a)&&Rre(a)===r);if(s&&s.kind!=="browser"&&"viewInstanceId"in s&&s.viewInstanceId)return{...t,viewInstanceId:s.viewInstanceId}}return{...t,viewInstanceId:szt()}}function Yve(e,t){return{...e,tabId:t.tabId,viewInstanceId:t.viewInstanceId??t.tabId,savedViewRecovery:t.savedViewRecovery??e.savedViewRecovery}}function WX(e,t,n,r=!0){const s=gs(n),a=n.kind==="browser"&&n.dedupeKey?e.find(d=>d.kind==="browser"&&d.dedupeKey===n.dedupeKey):void 0;if(n.kind==="browser"&&(a==null?void 0:a.kind)==="browser"){const d=gs(a),u=Yve(n,a);return{activeKey:d,tabs:e.map(f=>gs(f)===d?u:f),openResult:{admitted:!0}}}const o=e.find(d=>gs(d)===s);if(o){const d=n.kind==="browser"&&o.kind==="browser"?Yve(n,o):n;return{activeKey:s,tabs:e.map(u=>gs(u)===s?d:u),openResult:{admitted:!0}}}const l=[...e,n];if(n.kind!=="browser")return{activeKey:s,tabs:l,openResult:{admitted:!0}};const c=e.filter(d=>d.kind==="browser").length;return r&&c<eP?{activeKey:s,tabs:l,openResult:{admitted:!0}}:{activeKey:t,tabs:e,openResult:{admitted:!1,reason:"browser_capacity"}}}function Fre(e){var t;return((t=e.viewInstanceId)==null?void 0:t.trim())||e.tabId.trim()}function ZX(e){const t=new Set;for(const n of Object.values(e))for(const r of n.tabs)r.kind==="browser"&&t.add(Fre(r));return t}function izt(e,t,n){const r=e.activeKey?e.tabs.findIndex(l=>gs(l)===e.activeKey):-1,s=e.tabs.filter(l=>l.kind!=="browser"||(n==null?void 0:n(t,l))==="preserve");if(s.length===e.tabs.length)return e;const a=e.activeKey!==null&&s.some(l=>gs(l)===e.activeKey),o=s[Math.min(Math.max(r,0),s.length-1)]??s.at(-1)??null;return{...e,activeKey:e.activeKey===null?null:a?e.activeKey:o?gs(o):null,tabs:s}}function azt({children:e}){const t=m.useRef({[hN]:a1()}),n=m.useRef({[hN]:{}}),r=m.useRef(hN),[s,a]=m.useState(hN),[o,l]=m.useState(()=>a1()),[c,d]=m.useState(null),[u,f]=m.useState(!1),A=m.useRef(null),h=m.useRef(null),g=m.useCallback(($,ee)=>{const re=t.current[$]??a1(),ne=ee(re);if(ne!==re){const te=new Map(re.tabs.map(he=>[gs(he),he])),ce=n.current[$]??{},se={...ce};for(const he of ne.tabs){const we=gs(he),Ue=te.get(we),je=ce[we]??0;se[we]=Ue?Ue!==he?je+1:je:Object.hasOwn(ce,we)?je+1:0}n.current={...n.current,[$]:se}}return t.current={...t.current,[$]:ne},$===r.current&&l(ne),ne},[]),x=m.useCallback($=>{const ee=k5($);if(r.current===ee)return;const re=t.current[ee]??a1();r.current=ee,l(re),f(qX(re)&&re.open),a(ne=>ne===ee?ne:ee)},[]),y=m.useCallback(($,ee)=>{let re={admitted:!0};return g(s,ne=>{const te=ZX(t.current),ce=$.kind!=="browser"||te.has(Fre($))||(ee==null?void 0:ee.allowNewBrowserGuest)!==!1&&te.size<eP,se=WX(ne.tabs,ne.activeKey,KX(ne.tabs,$,!1),ce);return re=se.openResult,{activeKey:se.activeKey,hasPanelState:!0,open:!0,tabs:se.tabs}}),f(!0),re},[s,g]),v=m.useCallback(($,ee)=>{let re={admitted:!0};return g(s,ne=>{const te=ZX(t.current),ce=$.kind!=="browser"||(ee==null?void 0:ee.allowNewBrowserGuest)!==!1&&te.size<eP,se=WX(ne.tabs,ne.activeKey,KX(ne.tabs,$,!0),ce);return re=se.openResult,{activeKey:se.activeKey,hasPanelState:!0,open:!0,tabs:se.tabs}}),f(!0),re},[s,g]),w=m.useCallback(($,ee,re)=>{const ne=k5($);let te={admitted:!0};const ce=g(ne,se=>{const he=ZX(t.current),we=ee.kind!=="browser"||he.has(Fre(ee))||(re==null?void 0:re.allowNewBrowserGuest)!==!1&&he.size<eP,Ue=WX(se.tabs,se.activeKey,KX(se.tabs,ee,!1),we);return te=Ue.openResult,{activeKey:Ue.activeKey,hasPanelState:!0,open:!0,tabs:Ue.tabs}});return ne===r.current&&(l(ce),f(!0)),te},[g]),k=m.useCallback(()=>{g(s,$=>({...$,hasPanelState:!0,open:!0})),f(!0)},[s,g]),O=m.useCallback($=>{const ee=k5($),ne={...t.current[ee]??a1(),hasPanelState:!0,open:!0};t.current={...t.current,[ee]:ne},r.current=ee,a(ee),l(ne),f(!0)},[]),j=m.useCallback(()=>{f(!0),g(s,$=>({...$,activeKey:null,hasPanelState:!0,open:!0}))},[s,g]),C=m.useCallback(()=>{d(null),g(s,$=>qX($)?{...$,open:!1}:$),f(!1)},[s,g]),N=m.useCallback(()=>{d(null),g(s,()=>a1()),f(!1)},[s,g]),I=C,E=m.useCallback(()=>{d(null)},[]),_=m.useCallback(($,ee=r.current)=>{const re=$.trim(),ne=k5(ee);return!re||!ne.startsWith("chat:")&&!ne.startsWith("issue:")?!1:(d({organizationId:re,contextKey:ne}),!0)},[]),T=m.useCallback(($,ee)=>{var te,ce;const re=k5($);return(((te=t.current[re])==null?void 0:te.tabs)??[]).some(se=>gs(se)===ee)?((ce=n.current[re])==null?void 0:ce[ee])??0:null},[]),R=m.useCallback(($,ee,re)=>{var Ue;const ne=k5($),te=t.current[ne]??a1(),ce=te.tabs.findIndex(je=>gs(je)===ee);if(ce<0)return{detached:!1,reason:"not_found",revision:null};const se=((Ue=n.current[ne])==null?void 0:Ue[ee])??0;if(re!==se)return{detached:!1,reason:"revision_mismatch",revision:se};const he=te.tabs[ce],we=g(ne,je=>{const ke=je.tabs.filter(oe=>gs(oe)!==ee);if(ke.length===0)return{activeKey:null,hasPanelState:!0,open:!1,tabs:[]};if(je.activeKey!==ee)return{...je,tabs:ke};const Se=ke[Math.min(ce,ke.length-1)]??null;return{activeKey:Se?gs(Se):null,hasPanelState:!0,open:!0,tabs:ke}});return ne===r.current&&f(we.open),{detached:!0,revision:se,target:he}},[g]),M=m.useCallback($=>{g(s,ee=>{const re=ee.tabs.findIndex(ce=>gs(ce)===$),ne=ee.tabs.filter(ce=>gs(ce)!==$);if(ne.length===0)return f(!1),{activeKey:null,hasPanelState:!0,open:!1,tabs:[]};if(ee.activeKey!==$)return{...ee,tabs:ne};const te=ne[Math.min(Math.max(re,0),ne.length-1)]??ne.at(-1)??null;return{activeKey:te?gs(te):null,hasPanelState:!0,open:!0,tabs:ne}})},[s,g]),L=m.useCallback($=>(A.current=$,()=>{A.current===$&&(A.current=null)}),[]),U=m.useCallback($=>(h.current=$,()=>{h.current===$&&(h.current=null)}),[]),B=m.useCallback($=>{const re=(t.current[r.current]??a1()).tabs.find(te=>gs(te)===$);if(!re)return;const ne=A.current;if(ne){ne(re);return}M($)},[M]),z=u&&!!o.activeKey;m.useEffect(()=>{const $=Pn(),ee=$==null?void 0:$.setSidePanelCloseShortcutActive;if(!ee)return;let re=!1,ne=null;const te=()=>{if(re)return;const se=z&&!Gve(document.activeElement);ne!==se&&(ne=se,ee(se).catch(()=>{}))},ce=()=>queueMicrotask(te);return document.addEventListener("focusin",ce,!0),document.addEventListener("focusout",ce,!0),te(),()=>{re=!0,document.removeEventListener("focusin",ce,!0),document.removeEventListener("focusout",ce,!0)}},[z]),m.useEffect(()=>{const $=Pn(),ee=$==null?void 0:$.setSidePanelCloseShortcutActive;if(ee)return()=>{ee(!1).catch(()=>{})}},[]),m.useEffect(()=>{const $=Pn();if($!=null&&$.onBrowserReset)return $.onBrowserReset(()=>{const ee=Object.fromEntries(Object.entries(t.current).map(([ne,te])=>[ne,izt(te,ne,h.current)]));t.current=ee;const re=ee[r.current]??a1();l(re),f(qX(re)&&re.open)})},[]),m.useEffect(()=>{if(!z)return;const $=Pn();if($!=null&&$.onCloseSidePanelActiveTab)return $.onCloseSidePanelActiveTab(()=>{const ee=o.activeKey;ee&&B(ee)})},[o.activeKey,z,B]),m.useEffect(()=>{const $=Pn();if($!=null&&$.onOpenEmptySidePanel)return $.onOpenEmptySidePanel(j)},[j]),m.useEffect(()=>{if(!u||!o.activeKey)return;const $=ee=>{Gve(ee.target)||ee.key.toLowerCase()!=="w"||(TM()==="mac"?!ee.metaKey||ee.ctrlKey:!ee.ctrlKey||ee.metaKey)||ee.altKey||ee.shiftKey||(ee.preventDefault(),ee.stopPropagation(),B(o.activeKey))};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)},[o.activeKey,u,B]);const H=m.useCallback(($,ee,re)=>{const ne=k5($);if(!(t.current[ne]??a1()).tabs.some(se=>gs(se)===ee))return!1;const ce=gs(re);return g(ne,se=>({...se,activeKey:se.activeKey===ee?ce:se.activeKey,tabs:se.tabs.map(he=>gs(he)===ee?re:he)})),!0},[g]),J=m.useCallback(($,ee)=>{H(s,$,ee)},[s,H]),F=m.useCallback(($,ee,re)=>{$!==ee&&g(s,ne=>{const te=ne.tabs.findIndex(je=>gs(je)===$),ce=ne.tabs.findIndex(je=>gs(je)===ee);if(te<0||ce<0)return ne;const se=[...ne.tabs],[he]=se.splice(te,1);if(!he)return ne;const Ue=se.findIndex(je=>gs(je)===ee)+(re==="after"?1:0);return se.splice(Ue,0,he),{...ne,tabs:se}})},[s,g]),Q=m.useCallback($=>{g(s,ee=>({...ee,activeKey:$,hasPanelState:!0,open:!0}))},[s,g]),W=m.useMemo(()=>({activeKey:o.activeKey,clearCurrentContext:N,clearDisplayedContextHold:E,closePanel:I,closeTarget:M,contextKey:s,detachTargetForContext:R,displayedContextHold:c,getTargetRevisionForContext:T,hidePanel:C,holdDisplayedContext:_,open:u,openEmpty:j,openTarget:y,openTargetInNewTab:v,openTargetForContext:w,registerCloseRequestHandler:L,registerBrowserResetHandler:U,replaceTarget:J,replaceTargetForContext:H,reorderTarget:F,setActiveKey:Q,setContextKey:x,showPanel:k,showPanelForContext:O,tabs:o.tabs}),[N,E,I,M,s,o.activeKey,o.tabs,R,c,T,C,_,u,j,y,w,v,U,L,F,J,H,Q,x,k,O]);return i.jsx(ufe.Provider,{value:W,children:e})}function R3(){const e=m.useContext(ufe);if(!e)throw new Error("useSidePanel must be used inside SidePanelProvider");return e}function ozt(){return m.useContext(ufe)}function lzt(e){try{const t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}async function czt(e){var r;const{request:t}=e;if(!lzt(t.url))return"ignored";let n;try{n=await e.getSettings()}catch{return await e.forceOpenExternal(t.url),"default_browser"}return n.openLinksIn==="built_in"||t.source==="browser_popup"?(e.openBuiltIn(E4(t.url,{favicon:(r=e.resolveFavicon)==null?void 0:r.call(e,t.url),newTab:t.source==="browser_popup"})),"built_in"):(await e.forceOpenExternal(t.url),"default_browser")}const Cv=8;function dzt(){return{activeViewInstanceId:null,tabOrder:[],tabsByViewInstanceId:{},runtimesById:{},promotionsById:{}}}function uzt(){return{organizations:{}}}function nw(e){return e.kind==="side"||e.kind==="transferring"||e.kind==="main"||e.kind==="parked"}function fzt(e,t){const n=e.organizations[t];return n?Object.values(n.runtimesById).filter(r=>r.targetKind==="browser"&&nw(r.host)).length:0}function Azt(e){return Object.values(e.runtimesById).filter(t=>t.targetKind==="browser"&&nw(t.host)).length}function hzt(e,t){return e.kind!==t.kind?!1:e.kind==="side"&&t.kind==="side"?e.contextKey===t.contextKey:e.kind==="main"&&t.kind==="main"?e.organizationId===t.organizationId:!0}function mzt(e){return{...e}}function uBe(e,t,n){if(!n.id||!n.viewInstanceId||n.target.viewInstanceId!==n.viewInstanceId||n.target.kind!==n.targetKind||n.host.kind==="main"&&n.host.organizationId!==t)return!1;const r=e.runtimesById[n.id];return r&&(r.viewInstanceId!==n.viewInstanceId||r.targetKind!==n.targetKind)||n.targetKind==="browser"&&nw(n.host)&&!((r==null?void 0:r.targetKind)==="browser"&&nw(r.host))&&Azt(e)>=Cv?!1:!(nw(n.host)&&Object.values(e.runtimesById).some(o=>o.id!==n.id&&o.viewInstanceId===n.viewInstanceId&&nw(o.host)))}function xg(e,t,n){if(!uBe(e,t,n))return e;const r=e.runtimesById[n.id];return r&&hzt(r.host,n.host)?e:{...e,runtimesById:{...e.runtimesById,[n.id]:{...n,organizationId:t,target:(r==null?void 0:r.target)??O6(n.target),host:mzt(n.host)}}}}function O6(e){return e.kind!=="browser"||!e.savedViewRecovery?{...e}:{...e,savedViewRecovery:{...e.savedViewRecovery,persistedMetadata:{...e.savedViewRecovery.persistedMetadata,target:{...e.savedViewRecovery.persistedMetadata.target}}}}}function fBe(e){return!!(e.viewInstanceId&&e.runtimeId&&e.originContextKey&&e.target.viewInstanceId===e.viewInstanceId)}function ffe(e,t){return Object.values(e.tabsByViewInstanceId).find(n=>n.savedViewId===t)??null}function Bre(e,t,n,r){if(!fBe(n)||r!==null&&!r)return{organization:e,outcome:"rejected"};const s=r?ffe(e,r):null;if(s&&s.viewInstanceId!==n.viewInstanceId)return e.activeViewInstanceId===s.viewInstanceId?{organization:e,outcome:"focused_existing_binding"}:{organization:{...e,activeViewInstanceId:s.viewInstanceId},outcome:"focused_existing_binding"};const a=e.tabsByViewInstanceId[n.viewInstanceId];if(a){const c=r!==null&&a.savedViewId!==null&&a.savedViewId!==r,d=r===null||a.savedViewId===r,u=e.activeViewInstanceId===n.viewInstanceId;return d&&u?{organization:e,outcome:"already_satisfied"}:{organization:{...e,activeViewInstanceId:n.viewInstanceId,tabsByViewInstanceId:r===null||d||c?e.tabsByViewInstanceId:{...e.tabsByViewInstanceId,[n.viewInstanceId]:{...a,savedViewId:r}}},outcome:c?"binding_conflict":"already_satisfied"}}const o={id:n.runtimeId,viewInstanceId:n.viewInstanceId,targetKind:n.target.kind,target:n.target,host:{kind:"main",organizationId:t}};if(!uBe(e,t,o))return{organization:e,outcome:"rejected"};const l=xg(e,t,o);return{organization:{...l,activeViewInstanceId:n.viewInstanceId,tabOrder:[...l.tabOrder,n.viewInstanceId],tabsByViewInstanceId:{...l.tabsByViewInstanceId,[n.viewInstanceId]:{organizationId:t,viewInstanceId:n.viewInstanceId,savedViewId:r,target:O6(n.target),originContextKey:n.originContextKey,runtimeId:n.runtimeId}}},outcome:"opened"}}function ll(e,t,n){if(!t)return e;const r=e.organizations[t]??dzt(),s=n(r);return s===r?e:{...e,organizations:{...e.organizations,[t]:s}}}function pzt(e,t,n){const r=e.tabsByViewInstanceId[t];return!r||!n||r.savedViewId===n||r.savedViewId!==null||ffe(e,n)?e:{...e,tabsByViewInstanceId:{...e.tabsByViewInstanceId,[t]:{...r,savedViewId:n}}}}function gzt(e,t,n){const r=e.tabsByViewInstanceId[t];return!r||r.savedViewId!==n?e:{...e,tabsByViewInstanceId:{...e.tabsByViewInstanceId,[t]:{...r,savedViewId:null}}}}function xzt(e,t,n){var u;const r=e.tabsByViewInstanceId[n];if(!r)return e;const s=e.tabOrder.indexOf(n),a=e.tabOrder.filter(f=>f!==n),{[n]:o,...l}=e.tabsByViewInstanceId,c=xg(e,t,{id:r.runtimeId,viewInstanceId:r.viewInstanceId,targetKind:r.target.kind,target:((u=e.runtimesById[r.runtimeId])==null?void 0:u.target)??r.target,host:{kind:"disposed"}}),d=e.activeViewInstanceId===n?a[Math.min(Math.max(s,0),a.length-1)]??null:e.activeViewInstanceId;return{...c,activeViewInstanceId:d,tabOrder:a,tabsByViewInstanceId:l}}function bzt(e,t,n){const r=e.tabOrder.indexOf(t);if(r<0||!Number.isFinite(n))return e;const s=Math.max(0,Math.min(Math.trunc(n),e.tabOrder.length-1));if(r===s)return e;const a=[...e.tabOrder];return a.splice(r,1),a.splice(s,0,t),{...e,tabOrder:a}}function yzt(e){return{...e,target:O6(e.target)}}function Jq(e){return Number.isInteger(e)&&e>=0}function vzt(e){return e.status==="pending"||e.status==="reconciling"||e.status==="claiming"||e.status==="detaching"}function wzt(e,t,n,r,s){if(!n||!s||!fBe(r)||!Jq(r.sourceRevision)||e.promotionsById[n]||Object.values(e.promotionsById).some(l=>vzt(l)&&l.source.runtimeId===r.runtimeId))return e;const a=e.runtimesById[r.runtimeId];if(!a||a.viewInstanceId!==r.viewInstanceId||a.targetKind!==r.target.kind||a.host.kind!=="side"||a.host.contextKey!==r.originContextKey)return e;const o=xg(e,t,{id:a.id,viewInstanceId:a.viewInstanceId,targetKind:a.targetKind,target:a.target,host:{kind:"transferring"}});return{...o,promotionsById:{...o.promotionsById,[n]:{id:n,organizationId:t,clientMutationId:s,status:"pending",source:yzt(r)}}}}function d9(e,t,n){const r=e.runtimesById[n.runtimeId];return r?xg(e,t,{id:r.id,viewInstanceId:r.viewInstanceId,targetKind:r.targetKind,target:r.target,host:{kind:"side",contextKey:n.originContextKey}}):e}function _M(e,t,n){const r=e.promotionsById[t];if(!r||r.status!=="pending"&&r.status!=="reconciling"&&r.status!=="claiming"||r.source.sourceRevision!==n)return null;const s=e.runtimesById[r.source.runtimeId];return!s||s.viewInstanceId!==r.source.viewInstanceId||s.targetKind!==r.source.target.kind||s.host.kind!=="transferring"?null:r}function kzt(e,t,n,r,s){const a=e.promotionsById[n];if(!a||a.status!=="server_failed"&&a.status!=="commit_unknown"||a.source.sourceRevision!==r||!Jq(s)||s<=r)return e;const o=e.runtimesById[a.source.runtimeId];if(!o||o.host.kind!=="side"||o.host.contextKey!==a.source.originContextKey)return e;const l=xg(e,t,{id:o.id,viewInstanceId:o.viewInstanceId,targetKind:o.targetKind,target:o.target,host:{kind:"transferring"}});return{...l,promotionsById:{...l.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,status:"pending",source:{...a.source,sourceRevision:s}}}}}function Szt(e,t,n,r,s){const a=e.promotionsById[n];if(!a||a.status!=="commit_unknown"||a.source.sourceRevision!==r||!Jq(s)||s<=r)return e;const o=e.runtimesById[a.source.runtimeId];if(!o||o.host.kind!=="side"||o.host.contextKey!==a.source.originContextKey)return e;const l=xg(e,t,{id:o.id,viewInstanceId:o.viewInstanceId,targetKind:o.targetKind,target:o.target,host:{kind:"transferring"}});return{...l,promotionsById:{...l.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,status:"reconciling",source:{...a.source,sourceRevision:s}}}}}function Ozt(e,t,n,r,s){const a=e.promotionsById[n];if(!a||a.status!=="claim_failed"||a.source.sourceRevision!==r||!Jq(s)||s<=r)return e;const o=e.runtimesById[a.source.runtimeId];if(!o||o.host.kind!=="side"||o.host.contextKey!==a.source.originContextKey)return e;const l=xg(e,t,{id:o.id,viewInstanceId:o.viewInstanceId,targetKind:o.targetKind,target:o.target,host:{kind:"transferring"}});return{...l,promotionsById:{...l.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,status:"claiming",savedViewId:a.savedViewId,source:{...a.source,sourceRevision:s}}}}}function jzt(e,t,n,r,s){const a=_M(e,n,s);return!a||a.status==="claiming"||!r?e:{...e,promotionsById:{...e.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,source:a.source,status:"claiming",savedViewId:r}}}}function Czt(e,t,n,r,s){const a=_M(e,n,r);if(!a||a.status==="claiming")return e;const o=d9(e,t,a.source);return{...o,promotionsById:{...o.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,source:a.source,status:"server_failed",error:s}}}}function Nzt(e,t,n,r,s){const a=_M(e,n,r);if(!a||a.status==="claiming")return e;const o=d9(e,t,a.source);return{...o,promotionsById:{...o.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,source:a.source,status:"commit_unknown",error:s}}}}function Pzt(e,t,n,r,s,a){const o=_M(e,n,s);if(!o||o.status!=="claiming"||!r||o.savedViewId!==r)return e;const l=d9(e,t,o.source);return{...l,promotionsById:{...l.promotionsById,[n]:{id:o.id,organizationId:t,clientMutationId:o.clientMutationId,source:o.source,status:"claim_failed",savedViewId:r,error:a}}}}function fB(e,t){const{[t]:n,...r}=e.promotionsById;return{...e,promotionsById:r}}function Izt(e,t,n){const r=e.promotionsById[t];return!r||r.status!=="server_failed"&&r.status!=="commit_unknown"&&r.status!=="claim_failed"||r.source.sourceRevision!==n?e:fB(e,t)}function Tzt(e,t,n,r,s){const a=e.promotionsById[n];if(!a||a.source.sourceRevision!==s||a.source.savedViewId!==r&&(!("savedViewId"in a)||a.savedViewId!==r))return e;if(a.status==="detaching"){const o=mBe(e,t,n,r,s,"saved_view_removed");return fB(o,n)}return fB(d9(e,t,a.source),n)}function fC(e,t,n,r,s){const a=d9(e,t,n.source);return{...a,promotionsById:{...a.promotionsById,[n.id]:{id:n.id,organizationId:t,clientMutationId:n.clientMutationId,source:n.source,status:"claim_failed",savedViewId:r,error:s}}}}function ABe(e){return{...e,target:O6(e.target)}}function Jve(e,t,n,r){return{...e,promotionsById:{...e.promotionsById,[n.id]:{...n,organizationId:t,status:"detaching",rollback:r}}}}function _zt(e,t,n,r,s){var u;const a=_M(e,n,s);if(!a||a.status!=="claiming"||!r||a.savedViewId!==r)return e;const o={activeViewInstanceId:e.activeViewInstanceId,tab:e.tabsByViewInstanceId[a.source.viewInstanceId]?ABe(e.tabsByViewInstanceId[a.source.viewInstanceId]):null},l=e.tabsByViewInstanceId[a.source.viewInstanceId],c=ffe(e,r);if(c&&c.viewInstanceId!==a.source.viewInstanceId){const f=e.activeViewInstanceId===c.viewInstanceId?e:{...e,activeViewInstanceId:c.viewInstanceId};return fC(f,t,a,r,"saved_view_already_bound")}if(l!=null&&l.savedViewId&&l.savedViewId!==r){const f=e.activeViewInstanceId===l.viewInstanceId?e:{...e,activeViewInstanceId:l.viewInstanceId};return fC(f,t,a,r,"saved_view_binding_conflict")}if(l){let f=e,A=l.runtimeId;if(l.runtimeId===a.source.runtimeId){const h=f.runtimesById[a.source.runtimeId];f=xg(f,t,{id:h.id,viewInstanceId:h.viewInstanceId,targetKind:h.targetKind,target:h.target,host:{kind:"main",organizationId:t}})}else{const h=f.runtimesById[l.runtimeId];if(!h||h.viewInstanceId!==l.viewInstanceId||h.targetKind!==l.target.kind||nw(h.host))return fC(e,t,a,r,"existing_tab_runtime_unavailable");const g=f.runtimesById[a.source.runtimeId];if(f=xg(f,t,{id:g.id,viewInstanceId:g.viewInstanceId,targetKind:g.targetKind,target:g.target,host:{kind:"main",organizationId:t}}),((u=f.runtimesById[g.id])==null?void 0:u.host.kind)!=="main")return fC(e,t,a,r,"existing_tab_runtime_unavailable");A=g.id}return f={...f,activeViewInstanceId:l.viewInstanceId,tabsByViewInstanceId:l.savedViewId===r&&l.runtimeId===A?f.tabsByViewInstanceId:{...f.tabsByViewInstanceId,[l.viewInstanceId]:{...l,savedViewId:r,runtimeId:A,target:O6(a.source.target),originContextKey:a.source.originContextKey}}},Jve(f,t,a,o)}const d=Bre(e,t,{viewInstanceId:a.source.viewInstanceId,runtimeId:a.source.runtimeId,target:a.source.target,originContextKey:a.source.originContextKey},r);return d.outcome!=="opened"?fC(d.organization,t,a,r,d.outcome==="binding_conflict"?"saved_view_binding_conflict":"main_host_claim_rejected"):Jve(d.organization,t,a,o)}function hBe(e,t,n,r){const s=e.promotionsById[t];if(!s||s.status!=="detaching"||s.savedViewId!==n||s.source.sourceRevision!==r)return null;const a=e.runtimesById[s.source.runtimeId],o=e.tabsByViewInstanceId[s.source.viewInstanceId];return!a||a.viewInstanceId!==s.source.viewInstanceId||a.host.kind!=="main"||a.host.organizationId!==s.organizationId||!o||o.runtimeId!==a.id||o.savedViewId!==n?null:s}function Mzt(e,t,n,r){const s=hBe(e,t,n,r);return s?fB(e,s.id):e}function mBe(e,t,n,r,s,a){const o=hBe(e,n,r,s);if(!o)return e;const l=d9(e,t,o.source),c={...l.tabsByViewInstanceId};let d=l.tabOrder;return o.rollback.tab?c[o.source.viewInstanceId]=ABe(o.rollback.tab):(delete c[o.source.viewInstanceId],d=d.filter(u=>u!==o.source.viewInstanceId)),{...l,activeViewInstanceId:o.rollback.activeViewInstanceId,tabOrder:d,tabsByViewInstanceId:c,promotionsById:{...l.promotionsById,[n]:{id:o.id,organizationId:t,clientMutationId:o.clientMutationId,source:o.source,status:"claim_failed",savedViewId:r,error:a}}}}function Ezt(e,t,n,r){const s=e.runtimesById[t];return!s||s.viewInstanceId!==n||r.viewInstanceId!==n||s.targetKind!==r.kind?e:{...e,runtimesById:{...e.runtimesById,[t]:{...s,target:O6(r)}}}}function Dzt(e,t,n,r){const s=e.tabsByViewInstanceId[n],a=e.runtimesById[t];return!s||s.runtimeId!==t||s.target.kind!==r.kind||r.viewInstanceId!==n||!a||a.viewInstanceId!==n||a.targetKind!==r.kind?e:{...e,tabsByViewInstanceId:{...e.tabsByViewInstanceId,[n]:{...s,target:O6(r)}}}}function Rzt(e,t){switch(t.type){case"saved-tab/open":return ll(e,t.organizationId,n=>Bre(n,t.organizationId,t.tab,t.savedViewId).organization);case"session-tab/create":return ll(e,t.organizationId,n=>Bre(n,t.organizationId,t.tab,null).organization);case"tab/focus":return ll(e,t.organizationId,n=>n.activeViewInstanceId===t.viewInstanceId||!n.tabsByViewInstanceId[t.viewInstanceId]?n:{...n,activeViewInstanceId:t.viewInstanceId});case"tab/reorder":return ll(e,t.organizationId,n=>bzt(n,t.viewInstanceId,t.toIndex));case"tab/bind-saved-view":return ll(e,t.organizationId,n=>pzt(n,t.viewInstanceId,t.savedViewId));case"tab/unbind-saved-view":return ll(e,t.organizationId,n=>gzt(n,t.viewInstanceId,t.savedViewId));case"tab/close":return ll(e,t.organizationId,n=>xzt(n,t.organizationId,t.viewInstanceId));case"tab/update-target":return ll(e,t.organizationId,n=>Dzt(n,t.runtimeId,t.viewInstanceId,t.target));case"runtime/admit":return ll(e,t.organizationId,n=>xg(n,t.organizationId,t.runtime));case"runtime/set-host":return ll(e,t.organizationId,n=>{const r=n.runtimesById[t.runtimeId];return r?xg(n,t.organizationId,{id:r.id,viewInstanceId:r.viewInstanceId,targetKind:r.targetKind,target:r.target,host:t.host}):n});case"runtime/update-target":return ll(e,t.organizationId,n=>Ezt(n,t.runtimeId,t.viewInstanceId,t.target));case"promotion/start":return ll(e,t.organizationId,n=>wzt(n,t.organizationId,t.promotionId,t.source,t.clientMutationId));case"promotion/server-commit":return ll(e,t.organizationId,n=>jzt(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision));case"promotion/claim":return ll(e,t.organizationId,n=>_zt(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision));case"promotion/detach-succeed":return ll(e,t.organizationId,n=>Mzt(n,t.promotionId,t.savedViewId,t.expectedSourceRevision));case"promotion/detach-fail":return ll(e,t.organizationId,n=>mBe(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision,t.error));case"promotion/server-fail":return ll(e,t.organizationId,n=>Czt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.error));case"promotion/timeout":return ll(e,t.organizationId,n=>Nzt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.error));case"promotion/retry":return ll(e,t.organizationId,n=>kzt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.nextSourceRevision));case"promotion/reconcile":return ll(e,t.organizationId,n=>Szt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.nextSourceRevision));case"promotion/claim-fail":return ll(e,t.organizationId,n=>Pzt(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision,t.error));case"promotion/claim-retry":return ll(e,t.organizationId,n=>Ozt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.nextSourceRevision));case"promotion/discard":return ll(e,t.organizationId,n=>Izt(n,t.promotionId,t.expectedSourceRevision));case"promotion/cancel-saved-view":return ll(e,t.organizationId,n=>Tzt(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision))}}function pBe(){var n,r;const e=(n=document.activeElement)==null?void 0:n.closest("[data-runtime-id]");if(!e||e.hidden||e.hasAttribute("inert")||e.getAttribute("aria-hidden")==="true")return null;const t=e.dataset.runtimeId;return t?{runtimeId:t,owner:(r=e.dataset.ownerId)!=null&&r.startsWith("main:")?"main_workbench":"side_panel"}:null}function Lzt(){var e;return((e=pBe())==null?void 0:e.runtimeId)??null}function zzt(){const e=Wn(),t=cfe(),n=ALe(),{openTarget:r}=R3(),s=l9();return m.useEffect(()=>{const a=Pn();if(a!=null&&a.onOpenWebLink)return a.onOpenWebLink(o=>{czt({request:o,getSettings:()=>e.fetchQuery({queryKey:V.instance.browserSettings,queryFn:()=>fo.getBrowser(),staleTime:0}),openBuiltIn:l=>{var f;if(o.sourceWebContentsId){((t==null?void 0:t.openTargetForGuest(o.sourceWebContentsId,l))??!1)||console.warn("[rudder-ui] ignored Browser popup without a live guest owner",o.sourceWebContentsId);return}const c=((f=n==null?void 0:n.selectedOrganizationId)==null?void 0:f.trim())??"",d=!t||!c||t.getLiveBrowserCount(c)<Cv;r(l,{allowNewBrowserGuest:d}).admitted||s==null||s.pushToast({title:"Browser tab limit reached",body:`Close a Browser tab to open another. Side Panel and Main share ${Cv} live tabs.`,tone:"error"})},forceOpenExternal:l=>{var c;return((c=a.forceOpenExternal)==null?void 0:c.call(a,l))??a.openExternal(l)},resolveFavicon:eLt}).catch(l=>{console.warn("[rudder-ui] failed to route Desktop web link",l)})})},[t,r,n==null?void 0:n.selectedOrganizationId,e,s]),m.useEffect(()=>{const a=Pn();if(a!=null&&a.onBrowserShortcut)return a.onBrowserShortcut(o=>{if(!t)return;const l=o.sourceWebContentsId?null:Lzt();if(o.action==="close_tab"){o.sourceWebContentsId?t.closeTargetForGuest(o.sourceWebContentsId):l&&t.closeTargetForRuntime(l);return}o.sourceWebContentsId?t.dispatchBrowserShortcutForGuest(o.sourceWebContentsId,o.action):l&&t.dispatchBrowserShortcutForRuntime(l,o.action)})},[t]),m.useEffect(()=>{var f;const a=(f=Pn())==null?void 0:f.setBrowserSurfaceShortcutActive;if(!a||!t)return;let o=!1,l=!1,c;const d=()=>{var y;if(o)return;const A=pBe(),h=(A==null?void 0:A.runtimeId)??null,g=h?((y=t.getRuntimeTarget(h))==null?void 0:y.kind)==="browser":!1,x=A==null?void 0:A.owner;l===g&&x===c||(l=g,c=x,a(g,x).catch(()=>{}))},u=()=>queueMicrotask(d);return document.addEventListener("focusin",u,!0),document.addEventListener("focusout",u,!0),d(),()=>{o=!0,document.removeEventListener("focusin",u,!0),document.removeEventListener("focusout",u,!0),a(!1).catch(()=>{})}},[t]),null}const CI="https://docs.rudderhq.dev",gBe="https://discord.gg/ZcfWwPVkUz";function xBe({alt:e="",className:t,...n}){return i.jsx("img",{src:"/rudder-logo.png",alt:e,"aria-hidden":e?void 0:!0,className:q("inline-block shrink-0 rounded-full bg-white object-cover ring-1 ring-black/5 dark:ring-white/10",t),...n})}function $zt(){const[e,t]=m.useState(null),n=m.useRef(null);m.useEffect(()=>{const a=Pn();if(!(a!=null&&a.getReleaseNotes))return;let o=!1;return a.getReleaseNotes().then(l=>{o||l.status!=="available"||(n.current=l.notes,t(l.notes))}).catch(()=>{}),()=>{o=!0}},[]);async function r(){var o,l;const a=n.current;n.current=null,t(null),a&&await((l=(o=Pn())==null?void 0:o.markReleaseNotesShown)==null?void 0:l.call(o,a.version).catch(()=>{}))}async function s(){const a=Pn();if(a){await a.openExternal(CI).catch(()=>{});return}window.open(CI,"_blank","noopener,noreferrer")}return i.jsx(ws,{open:e!==null,onOpenChange:a=>{a||r()},children:i.jsxs(Ps,{className:"gap-0 overflow-hidden p-0 sm:max-w-[36rem]",showCloseButton:!1,children:[i.jsxs("div",{className:"flex items-start gap-3 border-b border-border/70 px-5 pb-4 pt-5",children:[i.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-[var(--radius-md)] border border-border bg-background shadow-sm",children:i.jsx(xBe,{alt:"Rudder",className:"h-6 w-6 ring-0"})}),i.jsxs(Ai,{className:"min-w-0 gap-1 text-left",children:[i.jsx(Js,{className:"text-base leading-6",children:(e==null?void 0:e.title)??"What's new in Rudder"}),i.jsx(wi,{className:"text-sm leading-5",children:"Updates installed with this version."})]})]}),i.jsx("div",{className:"max-h-[min(62vh,34rem)] overflow-y-auto px-5 py-4",children:i.jsx("div",{className:"space-y-4",children:e==null?void 0:e.sections.map(a=>i.jsxs("section",{className:"space-y-2",children:[i.jsx("h2",{className:"text-sm font-semibold text-foreground",children:a.title}),i.jsx("ul",{className:"space-y-1.5 text-sm leading-5 text-muted-foreground",children:a.items.map(o=>i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"mt-2 h-1 w-1 shrink-0 rounded-full bg-muted-foreground/70"}),i.jsx("span",{children:o})]},o))})]},a.title))})}),i.jsxs(aa,{className:"border-t border-border/70 px-5 py-4 sm:justify-between",children:[i.jsxs(ie,{type:"button",variant:"outline",onClick:()=>void s(),children:[i.jsx(La,{className:"h-4 w-4"}),"Docs"]}),i.jsx(ie,{type:"button",onClick:()=>void r(),children:"Continue"})]})]})})}function Fzt(e){const[t="",...n]=e.split(/\n{2,}/);return{body:t.trim(),runDetail:n.join(`
|
|
1681
|
+
- (兼容旧字段)\`agentDefaultsPayload.headers["x-openclaw-auth"]\``,"organizationSettings.packages.description":"在不同 Rudder 安装之间迁移组织配置与工作数据。","organizationSettings.packages.export":"导出","organizationSettings.packages.import":"导入","organizationSettings.danger.description":"归档这个 organization 后,它会从侧边栏中隐藏。这个状态会持久化到数据库。","organizationSettings.danger.confirm":"要归档 organization “{{name}}” 吗?它会从侧边栏中隐藏。","organizationSettings.danger.archiving":"归档中...","organizationSettings.danger.alreadyArchived":"已归档","organizationSettings.danger.archive":"归档 organization","organizationSettings.danger.failed":"归档 organization 失败","settings.eyebrow.system":"系统设置","settings.eyebrow.labs":"实验室","app.instanceSetupRequired":"需要完成实例初始化","app.bootstrapInvite.active":"当前还没有实例管理员。引导邀请已经激活。请查看 Rudder 启动日志中的首个管理员邀请链接,或运行下面的命令重新生成:","app.bootstrapInvite.inactive":"当前还没有实例管理员。请在 Rudder 运行环境中执行下面的命令生成首个管理员邀请链接:","app.failedToLoadAppState":"加载应用状态失败","app.addAnotherAgentToOrganization":"为 {{name}} 再添加一个智能体","app.createAnotherOrganization":"创建另一个组织","app.createFirstOrganization":"创建你的第一个组织","app.onboarding.addAgentDescription":"再次运行引导,为这个组织添加一个智能体和一个初始任务。","app.onboarding.createAnotherDescription":"再次运行引导,创建另一个组织并初始化它的第一个智能体。","app.onboarding.createFirstDescription":"从创建一个组织和你的第一个智能体开始。","app.addAgent":"添加智能体","app.startOnboarding":"开始引导","app.noCompaniesDescription":"从创建一个组织开始。","app.newOrganization":"新建组织","general.title":"通用","general.description":"这台设备上的核心应用偏好。","general.updateFailed":"更新通用设置失败。","general.loadLoading":"正在加载通用设置...","general.loadFailed":"加载通用设置失败。","general.language.title":"语言","general.language.description":"选择这个 Rudder 实例在控制台界面中使用的语言。","general.language.label":"界面语言","general.language.help":"这是实例级界面语言,会影响所有使用这个实例的用户看到的控制台外壳和设置页面。","general.language.option.en.label":"英语","general.language.option.en.description":"默认产品语言","general.language.option.zh-CN.label":"简体中文","general.language.option.zh-CN.description":"中文界面","general.language.preview.en.primary":"Hello","general.language.preview.en.secondary":"Board UI","general.language.preview.zh-CN.primary":"你好","general.language.preview.zh-CN.secondary":"控制台界面","general.basics.title":"基础","general.productTour.title":"工作台教程","general.productTour.description":"重新播放引导教程。","general.productTour.start":"开始教程","general.logs.title":"操作日志","general.logs.description":"调整界面中面向操作员展示的输出方式。","general.logs.censor.title":"对日志中的用户名做脱敏","general.logs.censor.description":"对日志中显示的主目录路径用户名做脱敏。","general.updates.title":"桌面应用","general.updates.description":"选择这台机器安装 Rudder Desktop 时使用哪个发布渠道。","general.updates.loadFailed":"加载桌面更新设置失败。","general.updates.updateFailed":"更新桌面更新设置失败。","general.updates.unavailable":"当前环境不支持桌面更新设置。","general.updates.canary.title":"接收桌面测试版更新","general.updates.canary.disabledDescription":"安装最新正式版;当测试版更新时也纳入检测。","general.updates.canary.enabledDescription":"这台机器会同时检查正式版和更新的测试版。","general.diagnostics.developer.title":"显示开发诊断信息","general.diagnostics.developer.description":"在 transcript 中显示 Rudder 内部运行时、workspace、session 和 adapter 诊断信息。","general.developer.title":"开发者","general.appearance.title":"外观","general.appearance.description":"选择这个设备上的 Rudder 外观。视觉风格遵循低眩光、克制的 Claude 风格界面。","general.appearance.colorMode":"颜色模式","general.appearance.light.label":"浅色","general.appearance.light.description":"暖色纸面风格","general.appearance.system.label":"自动","general.appearance.system.description":"跟随系统外观","general.appearance.dark.label":"深色","general.appearance.dark.description":"低眩光工作区","general.appearance.designStyle":"设计风格","general.appearance.defaultStyle.label":"Classic","general.appearance.defaultStyle.description":"平衡的低眩光界面","general.appearance.mira.label":"Compact","general.appearance.mira.description":"紧凑卡片与控件","general.appearance.luma.label":"Rudder","general.appearance.luma.description":"柔和宽松的控件","general.appearance.baseColor":"基础色","general.appearance.base.neutral.label":"Neutral","general.appearance.base.neutral.description":"平衡的中性灰界面","general.appearance.base.stone.label":"Stone","general.appearance.base.stone.description":"暖调石色界面","general.appearance.base.zinc.label":"Zinc","general.appearance.base.zinc.description":"冷调灰色界面","general.appearance.base.mauve.label":"Mauve","general.appearance.base.mauve.description":"低饱和玫瑰灰界面","general.appearance.base.olive.label":"Olive","general.appearance.base.olive.description":"低饱和橄榄色界面","general.appearance.base.mist.label":"Mist","general.appearance.base.mist.description":"柔和蓝灰界面","general.appearance.base.taupe.label":"Taupe","general.appearance.base.taupe.description":"暖调灰褐界面","general.appearance.themeColor":"主题色","general.appearance.theme.neutral.label":"Neutral","general.appearance.theme.neutral.description":"单色操作状态","general.appearance.theme.amber.label":"Amber","general.appearance.theme.amber.description":"琥珀色操作状态","general.appearance.theme.blue.label":"Blue","general.appearance.theme.blue.description":"蓝色操作状态","general.appearance.theme.cyan.label":"Cyan","general.appearance.theme.cyan.description":"青色操作状态","general.appearance.theme.emerald.label":"Rudder","general.appearance.theme.emerald.description":"Rudder 绿色操作状态","general.appearance.theme.fuchsia.label":"Fuchsia","general.appearance.theme.fuchsia.description":"紫红色操作状态","general.appearance.theme.green.label":"Green","general.appearance.theme.green.description":"绿色操作状态","general.appearance.theme.indigo.label":"Indigo","general.appearance.theme.indigo.description":"靛蓝色操作状态","general.appearance.theme.lime.label":"Lime","general.appearance.theme.lime.description":"青柠色操作状态","general.appearance.theme.orange.label":"Orange","general.appearance.theme.orange.description":"橙色操作状态","general.appearance.theme.pink.label":"Pink","general.appearance.theme.pink.description":"粉色操作状态","notifications.title":"通知","notifications.description":"管理这个 Rudder 实例的未读 inbox 提醒。","notifications.loadFailed":"加载通知设置失败。","notifications.updateFailed":"更新通知设置失败。","notifications.support.available":"可用","notifications.support.unavailable":"不可用","notifications.permission.title":"权限","notifications.permission.description":"通知权限由操作系统或浏览器掌控,所以 Rudder 需要同时展示当前状态和修复入口。","notifications.permission.requestFailed":"请求通知权限失败。","notifications.permission.openSettingsFailed":"打开通知设置失败。","notifications.permission.access.title":"通知访问权限","notifications.permission.access.summary":"权限:{{permission}}。提醒:{{notificationsSupport}}。","notifications.permission.access.summaryDesktop":"权限:{{permission}}。原生提醒:{{notificationsSupport}}。","notifications.permission.access.default":"Rudder 还没有请求通知权限,因此未读 inbox 提醒可能不会出现。","notifications.permission.access.denied.desktop":"通知权限已被操作系统拦截。请在系统通知设置中重新允许 Rudder,才能恢复 macOS 提醒。","notifications.permission.access.denied.browser":"通知权限已被浏览器拦截。请在浏览器站点通知设置中重新允许 Rudder,才能在 `pnpm dev` 里预览 inbox 提醒。","notifications.permission.access.requesting":"请求中...","notifications.permission.access.enable":"开启通知","notifications.permission.access.desktopHelp":"这里能触发原生通知,但真正的允许/阻止状态由 macOS 管理。如果没有弹出通知,请打开系统设置并检查 {{appName}}。","notifications.permission.access.desktopHelpProd":"真正的允许/阻止状态由 macOS 管理。如果没有弹出通知,请打开系统设置并检查 {{appName}}。","notifications.permission.access.openSettings":"打开通知设置","notifications.environment.title":"当前环境","notifications.environment.desktop":"当前运行在 Electron 桌面壳中。","notifications.environment.browser":"当前运行在浏览器预览模式中。","notifications.environment.desktopHelp":"这里可以使用原生系统通知来提示未读 inbox 变化。","notifications.environment.browserHelp":"浏览器模式可以通过 Web Notifications API 预览未读 inbox 提醒。","notifications.behavior.title":"行为","notifications.behavior.description":"选择 Rudder 是否提示未读 inbox 活动。","notifications.behavior.inbox.title":"Inbox 活动提醒","notifications.behavior.inbox.description":"当未读 inbox 数量增加时显示提醒。","notifications.behavior.inbox.toggle":"切换 inbox 通知","systemPermissions.title":"系统权限","systemPermissions.description":"管理本地自动化、文件访问和 inbox 提醒所需的系统权限。","systemPermissions.section.title":"权限","systemPermissions.section.description":"Rudder 会尽量打开对应系统设置;最终状态仍以操作系统为准。","systemPermissions.status.authorized":"已授权","systemPermissions.status.needsAccess":"需要授权","systemPermissions.status.blocked":"已阻止","systemPermissions.status.checking":"检查中","systemPermissions.status.desktopOnly":"仅桌面应用","systemPermissions.status.perApp":"按应用授权","systemPermissions.status.unknown":"未知","systemPermissions.status.unavailable":"不可用","systemPermissions.action.openSettings":"打开设置","systemPermissions.action.desktopOnly":"仅桌面可用","systemPermissions.action.browserManaged":"由浏览器管理","systemPermissions.openSettingsFailed":"打开系统设置失败。","systemPermissions.permission.fullDiskAccess.title":"完全磁盘访问权限","systemPermissions.permission.fullDiskAccess.description":"在需要更广文件访问时读取本地项目文件和工作区元数据。","systemPermissions.permission.accessibility.title":"辅助功能","systemPermissions.permission.accessibility.description":"让 Rudder 驱动的桌面自动化在需要时观察并控制应用界面。","systemPermissions.permission.automation.title":"自动化","systemPermissions.permission.automation.description":"macOS 会按目标应用分别授权自动化;可打开此面板查看具体应用条目。","systemPermissions.permission.notifications.title":"通知","systemPermissions.permission.notifications.description":"Rudder 通知的系统访问权限。Issue 和 chat 通知可以在下方分别控制。","systemPermissions.permission.notifications.inboxLabel":"Inbox 活动提醒","systemPermissions.notifications.title":"通知","systemPermissions.notifications.description":"系统通知权限可用后,选择 Rudder 哪些事件需要提醒你。","systemPermissions.notifications.system.title":"系统通知访问权限","systemPermissions.notifications.system.description":"如果 Rudder 通知被阻止或没有出现,可以打开系统通知设置检查。","systemPermissions.notifications.issue.title":"Issue 通知","systemPermissions.notifications.issue.description":"当 issue 被创建、更新、评论或重新打开时提醒。","systemPermissions.notifications.issue.toggle":"切换 issue 通知","systemPermissions.notifications.chat.title":"Chat 通知","systemPermissions.notifications.chat.description":"当 assistant chat 回复、提议 issue 或操作时提醒。","systemPermissions.notifications.chat.toggle":"切换 chat 通知","about.title":"关于","about.version.title":"版本","about.version.description":"这里显示当前机器上运行的 Rudder 构建版本。","about.version.current":"版本","about.desktop.title":"桌面应用","about.desktop.description":"这个壳层连接到与控制台、CLI 以及其他本地 Rudder 界面共用的同一份本地实例数据。","about.desktop.profile":"环境","about.desktop.instance":"实例 ID","about.desktop.runtime":"运行时","about.desktop.owner":"拥有者","about.desktop.instanceDataPath":"实例数据路径","about.actions.title":"操作","about.actions.description":"这些动作属于应用生命周期,不应该埋在通用偏好里。","about.notifications.description":"Inbox 提醒、角标行为和权限修复入口现在都集中在独立的通知设置页中管理。","about.notifications.open":"打开通知设置","about.updates.title":"检查更新","about.updates.description":"将当前桌面构建与所选 GitHub Release 策略做对比。","about.updates.check":"检查更新","about.updates.install":"更新","about.updates.download":"下载更新","about.updates.installing":"正在更新...","about.updates.channel.stable":"正式版","about.updates.channel.canary":"正式版 + Canary","about.updates.available.inline":"发现 {{channel}} 新版本:{{latestVersion}}。","about.updates.current.inline":"{{channel}} 当前已经是最新版本:{{currentVersion}}。","about.updates.unavailable.inline":"暂时无法完成 {{channel}} 版本对比。","about.updates.available.toastTitle":"发现新版本","about.updates.available.toastBody":"{{latestVersion}} 已可下载。","about.updates.installStarted.toastTitle":"已开始更新","about.updates.installStarted.toastBody":"Rudder 会在安装 {{latestVersion}} 后关闭并重新打开。","about.updates.installWaiting.toastTitle":"更新已排队","about.updates.installWaiting.toastBody":"安装包正在下载。Rudder 会在 {{totalRuns}} 个活跃运行结束后自动更新。","about.updates.installBlocked.toastTitle":"更新已暂停","about.updates.installUnavailable":"当前构建不支持应用内安装更新。","about.updates.installFailed":"无法开始更新。","about.updates.installFailedToastTitle":"无法开始更新","about.updates.progress.title":"正在更新到 {{version}}","about.updates.progress.readyTitle":"更新已准备好","about.updates.progress.completeTitle":"重启交接已完成","about.updates.progress.detailsTitle":"更新进度详情","about.updates.progress.failedTitle":"更新失败","about.updates.progress.retry":"重试","about.updates.progress.restartToUpdate":"退出并更新","about.updates.progress.updateWhenIdle":"空闲时更新","about.updates.progress.forceRestartToUpdate":"停止运行并立即更新","about.updates.progress.blockersTitle":"正在延迟更新的运行","about.updates.progress.blockerRun":"{{organization}} · {{agent}} · 运行 {{runId}}","about.updates.progress.automaticApply":"这些运行结束后,Rudder 会自动完成更新。","about.updates.progress.openReleases":"打开发布页","about.updates.progress.dismiss":"关闭更新状态","about.updates.progress.phase.starting":"正在开始更新...","about.updates.progress.phase.resolving_release":"正在解析发布版本...","about.updates.progress.phase.downloading_checksums":"正在下载校验文件...","about.updates.progress.phase.downloading_asset":"正在下载桌面安装包...","about.updates.progress.phase.verifying_checksum":"正在校验安装包...","about.updates.progress.phase.ready_to_install":"安装包已下载并校验完成,正在检查运行状态...","about.updates.progress.phase.waiting_for_active_runs":"正在等待运行结束...","about.updates.progress.phase.preparing_restart":"正在准备重启...","about.updates.progress.phase.closing":"Rudder 将关闭并重新打开以完成更新。","about.updates.progress.phase.complete":"Rudder Desktop 启动交接已完成。","about.updates.progress.phase.failed":"更新失败。","about.updates.current.toastTitle":"已经是最新版本","about.updates.current.toastBody":"当前桌面构建已经是 {{currentVersion}}。","about.updates.unavailable.toastTitle":"暂时无法检查更新","about.updates.unavailable.toastBody":"当前无法把这个构建与最新桌面版本进行对比。","about.updates.browserFallback.toastTitle":"已打开发布页","about.updates.browserFallback.toastBody":"桌面更新检查只能在打包后的应用内运行,因此已改为打开发布页面。","about.updates.failed":"检查更新失败。","about.updates.failedToastTitle":"检查更新失败","about.feedback.title":"发送反馈","about.feedback.description":"打开默认邮件应用,并创建一封发往 Rudder 维护者邮箱的草稿。","about.feedback.send":"发送反馈","about.feedback.toastTitle":"正在打开邮件应用","about.feedback.toastBody":"正在为 Rudder 维护者邮箱创建新邮件草稿。","about.feedback.failed":"打开反馈邮件草稿失败。","about.feedback.failedToastTitle":"发送反馈失败","profile.title":"个人资料与账号","profile.description":"管理你的操作员资料、Rudder Account 和已登录设备。","profile.loadLoading":"正在加载个人资料设置...","profile.loadFailed":"加载个人资料设置失败。","profile.updateFailed":"更新个人资料设置失败。","profile.toastSaved.title":"个人资料已保存","profile.toastSaved.body":"你的操作员资料已更新。","profile.toastSaveFailed.title":"保存个人资料失败","profile.about.title":"关于你","profile.about.description":"这里沿用类似 ChatGPT 的轻量个人上下文结构:一个偏好的称呼,加上一些可选的工作背景信息。","profile.nickname.label":"你的称呼","profile.nickname.placeholder":"Rudder 应该怎么称呼你?","profile.nickname.help":"如果填写了,内置聊天助手可以用它来称呼你。","profile.moreAboutYou.label":"更多关于你","profile.moreAboutYou.placeholder":"补充一些长期有效的背景信息,帮助内置聊天助手更好理解你的请求。","profile.moreAboutYou.help":"Rudder 只会把这段内容注入内置聊天助手。如果留空,则不会追加到聊天系统提示词中。","profile.import.helper.title":"从其他 AI 导入 memories","profile.import.helper.description":"把这段提示词复制到 ChatGPT、Claude 或其他 AI provider,再把导出的 memory 粘贴到下面。","profile.import.copyPrompt":"复制 memory 导入提示词","profile.import.copiedButton":"已复制","profile.import.copied.title":"提示词已复制","profile.import.copied.body":"把结果粘贴到“更多关于你”,再编辑并保存。","profile.import.copyFailed.title":"提示词未复制","profile.import.copyFailed.body":"请手动选中提示词文本并复制。","profile.save":"保存资料","profile.saving":"保存中...","productTour.checklist.title":"完成首次工作闭环","productTour.checklist.workspace":"读懂控制台","productTour.checklist.create":"创建小任务","productTour.checklist.issues":"使用 issue 结构","productTour.checklist.inspect":"检查工作输出","productTour.checklist.settings":"再次找到教程","productTour.stepCounter":"{{current}} / {{total}}","productTour.step.workspace.title":"Rudder 是 agent work 的控制台","productTour.step.workspace.body":"主导航把关键工作面放在一起:Messenger、Dashboard、Issues、Agents、Organization、Automations 和 Calendar。用它在行动、检查和 review 之间切换。","productTour.step.create.title":"从一个 agent 真能推进的小任务开始","productTour.step.create.body":"创建菜单是新 Chat、issue、agent 和 project 的入口。第一次闭环可以选择边界清楚、结果可 review 的小 Chat 或 issue。","productTour.step.issues.title":"Issue 增加明确的工作流结构","productTour.step.issues.body":"Issue 页面展示哪些工作在等待、执行、阻塞或完成。Chat 是并列的对话式路径;需要明确 owner、状态、优先级、依赖或 review 时,再使用 issue。","productTour.step.inspect.title":"先检查工作,再审批或继续推进","productTour.step.inspect.body":"Dashboard 会展示当前页面、详情、transcript、产出和审批入口。Rudder 应该让你清楚看到发生了什么,以及哪里需要你介入。","productTour.step.settings.title":"你可以从 Settings 重新播放教程","productTour.step.settings.body":"第一次导览结束后,Rudder 会保持安静。以后想重新查看时,打开系统设置,再进入通用即可再次运行。","productTour.back":"上一步","productTour.next":"下一步","productTour.finish":"完成","productTour.skip":"跳过教程","heartbeats.title":"心跳","heartbeats.description":"查看所有组织的定时心跳配置。你可以在这里看到哪些已调度、哪些只是已配置,并直接按行启停心跳。","heartbeats.loadLoading":"正在加载调度心跳...","heartbeats.loadFailed":"加载调度心跳失败。","heartbeats.updateFailed":"更新心跳失败。","heartbeats.disableAllFailed":"批量关闭所有心跳失败。","heartbeats.summary.scheduled":"已调度","heartbeats.summary.configuredInactive":"已配置未激活","heartbeats.summary.disabled":"已关闭","heartbeats.summary.organization":"个组织","heartbeats.summary.organizations":"个组织","heartbeats.disableAll":"全部关闭","heartbeats.disabling":"关闭中...","heartbeats.confirmDisableAll.one":"确定要关闭全部 {{count}} 个已启用智能体的定时心跳吗?","heartbeats.confirmDisableAll.many":"确定要关闭全部 {{count}} 个已启用智能体的定时心跳吗?","heartbeats.empty":"没有符合当前条件的调度心跳。","heartbeats.section.title":"已调度智能体","heartbeats.section.description":"按组织分组展示已启用心跳的智能体,方便你统一查看归属、频率与最近心跳状态。","heartbeats.table.agent":"智能体","heartbeats.table.role":"角色","heartbeats.table.scheduler":"调度状态","heartbeats.table.interval":"间隔","heartbeats.table.lastHeartbeat":"最近心跳","heartbeats.table.actions":"操作","heartbeats.scheduler.scheduled":"已调度","heartbeats.scheduler.configuredInactive":"已配置,未激活","heartbeats.scheduler.disabled":"已关闭","heartbeats.never":"从未","heartbeats.fullAgentConfig":"完整智能体配置","heartbeats.timerState":"定时心跳状态","heartbeats.on":"开","heartbeats.off":"关","chat.annotations.selectionUnavailable":"选区已不可用","chat.annotations.selectionUnavailableBody":"请重新选择回复中的文字后再试。","chat.annotations.couldNotAdd":"无法添加批注","chat.annotations.added":"已添加批注","chat.annotations.removed":"已移除批注"},ZFe=["placeholder","title","aria-label"],OLt=["code","pre","script","style","textarea","[contenteditable='true']",".cm-editor",".cm-content",".mdxeditor","[data-i18n-ignore='true']"].join(", "),Wve=new WeakMap,Zve=new WeakMap;function HFe(e){return e?e.closest(OLt)!=null:!0}function XFe(e,t){const n=e.parentElement;if(!n||HFe(n))return;const r=e.textContent??"";let s=Wve.get(e);s?r!==s.rendered&&r!==s.source&&(s.source=r):(s={source:r,rendered:r},Wve.set(e,s));const a=UO(t,s.source);s.rendered=a,r!==a&&(e.textContent=a)}function GFe(e,t,n){if(!e.hasAttribute(t)||HFe(e))return;const r=e.getAttribute(t)??"";let s=Zve.get(e);s||(s=new Map,Zve.set(e,s));let a=s.get(t);a?r!==a.rendered&&r!==a.source&&(a.source=r):(a={source:r,rendered:r},s.set(t,a));const o=UO(n,a.source);a.rendered=o,r!==o&&e.setAttribute(t,o)}function Dre(e,t){if(e.nodeType===Node.TEXT_NODE){XFe(e,t);return}if(e.nodeType!==Node.ELEMENT_NODE)return;const n=e;for(const r of ZFe)GFe(n,r,t);for(const r of Array.from(n.childNodes))Dre(r,t)}function jLt({locale:e}){return m.useEffect(()=>{if(typeof document>"u")return;const t=document.body;if(!t)return;Dre(t,e);const n=new MutationObserver(r=>{for(const s of r){if(s.type==="characterData"){XFe(s.target,e);continue}if(s.type==="attributes"){GFe(s.target,s.attributeName,e);continue}for(const a of Array.from(s.addedNodes))Dre(a,e)}});return n.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[...ZFe]}),()=>n.disconnect()},[e]),null}const CLt={en:WFe,"zh-CN":SLt},YFe=m.createContext(null);function NLt(e,t){return t?e.replaceAll(/\{\{(\w+)\}\}/g,(n,r)=>{const s=t[r];return s==null?n:String(s)}):e}function PLt(e,t,n){const r=CLt[e][t]??WFe[t];return NLt(r,n)}function ILt({children:e}){var a;const n=((a=Te({queryKey:V.health,queryFn:()=>FA.get(),retry:!1}).data)==null?void 0:a.uiLocale)??"en";m.useEffect(()=>{typeof document>"u"||(document.documentElement.lang=n)},[n]);const r=m.useCallback((o,l)=>PLt(n,o,l),[n]),s=m.useMemo(()=>({locale:n,t:r}),[n,r]);return i.jsxs(YFe.Provider,{value:s,children:[i.jsx(jLt,{locale:n}),e]})}function as(){const e=m.useContext(YFe);if(!e)throw new Error("useI18n must be used within I18nProvider");return e}const tv="about:blank";function TLt(e){try{return new URL(e).hostname||e}catch{return e}}function _Lt(e){const t=TLt(e.url);return e.code==="ERR_CONNECTION_REFUSED"?{summary:`${t} refused to connect.`,suggestions:["Checking the connection","Checking the proxy and firewall"]}:e.code==="ERR_NAME_NOT_RESOLVED"?{summary:`${t}'s server IP address could not be found.`,suggestions:["Checking the address","Checking the connection"]}:e.code==="ERR_TIMED_OUT"?{summary:`${t} took too long to respond.`,suggestions:["Checking the connection","Trying again later"]}:{summary:`The page at ${t} could not be loaded.`,suggestions:["Checking the address","Trying again later"]}}function MLt(e){var r;return!e||e.type==="keyUp"||!(((r=e.key)==null?void 0:r.toLowerCase())==="w"||e.code==="KeyW")||e.alt||e.shift?!1:navigator.platform.toLowerCase().includes("mac")?!!e.meta&&!e.control:!!e.control&&!e.meta}function xR(e){return`https://www.google.com/search?q=${encodeURIComponent(e)}`}function ELt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function DLt(e){try{return new URL(e).toString()}catch{return e.trim()}}function RLt(e){return decodeURIComponent(e.pathname).replace(/\/+$/g,"").split("/").filter(Boolean).at(-1)||"File"}function LLt(e,t){try{const n=decodeURIComponent(t.pathname);return/^file:\/\/\//i.test(e)&&t.protocol==="file:"&&t.hostname===""&&n.startsWith("/")&&!/^\/[\\/]/.test(n)}catch{return!1}}function z5(e){const t=e.trim();if(!t||t===tv)return"New tab";try{const n=new URL(t);return n.protocol==="file:"?RLt(n):n.hostname||n.protocol.replace(":","")||"Browser"}catch{return t}}function zLt(e){const t=e.trim();if(!t||/^about:blank$/i.test(t))return tv;if(/^(https?|file):/i.test(t))try{const n=new URL(t);return n.protocol==="http:"||n.protocol==="https:"||LLt(t,n)?n.toString():xR(t)}catch{return xR(t)}return/^(localhost|\d{1,3}(?:\.\d{1,3}){3})(:\d+)?(\/.*)?$/i.test(t)?`http://${t}`:/^[a-z][a-z0-9+.-]*:/i.test(t)||/\s/.test(t)?xR(t):t.includes(".")?`https://${t}`:xR(t)}function E4(e=tv,t={newTab:!0}){return{kind:"browser",url:e,label:z5(e),tabId:ELt(),...t.favicon?{favicon:t.favicon}:{},...t.newTab===!1?{dedupeKey:DLt(e)}:{}}}const QX=[.25,.33,.5,.67,.75,.8,.9,1,1.1,1.25,1.5,1.75,2,2.5,3,4,5],JFe="rudder.browser.side-panel-onboarding.dismissed.v1",eBe="rudder.browser.side-panel-onboarding.session-dismissed.v1",UX="rudder:browser-side-panel-onboarding-dismissed";function $Lt(){if(typeof window>"u")return!0;try{if(window.localStorage.getItem(JFe)==="true")return!0}catch{}try{return window.sessionStorage.getItem(eBe)==="true"}catch{return!1}}function FLt(e){if(typeof e!="string")return null;const t=e.trim();if(!t||t.length>J_)return null;if(t.startsWith("data:image/"))return t;try{const n=new URL(t);return n.protocol==="http:"||n.protocol==="https:"?t:null}catch{return null}}function tBe({active:e,canOpenNewTab:t,surface:n,target:r,targetKey:s,onOpenBrowserSettings:a,onOpenTarget:o,onReplaceTarget:l,onCloseTarget:c,onCycleTab:d,onWebContentsIdChange:u,onRegisterShortcutController:f}){const{t:A}=as(),h=m.useRef(null),g=m.useRef(null),x=m.useRef(!1),y=m.useRef(r.url),v=m.useRef(r.url),w=m.useRef(r),k=m.useRef(l),O=m.useRef(c),j=m.useRef(d),C=m.useRef(u),N=m.useRef(e),I=m.useRef(null),[E,_]=m.useState(null),T=m.useRef(1),[R,M]=m.useState(r.url===tv?"":r.url),[L,U]=m.useState(r.url),[B,z]=m.useState(r.url),[H,J]=m.useState(!1),[F,Q]=m.useState({canGoBack:!1,canGoForward:!1}),[W,$]=m.useState(null),[ee,re]=m.useState(!1),[ne,te]=m.useState(()=>!$Lt()),ce=L===tv,se=W?_Lt(W):null;v.current=L,w.current=r,k.current=l,O.current=c,j.current=d,C.current=u,N.current=e;const he=m.useCallback((me,ye)=>{const qe=g.current;if(!x.current||!qe||qe.tagName.toLowerCase()!=="webview")return ye;try{return me(qe)}catch{return ye}},[]),we=m.useCallback(me=>he(ye=>{var qe;return((qe=ye.getURL)==null?void 0:qe.call(ye))??me},me),[he]),Ue=m.useCallback(()=>{Q({canGoBack:he(me=>{var ye;return!!((ye=me.canGoBack)!=null&&ye.call(me))},!1),canGoForward:he(me=>{var ye;return!!((ye=me.canGoForward)!=null&&ye.call(me))},!1)})},[he]),je=m.useCallback(me=>{he(qe=>qe.setZoomFactor?(qe.setZoomFactor(me),!0):!1,!1)&&(T.current=me)},[he]),ke=m.useCallback(me=>{const ye=T.current;let qe=0,Ce=Number.POSITIVE_INFINITY;QX.forEach((G,Ae)=>{const Je=Math.abs(G-ye);Je<Ce&&(Ce=Je,qe=Ae)});const X=Math.max(0,Math.min(QX.length-1,qe+me));je(QX[X]??1)},[je]),Se=m.useCallback(me=>{var ye,qe;if(e)switch(me){case"new_tab":t&&o(E4());return;case"focus_location":(ye=h.current)==null||ye.focus(),(qe=h.current)==null||qe.select();return;case"reload":ce||he(Ce=>{var X;return(X=Ce.reload)==null?void 0:X.call(Ce)},void 0);return;case"reload_ignoring_cache":ce||he(Ce=>{var X;return(X=Ce.reloadIgnoringCache)==null?void 0:X.call(Ce)},void 0);return;case"go_back":ce||he(Ce=>{var X,G;(X=Ce.canGoBack)!=null&&X.call(Ce)&&((G=Ce.goBack)==null||G.call(Ce))},void 0);return;case"go_forward":ce||he(Ce=>{var X,G;(X=Ce.canGoForward)!=null&&X.call(Ce)&&((G=Ce.goForward)==null||G.call(Ce))},void 0);return;case"zoom_in":ce||ke(1);return;case"zoom_out":ce||ke(-1);return;case"zoom_reset":ce||je(1)}},[e,je,t,ce,o,he,ke]);I.current=Se,m.useEffect(()=>(f(s,Se),()=>f(s,null)),[Se,f,s]);const oe=m.useCallback((me,ye=z5(me))=>{const qe=w.current.url!==me,Ce={...w.current,url:me,label:ye,favicon:qe?void 0:w.current.favicon};v.current=me,w.current=Ce,U(me),M(me===tv?"":me),y.current=me,k.current(s,Ce)},[s]);m.useEffect(()=>{const me=y.current!==r.url;y.current=r.url,v.current=r.url,w.current=r,U(r.url),M(r.url===tv?"":r.url),me&&(z(r.url),$(null),re(!1)),x.current?Ue():Q({canGoBack:!1,canGoForward:!1})},[r.label,r.url,Ue]),m.useEffect(()=>{const me=E;if(!me||me.tagName.toLowerCase()!=="webview")return;const ye=()=>{J(!0),$(null),re(!1)},qe=ft=>{const dt=!("isMainFrame"in ft)||ft.isMainFrame!==!1,yt="url"in ft&&typeof ft.url=="string"?ft.url:"";dt&&yt&&yt!==v.current&&oe(yt,z5(yt))},Ce=()=>{J(!1);const ft=we("");ft&&ft!==v.current&&oe(ft,z5(ft)),Ue()},X=ft=>{const dt="url"in ft&&typeof ft.url=="string"?ft.url:we("");dt&&oe(dt,z5(dt)),Ue()},G=ft=>{const dt=we(v.current),yt="title"in ft&&typeof ft.title=="string"&&ft.title.trim()?ft.title.trim():z5(dt),Mt={...w.current,url:dt,label:yt};w.current=Mt,k.current(s,Mt)},Ae=ft=>{const yt=("favicons"in ft&&Array.isArray(ft.favicons)?ft.favicons:[]).map(FLt).find(Xe=>!!Xe);if(!yt||yt===w.current.favicon)return;const Mt={...w.current,favicon:yt};w.current=Mt,k.current(s,Mt)},Je=ft=>{const dt="errorDescription"in ft&&typeof ft.errorDescription=="string"?ft.errorDescription:"Could not load this page.",yt="validatedURL"in ft&&typeof ft.validatedURL=="string"&&ft.validatedURL?ft.validatedURL:v.current;(!("isMainFrame"in ft)||ft.isMainFrame!==!1)&&dt!=="ERR_ABORTED"&&(J(!1),$({code:dt,url:yt}),re(!1)),Ue()},ht=()=>{var dt,yt;x.current=!0;const ft=(dt=me.getWebContentsId)==null?void 0:dt.call(me);typeof ft=="number"&&Number.isFinite(ft)&&((yt=C.current)==null||yt.call(C,ft)),T.current!==1&&he(Mt=>{var Xe;return(Xe=Mt.setZoomFactor)==null?void 0:Xe.call(Mt,T.current)},void 0),Ue()},De=ft=>{var At,it;const dt=ft,yt=dt.input;if(yt&&yt.type!=="keyUp"&&(yt.key==="Tab"||yt.code==="Tab")&&!!yt.control&&!yt.meta&&!yt.alt&&N.current&&j.current){ft.preventDefault(),j.current(yt.shift?-1:1);return}if((At=Pn())!=null&&At.onBrowserShortcut)return;if(MLt(dt.input)){ft.preventDefault(),O.current(w.current);return}if(!dt.input||!N.current)return;const Xe=WEe(dt.input,{isMac:navigator.platform.toLowerCase().includes("mac")});Xe&&(ft.preventDefault(),(it=I.current)==null||it.call(I,Xe))};return me.addEventListener("dom-ready",ht),me.addEventListener("before-input-event",De),me.addEventListener("did-start-loading",ye),me.addEventListener("did-start-navigation",qe),me.addEventListener("did-stop-loading",Ce),me.addEventListener("did-navigate",X),me.addEventListener("did-navigate-in-page",X),me.addEventListener("page-title-updated",G),me.addEventListener("page-favicon-updated",Ae),me.addEventListener("did-fail-load",Je),Ue(),()=>{me.removeEventListener("dom-ready",ht),me.removeEventListener("before-input-event",De),me.removeEventListener("did-start-loading",ye),me.removeEventListener("did-start-navigation",qe),me.removeEventListener("did-stop-loading",Ce),me.removeEventListener("did-navigate",X),me.removeEventListener("did-navigate-in-page",X),me.removeEventListener("page-title-updated",G),me.removeEventListener("page-favicon-updated",Ae),me.removeEventListener("did-fail-load",Je)}},[oe,we,he,s,Ue,E]);const fe=m.useCallback(me=>{g.current=me,x.current=!1,_(me),me||Q({canGoBack:!1,canGoForward:!1})},[]);m.useEffect(()=>()=>{var me;(me=C.current)==null||me.call(C,null)},[]),m.useEffect(()=>{const me=()=>te(!1);return window.addEventListener(UX,me),()=>{window.removeEventListener(UX,me)}},[]);const Ie=()=>{te(!1);try{window.localStorage.setItem(JFe,"true")}catch{}try{window.sessionStorage.setItem(eBe,"true")}catch{}window.dispatchEvent(new Event(UX))},ue=m.useCallback(me=>{const ye=zLt(me);$(null),re(!1),z(ye),oe(ye,z5(ye))},[oe]),be=m.useCallback(()=>{re(!1),he(me=>{var ye;(ye=me.reload)==null||ye.call(me)},void 0)},[he]),at=me=>{me.preventDefault();const qe=new FormData(me.currentTarget).get("browser-url");ue(typeof qe=="string"?qe:R)},ve=()=>{var ye;if(ce)return;const me=Pn();if(me){((ye=me.forceOpenExternal)==null?void 0:ye.call(me,L))??me.openExternal(L);return}window.open(L,"_blank","noopener,noreferrer")};return i.jsxs("div",{className:"flex min-h-full flex-col bg-[color:var(--surface-elevated)]","data-testid":e?"chat-side-panel-browser-view":"chat-side-panel-browser-view-hidden","data-browser-tab-id":r.tabId,"data-active":e?"true":"false",children:[i.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-2 py-2","data-testid":"chat-side-panel-browser-toolbar",children:[i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Back",disabled:!F.canGoBack,onClick:()=>he(me=>{var ye;(ye=me.goBack)==null||ye.call(me)},void 0),children:i.jsx(yx,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Forward",disabled:!F.canGoForward,onClick:()=>he(me=>{var ye;(ye=me.goForward)==null||ye.call(me)},void 0),children:i.jsx(j4,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Reload",disabled:ce,onClick:be,children:i.jsx(s2,{className:q("h-3.5 w-3.5",H&&"animate-spin")})}),i.jsx("form",{className:"min-w-0 flex-1",onSubmit:at,children:i.jsx(Vn,{ref:h,"aria-label":"Browser URL",name:"browser-url",value:R,onChange:me=>M(me.currentTarget.value),placeholder:"Enter a URL",className:"h-8 rounded-[var(--radius-md)] bg-[color:var(--surface-inset)] font-mono text-xs"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open new browser tab",title:t?"Open new browser tab":"Browser tab limit reached",disabled:!t,onClick:()=>o(E4()),children:i.jsx(Ur,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open browser page externally",disabled:ce,onClick:ve,children:i.jsx(La,{className:"h-3.5 w-3.5"})})]}),i.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col bg-[color:var(--surface-inset)]","data-testid":"chat-side-panel-browser-content",children:[e&&n==="side_panel"&&ne?i.jsx(KFe,{testId:"browser-side-panel-onboarding",className:"absolute right-3 top-3 z-20 w-[min(24rem,calc(100%-1.5rem))] shadow-[var(--shadow-lg)]",icon:i.jsx(oue,{"aria-hidden":"true"}),title:A("browser.onboarding.title"),description:A("browser.onboarding.description"),stackActions:!0,actions:i.jsxs(i.Fragment,{children:[a?i.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:()=>{Ie(),a()},children:A("browser.onboarding.settings")}):null,i.jsx(ie,{type:"button",size:"sm",onClick:Ie,children:A("browser.onboarding.dismiss")})]})}):null,ce?i.jsx("div",{className:"flex min-h-[44vh] flex-1 items-center justify-center px-6 text-center","data-testid":"chat-side-panel-browser-start",children:i.jsxs("div",{className:"max-w-[18rem]",children:[i.jsx(Vm,{className:"mx-auto h-12 w-12 text-muted-foreground"}),i.jsx("h3",{className:"mt-4 text-base font-semibold text-foreground",children:"Start browsing"}),i.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Enter a URL to open a page."})]})}):i.jsxs("div",{className:"relative flex min-h-[52vh] flex-1",children:[m.createElement("webview",{ref:fe,src:B,className:q("min-h-[52vh] flex-1 bg-[color:var(--surface-elevated)]",W&&"invisible"),"data-testid":e?"chat-side-panel-browser-webview":"chat-side-panel-browser-webview-hidden","data-browser-tab-id":r.tabId,"data-active":e?"true":"false",allowpopups:"true"}),W?i.jsx("div",{role:"alert","data-testid":"chat-side-panel-browser-error",className:"absolute inset-0 flex overflow-y-auto bg-[color:var(--surface-elevated)] px-8 py-10",children:i.jsxs("div",{className:"m-auto w-full max-w-[32rem]",children:[i.jsx(u7t,{className:"h-12 w-12 text-muted-foreground","aria-hidden":"true"}),i.jsx("h3",{className:"mt-6 text-xl font-semibold text-foreground",children:"This site can't be reached"}),i.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:se==null?void 0:se.summary}),i.jsxs("div",{className:"mt-5 text-sm text-muted-foreground",children:[i.jsx("p",{children:"Try:"}),i.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-6",children:se==null?void 0:se.suggestions.map(me=>i.jsx("li",{children:me},me))})]}),i.jsx("p",{className:"mt-5 font-mono text-xs text-muted-foreground",children:W.code}),ee?i.jsx("p",{className:"mt-4 break-all rounded-[var(--radius-md)] border border-[color:var(--border-soft)] bg-[color:var(--surface-inset)] px-3 py-2 font-mono text-xs text-muted-foreground",children:W.url}):null,i.jsxs("div",{className:"mt-7 flex items-center justify-between gap-3",children:[i.jsx(ie,{type:"button",variant:"outline",size:"sm","aria-expanded":ee,onClick:()=>re(me=>!me),children:"Details"}),i.jsxs(ie,{type:"button",size:"sm",onClick:be,children:[i.jsx(s2,{className:"h-3.5 w-3.5"}),"Reload"]})]})]})}):null]})]})]})}function wf(e,t){return(e==null?void 0:e.trim())||t}function dB(e,t){return e.split("/").filter(Boolean).at(-1)??t}function nBe(e){try{return new URL(e,"http://rudder.local")}catch{return null}}function rBe(e){return(e.searchParams.get("messageId")??e.searchParams.get("targetMessageId")??"").trim()||null}function BLt(e){const t=decodeURIComponent(e.hash.replace(/^#/,"")).trim();return t.startsWith("comment-")&&t.slice(8).trim()||null}function Rre(e){return e.kind==="issue"?`issue:${e.issueId}:${e.commentId??""}`:e.kind==="issue_proposal"?`issue-proposal:${e.conversationId}:${e.messageId}`:e.kind==="automation"?`automation:${e.automationId}`:e.kind==="chat"?`chat:${e.conversationId}:${e.messageId??""}`:e.kind==="subagents"?`subagents:${e.conversationId}`:e.kind==="subagent"?`subagent:${e.threadId}`:e.kind==="side_chat"?e.conversationId?`side-chat:${e.conversationId}`:`side-chat:draft:${e.clientMutationId}`:e.kind==="library_document"?`library-document:${e.documentId}`:e.kind==="library_entry"?`library-entry:${e.entryId}:${e.path??""}`:e.kind==="library_file"?`library-file:${e.filePath}`:e.kind==="local_file"?`local-file:${e.filePath}`:e.kind==="organization_skill_file"?`organization-skill-file:${e.skillId}:${e.filePath}`:e.kind==="local_apps"?"local-apps":e.kind==="local_app"?`local-app:${encodeURIComponent(e.desktopInstallationId)}:${encodeURIComponent(e.appPublicId)}:${encodeURIComponent(e.localBindingId)}`:e.kind==="library_directory"?`library-directory:${e.directoryPath}`:e.kind==="browser"?`browser-tab:${e.tabId}`:`placeholder:${e.targetKind}`}function _f(e){return e.kind==="automation"||e.kind==="library_document"||e.kind==="library_entry"||e.kind==="library_file"||e.kind==="library_directory"||e.kind==="browser"||e.kind==="local_app"}function gs(e){const t=Rre(e);return e.kind==="browser"||!_f(e)||!e.viewInstanceId?t:`${t}:view:${e.viewInstanceId}`}function QLt(e,t){var l,c,d;const n=nBe(e);if(!n||n.origin!=="http://rudder.local")return null;const r=n.pathname.split("/").filter(Boolean).map(u=>{try{return decodeURIComponent(u)}catch{return u}}),s=r.length>=2&&r.at(-2)==="issues"?(l=r.at(-1))==null?void 0:l.trim():"";if(s)return{kind:"issue",issueId:s,ref:(t==null?void 0:t.trim())||null,commentId:BLt(n),label:wf(t,"Issue")};const a=r.length>=2&&r.at(-2)==="automations"?(c=r.at(-1))==null?void 0:c.trim():"";if(a)return{kind:"automation",automationId:a,label:wf(t,n.searchParams.get("t")??n.searchParams.get("title")??"Automation")};const o=r.length>=2&&r.at(-2)==="chat"?(d=r.at(-1))==null?void 0:d.trim():"";if(o)return{kind:"chat",conversationId:o,messageId:rBe(n),label:wf(t,"Chat")};if(r.at(-1)==="library"){const u=(n.searchParams.get("skill")??"").trim();if(u)return{kind:"organization_skill_file",skillId:u,filePath:(n.searchParams.get("skillFile")??"SKILL.md").trim()||"SKILL.md",label:wf(t,"Skill")};const f=(n.searchParams.get("document")??n.searchParams.get("doc")??"").trim();if(f)return{kind:"library_document",documentId:f,label:wf(t,n.searchParams.get("t")??n.searchParams.get("title")??"Library document")};const A=(n.searchParams.get("path")??"").trim();if(A)return{kind:"library_file",filePath:A,label:wf(t,dB(A,"Library file"))};const h=(n.searchParams.get("directory")??"").trim();if(h)return{kind:"library_directory",directoryPath:h,label:wf(t,dB(h,"Library directory"))};const g=(n.searchParams.get("entry")??"").trim();if(g)return{kind:"library_entry",entryId:g,path:A||null,label:wf(t,g)}}return null}function ULt(e,t){const n=$c(e);if(!n)return QLt(e,t);if(n.kind==="issue")return{kind:"issue",issueId:n.issueId,ref:n.ref??(t==null?void 0:t.trim())??null,commentId:n.commentId,label:wf(t,n.ref??"Issue")};if(n.kind==="automation")return{kind:"automation",automationId:n.automationId,label:wf(t,n.title??"Automation")};if(n.kind==="chat"){const r=nBe(e);return{kind:"chat",conversationId:n.conversationId,messageId:r?rBe(r):null,label:wf(t,n.title??"Chat")}}return n.kind==="library_doc"?{kind:"library_document",documentId:n.documentId,label:wf(t,n.title??"Library document")}:n.kind==="library_entry"?{kind:"library_entry",entryId:n.entryId,path:n.path,label:wf(t,n.title??n.path??"Library entry")}:n.kind==="library_file"?{kind:"library_file",filePath:n.filePath,label:wf(t,n.title??dB(n.filePath,"Library file"))}:n.kind==="library_directory"?{kind:"library_directory",directoryPath:n.directoryPath,label:wf(t,n.title??dB(n.directoryPath,"Library directory"))}:null}const VLt=m.lazy(async()=>({default:(await Wt(async()=>{const{AutomationDetail:e}=await Promise.resolve().then(()=>gNn);return{AutomationDetail:e}},void 0)).AutomationDetail})),qLt=m.lazy(async()=>({default:(await Wt(async()=>{const{LibraryLiveSurface:e}=await import("./LibraryLiveSurface-CC-trIKx.js");return{LibraryLiveSurface:e}},[])).LibraryLiveSurface})),lfe=m.createContext(null);function uB(e){var n;const t=((n=e.viewInstanceId)==null?void 0:n.trim())||(e.kind==="browser"?e.tabId.trim():"");if(!t)throw new Error(`${e.kind} live surface requires a viewInstanceId`);return t}function jI(e,t){return JSON.stringify([e.trim(),t.kind,uB(t)])}function sBe(e){try{const t=JSON.parse(e);return Array.isArray(t)&&typeof t[0]=="string"?t[0]:""}catch{return""}}function VX(e,t){return e.kind===t.kind&&uB(e)===uB(t)}function Lre(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,l)=>Lre(o,t[l]));const n=e,r=t,s=Object.keys(n).filter(o=>n[o]!==void 0),a=Object.keys(r).filter(o=>r[o]!==void 0);return s.length===a.length&&s.every(o=>Object.hasOwn(r,o)&&Lre(n[o],r[o]))}function iBe(e){return e.startsWith("main:")?"workbench":"side_panel"}function zre(e){if(!aBe(e))return!1;const t=e.element.getBoundingClientRect();return t.width>0&&t.height>0}function aBe(e){return!!(e!=null&&e.active&&e.element.isConnected)}function KLt({children:e}){const t=m.useRef(new Map),n=m.useRef(new Map),[r,s]=m.useState(0),a=m.useCallback(()=>{s(T=>T+1)},[]),o=m.useCallback(T=>{const R=t.current.get(T.runtimeId);if(R&&!VX(R.target,T.target))return()=>{};const M=R??{interactionLocked:!1,leaseOwnerId:null,owners:new Map,renderSurface:T.renderSurface??null,runtimeId:T.runtimeId,shortcutController:null,target:T.target,webContentsId:null};return M.owners.set(T.ownerId,T),T.renderSurface&&(M.renderSurface=T.renderSurface),t.current.set(T.runtimeId,M),a(),()=>{const L=t.current.get(T.runtimeId);L&&(L.owners.delete(T.ownerId),L.leaseOwnerId===T.ownerId&&(L.leaseOwnerId=null),a())}},[a]),l=m.useCallback(T=>{const R=t.current.get(T.runtimeId);if(!R||!VX(R.target,T.target))return;const M=R.owners.get(T.ownerId);if(!M)return;const L=!Lre(M.target,T.target);(M.active!==T.active||M.callbacks!==T.callbacks||M.element!==T.element||M.hostId!==T.hostId||M.renderSurface!==T.renderSurface||L)&&(R.owners.set(T.ownerId,T),L&&R.leaseOwnerId===T.ownerId&&!R.interactionLocked&&(R.target=T.target),T.renderSurface&&(R.renderSurface=T.renderSurface),a())},[a]),c=m.useCallback((T,R)=>{const M=t.current.get(T),L=M==null?void 0:M.owners.get(R);return!M||!zre(L)?!1:(M.leaseOwnerId===R||(M.leaseOwnerId=R,a()),!0)},[a]),d=m.useCallback((T,R)=>{const M=t.current.get(T),L=M==null?void 0:M.owners.get(R);return!M||!aBe(L)||M.leaseOwnerId&&M.leaseOwnerId!==R?!1:(M.leaseOwnerId===R||(M.leaseOwnerId=R,a()),!0)},[a]),u=m.useCallback(async(T,R,M=5e3)=>{var U;const L=Date.now();for(;Date.now()-L<=M;){const B=(U=t.current.get(T))==null?void 0:U.owners.get(R);if(zre(B))return!0;await new Promise(z=>{window.setTimeout(z,16)})}return!1},[]),f=m.useCallback((T,R)=>{const M=t.current.get(T);!M||M.interactionLocked===R||(M.interactionLocked=R,a())},[a]),A=m.useCallback((T,R)=>{const M=t.current.get(T);return!M||!VX(M.target,R)?!1:(M.target=R,a(),!0)},[a]),h=m.useCallback(T=>{const R=t.current.get(T);R&&(R.webContentsId!==null&&n.current.delete(R.webContentsId),t.current.delete(T),a())},[a]),g=m.useCallback((T,R)=>{const M=t.current.get(T);!M||M.webContentsId===R||(M.webContentsId!==null&&n.current.delete(M.webContentsId),M.webContentsId=R,R!==null&&n.current.set(R,T))},[]),x=m.useCallback(T=>{const R=n.current.get(T),M=R?t.current.get(R):null,L=M!=null&&M.leaseOwnerId?M.owners.get(M.leaseOwnerId):null;return!M||!L?null:{hostId:L.hostId,ownerId:L.ownerId,runtimeId:M.runtimeId,surface:iBe(L.ownerId),targetKind:M.target.kind}},[]),y=m.useCallback((T,R)=>{const M=n.current.get(T),L=M?t.current.get(M):null,U=L!=null&&L.leaseOwnerId?L.owners.get(L.leaseOwnerId):null;return U!=null&&U.callbacks.onOpenTarget?(U.callbacks.onOpenTarget(R),!0):!1},[]),v=m.useCallback(T=>{const R=t.current.get(T),M=R!=null&&R.leaseOwnerId?R.owners.get(R.leaseOwnerId):null;return!R||!(M!=null&&M.callbacks.onCloseTarget)?!1:(M.callbacks.onCloseTarget(R.target),!0)},[]),w=m.useCallback(T=>{const R=n.current.get(T);return R?v(R):!1},[v]),k=m.useCallback((T,R)=>{const M=t.current.get(T);!M||M.target.kind!=="browser"||(M.shortcutController=R)},[]),O=m.useCallback((T,R)=>{const M=t.current.get(T);return!M||M.target.kind!=="browser"||!M.leaseOwnerId||!M.shortcutController?!1:(M.shortcutController(R),!0)},[]),j=m.useCallback((T,R)=>{const M=n.current.get(T);return M?O(M,R):!1},[O]),C=m.useCallback(T=>Array.from(t.current.values()).filter(R=>R.target.kind==="browser"&&sBe(R.runtimeId)===T).length,[]),N=m.useCallback(T=>{var R;return((R=t.current.get(T))==null?void 0:R.target)??null},[]),I=m.useCallback(T=>t.current.has(T),[]),E=m.useCallback(()=>Array.from(t.current.values()),[]),_=m.useMemo(()=>({autoClaimSurface:d,claimSurface:c,closeTargetForGuest:w,closeTargetForRuntime:v,dispatchBrowserShortcutForGuest:j,dispatchBrowserShortcutForRuntime:O,disposeSurface:h,getGuestOwner:x,getLiveBrowserCount:C,getRuntimeTarget:N,hasSurface:I,listRecords:E,openTargetForGuest:y,registerBrowserShortcutController:k,registerOwner:o,registerWebContentsId:g,revision:r,setInteractionLocked:f,updateOwner:l,updateTarget:A,waitForOwner:u}),[d,c,w,v,j,O,h,x,C,N,I,E,y,k,o,g,r,f,l,A,u]);return i.jsx(lfe.Provider,{value:_,children:e})}function IM(){const e=m.useContext(lfe);if(!e)throw new Error("useLiveSurfaceRuntime must be used inside LiveSurfaceRuntimeProvider");return e}function cfe(){return m.useContext(lfe)}function oBe({active:e,autoClaim:t=!0,callbacks:n={},hostId:r,ownerId:s,renderSurface:a,runtimeId:o,target:l,...c}){const{autoClaimSurface:d,registerOwner:u,updateOwner:f}=IM(),A=m.useRef(null),h=m.useRef(n);h.current=n;const g=m.useMemo(()=>({get annotationConversationId(){return h.current.annotationConversationId},get canOpenNewTab(){return h.current.canOpenNewTab},get savedViewId(){return h.current.savedViewId},onCloseTarget:x=>{var y,v;return(v=(y=h.current).onCloseTarget)==null?void 0:v.call(y,x)},onCycleTab:x=>{var y,v;return(v=(y=h.current).onCycleTab)==null?void 0:v.call(y,x)},onLocalAppTitleChange:x=>{var y,v;return(v=(y=h.current).onLocalAppTitleChange)==null?void 0:v.call(y,x)},onOpenBrowserSettings:()=>{var x,y;return(y=(x=h.current).onOpenBrowserSettings)==null?void 0:y.call(x)},onOpenTarget:x=>{var y,v;return(v=(y=h.current).onOpenTarget)==null?void 0:v.call(y,x)},onRegisterShortcutController:(x,y)=>{var v,w;return(w=(v=h.current).onRegisterShortcutController)==null?void 0:w.call(v,x,y)},onReplaceTarget:x=>{var y,v;return(v=(y=h.current).onReplaceTarget)==null?void 0:v.call(y,x)}}),[]);return m.useLayoutEffect(()=>{const x=A.current;if(x)return u({active:e,callbacks:g,element:x,hostId:r,ownerId:s,renderSurface:a,runtimeId:o,target:l})},[r,s,u,o]),m.useLayoutEffect(()=>{const x=A.current;if(!x)return;f({active:e,callbacks:g,element:x,hostId:r,ownerId:s,renderSurface:a,runtimeId:o,target:l}),e&&t&&d(o,s)},[e,t,d,r,s,a,o,g,l,f]),i.jsx("div",{...c,ref:A,"data-owner-id":s})}function WLt({record:e,owner:t,visible:n}){var f;const r=IM(),s=e.target,a=t==null?void 0:t.callbacks,o=t?iBe(t.ownerId):"side_panel",l=A=>{var h;(h=a==null?void 0:a.onCloseTarget)==null||h.call(a,A)},c=A=>{var h;(h=a==null?void 0:a.onOpenTarget)==null||h.call(a,A)},d=A=>{var h;(A.kind==="automation"||A.kind==="browser"||A.kind==="library_directory"||A.kind==="library_document"||A.kind==="library_entry"||A.kind==="library_file"||A.kind==="local_app")&&r.updateTarget(e.runtimeId,A),e.interactionLocked||(h=a==null?void 0:a.onReplaceTarget)==null||h.call(a,A)},u=(f=e.renderSurface)==null?void 0:f.call(e,{active:n,closeTarget:l,openTarget:c,replaceTarget:d,surface:o,target:s});return s.kind==="browser"?i.jsx(tBe,{active:n,canOpenNewTab:(a==null?void 0:a.canOpenNewTab)??!1,surface:o,target:s,targetKey:gs(s),onCloseTarget:l,onCycleTab:a==null?void 0:a.onCycleTab,onOpenBrowserSettings:a==null?void 0:a.onOpenBrowserSettings,onOpenTarget:c,onRegisterShortcutController:(A,h)=>{var g;r.registerBrowserShortcutController(e.runtimeId,h),(g=a==null?void 0:a.onRegisterShortcutController)==null||g.call(a,A,h)},onReplaceTarget:(A,h)=>d(h),onWebContentsIdChange:A=>{r.registerWebContentsId(e.runtimeId,A)}}):s.kind==="local_app"?i.jsx(qFe,{active:n,savedViewId:a==null?void 0:a.savedViewId,target:s,onTitleChange:a==null?void 0:a.onLocalAppTitleChange}):u!==void 0?i.jsx(i.Fragment,{children:u}):s.kind==="automation"?i.jsx(m.Suspense,{fallback:i.jsx("div",{className:"h-full"}),children:i.jsx(VLt,{automationId:s.automationId,onClose:()=>l(s),surface:o})}):i.jsx(m.Suspense,{fallback:i.jsx("div",{className:"h-full"}),children:i.jsx(qLt,{active:n,annotationConversationId:a==null?void 0:a.annotationConversationId,organizationId:sBe(e.runtimeId),onOpenTarget:c,surface:o,target:s})})}function ZLt(){const e=IM(),t=e.listRecords(),[,n]=m.useState(0);return m.useEffect(()=>{const r=()=>n(a=>a+1);window.addEventListener("resize",r),window.addEventListener("scroll",r,!0);const s=typeof ResizeObserver>"u"?null:new ResizeObserver(r);for(const a of e.listRecords())for(const o of a.owners.values())s==null||s.observe(o.element);return()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0),s==null||s.disconnect()}},[e]),i.jsx("div",{className:"pointer-events-none fixed inset-0","data-testid":"live-surface-runtime-layer","aria-label":"Live workspace surfaces",children:t.map(r=>{const s=r.leaseOwnerId?r.owners.get(r.leaseOwnerId)??null:null,a=zre(s),o=a?s.element.getBoundingClientRect():null,l=!a||r.interactionLocked;return i.jsx("div",{"data-testid":"live-surface-runtime-host","data-host-id":s==null?void 0:s.hostId,"data-owner-id":s==null?void 0:s.ownerId,"data-runtime-id":r.runtimeId,"data-target-kind":r.target.kind,"data-view-instance-id":uB(r.target),"aria-hidden":!a,hidden:!a,inert:l?!0:void 0,className:`fixed flex min-h-0 flex-col overflow-hidden bg-[color:var(--surface-panel)] ${s!=null&&s.ownerId.startsWith("side:")?"rounded-[var(--desktop-workspace-radius)]":s!=null&&s.ownerId.startsWith("main:")?r.target.kind==="browser"?"rounded-[var(--desktop-workspace-radius)]":"rounded-b-[var(--desktop-workspace-radius)]":""}`,style:{height:o?`${o.height}px`:"0px",left:o?`${o.left}px`:"0px",pointerEvents:l?"none":"auto",top:o?`${o.top}px`:"0px",width:o?`${o.width}px`:"0px",zIndex:s!=null&&s.ownerId.startsWith("side:")?70:40},children:i.jsx(WLt,{record:r,owner:s,visible:a&&!r.interactionLocked})},r.runtimeId)})})}const wk=[{actionId:"commandPalette.open",label:"Open command palette",description:"Search and jump across Rudder.",scope:"Global",defaultBindings:[{key:"k",code:"KeyK",metaKey:!0},{key:"k",code:"KeyK",ctrlKey:!0}],defaultBindingsByPlatform:{mac:[{key:"k",code:"KeyK",metaKey:!0}],nonMac:[{key:"k",code:"KeyK",ctrlKey:!0}]},configurable:!0,disableable:!0},{actionId:"settings.open",label:"Open settings",description:"Open System Settings.",scope:"Global",defaultBindings:[{key:",",metaKey:!0},{key:",",ctrlKey:!0}],defaultBindingsByPlatform:{mac:[{key:",",metaKey:!0}],nonMac:[{key:",",ctrlKey:!0}]},configurable:!0,disableable:!0},{actionId:"chat.create",label:"New chat",description:"Open the new chat composer.",scope:"Global",defaultBindings:[{key:"s",code:"KeyS",metaKey:!0,altKey:!0},{key:"s",code:"KeyS",ctrlKey:!0,altKey:!0}],defaultBindingsByPlatform:{mac:[{key:"s",code:"KeyS",metaKey:!0,altKey:!0}],nonMac:[{key:"s",code:"KeyS",ctrlKey:!0,altKey:!0}]},configurable:!0,disableable:!0},{actionId:"issue.create",label:"Create issue",description:"Open the new issue dialog.",scope:"Global",defaultBindings:[{key:"n",code:"KeyN",metaKey:!0},{key:"n",code:"KeyN",ctrlKey:!0}],defaultBindingsByPlatform:{mac:[{key:"n",code:"KeyN",metaKey:!0}],nonMac:[{key:"n",code:"KeyN",ctrlKey:!0}]},configurable:!0,disableable:!0},{actionId:"sidebar.toggle",label:"Toggle sidebar",description:"Show or hide the workspace sidebar.",scope:"Global",defaultBindings:[{key:"["}],configurable:!0,disableable:!0},{actionId:"panel.toggle",label:"Toggle panel",description:"Show or hide the context panel.",scope:"Global",defaultBindings:[{key:"]"}],configurable:!0,disableable:!0},{actionId:"system.escapeBack",label:"Navigate back / close detail",description:"System Escape behavior is read-only in this version.",scope:"System",defaultBindings:[{key:"Escape"}],configurable:!1,disableable:!1}],HLt=new Set(wk.filter(e=>e.configurable).map(e=>e.actionId)),XLt=new Set(["Alt","Control","Meta","Shift"]),Hve=new Set(["meta+n","meta+shift+o"]);function TM(){var n,r,s;if(typeof navigator>"u")return"nonMac";const e=navigator,t=((r=(n=e.userAgentData)==null?void 0:n.platform)==null?void 0:r.trim())||((s=e.platform)==null?void 0:s.trim())||"";return/mac|iphone|ipad|ipod/i.test(t)?"mac":"nonMac"}function lBe(e,t=TM()){var n;return(((n=e.defaultBindingsByPlatform)==null?void 0:n[t])??e.defaultBindings).map(S6)}function cBe(e){return e.length===1?e.toLowerCase():e}function S6(e){return{key:cBe(e.key.trim()),...e.code?{code:e.code.trim()}:{},...e.metaKey?{metaKey:!0}:{},...e.ctrlKey?{ctrlKey:!0}:{},...e.altKey?{altKey:!0}:{},...e.shiftKey?{shiftKey:!0}:{}}}function $re(e){const t=S6(e);return[t.metaKey?"meta":"",t.ctrlKey?"ctrl":"",t.altKey?"alt":"",t.shiftKey?"shift":"",t.key].filter(Boolean).join("+")}function dBe(e){if(!(e instanceof HTMLElement)||GLt(e))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||!!e.closest('[contenteditable="true"], [contenteditable="plaintext-only"]')}function GLt(e){let t=e;for(;t;){if(t.hidden||t.getAttribute("aria-hidden")==="true")return!0;const n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden"||n.visibility==="collapse")return!0;t=t.parentElement}return!1}function YLt(e){return XLt.has(e.key)?null:S6({key:e.key,code:e.code||void 0,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey})}function JLt(e,t){const n=S6(t);return(n.code&&e.code?e.code===n.code:cBe(e.key)===n.key)&&e.metaKey===!!n.metaKey&&e.ctrlKey===!!n.ctrlKey&&e.altKey===!!n.altKey&&e.shiftKey===!!n.shiftKey}function dfe(e,t=TM()){const n={};for(const r of wk)HLt.has(r.actionId)&&(n[r.actionId]=lBe(r,t));for(const r of(e==null?void 0:e.shortcuts)??[]){const s=wk.find(a=>a.actionId===r.actionId);if(s!=null&&s.configurable){if(r.disabled===!0){n[r.actionId]=[];continue}if(r.bindings&&r.bindings.length>0){const a=r.bindings.map(S6);if(ezt(r.actionId,a))continue;n[r.actionId]=a}}}return n}function ezt(e,t){return e!=="chat.create"||t.length!==Hve.size?!1:t.every(n=>Hve.has($re(n)))}function b7(e,t,n,r){return n===void 0?!1:(dfe(n,r)[t]??[]).some(a=>JLt(e,a))}function Xve(e,t=TM()){const n=S6(e),r=[];return n.ctrlKey&&r.push(t==="mac"?"⌃":"Ctrl"),n.altKey&&r.push(t==="mac"?"⌥":"Alt"),n.shiftKey&&r.push(t==="mac"?"⇧":"Shift"),n.metaKey&&r.push(t==="mac"?"⌘":"Meta"),r.push(tzt(n.key)),t==="mac"?r.join(""):r.join("+")}function tzt(e){return e===" "?"Space":e==="Escape"?"Esc":e.length===1?e.toUpperCase():e}function nzt(e){const t=S6(e),n=t.key.toLowerCase();return t.metaKey||t.ctrlKey?["l","r","w","q"].includes(n):!1}function rzt(e,t,n,r){const s=$re(t),a=dfe(n,r);for(const[o,l]of Object.entries(a))if(o!==e&&l.some(c=>$re(c)===s))return o;return null}function bR(e,t,n){const r=e.shortcuts.filter(s=>s.actionId!==t);return n&&r.push({actionId:t,...n}),{shortcuts:r}}const ufe=m.createContext(null),hN="global",eP=8;function k5(e){return(e==null?void 0:e.trim())||hN}function a1(){return{activeKey:null,hasPanelState:!1,open:!1,tabs:[]}}function qX(e){return!!(e&&(e.hasPanelState||e.tabs.length>0||e.activeKey!==null))}function Gve(e){return e instanceof Element&&!!e.closest("[data-testid='messenger-main-workbench'],[data-testid='live-surface-runtime-host'][data-owner-id^='main:']")}function szt(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`view-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function KX(e,t,n){if(!_f(t))return t;if(t.kind==="browser")return{...t,viewInstanceId:t.viewInstanceId??t.tabId};if(!n&&t.viewInstanceId)return t;if(!n){const r=Rre(t),s=e.find(a=>_f(a)&&Rre(a)===r);if(s&&s.kind!=="browser"&&"viewInstanceId"in s&&s.viewInstanceId)return{...t,viewInstanceId:s.viewInstanceId}}return{...t,viewInstanceId:szt()}}function Yve(e,t){return{...e,tabId:t.tabId,viewInstanceId:t.viewInstanceId??t.tabId,savedViewRecovery:t.savedViewRecovery??e.savedViewRecovery}}function WX(e,t,n,r=!0){const s=gs(n),a=n.kind==="browser"&&n.dedupeKey?e.find(d=>d.kind==="browser"&&d.dedupeKey===n.dedupeKey):void 0;if(n.kind==="browser"&&(a==null?void 0:a.kind)==="browser"){const d=gs(a),u=Yve(n,a);return{activeKey:d,tabs:e.map(f=>gs(f)===d?u:f),openResult:{admitted:!0}}}const o=e.find(d=>gs(d)===s);if(o){const d=n.kind==="browser"&&o.kind==="browser"?Yve(n,o):n;return{activeKey:s,tabs:e.map(u=>gs(u)===s?d:u),openResult:{admitted:!0}}}const l=[...e,n];if(n.kind!=="browser")return{activeKey:s,tabs:l,openResult:{admitted:!0}};const c=e.filter(d=>d.kind==="browser").length;return r&&c<eP?{activeKey:s,tabs:l,openResult:{admitted:!0}}:{activeKey:t,tabs:e,openResult:{admitted:!1,reason:"browser_capacity"}}}function Fre(e){var t;return((t=e.viewInstanceId)==null?void 0:t.trim())||e.tabId.trim()}function ZX(e){const t=new Set;for(const n of Object.values(e))for(const r of n.tabs)r.kind==="browser"&&t.add(Fre(r));return t}function izt(e,t,n){const r=e.activeKey?e.tabs.findIndex(l=>gs(l)===e.activeKey):-1,s=e.tabs.filter(l=>l.kind!=="browser"||(n==null?void 0:n(t,l))==="preserve");if(s.length===e.tabs.length)return e;const a=e.activeKey!==null&&s.some(l=>gs(l)===e.activeKey),o=s[Math.min(Math.max(r,0),s.length-1)]??s.at(-1)??null;return{...e,activeKey:e.activeKey===null?null:a?e.activeKey:o?gs(o):null,tabs:s}}function azt({children:e}){const t=m.useRef({[hN]:a1()}),n=m.useRef({[hN]:{}}),r=m.useRef(hN),[s,a]=m.useState(hN),[o,l]=m.useState(()=>a1()),[c,d]=m.useState(null),[u,f]=m.useState(!1),A=m.useRef(null),h=m.useRef(null),g=m.useCallback(($,ee)=>{const re=t.current[$]??a1(),ne=ee(re);if(ne!==re){const te=new Map(re.tabs.map(he=>[gs(he),he])),ce=n.current[$]??{},se={...ce};for(const he of ne.tabs){const we=gs(he),Ue=te.get(we),je=ce[we]??0;se[we]=Ue?Ue!==he?je+1:je:Object.hasOwn(ce,we)?je+1:0}n.current={...n.current,[$]:se}}return t.current={...t.current,[$]:ne},$===r.current&&l(ne),ne},[]),x=m.useCallback($=>{const ee=k5($);if(r.current===ee)return;const re=t.current[ee]??a1();r.current=ee,l(re),f(qX(re)&&re.open),a(ne=>ne===ee?ne:ee)},[]),y=m.useCallback(($,ee)=>{let re={admitted:!0};return g(s,ne=>{const te=ZX(t.current),ce=$.kind!=="browser"||te.has(Fre($))||(ee==null?void 0:ee.allowNewBrowserGuest)!==!1&&te.size<eP,se=WX(ne.tabs,ne.activeKey,KX(ne.tabs,$,!1),ce);return re=se.openResult,{activeKey:se.activeKey,hasPanelState:!0,open:!0,tabs:se.tabs}}),f(!0),re},[s,g]),v=m.useCallback(($,ee)=>{let re={admitted:!0};return g(s,ne=>{const te=ZX(t.current),ce=$.kind!=="browser"||(ee==null?void 0:ee.allowNewBrowserGuest)!==!1&&te.size<eP,se=WX(ne.tabs,ne.activeKey,KX(ne.tabs,$,!0),ce);return re=se.openResult,{activeKey:se.activeKey,hasPanelState:!0,open:!0,tabs:se.tabs}}),f(!0),re},[s,g]),w=m.useCallback(($,ee,re)=>{const ne=k5($);let te={admitted:!0};const ce=g(ne,se=>{const he=ZX(t.current),we=ee.kind!=="browser"||he.has(Fre(ee))||(re==null?void 0:re.allowNewBrowserGuest)!==!1&&he.size<eP,Ue=WX(se.tabs,se.activeKey,KX(se.tabs,ee,!1),we);return te=Ue.openResult,{activeKey:Ue.activeKey,hasPanelState:!0,open:!0,tabs:Ue.tabs}});return ne===r.current&&(l(ce),f(!0)),te},[g]),k=m.useCallback(()=>{g(s,$=>({...$,hasPanelState:!0,open:!0})),f(!0)},[s,g]),O=m.useCallback($=>{const ee=k5($),ne={...t.current[ee]??a1(),hasPanelState:!0,open:!0};t.current={...t.current,[ee]:ne},r.current=ee,a(ee),l(ne),f(!0)},[]),j=m.useCallback(()=>{f(!0),g(s,$=>({...$,activeKey:null,hasPanelState:!0,open:!0}))},[s,g]),C=m.useCallback(()=>{d(null),g(s,$=>qX($)?{...$,open:!1}:$),f(!1)},[s,g]),N=m.useCallback(()=>{d(null),g(s,()=>a1()),f(!1)},[s,g]),I=C,E=m.useCallback(()=>{d(null)},[]),_=m.useCallback(($,ee=r.current)=>{const re=$.trim(),ne=k5(ee);return!re||!ne.startsWith("chat:")&&!ne.startsWith("issue:")?!1:(d({organizationId:re,contextKey:ne}),!0)},[]),T=m.useCallback(($,ee)=>{var te,ce;const re=k5($);return(((te=t.current[re])==null?void 0:te.tabs)??[]).some(se=>gs(se)===ee)?((ce=n.current[re])==null?void 0:ce[ee])??0:null},[]),R=m.useCallback(($,ee,re)=>{var Ue;const ne=k5($),te=t.current[ne]??a1(),ce=te.tabs.findIndex(je=>gs(je)===ee);if(ce<0)return{detached:!1,reason:"not_found",revision:null};const se=((Ue=n.current[ne])==null?void 0:Ue[ee])??0;if(re!==se)return{detached:!1,reason:"revision_mismatch",revision:se};const he=te.tabs[ce],we=g(ne,je=>{const ke=je.tabs.filter(oe=>gs(oe)!==ee);if(ke.length===0)return{activeKey:null,hasPanelState:!0,open:!1,tabs:[]};if(je.activeKey!==ee)return{...je,tabs:ke};const Se=ke[Math.min(ce,ke.length-1)]??null;return{activeKey:Se?gs(Se):null,hasPanelState:!0,open:!0,tabs:ke}});return ne===r.current&&f(we.open),{detached:!0,revision:se,target:he}},[g]),M=m.useCallback($=>{g(s,ee=>{const re=ee.tabs.findIndex(ce=>gs(ce)===$),ne=ee.tabs.filter(ce=>gs(ce)!==$);if(ne.length===0)return f(!1),{activeKey:null,hasPanelState:!0,open:!1,tabs:[]};if(ee.activeKey!==$)return{...ee,tabs:ne};const te=ne[Math.min(Math.max(re,0),ne.length-1)]??ne.at(-1)??null;return{activeKey:te?gs(te):null,hasPanelState:!0,open:!0,tabs:ne}})},[s,g]),L=m.useCallback($=>(A.current=$,()=>{A.current===$&&(A.current=null)}),[]),U=m.useCallback($=>(h.current=$,()=>{h.current===$&&(h.current=null)}),[]),B=m.useCallback($=>{const re=(t.current[r.current]??a1()).tabs.find(te=>gs(te)===$);if(!re)return;const ne=A.current;if(ne){ne(re);return}M($)},[M]),z=u&&!!o.activeKey;m.useEffect(()=>{const $=Pn(),ee=$==null?void 0:$.setSidePanelCloseShortcutActive;if(!ee)return;let re=!1,ne=null;const te=()=>{if(re)return;const se=z&&!Gve(document.activeElement);ne!==se&&(ne=se,ee(se).catch(()=>{}))},ce=()=>queueMicrotask(te);return document.addEventListener("focusin",ce,!0),document.addEventListener("focusout",ce,!0),te(),()=>{re=!0,document.removeEventListener("focusin",ce,!0),document.removeEventListener("focusout",ce,!0)}},[z]),m.useEffect(()=>{const $=Pn(),ee=$==null?void 0:$.setSidePanelCloseShortcutActive;if(ee)return()=>{ee(!1).catch(()=>{})}},[]),m.useEffect(()=>{const $=Pn();if($!=null&&$.onBrowserReset)return $.onBrowserReset(()=>{const ee=Object.fromEntries(Object.entries(t.current).map(([ne,te])=>[ne,izt(te,ne,h.current)]));t.current=ee;const re=ee[r.current]??a1();l(re),f(qX(re)&&re.open)})},[]),m.useEffect(()=>{if(!z)return;const $=Pn();if($!=null&&$.onCloseSidePanelActiveTab)return $.onCloseSidePanelActiveTab(()=>{const ee=o.activeKey;ee&&B(ee)})},[o.activeKey,z,B]),m.useEffect(()=>{const $=Pn();if($!=null&&$.onOpenEmptySidePanel)return $.onOpenEmptySidePanel(j)},[j]),m.useEffect(()=>{if(!u||!o.activeKey)return;const $=ee=>{Gve(ee.target)||ee.key.toLowerCase()!=="w"||(TM()==="mac"?!ee.metaKey||ee.ctrlKey:!ee.ctrlKey||ee.metaKey)||ee.altKey||ee.shiftKey||(ee.preventDefault(),ee.stopPropagation(),B(o.activeKey))};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)},[o.activeKey,u,B]);const H=m.useCallback(($,ee,re)=>{const ne=k5($);if(!(t.current[ne]??a1()).tabs.some(se=>gs(se)===ee))return!1;const ce=gs(re);return g(ne,se=>({...se,activeKey:se.activeKey===ee?ce:se.activeKey,tabs:se.tabs.map(he=>gs(he)===ee?re:he)})),!0},[g]),J=m.useCallback(($,ee)=>{H(s,$,ee)},[s,H]),F=m.useCallback(($,ee,re)=>{$!==ee&&g(s,ne=>{const te=ne.tabs.findIndex(je=>gs(je)===$),ce=ne.tabs.findIndex(je=>gs(je)===ee);if(te<0||ce<0)return ne;const se=[...ne.tabs],[he]=se.splice(te,1);if(!he)return ne;const Ue=se.findIndex(je=>gs(je)===ee)+(re==="after"?1:0);return se.splice(Ue,0,he),{...ne,tabs:se}})},[s,g]),Q=m.useCallback($=>{g(s,ee=>({...ee,activeKey:$,hasPanelState:!0,open:!0}))},[s,g]),W=m.useMemo(()=>({activeKey:o.activeKey,clearCurrentContext:N,clearDisplayedContextHold:E,closePanel:I,closeTarget:M,contextKey:s,detachTargetForContext:R,displayedContextHold:c,getTargetRevisionForContext:T,hidePanel:C,holdDisplayedContext:_,open:u,openEmpty:j,openTarget:y,openTargetInNewTab:v,openTargetForContext:w,registerCloseRequestHandler:L,registerBrowserResetHandler:U,replaceTarget:J,replaceTargetForContext:H,reorderTarget:F,setActiveKey:Q,setContextKey:x,showPanel:k,showPanelForContext:O,tabs:o.tabs}),[N,E,I,M,s,o.activeKey,o.tabs,R,c,T,C,_,u,j,y,w,v,U,L,F,J,H,Q,x,k,O]);return i.jsx(ufe.Provider,{value:W,children:e})}function R3(){const e=m.useContext(ufe);if(!e)throw new Error("useSidePanel must be used inside SidePanelProvider");return e}function ozt(){return m.useContext(ufe)}function lzt(e){try{const t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}async function czt(e){var r;const{request:t}=e;if(!lzt(t.url))return"ignored";let n;try{n=await e.getSettings()}catch{return await e.forceOpenExternal(t.url),"default_browser"}return n.openLinksIn==="built_in"||t.source==="browser_popup"?(e.openBuiltIn(E4(t.url,{favicon:(r=e.resolveFavicon)==null?void 0:r.call(e,t.url),newTab:t.source==="browser_popup"})),"built_in"):(await e.forceOpenExternal(t.url),"default_browser")}const Cv=8;function dzt(){return{activeViewInstanceId:null,tabOrder:[],tabsByViewInstanceId:{},runtimesById:{},promotionsById:{}}}function uzt(){return{organizations:{}}}function nw(e){return e.kind==="side"||e.kind==="transferring"||e.kind==="main"||e.kind==="parked"}function fzt(e,t){const n=e.organizations[t];return n?Object.values(n.runtimesById).filter(r=>r.targetKind==="browser"&&nw(r.host)).length:0}function Azt(e){return Object.values(e.runtimesById).filter(t=>t.targetKind==="browser"&&nw(t.host)).length}function hzt(e,t){return e.kind!==t.kind?!1:e.kind==="side"&&t.kind==="side"?e.contextKey===t.contextKey:e.kind==="main"&&t.kind==="main"?e.organizationId===t.organizationId:!0}function mzt(e){return{...e}}function uBe(e,t,n){if(!n.id||!n.viewInstanceId||n.target.viewInstanceId!==n.viewInstanceId||n.target.kind!==n.targetKind||n.host.kind==="main"&&n.host.organizationId!==t)return!1;const r=e.runtimesById[n.id];return r&&(r.viewInstanceId!==n.viewInstanceId||r.targetKind!==n.targetKind)||n.targetKind==="browser"&&nw(n.host)&&!((r==null?void 0:r.targetKind)==="browser"&&nw(r.host))&&Azt(e)>=Cv?!1:!(nw(n.host)&&Object.values(e.runtimesById).some(o=>o.id!==n.id&&o.viewInstanceId===n.viewInstanceId&&nw(o.host)))}function xg(e,t,n){if(!uBe(e,t,n))return e;const r=e.runtimesById[n.id];return r&&hzt(r.host,n.host)?e:{...e,runtimesById:{...e.runtimesById,[n.id]:{...n,organizationId:t,target:(r==null?void 0:r.target)??O6(n.target),host:mzt(n.host)}}}}function O6(e){return e.kind!=="browser"||!e.savedViewRecovery?{...e}:{...e,savedViewRecovery:{...e.savedViewRecovery,persistedMetadata:{...e.savedViewRecovery.persistedMetadata,target:{...e.savedViewRecovery.persistedMetadata.target}}}}}function fBe(e){return!!(e.viewInstanceId&&e.runtimeId&&e.originContextKey&&e.target.viewInstanceId===e.viewInstanceId)}function ffe(e,t){return Object.values(e.tabsByViewInstanceId).find(n=>n.savedViewId===t)??null}function Bre(e,t,n,r){if(!fBe(n)||r!==null&&!r)return{organization:e,outcome:"rejected"};const s=r?ffe(e,r):null;if(s&&s.viewInstanceId!==n.viewInstanceId)return e.activeViewInstanceId===s.viewInstanceId?{organization:e,outcome:"focused_existing_binding"}:{organization:{...e,activeViewInstanceId:s.viewInstanceId},outcome:"focused_existing_binding"};const a=e.tabsByViewInstanceId[n.viewInstanceId];if(a){const c=r!==null&&a.savedViewId!==null&&a.savedViewId!==r,d=r===null||a.savedViewId===r,u=e.activeViewInstanceId===n.viewInstanceId;return d&&u?{organization:e,outcome:"already_satisfied"}:{organization:{...e,activeViewInstanceId:n.viewInstanceId,tabsByViewInstanceId:r===null||d||c?e.tabsByViewInstanceId:{...e.tabsByViewInstanceId,[n.viewInstanceId]:{...a,savedViewId:r}}},outcome:c?"binding_conflict":"already_satisfied"}}const o={id:n.runtimeId,viewInstanceId:n.viewInstanceId,targetKind:n.target.kind,target:n.target,host:{kind:"main",organizationId:t}};if(!uBe(e,t,o))return{organization:e,outcome:"rejected"};const l=xg(e,t,o);return{organization:{...l,activeViewInstanceId:n.viewInstanceId,tabOrder:[...l.tabOrder,n.viewInstanceId],tabsByViewInstanceId:{...l.tabsByViewInstanceId,[n.viewInstanceId]:{organizationId:t,viewInstanceId:n.viewInstanceId,savedViewId:r,target:O6(n.target),originContextKey:n.originContextKey,runtimeId:n.runtimeId}}},outcome:"opened"}}function ll(e,t,n){if(!t)return e;const r=e.organizations[t]??dzt(),s=n(r);return s===r?e:{...e,organizations:{...e.organizations,[t]:s}}}function pzt(e,t,n){const r=e.tabsByViewInstanceId[t];return!r||!n||r.savedViewId===n||r.savedViewId!==null||ffe(e,n)?e:{...e,tabsByViewInstanceId:{...e.tabsByViewInstanceId,[t]:{...r,savedViewId:n}}}}function gzt(e,t,n){const r=e.tabsByViewInstanceId[t];return!r||r.savedViewId!==n?e:{...e,tabsByViewInstanceId:{...e.tabsByViewInstanceId,[t]:{...r,savedViewId:null}}}}function xzt(e,t,n){var u;const r=e.tabsByViewInstanceId[n];if(!r)return e;const s=e.tabOrder.indexOf(n),a=e.tabOrder.filter(f=>f!==n),{[n]:o,...l}=e.tabsByViewInstanceId,c=xg(e,t,{id:r.runtimeId,viewInstanceId:r.viewInstanceId,targetKind:r.target.kind,target:((u=e.runtimesById[r.runtimeId])==null?void 0:u.target)??r.target,host:{kind:"disposed"}}),d=e.activeViewInstanceId===n?a[Math.min(Math.max(s,0),a.length-1)]??null:e.activeViewInstanceId;return{...c,activeViewInstanceId:d,tabOrder:a,tabsByViewInstanceId:l}}function bzt(e,t,n){const r=e.tabOrder.indexOf(t);if(r<0||!Number.isFinite(n))return e;const s=Math.max(0,Math.min(Math.trunc(n),e.tabOrder.length-1));if(r===s)return e;const a=[...e.tabOrder];return a.splice(r,1),a.splice(s,0,t),{...e,tabOrder:a}}function yzt(e){return{...e,target:O6(e.target)}}function Jq(e){return Number.isInteger(e)&&e>=0}function vzt(e){return e.status==="pending"||e.status==="reconciling"||e.status==="claiming"||e.status==="detaching"}function wzt(e,t,n,r,s){if(!n||!s||!fBe(r)||!Jq(r.sourceRevision)||e.promotionsById[n]||Object.values(e.promotionsById).some(l=>vzt(l)&&l.source.runtimeId===r.runtimeId))return e;const a=e.runtimesById[r.runtimeId];if(!a||a.viewInstanceId!==r.viewInstanceId||a.targetKind!==r.target.kind||a.host.kind!=="side"||a.host.contextKey!==r.originContextKey)return e;const o=xg(e,t,{id:a.id,viewInstanceId:a.viewInstanceId,targetKind:a.targetKind,target:a.target,host:{kind:"transferring"}});return{...o,promotionsById:{...o.promotionsById,[n]:{id:n,organizationId:t,clientMutationId:s,status:"pending",source:yzt(r)}}}}function d9(e,t,n){const r=e.runtimesById[n.runtimeId];return r?xg(e,t,{id:r.id,viewInstanceId:r.viewInstanceId,targetKind:r.targetKind,target:r.target,host:{kind:"side",contextKey:n.originContextKey}}):e}function _M(e,t,n){const r=e.promotionsById[t];if(!r||r.status!=="pending"&&r.status!=="reconciling"&&r.status!=="claiming"||r.source.sourceRevision!==n)return null;const s=e.runtimesById[r.source.runtimeId];return!s||s.viewInstanceId!==r.source.viewInstanceId||s.targetKind!==r.source.target.kind||s.host.kind!=="transferring"?null:r}function kzt(e,t,n,r,s){const a=e.promotionsById[n];if(!a||a.status!=="server_failed"&&a.status!=="commit_unknown"||a.source.sourceRevision!==r||!Jq(s)||s<=r)return e;const o=e.runtimesById[a.source.runtimeId];if(!o||o.host.kind!=="side"||o.host.contextKey!==a.source.originContextKey)return e;const l=xg(e,t,{id:o.id,viewInstanceId:o.viewInstanceId,targetKind:o.targetKind,target:o.target,host:{kind:"transferring"}});return{...l,promotionsById:{...l.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,status:"pending",source:{...a.source,sourceRevision:s}}}}}function Szt(e,t,n,r,s){const a=e.promotionsById[n];if(!a||a.status!=="commit_unknown"||a.source.sourceRevision!==r||!Jq(s)||s<=r)return e;const o=e.runtimesById[a.source.runtimeId];if(!o||o.host.kind!=="side"||o.host.contextKey!==a.source.originContextKey)return e;const l=xg(e,t,{id:o.id,viewInstanceId:o.viewInstanceId,targetKind:o.targetKind,target:o.target,host:{kind:"transferring"}});return{...l,promotionsById:{...l.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,status:"reconciling",source:{...a.source,sourceRevision:s}}}}}function Ozt(e,t,n,r,s){const a=e.promotionsById[n];if(!a||a.status!=="claim_failed"||a.source.sourceRevision!==r||!Jq(s)||s<=r)return e;const o=e.runtimesById[a.source.runtimeId];if(!o||o.host.kind!=="side"||o.host.contextKey!==a.source.originContextKey)return e;const l=xg(e,t,{id:o.id,viewInstanceId:o.viewInstanceId,targetKind:o.targetKind,target:o.target,host:{kind:"transferring"}});return{...l,promotionsById:{...l.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,status:"claiming",savedViewId:a.savedViewId,source:{...a.source,sourceRevision:s}}}}}function jzt(e,t,n,r,s){const a=_M(e,n,s);return!a||a.status==="claiming"||!r?e:{...e,promotionsById:{...e.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,source:a.source,status:"claiming",savedViewId:r}}}}function Czt(e,t,n,r,s){const a=_M(e,n,r);if(!a||a.status==="claiming")return e;const o=d9(e,t,a.source);return{...o,promotionsById:{...o.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,source:a.source,status:"server_failed",error:s}}}}function Nzt(e,t,n,r,s){const a=_M(e,n,r);if(!a||a.status==="claiming")return e;const o=d9(e,t,a.source);return{...o,promotionsById:{...o.promotionsById,[n]:{id:a.id,organizationId:t,clientMutationId:a.clientMutationId,source:a.source,status:"commit_unknown",error:s}}}}function Pzt(e,t,n,r,s,a){const o=_M(e,n,s);if(!o||o.status!=="claiming"||!r||o.savedViewId!==r)return e;const l=d9(e,t,o.source);return{...l,promotionsById:{...l.promotionsById,[n]:{id:o.id,organizationId:t,clientMutationId:o.clientMutationId,source:o.source,status:"claim_failed",savedViewId:r,error:a}}}}function fB(e,t){const{[t]:n,...r}=e.promotionsById;return{...e,promotionsById:r}}function Izt(e,t,n){const r=e.promotionsById[t];return!r||r.status!=="server_failed"&&r.status!=="commit_unknown"&&r.status!=="claim_failed"||r.source.sourceRevision!==n?e:fB(e,t)}function Tzt(e,t,n,r,s){const a=e.promotionsById[n];if(!a||a.source.sourceRevision!==s||a.source.savedViewId!==r&&(!("savedViewId"in a)||a.savedViewId!==r))return e;if(a.status==="detaching"){const o=mBe(e,t,n,r,s,"saved_view_removed");return fB(o,n)}return fB(d9(e,t,a.source),n)}function fC(e,t,n,r,s){const a=d9(e,t,n.source);return{...a,promotionsById:{...a.promotionsById,[n.id]:{id:n.id,organizationId:t,clientMutationId:n.clientMutationId,source:n.source,status:"claim_failed",savedViewId:r,error:s}}}}function ABe(e){return{...e,target:O6(e.target)}}function Jve(e,t,n,r){return{...e,promotionsById:{...e.promotionsById,[n.id]:{...n,organizationId:t,status:"detaching",rollback:r}}}}function _zt(e,t,n,r,s){var u;const a=_M(e,n,s);if(!a||a.status!=="claiming"||!r||a.savedViewId!==r)return e;const o={activeViewInstanceId:e.activeViewInstanceId,tab:e.tabsByViewInstanceId[a.source.viewInstanceId]?ABe(e.tabsByViewInstanceId[a.source.viewInstanceId]):null},l=e.tabsByViewInstanceId[a.source.viewInstanceId],c=ffe(e,r);if(c&&c.viewInstanceId!==a.source.viewInstanceId){const f=e.activeViewInstanceId===c.viewInstanceId?e:{...e,activeViewInstanceId:c.viewInstanceId};return fC(f,t,a,r,"saved_view_already_bound")}if(l!=null&&l.savedViewId&&l.savedViewId!==r){const f=e.activeViewInstanceId===l.viewInstanceId?e:{...e,activeViewInstanceId:l.viewInstanceId};return fC(f,t,a,r,"saved_view_binding_conflict")}if(l){let f=e,A=l.runtimeId;if(l.runtimeId===a.source.runtimeId){const h=f.runtimesById[a.source.runtimeId];f=xg(f,t,{id:h.id,viewInstanceId:h.viewInstanceId,targetKind:h.targetKind,target:h.target,host:{kind:"main",organizationId:t}})}else{const h=f.runtimesById[l.runtimeId];if(!h||h.viewInstanceId!==l.viewInstanceId||h.targetKind!==l.target.kind||nw(h.host))return fC(e,t,a,r,"existing_tab_runtime_unavailable");const g=f.runtimesById[a.source.runtimeId];if(f=xg(f,t,{id:g.id,viewInstanceId:g.viewInstanceId,targetKind:g.targetKind,target:g.target,host:{kind:"main",organizationId:t}}),((u=f.runtimesById[g.id])==null?void 0:u.host.kind)!=="main")return fC(e,t,a,r,"existing_tab_runtime_unavailable");A=g.id}return f={...f,activeViewInstanceId:l.viewInstanceId,tabsByViewInstanceId:l.savedViewId===r&&l.runtimeId===A?f.tabsByViewInstanceId:{...f.tabsByViewInstanceId,[l.viewInstanceId]:{...l,savedViewId:r,runtimeId:A,target:O6(a.source.target),originContextKey:a.source.originContextKey}}},Jve(f,t,a,o)}const d=Bre(e,t,{viewInstanceId:a.source.viewInstanceId,runtimeId:a.source.runtimeId,target:a.source.target,originContextKey:a.source.originContextKey},r);return d.outcome!=="opened"?fC(d.organization,t,a,r,d.outcome==="binding_conflict"?"saved_view_binding_conflict":"main_host_claim_rejected"):Jve(d.organization,t,a,o)}function hBe(e,t,n,r){const s=e.promotionsById[t];if(!s||s.status!=="detaching"||s.savedViewId!==n||s.source.sourceRevision!==r)return null;const a=e.runtimesById[s.source.runtimeId],o=e.tabsByViewInstanceId[s.source.viewInstanceId];return!a||a.viewInstanceId!==s.source.viewInstanceId||a.host.kind!=="main"||a.host.organizationId!==s.organizationId||!o||o.runtimeId!==a.id||o.savedViewId!==n?null:s}function Mzt(e,t,n,r){const s=hBe(e,t,n,r);return s?fB(e,s.id):e}function mBe(e,t,n,r,s,a){const o=hBe(e,n,r,s);if(!o)return e;const l=d9(e,t,o.source),c={...l.tabsByViewInstanceId};let d=l.tabOrder;return o.rollback.tab?c[o.source.viewInstanceId]=ABe(o.rollback.tab):(delete c[o.source.viewInstanceId],d=d.filter(u=>u!==o.source.viewInstanceId)),{...l,activeViewInstanceId:o.rollback.activeViewInstanceId,tabOrder:d,tabsByViewInstanceId:c,promotionsById:{...l.promotionsById,[n]:{id:o.id,organizationId:t,clientMutationId:o.clientMutationId,source:o.source,status:"claim_failed",savedViewId:r,error:a}}}}function Ezt(e,t,n,r){const s=e.runtimesById[t];return!s||s.viewInstanceId!==n||r.viewInstanceId!==n||s.targetKind!==r.kind?e:{...e,runtimesById:{...e.runtimesById,[t]:{...s,target:O6(r)}}}}function Dzt(e,t,n,r){const s=e.tabsByViewInstanceId[n],a=e.runtimesById[t];return!s||s.runtimeId!==t||s.target.kind!==r.kind||r.viewInstanceId!==n||!a||a.viewInstanceId!==n||a.targetKind!==r.kind?e:{...e,tabsByViewInstanceId:{...e.tabsByViewInstanceId,[n]:{...s,target:O6(r)}}}}function Rzt(e,t){switch(t.type){case"saved-tab/open":return ll(e,t.organizationId,n=>Bre(n,t.organizationId,t.tab,t.savedViewId).organization);case"session-tab/create":return ll(e,t.organizationId,n=>Bre(n,t.organizationId,t.tab,null).organization);case"tab/focus":return ll(e,t.organizationId,n=>n.activeViewInstanceId===t.viewInstanceId||!n.tabsByViewInstanceId[t.viewInstanceId]?n:{...n,activeViewInstanceId:t.viewInstanceId});case"tab/reorder":return ll(e,t.organizationId,n=>bzt(n,t.viewInstanceId,t.toIndex));case"tab/bind-saved-view":return ll(e,t.organizationId,n=>pzt(n,t.viewInstanceId,t.savedViewId));case"tab/unbind-saved-view":return ll(e,t.organizationId,n=>gzt(n,t.viewInstanceId,t.savedViewId));case"tab/close":return ll(e,t.organizationId,n=>xzt(n,t.organizationId,t.viewInstanceId));case"tab/update-target":return ll(e,t.organizationId,n=>Dzt(n,t.runtimeId,t.viewInstanceId,t.target));case"runtime/admit":return ll(e,t.organizationId,n=>xg(n,t.organizationId,t.runtime));case"runtime/set-host":return ll(e,t.organizationId,n=>{const r=n.runtimesById[t.runtimeId];return r?xg(n,t.organizationId,{id:r.id,viewInstanceId:r.viewInstanceId,targetKind:r.targetKind,target:r.target,host:t.host}):n});case"runtime/update-target":return ll(e,t.organizationId,n=>Ezt(n,t.runtimeId,t.viewInstanceId,t.target));case"promotion/start":return ll(e,t.organizationId,n=>wzt(n,t.organizationId,t.promotionId,t.source,t.clientMutationId));case"promotion/server-commit":return ll(e,t.organizationId,n=>jzt(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision));case"promotion/claim":return ll(e,t.organizationId,n=>_zt(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision));case"promotion/detach-succeed":return ll(e,t.organizationId,n=>Mzt(n,t.promotionId,t.savedViewId,t.expectedSourceRevision));case"promotion/detach-fail":return ll(e,t.organizationId,n=>mBe(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision,t.error));case"promotion/server-fail":return ll(e,t.organizationId,n=>Czt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.error));case"promotion/timeout":return ll(e,t.organizationId,n=>Nzt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.error));case"promotion/retry":return ll(e,t.organizationId,n=>kzt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.nextSourceRevision));case"promotion/reconcile":return ll(e,t.organizationId,n=>Szt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.nextSourceRevision));case"promotion/claim-fail":return ll(e,t.organizationId,n=>Pzt(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision,t.error));case"promotion/claim-retry":return ll(e,t.organizationId,n=>Ozt(n,t.organizationId,t.promotionId,t.expectedSourceRevision,t.nextSourceRevision));case"promotion/discard":return ll(e,t.organizationId,n=>Izt(n,t.promotionId,t.expectedSourceRevision));case"promotion/cancel-saved-view":return ll(e,t.organizationId,n=>Tzt(n,t.organizationId,t.promotionId,t.savedViewId,t.expectedSourceRevision))}}function pBe(){var n,r;const e=(n=document.activeElement)==null?void 0:n.closest("[data-runtime-id]");if(!e||e.hidden||e.hasAttribute("inert")||e.getAttribute("aria-hidden")==="true")return null;const t=e.dataset.runtimeId;return t?{runtimeId:t,owner:(r=e.dataset.ownerId)!=null&&r.startsWith("main:")?"main_workbench":"side_panel"}:null}function Lzt(){var e;return((e=pBe())==null?void 0:e.runtimeId)??null}function zzt(){const e=Wn(),t=cfe(),n=ALe(),{openTarget:r}=R3(),s=l9();return m.useEffect(()=>{const a=Pn();if(a!=null&&a.onOpenWebLink)return a.onOpenWebLink(o=>{czt({request:o,getSettings:()=>e.fetchQuery({queryKey:V.instance.browserSettings,queryFn:()=>fo.getBrowser(),staleTime:0}),openBuiltIn:l=>{var f;if(o.sourceWebContentsId){((t==null?void 0:t.openTargetForGuest(o.sourceWebContentsId,l))??!1)||console.warn("[rudder-ui] ignored Browser popup without a live guest owner",o.sourceWebContentsId);return}const c=((f=n==null?void 0:n.selectedOrganizationId)==null?void 0:f.trim())??"",d=!t||!c||t.getLiveBrowserCount(c)<Cv;r(l,{allowNewBrowserGuest:d}).admitted||s==null||s.pushToast({title:"Browser tab limit reached",body:`Close a Browser tab to open another. Side Panel and Main share ${Cv} live tabs.`,tone:"error"})},forceOpenExternal:l=>{var c;return((c=a.forceOpenExternal)==null?void 0:c.call(a,l))??a.openExternal(l)},resolveFavicon:eLt}).catch(l=>{console.warn("[rudder-ui] failed to route Desktop web link",l)})})},[t,r,n==null?void 0:n.selectedOrganizationId,e,s]),m.useEffect(()=>{const a=Pn();if(a!=null&&a.onBrowserShortcut)return a.onBrowserShortcut(o=>{if(!t)return;const l=o.sourceWebContentsId?null:Lzt();if(o.action==="close_tab"){o.sourceWebContentsId?t.closeTargetForGuest(o.sourceWebContentsId):l&&t.closeTargetForRuntime(l);return}o.sourceWebContentsId?t.dispatchBrowserShortcutForGuest(o.sourceWebContentsId,o.action):l&&t.dispatchBrowserShortcutForRuntime(l,o.action)})},[t]),m.useEffect(()=>{var f;const a=(f=Pn())==null?void 0:f.setBrowserSurfaceShortcutActive;if(!a||!t)return;let o=!1,l=!1,c;const d=()=>{var y;if(o)return;const A=pBe(),h=(A==null?void 0:A.runtimeId)??null,g=h?((y=t.getRuntimeTarget(h))==null?void 0:y.kind)==="browser":!1,x=A==null?void 0:A.owner;l===g&&x===c||(l=g,c=x,a(g,x).catch(()=>{}))},u=()=>queueMicrotask(d);return document.addEventListener("focusin",u,!0),document.addEventListener("focusout",u,!0),d(),()=>{o=!0,document.removeEventListener("focusin",u,!0),document.removeEventListener("focusout",u,!0),a(!1).catch(()=>{})}},[t]),null}const CI="https://docs.rudderhq.dev",gBe="https://discord.gg/ZcfWwPVkUz";function xBe({alt:e="",className:t,...n}){return i.jsx("img",{src:"/rudder-logo.png",alt:e,"aria-hidden":e?void 0:!0,className:q("inline-block shrink-0 rounded-full bg-white object-cover ring-1 ring-black/5 dark:ring-white/10",t),...n})}function $zt(){const[e,t]=m.useState(null),n=m.useRef(null);m.useEffect(()=>{const a=Pn();if(!(a!=null&&a.getReleaseNotes))return;let o=!1;return a.getReleaseNotes().then(l=>{o||l.status!=="available"||(n.current=l.notes,t(l.notes))}).catch(()=>{}),()=>{o=!0}},[]);async function r(){var o,l;const a=n.current;n.current=null,t(null),a&&await((l=(o=Pn())==null?void 0:o.markReleaseNotesShown)==null?void 0:l.call(o,a.version).catch(()=>{}))}async function s(){const a=Pn();if(a){await a.openExternal(CI).catch(()=>{});return}window.open(CI,"_blank","noopener,noreferrer")}return i.jsx(ws,{open:e!==null,onOpenChange:a=>{a||r()},children:i.jsxs(Ps,{className:"gap-0 overflow-hidden p-0 sm:max-w-[36rem]",showCloseButton:!1,children:[i.jsxs("div",{className:"flex items-start gap-3 border-b border-border/70 px-5 pb-4 pt-5",children:[i.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-[var(--radius-md)] border border-border bg-background shadow-sm",children:i.jsx(xBe,{alt:"Rudder",className:"h-6 w-6 ring-0"})}),i.jsxs(Ai,{className:"min-w-0 gap-1 text-left",children:[i.jsx(Js,{className:"text-base leading-6",children:(e==null?void 0:e.title)??"What's new in Rudder"}),i.jsx(wi,{className:"text-sm leading-5",children:"Updates installed with this version."})]})]}),i.jsx("div",{className:"max-h-[min(62vh,34rem)] overflow-y-auto px-5 py-4",children:i.jsx("div",{className:"space-y-4",children:e==null?void 0:e.sections.map(a=>i.jsxs("section",{className:"space-y-2",children:[i.jsx("h2",{className:"text-sm font-semibold text-foreground",children:a.title}),i.jsx("ul",{className:"space-y-1.5 text-sm leading-5 text-muted-foreground",children:a.items.map(o=>i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"mt-2 h-1 w-1 shrink-0 rounded-full bg-muted-foreground/70"}),i.jsx("span",{children:o})]},o))})]},a.title))})}),i.jsxs(aa,{className:"border-t border-border/70 px-5 py-4 sm:justify-between",children:[i.jsxs(ie,{type:"button",variant:"outline",onClick:()=>void s(),children:[i.jsx(La,{className:"h-4 w-4"}),"Docs"]}),i.jsx(ie,{type:"button",onClick:()=>void r(),children:"Continue"})]})]})})}function Fzt(e){const[t="",...n]=e.split(/\n{2,}/);return{body:t.trim(),runDetail:n.join(`
|
|
1682
1682
|
|
|
1683
1683
|
`).trim()}}function Bzt(){const[e,t]=m.useState(null),[n,r]=m.useState(!1),s=m.useRef(null);m.useEffect(()=>{var d;const c=Pn();if(c!=null&&c.onDeferredUpdatePrompt)return(d=c.setDeferredUpdatePromptReady)==null||d.call(c,!0),c.onDeferredUpdatePrompt(u=>{s.current=u,t(u),r(!1)})},[]),m.useEffect(()=>()=>{var c,d;(d=(c=Pn())==null?void 0:c.setDeferredUpdatePromptReady)==null||d.call(c,!1)},[]);async function a(c){var f;const d=s.current;if(!d)return;const u=Pn();s.current=null,r(!0),t(null),await((f=u==null?void 0:u.respondDeferredUpdatePrompt)==null?void 0:f.call(u,d.promptId,c).catch(()=>{})),r(!1)}const{body:o,runDetail:l}=Fzt((e==null?void 0:e.detail)??"");return i.jsx(ws,{open:e!==null,onOpenChange:c=>{c||a("cancel")},children:i.jsxs(Ps,{className:"gap-0 p-0 sm:max-w-[34rem]",showCloseButton:!1,children:[i.jsxs("div",{className:"flex items-start gap-3 px-5 pb-4 pt-5",children:[i.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-[var(--radius-md)] border border-amber-500/30 bg-amber-500/12 text-amber-600 dark:text-amber-300",children:i.jsx(zf,{className:"h-5 w-5"})}),i.jsxs(Ai,{className:"min-w-0 gap-2 text-left",children:[i.jsx(Js,{className:"text-base leading-6",children:e==null?void 0:e.message}),o?i.jsx(wi,{className:"text-sm leading-5",children:o}):null]})]}),l?i.jsx("div",{className:"mx-5 rounded-[var(--radius-md)] border border-border/70 bg-muted/35 px-3 py-2.5",children:i.jsx("p",{className:"whitespace-pre-wrap break-words text-xs font-medium leading-5 text-foreground",children:l})}):null,i.jsxs(aa,{className:"grid grid-cols-1 gap-2 px-5 pb-5 pt-4 sm:grid-cols-2 sm:justify-stretch",children:[i.jsx(ie,{type:"button",variant:"outline",className:"h-auto min-h-10 min-w-0 whitespace-normal leading-5",disabled:n,onClick:()=>void a("cancel"),children:(e==null?void 0:e.cancelLabel)??"Cancel"}),i.jsx(ie,{type:"button",variant:"outline",className:"h-auto min-h-10 min-w-0 whitespace-normal leading-5",disabled:n,onClick:()=>void a("force"),children:(e==null?void 0:e.forceLabel)??"Stop Runs and Update Now"}),i.jsx(ie,{type:"button",className:"h-auto min-h-10 min-w-0 whitespace-normal leading-5 sm:col-span-2",disabled:n,onClick:()=>void a("wait"),children:(e==null?void 0:e.confirmLabel)??"Download and Update When Idle"})]})]})})}const bBe=m.createContext(null),Qzt={progress:null,dismissProgress:()=>{}};function Uzt({children:e}){const[t,n]=m.useState(null),[r,s]=m.useState(null);m.useEffect(()=>{var d,u;const l=Pn();if(!l)return;function c(f){n(f),f.phase==="complete"&&window.setTimeout(()=>{n(A=>(A==null?void 0:A.updateId)===f.updateId&&A.phase==="complete"?null:A)},4e3)}return(d=l.getUpdateProgress)==null||d.call(l).then(f=>{f&&c(f)}).catch(()=>{}),(u=l.onUpdateProgress)==null?void 0:u.call(l,f=>{c(f),s(A=>A===f.updateId&&f.phase!=="failed"?A:null)})},[]);const a=(t==null?void 0:t.updateId)===r?null:t,o=m.useMemo(()=>({progress:a,dismissProgress:()=>{t&&s(t.updateId)}}),[t,a]);return i.jsx(bBe.Provider,{value:o,children:e})}function yBe(){return m.useContext(bBe)??Qzt}const e3e="https://github.com/Undertone0809/rudder/releases",t3e={starting:"about.updates.progress.phase.starting",resolving_release:"about.updates.progress.phase.resolving_release",downloading_checksums:"about.updates.progress.phase.downloading_checksums",downloading_asset:"about.updates.progress.phase.downloading_asset",verifying_checksum:"about.updates.progress.phase.verifying_checksum",ready_to_install:"about.updates.progress.phase.ready_to_install",waiting_for_active_runs:"about.updates.progress.phase.waiting_for_active_runs",preparing_restart:"about.updates.progress.phase.preparing_restart",closing:"about.updates.progress.phase.closing",complete:"about.updates.progress.phase.complete",failed:"about.updates.progress.phase.failed"};function n3e(e){if(typeof e!="number"||!Number.isFinite(e))return null;const t=["B","KB","MB","GB"];let n=Math.max(0,e),r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return r===0?`${Math.round(n)} ${t[r]}`:`${n.toFixed(1)} ${t[r]}`}function Vzt(e){return e==="failed"?"failed":e==="ready_to_install"||e==="closing"||e==="complete"?"ready":"active"}function qzt(){const{progress:e,dismissProgress:t}=yBe(),{t:n}=as(),[r,s]=m.useState(null),[a,o]=m.useState(!1);if(!e)return null;const l=e,c=Vzt(l.phase),d=n3e(l.transferredBytes),u=n3e(l.totalBytes),f=typeof l.percent=="number"?Math.max(0,Math.min(100,l.percent)):null,A=f!==null,h=f!==null?`${f}%`:d?u?`${d} / ${u}`:d:null,g=c==="active"&&!A,x=l.blockers??[],y=l.phase==="waiting_for_active_runs"&&x.length>0;async function v(){const O=Pn();O&&(s(null),await O.installUpdate(l.version))}async function w(O={}){const j=Pn();if(s(null),!(j!=null&&j.applyUpdate)){s(n("about.updates.installUnavailable"));return}o(!0);try{const C=await j.applyUpdate(l.updateId,O.force?{force:!0}:void 0);C.status!=="started"&&s(C.message||n("about.updates.installFailed"))}catch(C){s(C instanceof Error?C.message:n("about.updates.installFailed"))}finally{o(!1)}}async function k(){const O=Pn();O?await O.openExternal(e3e):window.open(e3e,"_blank","noopener,noreferrer")}return i.jsx("aside",{"aria-live":"polite",className:"pointer-events-none fixed bottom-[calc(1rem+5.75rem)] right-4 z-[1001] w-[min(calc(100vw-2rem),20rem)] md:bottom-4",children:i.jsx("div",{className:q("pointer-events-auto overflow-hidden rounded-[var(--radius-md)] border bg-popover text-popover-foreground shadow-[0_16px_40px_rgba(15,23,42,0.16)] backdrop-blur-xl dark:shadow-[0_16px_44px_rgba(0,0,0,0.45)]",c==="failed"?"border-destructive/35":"border-border/70"),children:i.jsxs("div",{className:"flex items-start gap-3 px-3.5 py-3",children:[i.jsx("span",{className:q("flex h-7 w-7 shrink-0 items-center justify-center rounded-[var(--radius-sm)] bg-muted text-muted-foreground",c==="failed"&&"bg-destructive/10 text-destructive",c==="ready"&&"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:c==="failed"?i.jsx(zf,{className:"h-4 w-4"}):c==="ready"?i.jsx(Jc,{className:"h-4 w-4"}):i.jsx(pg,{className:"h-4 w-4"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsx("p",{className:"text-sm font-semibold leading-5",children:c==="failed"?n("about.updates.progress.failedTitle"):l.phase==="ready_to_install"?n("about.updates.progress.readyTitle"):l.phase==="complete"?n("about.updates.progress.completeTitle"):n("about.updates.progress.title",{version:l.version.startsWith("v")?l.version:`v${l.version}`})}),h?i.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:h}):null]}),i.jsx("p",{className:"mt-0.5 whitespace-pre-wrap break-words text-xs leading-4 text-muted-foreground",children:l.error??l.message??n(t3e[l.phase])}),y?i.jsxs("div",{className:"mt-2 rounded-[var(--radius-sm)] border border-amber-500/25 bg-amber-500/8 px-2.5 py-2",children:[i.jsx("p",{className:"text-[11px] font-semibold text-foreground",children:n("about.updates.progress.blockersTitle")}),i.jsxs("div",{className:"mt-1 grid gap-0.5",children:[x.slice(0,3).map(O=>i.jsx("p",{className:"break-words text-[11px] leading-4 text-muted-foreground",children:n("about.updates.progress.blockerRun",{organization:O.organizationName,agent:O.agentName,runId:O.runId.slice(0,8)})},O.runId)),x.length>3?i.jsxs("p",{className:"text-[11px] leading-4 text-muted-foreground",children:["+",x.length-3]}):null]}),i.jsx("p",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n("about.updates.progress.automaticApply")})]}):null,r?i.jsx("p",{className:"mt-2 rounded-[var(--radius-sm)] border border-destructive/25 bg-destructive/8 px-2.5 py-2 text-xs leading-4 text-destructive",children:r}):null,A?i.jsx("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-muted",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":f,children:i.jsx("div",{className:q("h-full rounded-full bg-emerald-700 transition-[width] duration-300",c==="failed"&&"bg-destructive"),style:{width:`${f}%`}})}):g?i.jsx("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-muted",role:"progressbar","aria-label":n(t3e[l.phase]),children:i.jsx("div",{className:"h-full w-2/5 rounded-full bg-emerald-700/70 animate-pulse"})}):null,l.phase==="ready_to_install"&&l.automaticApply!==!0?i.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:i.jsx(ie,{type:"button",size:"sm",className:"h-8 px-3 text-xs",disabled:a,onClick:()=>void w(),children:n(a?"about.updates.installing":"about.updates.progress.restartToUpdate")})}):null,y?i.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:i.jsx(ie,{type:"button",variant:"outline",size:"sm",className:"h-8 px-3 text-xs",disabled:a,onClick:()=>void w({force:!0}),children:n(a?"about.updates.installing":"about.updates.progress.forceRestartToUpdate")})}):null,c==="failed"?i.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[i.jsx(ie,{type:"button",size:"sm",className:"h-8 px-3 text-xs",onClick:()=>void v(),children:n("about.updates.progress.retry")}),i.jsx(ie,{type:"button",variant:"outline",size:"sm",className:"h-8 px-3 text-xs",onClick:()=>void k(),children:n("about.updates.progress.openReleases")})]}):null]}),i.jsx("button",{type:"button","aria-label":n("about.updates.progress.dismiss"),onClick:t,className:"-mr-1 -mt-1 shrink-0 rounded-[var(--radius-sm)] p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:i.jsx(Ls,{className:"h-3.5 w-3.5"})})]})})})}const Ya={list:e=>Me.get(`/plugins${e?`?status=${e}`:""}`),listAvailable:()=>Me.get("/plugins/available"),listExamples:()=>Me.get("/plugins/examples"),get:e=>Me.get(`/plugins/${e}`),install:e=>Me.post("/plugins/install",e),uninstall:(e,t)=>Me.delete(`/plugins/${e}${t?"?purge=true":""}`),enable:e=>Me.post(`/plugins/${e}/enable`,{}),disable:(e,t)=>Me.post(`/plugins/${e}/disable`,t?{reason:t}:{}),health:e=>Me.get(`/plugins/${e}/health`),dashboard:e=>Me.get(`/plugins/${e}/dashboard`),logs:(e,t)=>{const n=new URLSearchParams;t!=null&&t.limit&&n.set("limit",String(t.limit)),t!=null&&t.level&&n.set("level",t.level),t!=null&&t.since&&n.set("since",t.since);const r=n.toString();return Me.get(`/plugins/${e}/logs${r?`?${r}`:""}`)},upgrade:(e,t)=>Me.post(`/plugins/${e}/upgrade`,t?{version:t}:{}),listUiContributions:()=>Me.get("/plugins/ui-contributions"),getConfig:e=>Me.get(`/plugins/${e}/config`),saveConfig:(e,t)=>Me.post(`/plugins/${e}/config`,{configJson:t}),testConfig:(e,t)=>Me.post(`/plugins/${e}/config/test`,{configJson:t}),bridgeGetData:(e,t,n,r,s)=>Me.post(`/plugins/${e}/data/${encodeURIComponent(t)}`,{orgId:r??void 0,params:n,renderEnvironment:s??void 0}),bridgePerformAction:(e,t,n,r,s)=>Me.post(`/plugins/${e}/actions/${encodeURIComponent(t)}`,{orgId:r??void 0,params:n,renderEnvironment:s??void 0})},Afe=m.createContext(null);function eK(){const e=m.useContext(Afe);if(!e)throw new Error("Plugin bridge hook called outside of a <PluginBridgeContext.Provider>. Ensure the plugin component is rendered within a PluginBridgeScope.");return e}function vBe(e){if(e instanceof Xl&&e.body&&typeof e.body=="object"){const t=e.body;if(typeof t.code=="string"&&typeof t.message=="string")return{code:t.code,message:t.message,details:t.details};if(typeof t.error=="string")return{code:"UNKNOWN",message:t.error}}return{code:"UNKNOWN",message:e instanceof Error?e.message:String(e)}}function Kzt(e){if(!e)return"";try{return JSON.stringify(e,Object.keys(e).sort())}catch{return""}}function wBe(e){return e?{environment:e.environment,launcherId:e.launcherId,bounds:e.bounds}:null}function Wzt(e){return e?JSON.stringify(e):""}function Zzt(e,t){const{pluginId:n,hostContext:r}=eK(),s=r.orgId,a=wBe(r.renderEnvironment),o=Wzt(a),[l,c]=m.useState(null),[d,u]=m.useState(!0),[f,A]=m.useState(null),[h,g]=m.useState(0),x=Kzt(t);m.useEffect(()=>{let v=!1,w=null,k=0;const O=2,j=["WORKER_UNAVAILABLE","TIMEOUT"];u(!0);const C=()=>{Ya.bridgeGetData(n,e,t,s,a).then(N=>{v||(c(N.data),A(null),u(!1))}).catch(N=>{if(v)return;const I=vBe(N);if(j.includes(I.code)&&k<O){k+=1,w=setTimeout(()=>{w=null,v||C()},150*k);return}A(I),c(null),u(!1)})};return C(),()=>{v=!0,w&&clearTimeout(w)}},[n,e,x,h,s,o]);const y=m.useCallback(()=>{g(v=>v+1)},[]);return{data:l,loading:d,error:f,refresh:y}}function Hzt(e){const t=eK(),n=m.useRef(t);return n.current=t,m.useCallback(async r=>{const{pluginId:s,hostContext:a}=n.current,o=a.orgId,l=wBe(a.renderEnvironment);try{return(await Ya.bridgePerformAction(s,e,r,o,l)).data}catch(c){throw vBe(c)}},[e])}function Xzt(){const{hostContext:e}=eK();return e}function Gzt(){const{pushToast:e}=As();return m.useCallback(t=>e(t),[e])}function Yzt(e,t){const{pluginId:n,hostContext:r}=eK(),s=(t==null?void 0:t.orgId)??r.orgId??void 0,[a,o]=m.useState([]),[l,c]=m.useState(null),[d,u]=m.useState(!!s),[f,A]=m.useState(!1),[h,g]=m.useState(null),x=m.useRef(null),y=m.useCallback(()=>{var v;(v=x.current)==null||v.close(),x.current=null,u(!1),A(!1)},[]);return m.useEffect(()=>{if(o([]),c(null),g(null),!s){y();return}const v=new URLSearchParams({orgId:s}),w=new EventSource(`/api/plugins/${encodeURIComponent(n)}/bridge/stream/${encodeURIComponent(e)}?${v.toString()}`,{withCredentials:!0});return x.current=w,u(!0),A(!1),w.onopen=()=>{u(!1),A(!0),g(null)},w.onmessage=k=>{try{const O=JSON.parse(k.data);o(j=>[...j,O]),c(O)}catch(O){g(O instanceof Error?O:new Error(String(O)))}},w.addEventListener("close",()=>{w.close(),x.current===w&&(x.current=null),u(!1),A(!1)}),w.onerror=()=>{u(!1),A(!1),g(new Error(`Failed to connect to plugin stream "${e}"`)),w.close(),x.current===w&&(x.current=null)},()=>{w.close(),x.current===w&&(x.current=null)}},[e,y,s,n]),{events:a,lastEvent:l,connecting:d,connected:f,error:h,close:y}}const tK=new Map;function nK(e,t){return`${e}:${t}`}function Jzt(e){return e==="detailTab"||e==="taskDetailView"||e==="contextMenuItem"||e==="commentAnnotation"||e==="commentContextMenuItem"||e==="projectSidebarItem"||e==="toolbarButton"}function e$t(e){return e instanceof Error&&e.message?e.message:"Unknown error"}function t$t(e,t,n){tK.set(nK(e,t),{kind:"react",component:n})}function n$t(e,t,n){tK.set(nK(e,t),{kind:"web-component",tagName:n})}function r$t(e){return tK.get(nK(e.pluginKey,e.exportName))??null}function r3e(e,t){return tK.get(nK(e,t))??null}const q5=new Map,mN=new Map;function hfe(e){const t=e.updatedAt??e.version??"0";return`${e.pluginId}:${t}`}function s$t(e){const t=encodeURIComponent(e.updatedAt??e.version??"0");return`/_plugins/${encodeURIComponent(e.pluginId)}/ui/${e.uiEntryFile}?v=${t}`}const HX={};function i$t(e,t){return t===void 0?e??{}:{...e??{},key:t}}function em(e){if(HX[e])return HX[e];let t;switch(e){case"react":t=`
|
|
1684
1684
|
const R = globalThis.__rudderPluginBridge__?.react;
|
|
@@ -1782,7 +1782,7 @@ When you submit the join request, use:
|
|
|
1782
1782
|
constructor(\${params}) {
|
|
1783
1783
|
\${}
|
|
1784
1784
|
}
|
|
1785
|
-
}`,{label:"class",detail:"definition",type:"keyword"}),Cl('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Cl('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],xXe=cme.concat([Cl("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Cl("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Cl("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),p8e=new rHe,bXe=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function SC(e){return(t,n)=>{let r=t.node.getChild("VariableDefinition");return r&&n(r,e),!0}}const Fin=["FunctionDeclaration"],Bin={FunctionDeclaration:SC("function"),ClassDeclaration:SC("class"),ClassExpression:()=>!0,EnumDeclaration:SC("constant"),TypeAliasDeclaration:SC("type"),NamespaceDeclaration:SC("namespace"),VariableDefinition(e,t){e.matchContext(Fin)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null};function yXe(e,t){let n=p8e.get(t);if(n)return n;let r=[],s=!0;function a(o,l){let c=e.sliceString(o.from,o.to);r.push({label:c,type:l})}return t.cursor(Ua.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let l=Bin[o.name];if(l&&l(o,a)||bXe.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of yXe(e,o.node))r.push(l);return!1}}),p8e.set(t,r),r}const jQ=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,dme=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function vXe(e){let t=pc(e.state).resolveInner(e.pos,-1);if(dme.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&jQ.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let s=t;s;s=s.parent)bXe.has(s.name)&&(r=r.concat(yXe(e.state.doc,s)));return{options:r,from:n?t.from:e.pos,validFor:jQ}}function bY(e,t,n){var r;let s=[];for(;;){let a=t.firstChild,o;if((a==null?void 0:a.name)=="VariableName")return s.push(e(a)),{path:s.reverse(),name:n};if((a==null?void 0:a.name)=="MemberExpression"&&((r=o=a.lastChild)===null||r===void 0?void 0:r.name)=="PropertyName")s.push(e(o)),t=a;else return null}}function wXe(e){let t=r=>e.state.doc.sliceString(r.from,r.to),n=pc(e.state).resolveInner(e.pos,-1);return n.name=="PropertyName"?bY(t,n.parent,t(n)):(n.name=="."||n.name=="?.")&&n.parent.name=="MemberExpression"?bY(t,n.parent,""):dme.indexOf(n.name)>-1?null:n.name=="VariableName"||n.to-n.from<20&&jQ.test(t(n))?{path:[],name:t(n)}:n.name=="MemberExpression"?bY(t,n,""):e.explicit?{path:[],name:""}:null}function Qin(e,t){let n=e,r=[],s=new Set;for(let a=0;;a++){for(let l of(Object.getOwnPropertyNames||Object.keys)(e)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(l)||s.has(l))continue;s.add(l);let c;try{c=n[l]}catch{continue}r.push({label:l,type:typeof c=="function"?/^[A-Z]/.test(l)?"class":t?"function":"method":t?"variable":"property",boost:-a})}let o=Object.getPrototypeOf(e);if(!o)return r;e=o}}function Uin(e){let t=new Map;return n=>{let r=wXe(n);if(!r)return null;let s=e;for(let o of r.path)if(s=s[o],!s)return null;let a=t.get(s);return a||t.set(s,a=Qin(s,!r.path.length)),{from:n.pos-r.name.length,options:a,validFor:jQ}}}const d2=o3.define({name:"javascript",parser:$in.configure({props:[B9.add({IfStatement:SP({except:/^\s*({|else\b)/}),TryStatement:SP({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:cnn,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:Ek({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":SP({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),aE.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":tW,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name=="JSXSelfClosingTag")return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){var t;let n=(t=e.firstChild)===null||t===void 0?void 0:t.nextSibling,r=e.lastChild;return!n||n.type.isError?null:{from:n.to,to:r.type.isError?e.to:r.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),kXe={test:e=>/^JSX/.test(e.name),facet:Qhe({commentTokens:{block:{open:"{/*",close:"*/}"}}})},SXe=d2.configure({dialect:"ts"},"typescript"),OXe=d2.configure({dialect:"jsx",props:[Uhe.add(e=>e.isTop?[kXe]:void 0)]}),jXe=d2.configure({dialect:"jsx ts",props:[Uhe.add(e=>e.isTop?[kXe]:void 0)]},"typescript");let CXe=e=>({label:e,type:"keyword"});const NXe="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(CXe),Vin=NXe.concat(["declare","implements","private","protected","public"].map(CXe));function oae(e={}){let t=e.jsx?e.typescript?jXe:OXe:e.typescript?SXe:d2,n=e.typescript?xXe.concat(Vin):cme.concat(NXe);return new G4(t,[d2.data.of({autocomplete:CHe(dme,Xhe(n))}),d2.data.of({autocomplete:vXe}),e.jsx?PXe:[]])}function qin(e){for(;;){if(e.name=="JSXOpenTag"||e.name=="JSXSelfClosingTag"||e.name=="JSXFragmentTag")return e;if(e.name=="JSXEscape"||!e.parent)return null;e=e.parent}}function g8e(e,t,n=e.length){for(let r=t==null?void 0:t.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return e.sliceString(r.from,Math.min(r.to,n));return""}const Kin=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),PXe=sr.inputHandler.of((e,t,n,r,s)=>{if((Kin?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=">"&&r!="/"||!d2.isActiveAt(e.state,t,-1))return!1;let a=s(),{state:o}=a,l=o.changeByRange(c=>{var d;let{head:u}=c,f=pc(o).resolveInner(u-1,-1),A;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(u-1,u)!=r||f.name=="JSXAttributeValue"&&f.to>u)){if(r==">"&&f.name=="JSXFragmentTag")return{range:c,changes:{from:u,insert:"</>"}};if(r=="/"&&f.name=="JSXStartCloseTag"){let h=f.parent,g=h.parent;if(g&&h.from==u-2&&((A=g8e(o.doc,g.firstChild,u))||((d=g.firstChild)===null||d===void 0?void 0:d.name)=="JSXFragmentTag")){let x=`${A}>`;return{range:sn.cursor(u+x.length,-1),changes:{from:u,insert:x}}}}else if(r==">"){let h=qin(f);if(h&&h.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(u,u+2))&&(A=g8e(o.doc,h,u)))return{range:c,changes:{from:u,insert:`</${A}>`}}}}return{range:c}});return l.changes.empty?!1:(e.dispatch([a,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function Win(e,t){return t||(t={parserOptions:{ecmaVersion:2019,sourceType:"module"},env:{browser:!0,node:!0,es6:!0,es2015:!0,es2017:!0,es2020:!0},rules:{}},e.getRules().forEach((n,r)=>{var s;!((s=n.meta.docs)===null||s===void 0)&&s.recommended&&(t.rules[r]=2)})),n=>{let{state:r}=n,s=[];for(let{from:a,to:o}of d2.findRegions(r)){let l=r.doc.lineAt(a),c={line:l.number-1,col:a-l.from,pos:a};for(let d of e.verify(r.sliceDoc(a,o),t))s.push(Zin(d,r.doc,c))}return s}}function x8e(e,t,n,r){return n.line(e+r.line).from+t+(e==1?r.col-1:-1)}function Zin(e,t,n){let r=x8e(e.line,e.column,t,n),s={from:r,to:e.endLine!=null&&e.endColumn!=1?x8e(e.endLine,e.endColumn,t,n):r,message:e.message,source:e.ruleId?"eslint:"+e.ruleId:"eslint",severity:e.severity==1?"warning":"error"};if(e.fix){let{range:a,text:o}=e.fix,l=a[0]+n.pos-r,c=a[1]+n.pos-r;s.actions=[{name:"fix",apply(d,u){d.dispatch({changes:{from:u+l,to:u+c,insert:o},scrollIntoView:!0})}}]}return s}const aL=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:PXe,completionPath:wXe,esLint:Win,javascript:oae,javascriptLanguage:d2,jsxLanguage:OXe,localCompletionSource:vXe,scopeCompletionSource:Uin,snippets:cme,tsxLanguage:jXe,typescriptLanguage:SXe,typescriptSnippets:xXe},Symbol.toStringTag,{value:"Module"}));function Hin(e,t,n,r){const s=dx(ml),a=yh(eKe),o=ge.useRef(null),{lexicalNode:l}=aie(),c=ge.useRef(!1),d=ge.useRef(!1),u=ge.useCallback(()=>{a({editorType:t,rootNode:l,editorRef:o.current})},[t,l,a]),f=ge.useCallback(A=>{var h,g,x,y,v,w;if(A.key==="ArrowDown"){const k=(g=(h=o.current)==null?void 0:h.getCodemirror())==null?void 0:g.state;if(k){const O=k.doc.length,j=k.selection.ranges[0].to;O===j&&(c.current?(s==null||s.update(()=>{var C,N;const I=ex(e);I.getNextSibling()?((N=(C=o.current)==null?void 0:C.getCodemirror())==null||N.contentDOM.blur(),I.selectNext()):I.insertAfter(jo())}),c.current=!1):c.current=!0)}}else if(A.key==="ArrowUp"){const k=(y=(x=o.current)==null?void 0:x.getCodemirror())==null?void 0:y.state;k&&k.selection.ranges[0].from===0&&(d.current?(s==null||s.update(()=>{var j,C;const N=ex(e);N.getPreviousSibling()&&((C=(j=o.current)==null?void 0:j.getCodemirror())==null||C.contentDOM.blur(),N.selectPrevious())}),d.current=!1):d.current=!0)}else if(A.key==="Enter")A.stopPropagation();else if(A.key==="Backspace"||A.key==="Delete"){const k=(w=(v=o.current)==null?void 0:v.getCodemirror())==null?void 0:w.state;(k==null?void 0:k.doc.length)===0&&(s==null||s.update(()=>{ex(e).remove()}))}},[s,e]);return ge.useEffect(()=>{const A=o.current;return setTimeout(()=>{var h,g;(h=A==null?void 0:A.getCodemirror())==null||h.contentDOM.addEventListener("focus",u),(g=A==null?void 0:A.getCodemirror())==null||g.contentDOM.addEventListener("keydown",f)},300),()=>{var h,g;(h=A==null?void 0:A.getCodemirror())==null||h.contentDOM.removeEventListener("focus",u),(g=A==null?void 0:A.getCodemirror())==null||g.contentDOM.removeEventListener("keydown",f)}},[o,u,f,n]),ge.useEffect(()=>{r.subscribe(()=>{var A,h;(h=(A=o.current)==null?void 0:A.getCodemirror())==null||h.focus(),u()})},[r,o,e,u]),o}function pn(e){return new G4(Whe.define(e))}function Xb(e){return Wt(()=>import("./index-CS_SCGq-.js"),[]).then(t=>t.sql({dialect:t[e]}))}const Xin=[Ut.of({name:"C",extensions:["c","h","ino"],load(){return Wt(()=>import("./index-CiBZqJye.js"),[]).then(e=>e.cpp())}}),Ut.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Wt(()=>import("./index-CiBZqJye.js"),[]).then(e=>e.cpp())}}),Ut.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Xb("Cassandra")}}),Ut.of({name:"CSS",extensions:["css"],load(){return Wt(()=>import("./index-_QsesMkH.js"),[]).then(e=>e.css())}}),Ut.of({name:"Go",extensions:["go"],load(){return Wt(()=>import("./index-CJ8Y6mRU.js"),[]).then(e=>e.go())}}),Ut.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Wt(()=>import("./index-CRRh2Q50.js"),__vite__mapDeps([0,1])).then(e=>e.html())}}),Ut.of({name:"Java",extensions:["java"],load(){return Wt(()=>import("./index-CNJdbN2c.js"),[]).then(e=>e.java())}}),Ut.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Wt(()=>Promise.resolve().then(()=>aL),void 0).then(e=>e.javascript())}}),Ut.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load(){return Wt(()=>import("./index-BzBuqR8a.js"),__vite__mapDeps([2,0,1])).then(e=>e.jinja())}}),Ut.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Wt(()=>Promise.resolve().then(()=>g9n),void 0).then(e=>e.json())}}),Ut.of({name:"JSX",extensions:["jsx"],load(){return Wt(()=>Promise.resolve().then(()=>aL),void 0).then(e=>e.javascript({jsx:!0}))}}),Ut.of({name:"LESS",extensions:["less"],load(){return Wt(()=>import("./index-BDWwQIJI.js"),__vite__mapDeps([3,1])).then(e=>e.less())}}),Ut.of({name:"Liquid",extensions:["liquid"],load(){return Wt(()=>import("./index-BOLgWo9p.js"),__vite__mapDeps([4,0,1])).then(e=>e.liquid())}}),Ut.of({name:"MariaDB SQL",load(){return Xb("MariaSQL")}}),Ut.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Wt(()=>import("./index-Z1lC3yRm.js"),__vite__mapDeps([5,0,1])).then(e=>e.markdown())}}),Ut.of({name:"MS SQL",load(){return Xb("MSSQL")}}),Ut.of({name:"MySQL",load(){return Xb("MySQL")}}),Ut.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Wt(()=>import("./index-CWZ6QjAd.js"),__vite__mapDeps([6,0,1])).then(e=>e.php())}}),Ut.of({name:"PLSQL",extensions:["pls"],load(){return Xb("PLSQL")}}),Ut.of({name:"PostgreSQL",load(){return Xb("PostgreSQL")}}),Ut.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Wt(()=>Promise.resolve().then(()=>Tjn),void 0).then(e=>e.python())}}),Ut.of({name:"Rust",extensions:["rs"],load(){return Wt(()=>import("./index-D7jFNS5a.js"),[]).then(e=>e.rust())}}),Ut.of({name:"Sass",extensions:["sass"],load(){return Wt(()=>import("./index-DEdvpket.js"),__vite__mapDeps([7,1])).then(e=>e.sass({indented:!0}))}}),Ut.of({name:"SCSS",extensions:["scss"],load(){return Wt(()=>import("./index-DEdvpket.js"),__vite__mapDeps([7,1])).then(e=>e.sass())}}),Ut.of({name:"SQL",extensions:["sql"],load(){return Xb("StandardSQL")}}),Ut.of({name:"SQLite",load(){return Xb("SQLite")}}),Ut.of({name:"TSX",extensions:["tsx"],load(){return Wt(()=>Promise.resolve().then(()=>aL),void 0).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Ut.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Wt(()=>Promise.resolve().then(()=>aL),void 0).then(e=>e.javascript({typescript:!0}))}}),Ut.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Wt(()=>import("./index-Df6CE5HD.js"),[]).then(e=>e.wast())}}),Ut.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Wt(()=>import("./index-DQRYID5z.js"),[]).then(e=>e.xml())}}),Ut.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Wt(()=>Promise.resolve().then(()=>cCn),void 0).then(e=>e.yaml())}}),Ut.of({name:"APL",extensions:["dyalog","apl"],load(){return Wt(()=>import("./apl-B4CMkyY2.js"),[]).then(e=>pn(e.apl))}}),Ut.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Wt(()=>import("./asciiarmor-Df11BRmG.js"),[]).then(e=>pn(e.asciiArmor))}}),Ut.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Wt(()=>import("./asn1-EdZsLKOL.js"),[]).then(e=>pn(e.asn1({})))}}),Ut.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Wt(()=>import("./asterisk-B-8jnY81.js"),[]).then(e=>pn(e.asterisk))}}),Ut.of({name:"Brainfuck",extensions:["b","bf"],load(){return Wt(()=>import("./brainfuck-C4LP7Hcl.js"),[]).then(e=>pn(e.brainfuck))}}),Ut.of({name:"Cobol",extensions:["cob","cpy"],load(){return Wt(()=>import("./cobol-CWcv1MsR.js"),[]).then(e=>pn(e.cobol))}}),Ut.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.csharp))}}),Ut.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Wt(()=>import("./clojure-BMjYHr_A.js"),[]).then(e=>pn(e.clojure))}}),Ut.of({name:"ClojureScript",extensions:["cljs"],load(){return Wt(()=>import("./clojure-BMjYHr_A.js"),[]).then(e=>pn(e.clojure))}}),Ut.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Wt(()=>import("./css-BnMrqG3P.js"),[]).then(e=>pn(e.gss))}}),Ut.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Wt(()=>import("./cmake-BQqOBYOt.js"),[]).then(e=>pn(e.cmake))}}),Ut.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Wt(()=>import("./coffeescript-S37ZYGWr.js"),[]).then(e=>pn(e.coffeeScript))}}),Ut.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Wt(()=>import("./commonlisp-DBKNyK5s.js"),[]).then(e=>pn(e.commonLisp))}}),Ut.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Wt(()=>import("./cypher-C_CwsFkJ.js"),[]).then(e=>pn(e.cypher))}}),Ut.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Wt(()=>import("./python-BuPzkPfP.js"),[]).then(e=>pn(e.cython))}}),Ut.of({name:"Crystal",extensions:["cr"],load(){return Wt(()=>import("./crystal-SjHAIU92.js"),[]).then(e=>pn(e.crystal))}}),Ut.of({name:"D",extensions:["d"],load(){return Wt(()=>import("./d-pRatUO7H.js"),[]).then(e=>pn(e.d))}}),Ut.of({name:"Dart",extensions:["dart"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.dart))}}),Ut.of({name:"diff",extensions:["diff","patch"],load(){return Wt(()=>import("./diff-DbItnlRl.js"),[]).then(e=>pn(e.diff))}}),Ut.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Wt(()=>import("./dockerfile-BKs6k2Af.js"),__vite__mapDeps([8,9])).then(e=>pn(e.dockerFile))}}),Ut.of({name:"DTD",extensions:["dtd"],load(){return Wt(()=>import("./dtd-DF_7sFjM.js"),[]).then(e=>pn(e.dtd))}}),Ut.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Wt(()=>import("./dylan-DwRh75JA.js"),[]).then(e=>pn(e.dylan))}}),Ut.of({name:"EBNF",load(){return Wt(()=>import("./ebnf-CDyGwa7X.js"),[]).then(e=>pn(e.ebnf))}}),Ut.of({name:"ECL",extensions:["ecl"],load(){return Wt(()=>import("./ecl-Cabwm37j.js"),[]).then(e=>pn(e.ecl))}}),Ut.of({name:"edn",extensions:["edn"],load(){return Wt(()=>import("./clojure-BMjYHr_A.js"),[]).then(e=>pn(e.clojure))}}),Ut.of({name:"Eiffel",extensions:["e"],load(){return Wt(()=>import("./eiffel-CnydiIhH.js"),[]).then(e=>pn(e.eiffel))}}),Ut.of({name:"Elm",extensions:["elm"],load(){return Wt(()=>import("./elm-vLlmbW-K.js"),[]).then(e=>pn(e.elm))}}),Ut.of({name:"Erlang",extensions:["erl"],load(){return Wt(()=>import("./erlang-BNw1qcRV.js"),[]).then(e=>pn(e.erlang))}}),Ut.of({name:"Esper",load(){return Wt(()=>import("./sql-D0XecflT.js"),[]).then(e=>pn(e.esper))}}),Ut.of({name:"Factor",extensions:["factor"],load(){return Wt(()=>import("./factor-kuTfRLto.js"),__vite__mapDeps([10,9])).then(e=>pn(e.factor))}}),Ut.of({name:"FCL",load(){return Wt(()=>import("./fcl-Kvtd6kyn.js"),[]).then(e=>pn(e.fcl))}}),Ut.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Wt(()=>import("./forth-Ffai-XNe.js"),[]).then(e=>pn(e.forth))}}),Ut.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Wt(()=>import("./fortran-DYz_wnZ1.js"),[]).then(e=>pn(e.fortran))}}),Ut.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Wt(()=>import("./mllike-CXdrOF99.js"),[]).then(e=>pn(e.fSharp))}}),Ut.of({name:"Gas",extensions:["s"],load(){return Wt(()=>import("./gas-Bneqetm1.js"),[]).then(e=>pn(e.gas))}}),Ut.of({name:"Gherkin",extensions:["feature"],load(){return Wt(()=>import("./gherkin-heZmZLOM.js"),[]).then(e=>pn(e.gherkin))}}),Ut.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Wt(()=>import("./groovy-D9Dt4D0W.js"),[]).then(e=>pn(e.groovy))}}),Ut.of({name:"Haskell",extensions:["hs"],load(){return Wt(()=>import("./haskell-Cw1EW3IL.js"),[]).then(e=>pn(e.haskell))}}),Ut.of({name:"Haxe",extensions:["hx"],load(){return Wt(()=>import("./haxe-H-WmDvRZ.js"),[]).then(e=>pn(e.haxe))}}),Ut.of({name:"HXML",extensions:["hxml"],load(){return Wt(()=>import("./haxe-H-WmDvRZ.js"),[]).then(e=>pn(e.hxml))}}),Ut.of({name:"HTTP",load(){return Wt(()=>import("./http-DBlCnlav.js"),[]).then(e=>pn(e.http))}}),Ut.of({name:"IDL",extensions:["pro"],load(){return Wt(()=>import("./idl-BEugSyMb.js"),[]).then(e=>pn(e.idl))}}),Ut.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Wt(()=>import("./javascript-iXu5QeM3.js"),[]).then(e=>pn(e.jsonld))}}),Ut.of({name:"Julia",extensions:["jl"],load(){return Wt(()=>import("./julia-DuME0IfC.js"),[]).then(e=>pn(e.julia))}}),Ut.of({name:"Kotlin",extensions:["kt","kts"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.kotlin))}}),Ut.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Wt(()=>import("./livescript-BwQOo05w.js"),[]).then(e=>pn(e.liveScript))}}),Ut.of({name:"Lua",extensions:["lua"],load(){return Wt(()=>import("./lua-BgMRiT3U.js"),[]).then(e=>pn(e.lua))}}),Ut.of({name:"mIRC",extensions:["mrc"],load(){return Wt(()=>import("./mirc-CjQqDB4T.js"),[]).then(e=>pn(e.mirc))}}),Ut.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Wt(()=>import("./mathematica-DTrFuWx2.js"),[]).then(e=>pn(e.mathematica))}}),Ut.of({name:"Modelica",extensions:["mo"],load(){return Wt(()=>import("./modelica-Dc1JOy9r.js"),[]).then(e=>pn(e.modelica))}}),Ut.of({name:"MUMPS",extensions:["mps"],load(){return Wt(()=>import("./mumps-BT43cFF4.js"),[]).then(e=>pn(e.mumps))}}),Ut.of({name:"Mbox",extensions:["mbox"],load(){return Wt(()=>import("./mbox-CNhZ1qSd.js"),[]).then(e=>pn(e.mbox))}}),Ut.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Wt(()=>import("./nginx-DdIZxoE0.js"),[]).then(e=>pn(e.nginx))}}),Ut.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Wt(()=>import("./nsis-LdVXkNf5.js"),__vite__mapDeps([11,9])).then(e=>pn(e.nsis))}}),Ut.of({name:"NTriples",extensions:["nt","nq"],load(){return Wt(()=>import("./ntriples-BfvgReVJ.js"),[]).then(e=>pn(e.ntriples))}}),Ut.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.objectiveC))}}),Ut.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.objectiveCpp))}}),Ut.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Wt(()=>import("./mllike-CXdrOF99.js"),[]).then(e=>pn(e.oCaml))}}),Ut.of({name:"Octave",extensions:["m"],load(){return Wt(()=>import("./octave-Ck1zUtKM.js"),[]).then(e=>pn(e.octave))}}),Ut.of({name:"Oz",extensions:["oz"],load(){return Wt(()=>import("./oz-BzwKVEFT.js"),[]).then(e=>pn(e.oz))}}),Ut.of({name:"Pascal",extensions:["p","pas"],load(){return Wt(()=>import("./pascal--L3eBynH.js"),[]).then(e=>pn(e.pascal))}}),Ut.of({name:"Perl",extensions:["pl","pm"],load(){return Wt(()=>import("./perl-CdXCOZ3F.js"),[]).then(e=>pn(e.perl))}}),Ut.of({name:"Pig",extensions:["pig"],load(){return Wt(()=>import("./pig-CevX1Tat.js"),[]).then(e=>pn(e.pig))}}),Ut.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Wt(()=>import("./powershell-CFHJl5sT.js"),[]).then(e=>pn(e.powerShell))}}),Ut.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Wt(()=>import("./properties-C78fOPTZ.js"),[]).then(e=>pn(e.properties))}}),Ut.of({name:"ProtoBuf",extensions:["proto"],load(){return Wt(()=>import("./protobuf-ChK-085T.js"),[]).then(e=>pn(e.protobuf))}}),Ut.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Wt(()=>import("./pug-DeIclll2.js"),__vite__mapDeps([12,13])).then(e=>pn(e.pug))}}),Ut.of({name:"Puppet",extensions:["pp"],load(){return Wt(()=>import("./puppet-DMA9R1ak.js"),[]).then(e=>pn(e.puppet))}}),Ut.of({name:"Q",extensions:["q"],load(){return Wt(()=>import("./q-pXgVlZs6.js"),[]).then(e=>pn(e.q))}}),Ut.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Wt(()=>import("./r-B6wPVr8A.js"),[]).then(e=>pn(e.r))}}),Ut.of({name:"RPM Changes",load(){return Wt(()=>import("./rpm-CTu-6PCP.js"),[]).then(e=>pn(e.rpmChanges))}}),Ut.of({name:"RPM Spec",extensions:["spec"],load(){return Wt(()=>import("./rpm-CTu-6PCP.js"),[]).then(e=>pn(e.rpmSpec))}}),Ut.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Wt(()=>import("./ruby-B2Rjki9n.js"),[]).then(e=>pn(e.ruby))}}),Ut.of({name:"SAS",extensions:["sas"],load(){return Wt(()=>import("./sas-B4kiWyti.js"),[]).then(e=>pn(e.sas))}}),Ut.of({name:"Scala",extensions:["scala"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.scala))}}),Ut.of({name:"Scheme",extensions:["scm","ss"],load(){return Wt(()=>import("./scheme-C41bIUwD.js"),[]).then(e=>pn(e.scheme))}}),Ut.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Wt(()=>import("./shell-CjFT_Tl9.js"),[]).then(e=>pn(e.shell))}}),Ut.of({name:"Sieve",extensions:["siv","sieve"],load(){return Wt(()=>import("./sieve-C3Gn_uJK.js"),[]).then(e=>pn(e.sieve))}}),Ut.of({name:"Smalltalk",extensions:["st"],load(){return Wt(()=>import("./smalltalk-CnHTOXQT.js"),[]).then(e=>pn(e.smalltalk))}}),Ut.of({name:"Solr",load(){return Wt(()=>import("./solr-DehyRSwq.js"),[]).then(e=>pn(e.solr))}}),Ut.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Wt(()=>import("./mllike-CXdrOF99.js"),[]).then(e=>pn(e.sml))}}),Ut.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Wt(()=>import("./sparql-DkYu6x3z.js"),[]).then(e=>pn(e.sparql))}}),Ut.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Wt(()=>import("./spreadsheet-BCZA_wO0.js"),[]).then(e=>pn(e.spreadsheet))}}),Ut.of({name:"Squirrel",extensions:["nut"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.squirrel))}}),Ut.of({name:"Stylus",extensions:["styl"],load(){return Wt(()=>import("./stylus-B533Al4x.js"),[]).then(e=>pn(e.stylus))}}),Ut.of({name:"Swift",extensions:["swift"],load(){return Wt(()=>import("./swift-BzpIVaGY.js"),[]).then(e=>pn(e.swift))}}),Ut.of({name:"sTeX",load(){return Wt(()=>import("./stex-C3f8Ysf7.js"),[]).then(e=>pn(e.stex))}}),Ut.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Wt(()=>import("./stex-C3f8Ysf7.js"),[]).then(e=>pn(e.stex))}}),Ut.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Wt(()=>import("./verilog-C6RDOZhf.js"),[]).then(e=>pn(e.verilog))}}),Ut.of({name:"Tcl",extensions:["tcl"],load(){return Wt(()=>import("./tcl-DVfN8rqt.js"),[]).then(e=>pn(e.tcl))}}),Ut.of({name:"Textile",extensions:["textile"],load(){return Wt(()=>import("./textile-CnDTJFAw.js"),[]).then(e=>pn(e.textile))}}),Ut.of({name:"TiddlyWiki",load(){return Wt(()=>import("./tiddlywiki-DO-Gjzrf.js"),[]).then(e=>pn(e.tiddlyWiki))}}),Ut.of({name:"Tiki wiki",load(){return Wt(()=>import("./tiki-DGYXhP31.js"),[]).then(e=>pn(e.tiki))}}),Ut.of({name:"TOML",extensions:["toml"],load(){return Wt(()=>import("./toml-Bm5Em-hy.js"),[]).then(e=>pn(e.toml))}}),Ut.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Wt(()=>import("./troff-wAsdV37c.js"),[]).then(e=>pn(e.troff))}}),Ut.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Wt(()=>import("./ttcn-CfJYG6tj.js"),[]).then(e=>pn(e.ttcn))}}),Ut.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Wt(()=>import("./ttcn-cfg-B9xdYoR4.js"),[]).then(e=>pn(e.ttcnCfg))}}),Ut.of({name:"Turtle",extensions:["ttl"],load(){return Wt(()=>import("./turtle-B1tBg_DP.js"),[]).then(e=>pn(e.turtle))}}),Ut.of({name:"Web IDL",extensions:["webidl"],load(){return Wt(()=>import("./webidl-ZXfAyPTL.js"),[]).then(e=>pn(e.webIDL))}}),Ut.of({name:"VB.NET",extensions:["vb"],load(){return Wt(()=>import("./vb-CmGdzxic.js"),[]).then(e=>pn(e.vb))}}),Ut.of({name:"VBScript",extensions:["vbs"],load(){return Wt(()=>import("./vbscript-BuJXcnF6.js"),[]).then(e=>pn(e.vbScript))}}),Ut.of({name:"Velocity",extensions:["vtl"],load(){return Wt(()=>import("./velocity-D8B20fx6.js"),[]).then(e=>pn(e.velocity))}}),Ut.of({name:"Verilog",extensions:["v"],load(){return Wt(()=>import("./verilog-C6RDOZhf.js"),[]).then(e=>pn(e.verilog))}}),Ut.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Wt(()=>import("./vhdl-lSbBsy5d.js"),[]).then(e=>pn(e.vhdl))}}),Ut.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load(){return Wt(()=>import("./xquery-DzFWVndE.js"),[]).then(e=>pn(e.xQuery))}}),Ut.of({name:"Yacas",extensions:["ys"],load(){return Wt(()=>import("./yacas-BJ4BC0dw.js"),[]).then(e=>pn(e.yacas))}}),Ut.of({name:"Z80",extensions:["z80"],load(){return Wt(()=>import("./z80-Hz9HOZM7.js"),[]).then(e=>pn(e.z80))}}),Ut.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Wt(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(e=>pn(e.mscgen))}}),Ut.of({name:"Xù",extensions:["xu"],load(){return Wt(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(e=>pn(e.xu))}}),Ut.of({name:"MsGenny",extensions:["msgenny"],load(){return Wt(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(e=>pn(e.msgenny))}}),Ut.of({name:"Vue",extensions:["vue"],load(){return Wt(()=>import("./index-BdhCuwEn.js"),__vite__mapDeps([14,0,1])).then(e=>e.vue())}}),Ut.of({name:"Angular Template",load(){return Wt(()=>import("./index-DhMy-JmC.js"),__vite__mapDeps([15,0,1])).then(e=>e.angular())}})],b8e="#2e3440",ume="#3b4252",y8e="#434c5e",oL="#4c566a",v8e="#e5e9f0",lae="#eceff4",yY="#8fbcbb",w8e="#88c0d0",Gin="#81a1c1",kp="#5e81ac",Yin="#bf616a",L8="#d08770",vY="#ebcb8b",k8e="#a3be8c",Jin="#b48ead",S8e="#d30102",fme=lae,wY=fme,ean="#ffffff",kY=ume,tan=fme,O8e=ume,nan=sr.theme({"&":{color:b8e,backgroundColor:ean},".cm-content":{caretColor:O8e},".cm-cursor, .cm-dropCursor":{borderLeftColor:O8e},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:tan},".cm-panels":{backgroundColor:fme,color:oL},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${oL}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:v8e},".cm-activeLine":{backgroundColor:wY},".cm-selectionMatch":{backgroundColor:v8e},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${oL}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:lae},".cm-gutters":{backgroundColor:lae,color:b8e,border:"none"},".cm-activeLineGutter":{backgroundColor:wY},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:kY},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:kY,borderBottomColor:kY},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:wY,color:oL}}},{dark:!1}),ran=Q9.define([{tag:Ge.keyword,color:kp},{tag:[Ge.name,Ge.deleted,Ge.character,Ge.propertyName,Ge.macroName],color:L8},{tag:[Ge.variableName],color:L8},{tag:[Ge.function(Ge.variableName)],color:kp},{tag:[Ge.labelName],color:Gin},{tag:[Ge.color,Ge.constant(Ge.name),Ge.standard(Ge.name)],color:kp},{tag:[Ge.definition(Ge.name),Ge.separator],color:k8e},{tag:[Ge.brace],color:yY},{tag:[Ge.annotation],color:S8e},{tag:[Ge.number,Ge.changed,Ge.annotation,Ge.modifier,Ge.self,Ge.namespace],color:w8e},{tag:[Ge.typeName,Ge.className],color:vY},{tag:[Ge.operator,Ge.operatorKeyword],color:k8e},{tag:[Ge.tagName],color:Jin},{tag:[Ge.squareBracket],color:Yin},{tag:[Ge.angleBracket],color:L8},{tag:[Ge.attributeName],color:vY},{tag:[Ge.regexp],color:kp},{tag:[Ge.quote],color:ume},{tag:[Ge.string],color:L8},{tag:Ge.link,color:yY,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Ge.url,Ge.escape,Ge.special(Ge.string)],color:L8},{tag:[Ge.meta],color:w8e},{tag:[Ge.comment],color:y8e,fontStyle:"italic"},{tag:Ge.strong,fontWeight:"bold",color:kp},{tag:Ge.emphasis,fontStyle:"italic",color:kp},{tag:Ge.strikethrough,textDecoration:"line-through"},{tag:Ge.heading,fontWeight:"bold",color:kp},{tag:Ge.special(Ge.heading1),fontWeight:"bold",color:kp},{tag:Ge.heading1,fontWeight:"bold",color:kp},{tag:[Ge.heading2,Ge.heading3,Ge.heading4],fontWeight:"bold",color:kp},{tag:[Ge.heading5,Ge.heading6],color:kp},{tag:[Ge.atom,Ge.bool,Ge.special(Ge.variableName)],color:L8},{tag:[Ge.processingInstruction,Ge.inserted],color:yY},{tag:[Ge.contentSeparator],color:vY},{tag:Ge.invalid,color:y8e,borderBottom:`1px dotted ${S8e}`}]),san=[nan,Khe(ran)],j8e=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class fO{constructor(t,n,r=0,s=t.length,a,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(r,s),this.bufferStart=r,this.normalize=a?l=>a(j8e(l)):j8e,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return bA(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let n=bhe(t),r=this.bufferStart+this.bufferPos;this.bufferPos+=E1(t);let s=this.normalize(n);if(s.length)for(let a=0,o=r;;a++){let l=s.charCodeAt(a),c=this.match(l,o,this.bufferPos+this.bufferStart);if(a==s.length-1){if(c)return this.value=c,this;break}o==r&&a<n.length&&n.charCodeAt(a)==l&&o++}}}match(t,n,r){let s=null;for(let a=0;a<this.matches.length;a+=2){let o=this.matches[a],l=!1;this.query.charCodeAt(o)==t&&(o==this.query.length-1?s={from:this.matches[a+1],to:r}:(this.matches[a]++,l=!0)),l||(this.matches.splice(a,2),a-=2)}return this.query.charCodeAt(0)==t&&(this.query.length==1?s={from:n,to:r}:this.matches.push(1,n)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(fO.prototype[Symbol.iterator]=function(){return this});const IXe={from:-1,to:-1,match:/.*/.exec("")},Ame="gm"+(/x/.unicode==null?"":"u");class TXe{constructor(t,n,r,s=0,a=t.length){if(this.text=t,this.to=a,this.curLine="",this.done=!1,this.value=IXe,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new _Xe(t,n,r,s,a);this.re=new RegExp(n,Ame+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.iter=t.iter();let o=t.lineAt(s);this.curLineStart=o.from,this.matchPos=CQ(t,s),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,s=r+n[0].length;if(this.matchPos=CQ(this.text,s+(r==s?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<s||r>this.value.to)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,match:n},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}}const SY=new WeakMap;class Lk{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let s=SY.get(t);if(!s||s.from>=r||s.to<=n){let l=new Lk(n,t.sliceString(n,r));return SY.set(t,l),l}if(s.from==n&&s.to==r)return s;let{text:a,from:o}=s;return o>n&&(a=t.sliceString(n,o)+a,o=n),s.to<r&&(a+=t.sliceString(s.to,r)),SY.set(t,new Lk(o,a)),new Lk(n,a.slice(n-o,r-o))}}class _Xe{constructor(t,n,r,s,a){this.text=t,this.to=a,this.done=!1,this.value=IXe,this.matchPos=CQ(t,s),this.re=new RegExp(n,Ame+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.flat=Lk.get(t,s,this.chunkEnd(s+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==t&&(this.re.lastIndex=t+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,s=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,match:n},this.matchPos=CQ(this.text,s+(r==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Lk.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(TXe.prototype[Symbol.iterator]=_Xe.prototype[Symbol.iterator]=function(){return this});function ian(e){try{return new RegExp(e,Ame),!0}catch{return!1}}function CQ(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}const aan=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:s}=xtn(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return s.then(a=>{let o=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!o){e.dispatch({effects:r});return}let l=t.doc.lineAt(t.selection.main.head),[,c,d,u,f]=o,A=u?+u.slice(1):0,h=d?+d:l.number;if(d&&f){let y=h/100;c&&(y=y*(c=="-"?-1:1)+l.number/t.doc.lines),h=Math.round(t.doc.lines*y)}else d&&c&&(h=h*(c=="-"?-1:1)+l.number);let g=t.doc.line(Math.max(1,Math.min(t.doc.lines,h))),x=sn.cursor(g.from+Math.max(0,Math.min(A,g.length)));e.dispatch({effects:[r,sr.scrollIntoView(x.from,{y:"center"})],selection:x})}),!0},oan={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},lan=Ar.define({combine(e){return Sx(e,oan,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function can(e){return[han,Aan]}const dan=Jr.mark({class:"cm-selectionMatch"}),uan=Jr.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function C8e(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=pl.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=pl.Word)}function fan(e,t,n,r){return e(t.sliceDoc(n,n+1))==pl.Word&&e(t.sliceDoc(r-1,r))==pl.Word}const Aan=mc.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(lan),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Jr.none;let s=r.main,a,o=null;if(s.empty){if(!t.highlightWordAroundCursor)return Jr.none;let c=n.wordAt(s.head);if(!c)return Jr.none;o=n.charCategorizer(s.head),a=n.sliceDoc(c.from,c.to)}else{let c=s.to-s.from;if(c<t.minSelectionLength||c>200)return Jr.none;if(t.wholeWords){if(a=n.sliceDoc(s.from,s.to),o=n.charCategorizer(s.head),!(C8e(o,n,s.from,s.to)&&fan(o,n,s.from,s.to)))return Jr.none}else if(a=n.sliceDoc(s.from,s.to),!a)return Jr.none}let l=[];for(let c of e.visibleRanges){let d=new fO(n.doc,a,c.from,c.to);for(;!d.next().done;){let{from:u,to:f}=d.value;if((!o||C8e(o,n,u,f))&&(s.empty&&u<=s.from&&f>=s.to?l.push(uan.range(u,f)):(u>=s.to||f<=s.from)&&l.push(dan.range(u,f)),l.length>t.maxMatches))return Jr.none}}return Jr.set(l)}},{decorations:e=>e.decorations}),han=sr.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),man=({state:e,dispatch:t})=>{let{selection:n}=e,r=sn.create(n.ranges.map(s=>e.wordAt(s.head)||sn.cursor(s.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function pan(e,t){let{main:n,ranges:r}=e.selection,s=e.wordAt(n.head),a=s&&s.from==n.from&&s.to==n.to;for(let o=!1,l=new fO(e.doc,t,r[r.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new fO(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),o=!0}else{if(o&&r.some(c=>c.from==l.value.from))continue;if(a){let c=e.wordAt(l.value.from);if(!c||c.from!=l.value.from||c.to!=l.value.to)continue}return l.value}}const gan=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(a=>a.from===a.to))return man({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(a=>e.sliceDoc(a.from,a.to)!=r))return!1;let s=pan(e,r);return s?(t(e.update({selection:e.selection.addRange(sn.range(s.from,s.to),!1),effects:sr.scrollIntoView(s.to)})),!0):!1},q9=Ar.define({combine(e){return Sx(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new Tan(t),scrollToMatch:t=>sr.scrollIntoView(t)})}});class MXe{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||ian(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
|
|
1785
|
+
}`,{label:"class",detail:"definition",type:"keyword"}),Cl('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Cl('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],xXe=cme.concat([Cl("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Cl("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Cl("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),p8e=new rHe,bXe=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function SC(e){return(t,n)=>{let r=t.node.getChild("VariableDefinition");return r&&n(r,e),!0}}const Fin=["FunctionDeclaration"],Bin={FunctionDeclaration:SC("function"),ClassDeclaration:SC("class"),ClassExpression:()=>!0,EnumDeclaration:SC("constant"),TypeAliasDeclaration:SC("type"),NamespaceDeclaration:SC("namespace"),VariableDefinition(e,t){e.matchContext(Fin)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null};function yXe(e,t){let n=p8e.get(t);if(n)return n;let r=[],s=!0;function a(o,l){let c=e.sliceString(o.from,o.to);r.push({label:c,type:l})}return t.cursor(Ua.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let l=Bin[o.name];if(l&&l(o,a)||bXe.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of yXe(e,o.node))r.push(l);return!1}}),p8e.set(t,r),r}const jQ=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,dme=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function vXe(e){let t=pc(e.state).resolveInner(e.pos,-1);if(dme.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&jQ.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let s=t;s;s=s.parent)bXe.has(s.name)&&(r=r.concat(yXe(e.state.doc,s)));return{options:r,from:n?t.from:e.pos,validFor:jQ}}function bY(e,t,n){var r;let s=[];for(;;){let a=t.firstChild,o;if((a==null?void 0:a.name)=="VariableName")return s.push(e(a)),{path:s.reverse(),name:n};if((a==null?void 0:a.name)=="MemberExpression"&&((r=o=a.lastChild)===null||r===void 0?void 0:r.name)=="PropertyName")s.push(e(o)),t=a;else return null}}function wXe(e){let t=r=>e.state.doc.sliceString(r.from,r.to),n=pc(e.state).resolveInner(e.pos,-1);return n.name=="PropertyName"?bY(t,n.parent,t(n)):(n.name=="."||n.name=="?.")&&n.parent.name=="MemberExpression"?bY(t,n.parent,""):dme.indexOf(n.name)>-1?null:n.name=="VariableName"||n.to-n.from<20&&jQ.test(t(n))?{path:[],name:t(n)}:n.name=="MemberExpression"?bY(t,n,""):e.explicit?{path:[],name:""}:null}function Qin(e,t){let n=e,r=[],s=new Set;for(let a=0;;a++){for(let l of(Object.getOwnPropertyNames||Object.keys)(e)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(l)||s.has(l))continue;s.add(l);let c;try{c=n[l]}catch{continue}r.push({label:l,type:typeof c=="function"?/^[A-Z]/.test(l)?"class":t?"function":"method":t?"variable":"property",boost:-a})}let o=Object.getPrototypeOf(e);if(!o)return r;e=o}}function Uin(e){let t=new Map;return n=>{let r=wXe(n);if(!r)return null;let s=e;for(let o of r.path)if(s=s[o],!s)return null;let a=t.get(s);return a||t.set(s,a=Qin(s,!r.path.length)),{from:n.pos-r.name.length,options:a,validFor:jQ}}}const d2=o3.define({name:"javascript",parser:$in.configure({props:[B9.add({IfStatement:SP({except:/^\s*({|else\b)/}),TryStatement:SP({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:cnn,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:Ek({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":SP({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),aE.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":tW,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name=="JSXSelfClosingTag")return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){var t;let n=(t=e.firstChild)===null||t===void 0?void 0:t.nextSibling,r=e.lastChild;return!n||n.type.isError?null:{from:n.to,to:r.type.isError?e.to:r.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),kXe={test:e=>/^JSX/.test(e.name),facet:Qhe({commentTokens:{block:{open:"{/*",close:"*/}"}}})},SXe=d2.configure({dialect:"ts"},"typescript"),OXe=d2.configure({dialect:"jsx",props:[Uhe.add(e=>e.isTop?[kXe]:void 0)]}),jXe=d2.configure({dialect:"jsx ts",props:[Uhe.add(e=>e.isTop?[kXe]:void 0)]},"typescript");let CXe=e=>({label:e,type:"keyword"});const NXe="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(CXe),Vin=NXe.concat(["declare","implements","private","protected","public"].map(CXe));function oae(e={}){let t=e.jsx?e.typescript?jXe:OXe:e.typescript?SXe:d2,n=e.typescript?xXe.concat(Vin):cme.concat(NXe);return new G4(t,[d2.data.of({autocomplete:CHe(dme,Xhe(n))}),d2.data.of({autocomplete:vXe}),e.jsx?PXe:[]])}function qin(e){for(;;){if(e.name=="JSXOpenTag"||e.name=="JSXSelfClosingTag"||e.name=="JSXFragmentTag")return e;if(e.name=="JSXEscape"||!e.parent)return null;e=e.parent}}function g8e(e,t,n=e.length){for(let r=t==null?void 0:t.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return e.sliceString(r.from,Math.min(r.to,n));return""}const Kin=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),PXe=sr.inputHandler.of((e,t,n,r,s)=>{if((Kin?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=">"&&r!="/"||!d2.isActiveAt(e.state,t,-1))return!1;let a=s(),{state:o}=a,l=o.changeByRange(c=>{var d;let{head:u}=c,f=pc(o).resolveInner(u-1,-1),A;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(u-1,u)!=r||f.name=="JSXAttributeValue"&&f.to>u)){if(r==">"&&f.name=="JSXFragmentTag")return{range:c,changes:{from:u,insert:"</>"}};if(r=="/"&&f.name=="JSXStartCloseTag"){let h=f.parent,g=h.parent;if(g&&h.from==u-2&&((A=g8e(o.doc,g.firstChild,u))||((d=g.firstChild)===null||d===void 0?void 0:d.name)=="JSXFragmentTag")){let x=`${A}>`;return{range:sn.cursor(u+x.length,-1),changes:{from:u,insert:x}}}}else if(r==">"){let h=qin(f);if(h&&h.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(u,u+2))&&(A=g8e(o.doc,h,u)))return{range:c,changes:{from:u,insert:`</${A}>`}}}}return{range:c}});return l.changes.empty?!1:(e.dispatch([a,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function Win(e,t){return t||(t={parserOptions:{ecmaVersion:2019,sourceType:"module"},env:{browser:!0,node:!0,es6:!0,es2015:!0,es2017:!0,es2020:!0},rules:{}},e.getRules().forEach((n,r)=>{var s;!((s=n.meta.docs)===null||s===void 0)&&s.recommended&&(t.rules[r]=2)})),n=>{let{state:r}=n,s=[];for(let{from:a,to:o}of d2.findRegions(r)){let l=r.doc.lineAt(a),c={line:l.number-1,col:a-l.from,pos:a};for(let d of e.verify(r.sliceDoc(a,o),t))s.push(Zin(d,r.doc,c))}return s}}function x8e(e,t,n,r){return n.line(e+r.line).from+t+(e==1?r.col-1:-1)}function Zin(e,t,n){let r=x8e(e.line,e.column,t,n),s={from:r,to:e.endLine!=null&&e.endColumn!=1?x8e(e.endLine,e.endColumn,t,n):r,message:e.message,source:e.ruleId?"eslint:"+e.ruleId:"eslint",severity:e.severity==1?"warning":"error"};if(e.fix){let{range:a,text:o}=e.fix,l=a[0]+n.pos-r,c=a[1]+n.pos-r;s.actions=[{name:"fix",apply(d,u){d.dispatch({changes:{from:u+l,to:u+c,insert:o},scrollIntoView:!0})}}]}return s}const aL=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:PXe,completionPath:wXe,esLint:Win,javascript:oae,javascriptLanguage:d2,jsxLanguage:OXe,localCompletionSource:vXe,scopeCompletionSource:Uin,snippets:cme,tsxLanguage:jXe,typescriptLanguage:SXe,typescriptSnippets:xXe},Symbol.toStringTag,{value:"Module"}));function Hin(e,t,n,r){const s=dx(ml),a=yh(eKe),o=ge.useRef(null),{lexicalNode:l}=aie(),c=ge.useRef(!1),d=ge.useRef(!1),u=ge.useCallback(()=>{a({editorType:t,rootNode:l,editorRef:o.current})},[t,l,a]),f=ge.useCallback(A=>{var h,g,x,y,v,w;if(A.key==="ArrowDown"){const k=(g=(h=o.current)==null?void 0:h.getCodemirror())==null?void 0:g.state;if(k){const O=k.doc.length,j=k.selection.ranges[0].to;O===j&&(c.current?(s==null||s.update(()=>{var C,N;const I=ex(e);I.getNextSibling()?((N=(C=o.current)==null?void 0:C.getCodemirror())==null||N.contentDOM.blur(),I.selectNext()):I.insertAfter(jo())}),c.current=!1):c.current=!0)}}else if(A.key==="ArrowUp"){const k=(y=(x=o.current)==null?void 0:x.getCodemirror())==null?void 0:y.state;k&&k.selection.ranges[0].from===0&&(d.current?(s==null||s.update(()=>{var j,C;const N=ex(e);N.getPreviousSibling()&&((C=(j=o.current)==null?void 0:j.getCodemirror())==null||C.contentDOM.blur(),N.selectPrevious())}),d.current=!1):d.current=!0)}else if(A.key==="Enter")A.stopPropagation();else if(A.key==="Backspace"||A.key==="Delete"){const k=(w=(v=o.current)==null?void 0:v.getCodemirror())==null?void 0:w.state;(k==null?void 0:k.doc.length)===0&&(s==null||s.update(()=>{ex(e).remove()}))}},[s,e]);return ge.useEffect(()=>{const A=o.current;return setTimeout(()=>{var h,g;(h=A==null?void 0:A.getCodemirror())==null||h.contentDOM.addEventListener("focus",u),(g=A==null?void 0:A.getCodemirror())==null||g.contentDOM.addEventListener("keydown",f)},300),()=>{var h,g;(h=A==null?void 0:A.getCodemirror())==null||h.contentDOM.removeEventListener("focus",u),(g=A==null?void 0:A.getCodemirror())==null||g.contentDOM.removeEventListener("keydown",f)}},[o,u,f,n]),ge.useEffect(()=>{r.subscribe(()=>{var A,h;(h=(A=o.current)==null?void 0:A.getCodemirror())==null||h.focus(),u()})},[r,o,e,u]),o}function pn(e){return new G4(Whe.define(e))}function Xb(e){return Wt(()=>import("./index-C-4Zo7dp.js"),[]).then(t=>t.sql({dialect:t[e]}))}const Xin=[Ut.of({name:"C",extensions:["c","h","ino"],load(){return Wt(()=>import("./index-b048gRJ5.js"),[]).then(e=>e.cpp())}}),Ut.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Wt(()=>import("./index-b048gRJ5.js"),[]).then(e=>e.cpp())}}),Ut.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Xb("Cassandra")}}),Ut.of({name:"CSS",extensions:["css"],load(){return Wt(()=>import("./index-BH9LwKXk.js"),[]).then(e=>e.css())}}),Ut.of({name:"Go",extensions:["go"],load(){return Wt(()=>import("./index-Cm_HvF4F.js"),[]).then(e=>e.go())}}),Ut.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Wt(()=>import("./index-CLvaLbgc.js"),__vite__mapDeps([0,1])).then(e=>e.html())}}),Ut.of({name:"Java",extensions:["java"],load(){return Wt(()=>import("./index-vGVwOJ8z.js"),[]).then(e=>e.java())}}),Ut.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Wt(()=>Promise.resolve().then(()=>aL),void 0).then(e=>e.javascript())}}),Ut.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load(){return Wt(()=>import("./index-DacDSgdg.js"),__vite__mapDeps([2,0,1])).then(e=>e.jinja())}}),Ut.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Wt(()=>Promise.resolve().then(()=>g9n),void 0).then(e=>e.json())}}),Ut.of({name:"JSX",extensions:["jsx"],load(){return Wt(()=>Promise.resolve().then(()=>aL),void 0).then(e=>e.javascript({jsx:!0}))}}),Ut.of({name:"LESS",extensions:["less"],load(){return Wt(()=>import("./index-DVJpqZtD.js"),__vite__mapDeps([3,1])).then(e=>e.less())}}),Ut.of({name:"Liquid",extensions:["liquid"],load(){return Wt(()=>import("./index-DrWke90U.js"),__vite__mapDeps([4,0,1])).then(e=>e.liquid())}}),Ut.of({name:"MariaDB SQL",load(){return Xb("MariaSQL")}}),Ut.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Wt(()=>import("./index-CQiu3CXd.js"),__vite__mapDeps([5,0,1])).then(e=>e.markdown())}}),Ut.of({name:"MS SQL",load(){return Xb("MSSQL")}}),Ut.of({name:"MySQL",load(){return Xb("MySQL")}}),Ut.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Wt(()=>import("./index-DrRUMUXa.js"),__vite__mapDeps([6,0,1])).then(e=>e.php())}}),Ut.of({name:"PLSQL",extensions:["pls"],load(){return Xb("PLSQL")}}),Ut.of({name:"PostgreSQL",load(){return Xb("PostgreSQL")}}),Ut.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Wt(()=>Promise.resolve().then(()=>Tjn),void 0).then(e=>e.python())}}),Ut.of({name:"Rust",extensions:["rs"],load(){return Wt(()=>import("./index-DfScGbDG.js"),[]).then(e=>e.rust())}}),Ut.of({name:"Sass",extensions:["sass"],load(){return Wt(()=>import("./index-DzECL1TA.js"),__vite__mapDeps([7,1])).then(e=>e.sass({indented:!0}))}}),Ut.of({name:"SCSS",extensions:["scss"],load(){return Wt(()=>import("./index-DzECL1TA.js"),__vite__mapDeps([7,1])).then(e=>e.sass())}}),Ut.of({name:"SQL",extensions:["sql"],load(){return Xb("StandardSQL")}}),Ut.of({name:"SQLite",load(){return Xb("SQLite")}}),Ut.of({name:"TSX",extensions:["tsx"],load(){return Wt(()=>Promise.resolve().then(()=>aL),void 0).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Ut.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Wt(()=>Promise.resolve().then(()=>aL),void 0).then(e=>e.javascript({typescript:!0}))}}),Ut.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Wt(()=>import("./index-CFUDXhV8.js"),[]).then(e=>e.wast())}}),Ut.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Wt(()=>import("./index-Du9mXfo2.js"),[]).then(e=>e.xml())}}),Ut.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Wt(()=>Promise.resolve().then(()=>cCn),void 0).then(e=>e.yaml())}}),Ut.of({name:"APL",extensions:["dyalog","apl"],load(){return Wt(()=>import("./apl-B4CMkyY2.js"),[]).then(e=>pn(e.apl))}}),Ut.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Wt(()=>import("./asciiarmor-Df11BRmG.js"),[]).then(e=>pn(e.asciiArmor))}}),Ut.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Wt(()=>import("./asn1-EdZsLKOL.js"),[]).then(e=>pn(e.asn1({})))}}),Ut.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Wt(()=>import("./asterisk-B-8jnY81.js"),[]).then(e=>pn(e.asterisk))}}),Ut.of({name:"Brainfuck",extensions:["b","bf"],load(){return Wt(()=>import("./brainfuck-C4LP7Hcl.js"),[]).then(e=>pn(e.brainfuck))}}),Ut.of({name:"Cobol",extensions:["cob","cpy"],load(){return Wt(()=>import("./cobol-CWcv1MsR.js"),[]).then(e=>pn(e.cobol))}}),Ut.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.csharp))}}),Ut.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Wt(()=>import("./clojure-BMjYHr_A.js"),[]).then(e=>pn(e.clojure))}}),Ut.of({name:"ClojureScript",extensions:["cljs"],load(){return Wt(()=>import("./clojure-BMjYHr_A.js"),[]).then(e=>pn(e.clojure))}}),Ut.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Wt(()=>import("./css-BnMrqG3P.js"),[]).then(e=>pn(e.gss))}}),Ut.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Wt(()=>import("./cmake-BQqOBYOt.js"),[]).then(e=>pn(e.cmake))}}),Ut.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Wt(()=>import("./coffeescript-S37ZYGWr.js"),[]).then(e=>pn(e.coffeeScript))}}),Ut.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Wt(()=>import("./commonlisp-DBKNyK5s.js"),[]).then(e=>pn(e.commonLisp))}}),Ut.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Wt(()=>import("./cypher-C_CwsFkJ.js"),[]).then(e=>pn(e.cypher))}}),Ut.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Wt(()=>import("./python-BuPzkPfP.js"),[]).then(e=>pn(e.cython))}}),Ut.of({name:"Crystal",extensions:["cr"],load(){return Wt(()=>import("./crystal-SjHAIU92.js"),[]).then(e=>pn(e.crystal))}}),Ut.of({name:"D",extensions:["d"],load(){return Wt(()=>import("./d-pRatUO7H.js"),[]).then(e=>pn(e.d))}}),Ut.of({name:"Dart",extensions:["dart"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.dart))}}),Ut.of({name:"diff",extensions:["diff","patch"],load(){return Wt(()=>import("./diff-DbItnlRl.js"),[]).then(e=>pn(e.diff))}}),Ut.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Wt(()=>import("./dockerfile-BKs6k2Af.js"),__vite__mapDeps([8,9])).then(e=>pn(e.dockerFile))}}),Ut.of({name:"DTD",extensions:["dtd"],load(){return Wt(()=>import("./dtd-DF_7sFjM.js"),[]).then(e=>pn(e.dtd))}}),Ut.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Wt(()=>import("./dylan-DwRh75JA.js"),[]).then(e=>pn(e.dylan))}}),Ut.of({name:"EBNF",load(){return Wt(()=>import("./ebnf-CDyGwa7X.js"),[]).then(e=>pn(e.ebnf))}}),Ut.of({name:"ECL",extensions:["ecl"],load(){return Wt(()=>import("./ecl-Cabwm37j.js"),[]).then(e=>pn(e.ecl))}}),Ut.of({name:"edn",extensions:["edn"],load(){return Wt(()=>import("./clojure-BMjYHr_A.js"),[]).then(e=>pn(e.clojure))}}),Ut.of({name:"Eiffel",extensions:["e"],load(){return Wt(()=>import("./eiffel-CnydiIhH.js"),[]).then(e=>pn(e.eiffel))}}),Ut.of({name:"Elm",extensions:["elm"],load(){return Wt(()=>import("./elm-vLlmbW-K.js"),[]).then(e=>pn(e.elm))}}),Ut.of({name:"Erlang",extensions:["erl"],load(){return Wt(()=>import("./erlang-BNw1qcRV.js"),[]).then(e=>pn(e.erlang))}}),Ut.of({name:"Esper",load(){return Wt(()=>import("./sql-D0XecflT.js"),[]).then(e=>pn(e.esper))}}),Ut.of({name:"Factor",extensions:["factor"],load(){return Wt(()=>import("./factor-kuTfRLto.js"),__vite__mapDeps([10,9])).then(e=>pn(e.factor))}}),Ut.of({name:"FCL",load(){return Wt(()=>import("./fcl-Kvtd6kyn.js"),[]).then(e=>pn(e.fcl))}}),Ut.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Wt(()=>import("./forth-Ffai-XNe.js"),[]).then(e=>pn(e.forth))}}),Ut.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Wt(()=>import("./fortran-DYz_wnZ1.js"),[]).then(e=>pn(e.fortran))}}),Ut.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Wt(()=>import("./mllike-CXdrOF99.js"),[]).then(e=>pn(e.fSharp))}}),Ut.of({name:"Gas",extensions:["s"],load(){return Wt(()=>import("./gas-Bneqetm1.js"),[]).then(e=>pn(e.gas))}}),Ut.of({name:"Gherkin",extensions:["feature"],load(){return Wt(()=>import("./gherkin-heZmZLOM.js"),[]).then(e=>pn(e.gherkin))}}),Ut.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Wt(()=>import("./groovy-D9Dt4D0W.js"),[]).then(e=>pn(e.groovy))}}),Ut.of({name:"Haskell",extensions:["hs"],load(){return Wt(()=>import("./haskell-Cw1EW3IL.js"),[]).then(e=>pn(e.haskell))}}),Ut.of({name:"Haxe",extensions:["hx"],load(){return Wt(()=>import("./haxe-H-WmDvRZ.js"),[]).then(e=>pn(e.haxe))}}),Ut.of({name:"HXML",extensions:["hxml"],load(){return Wt(()=>import("./haxe-H-WmDvRZ.js"),[]).then(e=>pn(e.hxml))}}),Ut.of({name:"HTTP",load(){return Wt(()=>import("./http-DBlCnlav.js"),[]).then(e=>pn(e.http))}}),Ut.of({name:"IDL",extensions:["pro"],load(){return Wt(()=>import("./idl-BEugSyMb.js"),[]).then(e=>pn(e.idl))}}),Ut.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Wt(()=>import("./javascript-iXu5QeM3.js"),[]).then(e=>pn(e.jsonld))}}),Ut.of({name:"Julia",extensions:["jl"],load(){return Wt(()=>import("./julia-DuME0IfC.js"),[]).then(e=>pn(e.julia))}}),Ut.of({name:"Kotlin",extensions:["kt","kts"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.kotlin))}}),Ut.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Wt(()=>import("./livescript-BwQOo05w.js"),[]).then(e=>pn(e.liveScript))}}),Ut.of({name:"Lua",extensions:["lua"],load(){return Wt(()=>import("./lua-BgMRiT3U.js"),[]).then(e=>pn(e.lua))}}),Ut.of({name:"mIRC",extensions:["mrc"],load(){return Wt(()=>import("./mirc-CjQqDB4T.js"),[]).then(e=>pn(e.mirc))}}),Ut.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Wt(()=>import("./mathematica-DTrFuWx2.js"),[]).then(e=>pn(e.mathematica))}}),Ut.of({name:"Modelica",extensions:["mo"],load(){return Wt(()=>import("./modelica-Dc1JOy9r.js"),[]).then(e=>pn(e.modelica))}}),Ut.of({name:"MUMPS",extensions:["mps"],load(){return Wt(()=>import("./mumps-BT43cFF4.js"),[]).then(e=>pn(e.mumps))}}),Ut.of({name:"Mbox",extensions:["mbox"],load(){return Wt(()=>import("./mbox-CNhZ1qSd.js"),[]).then(e=>pn(e.mbox))}}),Ut.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Wt(()=>import("./nginx-DdIZxoE0.js"),[]).then(e=>pn(e.nginx))}}),Ut.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Wt(()=>import("./nsis-LdVXkNf5.js"),__vite__mapDeps([11,9])).then(e=>pn(e.nsis))}}),Ut.of({name:"NTriples",extensions:["nt","nq"],load(){return Wt(()=>import("./ntriples-BfvgReVJ.js"),[]).then(e=>pn(e.ntriples))}}),Ut.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.objectiveC))}}),Ut.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.objectiveCpp))}}),Ut.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Wt(()=>import("./mllike-CXdrOF99.js"),[]).then(e=>pn(e.oCaml))}}),Ut.of({name:"Octave",extensions:["m"],load(){return Wt(()=>import("./octave-Ck1zUtKM.js"),[]).then(e=>pn(e.octave))}}),Ut.of({name:"Oz",extensions:["oz"],load(){return Wt(()=>import("./oz-BzwKVEFT.js"),[]).then(e=>pn(e.oz))}}),Ut.of({name:"Pascal",extensions:["p","pas"],load(){return Wt(()=>import("./pascal--L3eBynH.js"),[]).then(e=>pn(e.pascal))}}),Ut.of({name:"Perl",extensions:["pl","pm"],load(){return Wt(()=>import("./perl-CdXCOZ3F.js"),[]).then(e=>pn(e.perl))}}),Ut.of({name:"Pig",extensions:["pig"],load(){return Wt(()=>import("./pig-CevX1Tat.js"),[]).then(e=>pn(e.pig))}}),Ut.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Wt(()=>import("./powershell-CFHJl5sT.js"),[]).then(e=>pn(e.powerShell))}}),Ut.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Wt(()=>import("./properties-C78fOPTZ.js"),[]).then(e=>pn(e.properties))}}),Ut.of({name:"ProtoBuf",extensions:["proto"],load(){return Wt(()=>import("./protobuf-ChK-085T.js"),[]).then(e=>pn(e.protobuf))}}),Ut.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Wt(()=>import("./pug-DeIclll2.js"),__vite__mapDeps([12,13])).then(e=>pn(e.pug))}}),Ut.of({name:"Puppet",extensions:["pp"],load(){return Wt(()=>import("./puppet-DMA9R1ak.js"),[]).then(e=>pn(e.puppet))}}),Ut.of({name:"Q",extensions:["q"],load(){return Wt(()=>import("./q-pXgVlZs6.js"),[]).then(e=>pn(e.q))}}),Ut.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Wt(()=>import("./r-B6wPVr8A.js"),[]).then(e=>pn(e.r))}}),Ut.of({name:"RPM Changes",load(){return Wt(()=>import("./rpm-CTu-6PCP.js"),[]).then(e=>pn(e.rpmChanges))}}),Ut.of({name:"RPM Spec",extensions:["spec"],load(){return Wt(()=>import("./rpm-CTu-6PCP.js"),[]).then(e=>pn(e.rpmSpec))}}),Ut.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Wt(()=>import("./ruby-B2Rjki9n.js"),[]).then(e=>pn(e.ruby))}}),Ut.of({name:"SAS",extensions:["sas"],load(){return Wt(()=>import("./sas-B4kiWyti.js"),[]).then(e=>pn(e.sas))}}),Ut.of({name:"Scala",extensions:["scala"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.scala))}}),Ut.of({name:"Scheme",extensions:["scm","ss"],load(){return Wt(()=>import("./scheme-C41bIUwD.js"),[]).then(e=>pn(e.scheme))}}),Ut.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Wt(()=>import("./shell-CjFT_Tl9.js"),[]).then(e=>pn(e.shell))}}),Ut.of({name:"Sieve",extensions:["siv","sieve"],load(){return Wt(()=>import("./sieve-C3Gn_uJK.js"),[]).then(e=>pn(e.sieve))}}),Ut.of({name:"Smalltalk",extensions:["st"],load(){return Wt(()=>import("./smalltalk-CnHTOXQT.js"),[]).then(e=>pn(e.smalltalk))}}),Ut.of({name:"Solr",load(){return Wt(()=>import("./solr-DehyRSwq.js"),[]).then(e=>pn(e.solr))}}),Ut.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Wt(()=>import("./mllike-CXdrOF99.js"),[]).then(e=>pn(e.sml))}}),Ut.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Wt(()=>import("./sparql-DkYu6x3z.js"),[]).then(e=>pn(e.sparql))}}),Ut.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Wt(()=>import("./spreadsheet-BCZA_wO0.js"),[]).then(e=>pn(e.spreadsheet))}}),Ut.of({name:"Squirrel",extensions:["nut"],load(){return Wt(()=>import("./clike-B9uivgTg.js"),[]).then(e=>pn(e.squirrel))}}),Ut.of({name:"Stylus",extensions:["styl"],load(){return Wt(()=>import("./stylus-B533Al4x.js"),[]).then(e=>pn(e.stylus))}}),Ut.of({name:"Swift",extensions:["swift"],load(){return Wt(()=>import("./swift-BzpIVaGY.js"),[]).then(e=>pn(e.swift))}}),Ut.of({name:"sTeX",load(){return Wt(()=>import("./stex-C3f8Ysf7.js"),[]).then(e=>pn(e.stex))}}),Ut.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Wt(()=>import("./stex-C3f8Ysf7.js"),[]).then(e=>pn(e.stex))}}),Ut.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Wt(()=>import("./verilog-C6RDOZhf.js"),[]).then(e=>pn(e.verilog))}}),Ut.of({name:"Tcl",extensions:["tcl"],load(){return Wt(()=>import("./tcl-DVfN8rqt.js"),[]).then(e=>pn(e.tcl))}}),Ut.of({name:"Textile",extensions:["textile"],load(){return Wt(()=>import("./textile-CnDTJFAw.js"),[]).then(e=>pn(e.textile))}}),Ut.of({name:"TiddlyWiki",load(){return Wt(()=>import("./tiddlywiki-DO-Gjzrf.js"),[]).then(e=>pn(e.tiddlyWiki))}}),Ut.of({name:"Tiki wiki",load(){return Wt(()=>import("./tiki-DGYXhP31.js"),[]).then(e=>pn(e.tiki))}}),Ut.of({name:"TOML",extensions:["toml"],load(){return Wt(()=>import("./toml-Bm5Em-hy.js"),[]).then(e=>pn(e.toml))}}),Ut.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Wt(()=>import("./troff-wAsdV37c.js"),[]).then(e=>pn(e.troff))}}),Ut.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Wt(()=>import("./ttcn-CfJYG6tj.js"),[]).then(e=>pn(e.ttcn))}}),Ut.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Wt(()=>import("./ttcn-cfg-B9xdYoR4.js"),[]).then(e=>pn(e.ttcnCfg))}}),Ut.of({name:"Turtle",extensions:["ttl"],load(){return Wt(()=>import("./turtle-B1tBg_DP.js"),[]).then(e=>pn(e.turtle))}}),Ut.of({name:"Web IDL",extensions:["webidl"],load(){return Wt(()=>import("./webidl-ZXfAyPTL.js"),[]).then(e=>pn(e.webIDL))}}),Ut.of({name:"VB.NET",extensions:["vb"],load(){return Wt(()=>import("./vb-CmGdzxic.js"),[]).then(e=>pn(e.vb))}}),Ut.of({name:"VBScript",extensions:["vbs"],load(){return Wt(()=>import("./vbscript-BuJXcnF6.js"),[]).then(e=>pn(e.vbScript))}}),Ut.of({name:"Velocity",extensions:["vtl"],load(){return Wt(()=>import("./velocity-D8B20fx6.js"),[]).then(e=>pn(e.velocity))}}),Ut.of({name:"Verilog",extensions:["v"],load(){return Wt(()=>import("./verilog-C6RDOZhf.js"),[]).then(e=>pn(e.verilog))}}),Ut.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Wt(()=>import("./vhdl-lSbBsy5d.js"),[]).then(e=>pn(e.vhdl))}}),Ut.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load(){return Wt(()=>import("./xquery-DzFWVndE.js"),[]).then(e=>pn(e.xQuery))}}),Ut.of({name:"Yacas",extensions:["ys"],load(){return Wt(()=>import("./yacas-BJ4BC0dw.js"),[]).then(e=>pn(e.yacas))}}),Ut.of({name:"Z80",extensions:["z80"],load(){return Wt(()=>import("./z80-Hz9HOZM7.js"),[]).then(e=>pn(e.z80))}}),Ut.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Wt(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(e=>pn(e.mscgen))}}),Ut.of({name:"Xù",extensions:["xu"],load(){return Wt(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(e=>pn(e.xu))}}),Ut.of({name:"MsGenny",extensions:["msgenny"],load(){return Wt(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(e=>pn(e.msgenny))}}),Ut.of({name:"Vue",extensions:["vue"],load(){return Wt(()=>import("./index-VuYeSyL5.js"),__vite__mapDeps([14,0,1])).then(e=>e.vue())}}),Ut.of({name:"Angular Template",load(){return Wt(()=>import("./index-DFr2tnOE.js"),__vite__mapDeps([15,0,1])).then(e=>e.angular())}})],b8e="#2e3440",ume="#3b4252",y8e="#434c5e",oL="#4c566a",v8e="#e5e9f0",lae="#eceff4",yY="#8fbcbb",w8e="#88c0d0",Gin="#81a1c1",kp="#5e81ac",Yin="#bf616a",L8="#d08770",vY="#ebcb8b",k8e="#a3be8c",Jin="#b48ead",S8e="#d30102",fme=lae,wY=fme,ean="#ffffff",kY=ume,tan=fme,O8e=ume,nan=sr.theme({"&":{color:b8e,backgroundColor:ean},".cm-content":{caretColor:O8e},".cm-cursor, .cm-dropCursor":{borderLeftColor:O8e},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:tan},".cm-panels":{backgroundColor:fme,color:oL},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${oL}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:v8e},".cm-activeLine":{backgroundColor:wY},".cm-selectionMatch":{backgroundColor:v8e},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${oL}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:lae},".cm-gutters":{backgroundColor:lae,color:b8e,border:"none"},".cm-activeLineGutter":{backgroundColor:wY},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:kY},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:kY,borderBottomColor:kY},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:wY,color:oL}}},{dark:!1}),ran=Q9.define([{tag:Ge.keyword,color:kp},{tag:[Ge.name,Ge.deleted,Ge.character,Ge.propertyName,Ge.macroName],color:L8},{tag:[Ge.variableName],color:L8},{tag:[Ge.function(Ge.variableName)],color:kp},{tag:[Ge.labelName],color:Gin},{tag:[Ge.color,Ge.constant(Ge.name),Ge.standard(Ge.name)],color:kp},{tag:[Ge.definition(Ge.name),Ge.separator],color:k8e},{tag:[Ge.brace],color:yY},{tag:[Ge.annotation],color:S8e},{tag:[Ge.number,Ge.changed,Ge.annotation,Ge.modifier,Ge.self,Ge.namespace],color:w8e},{tag:[Ge.typeName,Ge.className],color:vY},{tag:[Ge.operator,Ge.operatorKeyword],color:k8e},{tag:[Ge.tagName],color:Jin},{tag:[Ge.squareBracket],color:Yin},{tag:[Ge.angleBracket],color:L8},{tag:[Ge.attributeName],color:vY},{tag:[Ge.regexp],color:kp},{tag:[Ge.quote],color:ume},{tag:[Ge.string],color:L8},{tag:Ge.link,color:yY,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Ge.url,Ge.escape,Ge.special(Ge.string)],color:L8},{tag:[Ge.meta],color:w8e},{tag:[Ge.comment],color:y8e,fontStyle:"italic"},{tag:Ge.strong,fontWeight:"bold",color:kp},{tag:Ge.emphasis,fontStyle:"italic",color:kp},{tag:Ge.strikethrough,textDecoration:"line-through"},{tag:Ge.heading,fontWeight:"bold",color:kp},{tag:Ge.special(Ge.heading1),fontWeight:"bold",color:kp},{tag:Ge.heading1,fontWeight:"bold",color:kp},{tag:[Ge.heading2,Ge.heading3,Ge.heading4],fontWeight:"bold",color:kp},{tag:[Ge.heading5,Ge.heading6],color:kp},{tag:[Ge.atom,Ge.bool,Ge.special(Ge.variableName)],color:L8},{tag:[Ge.processingInstruction,Ge.inserted],color:yY},{tag:[Ge.contentSeparator],color:vY},{tag:Ge.invalid,color:y8e,borderBottom:`1px dotted ${S8e}`}]),san=[nan,Khe(ran)],j8e=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class fO{constructor(t,n,r=0,s=t.length,a,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(r,s),this.bufferStart=r,this.normalize=a?l=>a(j8e(l)):j8e,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return bA(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let n=bhe(t),r=this.bufferStart+this.bufferPos;this.bufferPos+=E1(t);let s=this.normalize(n);if(s.length)for(let a=0,o=r;;a++){let l=s.charCodeAt(a),c=this.match(l,o,this.bufferPos+this.bufferStart);if(a==s.length-1){if(c)return this.value=c,this;break}o==r&&a<n.length&&n.charCodeAt(a)==l&&o++}}}match(t,n,r){let s=null;for(let a=0;a<this.matches.length;a+=2){let o=this.matches[a],l=!1;this.query.charCodeAt(o)==t&&(o==this.query.length-1?s={from:this.matches[a+1],to:r}:(this.matches[a]++,l=!0)),l||(this.matches.splice(a,2),a-=2)}return this.query.charCodeAt(0)==t&&(this.query.length==1?s={from:n,to:r}:this.matches.push(1,n)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(fO.prototype[Symbol.iterator]=function(){return this});const IXe={from:-1,to:-1,match:/.*/.exec("")},Ame="gm"+(/x/.unicode==null?"":"u");class TXe{constructor(t,n,r,s=0,a=t.length){if(this.text=t,this.to=a,this.curLine="",this.done=!1,this.value=IXe,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new _Xe(t,n,r,s,a);this.re=new RegExp(n,Ame+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.iter=t.iter();let o=t.lineAt(s);this.curLineStart=o.from,this.matchPos=CQ(t,s),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,s=r+n[0].length;if(this.matchPos=CQ(this.text,s+(r==s?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<s||r>this.value.to)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,match:n},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}}const SY=new WeakMap;class Lk{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let s=SY.get(t);if(!s||s.from>=r||s.to<=n){let l=new Lk(n,t.sliceString(n,r));return SY.set(t,l),l}if(s.from==n&&s.to==r)return s;let{text:a,from:o}=s;return o>n&&(a=t.sliceString(n,o)+a,o=n),s.to<r&&(a+=t.sliceString(s.to,r)),SY.set(t,new Lk(o,a)),new Lk(n,a.slice(n-o,r-o))}}class _Xe{constructor(t,n,r,s,a){this.text=t,this.to=a,this.done=!1,this.value=IXe,this.matchPos=CQ(t,s),this.re=new RegExp(n,Ame+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.flat=Lk.get(t,s,this.chunkEnd(s+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==t&&(this.re.lastIndex=t+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,s=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,match:n},this.matchPos=CQ(this.text,s+(r==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Lk.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(TXe.prototype[Symbol.iterator]=_Xe.prototype[Symbol.iterator]=function(){return this});function ian(e){try{return new RegExp(e,Ame),!0}catch{return!1}}function CQ(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}const aan=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:s}=xtn(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return s.then(a=>{let o=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!o){e.dispatch({effects:r});return}let l=t.doc.lineAt(t.selection.main.head),[,c,d,u,f]=o,A=u?+u.slice(1):0,h=d?+d:l.number;if(d&&f){let y=h/100;c&&(y=y*(c=="-"?-1:1)+l.number/t.doc.lines),h=Math.round(t.doc.lines*y)}else d&&c&&(h=h*(c=="-"?-1:1)+l.number);let g=t.doc.line(Math.max(1,Math.min(t.doc.lines,h))),x=sn.cursor(g.from+Math.max(0,Math.min(A,g.length)));e.dispatch({effects:[r,sr.scrollIntoView(x.from,{y:"center"})],selection:x})}),!0},oan={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},lan=Ar.define({combine(e){return Sx(e,oan,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function can(e){return[han,Aan]}const dan=Jr.mark({class:"cm-selectionMatch"}),uan=Jr.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function C8e(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=pl.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=pl.Word)}function fan(e,t,n,r){return e(t.sliceDoc(n,n+1))==pl.Word&&e(t.sliceDoc(r-1,r))==pl.Word}const Aan=mc.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(lan),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Jr.none;let s=r.main,a,o=null;if(s.empty){if(!t.highlightWordAroundCursor)return Jr.none;let c=n.wordAt(s.head);if(!c)return Jr.none;o=n.charCategorizer(s.head),a=n.sliceDoc(c.from,c.to)}else{let c=s.to-s.from;if(c<t.minSelectionLength||c>200)return Jr.none;if(t.wholeWords){if(a=n.sliceDoc(s.from,s.to),o=n.charCategorizer(s.head),!(C8e(o,n,s.from,s.to)&&fan(o,n,s.from,s.to)))return Jr.none}else if(a=n.sliceDoc(s.from,s.to),!a)return Jr.none}let l=[];for(let c of e.visibleRanges){let d=new fO(n.doc,a,c.from,c.to);for(;!d.next().done;){let{from:u,to:f}=d.value;if((!o||C8e(o,n,u,f))&&(s.empty&&u<=s.from&&f>=s.to?l.push(uan.range(u,f)):(u>=s.to||f<=s.from)&&l.push(dan.range(u,f)),l.length>t.maxMatches))return Jr.none}}return Jr.set(l)}},{decorations:e=>e.decorations}),han=sr.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),man=({state:e,dispatch:t})=>{let{selection:n}=e,r=sn.create(n.ranges.map(s=>e.wordAt(s.head)||sn.cursor(s.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function pan(e,t){let{main:n,ranges:r}=e.selection,s=e.wordAt(n.head),a=s&&s.from==n.from&&s.to==n.to;for(let o=!1,l=new fO(e.doc,t,r[r.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new fO(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),o=!0}else{if(o&&r.some(c=>c.from==l.value.from))continue;if(a){let c=e.wordAt(l.value.from);if(!c||c.from!=l.value.from||c.to!=l.value.to)continue}return l.value}}const gan=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(a=>a.from===a.to))return man({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(a=>e.sliceDoc(a.from,a.to)!=r))return!1;let s=pan(e,r);return s?(t(e.update({selection:e.selection.addRange(sn.range(s.from,s.to),!1),effects:sr.scrollIntoView(s.to)})),!0):!1},q9=Ar.define({combine(e){return Sx(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new Tan(t),scrollToMatch:t=>sr.scrollIntoView(t)})}});class MXe{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||ian(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
|
|
1786
1786
|
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new kan(this):new yan(this)}getCursor(t,n=0,r){let s=t.doc?t:tl.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?j7(this,s,n,r):O7(this,s,n,r)}}class EXe{constructor(t){this.spec=t}}function xan(e,t,n){return(r,s,a,o)=>{if(n&&!n(r,s,a,o))return!1;let l=r>=o&&s<=o+a.length?a.slice(r-o,s-o):t.doc.sliceString(r,s);return e(l,t,r,s)}}function O7(e,t,n,r){let s;return e.wholeWord&&(s=ban(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=xan(e.test,t,s)),new fO(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function ban(e,t){return(n,r,s,a)=>((a>n||a+s.length<r)&&(a=Math.max(0,n-2),s=e.sliceString(a,Math.min(e.length,r+2))),(t(NQ(s,n-a))!=pl.Word||t(PQ(s,n-a))!=pl.Word)&&(t(PQ(s,r-a))!=pl.Word||t(NQ(s,r-a))!=pl.Word))}class yan extends EXe{constructor(t){super(t)}nextMatch(t,n,r){let s=O7(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=O7(this.spec,t,0,a).nextOverlapping()}return s.done||s.value.from==n&&s.value.to==r?null:s.value}prevMatchInRange(t,n,r){for(let s=r;;){let a=Math.max(n,s-1e4-this.spec.unquoted.length),o=O7(this.spec,t,a,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(a==n)return null;s-=1e4}}prevMatch(t,n,r){let s=this.prevMatchInRange(t,0,n);return s||(s=this.prevMatchInRange(t,Math.max(0,r-this.spec.unquoted.length),t.doc.length)),s&&(s.from!=n||s.to!=r)?s:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,n){let r=O7(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=O7(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}function van(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function j7(e,t,n,r){let s;return e.wholeWord&&(s=wan(t.charCategorizer(t.selection.main.head))),e.test&&(s=van(e.test,t,s)),new TXe(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function NQ(e,t){return e.slice(Td(e,t,!1),t)}function PQ(e,t){return e.slice(t,Td(e,t))}function wan(e){return(t,n,r)=>!r[0].length||(e(NQ(r.input,r.index))!=pl.Word||e(PQ(r.input,r.index))!=pl.Word)&&(e(PQ(r.input,r.index+r[0].length))!=pl.Word||e(NQ(r.input,r.index+r[0].length))!=pl.Word)}class kan extends EXe{nextMatch(t,n,r){let s=j7(this.spec,t,r,t.doc.length).next();return s.done&&(s=j7(this.spec,t,0,n).next()),s.done?null:s.value}prevMatchInRange(t,n,r){for(let s=1;;s++){let a=Math.max(n,r-s*1e4),o=j7(this.spec,t,a,r),l=null;for(;!o.next().done;)l=o.value;if(l&&(a==n||l.from>a+10))return l;if(a==n)return null}}prevMatch(t,n,r){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,r,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return t.match[0];if(r=="$")return"$";for(let s=r.length;s>0;s--){let a=+r.slice(0,s);if(a>0&&a<t.match.length)return t.match[a]+r.slice(s)}return n})}matchAll(t,n){let r=j7(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=j7(this.spec,t,Math.max(0,n-250),Math.min(r+250,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const AT=Qs.define(),hme=Qs.define(),_v=bu.define({create(e){return new OY(cae(e).create(),null)},update(e,t){for(let n of t.effects)n.is(AT)?e=new OY(n.value.create(),e.panel):n.is(hme)&&(e=new OY(e.query,n.value?mme:null));return e},provide:e=>iT.from(e,t=>t.panel)});class OY{constructor(t,n){this.query=t,this.panel=n}}const San=Jr.mark({class:"cm-searchMatch"}),Oan=Jr.mark({class:"cm-searchMatch cm-searchMatch-selected"}),jan=mc.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(_v))}update(e){let t=e.state.field(_v);(t!=e.startState.field(_v)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Jr.none;let{view:n}=this,r=new E2;for(let s=0,a=n.visibleRanges,o=a.length;s<o;s++){let{from:l,to:c}=a[s];for(;s<o-1&&c>a[s+1].from-500;)c=a[++s].to;e.highlight(n.state,l,c,(d,u)=>{let f=n.state.selection.ranges.some(A=>A.from==d&&A.to==u);r.add(d,u,f?Oan:San)})}return r.finish()}},{decorations:e=>e.decorations});function dE(e){return t=>{let n=t.state.field(_v,!1);return n&&n.query.spec.valid?e(t,n):LXe(t)}}const IQ=dE((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=sn.single(r.from,r.to),a=e.state.facet(q9);return e.dispatch({selection:s,effects:[pme(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),RXe(e),!0}),TQ=dE((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=sn.single(s.from,s.to),o=e.state.facet(q9);return e.dispatch({selection:a,effects:[pme(e,s),o.scrollToMatch(a.main,e)],userEvent:"select.search"}),RXe(e),!0}),Can=dE((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:sn.create(n.map(r=>sn.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),Nan=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:s}=n.main,a=[],o=0;for(let l=new fO(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(o=a.length),a.push(sn.range(l.value.from,l.value.to))}return t(e.update({selection:sn.create(a,o),userEvent:"select.search.matches"})),!0},N8e=dE((e,{query:t})=>{let{state:n}=e,{from:r,to:s}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,l=[],c,d,u=[];o.from==r&&o.to==s&&(d=n.toText(t.getReplacement(o)),l.push({from:o.from,to:o.to,insert:d}),o=t.nextMatch(n,o.from,o.to),u.push(sr.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let f=e.state.changes(l);return o&&(c=sn.single(o.from,o.to).map(f),u.push(pme(e,o)),u.push(n.facet(q9).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:u,userEvent:"input.replace"}),!0}),Pan=dE((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(s=>{let{from:a,to:o}=s;return{from:a,to:o,insert:t.getReplacement(s)}});if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:sr.announce.of(r),userEvent:"input.replace.all"}),!0});function mme(e){return e.state.facet(q9).createPanel(e)}function cae(e,t){var n,r,s,a,o;let l=e.selection.main,c=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!c)return t;let d=e.facet(q9);return new MXe({search:((n=t==null?void 0:t.literal)!==null&&n!==void 0?n:d.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(r=t==null?void 0:t.caseSensitive)!==null&&r!==void 0?r:d.caseSensitive,literal:(s=t==null?void 0:t.literal)!==null&&s!==void 0?s:d.literal,regexp:(a=t==null?void 0:t.regexp)!==null&&a!==void 0?a:d.regexp,wholeWord:(o=t==null?void 0:t.wholeWord)!==null&&o!==void 0?o:d.wholeWord})}function DXe(e){let t=Lhe(e,mme);return t&&t.dom.querySelector("[main-field]")}function RXe(e){let t=DXe(e);t&&t==e.root.activeElement&&t.select()}const LXe=e=>{let t=e.state.field(_v,!1);if(t&&t.panel){let n=DXe(e);if(n&&n!=e.root.activeElement){let r=cae(e.state,t.query.spec);r.valid&&e.dispatch({effects:AT.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[hme.of(!0),t?AT.of(cae(e.state,t.query.spec)):Qs.appendConfig.of(Man)]});return!0},zXe=e=>{let t=e.state.field(_v,!1);if(!t||!t.panel)return!1;let n=Lhe(e,mme);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:hme.of(!1)}),!0},Ian=[{key:"Mod-f",run:LXe,scope:"editor search-panel"},{key:"F3",run:IQ,shift:TQ,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:IQ,shift:TQ,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:zXe,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Nan},{key:"Mod-Alt-g",run:aan},{key:"Mod-d",run:gan,preventDefault:!0}];class Tan{constructor(t){this.view=t;let n=this.query=t.state.field(_v).query.spec;this.commit=this.commit.bind(this),this.searchField=lo("input",{value:n.search,placeholder:sh(t,"Find"),"aria-label":sh(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=lo("input",{value:n.replace,placeholder:sh(t,"Replace"),"aria-label":sh(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=lo("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=lo("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=lo("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,o){return lo("button",{class:"cm-button",name:s,onclick:a,type:"button"},o)}this.dom=lo("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>IQ(t),[sh(t,"next")]),r("prev",()=>TQ(t),[sh(t,"previous")]),r("select",()=>Can(t),[sh(t,"all")]),lo("label",null,[this.caseField,sh(t,"match case")]),lo("label",null,[this.reField,sh(t,"regexp")]),lo("label",null,[this.wordField,sh(t,"by word")]),...t.state.readOnly?[]:[lo("br"),this.replaceField,r("replace",()=>N8e(t),[sh(t,"replace")]),r("replaceAll",()=>Pan(t),[sh(t,"replace all")])],lo("button",{name:"close",onclick:()=>zXe(t),"aria-label":sh(t,"close"),type:"button"},["×"])])}commit(){let t=new MXe({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:AT.of(t)}))}keydown(t){Ien(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?TQ:IQ)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),N8e(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(AT)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(q9).top}}function sh(e,t){return e.state.phrase(t)}const lL=30,cL=/[\s\.,:;?!]/;function pme(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),s=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-lL),o=Math.min(s,n+lL),l=e.state.sliceDoc(a,o);if(a!=r.from){for(let c=0;c<lL;c++)if(!cL.test(l[c+1])&&cL.test(l[c])){l=l.slice(c);break}}if(o!=s){for(let c=l.length-1;c>l.length-lL;c--)if(!cL.test(l[c-1])&&cL.test(l[c])){l=l.slice(0,c);break}}return sr.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const _an=sr.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Man=[_v,Q3.low(jan),_an];class P8e{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class Z5{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(hT).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((h,g)=>h.from-g.from||h.to-g.to),o=new E2,l=[],c=0,d=r.doc.iter(),u=0,f=r.doc.length;for(let h=0;;){let g=h==a.length?null:a[h];if(!g&&!l.length)break;let x,y;if(l.length)x=c,y=l.reduce((k,O)=>Math.min(k,O.to),g&&g.from>x?g.from:1e8);else{if(x=g.from,x>f)break;y=g.to,l.push(g),h++}for(;h<a.length;){let k=a[h];if(k.from==x&&(k.to>k.from||k.to==x))l.push(k),h++,y=Math.min(k.to,y);else{y=Math.min(k.from,y);break}}y=Math.min(y,f);let v=!1;if(l.some(k=>k.from==x&&(k.to==y||y==f))&&(v=x==y,!v&&y-x<10)){let k=x-(u+d.value.length);k>0&&(d.next(k),u=x);for(let O=x;;){if(O>=y){v=!0;break}if(!d.lineBreak&&u+d.value.length>O)break;O=u+d.value.length,u+=d.value.length,d.next()}}let w=Kan(l);if(v)o.add(x,x,Jr.widget({widget:new Qan(w),diagnostics:l.slice()}));else{let k=l.reduce((O,j)=>j.markClass?O+" "+j.markClass:O,"");o.add(x,y,Jr.mark({class:"cm-lintRange cm-lintRange-"+w+k,diagnostics:l.slice(),inclusiveEnd:l.some(O=>O.to>y)}))}if(c=y,c==f)break;for(let k=0;k<l.length;k++)l[k].to<=c&&l.splice(k--,1)}let A=o.finish();return new Z5(A,n,d3(A))}}function d3(e,t=null,n=0){let r=null;return e.between(n,1e9,(s,a,{spec:o})=>{if(!(t&&o.diagnostics.indexOf(t)<0))if(!r)r=new P8e(s,a,t||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new P8e(r.from,a,r.diagnostic)}}),r}function Ean(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(hT).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(o=>o.is($Xe))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Dan(e,t){return e.field(Oh,!1)?t:t.concat(Qs.appendConfig.of(Wan))}const $Xe=Qs.define(),gme=Qs.define(),FXe=Qs.define(),Oh=bu.define({create(){return new Z5(Jr.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,s=e.panel;if(e.selected){let a=t.changes.mapPos(e.selected.from,1);r=d3(n,e.selected.diagnostic,a)||d3(n,null,a)}!n.size&&s&&t.state.facet(hT).autoPanel&&(s=null),e=new Z5(n,s,r)}for(let n of t.effects)if(n.is($Xe)){let r=t.state.facet(hT).autoPanel?n.value.length?mT.open:null:e.panel;e=Z5.init(n.value,r,t.state)}else n.is(gme)?e=new Z5(e.diagnostics,n.value?mT.open:null,e.selected):n.is(FXe)&&(e=new Z5(e.diagnostics,e.panel,n.value));return e},provide:e=>[iT.from(e,t=>t.panel),sr.decorations.from(e,t=>t.diagnostics)]}),Ran=Jr.mark({class:"cm-lintRange cm-lintRange-active"});function Lan(e,t,n){let{diagnostics:r}=e.state.field(Oh),s,a=-1,o=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(c,d,{spec:u})=>{if(t>=c&&t<=d&&(c==d||(t>c||n>0)&&(t<d||n<0)))return s=u.diagnostics,a=c,o=d,!1});let l=e.state.facet(hT).tooltipFilter;return s&&l&&(s=l(s,e.state)),s?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:zan(e,s)}}}:null}function zan(e,t){return lo("ul",{class:"cm-tooltip-lint"},t.map(n=>QXe(e,n,!1)))}const $an=e=>{let t=e.state.field(Oh,!1);(!t||!t.panel)&&e.dispatch({effects:Dan(e.state,[gme.of(!0)])});let n=Lhe(e,mT.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},I8e=e=>{let t=e.state.field(Oh,!1);return!t||!t.panel?!1:(e.dispatch({effects:gme.of(!1)}),!0)},Fan=e=>{let t=e.state.field(Oh,!1);if(!t)return!1;let n=e.state.selection.main,r=d3(t.diagnostics,null,n.to+1);return!r&&(r=d3(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},Ban=[{key:"Mod-Shift-m",run:$an,preventDefault:!0},{key:"F8",run:Fan}],hT=Ar.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...Sx(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:T8e,tooltipFilter:T8e,needsRefresh:(t,n)=>t?n?r=>t(r)||n(r):t:n,hideOn:(t,n)=>t?n?(r,s,a)=>t(r,s,a)||n(r,s,a):t:n,autoPanel:(t,n)=>t||n})}}});function T8e(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function BXe(e){let t=[];if(e)e:for(let{name:n}of e){for(let r=0;r<n.length;r++){let s=n[r];if(/[a-zA-Z]/.test(s)&&!t.some(a=>a.toLowerCase()==s.toLowerCase())){t.push(s);continue e}}t.push("")}return t}function QXe(e,t,n){var r;let s=n?BXe(t.actions):[];return lo("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},lo("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(r=t.actions)===null||r===void 0?void 0:r.map((a,o)=>{let l=!1,c=h=>{if(h.preventDefault(),l)return;l=!0;let g=d3(e.state.field(Oh).diagnostics,t);g&&a.apply(e,g.from,g.to)},{name:d}=a,u=s[o]?d.indexOf(s[o]):-1,f=u<0?d:[d.slice(0,u),lo("u",d.slice(u,u+1)),d.slice(u+1)],A=a.markClass?" "+a.markClass:"";return lo("button",{type:"button",class:"cm-diagnosticAction"+A,onclick:c,onmousedown:c,"aria-label":` Action: ${d}${u<0?"":` (access key "${s[o]})"`}.`},f)}),t.source&&lo("div",{class:"cm-diagnosticSource"},t.source))}class Qan extends Ox{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return lo("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class _8e{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=QXe(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class mT{constructor(t){this.view=t,this.items=[];let n=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)I8e(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:a}=this.items[this.selectedIndex],o=BXe(a.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=d3(this.view.state.field(Oh).diagnostics,a);c&&a.actions[l].apply(t,c.from,c.to)}}else return;s.preventDefault()}},r=s=>{for(let a=0;a<this.items.length;a++)this.items[a].dom.contains(s.target)&&this.moveSelection(a)};this.list=lo("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=lo("div",{class:"cm-panel-lint"},this.list,lo("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>I8e(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(Oh).selected;if(!t)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==t.diagnostic)return n;return-1}update(){let{diagnostics:t,selected:n}=this.view.state.field(Oh),r=0,s=!1,a=null,o=new Set;for(t.between(0,this.view.state.doc.length,(l,c,{spec:d})=>{for(let u of d.diagnostics){if(o.has(u))continue;o.add(u);let f=-1,A;for(let h=r;h<this.items.length;h++)if(this.items[h].diagnostic==u){f=h;break}f<0?(A=new _8e(this.view,u),this.items.splice(r,0,A),s=!0):(A=this.items[f],f>r&&(this.items.splice(r,f-r),s=!0)),n&&A.diagnostic==n.diagnostic?A.dom.hasAttribute("aria-selected")||(A.dom.setAttribute("aria-selected","true"),a=A):A.dom.hasAttribute("aria-selected")&&A.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new _8e(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),a?(this.list.setAttribute("aria-activedescendant",a.id),this.view.requestMeasure({key:this,read:()=>({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:c})=>{let d=c.height/this.list.offsetHeight;l.top<c.top?this.list.scrollTop-=(c.top-l.top)/d:l.bottom>c.bottom&&(this.list.scrollTop+=(l.bottom-c.bottom)/d)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let t=this.list.firstChild;function n(){let r=t;t=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;t!=r.dom;)n();t=r.dom.nextSibling}else this.list.insertBefore(r.dom,t);for(;t;)n()}moveSelection(t){if(this.selectedIndex<0)return;let n=this.view.state.field(Oh),r=d3(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:FXe.of(r)})}static open(t){return new mT(t)}}function Uan(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function dL(e){return Uan(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Van=sr.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:dL("#d11")},".cm-lintRange-warning":{backgroundImage:dL("orange")},".cm-lintRange-info":{backgroundImage:dL("#999")},".cm-lintRange-hint":{backgroundImage:dL("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function qan(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function Kan(e){let t="hint",n=1;for(let r of e){let s=qan(r.severity);s>n&&(n=s,t=r.severity)}return t}const Wan=[Oh,sr.decorations.compute([Oh],e=>{let{selected:t,panel:n}=e.field(Oh);return!t||!n||t.from==t.to?Jr.none:Jr.set([Ran.range(t.from,t.to)])}),ptn(Lan,{hideOn:Ean}),Van],UXe=[GZe(),Ttn(),Wen(),Xrn(),Snn(),Ren(),Ben(),tl.allowMultipleSelections.of(!0),unn(),Khe(Nnn,{fallback:!0}),Dnn(),Nrn(),$rn(),itn(),ltn(),Jen(),can(),$9.of([..._rn,...Ysn,...Ian,...isn,...ynn,...RHe,...Ban])],Zan=ge.forwardRef(({title:e,children:t},n)=>{const r=dx(_6);return ge.createElement(qce,{delayDuration:100},ge.createElement(Kce,null,ge.createElement(Wce,{ref:n,asChild:!0},ge.createElement("span",{className:Mn.tooltipTrigger},t)),ge.createElement(Zce,{container:r==null?void 0:r.current},ge.createElement(Hce,{className:uo(Mn.tooltipContent),sideOffset:10},e))))}),Han=ge.forwardRef(({children:e,className:t,...n},r)=>ge.createElement(rEe,{...n,ref:r,className:uo(t,Mn.selectItem)},ge.createElement(sEe,null,e))),Xan=({title:e,placeholder:t,className:n})=>{const[r,s]=Pg(Sg,J2);return ge.createElement(Zan,{title:e},ge.createElement(GMe,{"aria-label":t,className:uo(Mn.selectTrigger,n),"data-toolbar-item":!0,disabled:r},ge.createElement(YMe,{placeholder:t}),ge.createElement(JMe,{className:Mn.selectDropdownArrow},s("arrow_drop_down"))))},Gan=({children:e,className:t=Mn.selectContainer})=>{const n=dx(_6);return ge.createElement(eEe,{container:n==null?void 0:n.current},ge.createElement(tEe,{className:uo(t,"mdxeditor-select-content"),onCloseAutoFocus:r=>{r.preventDefault()},position:"popper"},ge.createElement(nEe,{"data-editor-dropdown":!0,style:{maxHeight:"var(--radix-select-content-available-height)"}},e)))},Yan=e=>ge.createElement(XMe,{value:e.value||"",onValueChange:e.onChange,disabled:e.disabled},ge.createElement(Xan,{title:e.triggerTitle,placeholder:e.placeholder}),ge.createElement(Gan,null,e.items.map((t,n)=>t==="separator"?ge.createElement(b1t,{key:n}):ge.createElement(Han,{key:n,value:t.value},t.label)))),VXe=({language:e,nodeKey:t,code:n,focusEmitter:r})=>{const s=eb(),{parentEditor:a,lexicalNode:o}=aie(),[l,c,d,u,f]=Pg(Sg,Aae,hae,J2,fae),A=Hin(t,"codeblock",e,r),{setCode:h}=aie(),g=ge.useRef(null),x=ge.useRef(null),y=ge.useRef(h);return y.current=h,A.current={getCodemirror:()=>g.current},ge.useEffect(()=>{const v=x.current;return(async()=>{const w=[...c,UXe,san,GZe(),$9.of([Jsn]),sr.lineWrapping,sr.updateListener.of(({state:k})=>{y.current(k.doc.toString())}),sr.domEventHandlers({focus:()=>{a.update(()=>{qm(null)})}})];if(l&&w.push(tl.readOnly.of(!0)),e!==""&&d){const k=Xin.find(O=>O.name===e||O.alias.includes(e)||O.extensions.includes(e));if(k)try{const O=await k.load();w.push(O.extension)}catch{console.warn("failed to load language support for",e)}}v.innerHTML="",g.current=new sr({parent:v,state:tl.create({doc:n,extensions:w})}),v.addEventListener("keydown",M8e)})(),()=>{var w;(w=g.current)==null||w.destroy(),g.current=null,v.removeEventListener("keydown",M8e)}},[l,e,...c]),ge.createElement("div",{className:Mn.codeMirrorWrapper},ge.createElement("div",{className:Mn.codeMirrorToolbar},ge.createElement(Yan,{disabled:l,value:f.keyMap[e]??e,onChange:v=>{a.update(()=>{o.setLanguage(v===dae?"":v),setTimeout(()=>{a.update(()=>{o.getLatest().select()})})})},triggerTitle:s("codeBlock.selectLanguage","Select code block language"),placeholder:s("codeBlock.inlineLanguage","Language"),items:f.items}),ge.createElement("button",{className:Mn.iconButton,type:"button",disabled:l,title:s("codeblock.delete","Delete code block"),onClick:v=>{v.preventDefault(),a.update(()=>{o.remove()})}},u("delete_small"))),ge.createElement("div",{ref:x}))};function M8e(e){e.stopPropagation()}const dae="__EMPTY_VALUE__";function uae(e){var t;const n=[],r={};if(Array.isArray(e))for(const s of e){const a=((t=s.alias)==null?void 0:t[0])??s.name.toLowerCase();if(n.push({value:a,label:s.name}),r[a]=a,s.alias)for(const o of s.alias)r[o]=a;if(s.extensions)for(const o of s.extensions)r[o]=a;r[s.name.toLowerCase()]=a}else{const s={};for(const[a,o]of Object.entries(e))o in s||(s[o]=a,n.push({value:a||dae,label:o})),r[a]=s[o]||dae}return{items:n,keyMap:r}}const fae=gr(uae({js:"JavaScript",ts:"TypeScript",tsx:"TypeScript (React)",jsx:"JavaScript (React)",css:"CSS"})),Jan=xc(e=>{e.link(e.pipe(Jan,Gv(({language:t,code:n})=>({code:n,language:t,meta:""}))),kWe)}),Aae=gr([]),hae=gr(!0),eon=xu({update(e,t){e.pubIn({[fae]:uae((t==null?void 0:t.codeBlockLanguages)??{}),[Aae]:(t==null?void 0:t.codeMirrorExtensions)??[],[hae]:(t==null?void 0:t.autoLoadLanguageSupport)??!0})},init(e,t){const n=uae((t==null?void 0:t.codeBlockLanguages)??{});e.pubIn({[fae]:n,[Aae]:(t==null?void 0:t.codeMirrorExtensions)??[],[kYt]:ton(n),[hae]:(t==null?void 0:t.autoLoadLanguageSupport)??!0})}});function ton(e){return{match(t,n){return Object.hasOwn(e.keyMap,t??"")&&!n},priority:1,Editor:VXe}}function non({url:e,title:t,text:n,onSubmit:r,onCancel:s,linkAutocompleteSuggestions:a,showLinkTitleField:o,showAnchorTextField:l}){const{register:c,handleSubmit:d,control:u,setValue:f,reset:A}=YKe({values:{url:e,title:t,text:n}}),h=eb();return ge.createElement("form",{onSubmit:g=>{d(r)(g),g.stopPropagation(),g.preventDefault()},onReset:g=>{g.stopPropagation(),s()},onKeyDown:g=>{g.key==="Escape"&&(g.stopPropagation(),s())},className:uo(Mn.multiFieldForm,Mn.linkDialogEditForm)},ge.createElement("div",{className:Mn.formField},ge.createElement("label",{htmlFor:"link-url"},h("createLink.url","URL")),ge.createElement(pWe,{register:c,initialInputValue:e,inputName:"url",suggestions:a,setValue:f,control:u,placeholder:h("createLink.urlPlaceholder","Select or paste an URL"),autofocus:!0})),l?ge.createElement("div",{className:Mn.formField},ge.createElement("label",{htmlFor:"link-text",title:h("createLink.textTooltip","The text to be displayed for the link")},h("createLink.text","Anchor text")),ge.createElement("input",{id:"link-text",className:Mn.textInput,size:40,...c("text")})):null,o?ge.createElement("div",{className:Mn.formField},ge.createElement("label",{htmlFor:"link-title",title:h("createLink.titleTooltip","The link's title attribute, shown on hover")},h("createLink.title","Link title")),ge.createElement("input",{id:"link-title",className:Mn.textInput,size:40,...c("title")})):null,ge.createElement("div",{style:{display:"flex",justifyContent:"flex-end",gap:"var(--spacing-2)"}},ge.createElement("button",{type:"submit",title:h("createLink.saveTooltip","Set URL"),"aria-label":h("createLink.saveTooltip","Set URL"),className:uo(Mn.primaryButton)},h("dialogControls.save","Save")),ge.createElement("button",{type:"reset",title:h("createLink.cancelTooltip","Cancel change"),"aria-label":h("createLink.cancelTooltip","Cancel change"),className:uo(Mn.secondaryButton)},h("dialogControls.cancel","Cancel"))))}const ron=()=>{const[e,t,n,r,s,a,o]=Pg(_6,ml,J2,cA,GXe,YXe,eGe),l=yh(qXe),c=yh(KXe),d=yh(WXe),u=yh(ZXe),f=yh(HXe);ge.useEffect(()=>{const v=()=>{t==null||t.getEditorState().read(()=>{l(!0)})};return window.addEventListener("resize",v),window.addEventListener("scroll",v),()=>{window.removeEventListener("resize",v),window.removeEventListener("scroll",v)}},[t,l]);const[A,h]=ge.useState(!1),g=eb();if(r.type==="inactive")return null;const x=r.rectangle,y=r.type==="preview"&&r.url.startsWith("http");return ge.createElement(qV,{open:!0},ge.createElement(oMe,{"data-visible":r.type==="edit",className:Mn.linkDialogAnchor,style:{top:`${x.top}px`,left:`${x.left}px`,width:`${x.width}px`,height:`${x.height}px`}}),ge.createElement(KV,{container:e==null?void 0:e.current},ge.createElement(lMe,{className:uo(Mn.linkDialogPopoverContent),sideOffset:5,onOpenAutoFocus:v=>{v.preventDefault()},key:r.linkNodeKey},r.type==="edit"&&ge.createElement(non,{url:r.url,title:r.title,text:r.text,onSubmit:c,onCancel:d.bind(null),linkAutocompleteSuggestions:s,showLinkTitleField:o,showAnchorTextField:r.withAnchorText}),r.type==="preview"&&ge.createElement(ge.Fragment,null,ge.createElement("a",{className:Mn.linkDialogPreviewAnchor,href:r.url,...y?{target:"_blank",rel:"noreferrer"}:{},onClick:v=>{a!==null&&(v.preventDefault(),a(r.url))},title:y?g("linkPreview.open","Open {{url}} in new window",{url:r.url}):r.url},ge.createElement("span",null,r.url),y&&n("open_in_new")),ge.createElement(jY,{onClick:()=>{u()},title:g("linkPreview.edit","Edit link URL"),"aria-label":g("linkPreview.edit","Edit link URL")},n("edit")),ge.createElement(qce,null,ge.createElement(Kce,{open:A},ge.createElement(Wce,{asChild:!0},ge.createElement(jY,{title:g("linkPreview.copyToClipboard","Copy to clipboard"),"aria-label":g("linkPreview.copyToClipboard","Copy to clipboard"),onClick:()=>{window.navigator.clipboard.writeText(r.url).then(()=>{h(!0),setTimeout(()=>{h(!1)},1e3)})}},n(A?"check":"content_copy"))),ge.createElement(Zce,{container:e==null?void 0:e.current},ge.createElement(Hce,{className:uo(Mn.tooltipContent),sideOffset:5},g("linkPreview.copied","Copied!"),ge.createElement(KEe,null))))),ge.createElement(jY,{title:g("linkPreview.remove","Remove link"),"aria-label":g("linkPreview.remove","Remove link"),onClick:()=>{f()}},n("link_off"))),ge.createElement(Mce,{className:Mn.popoverArrow}))))},jY=ge.forwardRef(({className:e,...t},n)=>ge.createElement("button",{className:uo(Mn.actionButton,e),ref:n,...t}));function mae(e){if(!e)return null;const t=mHt(e);if(t===null)return null;const n=t.getParent();return jf(n)?n:jf(t)?t:null}const qXe=xc(),cA=gr({type:"inactive"},e=>{e.pub(WI,t=>t.registerCommand(MK,()=>e.getValue(cA).type==="preview"?(e.pub(cA,{type:"inactive"}),!0):!1,$o)),e.sub(e.pipe(ZI),t=>{t!=="rich-text"&&e.pub(cA,{type:"inactive"})}),e.pub(WI,t=>t.registerCommand(JVe,n=>{if(n.key==="k"&&(CKe?n.metaKey:n.ctrlKey)&&!e.getValue(Sg)){const r=xr();return Ir(r)?(e.pub(XXe),n.stopPropagation(),n.preventDefault(),!0):!1}return!1},UI)),e.sub(e.pipe(ZXe,Tl(cA,ml)),([,t,n])=>{if(t.type==="preview")setTimeout(()=>{n==null||n.getEditorState().read(()=>{const r=ex(t.linkNodeKey),s=jf(r)?r.getTextContent().length>0&&r.getChildrenSize()<=1:!1,a=s&&r?r.getTextContent():"";e.pub(cA,{type:"edit",initialUrl:t.url,url:t.url,title:t.title,text:a,withAnchorText:s,linkNodeKey:t.linkNodeKey,rectangle:t.rectangle})})});else throw new Error("Cannot switch to edit mode when not in preview mode")}),e.sub(e.pipe(KXe,Tl(ml,cA,rO)),([t,n,r,s])=>{var a,o,l;const c=((a=t.text)==null?void 0:a.trim())??"",d=((o=t.url)==null?void 0:o.trim())??"",u=((l=t.title)==null?void 0:l.trim())??"";if(d!==""){if(s!=null&&s.isCollapsed()){const f=c||u||d;n==null||n.update(()=>{const A=mae(s);if(A)if(Vp(A)){const h=M2(d,{title:u});h.append(zm(c)),A.replace(h),h.select()}else A.setURL(d),A.setTitle(u),E8e(A.getFirstChild(),c);else{const h=M2(d,{title:u});h.append(zm(f)),T9([h]),h.select()}},{discrete:!0})}else n==null||n.update(()=>{E8e(s==null?void 0:s.anchor.getNode(),c)}),n==null||n.dispatchCommand(sO,{url:d,title:u});e.pub(cA,{type:"preview",linkNodeKey:r.linkNodeKey,rectangle:r.rectangle,title:u,url:d})}else r.type==="edit"&&r.initialUrl!==""&&(n==null||n.dispatchCommand(sO,null)),e.pub(cA,{type:"inactive"})}),e.link(e.pipe(WXe,Tl(cA,ml),Gv(([,t,n])=>{if(t.type==="edit")return n==null||n.focus(),t.initialUrl===""?{type:"inactive"}:{type:"preview",url:t.initialUrl,linkNodeKey:t.linkNodeKey,rectangle:t.rectangle};throw new Error("Cannot cancel edit when not in edit mode")})),cA),e.link(e.pipe(e.combine(rO,qXe),Tl(ml,cA,Sg),Gv(([[t],n,r,s])=>{if(Ir(t)&&n&&!s){const a=mae(t);if(!t.isCollapsed())return{type:"inactive"};if(a){const o=SKe(n);return o?{type:"preview",url:a.getURL(),linkNodeKey:a.getKey(),title:a.getTitle(),rectangle:o}:{type:"inactive"}}else return{type:"inactive"}}else return{type:"inactive"}})),cA)}),KXe=xc(),WXe=z3();z3();const ZXe=z3(),HXe=z3(e=>{e.sub(e.pipe(HXe,Tl(ml)),([,t])=>{t==null||t.dispatchCommand(sO,null)})}),XXe=z3(e=>{e.sub(e.pipe(XXe,Tl(rO,ml),UM(([,t])=>Ir(t))),([,t,n])=>{n==null||n.focus(()=>{setTimeout(()=>{n.getEditorState().read(()=>{const r=mae(t),s=SKe(n),a=(r==null?void 0:r.getURL())??"",o=(r==null?void 0:r.getURL())??"",l=(r==null?void 0:r.getTitle())??"",c=(r==null?void 0:r.getKey())??"",d=r?r.getTextContent().length>0&&r.getChildrenSize()<=1:!!(t!=null&&t.isCollapsed()),u=d&&r?r.getTextContent():"";e.pub(cA,{type:"edit",initialUrl:a,url:o,title:l,text:u,withAnchorText:d,linkNodeKey:c,rectangle:s})})})})})}),GXe=gr([]),YXe=gr(null),JXe=gr(null,e=>{e.pub(WI,t=>{function n(r){const[s,a]=e.getValues([Sg,JXe]);!s||a===null||t.update(()=>{const o=q4(r.target);if(o!==null){const l=lg(o,c=>c instanceof Mg);l!==null&&a(r,l,l.getURL())}})}return t.registerRootListener((r,s)=>{r&&r.addEventListener("click",n),s&&s.removeEventListener("click",n)})})});function E8e(e,t){Sa(e)&&t&&(e.setTextContent(t),e.selectStart())}const eGe=gr(!0),son=xu({init(e,t){e.pub(M6,(t==null?void 0:t.LinkDialog)??ron),e.pub(YXe,(t==null?void 0:t.onClickLinkCallback)??null),e.pub(JXe,(t==null?void 0:t.onReadOnlyClickLinkCallback)??null),e.pub(eGe,(t==null?void 0:t.showLinkTitleField)??!0)},update(e,t={}){e.pub(GXe,t.linkAutocompleteSuggestions??[])}});var CY={exports:{}},D8e;function ion(){return D8e||(D8e=1,(function(e){var t=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
|
|
1787
1787
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
1788
1788
|
*
|
|
@@ -1932,7 +1932,7 @@ ${xe}`:xe;return h&&n9e(h,We),We})}else if(A)for(const ot of mt)await A(ot)}fina
|
|
|
1932
1932
|
`}function d1e(e){const t=[];let n=[],r="",s=!1,a=!1;for(let o=0;o<e.length;o+=1){const l=e[o];if(a=!1,s){l==='"'?e[o+1]==='"'?(r+='"',o+=1):s=!1:r+=l;continue}if(l==='"'&&r.length===0){s=!0;continue}if(l===","){n.push(r),r="";continue}if(l===`
|
|
1933
1933
|
`||l==="\r"){n.push(r),t.push(n),n=[],r="",a=!0,l==="\r"&&e[o+1]===`
|
|
1934
1934
|
`&&(o+=1);continue}r+=l}return(n.length>0||r.length>0||!a)&&(n.push(r),t.push(n)),{rows:t.length>0?t:[[""]],lineEnding:gCn(e),hasTrailingLineBreak:a}}function u1e(e){let t=1;for(const n of e)t=Math.max(t,n.length);return{columnCount:t,rows:e.map(n=>Array.from({length:t},(r,s)=>n[s]??""))}}function xCn(e){return/[",\r\n]/u.test(e)?`"${e.replaceAll('"','""')}"`:e}function bCn(e,t=`
|
|
1935
|
-
`,n=!1){const r=e.map(s=>s.map(xCn).join(",")).join(t);return n&&r.length>0?`${r}${t}`:r}const yCn=YO("inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap rounded-[var(--control-radius)] border text-sm font-medium transition-[color,background-color,border-color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:border-[color:var(--border-base)] data-[state=on]:bg-secondary data-[state=on]:text-secondary-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"border-transparent bg-transparent text-muted-foreground shadow-none hover:border-[color:var(--border-soft)] hover:bg-[color:var(--surface-active)] hover:text-foreground",outline:"border-[color:var(--border-base)] bg-[color:var(--surface-elevated)] text-muted-foreground shadow-none hover:bg-[color:var(--surface-active)] hover:text-foreground"},size:{default:"h-9 min-w-9 px-2",sm:"h-7 min-w-7 px-2 text-xs",lg:"h-10 min-w-10 px-2.5"}},defaultVariants:{variant:"default",size:"default"}}),dat=m.createContext({size:"default",variant:"default",spacing:0});function uat({className:e,variant:t,size:n,spacing:r=0,children:s,...a}){return i.jsx(jEe,{"data-slot":"toggle-group","data-variant":t,"data-size":n,"data-spacing":r,style:{"--gap":r},className:q("group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-[var(--control-radius)]",e),...a,children:i.jsx(dat.Provider,{value:{variant:t,size:n,spacing:r},children:s})})}function OU({className:e,children:t,variant:n,size:r,...s}){const a=m.useContext(dat);return i.jsx(CEe,{"data-slot":"toggle-group-item","data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:q(yCn({variant:a.variant||n,size:a.size||r}),"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10","data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-[var(--control-radius)] data-[spacing=0]:last:rounded-r-[var(--control-radius)] data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",e),...s,children:t})}const YL=new Map,BC="connected";function nZ({viewMode:e,onViewModeChange:t,networkMode:n,onNetworkModeChange:r,networkUnavailable:s=!1,onReload:a,openAction:o,testIdPrefix:l="workspace-file",className:c}){const d=s?"offline":n,u=d==="connected"?"Connected":"Offline",f=d==="connected"?pye:mye,A=s?"Network mode: Offline. Connected preview is unavailable while using the static Offline fallback.":d==="connected"?"Network mode: Connected. Runs artifact scripts and may send preview content to external HTTPS sites.":"Network mode: Offline. Local assets only; scripts and external requests are blocked.";return i.jsx("div",{className:q("workspace-html-preview-toolbar scrollbar-auto-hide flex min-h-10 shrink-0 items-center overflow-x-auto border-b border-border bg-[color:var(--surface-elevated)] px-1",c),"data-testid":`${l}-html-preview-toolbar`,children:i.jsxs("div",{className:"workspace-html-preview-toolbar-controls ml-auto flex min-w-max items-center gap-1",children:[i.jsxs(uat,{type:"single",variant:"outline",size:"sm",spacing:0,value:e,onValueChange:h=>{(h==="preview"||h==="source")&&t(h)},"aria-label":"HTML file mode",children:[i.jsxs(OU,{value:"preview",className:"px-2","aria-label":"Preview",title:"Preview",children:[i.jsx(Vm,{"data-icon":"inline-start"}),i.jsx("span",{className:"workspace-html-preview-mode-label",children:"Preview"})]}),i.jsxs(OU,{value:"source",className:"px-2","aria-label":"Source",title:"Source",children:[i.jsx(tue,{"data-icon":"inline-start"}),i.jsx("span",{className:"workspace-html-preview-mode-label",children:"Source"})]})]}),e==="preview"&&d&&r?i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,disabled:s,children:i.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"min-w-[6.5rem] justify-between","aria-label":A,"data-testid":`${l}-html-preview-network-menu`,children:[i.jsx(f,{"data-icon":"inline-start"}),i.jsx("span",{children:u}),i.jsx(Br,{className:"workspace-html-preview-network-chevron","data-icon":"inline-end"})]})}),i.jsx(Di,{align:"end",className:"w-72",children:i.jsxs(pLt,{children:[i.jsx(OI,{children:"Network access"}),i.jsxs(ofe,{value:d,onValueChange:h=>{(h==="connected"||h==="offline")&&r(h)},children:[i.jsxs(cB,{value:"connected",children:[i.jsx(pye,{}),i.jsxs("span",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{children:"Connected"}),i.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"Run scripts and allow HTTPS resources"})]})]}),i.jsxs(cB,{value:"offline",children:[i.jsx(mye,{}),i.jsxs("span",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{children:"Offline"}),i.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"Local assets only; block scripts"})]})]})]})]})})]}):null,o?i.jsx("div",{className:"workspace-html-preview-open-action shrink-0",children:o}):null,e==="preview"&&a?i.jsx(id,{delayDuration:120,children:i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Reload website preview",onClick:a,children:i.jsx(_A,{})})}),i.jsx(Gi,{children:"Reload preview"})]})}):null]})})}function vCn(e,t,n,r,s){const a=[e,t,n,s,r??""].join("\0"),o=YL.get(a);if(o)return o;const l=En.createWorkspaceWebPreviewSession(e,{entryPath:t,networkMode:n,...r===void 0?{}:{htmlContent:r}});YL.set(a,l);const c=()=>{YL.get(a)===l&&YL.delete(a)};return l.then(c,c),l}function fat({organizationId:e,filePath:t,htmlContent:n,testIdPrefix:r="workspace-file",className:s,viewMode:a="preview",onViewModeChange:o=()=>{},networkMode:l,onNetworkModeChange:c,openAction:d}){const u=`${e}:${t}`,[f,A]=m.useState({identity:u,mode:BC}),[h,g]=m.useState(0),[x,y]=m.useState({status:"loading",session:null,error:null}),v=f.identity===u?f.mode:BC,w=l??v;m.useEffect(()=>{f.identity!==u&&A({identity:u,mode:BC})},[u,f.identity]),m.useEffect(()=>{let j=!1;return y({status:"loading",session:null,error:null}),vCn(e,t,w,n,h).then(C=>{j||y({status:"ready",session:C,error:null})}).catch(C=>{j||y({status:"error",session:null,error:C instanceof Error?C.message:"Website preview could not be started."})}),()=>{j=!0}},[t,n,w,e,h]);const k=j=>{x.status==="error"||j===w||(l===void 0&&A({identity:u,mode:j}),c==null||c(j))},O=()=>{l===void 0&&A({identity:u,mode:BC}),c==null||c(BC),g(j=>j+1)};return i.jsxs("div",{className:q("flex min-h-[420px] flex-1 flex-col bg-white",s),"data-testid":`${r}-html-preview-frame`,children:[i.jsx(nZ,{viewMode:a,onViewModeChange:o,networkMode:w,onNetworkModeChange:k,networkUnavailable:x.status==="error",onReload:()=>g(j=>j+1),openAction:d,testIdPrefix:r}),x.status==="loading"?i.jsxs("div",{className:"flex min-h-[384px] flex-1 items-center justify-center text-muted-foreground","data-testid":`${r}-html-preview-loading`,role:"status",children:[i.jsx(yn,{className:"h-5 w-5 animate-spin"}),i.jsx("span",{className:"sr-only",children:"Loading website preview"})]}):x.status==="error"?i.jsxs("div",{className:"flex min-h-[384px] flex-1 flex-col","data-testid":`${r}-html-preview-error`,children:[i.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border bg-muted/40 px-3 py-2",role:"alert",children:[i.jsxs("p",{className:"min-w-0 text-xs leading-5 text-muted-foreground",children:["Multi-file preview is unavailable. Showing a static Offline document. ",x.error]}),i.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:O,children:[i.jsx(_A,{"data-icon":"inline-start"}),"Retry"]})]}),i.jsx("iframe",{"data-testid":`${r}-html-preview`,"data-preview-fallback":"static",title:t||"Library static HTML preview",srcDoc:VMt(n??""),sandbox:"",referrerPolicy:"no-referrer",className:"block min-h-[336px] w-full flex-1 border-0 bg-white"})]}):i.jsx("iframe",{"data-testid":`${r}-html-preview`,title:t||"Library website preview",src:x.session.previewUrl,sandbox:w==="connected"?"allow-scripts":"",referrerPolicy:"no-referrer",className:"block min-h-[384px] w-full flex-1 border-0 bg-white"},x.session.previewUrl)]})}function Xk(e){const t=e.split("/").filter(Boolean),n=[];for(let r=0;r<t.length-1;r+=1)n.push(t.slice(0,r+1).join("/"));return new Set(n)}function Aat(e){const t=e.split("/").filter(Boolean),n=[];for(let r=0;r<t.length;r+=1)n.push(t.slice(0,r+1).join("/"));return new Set(n)}function dl(e){const t=(e==null?void 0:e.trim())??"";return t.length>0?t:null}const hat="rudder.workspace.launchTargetId",mat="rudder.workspace.unsupportedFileLaunchTargetId",wCn="rudder.workspace.openFileTabs",kCn=["cursor","vscode","windsurf","zed","webstorm","intellij","xcode","terminal","warp","commandPrompt","powershell","finder"],SCn={fileTarget:!0,id:"defaultApp",label:"Default app",kind:"app"};function f1e(e){return kCn.includes(e)}function OCn(e){return e.kind==="ide"&&e.id!=="xcode"}function fw(e){return"fileTarget"in e}function QT(e){return[SCn,...e.filter(OCn).map(t=>({fileTarget:!0,id:t.id,label:t.label,kind:"ide",workspaceTarget:t}))]}function jCn(e,t){if(!t.canOpenFile)return[];const n=QT(e);return t.canOpenLocation?[...n,...e.filter(r=>r.kind==="folder"||r.kind==="terminal")]:n}function CCn(e,t){return e.find(n=>n.id===t)??e.find(n=>n.id==="defaultApp")??null}function NCn(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(mat);return e==="defaultApp"||f1e(e)?e:null}catch{return null}}function PCn(e){if(!(typeof window>"u"))try{window.localStorage.setItem(mat,e)}catch{}}function ICn(){if(typeof window>"u")return null;const e=window.localStorage.getItem(hat);return f1e(e)?e:null}function KP(e){typeof window>"u"||window.localStorage.setItem(hat,e)}function Xoe(e){return e&&f1e(e)?e:null}function TCn(e){return e.defaultPrevented||e.altKey||e.shiftKey||!e.metaKey&&!e.ctrlKey?!1:e.key.toLowerCase()==="w"}function jU(e){const t=new Set,n=[];for(const r of e){const s=dl(r??null);!s||t.has(s)||(t.add(s),n.push(s))}return n.slice(-24)}function pat(e){return`${wCn}:${e}`}function E7(e,t){const n=jU([...e,t]),r=dl(t??null);return{openFilePaths:n,selectedFilePath:r&&n.includes(r)?r:n[0]??null}}function Goe(e){var t;if(!e||typeof window>"u")return E7([],null);try{const n=(t=window.sessionStorage)==null?void 0:t.getItem(pat(e)),r=n?JSON.parse(n):null;if(Array.isArray(r))return E7(r,r[0]);if(r&&typeof r=="object"){const s=r;return E7(Array.isArray(s.openFilePaths)?s.openFilePaths:[],typeof s.selectedFilePath=="string"?s.selectedFilePath:null)}}catch{return E7([],null)}return E7([],null)}function _Cn(e,t,n){var r;if(!(!e||typeof window>"u"))try{const s=E7(t,n);(r=window.sessionStorage)==null||r.setItem(pat(e),JSON.stringify(s))}catch{}}function MCn(e,t){return e.includes(t)?e:jU([...e,t])}const ECn={cursor:{src:"/brands/cursor-app-icon.svg"}},DCn={vscode:{label:"VS",className:"bg-[#0078d4] text-white"},windsurf:{label:"W",className:"bg-[#14b8a6] text-white"},zed:{label:"Z",className:"bg-[#171717] text-white"},webstorm:{label:"WS",className:"bg-[#ec4899] text-white"},intellij:{label:"IJ",className:"bg-[#f97316] text-white"},xcode:{label:"XC",className:"bg-[#147efb] text-white"},commandPrompt:{label:"CMD",className:"bg-[#111827] text-white"},powershell:{label:"PS",className:"bg-[#2563eb] text-white"}};function B2({target:e,className:t}){const[n,r]=m.useState(!1),[s,a]=m.useState(!1),o=fw(e)?e.workspaceTarget:e,l=q("inline-flex h-5 w-5 shrink-0 items-center justify-center",t);if(o!=null&&o.iconDataUrl&&!n)return i.jsx("span",{"aria-hidden":"true",className:l,"data-workspace-launch-target-icon":e.id,children:i.jsx("img",{src:o.iconDataUrl,alt:"",className:"h-full w-full object-contain",onError:()=>r(!0)})});const c=o?ECn[o.id]:null;if(c&&!s)return i.jsx("span",{"aria-hidden":"true",className:l,"data-workspace-launch-target-icon":e.id,"data-fallback-icon":"true","data-brand-fallback":"true",children:i.jsx("img",{src:c.src,alt:"",className:"h-full w-full object-contain",onError:()=>a(!0)})});const d=o?DCn[o.id]:null;if(d)return i.jsx("span",{"aria-hidden":"true",className:q("inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[5px] border border-[color:var(--border-base)] text-[9px] font-semibold leading-none",d.className,t),"data-workspace-launch-target-icon":e.id,"data-fallback-icon":"true","data-app-specific-fallback":"true",children:d.label});const u=e.kind==="terminal"?pM:e.kind==="folder"?q2:e.kind==="app"?La:tue;return i.jsx("span",{"aria-hidden":"true",className:q("inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[5px] border border-[color:var(--border-base)] bg-[color:var(--surface-page)] text-foreground",t),"data-workspace-launch-target-icon":e.id,"data-fallback-icon":"true",children:i.jsx(u,{className:"h-[72%] w-[72%]"})})}function Yoe({rootPath:e,targets:t,openingTargetId:n,onOpenTarget:r,className:s,contentAlign:a="end",testId:o="org-workspaces-launcher",targetTestIdPrefix:l="org-workspaces-launch-target"}){return t.length===0?null:i.jsxs(Mi,{children:[i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(Ei,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:q("h-7 w-7 rounded-md text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground",s),"aria-label":"Open Library menu",disabled:n!==null,"data-testid":o,children:n?i.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(La,{className:"h-3.5 w-3.5"})})})}),i.jsx(Gi,{children:"Open Library"})]}),i.jsx(Di,{align:a,sideOffset:8,className:"w-60 whitespace-nowrap p-1",children:t.map(c=>i.jsxs(Gt,{className:"h-9 gap-2 rounded-[6px]",disabled:n!==null,"data-testid":`${l}-${c.id}`,onSelect:()=>{r(e,c,"workspace")},children:[n===c.id?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(B2,{target:c}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:c.label}),i.jsx("span",{className:"text-[11px] capitalize text-muted-foreground",children:c.kind})]},c.id))})]})}function RCn({targets:e,currentTarget:t,openingTargetId:n,onOpenTarget:r}){const s=n!==null;return i.jsx("div",{className:"flex h-full min-h-[360px] items-center justify-center px-6 py-10",children:i.jsxs("div",{className:"flex max-w-md flex-col items-center text-center",children:[i.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"This file can’t be previewed or edited in Rudder."}),t&&e.length>0?i.jsxs("div",{className:"mt-4 inline-flex h-9 items-stretch rounded-md border border-[color:var(--border-base)] bg-[color:var(--surface-page)]",children:[i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-10 rounded-r-none border-r border-[color:var(--border-base)]","aria-label":`Open file with ${t.label}`,disabled:s,"data-testid":"org-workspaces-unsupported-file-open-current",onClick:()=>r(t),children:s?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(B2,{target:t})})}),i.jsx(Gi,{className:"pointer-events-none",children:`Open with ${t.label}`})]}),i.jsxs(Mi,{children:[i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(Ei,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-8 rounded-l-none","aria-label":"Choose how to open file",disabled:s,"data-testid":"org-workspaces-unsupported-file-launcher",children:i.jsx(Br,{className:"h-3.5 w-3.5"})})})}),i.jsx(Gi,{className:"pointer-events-none",children:"Choose how to open file"})]}),i.jsx(Di,{align:"center",sideOffset:8,className:"w-60 whitespace-nowrap p-1",children:e.map(a=>i.jsxs(Gt,{className:"h-9 gap-2 rounded-[6px]",disabled:s,"data-testid":`org-workspaces-unsupported-file-target-${a.id}`,onSelect:()=>r(a),children:[n===a.id?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(B2,{target:a}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.label})]},a.id))})]})]}):null]})})}function LCn({onOpenInLibrary:e,targets:t,openingTargetId:n,onOpenTarget:r,testId:s="workspace-file-open-menu"}){return t.length===0?null:i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1 px-2","aria-label":"Open file options",disabled:n!==null,"data-testid":s,children:[n?i.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(La,{className:"h-3.5 w-3.5"}),i.jsx("span",{children:"Open"}),i.jsx(Br,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),i.jsxs(Di,{align:"center",sideOffset:8,className:"w-60 whitespace-nowrap p-1",children:[e?i.jsxs(Gt,{className:"h-9 gap-2 rounded-[6px]",onSelect:e,children:[i.jsx(dM,{className:"h-4 w-4","aria-hidden":!0}),i.jsx("span",{children:"Open in Library"})]}):null,t.map(a=>i.jsxs(Gt,{className:"h-9 gap-2 rounded-[6px]",disabled:n!==null,"data-testid":`${s}-target-${a.id}`,onSelect:()=>r(a),children:[i.jsx(B2,{target:a}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.label})]},a.id))]})]})}const zCn="/assets/pdf.worker.min-yatZIOMy.mjs",$Cn=640,O9e=280,FCn=2,j9e=16384,BCn=16777216,C9e=16384,gat=.6,xat=2,N9e=.2;let P9e=null;function QCn(){return P9e??(P9e=Wt(()=>import("./pdf-CcZYcL52.js"),[]).then(e=>(e.GlobalWorkerOptions.workerSrc=zCn,e))),P9e}function I9e(e){return Math.min(xat,Math.max(gat,e))}function bat({className:e,showOpenAction:t=!1,src:n,testId:r,title:s}){const a=m.useRef(null),o=m.useRef(null),l=m.useRef(null),[c,d]=m.useState($Cn),[u,f]=m.useState(null),[A,h]=m.useState(null),[g,x]=m.useState(!0),[y,v]=m.useState(1),[w,k]=m.useState(""),[O,j]=m.useState(null),[C,N]=m.useState(!1),[I,E]=m.useState(1),_=(u==null?void 0:u.numPages)??0;return m.useEffect(()=>{const T=a.current;if(!T)return;const R=(U=T.getBoundingClientRect().width)=>{U>0&&d(Math.max(O9e,U))},M=()=>R();if(R(),typeof ResizeObserver>"u")return window.addEventListener("resize",M),()=>window.removeEventListener("resize",M);const L=new ResizeObserver(U=>{var B;R((B=U[0])==null?void 0:B.contentRect.width)});return L.observe(T),()=>L.disconnect()},[]),m.useEffect(()=>{let T=!1,R=null;return f(null),h(null),x(!0),v(1),k(""),j(null),E(1),QCn().then(M=>T?null:(R=M.getDocument({url:n,withCredentials:!0}),R.promise)).then(M=>{if(M){if(T){R==null||R.destroy();return}f(M),x(!1)}}).catch(M=>{T||(h(M instanceof Error?M.message:"The PDF could not be loaded."),x(!1))}),()=>{var M;T=!0,(M=l.current)==null||M.cancel(),l.current=null,R&&R.destroy()}},[n]),m.useEffect(()=>{var R;if(!u)return;let T=!1;return(R=l.current)==null||R.cancel(),l.current=null,h(null),j(null),N(!0),u.getPage(y).then(async M=>{if(T)return;const L=o.current;if(!L)return;const U=L.getContext("2d");if(!U)throw new Error("Canvas rendering is unavailable.");const B=M.getViewport({scale:1}),J=Math.max(O9e-32,c-32)/B.width*I,F=M.getViewport({scale:J}),Q=Math.min(1,C9e/Math.max(1,F.width),C9e/Math.max(1,F.height)),W=J*Q,$=Q<1?M.getViewport({scale:W}):F,ee=Math.min(window.devicePixelRatio||1,FCn),re=M.getViewport({scale:W*ee}),ne=re.width*re.height,te=Math.min(1,Math.sqrt(BCn/Math.max(1,ne)),j9e/Math.max(1,re.width),j9e/Math.max(1,re.height)),ce=te<1?M.getViewport({scale:W*ee*te}):re;L.width=Math.max(1,Math.floor(ce.width)),L.height=Math.max(1,Math.floor(ce.height)),L.style.width=`${Math.floor($.width)}px`,L.style.height=`${Math.floor($.height)}px`;const se=M.render({canvasContext:U,viewport:ce});l.current=se,await se.promise,T||j(y)}).catch(M=>{T||M instanceof Error&&M.name==="RenderingCancelledException"||h(M instanceof Error?M.message:"The PDF page could not be rendered.")}).finally(()=>{T||N(!1)}),()=>{var M;T=!0,(M=l.current)==null||M.cancel(),l.current=null}},[c,u,y,I]),m.useEffect(()=>{if(!u)return;let T=!1;return k(""),u.getPage(y).then(R=>R.getTextContent()).then(R=>R.items.map(M=>"str"in M?M.str:"").filter(Boolean).join(" ").trim()).then(R=>{T||k(R)}).catch(()=>{T||k("")}),()=>{T=!0}},[u,y]),i.jsxs("div",{className:q("flex min-h-0 flex-1 flex-col bg-[color:var(--surface-page)]",e),"data-pdf-src":n,"data-testid":r,children:[i.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Previous PDF page",title:"Previous page",disabled:g||y<=1,onClick:()=>v(T=>Math.max(1,T-1)),children:i.jsx(iM,{className:"h-4 w-4"})}),i.jsx("span",{className:"w-20 text-center text-xs tabular-nums text-muted-foreground","data-testid":`${r}-page-indicator`,children:_>0?`${y} / ${_}`:"- / -"}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Next PDF page",title:"Next page",disabled:g||y>=_,onClick:()=>v(T=>Math.min(_,T+1)),children:i.jsx(_i,{className:"h-4 w-4"})})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Zoom out PDF",title:"Zoom out",disabled:g||I<=gat,onClick:()=>E(T=>I9e(T-N9e)),children:i.jsx(D9t,{className:"h-4 w-4"})}),i.jsxs("span",{className:"w-10 text-center text-xs tabular-nums text-muted-foreground",children:[Math.round(I*100),"%"]}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Zoom in PDF",title:"Zoom in",disabled:g||I>=xat,onClick:()=>E(T=>I9e(T+N9e)),children:i.jsx(M9t,{className:"h-4 w-4"})}),t?i.jsxs("a",{href:n,target:"_blank",rel:"noreferrer",className:"ml-1 inline-flex h-7 items-center gap-1.5 rounded-[4px] px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[i.jsx(La,{className:"h-3.5 w-3.5","aria-hidden":"true"}),i.jsx("span",{children:"Open"})]}):null]})]}),i.jsxs("div",{ref:a,className:"scrollbar-auto-hide relative flex min-h-[360px] flex-1 items-start justify-center overflow-auto bg-[#ececec] p-4 dark:bg-[#202020]",role:"region","aria-label":`PDF preview: ${s}`,children:[i.jsx("canvas",{ref:o,"aria-hidden":"true",className:q("block max-w-none bg-white shadow-[0_1px_4px_rgba(0,0,0,0.2)]",O===y?"visible":"invisible"),"data-rendered-page":O??void 0,"data-testid":`${r}-canvas`}),O===y?i.jsxs("p",{className:"sr-only","data-testid":`${r}-text-content`,children:["Page ",y," of ",_,". ",w||"This page contains no extractable text."]}):null,g||C?i.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted-foreground",role:"status","aria-label":"Loading PDF preview",children:i.jsx(yn,{className:"h-5 w-5 animate-spin"})}):null,A?i.jsxs("div",{className:"absolute inset-0 flex items-center justify-center px-6 text-center text-sm text-muted-foreground",role:"alert",children:["Could not preview this PDF. ",A]}):null]})]})}function yat({kind:e,src:t,contentType:n,title:r,openAction:s,className:a,testId:o="workspace-media-preview"}){const l=`${e}:${t}`,[c,d]=m.useState(null),u=c===l,f=`${r||`Library ${e}`} ${e} preview`,A=e==="video"?rue:nue,h=i.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i.jsx(ie,{asChild:!0,variant:"outline",size:"sm",className:"h-8 gap-1.5",children:i.jsxs("a",{href:t,download:!0,children:[i.jsx(pg,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Download"]})}),s]});return m.useEffect(()=>{d(null)},[l]),u?i.jsx("div",{className:q("flex min-h-[320px] flex-1 items-center justify-center px-6 py-10",a),"data-testid":`${o}-fallback`,role:"alert",children:i.jsxs("div",{className:"flex max-w-md flex-col items-center text-center",children:[i.jsx(A,{className:"h-8 w-8 text-muted-foreground","aria-hidden":"true"}),i.jsxs("p",{className:"mt-3 text-sm font-medium text-foreground",children:["This ",e," can’t be played in this browser."]}),i.jsx("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"The file may use a codec your browser does not support. Download it or open it with another app."}),i.jsx("div",{className:"mt-4",children:h})]})}):i.jsxs("div",{className:q("flex min-h-[320px] min-w-0 flex-1 flex-col bg-accent/10",a),"data-testid":`${o}-frame`,"data-workspace-media-preview":e,children:[i.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-4",children:e==="video"?i.jsx("video",{"aria-label":f,className:"h-auto w-full max-h-full max-w-5xl rounded-md bg-black shadow-sm",controls:!0,playsInline:!0,preload:"metadata",src:t,"data-content-type":n??void 0,"data-testid":o,onError:()=>d(l),onLoadedMetadata:()=>d(null)},l):i.jsx("audio",{"aria-label":f,className:"w-full max-w-2xl",controls:!0,preload:"metadata",src:t,"data-content-type":n??void 0,"data-testid":o,onError:()=>d(l),onLoadedMetadata:()=>d(null)},l)}),i.jsx("div",{className:"shrink-0 border-t border-[color:var(--border-soft)] bg-[color:var(--surface-page)] px-3 py-2",children:h})]})}function UCn({cacheKey:e,kind:t,src:n,contentType:r,title:s,targets:a,openingTargetId:o,onOpenTarget:l,scrollRef:c}){return t==="pdf"?i.jsx("div",{ref:c,"data-testid":"org-workspaces-pdf-preview-scroll",className:"scrollbar-auto-hide flex h-full min-h-[420px] flex-col overflow-hidden bg-[color:var(--surface-page)]",children:i.jsx(bat,{className:"h-full min-h-[420px]",showOpenAction:!0,src:n,testId:"org-workspaces-pdf-preview",title:s})}):i.jsx(yat,{kind:t,src:n,contentType:r,title:s,openAction:i.jsx(LCn,{targets:a,openingTargetId:o,onOpenTarget:l,testId:"org-workspaces-media-open-menu"}),className:"h-full min-h-[420px]",testId:`org-workspaces-${t}-preview`},e)}const VCn=[".md",".markdown",".mdown",".mdx"],qCn=[".csv"],KCn=500,WCn=100;function vat(e){var t;return((t=e==null?void 0:e.toLowerCase().split(";")[0])==null?void 0:t.trim())??""}function wat(e,t){const n=(e==null?void 0:e.toLowerCase())??"";return t.some(r=>n.endsWith(r))}function kat(e){return e.previewKind==="text"&&e.content!==null&&(wat(e.filePath,VCn)||vat(e.contentType)==="text/markdown")}function Sat(e){return e.previewKind==="text"&&e.content!==null&&(wM(e.filePath)||W$e(e.contentType))}function Oat(e){return e.previewKind==="text"&&e.content!==null&&(wat(e.filePath,qCn)||vat(e.contentType)==="text/csv")}function ZCn({content:e,testId:t}){const n=d1e(e),r=n.rows.slice(0,KCn+1);let s=1;for(const A of r)s=Math.max(s,A.length);const{rows:a,columnCount:o}=u1e(r.map(A=>A.slice(0,WCn))),l=a[0]??Array.from({length:o},()=>""),c=a.slice(1),d=Math.max(0,n.rows.length-1-c.length),u=Math.max(0,s-o),f=[d>0?`${d.toLocaleString()} more data rows`:null,u>0?`${u.toLocaleString()} more columns`:null].filter(A=>A!==null);return i.jsxs("div",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-auto","data-testid":t,role:"region","aria-label":"CSV preview",children:[i.jsxs("table",{className:"w-max min-w-full border-separate border-spacing-0 text-left text-sm","aria-label":"CSV preview table",children:[i.jsxs("caption",{className:"sr-only",children:["CSV preview with ",n.rows.length," rows and ",o," visible columns"]}),i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",className:"sticky left-0 top-0 z-20 w-12 border-b border-r border-border bg-[color:var(--surface-page)] px-3 py-2 text-center text-xs font-medium text-muted-foreground",children:"#"}),l.map((A,h)=>i.jsx("th",{scope:"col",className:"sticky top-0 z-10 min-w-[10rem] border-b border-r border-border bg-[color:var(--surface-page)] px-3 py-2 font-semibold text-foreground",children:A||`Column ${h+1}`},h))]})}),i.jsx("tbody",{children:c.map((A,h)=>i.jsxs("tr",{children:[i.jsx("th",{scope:"row",className:"sticky left-0 z-10 border-b border-r border-border bg-[color:var(--surface-page)] px-3 py-2 text-center text-xs font-medium text-muted-foreground",children:h+2}),A.map((g,x)=>i.jsx("td",{className:"max-w-[28rem] whitespace-pre-wrap border-b border-r border-border px-3 py-2 align-top leading-6 text-foreground",children:g},x))]},h))})]}),f.length>0?i.jsxs("p",{className:"sticky bottom-0 border-t border-border bg-[color:var(--surface-page)] px-4 py-2 text-xs text-muted-foreground",role:"status",children:["Showing a bounded table preview. Open Source to inspect ",f.join(" and "),"."]}):null]})}function jat({file:e,organizationId:t,mode:n="preview",onModeChange:r=()=>{},htmlOpenAction:s,mediaOpenAction:a,testIdPrefix:o="workspace-file"}){const l=`${t}:${e.filePath}`,[c,d]=m.useState({identity:l,mode:"connected"}),u=c.identity===l?c.mode:"connected";return m.useEffect(()=>{d(f=>f.identity===l?f:{identity:l,mode:"connected"})},[l]),e.previewKind==="text"&&e.content!==null?Sat(e)?n==="preview"?i.jsx(fat,{organizationId:t,filePath:e.filePath,htmlContent:e.content,viewMode:n,onViewModeChange:r,networkMode:u,onNetworkModeChange:f=>{d({identity:l,mode:f})},openAction:s,testIdPrefix:o},`${t}:${e.filePath}`):i.jsxs("div",{className:"flex min-h-[420px] flex-1 flex-col","data-testid":`${o}-html-source-frame`,children:[i.jsx(nZ,{viewMode:n,onViewModeChange:r,openAction:s,testIdPrefix:o}),i.jsx(BT,{"data-testid":`${o}-code-preview`,ariaLabel:`${e.filePath||"Library file"} source`,filePath:e.filePath,value:e.content,readOnly:!0})]}):kat(e)?i.jsx("article",{className:"scrollbar-auto-hide min-h-0 min-w-0 flex-1 overflow-y-auto px-5 py-5","data-testid":`${o}-markdown-preview`,"aria-label":`${e.filePath||"Library file"} preview`,children:i.jsx(Bo,{className:"rudder-library-document-editor rudder-side-panel-library-document text-[15px] leading-7 text-foreground",enableCodeBlockCopy:!0,children:e.content})}):Oat(e)&&n==="preview"?i.jsx(ZCn,{content:e.content,testId:`${o}-csv-preview`}):i.jsx(BT,{"data-testid":`${o}-code-preview`,ariaLabel:`${e.filePath||"Library file"} source`,filePath:e.filePath,value:e.content,readOnly:!0}):e.previewKind==="image"&&e.contentPath?i.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-4","data-testid":`${o}-image-preview-frame`,children:i.jsx(H2,{"data-testid":`${o}-image-preview`,src:e.contentPath,alt:e.filePath,name:e.filePath||"Library image preview",className:"max-h-full max-w-full object-contain",previewTestId:`${o}-image-preview-dialog`,previewTitleFallback:"Library image preview",triggerClassName:"max-h-full",wrapperClassName:"max-h-full"})}):e.previewKind==="pdf"&&e.contentPath?i.jsx("div",{className:"flex min-h-[420px] flex-1","data-testid":`${o}-pdf-preview-frame`,children:i.jsx(bat,{className:"min-h-[420px]",src:e.contentPath,testId:`${o}-pdf-preview`,title:e.filePath||"Library PDF preview"})}):(e.previewKind==="video"||e.previewKind==="audio")&&e.contentPath?i.jsx(yat,{kind:e.previewKind,src:e.contentPath,contentType:e.contentType,title:e.filePath||`Library ${e.previewKind}`,openAction:a,testId:`${o}-${e.previewKind}-preview`},`${t}:${e.filePath}`):i.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-center","data-testid":`${o}-preview-unavailable`,children:i.jsx("p",{className:"max-w-sm text-sm leading-6 text-muted-foreground",children:e.message??"No inline preview is available for this file."})})}const QC="desktop-local-file";function HCn(e){return e.base64?`data:${e.contentType};base64,${e.base64}`:null}function XCn(e){return{source:"org_root",rootPath:e.parentPath,repoUrl:null,filePath:e.canonicalPath,libraryEntryId:null,mentionHref:null,markdownLink:null,rootExists:!0,content:e.content,contentType:e.contentType,previewKind:e.previewKind==="image"||e.previewKind==="pdf"?e.previewKind:"text",contentPath:HCn(e),message:null,truncated:e.truncated}}function GCn(e,t){const n=e instanceof Error?e.message:"";return/\bENOENT\b|no such file or directory/iu.test(n)?"Could not resolve the file location recorded by this run. The file may have moved, or an older transcript may not include the command's original working directory.":n||`Could not preview ${t}.`}function YCn({preview:e,sourceConversationId:t,onPreviewChange:n}){const r=Pn(),s=e.content??"",o=m.useRef($it(QC,e.canonicalPath,s)).current,l=m.useRef(o.baseContent),c=m.useRef(o.content),d=m.useRef(s),u=m.useRef(!1),f=m.useRef(null),A=m.useRef(o.conflicted),[h,g]=m.useState(o.content),[x,y]=m.useState(o.conflicted?"error":o.content===s?"saved":"saving"),[v,w]=m.useState(o.conflicted?"This file changed outside Rudder. Choose which version to keep.":null),[k,O]=m.useState(o.conflicted),j=m.useRef(null),[C,N]=m.useState(null),I=m.useCallback(U=>{const B=U.content??c.current;l.current=B,d.current=B,A.current=!1,O(!1),w(null),n(U),Dy(QC,e.canonicalPath,B,c.current),c.current!==B&&(f.current=c.current)},[n,e.canonicalPath]);m.useEffect(()=>()=>{Dy(QC,e.canonicalPath,l.current,c.current)},[e.canonicalPath]);const E=m.useCallback(async()=>{if(!(!r||u.current)){u.current=!0;try{for(;f.current!==null;){const U=f.current;if(f.current=null,!(A.current||U===l.current)){y("saving"),w(null);try{const B=await r.updateLocalFile(e.canonicalPath,{content:U,expectedContent:l.current,writeCapability:e.writeCapability??""});I(B)}catch(B){let z=null;try{z=await r.previewLocalFile(e.canonicalPath)}catch{}if((z==null?void 0:z.content)===U){I(z);continue}z&&z.content!==null&&z.content!==l.current&&(d.current=z.content,A.current=!0,O(!0)),y("error"),w(A.current?"This file changed outside Rudder. Choose which version to keep.":B instanceof Error?B.message:"Could not save this file.");return}}}y(c.current===l.current?"saved":"saving")}finally{u.current=!1,f.current!==null&&!A.current&&E()}}},[I,r,e.canonicalPath]);m.useEffect(()=>{if(Dy(QC,e.canonicalPath,l.current,h),A.current||h===l.current)return;y("saving");const U=window.setTimeout(()=>{f.current=h,E()},700);return()=>window.clearTimeout(U)},[h,E,e.canonicalPath]);const _=U=>{c.current=U,g(U),y(A.current?"error":"saving"),A.current||w(null)},T=()=>{l.current=d.current,A.current=!1,O(!1),y("saving"),w(null),f.current=c.current,E()},R=()=>{const U=d.current;l.current=U,c.current=U,f.current=null,A.current=!1,O(!1),g(U),y("saved"),w(null),r4(QC,e.canonicalPath)},M=()=>{f.current=c.current,E()},L=e.previewKind==="markdown"?r1e(h):{frontmatter:null,separator:"",body:h};return i.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col","data-testid":"chat-side-panel-local-file-editor",children:[e.previewKind==="markdown"?i.jsxs("div",{ref:j,className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-5 pb-16 pt-5",children:[L.frontmatter!==null?i.jsxs("details",{className:"group mb-6 rounded-md border border-border bg-muted/20","data-chat-annotation-ignore":!0,children:[i.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-muted-foreground [&::-webkit-details-marker]:hidden",children:[i.jsx("span",{children:"Frontmatter"}),i.jsx(_i,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-90"})]}),i.jsx("textarea",{value:L.frontmatter,onChange:U=>_(kU(U.currentTarget.value,L.separator,L.body)),spellCheck:!1,className:"block min-h-28 w-full resize-y border-t border-border bg-transparent px-3 py-2 font-mono text-xs leading-5 text-foreground outline-none","aria-label":"Frontmatter"})]}):null,i.jsx(Au,{engine:"milkdown",value:L.body,onChange:U=>_(kU(L.frontmatter,L.separator,U)),bordered:!1,placeholder:"Write in Markdown...",contentClassName:"rudder-library-document-editor rudder-side-panel-library-document min-h-[420px] text-[15px] leading-7 text-foreground"},e.canonicalPath)]}):i.jsx("div",{ref:j,className:"min-h-0 flex-1 pb-14",children:i.jsx(BT,{"data-testid":"chat-side-panel-local-file-source-editor",annotationSource:{surface:"local_file",sourceFilePath:e.canonicalPath},ariaLabel:`${e.fileName} source editor`,filePath:e.canonicalPath,value:h,onChange:_,onSelectionChange:N})}),i.jsx(qQe,{containerRef:j,conversationId:t,explicitSelection:e.previewKind==="markdown"?void 0:C,saved:x==="saved"&&!k&&h===l.current,source:h,sourceIdentity:{surface:"local_file",sourceFilePath:e.canonicalPath},sourceRenderMode:e.previewKind==="markdown"?"markdown":"text",renderedSource:e.previewKind==="markdown"?L.body:h,renderedSourceOffset:e.previewKind==="markdown"?h.length-L.body.length:0}),i.jsxs("div",{className:`absolute bottom-3 left-3 z-10 flex min-h-8 items-center gap-2 rounded-md border border-border bg-[color:var(--surface-elevated)] px-2.5 text-xs shadow-sm ${x==="error"?"text-destructive":"text-muted-foreground"}`,role:x==="error"?"alert":"status",title:v??void 0,children:[i.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${x==="error"?"bg-destructive":x==="saving"?"bg-[color:var(--accent-strong)]":"bg-emerald-500"}`}),i.jsx("span",{children:k?"Conflict":x==="error"?"Save failed":x==="saving"?"Saving":"Saved"}),k?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:T,children:"Keep mine"}),i.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:R,children:"Use latest"})]}):x==="error"?i.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:M,children:"Retry"}):null]})]})}function JCn({targetPath:e,label:t,sourceConversationId:n=null}){const r=Pn(),[s,a]=m.useState(null),[o,l]=m.useState(()=>r?null:"Local file previews are available in the Rudder Desktop app."),[c,d]=m.useState(!!r);m.useEffect(()=>{let A=!1;if(!r){a(null),d(!1),l("Local file previews are available in the Rudder Desktop app.");return}return d(!0),l(null),r.previewLocalFile(e).then(h=>{A||a(h)}).catch(h=>{A||(a(null),l(GCn(h,t)))}).finally(()=>{A||d(!1)}),()=>{A=!0}},[r,t,e]);const u=m.useMemo(()=>s?XCn(s):null,[s]),f=async()=>{if(!(!r||!s))try{await r.openPath(s.canonicalPath)}catch(A){l(A instanceof Error?A.message:`Could not open ${t}.`)}};return c?i.jsxs("div",{className:"flex min-h-[16rem] items-center justify-center text-sm text-muted-foreground",role:"status",children:[i.jsx(yn,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":!0}),"Loading ",t]}):o||!s||!u?i.jsx("div",{className:"p-4",children:i.jsx("div",{role:"alert",className:"rounded-[var(--radius-md)] border border-border bg-muted/20 px-3 py-3 text-sm text-muted-foreground",children:o??`Could not preview ${t}.`})}):i.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-testid":"chat-side-panel-local-file-view",children:[i.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b border-border px-4 py-3",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:s.fileName||t}),i.jsx("div",{className:"truncate text-xs text-muted-foreground",title:s.parentPath,children:s.parentPath})]}),i.jsxs("button",{type:"button",className:"inline-flex h-8 items-center gap-1.5 rounded-[var(--radius-sm)] border border-border px-2.5 text-xs text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",onClick:()=>void f(),children:[i.jsx(La,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Open"]})]}),s.truncated?i.jsx("div",{className:"shrink-0 border-b border-border bg-amber-500/10 px-4 py-2 text-xs text-amber-800 dark:text-amber-200",role:"status",children:"Showing a bounded preview. Open the file to inspect the complete content."}):null,!s.truncated&&s.content!==null?i.jsx(YCn,{preview:s,sourceConversationId:n,onPreviewChange:a}):i.jsx(jat,{file:u,organizationId:"local-transcript-file",testIdPrefix:"transcript-local-file"})]})}function CU(e){return Array.isArray(e)?`[${e.map(CU).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).filter(([,n])=>n!==void 0).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>`${JSON.stringify(n)}:${CU(r)}`).join(",")}}`:JSON.stringify(e)}function eNn(e){const t=Math.max(0,e.debounceMs??350),n=e.retryDelaysMs??[120,400],r=Math.max(1,e.maxRememberedSuccesses??32),s=new Map,a=new Map,o=new Set,l=(x,y)=>{for(a.delete(x),a.set(x,y);a.size>r;){const v=a.keys().next().value;if(v===void 0)break;a.delete(v)}},c=x=>{const y=s.get(x);if(y)return y;const v={timer:null,pending:null,failed:null,running:null};return s.set(x,v),v},d=x=>new Promise(y=>{setTimeout(y,Math.max(0,x))}),u=x=>{const y=s.get(x);if(!y)return Promise.resolve();if(o.has(x))return y.running??Promise.resolve();if(y.timer&&(clearTimeout(y.timer),y.timer=null),y.running)return y.running;if(!y.pending&&y.failed&&(y.pending=y.failed,y.failed=null),!y.pending)return Promise.resolve();const v=(async()=>{for(;y.pending&&!o.has(x);){let w=y.pending;y.pending=null;let k=!1;for(let O=0;O<=n.length&&!o.has(x);O+=1){y.pending&&(w=y.pending,y.pending=null,O=0);try{if(await e.update(w.organizationId,w.savedViewId,w.metadata),o.has(x))break;l(x,w.fingerprint),y.failed=null,k=!0;break}catch{if(o.has(x))break;if(O>=n.length){y.failed=y.pending??w,y.pending=null;break}await d(n[O]??0)}}if(o.has(x)){y.pending=null,y.failed=null;break}if(!k&&!y.pending)break}})();return y.running=v,v.finally(()=>{y.running===v&&(y.running=null),o.has(x)&&s.delete(x)}),v},f=x=>{if(o.has(x.savedViewId))return;const y=CU(x.metadata),v=a.get(x.savedViewId),w=s.get(x.savedViewId);if(v?v===y:!w&&y===CU(x.persistedMetadata))return;const k=c(x.savedViewId);k.pending={organizationId:x.organizationId,savedViewId:x.savedViewId,metadata:x.metadata,fingerprint:y},k.failed=null,!k.running&&(k.timer&&clearTimeout(k.timer),k.timer=setTimeout(()=>{k.timer=null,u(x.savedViewId)},t))},A=x=>{o.add(x),a.delete(x);const y=s.get(x);y&&(y.timer&&clearTimeout(y.timer),y.timer=null,y.pending=null,y.failed=null,y.running||s.delete(x))},h=async x=>{const y=s.get(x);if(y)for(await u(x);y.running||y.pending;)y.running&&await y.running,y.pending&&await u(x)};return{schedule:f,cancelSavedView:A,flushSavedView:h,flushAll:async()=>{await Promise.all([...s.keys()].map(h))}}}function Joe(e){return e.viewInstanceId??e.tabId}function T9e(e,t){return{target:{kind:"browser",tabId:e.tabId,url:e.url,viewInstanceId:Joe(e)},title:e.label,subtitle:e.url,favicon:e.favicon!==void 0?e.favicon:t.target.url===e.url?t.favicon:null}}function Cat({browserTargets:e,organizationId:t}){const n=Wn(),r=m.useMemo(()=>eNn({update:async(f,A,h)=>{await Es.updateSavedView(f,A,h),n.invalidateQueries({queryKey:V.messenger.customGroups(f)})}}),[n]),s=Te({queryKey:V.messenger.customGroups(t??"__none__"),queryFn:()=>Es.listCustomGroups(t),enabled:!!(t&&e.length>0)}),a=m.useMemo(()=>s.data&&!Array.isArray(s.data)?s.data.groups:[],[s.data]),o=m.useMemo(()=>a.flatMap(f=>f.entries).filter(f=>f.item.type==="saved_view"),[a]),l=m.useMemo(()=>new Set(o.map(f=>f.item.type==="saved_view"?f.item.savedView.id:"")),[o]),c=m.useRef(new Map);m.useLayoutEffect(()=>{var A,h;if(!t)return;const f=new Map;for(const g of e){const x=Joe(g),y=o.find(j=>j.item.type==="saved_view"&&j.item.savedView.targetPayload.kind==="browser"&&j.item.savedView.targetPayload.viewInstanceId===x),v=(y==null?void 0:y.item.type)==="saved_view"?y.item.savedView:null,w=(v==null?void 0:v.targetPayload.kind)==="browser"?{target:v.targetPayload,title:v.title,subtitle:v.subtitle,favicon:v.favicon}:null,k=(v==null?void 0:v.targetPayload.kind)==="browser"?v.id:s.isSuccess?null:((A=g.savedViewRecovery)==null?void 0:A.id)??null,O=w??(s.isSuccess?null:((h=g.savedViewRecovery)==null?void 0:h.persistedMetadata)??null);s.isSuccess&&g.savedViewRecovery&&!l.has(g.savedViewRecovery.id)&&r.cancelSavedView(g.savedViewRecovery.id),!(!k||!O)&&(f.set(x,{savedViewId:k,persistedMetadata:O}),r.schedule({organizationId:t,savedViewId:k,metadata:T9e(g,O),persistedMetadata:O}))}for(const[g,x]of c.current)f.has(g)||(s.isSuccess&&!l.has(x.savedViewId)?r.cancelSavedView(x.savedViewId):r.flushSavedView(x.savedViewId));c.current=f},[e,s.isSuccess,t,r,o,l]),m.useEffect(()=>()=>{r.flushAll()},[r]);const d=m.useCallback(f=>{const A=f.savedViewRecovery;if(s.isSuccess&&A&&!l.has(A.id))return r.cancelSavedView(A.id),Promise.resolve();const h=c.current.get(Joe(f)),g=h&&(!s.isSuccess||o.some(x=>x.item.type==="saved_view"&&x.item.savedView.id===h.savedViewId))?h:!s.isSuccess&&A?{savedViewId:A.id,persistedMetadata:A.persistedMetadata}:null;return!g||!t?Promise.resolve():(r.schedule({organizationId:t,savedViewId:g.savedViewId,metadata:T9e(f,g.persistedMetadata),persistedMetadata:g.persistedMetadata}),r.flushSavedView(g.savedViewId))},[s.isSuccess,t,r,o,l]);return{flushAll:m.useCallback(()=>r.flushAll(),[r]),flushTarget:d}}function DE(){const{data:e}=Te({queryKey:V.instance.profileSettings,queryFn:()=>fo.getProfile(),staleTime:Wo});return Dfe(e==null?void 0:e.nickname)}const NU="chatResponseAnnotationSource";function A1e(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Nat(e,t,n){return{...A1e(n),[NU]:{annotation:e,ordinal:t}}}function tNn(e){const t=A1e(e)[NU];if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t,r=VDe.safeParse(n.annotation);return!r.success||typeof n.ordinal!="number"||!Number.isInteger(n.ordinal)||n.ordinal<1?null:{annotation:r.data,ordinal:n.ordinal}}function nNn(e){const t=A1e(e);if(!(NU in t))return e;const{[NU]:n,...r}=t;return Object.keys(r).length>0?r:null}const rNn=YO("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-[calc(var(--radius-sm)-1px)] border px-2.5 py-1 text-xs font-medium whitespace-nowrap [&>svg]:size-3 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,background-color,border-color,box-shadow]",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-[color:color-mix(in_oklab,var(--border-soft)_94%,transparent)] bg-secondary text-secondary-foreground [a&]:hover:bg-[color:var(--surface-active)]",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/80",outline:"border-[color:var(--border-base)] bg-[color:color-mix(in_oklab,var(--surface-elevated)_98%,transparent)] text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"border-transparent bg-transparent [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function $i({className:e,variant:t="default",asChild:n=!1,...r}){const s=n?ice:"span";return i.jsx(s,{"data-slot":"badge","data-variant":t,className:q(rNn({variant:t}),e),...r})}function Zo({...e}){return i.jsx(XMe,{"data-slot":"select",...e})}function Pat({...e}){return i.jsx(m1t,{"data-slot":"select-group",...e})}function Ho({...e}){return i.jsx(YMe,{"data-slot":"select-value",...e})}function Xo({className:e,size:t="default",children:n,...r}){return i.jsxs(GMe,{"data-slot":"select-trigger","data-size":t,className:q("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-fit items-center justify-between gap-[var(--control-gap)] rounded-[var(--control-radius)] border bg-[color:var(--input-background)] px-[var(--control-padding-x-sm)] py-2 text-[length:var(--control-font-size)] whitespace-nowrap shadow-none transition-[color,box-shadow,border-color,background-color] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[var(--control-height-sm)] data-[size=sm]:h-[var(--control-height-xs)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-[var(--control-icon-size)]",e),...r,children:[n,i.jsx(JMe,{asChild:!0,children:i.jsx(Br,{className:"size-4 opacity-50"})})]})}function Go({className:e,children:t,position:n="item-aligned",align:r="center",...s}){return i.jsx(eEe,{children:i.jsxs(tEe,{"data-slot":"select-content",className:q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[var(--menu-min-width)] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-[var(--menu-radius)] border border-[color:var(--border-base)] shadow-[var(--shadow-md)]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:r,...s,children:[i.jsx(sNn,{}),i.jsx(nEe,{className:q("p-[var(--menu-padding)]",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),i.jsx(iNn,{})]})})}function Vs({className:e,children:t,icon:n,...r}){return i.jsxs(rEe,{"data-slot":"select-item",className:q("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex min-h-[var(--menu-item-min-height)] w-full cursor-default items-center gap-[var(--control-gap)] rounded-[var(--menu-item-radius)] py-[var(--menu-item-padding-y)] pr-8 pl-2 text-[length:var(--menu-item-font-size)] outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-[var(--control-icon-size)] *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[n?i.jsx("span",{"aria-hidden":"true",className:"flex size-4 shrink-0 items-center justify-center text-muted-foreground",children:n}):null,i.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:i.jsx(p1t,{children:i.jsx(Zi,{className:"size-4"})})}),i.jsx(sEe,{children:i.jsx("span",{className:"min-w-0 truncate",children:t})})]})}function sNn({className:e,...t}){return i.jsx(g1t,{"data-slot":"select-scroll-up-button",className:q("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(kq,{className:"size-4"})})}function iNn({className:e,...t}){return i.jsx(x1t,{"data-slot":"select-scroll-down-button",className:q("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(Br,{className:"size-4"})})}function ma({icon:e,message:t,action:n,onAction:r,className:s}){return i.jsxs("div",{className:q("surface-panel mx-auto flex max-w-xl flex-col items-center justify-center rounded-[var(--radius-xl)] px-8 py-14 text-center",s),children:[i.jsx("div",{className:"mb-5 flex h-16 w-16 items-center justify-center rounded-[calc(var(--radius-md)+4px)] border border-[color:var(--border-soft)] bg-[color:color-mix(in_oklab,var(--surface-proposal)_72%,transparent)]",children:i.jsx(e,{className:"h-8 w-8 text-[color:var(--accent-base)]"})}),i.jsx("p",{className:"font-display text-[1.5rem] leading-tight text-foreground",children:"Nothing here yet"}),i.jsx("p",{className:"mt-3 max-w-md text-sm leading-6 text-muted-foreground",children:t}),n&&r&&i.jsxs(ie,{onClick:r,className:"mt-6",children:[i.jsx(Ur,{className:"h-4 w-4 mr-1.5"}),n]})]})}function Oee(e){return e?typeof e=="string"?e:e.toISOString():null}function _9e(e){return e==="queued"||e==="running"}function Iat({issueId:e,orgId:t}){const n=Wn(),[r,s]=m.useState(new Set),{data:a}=Te({queryKey:V.issues.liveRuns(e),queryFn:()=>So.liveRunsForIssue(e),enabled:!!e,refetchInterval:3e3}),{data:o}=Te({queryKey:V.issues.activeRun(e),queryFn:()=>So.activeRunForIssue(e),enabled:!!e,refetchInterval:3e3}),l=m.useMemo(()=>{const g=new Map;for(const x of a??[])g.set(x.id,x);return o&&g.set(o.id,{id:o.id,status:o.status,invocationSource:o.invocationSource,triggerDetail:o.triggerDetail,startedAt:Oee(o.startedAt),finishedAt:Oee(o.finishedAt),createdAt:Oee(o.createdAt)??new Date().toISOString(),agentId:o.agentId,agentName:o.agentName,agentRuntimeType:o.agentRuntimeType,issueId:e}),[...g.values()].sort((x,y)=>new Date(y.createdAt).getTime()-new Date(x.createdAt).getTime())},[o,e,a]),{transcriptByRun:c,hasOutputForRun:d}=_E({runs:l,orgId:t}),u=l.some(g=>_9e(g.status)),{data:f}=Te({queryKey:V.agents.list(t??"__none__"),queryFn:()=>_n.list(t),enabled:!!t&&l.length>0}),A=m.useMemo(()=>new Map((f??[]).map(g=>[g.id,g])),[f]),h=async g=>{s(x=>new Set(x).add(g));try{await So.cancel(g),n.invalidateQueries({queryKey:V.issues.liveRuns(e)}),n.invalidateQueries({queryKey:V.issues.activeRun(e)})}finally{s(x=>{const y=new Set(x);return y.delete(g),y})}};return l.length===0?null:i.jsxs("div",{"data-active-surface":u?"live-run":void 0,className:q("overflow-hidden rounded-xl border border-cyan-500/25 bg-background/80 shadow-[0_18px_50px_rgba(6,182,212,0.08)]",u&&"active-surface-ring"),children:[i.jsxs("div",{className:"border-b border-border/60 bg-cyan-500/[0.04] px-4 py-3",children:[i.jsx("div",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-cyan-700 dark:text-cyan-300",children:"Live Runs"}),i.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Streamed with the same transcript UI used on the full run detail page."})]}),i.jsx("div",{className:"divide-y divide-border/60",children:l.map(g=>{const x=_9e(g.status),y=c.get(g.id)??[],v=A.get(g.agentId)??null,w=Aq(g.startedAt??g.createdAt,x?null:g.finishedAt);return i.jsxs("section",{className:"px-4 py-4",children:[i.jsxs("div",{className:"mb-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx(an,{to:`/agents/${g.agentId}`,className:"inline-flex hover:underline",children:v?i.jsx(uu,{name:v.name,icon:v.icon,role:v.role,size:"sm"}):i.jsx(Jd,{name:g.agentName,size:"sm"})}),i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[i.jsx(an,{to:`/agents/${g.agentId}/runs/${g.id}`,className:"inline-flex items-center rounded-full border border-border/70 bg-background/70 px-2 py-1 font-mono hover:border-cyan-500/30 hover:text-foreground",children:g.id.slice(0,8)}),i.jsx(Ds,{status:g.status}),i.jsx("span",{children:Ja(g.startedAt??g.createdAt)}),w?i.jsx("span",{children:x?`Live for ${w}`:`Ran for ${w}`}):null]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[x&&i.jsxs("button",{onClick:()=>h(g.id),disabled:r.has(g.id),className:"inline-flex items-center gap-1 rounded-full border border-red-500/20 bg-red-500/[0.06] px-2.5 py-1 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-500/[0.12] dark:text-red-300 disabled:opacity-50",children:[i.jsx(T3,{className:"h-2.5 w-2.5",fill:"currentColor"}),r.has(g.id)?"Stopping…":"Stop"]}),i.jsxs(an,{to:`/agents/${g.agentId}/runs/${g.id}`,className:"inline-flex items-center gap-1 rounded-full border border-border/70 bg-background/70 px-2.5 py-1 text-[11px] font-medium text-cyan-700 transition-colors hover:border-cyan-500/30 hover:text-cyan-600 dark:text-cyan-300",children:["Open run",i.jsx(La,{className:"h-3 w-3"})]})]})]}),i.jsx("div",{className:"max-h-[320px] overflow-y-auto pr-1",children:i.jsx(jg,{entries:y,density:"compact",limit:8,streaming:x,collapseStdout:!0,presentation:"chat",emptyMessage:d(g.id)?"Waiting for transcript parsing...":"Waiting for run output..."})})]},g.id)})})]})}function Co({variant:e="list"}){return e==="dashboard"?i.jsxs("div",{className:"space-y-6",children:[i.jsx(un,{className:"h-32 w-full border border-border"}),i.jsx("div",{className:"grid grid-cols-2 gap-2 xl:grid-cols-4",children:Array.from({length:4}).map((t,n)=>i.jsx(un,{className:"h-24 w-full"},n))}),i.jsx("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:Array.from({length:4}).map((t,n)=>i.jsx(un,{className:"h-44 w-full"},n))}),i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsx(un,{className:"h-72 w-full"}),i.jsx(un,{className:"h-72 w-full"})]})]}):e==="approvals"?i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx(un,{className:"h-9 w-44"})}),i.jsx("div",{className:"grid gap-3",children:Array.from({length:3}).map((t,n)=>i.jsx(un,{className:"h-36 w-full"},n))})]}):e==="costs"?i.jsxs("div",{className:"space-y-6",children:[i.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Array.from({length:6}).map((t,n)=>i.jsx(un,{className:"h-9 w-28"},n))}),i.jsx(un,{className:"h-40 w-full"}),i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsx(un,{className:"h-72 w-full"}),i.jsx(un,{className:"h-72 w-full"})]})]}):e==="inbox"?i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(un,{className:"h-9 w-56"}),i.jsx(un,{className:"h-8 w-40"})]}),i.jsx("div",{className:"space-y-5",children:Array.from({length:3}).map((t,n)=>i.jsxs("div",{className:"space-y-2",children:[i.jsx(un,{className:"h-4 w-40"}),i.jsx("div",{className:"space-y-1 border border-border",children:Array.from({length:3}).map((r,s)=>i.jsx(un,{className:"h-14 w-full rounded-none"},s))})]},n))})]}):e==="detail"?i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx(un,{className:"h-3 w-64"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(un,{className:"h-6 w-6"}),i.jsx(un,{className:"h-6 w-6"}),i.jsx(un,{className:"h-7 w-48"})]}),i.jsx(un,{className:"h-4 w-40"})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(un,{className:"h-10 w-full"}),i.jsx(un,{className:"h-32 w-full"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(un,{className:"h-8 w-24"}),i.jsx(un,{className:"h-8 w-24"}),i.jsx(un,{className:"h-8 w-24"})]}),i.jsx(un,{className:"h-24 w-full"}),i.jsx(un,{className:"h-24 w-full"})]})]}):e==="issues-list"?i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[i.jsx(un,{className:"h-9 w-64"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(un,{className:"h-8 w-16"}),i.jsx(un,{className:"h-8 w-16"}),i.jsx(un,{className:"h-8 w-16"}),i.jsx(un,{className:"h-8 w-24"})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(un,{className:"h-4 w-40"}),i.jsx("div",{className:"space-y-1",children:Array.from({length:8}).map((t,n)=>i.jsx(un,{className:"h-11 w-full rounded-none"},n))})]})]}):i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[i.jsx(un,{className:"h-9 w-44"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(un,{className:"h-8 w-20"}),i.jsx(un,{className:"h-8 w-24"})]})]}),i.jsx("div",{className:"space-y-1",children:Array.from({length:7}).map((t,n)=>i.jsx(un,{className:"h-11 w-full rounded-none"},n))})]})}const ele=[{value:"every_minute",label:"Every minute"},{value:"every_hour",label:"Every hour"},{value:"every_day",label:"Every day"},{value:"weekdays",label:"Weekdays"},{value:"weekly",label:"Weekly"},{value:"monthly",label:"Monthly"},{value:"custom",label:"Custom (cron)"}],Tat=Array.from({length:24},(e,t)=>({value:String(t),label:String(t).padStart(2,"0")})),jee=Array.from({length:12},(e,t)=>({value:String(t*5),label:String(t*5).padStart(2,"0")})),PU=[{value:"1",label:"Mon"},{value:"2",label:"Tue"},{value:"3",label:"Wed"},{value:"4",label:"Thu"},{value:"5",label:"Fri"},{value:"6",label:"Sat"},{value:"0",label:"Sun"}],M9e=Array.from({length:31},(e,t)=>({value:String(t+1),label:String(t+1)})),aNn={every_minute:"每分钟",every_hour:"每小时",every_day:"每天",weekdays:"工作日",weekly:"每周",monthly:"每月",custom:"自定义 cron"},oNn={1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",0:"周日"};function E9e(e,t){var n;return t==="zh-CN"?aNn[e]:((n=ele.find(r=>r.value===e))==null?void 0:n.label)??e}function D9e(e,t){var n;return t==="zh-CN"?oNn[e]??e:((n=PU.find(r=>r.value===e))==null?void 0:n.label)??e}function tle(e){const t={hour:"10",minute:"0",dayOfWeek:"1",dayOfMonth:"1"};if(!e||!e.trim())return{preset:"every_day",...t};const n=e.trim().split(/\s+/);if(n.length!==5)return{preset:"custom",...t};const[r,s,a,,o]=n;return r==="*"&&s==="*"&&a==="*"&&o==="*"?{preset:"every_minute",...t}:s==="*"&&a==="*"&&o==="*"?{preset:"every_hour",...t,minute:r==="*"?"0":r}:a==="*"&&o==="*"&&s!=="*"?{preset:"every_day",...t,hour:s,minute:r==="*"?"0":r}:a==="*"&&o==="1-5"&&s!=="*"?{preset:"weekdays",...t,hour:s,minute:r==="*"?"0":r}:a==="*"&&/^\d$/.test(o)&&s!=="*"?{preset:"weekly",...t,hour:s,minute:r==="*"?"0":r,dayOfWeek:o}:/^\d{1,2}$/.test(a)&&o==="*"&&s!=="*"?{preset:"monthly",...t,hour:s,minute:r==="*"?"0":r,dayOfMonth:a}:{preset:"custom",...t}}function lNn(e,t,n,r,s){switch(e){case"every_minute":return"* * * * *";case"every_hour":return`${n} * * * *`;case"every_day":return`${n} ${t} * * *`;case"weekdays":return`${n} ${t} * * 1-5`;case"weekly":return`${n} ${t} * * ${r}`;case"monthly":return`${n} ${t} ${s} * *`;case"custom":return""}}function IU(e,t){var d,u;const{preset:n,hour:r,minute:s,dayOfWeek:a,dayOfMonth:o}=tle(e),c=`${(((d=Tat.find(f=>f.value===r))==null?void 0:d.label)??`${r}`).padStart(2,"0")}:${s.padStart(2,"0")}`;switch(n){case"every_minute":return t==="zh-CN"?"每分钟":"Every minute";case"every_hour":return t==="zh-CN"?`每小时 ${Number(s)} 分`:`Every hour at :${s.padStart(2,"0")}`;case"every_day":return t==="zh-CN"?`每天 ${c}`:`Every day at ${c}`;case"weekdays":return t==="zh-CN"?`工作日 ${c}`:`Weekdays at ${c}`;case"weekly":{const A=t==="zh-CN"?{1:"一",2:"二",3:"三",4:"四",5:"五",6:"六",0:"日"}[a]??a:((u=PU.find(h=>h.value===a))==null?void 0:u.label)??a;return t==="zh-CN"?`每周${A} ${c}`:`Every ${A} at ${c}`}case"monthly":return t==="zh-CN"?`每月 ${o} 日 ${c}`:`Monthly on the ${o}${cNn(Number(o))} at ${c}`;case"custom":return e||(t==="zh-CN"?"未设置日程":"No schedule set")}}function cNn(e){const t=["th","st","nd","rd"],n=e%100;return t[(n-20)%10]||t[n]||t[0]}function rZ({value:e,onChange:t,variant:n="default"}){const r=m.useMemo(()=>tle(e),[e]),[s,a]=m.useState(r.preset),[o,l]=m.useState(r.hour),[c,d]=m.useState(r.minute),[u,f]=m.useState(r.dayOfWeek),[A,h]=m.useState(r.dayOfMonth),[g,x]=m.useState(s==="custom"?e:""),{locale:y}=as();m.useEffect(()=>{const O=tle(e);a(O.preset),l(O.hour),d(O.minute),f(O.dayOfWeek),h(O.dayOfMonth),O.preset==="custom"&&x(e)},[e]);const v=m.useCallback((O,j,C,N,I,E)=>{t(O==="custom"?E:lNn(O,j,C,N,I))},[t]),w=O=>{a(O),O==="custom"?x(e):v(O,o,c,u,A,g)},k=O=>{const[j,C]=O.split(":");if(j===void 0||C===void 0)return;const N=String(Number(j)),I=String(Number(C));l(N),d(I),v(s,N,I,u,A,g)};if(n==="compact"){const O=s!=="every_minute"&&s!=="every_hour"&&s!=="custom";return i.jsxs("div",{className:"space-y-2",children:[i.jsxs(Zo,{value:s,onValueChange:j=>w(j),children:[i.jsx(Xo,{className:"h-12 w-full rounded-md border-border/75 bg-background/60 px-3 text-base shadow-none md:text-sm",children:i.jsx(Ho,{placeholder:y==="zh-CN"?"选择频率...":"Choose frequency..."})}),i.jsx(Go,{children:ele.map(j=>i.jsx(Vs,{value:j.value,children:E9e(j.value,y)},j.value))})]}),O?i.jsx(Vn,{type:"time",step:300,value:`${o.padStart(2,"0")}:${c.padStart(2,"0")}`,onChange:j=>k(j.target.value),className:"h-12 rounded-md border-border/75 bg-background/60 text-base shadow-none md:text-sm"}):null,s==="every_hour"?i.jsxs(Zo,{value:c,onValueChange:j=>{d(j),v(s,o,j,u,A,g)},children:[i.jsx(Xo,{className:"h-12 w-full rounded-md border-border/75 bg-background/60 px-3 text-base shadow-none md:text-sm",children:i.jsx(Ho,{})}),i.jsx(Go,{children:jee.map(j=>i.jsxs(Vs,{value:j.value,children:[":",j.label]},j.value))})]}):null,s==="weekly"?i.jsxs(Zo,{value:u,onValueChange:j=>{f(j),v(s,o,c,j,A,g)},children:[i.jsx(Xo,{className:"h-12 w-full rounded-md border-border/75 bg-background/60 px-3 text-base shadow-none md:text-sm",children:i.jsx(Ho,{})}),i.jsx(Go,{children:PU.map(j=>i.jsx(Vs,{value:j.value,children:D9e(j.value,y)},j.value))})]}):null,s==="monthly"?i.jsxs(Zo,{value:A,onValueChange:j=>{h(j),v(s,o,c,u,j,g)},children:[i.jsx(Xo,{className:"h-12 w-full rounded-md border-border/75 bg-background/60 px-3 text-base shadow-none md:text-sm",children:i.jsx(Ho,{})}),i.jsx(Go,{children:M9e.map(j=>i.jsx(Vs,{value:j.value,children:j.label},j.value))})]}):null,s==="custom"?i.jsx(Vn,{value:g,onChange:j=>{x(j.target.value),v("custom",o,c,u,A,j.target.value)},placeholder:"0 10 * * *",className:"h-12 rounded-md border-border/75 bg-background/60 font-mono text-sm shadow-none"}):null]})}return i.jsxs("div",{className:"space-y-3",children:[i.jsxs(Zo,{value:s,onValueChange:O=>w(O),children:[i.jsx(Xo,{className:"w-full",children:i.jsx(Ho,{placeholder:y==="zh-CN"?"选择频率...":"Choose frequency..."})}),i.jsx(Go,{children:ele.map(O=>i.jsx(Vs,{value:O.value,children:E9e(O.value,y)},O.value))})]}),s==="custom"?i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Vn,{value:g,onChange:O=>{x(O.target.value),v("custom",o,c,u,A,O.target.value)},placeholder:"0 10 * * *",className:"font-mono text-sm"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:y==="zh-CN"?"五个字段:分钟 小时 日期 月份 星期":"Five fields: minute hour day-of-month month day-of-week"})]}):i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s!=="every_minute"&&s!=="every_hour"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:y==="zh-CN"?"时间":"at"}),i.jsxs(Zo,{value:o,onValueChange:O=>{l(O),v(s,O,c,u,A,g)},children:[i.jsx(Xo,{className:"w-[120px]",children:i.jsx(Ho,{})}),i.jsx(Go,{children:Tat.map(O=>i.jsx(Vs,{value:O.value,children:O.label},O.value))})]}),i.jsx("span",{className:"text-sm text-muted-foreground",children:":"}),i.jsxs(Zo,{value:c,onValueChange:O=>{d(O),v(s,o,O,u,A,g)},children:[i.jsx(Xo,{className:"w-[80px]",children:i.jsx(Ho,{})}),i.jsx(Go,{children:jee.map(O=>i.jsx(Vs,{value:O.value,children:O.label},O.value))})]})]}),s==="every_hour"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:y==="zh-CN"?"第几分钟":"at minute"}),i.jsxs(Zo,{value:c,onValueChange:O=>{d(O),v(s,o,O,u,A,g)},children:[i.jsx(Xo,{className:"w-[80px]",children:i.jsx(Ho,{})}),i.jsx(Go,{children:jee.map(O=>i.jsxs(Vs,{value:O.value,children:[":",O.label]},O.value))})]})]}),s==="weekly"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:y==="zh-CN"?"在":"on"}),i.jsx("div",{className:"flex gap-1",children:PU.map(O=>i.jsx(ie,{type:"button",variant:u===O.value?"default":"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>{f(O.value),v(s,o,c,O.value,A,g)},children:D9e(O.value,y)},O.value))})]}),s==="monthly"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:y==="zh-CN"?"日期":"on day"}),i.jsxs(Zo,{value:A,onValueChange:O=>{h(O),v(s,o,c,u,O,g)},children:[i.jsx(Xo,{className:"w-[80px]",children:i.jsx(Ho,{})}),i.jsx(Go,{children:M9e.map(O=>i.jsx(Vs,{value:O.value,children:O.label},O.value))})]})]})]})]})}const _at=m.createContext(null);function Mat({children:e,manageDocumentTitle:t=!0}){const[n,r]=m.useState([]),[s,a]=m.useState(null),o=m.useCallback(c=>{r(c)},[]),l=m.useCallback(c=>{a(c)},[]);return m.useEffect(()=>{if(t)if(n.length===0)document.title="Rudder";else{const c=[...n].reverse().flatMap(d=>{const u=[d.label];return d.sublabel&&u.push(d.sublabel),u});document.title=`${c.join(" · ")} · Rudder`}},[n,t]),i.jsx(_at.Provider,{value:{breadcrumbs:n,setBreadcrumbs:o,headerActions:s,setHeaderActions:l},children:e})}function ea(){const e=m.useContext(_at);if(!e)throw new Error("useBreadcrumbs must be used within BreadcrumbProvider");return e}const dNn={coalesce_if_active:{en:"coalesce if active","zh-CN":"有运行时合并"},always_enqueue:{en:"always enqueue","zh-CN":"始终排队"},skip_if_active:{en:"skip if active","zh-CN":"有运行时跳过"},skip_missed:{en:"skip missed","zh-CN":"跳过错过窗口"},enqueue_missed_with_cap:{en:"enqueue missed with cap","zh-CN":"限量补跑错过窗口"}},Eat={coalesce_if_active:{en:"Keep one follow-up run queued while an active run is still working.","zh-CN":"当前运行仍在执行时,只保留一个后续运行排队。"},always_enqueue:{en:"Queue every trigger occurrence, even if several runs stack up.","zh-CN":"每次触发都进入队列,即使多个运行堆积。"},skip_if_active:{en:"Drop overlapping trigger occurrences while the automation is already active.","zh-CN":"自动化已有运行时,丢弃重叠触发。"}},Dat={skip_missed:{en:"Ignore schedule windows that were missed while the automation or scheduler was paused.","zh-CN":"忽略自动化或调度器暂停期间错过的计划窗口。"},enqueue_missed_with_cap:{en:"Catch up missed schedule windows in capped batches after recovery.","zh-CN":"恢复后按上限分批补跑错过的计划窗口。"}};function Rat(e,t){return e[t]??e.en}function TU(e,t){return Rat(dNn[e]??{en:e.replaceAll("_"," "),"zh-CN":e.replaceAll("_"," ")},t)}function _U(e,t,n){const r=e[t];return r?Rat(r,n):t.replaceAll("_"," ")}function R9e(e,t,n){const r={};return e.kind==="schedule"&&(r.cronExpression=t.cronExpression.trim(),r.timezone=e.timezone??n),e.kind==="webhook"&&(r.signingMode=t.signingMode,r.replayWindowSec=Number(t.replayWindowSec||"300")),r}const uNn=["coalesce_if_active","always_enqueue","skip_if_active"],fNn=["skip_missed","enqueue_missed_with_cap"],ANn=["bearer","hmac_sha256"];function Cee(e,t){return e.includes(t)?e:[...e,t]}function Nee(e,t){return e.filter(n=>n!==t)}function L9e(e){e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}function Lat(e){if(e===null)return"null";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length===0?"[]":e.map(t=>Lat(t)).join(", ");try{return JSON.stringify(e)}catch{return"[unserializable]"}}function oA(e,t){const n=e==null?void 0:e[t];return typeof n=="string"&&n.trim()?n:null}function MU(e,t="en"){return UO(t,e.replaceAll("_"," "))}function ek(e,t="en"){return e==="schedule"?t==="zh-CN"?"日程触发器":"Schedule trigger":e==="webhook"?t==="zh-CN"?"Webhook 触发器":"Webhook trigger":e?t==="zh-CN"?`${MU(e,t)}触发器`:`${MU(e,t)} trigger`:t==="zh-CN"?"触发器":"Trigger"}function hNn(e,t="en"){return e==="manual"?t==="zh-CN"?"手动运行":"Manual run":e==="schedule"?t==="zh-CN"?"计划运行":"Scheduled run":e==="webhook"?t==="zh-CN"?"Webhook 运行":"Webhook run":MU(e,t)}function nle(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}function UC(e,t){return e?Ja(e):t}function X8(e,t="en"){return e?e.kind==="schedule"&&e.cronExpression?IU(e.cronExpression,t):e.kind==="webhook"?t==="zh-CN"?"Webhook 触发器":"Webhook trigger":ek(e.kind,t):"No triggers configured"}function mNn(e){return e.triggerCount===0?"No trigger":e.hasAssignee?e.latestRunStatus==="failed"?"Last failed":e.hasLiveRun?"Active run":"Normal":"No owner"}function Pee({title:e,children:t,card:n=!1}){return i.jsxs("section",{className:"space-y-2.5",children:[i.jsx("h2",{className:q("font-medium text-muted-foreground",n?"text-sm":"text-xs"),children:e}),i.jsx("div",{className:q("space-y-2.5",n&&"rounded-md border border-border/70 bg-card/70 px-3.5 py-2.5"),children:t})]})}function JL({label:e,children:t}){return i.jsxs("div",{className:"grid grid-cols-[76px_minmax(0,1fr)] items-center gap-3 text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:e}),i.jsx("div",{className:"min-w-0 text-right text-foreground",children:t})]})}function ny({label:e,children:t,align:n="center"}){return i.jsxs("div",{className:q("flex gap-3 py-1.5",n==="start"?"items-start":"items-center"),children:[i.jsx("span",{className:"w-20 shrink-0 text-xs text-muted-foreground",children:e}),i.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t})]})}function ez({children:e}){return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:e}),i.jsx(Br,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80"})]})}function pNn({trigger:e,onSave:t,onRotate:n,onDelete:r,isSaving:s,isDeleting:a,isRotating:o,saveError:l}){const{confirm:c}=ri(),{locale:d}=as(),[u,f]=m.useState(!1),[A,h]=m.useState({cronExpression:e.cronExpression??"",signingMode:e.signingMode??"bearer",replayWindowSec:String(e.replayWindowSec??300)}),g=m.useRef(!0);m.useEffect(()=>{h({cronExpression:e.cronExpression??"",signingMode:e.signingMode??"bearer",replayWindowSec:String(e.replayWindowSec??300)}),g.current=!0},[e]);const x=m.useMemo(()=>e.kind==="schedule"?A.cronExpression!==(e.cronExpression??""):e.kind==="webhook"?A.signingMode!==(e.signingMode??"bearer")||A.replayWindowSec!==String(e.replayWindowSec??300):!1,[A,e]),y=e.kind!=="schedule"||A.cronExpression.trim().length>0,v=e.kind==="schedule"?e.cronExpression?IU(e.cronExpression,d):d==="zh-CN"?"未设置日程":"No schedule":e.kind==="webhook"?d==="zh-CN"?"Webhook 触发器":"Webhook trigger":d==="zh-CN"?"API 触发器":"API trigger",w=e.kind==="schedule"&&e.nextRunAt?`${d==="zh-CN"?"下次:":"Next: "}${Ja(e.nextRunAt)}`:e.kind==="webhook"?"Webhook":"API",k=v,O=w,j=a?d==="zh-CN"?"删除中...":"Deleting...":o?d==="zh-CN"?"轮换中...":"Rotating...":s?d==="zh-CN"?"保存中...":"Saving...":l?d==="zh-CN"?"保存失败":"Save failed":y?x?d==="zh-CN"?"自动保存中...":"Autosaving...":d==="zh-CN"?"已同步":"In sync":d==="zh-CN"?"需要日程":"Needs schedule",C=a||o||s||x?"border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300":l?"border-destructive/40 bg-destructive/10 text-destructive":y?"border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-border/70 bg-muted/20 text-muted-foreground",N=j!==(d==="zh-CN"?"已同步":"In sync");return m.useEffect(()=>{if(g.current){g.current=!1;return}if(!x||!y)return;const I=window.setTimeout(()=>{t(e.id,R9e(e,A,nle()))},650);return()=>window.clearTimeout(I)},[y,A,x,t,e]),i.jsxs(es,{open:u,onOpenChange:f,children:[i.jsxs("div",{className:"flex min-h-12 min-w-0 items-center gap-2 rounded-md border border-border/60 bg-background/25 px-3 py-2",children:[i.jsx(bs,{asChild:!0,children:i.jsxs("button",{type:"button",className:"group flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Edit trigger","data-testid":"automation-trigger-menu-button",children:[i.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[i.jsx("span",{className:"block truncate text-sm font-medium",title:k,children:k}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",title:O,children:O})]}),i.jsx(Br,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180"})]})}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[N?i.jsx($i,{variant:"outline",className:C,children:j}):null,i.jsx(ie,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-destructive","aria-label":"Delete trigger",disabled:a,onClick:async()=>{await c({title:`Delete ${e.kind==="schedule"?"schedule":e.kind} trigger?`,description:`It will stop new ${e.kind} activations.`,confirmLabel:"Delete",tone:"destructive"})&&r(e.id)},children:i.jsx(fi,{className:"h-3.5 w-3.5"})})]})]}),i.jsxs(ts,{"data-testid":"automation-trigger-editor-body",align:"end",side:"left",sideOffset:8,className:"automation-trigger-menu-content glass-popover w-[min(320px,calc(100vw-2rem))] space-y-3 rounded-md p-3 text-foreground",children:[i.jsx("div",{className:"px-1 text-sm font-medium text-muted-foreground",children:e.kind==="schedule"?d==="zh-CN"?"日程":"Schedule":ek(e.kind,d)}),i.jsxs("div",{className:"grid gap-2",children:[e.kind==="schedule"&&i.jsxs("div",{className:"grid gap-1.5",children:[i.jsx(ya,{className:"px-1 text-xs text-muted-foreground",children:d==="zh-CN"?"日程":"Schedule"}),i.jsx(rZ,{variant:"compact",value:A.cronExpression,onChange:I=>h(E=>({...E,cronExpression:I}))})]}),e.kind==="webhook"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid gap-1.5",children:[i.jsx(ya,{className:"px-1 text-xs text-muted-foreground",children:d==="zh-CN"?"签名模式":"Signing mode"}),i.jsxs(Zo,{value:A.signingMode,onValueChange:I=>h(E=>({...E,signingMode:I})),children:[i.jsx(Xo,{className:"h-8",children:i.jsx(Ho,{})}),i.jsx(Go,{children:ANn.map(I=>i.jsx(Vs,{value:I,children:I},I))})]})]}),i.jsxs("div",{className:"grid gap-1.5",children:[i.jsx(ya,{className:"px-1 text-xs text-muted-foreground",children:d==="zh-CN"?"重放窗口":"Replay window"}),i.jsx(Vn,{value:A.replayWindowSec,className:"h-8",onChange:I=>h(E=>({...E,replayWindowSec:I.target.value}))})]})]})]}),e.lastResult||e.kind==="webhook"||l?i.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.lastResult&&i.jsxs("span",{className:"text-xs text-muted-foreground",children:[d==="zh-CN"?"最近:":"Last: ",e.lastResult]}),l?i.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-destructive",children:[i.jsx("span",{children:l}),y?i.jsx(ie,{variant:"ghost",size:"xs",className:"h-6 px-2 text-destructive hover:text-destructive",onClick:()=>t(e.id,R9e(e,A,nle())),children:d==="zh-CN"?"重试保存":"Retry save"}):null]}):null,i.jsx("div",{className:"ml-auto flex items-center gap-2",children:e.kind==="webhook"&&i.jsxs(ie,{variant:"outline",size:"sm",disabled:o,onClick:()=>n(e.id),children:[i.jsx(_A,{className:"mr-1.5 h-3.5 w-3.5"}),o?d==="zh-CN"?"轮换中...":"Rotating...":d==="zh-CN"?"轮换密钥":"Rotate secret"]})})]}):null]})]})}function z9e({children:e,onClose:t,surface:n}){return i.jsxs("div",{className:"scrollbar-auto-hide h-full min-h-0 overflow-y-auto overscroll-contain","data-testid":"automation-detail-shell","data-surface":n,children:[n==="side_panel"?i.jsx("header",{"data-testid":"automation-detail-panel-header",className:"sticky top-3 z-20 mx-3 mt-3 rounded-[var(--radius-md)] border border-border/70 bg-background/95 px-3 py-2 backdrop-blur sm:mx-4 sm:px-4",children:i.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Automation"}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":"Close automation detail",title:"Close automation detail",onClick:t,children:i.jsx(Ls,{className:"h-4 w-4"})})]})}):null,i.jsx("div",{className:"p-4 sm:p-5",children:e})]})}function h1e({automationId:e,embedded:t=!1,onClose:n,onOpenRunChat:r,surface:s}={}){var zn,Ze,Qt;const a=s??(t?"side_panel":"page"),o=a!=="page",{automationId:l}=Qo(),c=e??l,{selectedOrganizationId:d,selectedOrganization:u}=Nr(),{confirm:f}=ri(),{setBreadcrumbs:A,setHeaderActions:h}=ea(),g=Wn(),x=Hr(),{pushToast:y}=As(),{locale:v}=as(),w=m.useRef(null),k=m.useRef(null),O=m.useRef(null),j=m.useRef(null),C=m.useRef(null),N=m.useRef(null),I=m.useRef(null),[E,_]=m.useState(null),[T,R]=m.useState(null),[M,L]=m.useState(!1),[U,B]=m.useState(!1),[z,H]=m.useState([]),[J,F]=m.useState([]),[Q,W]=m.useState([]),[$,ee]=m.useState({}),[re,ne]=m.useState({kind:"schedule",cronExpression:"0 10 * * *",signingMode:"bearer",replayWindowSec:"300"}),[te,ce]=m.useState({title:"",description:"",projectId:"",assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",outputMode:"track_issue",chatConversationId:"",notifyOnIssueCreated:!1}),{data:se,isLoading:he,error:we}=Te({queryKey:V.automations.detail(c),queryFn:()=>yd.get(c),enabled:!!c}),Ue=(zn=se==null?void 0:se.activeIssue)==null?void 0:zn.id,{data:je}=Te({queryKey:V.issues.liveRuns(Ue),queryFn:()=>So.liveRunsForIssue(Ue),enabled:!!Ue,refetchInterval:3e3}),ke=(je??[]).length>0,{data:Se}=Te({queryKey:V.automations.runs(c),queryFn:()=>yd.listRuns(c),enabled:!!c,refetchInterval:ke?3e3:!1}),oe=m.useMemo(()=>({triggerIds:(se==null?void 0:se.triggers.map(He=>He.id))??[],runIds:(Se==null?void 0:Se.map(He=>He.id))??[]}),[se==null?void 0:se.triggers,Se]),{data:fe}=Te({queryKey:[...V.automations.activity(d,c),oe.triggerIds.join(","),oe.runIds.join(",")],queryFn:()=>yd.activity(d,c,oe),enabled:!!d&&!!c&&!!se}),{data:Ie}=Te({queryKey:V.agents.list(d),queryFn:()=>_n.list(d),enabled:!!d}),{data:ue}=Te({queryKey:V.projects.list(d),queryFn:()=>Ii.list(d),enabled:!!d}),{data:be}=Te({queryKey:V.issues.list(d),queryFn:()=>fr.list(d),enabled:!!d}),{data:at}=Te({queryKey:V.organizationSkills.list(d??"__none__"),queryFn:()=>Zu.list(d),enabled:!!d&&!!te.assigneeAgentId}),{data:ve}=Te({queryKey:V.agents.skills(te.assigneeAgentId||"__none__"),queryFn:()=>_n.skills(te.assigneeAgentId,d),enabled:!!d&&!!te.assigneeAgentId}),me=m.useMemo(()=>se?{title:se.title,description:se.description??"",projectId:se.projectId??"",assigneeAgentId:se.assigneeAgentId,priority:se.priority,concurrencyPolicy:se.concurrencyPolicy,catchUpPolicy:se.catchUpPolicy,outputMode:se.outputMode,chatConversationId:"",notifyOnIssueCreated:se.notifyOnIssueCreated}:null,[se]),ye=m.useMemo(()=>me?te.title!==me.title||te.description!==me.description||te.projectId!==me.projectId||te.assigneeAgentId!==me.assigneeAgentId||te.priority!==me.priority||te.concurrencyPolicy!==me.concurrencyPolicy||te.catchUpPolicy!==me.catchUpPolicy||te.outputMode!==me.outputMode||te.notifyOnIssueCreated!==me.notifyOnIssueCreated:!1,[te,me]),qe=!!(te.title.trim()&&te.assigneeAgentId),Ce=m.useMemo(()=>JSON.stringify({title:te.title,description:te.description.trim()||null,projectId:te.projectId||null,assigneeAgentId:te.assigneeAgentId,priority:te.priority,concurrencyPolicy:te.concurrencyPolicy,catchUpPolicy:te.catchUpPolicy,outputMode:te.outputMode,chatConversationId:null,notifyOnIssueCreated:te.notifyOnIssueCreated}),[te]);m.useEffect(()=>{if(!se||(o||A([{label:"Automations",href:"/automations"},{label:se.title}]),!me))return;const He=w.current!==se.id;(He||!ye)&&(ce(me),w.current=se.id,He&&(k.current=null))},[se,me,o,ye,A]),m.useEffect(()=>{L9e(O.current)},[te.title,se==null?void 0:se.id]),m.useEffect(()=>()=>{I.current&&window.clearTimeout(I.current)},[]);const X=async(He,Rt,In)=>{try{await navigator.clipboard.writeText(Rt),R(In),I.current&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{R(Zn=>Zn===In?null:Zn)},1800),y({title:`${He} copied`,tone:"success"})}catch(Zn){y({title:`Failed to copy ${He.toLowerCase()}`,body:Zn instanceof Error?Zn.message:"Clipboard access was denied.",tone:"error"})}},G=pt({mutationFn:He=>yd.update(c,{...He,projectId:He.projectId||null,instructions:He.description.trim()||null,chatConversationId:null}),onSuccess:async()=>{await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})])},onError:He=>{k.current=null,y({title:"Failed to save automation",body:He instanceof Error?He.message:"Rudder could not save the automation.",tone:"error"})}});m.useEffect(()=>{if(!se||!ye||!qe||G.isPending||k.current===Ce)return;const He=te,Rt=window.setTimeout(()=>{k.current=Ce,G.mutate(He)},700);return()=>window.clearTimeout(Rt)},[se,qe,te,Ce,ye,G]);const Ae=pt({mutationFn:()=>yd.run(c),onSuccess:async He=>{y({title:"Automation run started",tone:"success"}),await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.runs(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})]),He.linkedChatConversationId&&(r?r(He.linkedChatConversationId):x(`/messenger/chat/${He.linkedChatConversationId}`))},onError:He=>{y({title:"Automation run failed",body:He instanceof Error?He.message:"Rudder could not start the automation run.",tone:"error"})}}),Je=pt({mutationFn:()=>yd.delete(c),onSuccess:()=>{n?n():x("/automations"),y({title:"Automation deleted",tone:"success"}),Promise.all([g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})])},onError:He=>{y({title:"Failed to delete automation",body:He instanceof Error?He.message:"Rudder could not delete the automation.",tone:"error"})}}),ht=pt({mutationFn:He=>yd.update(c,{status:He}),onSuccess:async(He,Rt)=>{y({title:"Automation saved",body:Rt==="paused"?"Automation paused.":"Automation enabled.",tone:"success"}),await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)})])},onError:He=>{y({title:"Failed to update automation",body:He instanceof Error?He.message:"Rudder could not update the automation.",tone:"error"})}});m.useEffect(()=>{if(o)return;if(!d||!se){h(null);return}const He=se.status==="active",Rt=He?"Disable automation":"Enable automation";return h(i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md px-1 text-xs text-muted-foreground",children:[i.jsx(zA,{checked:He,size:"md",tone:"success","aria-label":Rt,title:Rt,disabled:ht.isPending,onClick:()=>ht.mutate(He?"paused":"active")}),i.jsx("span",{className:"min-w-5 tabular-nums",children:He?"On":"Off"})]}),i.jsx(ie,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive","aria-label":"Delete automation",title:"Delete automation",disabled:Je.isPending,onClick:async()=>{await f({title:`Delete "${se.title}"?`,description:"This will permanently remove the automation and stop future runs.",confirmLabel:"Delete",tone:"destructive"})&&Je.mutate()},children:Je.isPending?i.jsx(_A,{className:"h-4 w-4 animate-spin"}):i.jsx(fi,{className:"h-4 w-4"})}),i.jsxs(ie,{variant:"default",size:"sm",className:"border-white/70 bg-white px-2 text-black shadow-none hover:bg-white/90 min-[420px]:min-w-[92px] min-[420px]:px-3","aria-label":"Run now",disabled:Ae.isPending||!He,onClick:()=>Ae.mutate(),children:[i.jsx(SA,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"hidden min-[420px]:inline",children:Ae.isPending?"Starting...":"Run now"})]})]})),()=>h(null)},[se==null?void 0:se.id,se==null?void 0:se.status,se==null?void 0:se.title,Je.isPending,o,Ae.isPending,d,h,ht.isPending]);const De=pt({mutationFn:async()=>yd.createTrigger(c,{kind:re.kind,...re.kind==="schedule"?{cronExpression:re.cronExpression.trim(),timezone:nle()}:{},...re.kind==="webhook"?{signingMode:re.signingMode,replayWindowSec:Number(re.replayWindowSec||"300")}:{}}),onSuccess:async He=>{He.secretMaterial&&_({title:"Webhook trigger created",webhookUrl:He.secretMaterial.webhookUrl,webhookSecret:He.secretMaterial.webhookSecret}),await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})]),B(!1)},onError:He=>{y({title:"Failed to add trigger",body:He instanceof Error?He.message:"Rudder could not create the trigger.",tone:"error"})}}),ft=pt({mutationFn:({id:He,patch:Rt})=>yd.updateTrigger(He,Rt),onSuccess:async()=>{await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})])},onError:He=>{y({title:"Failed to update trigger",body:He instanceof Error?He.message:"Rudder could not update the trigger.",tone:"error"})}}),dt=m.useCallback((He,Rt)=>{H(In=>Cee(In,He)),ee(In=>{if(!(He in In))return In;const Zn={...In};return delete Zn[He],Zn}),ft.mutate({id:He,patch:Rt},{onError:In=>{ee(Zn=>({...Zn,[He]:In instanceof Error?In.message:"Rudder could not update the trigger."}))},onSettled:()=>{H(In=>Nee(In,He))}})},[ft]),yt=pt({mutationFn:He=>yd.deleteTrigger(He),onSuccess:async(He,Rt)=>{await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})]),ee(In=>{if(!(Rt in In))return In;const Zn={...In};return delete Zn[Rt],Zn})},onError:He=>{y({title:"Failed to delete trigger",body:He instanceof Error?He.message:"Rudder could not delete the trigger.",tone:"error"})}}),Mt=pt({mutationFn:He=>yd.rotateTriggerSecret(He),onSuccess:async He=>{_({title:"Webhook secret rotated",webhookUrl:He.secretMaterial.webhookUrl,webhookSecret:He.secretMaterial.webhookSecret}),await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})])},onError:He=>{y({title:"Failed to rotate webhook secret",body:He instanceof Error?He.message:"Rudder could not rotate the webhook secret.",tone:"error"})}}),Xe=m.useMemo(()=>new Map((Ie??[]).map(He=>[He.id,He])),[Ie]),At=m.useMemo(()=>new Map((ue??[]).map(He=>[He.id,He])),[ue]),it=m.useMemo(()=>ME(),[se==null?void 0:se.id]),Ee=m.useMemo(()=>RT((Ie??[]).filter(He=>He.status!=="terminated"),it).map(He=>({id:He.id,label:Qu(He),searchText:`${He.name} ${He.role} ${He.title??""}`})),[Ie,it]),mt=m.useMemo(()=>(ue??[]).map(He=>({id:He.id,label:He.name,searchText:He.description??""})),[ue]),ot=te.assigneeAgentId?Xe.get(te.assigneeAgentId)??null:null,xe=te.projectId?At.get(te.projectId)??null:null,Ne=m.useMemo(()=>new Map(((se==null?void 0:se.triggers)??[]).map(He=>[He.id,He])),[se==null?void 0:se.triggers]),We=m.useMemo(()=>o9({agent:ot,orgUrlKey:(u==null?void 0:u.urlKey)??"organization",organizationSkills:at,skillSnapshot:ve}),[at,ve,ot,u==null?void 0:u.urlKey]),ze=m.useMemo(()=>SM({agents:Ie,projects:ue,issues:be,skillMentionOptions:We}),[Ie,be,ue,We]),Ye=m.useMemo(()=>{const He=new Set((Se??[]).map(kt=>kt.id)),Rt=[],In=(kt,nn)=>kt?i.jsx("span",{children:kt},nn):null,Zn=kt=>{var Ke;if(!kt)return null;const nn=Xe.get(kt);return nn?Qu(nn):((Ke=se==null?void 0:se.assignee)==null?void 0:Ke.id)===kt?se.assignee.name:"Selected agent"},Xr=(kt,nn)=>{const st=(kt?Ne.get(kt):null)??nn;if(!st)return null;const Ft=X8(st,v),Dn=ek(st.kind,v);return Ft&&Ft!==Dn?`${Dn}: ${Ft}`:Dn},qs=(kt,nn)=>v!=="zh-CN"?`${kt==="added"?"Added":kt==="updated"?"Updated":"Removed"} ${nn.toLowerCase()}`:`${kt==="added"?"添加了":kt==="updated"?"更新了":"移除了"}${nn}`,hr=(kt,nn,Ke)=>{const st=hNn(kt,v);switch(nn){case"issue_created":return v==="zh-CN"?`${st}创建了执行任务`:`${st} opened an execution issue`;case"running":return v==="zh-CN"?Ke==="chat_output"?`${st}已启动聊天运行`:`${st}正在执行`:Ke==="chat_output"?`${st} started a chat run`:`${st} is in progress`;case"failed":return v==="zh-CN"?`${st}失败`:`${st} failed`;case"coalesced":return v==="zh-CN"?`${st}已合并到活跃运行`:`${st} joined an active run`;case"skipped":return v==="zh-CN"?`${st}已跳过`:`${st} skipped`;case"completed":return v==="zh-CN"?`${st}已完成`:`${st} completed`;default:return`${st} ${MU(nn,v)}`}},Fr=kt=>kt?kt.startsWith("Schedule trigger: ")?`for ${kt.replace("Schedule trigger: ","")}`:v==="zh-CN"&&kt.startsWith("日程触发器: ")?`用于${kt.replace("日程触发器: ","")}`:kt:null,jt=kt=>{const nn=kt.details??null,Ke=[];let st=kt.action.replaceAll("."," "),Ft=!1;if(kt.action==="automation.created"){const Rn=oA(nn,"title");st=Rn?v==="zh-CN"?`创建了“${Rn}”`:`Created "${Rn}"`:v==="zh-CN"?"创建了自动化":"Created automation",Ke.push(In(v==="zh-CN"?`分配给 ${Zn(oA(nn,"assigneeAgentId"))??"智能体"}`:`Assigned to ${Zn(oA(nn,"assigneeAgentId"))??"agent"}`,"assignee"))}else if(kt.action==="automation.updated"){const Rn=oA(nn,"title");st=Rn?v==="zh-CN"?`更新了“${Rn}”的自动化设置`:`Updated automation settings for "${Rn}"`:v==="zh-CN"?"更新了自动化设置":"Updated automation settings"}else if(kt.action==="automation.deleted"){const Rn=oA(nn,"title");st=Rn?v==="zh-CN"?`删除了“${Rn}”`:`Deleted "${Rn}"`:v==="zh-CN"?"删除了自动化":"Deleted automation"}else if(kt.action==="automation.trigger_created"){const Rn=Ne.get(kt.entityId),rt=(Rn==null?void 0:Rn.kind)??oA(nn,"kind");st=qs("added",ek(rt,v)),Ke.push(In(Fr(Xr(kt.entityId,{kind:oA(nn,"kind")??"trigger",cronExpression:(Rn==null?void 0:Rn.cronExpression)??null,label:(Rn==null?void 0:Rn.label)??null})),"trigger"))}else if(kt.action==="automation.trigger_updated"){const Rn=Ne.get(kt.entityId),rt=(Rn==null?void 0:Rn.kind)??oA(nn,"kind");st=qs("updated",ek(rt,v)),Ke.push(In(Fr(Xr(kt.entityId,{kind:oA(nn,"kind")??"trigger",cronExpression:null})),"trigger"))}else if(kt.action==="automation.trigger_deleted")st=qs("removed",ek(oA(nn,"kind"),v));else if(kt.action==="automation.trigger_secret_rotated")st=v==="zh-CN"?"已轮换 Webhook 密钥":"Webhook secret rotated";else if(kt.action==="automation.run_triggered"){const Rn=oA(nn,"source")??"run",rt=oA(nn,"status")??"started";st=hr(Rn,rt,oA(nn,"outputMode")??(se==null?void 0:se.outputMode));const Yt=Xr(oA(nn,"triggerId"),null);Ke.push(In(Fr(Yt),"trigger"))}else Ft=!0,Object.entries(nn??{}).filter(([Rn])=>!["automationId","triggerId","assigneeAgentId","projectId"].includes(Rn)).slice(0,2).forEach(([Rn,rt])=>{Ke.push(i.jsxs("span",{children:[i.jsxs("span",{className:"text-muted-foreground/70",children:[Rn.replaceAll("_"," "),":"]})," ",Lat(rt)]},Rn))});const Dn=Ke.filter(Boolean);Rt.push({id:`event:${kt.id}`,title:st,details:Dn.length>0||!Ft?Dn:[i.jsx("span",{children:"Activity recorded"},"fallback")],createdAt:kt.createdAt,sortAt:new Date(kt.createdAt).getTime()})};for(const kt of Se??(se==null?void 0:se.recentRuns)??[]){const nn=[],Ke=Xr(kt.triggerId,kt.trigger?{...kt.trigger,cronExpression:null}:null),st=Fr(Ke);st&&nn.push(i.jsx("span",{children:st},"trigger")),kt.linkedIssue&&nn.push(i.jsx(an,{to:`/issues/${kt.linkedIssue.identifier??kt.linkedIssue.id}`,className:"whitespace-nowrap font-medium text-foreground hover:underline",children:kt.linkedIssue.identifier??kt.linkedIssue.title},"issue")),kt.linkedChatConversation&&nn.push(i.jsx(an,{to:`/messenger/chat/${kt.linkedChatConversation.id}`,className:"whitespace-nowrap font-medium text-foreground hover:underline",children:kt.linkedChatConversation.title},"chat")),kt.failureReason&&nn.push(i.jsx("span",{children:kt.failureReason},"failure")),Rt.push({id:`run:${kt.id}`,title:hr(kt.source,kt.status,se==null?void 0:se.outputMode),details:nn,createdAt:kt.triggeredAt,sortAt:new Date(kt.triggeredAt).getTime()})}for(const kt of fe??[])kt.action!=="automation.updated"&&(kt.action==="automation.run_triggered"&&kt.entityType==="automation_run"&&He.has(kt.entityId)||jt(kt));return Rt.sort((kt,nn)=>nn.sortAt-kt.sortAt).slice(0,10)},[fe,Xe,se,Se,v,At,Ne]);if(!d)return i.jsx(ma,{icon:y6,message:"Select an organization to view automations."});if(he)return o?i.jsx(z9e,{onClose:n,surface:a==="workbench"?"workbench":"side_panel",children:i.jsx(Co,{variant:"issues-list"})}):i.jsx(Co,{variant:"issues-list"});if(we||!se){const He=we instanceof Error?we.message:"Automation not found";return o?i.jsx(z9e,{onClose:n,surface:a==="workbench"?"workbench":"side_panel",children:i.jsx("p",{className:"text-sm text-destructive",children:He})}):i.jsx("p",{className:"pt-6 text-sm text-destructive",children:He})}const _e=se.status==="active",Le=_e?"Active":"Paused",Pe=G.isPending?"Saving...":qe?ye?"Autosaving...":"In sync":"Needs fields",vt=G.isPending||ye?"text-amber-600":"text-muted-foreground",Be=[...se.triggers].filter(He=>He.enabled).sort((He,Rt)=>{const In=He.nextRunAt?new Date(He.nextRunAt).getTime():Number.POSITIVE_INFINITY,Zn=Rt.nextRunAt?new Date(Rt.nextRunAt).getTime():Number.POSITIVE_INFINITY;return In-Zn})[0]??se.triggers[0]??null,ut=(Se==null?void 0:Se[0])??se.recentRuns[0]??null,Et=((Ze=se.activeIssue)==null?void 0:Ze.identifier)??((Qt=se.activeIssue)==null?void 0:Qt.id.slice(0,8))??null,Zt=re.kind!=="schedule"||re.cronExpression.trim().length>0,Nn=mNn({status:se.status,triggerCount:se.triggers.length,hasAssignee:!!te.assigneeAgentId,hasLiveRun:ke,latestRunStatus:ut==null?void 0:ut.status});return i.jsxs("div",{className:q("pb-8",o&&"scrollbar-auto-hide h-full min-h-0 overflow-y-auto overscroll-contain"),"data-testid":"automation-detail-shell","data-surface":a,children:[a==="side_panel"?i.jsx("header",{"data-testid":"automation-detail-panel-header",className:"sticky top-3 z-20 mx-3 mt-3 rounded-[var(--radius-md)] border border-border/70 bg-card/95 px-3 py-2 backdrop-blur sm:mx-4 sm:px-4",children:i.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs font-medium",children:[i.jsx("span",{className:q("h-2 w-2 shrink-0 rounded-full",_e?"bg-emerald-500":"bg-muted-foreground/45")}),i.jsx("span",{className:"truncate",children:Le}),i.jsx("span",{className:q("truncate font-normal",vt),children:Pe})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":"Automation actions",title:"Automation actions",children:i.jsx(xl,{className:"h-4 w-4"})})}),i.jsxs(Di,{align:"end",children:[i.jsxs(Gt,{disabled:Ae.isPending||!_e,onClick:()=>Ae.mutate(),children:[i.jsx(SA,{className:"h-4 w-4"}),Ae.isPending?"Starting...":"Run now"]}),i.jsx(ko,{}),i.jsxs(Gt,{variant:"destructive",disabled:Je.isPending,onClick:async()=>{await f({title:`Delete "${se.title}"?`,description:"This will permanently remove the automation and stop future runs.",confirmLabel:"Delete",tone:"destructive"})&&Je.mutate()},children:[i.jsx(fi,{className:"h-4 w-4"}),"Delete"]})]})]}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":_e?"Pause automation":"Enable automation",title:_e?"Pause automation":"Enable automation",disabled:ht.isPending,onClick:()=>ht.mutate(_e?"paused":"active"),children:_e?i.jsx(Tq,{className:"h-4 w-4"}):i.jsx(SA,{className:"h-4 w-4"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":"Close automation detail",title:"Close automation detail",onClick:n,children:i.jsx(Ls,{className:"h-4 w-4"})})]})]})}):null,E&&i.jsxs("div",{className:q("relative mb-4 rounded-md border border-blue-500/30 bg-blue-500/5 p-4 pr-12 text-sm",o&&"mx-4 mt-4 sm:mx-5"),children:[i.jsxs("div",{className:"mb-3",children:[i.jsx("p",{className:"font-medium",children:E.title}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Save this now. Rudder will not show the secret value again."})]}),i.jsx(ie,{variant:"ghost",size:"icon-xs",className:"absolute right-4 top-4","aria-label":"Dismiss secret notice",onClick:()=>{_(null),R(null)},children:i.jsx(Ls,{className:"h-3.5 w-3.5"})}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Vn,{value:E.webhookUrl,readOnly:!0,className:"flex-1"}),i.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>X("Webhook URL",E.webhookUrl,"url"),children:[T==="url"?i.jsx(Zi,{className:"mr-1 h-3.5 w-3.5"}):i.jsx(sl,{className:"mr-1 h-3.5 w-3.5"}),T==="url"?"Copied":"URL"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Vn,{value:E.webhookSecret,readOnly:!0,className:"flex-1"}),i.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>X("Webhook secret",E.webhookSecret,"secret"),children:[T==="secret"?i.jsx(Zi,{className:"mr-1 h-3.5 w-3.5"}):i.jsx(sl,{className:"mr-1 h-3.5 w-3.5"}),T==="secret"?"Copied":"Secret"]})]})]})]}),i.jsxs("div",{className:q("grid min-w-0 grid-cols-[minmax(0,1fr)] gap-6 px-4 pt-3 sm:px-5",o?"pb-4":"lg:grid-cols-[minmax(0,1fr)_300px] lg:px-6 xl:grid-cols-[minmax(0,1fr)_320px] 2xl:grid-cols-[minmax(0,1fr)_340px]"),children:[i.jsxs("main",{className:q("min-w-0 space-y-6",o&&"contents"),children:[i.jsxs("section",{className:q("max-w-none space-y-3",o&&"order-1"),children:[a==="workbench"?i.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 border-b border-border/60 pb-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs font-medium",children:[i.jsx("span",{className:q("h-2 w-2 shrink-0 rounded-full",_e?"bg-emerald-500":"bg-muted-foreground/45")}),i.jsx("span",{className:"truncate",children:Le}),i.jsx("span",{className:q("truncate font-normal",vt),children:Pe})]}),i.jsxs(ie,{type:"button",variant:"default",size:"sm",className:"shrink-0","aria-label":"Run now",disabled:Ae.isPending||!_e,onClick:()=>Ae.mutate(),children:[Ae.isPending?i.jsx(_A,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(SA,{className:"h-3.5 w-3.5"}),Ae.isPending?"Starting...":"Run now"]})]}):null,i.jsx("textarea",{ref:O,className:q("min-h-[34px] w-full resize-none overflow-hidden bg-transparent font-semibold leading-tight outline-none placeholder:text-muted-foreground/50",o?"text-xl":"text-[1.45rem] sm:text-[1.6rem]"),placeholder:"Automation title",rows:1,value:te.title,onChange:He=>{ce(Rt=>({...Rt,title:He.target.value})),L9e(He.target)},onKeyDown:He=>{var Rt,In,Zn,Xr;if(He.key==="Enter"&&!He.metaKey&&!He.ctrlKey&&!He.nativeEvent.isComposing){He.preventDefault(),(Rt=j.current)==null||Rt.focus();return}He.key==="Tab"&&!He.shiftKey&&(He.preventDefault(),te.assigneeAgentId?te.projectId?(In=j.current)==null||In.focus():(Zn=N.current)==null||Zn.focus():(Xr=C.current)==null||Xr.focus())}}),i.jsx("div",{"data-testid":"automation-overview-strip",className:q("border-y border-border/60 bg-transparent py-2.5",o&&"hidden"),children:i.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-sm",children:[i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i.jsx("span",{className:q("h-2 w-2 rounded-full",_e?"bg-emerald-500":"bg-muted-foreground/45")}),i.jsx("span",{className:"text-foreground",children:Le})]}),ke?i.jsxs("span",{className:"inline-flex items-center gap-1.5 text-blue-700 dark:text-blue-300",children:[i.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-500"}),"In progress"]}):null,i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"text-muted-foreground",children:"Repeats"})," ",i.jsx("span",{className:"text-foreground",children:X8(Be,v)})]}),i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"text-muted-foreground",children:"Next"})," ",i.jsx("span",{className:"text-foreground",children:UC(Be==null?void 0:Be.nextRunAt,"-")})]}),se.activeIssue&&Et?i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"text-muted-foreground",children:"Issue"})," ",i.jsx(an,{to:`/issues/${Et}`,className:"text-muted-foreground underline-offset-4 hover:text-foreground hover:underline",children:Et})]}):null]})}),i.jsx(Au,{ref:j,value:te.description,onChange:He=>ce(Rt=>({...Rt,description:He})),mentions:ze,placeholder:"Add instructions...",bordered:!0,className:q("bg-background/40",o&&"rounded-md"),contentClassName:q("text-[15px] leading-7 text-foreground/90",o?"min-h-[220px]":"min-h-[180px] md:min-h-[240px]")})]}),i.jsxs("section",{"aria-label":o?"Previous runs":"Activity",className:q("space-y-3 border-t border-border/70 pt-4",o&&"order-3"),children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[o?null:i.jsx(wq,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:o?"Previous runs":"Activity"})]}),ke&&Ue&&se?i.jsx(Iat,{issueId:Ue,orgId:se.orgId}):null,Ye.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:"No activity yet."}):i.jsx("div",{"data-testid":"automation-activity-list",className:"relative space-y-1 before:absolute before:bottom-2 before:left-[7.5px] before:top-2 before:w-px before:bg-border/70",children:Ye.map(He=>i.jsxs("div",{"data-testid":"automation-activity-row",className:"grid min-h-8 grid-cols-[16px_minmax(0,1fr)] gap-x-2 rounded-sm py-1 text-xs text-muted-foreground sm:grid-cols-[16px_minmax(0,1fr)_auto] sm:items-center",children:[i.jsx("span",{"aria-hidden":"true",className:"relative z-10 row-span-2 flex h-full min-h-6 w-4 items-start justify-center pt-[7px] sm:row-span-1 sm:items-center sm:pt-0",children:i.jsx("span",{className:"h-2 w-2 rounded-full border border-background bg-muted-foreground/40 shadow-[0_0_0_2px_hsl(var(--background))]"})}),i.jsxs("span",{"data-testid":"automation-activity-summary",className:"flex min-w-0 items-baseline gap-x-1.5 overflow-hidden whitespace-nowrap",children:[i.jsx("span",{className:"min-w-0 truncate text-foreground/90",children:He.title}),He.details.length>0&&i.jsx("span",{"data-testid":"automation-activity-details",className:"inline-flex min-w-0 items-baseline gap-x-1.5 overflow-hidden text-muted-foreground",children:He.details.map((Rt,In)=>i.jsxs("span",{className:"min-w-0 truncate",children:[In>0&&i.jsx("span",{className:"mr-1.5 text-border",children:"·"}),Rt]},In))})]}),i.jsx("span",{"data-testid":"automation-activity-time",className:"col-start-2 shrink-0 text-muted-foreground/70 sm:col-start-auto",children:px(He.createdAt)})]},He.id))})]})]}),i.jsx("aside",{className:q("min-w-0 border-t border-border/70 pt-4",o?"order-2":"lg:sticky lg:top-20 lg:self-start lg:border-t-0 lg:pt-0"),children:i.jsxs("div",{"data-testid":"automation-configuration-card",className:q("min-w-0 space-y-6",o?"border-0 bg-transparent p-0":"rounded-md border border-border/70 bg-card/85 p-4 shadow-sm"),children:[i.jsxs(Pee,{title:o?"Details":"Configuration",card:o,children:[i.jsx(ny,{label:"Assignee",children:i.jsx("div",{"data-testid":"automation-detail-agent-control",className:"min-w-0 flex-1",children:i.jsx(Hp,{ref:C,value:te.assigneeAgentId,options:Ee,placeholder:"Select assignee",noneLabel:"No assignee",searchPlaceholder:"Search assignees...",emptyMessage:"No assignees found.",className:"-mx-1 min-h-7 w-full justify-between border-0 bg-transparent px-1 py-0.5 text-sm font-medium shadow-none hover:bg-accent/50",onChange:He=>{He&&NO(He),ce(Rt=>({...Rt,assigneeAgentId:He}))},onConfirm:()=>{var He,Rt;te.projectId?(He=j.current)==null||He.focus():(Rt=N.current)==null||Rt.focus()},renderTriggerValue:He=>He?i.jsx(ez,{children:ot?i.jsxs(i.Fragment,{children:[i.jsx(Ml,{icon:ot.icon,role:ot.role,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"truncate",children:He.label})]}):i.jsx("span",{className:"truncate",children:He.label})}):i.jsx(ez,{children:i.jsx("span",{className:"text-muted-foreground",children:"Select assignee"})}),renderOption:He=>{if(!He.id)return i.jsx("span",{className:"truncate",children:He.label});const Rt=Xe.get(He.id);return i.jsxs(i.Fragment,{children:[Rt?i.jsx(Ml,{icon:Rt.icon,role:Rt.role,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):null,i.jsx("span",{className:"truncate",children:He.label})]})}})})}),i.jsx(ny,{label:"Output",children:i.jsxs(Zo,{value:te.outputMode,onValueChange:He=>ce(Rt=>({...Rt,outputMode:He,chatConversationId:"",notifyOnIssueCreated:He==="track_issue"?Rt.notifyOnIssueCreated:!1})),children:[i.jsx(Xo,{size:"sm",className:"-mx-1 h-7 w-fit border-0 bg-transparent px-1 py-0.5 text-sm shadow-none hover:bg-accent/50",children:i.jsx(Ho,{})}),i.jsxs(Go,{children:[i.jsx(Vs,{value:"track_issue",children:"Track as issue"}),i.jsx(Vs,{value:"chat_output",children:"Send to chat"})]})]})}),te.outputMode==="track_issue"?i.jsx(ny,{label:"Follow created issues",children:i.jsx(zA,{checked:te.notifyOnIssueCreated,size:"sm","aria-label":"Follow issues created by this automation",title:"Follow issues created by this automation",onClick:()=>ce(He=>({...He,notifyOnIssueCreated:!He.notifyOnIssueCreated}))})}):null,o?null:i.jsxs(i.Fragment,{children:[i.jsx(ny,{label:"Repeats",children:i.jsx("span",{className:"min-w-0 truncate text-sm text-foreground",title:X8(Be,v),children:X8(Be,v)})}),i.jsx(ny,{label:"Next run",children:i.jsx("span",{className:"min-w-0 truncate text-sm text-muted-foreground",title:UC(Be==null?void 0:Be.nextRunAt,"-"),children:UC(Be==null?void 0:Be.nextRunAt,"-")})})]}),i.jsx(ny,{label:"Project",children:i.jsx("div",{"data-testid":"automation-detail-project-control",className:"min-w-0 flex-1",children:i.jsx(Hp,{ref:N,value:te.projectId,options:mt,placeholder:"No project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",className:"-mx-1 min-h-7 w-full justify-between border-0 bg-transparent px-1 py-0.5 text-sm font-medium shadow-none hover:bg-accent/50",onChange:He=>ce(Rt=>({...Rt,projectId:He})),onConfirm:()=>{var He;return(He=j.current)==null?void 0:He.focus()},renderTriggerValue:He=>He&&xe?i.jsxs(ez,{children:[i.jsx(Ao,{color:xe.color,icon:xe.icon,size:"xs"}),i.jsx("span",{className:"truncate",children:He.label})]}):i.jsx(ez,{children:i.jsx("span",{className:"text-muted-foreground",children:"No project"})}),renderOption:He=>{if(!He.id)return i.jsx("span",{className:"truncate",children:He.label});const Rt=At.get(He.id);return i.jsxs(i.Fragment,{children:[i.jsx(Ao,{color:Rt==null?void 0:Rt.color,icon:Rt==null?void 0:Rt.icon,size:"xs"}),i.jsx("span",{className:"truncate",children:He.label})]})}})})})]}),i.jsxs(j6,{open:M,onOpenChange:L,"data-testid":"automation-delivery-rules-section",className:"overflow-hidden rounded-md border border-border/70 bg-background/35",children:[i.jsxs(sK,{className:"flex w-full items-center justify-between gap-4 px-3 py-2.5 text-left text-sm font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i.jsx("span",{children:"Delivery rules"}),M?i.jsx(Br,{className:"h-4 w-4"}):i.jsx(_i,{className:"h-4 w-4"})]}),i.jsx(C6,{className:"border-t border-border/60 p-3",children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(ya,{className:"text-xs",children:"Concurrency"}),i.jsxs(Zo,{value:te.concurrencyPolicy,onValueChange:He=>ce(Rt=>({...Rt,concurrencyPolicy:He})),children:[i.jsx(Xo,{size:"sm",className:"w-full bg-background/60",children:i.jsx(Ho,{})}),i.jsx(Go,{children:uNn.map(He=>i.jsx(Vs,{value:He,children:TU(He,v)},He))})]}),i.jsx("p",{className:"text-xs leading-4 text-muted-foreground",children:_U(Eat,te.concurrencyPolicy,v)})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(ya,{className:"text-xs",children:"Catch-up"}),i.jsxs(Zo,{value:te.catchUpPolicy,onValueChange:He=>ce(Rt=>({...Rt,catchUpPolicy:He})),children:[i.jsx(Xo,{size:"sm",className:"w-full bg-background/60",children:i.jsx(Ho,{})}),i.jsx(Go,{children:fNn.map(He=>i.jsx(Vs,{value:He,children:TU(He,v)},He))})]}),i.jsx("p",{className:"text-xs leading-4 text-muted-foreground",children:_U(Dat,te.catchUpPolicy,v)})]})]})})]}),i.jsxs(Pee,{title:o?"Frequency":"Triggers",children:[o?i.jsxs("div",{className:"divide-y divide-border/60 rounded-md border border-border/70 bg-card/70 px-3.5",children:[i.jsx(ny,{label:"Repeat",children:i.jsx("span",{className:"min-w-0 truncate text-sm text-foreground",title:X8(Be,v),children:X8(Be,v)})}),i.jsx(ny,{label:"Next run",children:i.jsx("span",{className:"min-w-0 truncate text-sm text-muted-foreground",title:UC(Be==null?void 0:Be.nextRunAt,"-"),children:UC(Be==null?void 0:Be.nextRunAt,"-")})})]}):null,i.jsxs(es,{open:U,onOpenChange:B,children:[i.jsx(bs,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"automation-trigger-menu-trigger group w-full justify-center rounded-md bg-background/55 shadow-none","data-testid":"automation-add-trigger-button",children:["Add trigger",i.jsx(Br,{className:"h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180"})]})}),i.jsxs(ts,{"data-testid":"automation-add-trigger-card",align:"center",side:"bottom",sideOffset:8,collisionPadding:16,className:"automation-trigger-menu-content glass-popover max-h-[min(28rem,var(--radix-popover-content-available-height))] w-[min(320px,calc(100vw-2rem))] overflow-y-auto rounded-md p-3 text-foreground",children:[i.jsx("div",{className:"px-1 text-sm font-medium text-muted-foreground",children:"Schedule"}),i.jsx(rZ,{variant:"compact",value:re.cronExpression,onChange:He=>ne(Rt=>({...Rt,kind:"schedule",cronExpression:He}))}),i.jsx(ie,{className:"w-full justify-center",size:"sm",onClick:()=>De.mutate(),disabled:De.isPending||!Zt,children:De.isPending?"Adding...":"Create trigger"})]})]}),i.jsx("div",{"data-testid":"automation-triggers-list",className:"space-y-3",children:se.triggers.length===0?i.jsx("div",{className:"rounded-md border border-dashed border-border/80 px-3 py-4 text-sm text-muted-foreground",children:"No triggers configured yet."}):se.triggers.map(He=>i.jsx(pNn,{trigger:He,onSave:dt,onRotate:Rt=>{W(In=>Cee(In,Rt)),Mt.mutate(Rt,{onSettled:()=>W(In=>Nee(In,Rt))})},onDelete:Rt=>{F(In=>Cee(In,Rt)),yt.mutate(Rt,{onSettled:()=>F(In=>Nee(In,Rt))})},isSaving:z.includes(He.id),isDeleting:J.includes(He.id),isRotating:Q.includes(He.id),saveError:$[He.id]??null},He.id))})]}),o?null:i.jsxs(Pee,{title:"Run status",children:[i.jsx(JL,{label:"Last ran",children:i.jsx("span",{className:"truncate",children:ut?px(ut.triggeredAt):"-"})}),i.jsx(JL,{label:"Edits",children:i.jsx("span",{className:vt,children:Pe})}),i.jsx(JL,{label:"Risk",children:i.jsx("span",{className:"truncate",children:Nn})}),ke?i.jsx(JL,{label:"Run",children:i.jsx($i,{variant:"outline",className:"border-blue-500/40 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:"In progress"})}):null]})]})})]})]})}const gNn=Object.freeze(Object.defineProperty({__proto__:null,AutomationDetail:h1e},Symbol.toStringTag,{value:"Module"}));function xNn({...e}){return i.jsx(Qpt,{"data-slot":"context-menu",...e})}function bNn({onClickCapture:e,onKeyDown:t,...n}){return i.jsx(Upt,{"data-slot":"context-menu-trigger",...n,onClickCapture:r=>{e==null||e(r),!(r.defaultPrevented||r.currentTarget.dataset.state!=="open")&&(r.preventDefault(),r.stopPropagation())},onKeyDown:r=>{if(t==null||t(r),r.defaultPrevented||!(r.key==="ContextMenu"||r.code==="ContextMenu"||r.key==="F10"&&r.shiftKey))return;r.preventDefault(),r.stopPropagation();const a=r.currentTarget,o=a.getBoundingClientRect();a.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,button:2,clientX:o.left+Math.min(16,o.width/2),clientY:o.bottom,view:window}))}})}function yNn({className:e,...t}){return i.jsx(Vpt,{children:i.jsx(qpt,{"data-slot":"context-menu-content",className:q("motion-surface-pop bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md",e),...t})})}function Iee({className:e,inset:t,...n}){return i.jsx(Kpt,{"data-slot":"context-menu-item","data-inset":t,className:q("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...n})}function $9e({className:e,...t}){return i.jsx(Wpt,{"data-slot":"context-menu-separator",className:q("bg-border -mx-1 my-1 h-px",e),...t})}function vNn({children:e,closeDisabled:t,isMobile:n,moveInProgress:r,organizationId:s,tab:a,onClose:o,onOpenInNewTab:l,onMoveSideChat:c}){const[d,u]=m.useState(!1),f=a.kind==="side_chat"?a:null,A=Te({queryKey:V.chats.detail(s??"__none__",(f==null?void 0:f.conversationId)??"__side-chat-draft__"),queryFn:()=>rr.get(f.conversationId),enabled:d&&!!(s&&(f!=null&&f.conversationId))}),h=A.data??null,g=!!(f!=null&&f.conversationId&&(A.isPending||A.isFetching)),x=!!(f!=null&&f.conversationId&&!r&&!g&&!A.isError&&(h==null?void 0:h.sideChatState)==="active"&&!mit(h)),y=f!=null&&f.conversationId?r||g?"Checking whether this Side Chat can be moved…":x?"Make this Side Chat a regular Messenger chat. This tab will close.":"This Side Chat can no longer be moved. Close it instead.":"Send a message first to create this Side Chat.";return i.jsxs(xNn,{onOpenChange:v=>{u(v),v&&(f!=null&&f.conversationId)&&A.refetch()},children:[i.jsx(bNn,{asChild:!0,children:e}),i.jsxs(yNn,{"data-testid":"chat-side-panel-tab-context-menu",className:"surface-overlay z-[70] w-48 text-foreground",onContextMenu:v=>v.preventDefault(),children:[f?i.jsxs(i.Fragment,{children:[i.jsx(id,{delayDuration:300,children:i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsxs(Iee,{"aria-disabled":x?void 0:"true","data-disabled":x?void 0:"",onSelect:v=>{if(!x){v.preventDefault();return}c(f)},children:[i.jsx(ka,{}),"Move to Messenger"]})}),i.jsx(Gi,{side:n?"bottom":"left",align:n?"start":"center",collisionPadding:8,className:"z-[80] max-w-[calc(100vw-1rem)] whitespace-normal sm:max-w-xs",children:y})]})}),i.jsx($9e,{})]}):null,_f(a)?i.jsxs(i.Fragment,{children:[i.jsxs(Iee,{onSelect:()=>l(a),children:[i.jsx(U8t,{}),"Open in new tab"]}),i.jsx($9e,{})]}):null,i.jsxs(Iee,{"aria-disabled":t?"true":void 0,"data-disabled":t?"":void 0,onSelect:v=>{if(t){v.preventDefault();return}o(a)},children:[i.jsx(Ls,{}),"Close"]})]})]})}function m1e({className:e,children:t,...n}){return i.jsxs(qgt,{"data-slot":"scroll-area",className:q("relative flex flex-col overflow-hidden",e),...n,children:[i.jsx(Kgt,{"data-slot":"scroll-area-viewport",className:"flex-1 min-h-0 w-full focus-visible:ring-ring/50 rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),i.jsx(wNn,{}),i.jsx(Wgt,{})]})}function wNn({className:e,orientation:t="vertical",...n}){return i.jsx(AMe,{"data-slot":"scroll-area-scrollbar",orientation:t,className:q("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:i.jsx(gMe,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function EU({...e}){return i.jsx(E_,{"data-slot":"sheet",...e})}function kNn({...e}){return i.jsx(WIe,{"data-slot":"sheet-trigger",...e})}function SNn({...e}){return i.jsx(D_,{"data-slot":"sheet-portal",...e})}function ONn({className:e,...t}){return i.jsx(R_,{"data-slot":"sheet-overlay",className:q("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function DU({className:e,children:t,side:n="right",showCloseButton:r=!0,...s}){return i.jsxs(SNn,{children:[i.jsx(ONn,{}),i.jsxs(zO,{"data-slot":"sheet-content",className:q("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition [animation-timing-function:var(--motion-ease-enter)] data-[state=closed]:duration-[var(--motion-duration-standard)] data-[state=open]:duration-[var(--motion-duration-emphasis)] motion-reduce:animate-none motion-reduce:transition-none",n==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",n==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",n==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",n==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...s,children:[t,r&&i.jsxs($O,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[i.jsx(Ls,{className:"size-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function RU({className:e,...t}){return i.jsx("div",{"data-slot":"sheet-header",className:q("flex flex-col gap-1.5 p-4",e),...t})}function jNn({className:e,...t}){return i.jsx("div",{"data-slot":"sheet-footer",className:q("mt-auto flex flex-col gap-2 p-4",e),...t})}function LU({className:e,...t}){return i.jsx(L_,{"data-slot":"sheet-title",className:q("text-foreground font-semibold",e),...t})}function CNn({className:e,...t}){return i.jsx(ZIe,{"data-slot":"sheet-description",className:q("text-muted-foreground text-sm",e),...t})}const NNn=new Set(["detailTab","taskDetailView","contextMenuItem","commentAnnotation","commentContextMenuItem","projectSidebarItem","toolbarButton"]),zat=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(","),PNn=1e3,INn=new Set(jDe),$at=m.createContext(null);function TNn(e){return e instanceof Error&&e.message?e.message:"Unknown error"}function _Nn(e,t,n){return{orgId:e.orgId??null,orgPrefix:e.orgPrefix??null,projectId:e.projectId??(e.entityType==="project"?e.entityId??null:null),entityId:e.entityId??null,entityType:e.entityType??null,userId:n,renderEnvironment:t}}function MNn(e){if(!e)return;const t=e.querySelector(zat);if(t){t.focus();return}e.focus()}function ENn(e,t){if(t.key!=="Tab")return;const n=Array.from(e.querySelectorAll(zat)).filter(o=>!o.hasAttribute("disabled")&&o.tabIndex!==-1);if(n.length===0){t.preventDefault(),e.focus();return}const r=n[0],s=n[n.length-1],a=document.activeElement;if(t.shiftKey&&a===r){t.preventDefault(),s.focus();return}!t.shiftKey&&a===s&&(t.preventDefault(),r.focus())}function DNn(e){switch(e){case"projectSidebarItem":return"justify-start h-auto px-3 py-1 text-[12px] font-normal text-muted-foreground hover:text-foreground";case"contextMenuItem":case"commentContextMenuItem":return"justify-start h-7 w-full px-2 text-xs font-normal";case"sidebar":case"sidebarPanel":return"justify-start h-8 w-full";case"toolbarButton":case"globalToolbarButton":return"h-8";default:return"h-8"}}function Fat(e){switch(e){case"compact":return{width:"min(28rem, calc(100vw - 2rem))"};case"wide":return{width:"min(64rem, calc(100vw - 2rem))"};case"full":return{width:"calc(100vw - 2rem)",height:"calc(100vh - 2rem)"};case"inline":return{width:"min(24rem, calc(100vw - 2rem))"};case"default":default:return{width:"min(40rem, calc(100vw - 2rem))"}}}function RNn(e){const t=e.sourceRect,n=Fat(e.bounds).width??"min(24rem, calc(100vw - 2rem))";if(!t)return{width:n,maxHeight:"min(70vh, 36rem)",top:"4rem",left:"50%",transform:"translateX(-50%)"};const r=Math.min(t.bottom+8,window.innerHeight-32),s=Math.min(Math.max(t.left,16),Math.max(16,window.innerWidth-360));return{width:n,maxHeight:"min(70vh, 36rem)",top:r,left:s}}function LNn(e){return typeof e=="string"&&INn.has(e)}function Bat(e){const t=e.enabled??!0,{data:n,isLoading:r,error:s}=Te({queryKey:V.plugins.uiContributions,queryFn:()=>Ya.listUiContributions(),enabled:t}),a=m.useMemo(()=>[...e.placementZones].sort().join("|"),[e.placementZones]),o=m.useMemo(()=>{const c=new Map;for(const d of n??[])c.set(d.pluginId,d);return c},[n]);return{launchers:m.useMemo(()=>{var u;const c=new Set(a.split("|").filter(Boolean)),d=[];for(const f of n??[])for(const A of f.launchers)c.has(A.placementZone)&&(NNn.has(A.placementZone)&&(!e.entityType||!((u=A.entityTypes)!=null&&u.includes(e.entityType)))||d.push({...A,pluginId:f.pluginId,pluginKey:f.pluginKey,pluginDisplayName:f.displayName,pluginVersion:f.version,uiEntryFile:f.uiEntryFile}));return d.sort((f,A)=>{const h=f.order??Number.MAX_SAFE_INTEGER,g=A.order??Number.MAX_SAFE_INTEGER;if(h!==g)return h-g;const x=f.pluginDisplayName.localeCompare(A.pluginDisplayName);return x!==0?x:f.displayName.localeCompare(A.displayName)}),d},[n,e.entityType,a]),contributionsByPluginId:o,isLoading:t&&r,errorMessage:s?TNn(s):null}}async function zNn(e,t){const n=t.action.target,r=r3e(t.pluginKey,n);return r||(await d$t(e),r3e(t.pluginKey,n))}function $Nn({pluginId:e,hostContext:t,children:n}){const r=m.useMemo(()=>({pluginId:e,hostContext:t}),[e,t]);return i.jsx(Afe.Provider,{value:r,children:n})}class FNn extends m.Component{constructor(){super(...arguments);ai(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,r){console.error("Plugin launcher render failed",{pluginKey:this.props.launcher.pluginKey,launcherId:this.props.launcher.id,error:n,info:r.componentStack})}render(){return this.state.hasError?i.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive",children:[this.props.launcher.pluginDisplayName,": failed to render"]}):this.props.children}}function BNn({instance:e,renderEnvironment:t}){var l,c;const n=e.component,{data:r}=Te({queryKey:V.auth.session,queryFn:()=>el.getSession()}),s=((l=r==null?void 0:r.user)==null?void 0:l.id)??((c=r==null?void 0:r.session)==null?void 0:c.userId)??null,a=m.useMemo(()=>_Nn(e.hostContext,t,s),[e.hostContext,t,s]);if(!n)return t.environment==="iframe"?i.jsx("iframe",{src:`/_plugins/${encodeURIComponent(e.launcher.pluginId)}/ui/${e.launcher.action.target}`,title:`${e.launcher.pluginDisplayName} ${e.launcher.displayName}`,className:"h-full min-h-[24rem] w-full rounded-md border border-border bg-background"}):i.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive",children:[e.launcher.pluginDisplayName,': could not resolve launcher target "',e.launcher.action.target,'".']});if(n.kind==="web-component")return m.createElement(n.tagName,{className:"block w-full",pluginLauncher:e.launcher,pluginContext:a});const o=m.createElement(n.component,{launcher:e.launcher,context:a});return i.jsx(FNn,{launcher:e.launcher,children:i.jsx($Nn,{pluginId:e.launcher.pluginId,hostContext:a,children:o})})}function QNn({instance:e,stackIndex:t,isTopmost:n,requestBounds:r,closeLauncher:s}){const a=m.useRef(null),o=m.useId();m.useEffect(()=>{if(!n)return;const A=requestAnimationFrame(()=>{MNn(a.current)});return()=>cancelAnimationFrame(A)},[n]),m.useEffect(()=>{if(!n)return;const A=h=>{if(a.current){if(h.key==="Escape"){h.preventDefault(),s(e.key,{reason:"escapeKey",nativeEvent:h});return}ENn(a.current,h)}};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[s,e.key,n]);const l=m.useMemo(()=>{var A;return{environment:((A=e.launcher.render)==null?void 0:A.environment)??"hostOverlay",launcherId:e.launcher.id,bounds:e.bounds,requestModalBounds:h=>r(e.key,h),closeLifecycle:{onBeforeClose:h=>(e.beforeCloseHandlers.add(h),()=>e.beforeCloseHandlers.delete(h)),onClose:h=>(e.closeHandlers.add(h),()=>e.closeHandlers.delete(h))}}},[e,r]),c=PNn+t*20,d=e.launcher.action.type,u=d==="openPopover"?RNn(e):Fat(e.bounds),f=d==="openDrawer"?"fixed right-0 top-0 h-full max-w-[min(44rem,100vw)] overflow-hidden border-l border-border bg-background shadow-2xl":d==="openPopover"?"fixed overflow-hidden rounded-xl border border-border bg-background shadow-2xl":"fixed left-1/2 top-1/2 max-h-[calc(100vh-2rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-2xl border border-border bg-background shadow-2xl";return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 bg-black/45",style:{zIndex:c},"aria-hidden":"true",onMouseDown:A=>{n&&A.target===A.currentTarget&&s(e.key,{reason:"backdrop",nativeEvent:A})}}),i.jsxs("div",{ref:a,role:"dialog","aria-modal":"true","aria-labelledby":o,tabIndex:-1,className:f,style:{zIndex:c+1,...d==="openDrawer"?{width:u.width??"min(44rem, 100vw)"}:u},onMouseDown:A=>A.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center gap-3 border-b border-border px-4 py-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h2",{id:o,className:"truncate text-sm font-semibold",children:e.launcher.displayName}),i.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.launcher.pluginDisplayName})]}),i.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>void s(e.key,{reason:"programmatic"}),children:"Close"})]}),i.jsx("div",{className:q("overflow-auto p-4",d==="openDrawer"?"h-[calc(100%-3.5rem)]":"max-h-[calc(100vh-7rem)]"),children:i.jsx(BNn,{instance:e,renderEnvironment:l})})]})]})}function UNn({children:e}){const[t,n]=m.useState([]),r=m.useRef(t);r.current=t;const s=br(),a=Hr(),o=m.useCallback(async(u,f)=>{const A=r.current.find(h=>h.key===u);if(A){for(const h of[...A.beforeCloseHandlers])await h(f);n(h=>h.filter(g=>g.key!==u)),queueMicrotask(()=>{for(const h of[...A.closeHandlers])h(f);A.sourceElement&&document.contains(A.sourceElement)&&A.sourceElement.focus()})}},[]);m.useEffect(()=>{t.length!==0&&Promise.all(t.map(u=>o(u.key,{reason:"hostNavigation"})))},[s.key]);const l=m.useCallback(async(u,f)=>{LNn(f.bounds)&&n(A=>A.map(h=>h.key===u?{...h,bounds:f.bounds}:h))},[]),c=m.useCallback(async(u,f,A,h)=>{var g;switch(u.action.type){case"navigate":a(u.action.target);return;case"deepLink":/^https?:\/\//.test(u.action.target)?window.open(u.action.target,"_blank","noopener,noreferrer"):a(u.action.target);return;case"performAction":await Ya.bridgePerformAction(u.pluginId,u.action.target,u.action.params,f.orgId??null);return;case"openModal":case"openDrawer":case"openPopover":{const x=await zNn(A,u),y=(h==null?void 0:h.getBoundingClientRect())??null,v={key:`${u.pluginId}:${u.id}:${Date.now()}:${Math.random().toString(36).slice(2,8)}`,launcher:u,hostContext:f,contribution:A,component:x,sourceElement:h??null,sourceRect:y,bounds:((g=u.render)==null?void 0:g.bounds)??"default",beforeCloseHandlers:new Set,closeHandlers:new Set};n(w=>[...w,v]);return}}},[a]),d=m.useMemo(()=>({activateLauncher:c}),[c]);return i.jsxs($at.Provider,{value:d,children:[e,t.map((u,f)=>i.jsx(QNn,{instance:u,stackIndex:f,isTopmost:f===t.length-1,requestBounds:l,closeLauncher:o},u.key))]})}function VNn(){const e=m.useContext($at);if(!e)throw new Error("usePluginLauncherRuntime must be used within PluginLauncherProvider");return e}function qNn({launcher:e,placementZone:t,onClick:n}){return i.jsx(ie,{type:"button",variant:t==="toolbarButton"||t==="globalToolbarButton"?"outline":"ghost",size:"sm",className:DNn(t),onClick:n,children:e.displayName})}function p1e({placementZones:e,context:t,entityType:n,className:r,itemClassName:s,errorClassName:a}){const{activateLauncher:o}=VNn(),{launchers:l,contributionsByPluginId:c,errorMessage:d}=Bat({placementZones:e,entityType:n,orgId:t.orgId,enabled:!!t.orgId});return d?i.jsxs("div",{className:q("rounded-md border border-destructive/30 bg-destructive/5 px-2 py-1 text-xs text-destructive",a),children:["Plugin launchers unavailable: ",d]}):l.length===0?null:i.jsx("div",{className:r,children:l.map(u=>i.jsx("div",{className:s,children:i.jsx(qNn,{launcher:u,placementZone:u.placementZone,onClick:f=>{const A=c.get(u.pluginId);A&&o(u,t,A,f.currentTarget)}})},`${u.pluginKey}:${u.id}`))})}const KNn="mark[data-issue-find-highlight='true']",Qat="rudder-issue-find-highlight",rle="rudder-issue-find-highlight-active",WNn=["[data-issue-find-ui]","input","textarea","select","script","style","noscript","[aria-hidden='true']"].join(","),Uat="color-mix(in oklab, #f4c430 62%, transparent)",ZNn="color-mix(in oklab, var(--accent-base) 58%, #f4c430)",HNn="0 0 0 1px color-mix(in oklab, var(--accent-strong) 62%, transparent)";function XNn(e){e.style.borderRadius="2px",e.style.background=Uat,e.style.color="inherit",e.style.padding="0 1px"}function Tee(e,t){var n;return((n=e.ownerDocument.defaultView)==null?void 0:n.NodeFilter[t])??(t==="FILTER_ACCEPT"?1:t==="FILTER_REJECT"?2:4)}function g1e(e){var n;const t=e.defaultView;return!((n=t==null?void 0:t.CSS)!=null&&n.highlights)||!t.Highlight?null:{Highlight:t.Highlight,highlights:t.CSS.highlights}}function GNn(e){const t=e instanceof HTMLElement?e:null;return t?t.isContentEditable?!0:!!t.closest("input, textarea, select, [contenteditable='true']"):!1}function YNn(e){return e.defaultPrevented||e.key.toLowerCase()!=="f"||!e.metaKey&&!e.ctrlKey?!1:!e.altKey&&!e.shiftKey}function Z$(e){const t=g1e(e.ownerDocument);t==null||t.highlights.delete(Qat),t==null||t.highlights.delete(rle);const n=Array.from(e.querySelectorAll(KNn));for(const r of n){const s=r.parentNode;if(s){for(;r.firstChild;)s.insertBefore(r.firstChild,r);s.removeChild(r),s.normalize()}}}function JNn(e){return e.isContentEditable||e.matches("[contenteditable='true']")}function ePn(e,t){var a,o;const n=e.parentElement;if(!n||n.closest(WNn))return!1;const r=n.ownerDocument.activeElement,s=n.closest("[contenteditable='true']");return s&&t.mode==="css"&&!t.canUseCssHighlights||(a=t.skipElement)!=null&&a.contains(n)&&(!JNn(t.skipElement)||!t.canUseCssHighlights)?!1:s&&r instanceof Node&&s.contains(r)?t.canUseCssHighlights:!!((o=e.nodeValue)!=null&&o.trim())}function tPn(e,t,n={}){Z$(e);const r=t.trim();if(!r)return[];const s=e.ownerDocument,a=n.mode==="css"?g1e(s):null,o=!!a,l=[],c=s.createTreeWalker(e,Tee(e,"SHOW_TEXT"),{acceptNode:h=>ePn(h,{canUseCssHighlights:o,mode:n.mode??"mark",skipElement:n.skipElement})?Tee(e,"FILTER_ACCEPT"):Tee(e,"FILTER_REJECT")});let d=c.nextNode();for(;d;)l.push(d),d=c.nextNode();const u=[],f=r.toLocaleLowerCase(),A=r.length;for(const h of l){const g=h.nodeValue??"",x=g.toLocaleLowerCase();let y=0,v=x.indexOf(f,y);if(v===-1)continue;if(a){for(;v!==-1;){const k=s.createRange();k.setStart(h,v),k.setEnd(h,v+A),u.push(k),y=v+A,v=x.indexOf(f,y)}continue}const w=s.createDocumentFragment();for(;v!==-1;){v>y&&w.append(s.createTextNode(g.slice(y,v)));const k=s.createElement("mark");k.dataset.issueFindHighlight="true",k.className="issue-find-highlight",XNn(k),k.textContent=g.slice(v,v+A),w.append(k),u.push(k),y=v+A,v=x.indexOf(f,y)}y<g.length&&w.append(s.createTextNode(g.slice(y))),h.replaceWith(w)}if(a&&u.length>0){const h=u.filter(g=>g instanceof Range);a.highlights.set(Qat,new a.Highlight(...h))}return u}function F9e(e,t){let n=null;const r=e.find(o=>o instanceof Range)??null,s=(r==null?void 0:r.startContainer.ownerDocument)??null,a=s?g1e(s):null;if(a){const o=e[t]instanceof Range?e[t]:null;return o?(a.highlights.set(rle,new a.Highlight(o)),n=o):a.highlights.delete(rle),n}for(let o=0;o<e.length;o+=1){const l=e[o];if(!(l instanceof HTMLElement))continue;const c=o===t;l.dataset.issueFindActive=c?"true":"false",l.classList.toggle("issue-find-highlight--active",c),l.style.background=c?ZNn:Uat,l.style.boxShadow=c?HNn:"",c&&(n=l)}return n}function B9e(e){var r,s;if(!e)return;if(e instanceof HTMLElement){(r=e.scrollIntoView)==null||r.call(e,{block:"center",inline:"nearest",behavior:"smooth"});return}const t=e.startContainer.parentNode,n=t instanceof HTMLElement?t:null;(s=n==null?void 0:n.scrollIntoView)==null||s.call(n,{block:"center",inline:"nearest",behavior:"smooth"})}function nPn(){return typeof document>"u"?!1:!!(document.querySelector("[role='dialog']")||document.querySelector("[data-radix-popper-content-wrapper]"))}function rPn(e){return e.key==="Escape"&&!e.defaultPrevented&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey}function Vat({rootRef:e,disabled:t=!1,refreshKey:n,searchLabel:r="Find in issue",highlightMode:s="mark"}){const[a,o]=m.useState(!1),[l,c]=m.useState(""),[d,u]=m.useState(0),[f,A]=m.useState(0),h=m.useRef(null),g=m.useRef([]),x=m.useRef(0),y=m.useRef(""),v=m.useRef(null),w=m.useCallback(()=>{requestAnimationFrame(()=>{var C,N;(C=h.current)==null||C.focus(),(N=h.current)==null||N.select()})},[]),k=m.useCallback(()=>{const C=e.current;C&&Z$(C),g.current=[],x.current=0,y.current="",v.current=null,o(!1),c(""),u(0),A(0)},[e]),O=m.useCallback(C=>{const N=g.current;if(N.length===0){x.current=0,A(0);return}const I=(x.current+C+N.length)%N.length;x.current=I,A(I);const E=F9e(N,I);B9e(E)},[]);if(m.useEffect(()=>{t&&a&&k()},[k,t,a]),m.useEffect(()=>{const C=N=>{if(t)return;if(YNn(N)){if(nPn())return;const _=N.target instanceof HTMLElement?N.target:null;v.current=(_==null?void 0:_.closest("input, textarea, select, [contenteditable='true']"))??null,N.preventDefault(),o(!0),w();return}if(!a||!rPn(N))return;const I=N.target instanceof HTMLElement?N.target:null;!(I!=null&&I.closest("[data-issue-find-ui]"))&&GNn(N.target)||(N.preventDefault(),k())};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[k,t,w,a]),m.useLayoutEffect(()=>{const C=e.current;if(!C||!a)return;const N=tPn(C,l,{mode:s,skipElement:v.current});g.current=N,u(N.length);const I=l.trim(),E=y.current!==I;y.current=I;const _=N.length===0||E?0:Math.min(x.current,N.length-1);x.current=_,A(_);const T=F9e(N,_);return I&&T&&B9e(T),()=>{Z$(C),g.current=[]}},[s,a,l,n,e]),m.useEffect(()=>()=>{const C=e.current;C&&Z$(C)},[e]),!a)return null;const j=d===0?"0 of 0":`${f+1} of ${d}`;return i.jsxs("div",{"data-issue-find-ui":!0,role:"search","aria-label":r,className:"fixed right-4 top-4 z-50 flex w-[min(420px,calc(100vw-2rem))] items-center gap-1 rounded-md border border-border bg-popover p-1.5 text-popover-foreground shadow-md",children:[i.jsx(Pl,{className:"ml-1 h-4 w-4 shrink-0 text-muted-foreground"}),i.jsx(Vn,{ref:h,value:l,onChange:C=>c(C.target.value),onKeyDown:C=>{if(C.key==="Enter"){C.preventDefault(),O(C.shiftKey?-1:1);return}if(C.key==="ArrowDown"){C.preventDefault(),O(1);return}if(C.key==="ArrowUp"){C.preventDefault(),O(-1);return}C.key==="Escape"&&(C.preventDefault(),k())},className:"h-7 min-w-0 flex-1 border-0 bg-transparent px-1 text-sm shadow-none focus-visible:ring-0",placeholder:"Find","aria-label":r}),i.jsx("span",{className:"min-w-14 shrink-0 text-right text-xs tabular-nums text-muted-foreground",children:j}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Previous match",disabled:d===0,onClick:()=>O(-1),children:i.jsx(Xde,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Next match",disabled:d===0,onClick:()=>O(1),children:i.jsx(RLe,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Close find",onClick:k,children:i.jsx(Ls,{className:"h-3.5 w-3.5"})})]})}function sPn(e){return e.identifier??e.id.slice(0,8)}function iPn({parentIssue:e}){if(!e)return null;const t=sPn(e);return i.jsxs("div",{"aria-label":"Parent issue context",className:"flex min-w-0 items-center gap-2 text-sm leading-5 text-muted-foreground",children:[i.jsx("span",{className:"shrink-0",children:"Sub-issue of"}),i.jsxs(an,{to:tM(e),className:"inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md px-1 py-0.5 text-foreground transition-colors hover:bg-accent/50",children:[i.jsx(ni,{status:e.status,className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"max-w-28 shrink truncate font-mono text-xs text-muted-foreground",children:t}),i.jsx("span",{className:"min-w-0 truncate",children:e.title})]}),i.jsx(Dw,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"})]})}function Q9e(){const e=document.getElementById("main-content");if(e instanceof HTMLElement){const t=window.getComputedStyle(e).overflowY;if((t==="auto"||t==="scroll"||t==="overlay")&&e.scrollHeight>e.clientHeight+1)return{type:"element",element:e}}return{type:"window"}}function aPn(e){return e.type==="element"?e.element.scrollHeight-e.element.scrollTop-e.element.clientHeight:(document.scrollingElement??document.documentElement).scrollHeight-window.scrollY-window.innerHeight}function qat(){const[e,t]=m.useState(!1);m.useEffect(()=>{const r=()=>{t(aPn(Q9e())>300)},s=document.getElementById("main-content");return r(),s==null||s.addEventListener("scroll",r,{passive:!0}),window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),()=>{s==null||s.removeEventListener("scroll",r),window.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[]);const n=m.useCallback(()=>{const r=Q9e();if(r.type==="element"){r.element.scrollTo({top:r.element.scrollHeight,behavior:"smooth"});return}const s=document.scrollingElement??document.documentElement;window.scrollTo({top:s.scrollHeight,behavior:"smooth"})},[]);return e?i.jsx("button",{onClick:n,className:"fixed bottom-[calc(1.5rem+5rem+env(safe-area-inset-bottom))] right-6 z-40 flex h-9 w-9 items-center justify-center rounded-full border border-border bg-background shadow-md hover:bg-accent transition-colors md:bottom-6","aria-label":"Scroll to bottom",children:i.jsx(RLe,{className:"h-4 w-4"})}):null}const Kat="rudder:starred-issues";function oPn(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(Kat);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.length>0):[]}catch{return[]}}function U9e(){if(!(typeof window>"u"))try{window.localStorage.removeItem(Kat)}catch{}}function x1e(e){const t=Wn(),n=m.useRef(null),r=m.useRef(null),s=Te({queryKey:V.issues.follows(e??"__none__"),queryFn:()=>fr.listFollows(e),enabled:!!e}),a=m.useMemo(()=>new Set((s.data??[]).map(l=>l.issueId)),[s.data]);m.useEffect(()=>{if(!e||!s.isSuccess||n.current===e||r.current===e)return;const l=oPn();if(l.length===0){n.current=e;return}const c=l.filter(d=>!a.has(d));if(c.length===0){U9e(),n.current=e;return}r.current=e,Promise.allSettled(c.map(d=>fr.follow(d))).then(async d=>{r.current=null,!d.some(f=>f.status==="rejected")&&(U9e(),n.current=e,await t.invalidateQueries({queryKey:V.issues.follows(e)}),await t.invalidateQueries({queryKey:V.issues.list(e)}),await vA(t,e),await t.invalidateQueries({queryKey:V.messenger.issues(e)}))})},[a,s.isSuccess,e,t]);const o=m.useCallback(async l=>{e&&(a.has(l)?await fr.unfollow(l):await fr.follow(l),await t.invalidateQueries({queryKey:V.issues.follows(e)}),await t.invalidateQueries({queryKey:V.issues.list(e)}),await vA(t,e),await t.invalidateQueries({queryKey:V.messenger.issues(e)}))},[a,e,t]);return{follows:s.data??[],followedIssueIds:a,isLoading:s.isLoading,error:s.error instanceof Error?s.error:null,toggleFollowIssue:o}}function sZ(e,t,n,r){return e==="system"?"System":e==="user"?n&&t===n?Dfe(r):"Board":t||"Unknown"}function lPn(e,t,n,r){var s;return e.actorType==="agent"?((s=t.get(e.actorId))==null?void 0:s.name)??e.actorId??"Unknown":sZ(e.actorType,e.actorId,n,r)}function cPn(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.label=="string"&&typeof t.href=="string"}function zU(e,t){return{issueDetailBreadcrumb:{label:e,href:t}}}function dPn(e){if(typeof e!="object"||e===null)return null;const t=e.issueDetailBreadcrumb;return cPn(t)?t:null}const V9e={addFromLibrary:{en:"Add from Library","zh-CN":"从文档添加"},attachFromLibrary:{en:"Attach from Library","zh-CN":"从文档添加"},attachFromLibraryDescription:{en:"Choose a file to copy into this issue's attachments.","zh-CN":"选择要复制到此任务附件的文件。"},agentPrivateSkillsHelp:{en:"Agent-private skills belong to this agent only. Edit them in Library, then enable them here when you want Rudder to load them.","zh-CN":"智能体私有技能只属于当前智能体。先在文档中编辑,需要 Rudder 加载时再在这里启用。"},couldNotLoadLibraryFiles:{en:"Could not load Library files","zh-CN":"无法加载文档文件"},editInLibrary:{en:"Edit in Library","zh-CN":"在文档中编辑"},findInLibrary:{en:"Find in Library","zh-CN":"在文档中查找"},importSkillsIntoLibraryFirst:{en:"Import or scan skills into Library first, then enable them here.","zh-CN":"请先将技能导入或扫描到文档中,然后在这里启用。"},legacyLibraryDocument:{en:"Legacy Library document","zh-CN":"旧版文档"},library:{en:"Library","zh-CN":"文档"},libraryFiles:{en:"Library files","zh-CN":"文档文件"},linkedLibrary:{en:"Linked Library","zh-CN":"关联文档"},liveLibraryFile:{en:"live Library file","zh-CN":"实时文档文件"},liveLibraryFolder:{en:"live Library folder","zh-CN":"实时文档文件夹"},liveLibraryLink:{en:"live Library link","zh-CN":"实时文档链接"},noLibraryFiles:{en:"No Library files available.","zh-CN":"暂无文档文件。"},noMatchingLibraryFiles:{en:"No matching Library files.","zh-CN":"没有匹配的文档文件。"},projectContextHelp:{en:"Attach the codebases, Library files, URLs, and external systems agents should use for this project.","zh-CN":"添加这个项目中智能体应使用的代码库、文档文件、URL 和外部系统。"},organizationSkillsHelp:{en:"Bundled Rudder skills are locked on. Community presets and other organization skills stay optional; Library-backed skills can be edited from Library.","zh-CN":"内置 Rudder 技能固定开启。社区预设和其他组织技能保持可选;由文档库支持的技能可在文档中编辑。"},resourceNotFoundInProjectLibrary:{en:"Resource not found in this project Library.","zh-CN":"在这个项目文档中未找到资源。"},searchLibraryPlaceholder:{en:"Search Library or paste relative path","zh-CN":"搜索文档或粘贴相对路径"},libraryDocumentUnavailable:{en:"This Library document could not be found or is not available in this organization.","zh-CN":"找不到这个文档,或它在当前组织中不可用。"},readOnlyInLibrary:{en:"This file is rendered read-only in Library.","zh-CN":"这个文件在文档中以只读方式呈现。"},cannotRenderInLibrary:{en:"This file cannot be rendered in Library.","zh-CN":"这个文件无法在文档中呈现。"},useThisLibraryPath:{en:"Use this Library path","zh-CN":"使用这个文档路径"}};function ji(e,t){return V9e[e][t]??V9e[e].en}const Wat="rudder:recent-issues",uPn=50,sle="rudder:recent-issues-changed";function b1e(e){return[...new Set(e.filter(t=>typeof t=="string"&&t.length>0))]}function q9e(e){if(typeof window>"u")return{exists:!1,values:[]};try{const t=window.localStorage.getItem(e);if(t===null)return{exists:!1,values:[]};const n=JSON.parse(t);return Array.isArray(n)?{exists:!0,values:b1e(n)}:{exists:!0,values:[]}}catch{return{exists:!1,values:[]}}}function Zat(e){return`${Wat}:${e}`}function tk(e){if(!e)return[];const t=q9e(Zat(e));return t.exists?t.values:q9e(Wat).values}function fPn(e,t){const n=b1e(t).slice(0,uPn);if(typeof window>"u")return n;try{window.localStorage.setItem(Zat(e),JSON.stringify(n))}catch{}try{window.dispatchEvent(new CustomEvent(sle,{detail:{orgId:e,issueIds:n}}))}catch{}return n}function y1e(e,t,n){return fPn(e,[t,...n])}function APn(e,t){const n=new Map(t.map(r=>[r.id,r]));return b1e(e).map(r=>n.get(r)).filter(r=>!!r)}function hPn(e){const t=new URLSearchParams({issueId:e.id});return e.projectId&&t.set("projectId",e.projectId),e.assigneeAgentId&&t.set("agentId",e.assigneeAgentId),`/messenger/chat?${t.toString()}`}const mPn=[];function pPn(e){var s,a,o,l,c;const t=((s=e.issue)==null?void 0:s.title)??e.issueId??"Issue",n=((a=e.issue)==null?void 0:a.identifier)??((o=e.issue)!=null&&o.id?e.issue.id.slice(0,8):null),r=n&&((l=e.issue)!=null&&l.title)?`${n} ${e.issue.title}`:t;return[e.sourceBreadcrumb,...[...((c=e.issue)==null?void 0:c.ancestors)??[]].reverse().map(d=>({label:d.title,href:`/issues/${d.identifier??d.id}`})),{label:r}]}const gPn={assigneeAgentId:"assignee",assigneeUserId:"assignee",assigneeAgentRuntimeOverrides:"assignee runtime overrides",billingCode:"billing code",executionWorkspaceId:"run workspace",executionWorkspacePreference:"run workspace preference",executionWorkspaceSettings:"run workspace settings",goalId:"goal",hiddenAt:"visibility",labelIds:"labels",parentId:"parent issue",projectId:"project",projectWorkspaceId:"project workspace",requestDepth:"request depth",reviewerAgentId:"reviewer",reviewerUserId:"reviewer"},K9e={"issue.created":"created the issue","issue.updated":"updated the issue","issue.checked_out":"checked out the issue","issue.released":"released the issue","issue.comment_updated":"edited a comment","issue.comment_deleted":"deleted a comment","issue.code_committed":"committed code","issue.passive_followup_queued":"queued passive follow-up","issue.closure_needs_operator_review":"needs operator review for close-out","issue.review_decision_recorded":"recorded a reviewer decision","issue.attachment_added":"added an attachment","issue.attachment_removed":"removed an attachment","issue.approval_linked":"linked an approval","issue.approval_unlinked":"unlinked an approval","issue.document_created":"created a document","issue.document_updated":"updated a document","issue.document_deleted":"deleted a document","issue.deleted":"deleted the issue","agent.created":"created an agent","agent.updated":"updated the agent","agent.paused":"paused the agent","agent.resumed":"resumed the agent","agent.terminated":"terminated the agent","heartbeat.invoked":"invoked a heartbeat","heartbeat.cancelled":"cancelled a heartbeat","approval.created":"requested approval","approval.approved":"approved","approval.rejected":"rejected"},xPn=new Set(["issue.comment_updated","issue.comment_deleted","issue.deleted"]);function I5(e){return typeof e!="string"?String(e??"none"):e.replace(/_/g," ")}function bPn(e){return gPn[e]??e.replace(/Id$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()}function zN(e){return e!=null&&e!==""}function yPn(e,t,n){return zN(t)&&zN(n)?`changed the ${e}`:zN(t)?`set the ${e}`:zN(n)?`cleared the ${e}`:`updated the ${e}`}function vPn(e,t){return MA(e,t)??e.slice(0,8)}function tz(e,t,n){var r;return e?typeof e.agentId=="string"&&e.agentId?((r=t.get(e.agentId))==null?void 0:r.name)??e.agentId.slice(0,8):typeof e.userId=="string"&&e.userId?vPn(e.userId,n):null:null}function W9e(e){return e.toLabel?e.fromLabel?`${e.changedVerb} from ${e.fromLabel} to ${e.toLabel}`:`${e.assignedVerb} to ${e.toLabel}`:e.fromLabel?`${e.clearedVerb} ${e.fromLabel}`:e.unassignedVerb}function nx(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function Z9e(e){const t=nx(e);return!t||typeof t.id!="string"?null:{id:t.id,identifier:typeof t.identifier=="string"?t.identifier:null,title:typeof t.title=="string"?t.title:null}}function wPn(e){return e.identifier||e.title||e.id.slice(0,8)}function kPn(e){return`/issues/${e.identifier??e.id}`}function H9e(e){return i.jsx(an,{to:kPn(e),className:"underline underline-offset-4 hover:text-foreground",children:wPn(e)})}function Hat(e){return uq(e)}function SPn(e){return ORe(e.action,e.details)}function OPn(e){return!(e.action==="issue.comment_added"||xPn.has(e.action)||e.action==="issue.document_updated"||e.action==="issue.updated"&&Hat(e.details).length===0||SPn(e))}function VC(e,...t){if(!e)return 0;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return 0}function X9e(e,...t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}return null}const jPn=["backlog","todo","in_progress","in_review","done","cancelled","blocked"],CPn="image/*,application/pdf,text/plain,text/markdown,application/json,text/csv,text/html,.md,.markdown",Xat="rudder.linear",NPn="linear-issue-tab",G9e="issue-link";function H$(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function Y9e(e){return e.pluginKey===Xat&&e.id===NPn}function PPn(e){var t;return((t=e.displayLabel)==null?void 0:t.trim())||e.name}function IPn(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function TPn({orgId:e,open:t,onOpenChange:n,onAttach:r,attaching:s,error:a}){var g;const[o,l]=m.useState(""),[c,d]=m.useState(null);m.useEffect(()=>{t&&(l(""),d(null))},[t,e]);const u=Te({queryKey:V.organizations.workspaceFiles(e??"__none__",o),queryFn:()=>En.listWorkspaceFiles(e,o),enabled:t&&!!e,refetchOnWindowFocus:!1}),f=((g=u.data)==null?void 0:g.entries)??[],A=o.length>0,{locale:h}=as();return i.jsx(ws,{open:t,onOpenChange:n,children:i.jsxs(Ps,{className:"sm:max-w-xl",children:[i.jsxs(Ai,{children:[i.jsx(Js,{className:"text-base",children:ji("attachFromLibrary",h)}),i.jsx(wi,{children:ji("attachFromLibraryDescription",h)})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex min-h-8 items-center gap-2 rounded-md border border-border bg-muted/20 px-2 text-xs text-muted-foreground",children:[i.jsx("span",{className:"font-medium text-foreground",children:"/"}),i.jsx("span",{className:"truncate",children:o||ji("libraryFiles",h)})]}),i.jsx("div",{className:"h-[320px] overflow-hidden rounded-md border border-border",children:u.isLoading?i.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[i.jsx(yn,{className:"h-4 w-4 animate-spin"}),"Loading files..."]}):u.error?i.jsx("div",{className:"p-3 text-sm text-destructive",children:u.error instanceof Error?u.error.message:ji("couldNotLoadLibraryFiles",h)}):f.length===0&&!A?i.jsx("div",{className:"p-3 text-sm text-muted-foreground",children:ji("noLibraryFiles",h)}):i.jsx(m1e,{className:"h-full",children:i.jsxs("div",{className:"space-y-0.5 p-1.5",children:[A?i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:()=>{l(IPn(o)),d(null)},children:[i.jsx(_i,{className:"h-3.5 w-3.5 rotate-180"}),"Parent folder"]}):null,f.map(x=>{const y=PPn(x),v=c===x.path;return x.isDirectory?i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent/60",onClick:()=>{l(x.path),d(null)},children:[i.jsx(ho,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"truncate font-medium",children:y})]},x.path):i.jsxs("button",{type:"button",className:q("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors",v?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),onClick:()=>d(x.path),onDoubleClick:()=>void r(x.path),children:[i.jsx(b6,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:y})]},x.path)})]})})}),c?i.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:["Selected: ",c]}):null,a?i.jsx("p",{className:"text-xs text-destructive",children:a}):null]}),i.jsxs(aa,{children:[i.jsx(ie,{type:"button",variant:"ghost",onClick:()=>n(!1),disabled:s,children:"Cancel"}),i.jsxs(ie,{type:"button",onClick:()=>c?void r(c):void 0,disabled:!c||s,children:[s?i.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(Wu,{className:"h-3.5 w-3.5"}),"Attach"]})]})]})})}function _Pn(e,t,n,r){if(e==="issue.code_committed"&&t){const s=typeof t.shortSha=="string"?t.shortSha:null,a=typeof t.subject=="string"?t.subject:null;if(s&&a)return`committed ${s}: ${a}`;if(s)return`committed ${s}`}if(e==="issue.updated"&&t){const s=t._previous??{},a=[];if(t.status!==void 0){const l=s.status;a.push(l?`moved from ${H$(I5(l))} to ${H$(I5(t.status))}`:`moved to ${H$(I5(t.status))}`)}if(t.priority!==void 0){const l=s.priority;a.push(l?`changed the priority from ${sd(I5(l))} to ${sd(I5(t.priority))}`:`changed the priority to ${sd(I5(t.priority))}`)}if(t.assigneeAgentId!==void 0||t.assigneeUserId!==void 0){const l=nx(s.assignee),c=tz(l??{agentId:s.assigneeAgentId,userId:s.assigneeUserId},n,r),d=tz({agentId:t.assigneeAgentId,userId:t.assigneeUserId},n,r);a.push(W9e({toLabel:d,fromLabel:c,assignedVerb:"assigned the issue",changedVerb:"reassigned the issue",clearedVerb:"unassigned the issue from",unassignedVerb:"unassigned the issue"}))}if(t.reviewerAgentId!==void 0||t.reviewerUserId!==void 0){const l=nx(s.reviewer),c=tz(l??{agentId:s.reviewerAgentId,userId:s.reviewerUserId},n,r),d=tz({agentId:t.reviewerAgentId,userId:t.reviewerUserId},n,r);a.push(W9e({toLabel:d,fromLabel:c,assignedVerb:"set the reviewer",changedVerb:"changed the reviewer",clearedVerb:"cleared the reviewer from",unassignedVerb:"cleared the reviewer"}))}t.title!==void 0&&a.push("updated the title"),t.description!==void 0&&a.push("updated the description");const o=new Set(["assigneeAgentId","assigneeUserId","description","priority","reviewerAgentId","reviewerUserId","status","title"]);for(const l of Hat(t).filter(c=>!o.has(c)))a.push(yPn(bPn(l),t[l],s[l]));if(a.length>0)return a.join(", ")}if((e==="issue.document_created"||e==="issue.document_updated"||e==="issue.document_deleted")&&t){const s=typeof t.key=="string"?t.key:"document",a=typeof t.title=="string"&&t.title?` (${t.title})`:"";return`${K9e[e]??e} ${s}${a}`}if(e==="issue.passive_followup_queued"&&t){const s=typeof t.attempt=="number"?t.attempt:null,a=typeof t.maxAttempts=="number"?t.maxAttempts:null,o=typeof t.followupRunId=="string"?t.followupRunId:null;return`queued passive follow-up${s&&a?` (${s}/${a})`:""}${o?` as run ${o.slice(0,8)}`:""}`}if(e==="issue.closure_needs_operator_review"&&t){const s=typeof t.attempts=="number"?t.attempts:null;return s?`stopped passive follow-up after ${s} attempts; operator review needed`:"stopped passive follow-up; operator review needed"}return e==="issue.review_decision_recorded"&&t?`recorded reviewer decision: ${typeof t.decision=="string"?I5(t.decision):"unknown"}`:K9e[e]??e.replace(/[._]/g," ")}function MPn(e){const t=nx(e.details);return(typeof(t==null?void 0:t.conversationTitle)=="string"?t.conversationTitle.trim():"")||`Chat ${e.entityId.slice(0,8)}`}function EPn(e,t,n){const r=nx(e.details);if(e.action==="issue.updated"&&r&&Object.prototype.hasOwnProperty.call(r,"parentId")){const s=nx(r._previous),a=nx(r._references),o=Z9e(a==null?void 0:a.parentIssue),l=Z9e(a==null?void 0:a.previousParentIssue);if(o)return i.jsxs(i.Fragment,{children:[zN(s==null?void 0:s.parentId)?"changed the parent issue to ":"set the parent issue to ",H9e(o)]});if(l)return i.jsxs(i.Fragment,{children:["cleared the parent issue ",H9e(l)]})}if(e.entityType==="chat"){const s=`/chat/${e.entityId}`,a=MPn(e),o=i.jsx(an,{to:s,className:"underline underline-offset-4 hover:text-foreground",children:a});if(e.action==="chat.issue_converted")return i.jsxs(i.Fragment,{children:["created this issue from ",o]});if(e.action==="chat.context_linked")return i.jsxs(i.Fragment,{children:["linked this issue in ",o]});if(e.action==="chat.created")return i.jsxs(i.Fragment,{children:["started ",o," with this issue linked"]})}if(e.action==="issue.approval_linked"||e.action==="issue.approval_unlinked"){const s=typeof(r==null?void 0:r.approvalId)=="string"?r.approvalId:null;if(s){const a=e.action==="issue.approval_linked"?"linked":"unlinked";return i.jsxs(i.Fragment,{children:[a," ",i.jsx(an,{to:`/messenger/approvals/${s}`,className:"underline underline-offset-4 hover:text-foreground",children:"an approval"})]})}}return _Pn(e.action,r,t,n)}function DPn({evt:e,agentMap:t,currentBoardUserId:n,operatorDisplayName:r}){const s=e.actorId;if(e.actorType==="agent"){const a=t.get(s);return(a==null?void 0:a.name)??s.slice(0,8)}return sZ(e.actorType,s,n,r)}function RPn(e){const t=nx(e.details);return e.action==="issue.updated"&&typeof(t==null?void 0:t.status)=="string"?t.status:e.action==="issue.checked_out"?"in_progress":e.action==="issue.released"?"done":null}function LPn({evt:e}){const t=RPn(e);return i.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center","aria-hidden":"true",children:t?i.jsx(ni,{status:t,className:"h-4 w-4"}):i.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground/45"})})}function zPn({evt:e,agentMap:t,currentBoardUserId:n,operatorDisplayName:r}){const s=DPn({evt:e,agentMap:t,currentBoardUserId:n,operatorDisplayName:r}),a=EPn(e,t,n),o=Ti(e.createdAt);return i.jsxs("div",{"data-testid":"issue-activity-row",className:"grid min-h-8 grid-cols-[16px_minmax(0,1fr)] items-center gap-2 rounded-sm border border-transparent py-1 pl-3 pr-2 text-xs text-muted-foreground",children:[i.jsx(LPn,{evt:e}),i.jsxs("span",{"data-testid":"issue-activity-summary",className:"flex min-w-0 items-center gap-1.5 whitespace-nowrap leading-5",children:[i.jsx("span",{className:"max-w-[9rem] shrink-0 truncate font-medium text-foreground",children:s}),i.jsxs("span",{className:"min-w-0 truncate",children:[" ",a]}),i.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground/90",children:[" · ",o]})]})]})}function $Pn({data:e}){var A,h,g;const t=e.latestIssue,n=e.link,r=(t==null?void 0:t.identifier)??n.linearIdentifier,s=(t==null?void 0:t.title)??n.linearTitle,a=(t==null?void 0:t.url)??n.linearUrl,o=((A=t==null?void 0:t.description)==null?void 0:A.trim())??"",l=(t==null?void 0:t.team.name)??n.teamName,c=(t==null?void 0:t.state.name)??n.stateName,d=((h=t==null?void 0:t.project)==null?void 0:h.name)??n.projectName,u=((g=t==null?void 0:t.assignee)==null?void 0:g.name)??null,f=(t==null?void 0:t.updatedAt)??n.updatedAt;return i.jsxs("section",{className:"rounded-lg border border-border bg-card/70 p-3 text-sm","data-testid":"issue-activity-linear-link",children:[i.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0 space-y-1",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx("span",{className:"text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground",children:"Linked Linear issue"}),i.jsx("span",{className:"rounded-full border border-border bg-muted/40 px-2 py-0.5 font-mono text-[11px] text-muted-foreground",children:r})]}),i.jsx("div",{className:"font-medium text-foreground",children:s}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11px] text-muted-foreground",children:[i.jsx("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:l}),i.jsx("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:c}),d?i.jsx("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:d}):null,u?i.jsx("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:u}):null,i.jsxs("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:["Updated ",Ti(f)]}),i.jsxs("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:["Imported ",Ti(n.importedAt)]})]})]}),i.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",className:"inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:["Open in Linear",i.jsx(La,{className:"h-3 w-3"})]})]}),e.staleReason?i.jsx("div",{className:"mt-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-2 py-1.5 text-xs text-amber-700 dark:text-amber-200",children:e.staleReason}):null,o?i.jsx("p",{className:"mt-3 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:o}):null]})}function FPn(e){var n,r;if((n=e.title)!=null&&n.trim())return e.title.trim();const t=((r=e.issueLinks)==null?void 0:r[0])??null;return t?`${t.issueIdentifier??t.issueId.slice(0,8)} / ${t.key}`:`Document ${e.id.slice(0,8)}`}function J9e({kind:e}){const t=e==="folder"?ho:Fi;return i.jsx("span",{"aria-hidden":"true","data-testid":"linked-library-resource-icon","data-kind":e,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border bg-muted/35 text-muted-foreground",children:i.jsx(t,{className:"h-4 w-4"})})}function BPn({issue:e,libraryDocuments:t,libraryFiles:n}){const{locale:r}=as(),s=new Set(Rxt(e.description??"")),a=new Set(Lxt(e.description??"")),o=new Set(zxt(e.description??"")),l=new Map((t??[]).map(h=>[h.id,h])),c=new Map((n??[]).map(h=>[h.path,h])),d=new Map,u=new Map;for(const h of s){const g=l.get(h);g&&d.set(g.id,g)}for(const h of a){const g=c.get(h)??{name:h.split("/").pop()||h,path:h,isDirectory:!1};u.set(g.path,g)}for(const h of o){const g=c.get(h)??{name:h.split("/").pop()||h,path:h,isDirectory:!0};u.set(g.path,g)}const f=[...d.values()].sort((h,g)=>new Date(g.updatedAt).getTime()-new Date(h.updatedAt).getTime()),A=[...u.values()].sort((h,g)=>h.path.localeCompare(g.path));return f.length===0&&A.length===0?null:i.jsxs("section",{className:"space-y-3","aria-label":ji("linkedLibrary",r),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Fi,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),i.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:ji("library",r)}),i.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[11px] text-muted-foreground",children:f.length+A.length})]}),i.jsxs("div",{className:"grid gap-2",children:[A.map(h=>i.jsxs(an,{to:h.isDirectory?`/library?directory=${encodeURIComponent(h.path)}`:`/library?path=${encodeURIComponent(h.path)}`,className:"flex items-center justify-between gap-3 rounded-lg border border-border bg-background/70 px-3 py-2 text-sm transition-colors hover:bg-accent/35",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[i.jsx(J9e,{kind:h.isDirectory?"folder":"file"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"truncate font-medium text-foreground",children:h.name}),i.jsxs("div",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:[h.isDirectory?ji("liveLibraryFolder",r):ji("liveLibraryFile",r)," / ",h.path]})]})]}),i.jsx("span",{className:"shrink-0 rounded-full border border-border px-2 py-0.5 text-[11px] text-muted-foreground",children:h.isDirectory?"folder":"file"})]},h.path)),f.map(h=>{var y;const g=FPn(h),x=((y=h.issueLinks)==null?void 0:y[0])??null;return i.jsxs(an,{to:`/library?doc=${encodeURIComponent(h.id)}`,className:"flex items-center justify-between gap-3 rounded-lg border border-border bg-background/70 px-3 py-2 text-sm transition-colors hover:bg-accent/35",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[i.jsx(J9e,{kind:"doc"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"truncate font-medium text-foreground",children:g}),i.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground",children:[i.jsx("span",{children:ji("liveLibraryLink",r)}),x?i.jsxs(i.Fragment,{children:[i.jsx("span",{"aria-hidden":"true",children:"/"}),i.jsxs("span",{className:"truncate",children:["migrated from ",x.issueIdentifier??x.issueId.slice(0,8),":",x.key]})]}):null]})]})]}),i.jsxs("span",{className:"shrink-0 rounded-full border border-border px-2 py-0.5 text-[11px] text-muted-foreground",children:["r",h.latestRevisionNumber]})]},h.id)})]})]})}function eje({summary:e}){return!e.hasCost&&!e.hasTokens?null:i.jsxs("section",{className:"rounded-lg border border-border bg-background/80 p-3",children:[i.jsx("div",{className:"mb-2 text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:"Cost"}),i.jsxs("div",{className:"space-y-1.5 text-xs text-muted-foreground tabular-nums",children:[e.hasCost?i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Spend"}),i.jsxs("span",{className:"font-medium text-foreground",children:["$",e.cost.toFixed(4)]})]}):null,e.hasTokens?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Total tokens"}),i.jsx("span",{className:"font-medium text-foreground",children:Yr(e.totalTokens)})]}),i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Input"}),i.jsx("span",{children:Yr(e.input)})]}),i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Output"}),i.jsx("span",{children:Yr(e.output)})]}),e.cached>0?i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Cached"}),i.jsx("span",{children:Yr(e.cached)})]}):null]}):null]})]})}function $U({embeddedIssueId:e=null,embedded:t=!1}={}){var An,en,dr;const n=Qo(),r=e??n.issueId,{organizations:s,selectedOrganizationId:a,selectedOrganization:o}=Nr(),{setBreadcrumbs:l}=ea(),c=Wn(),d=Hr(),u=br(),f=vQe(),{pushToast:A}=As(),{openImagePreview:h}=OM(),{confirm:g}=ri(),{locale:x}=as(),y=DE(),w=rl(u.pathname).startsWith("/messenger/issues")?"/messenger/issues":"/issues",[k,O]=m.useState(!1),[j,C]=m.useState(!1),[N,I]=m.useState(!1),[E,_]=m.useState(null),[T,R]=m.useState(!1),[M,L]=m.useState(""),[U,B]=m.useState(!1),[z,H]=m.useState(""),[J,F]=m.useState(null),[Q,W]=m.useState(null),[$,ee]=m.useState(null),[re,ne]=m.useState(!1),[te,ce]=m.useState(!1),[se,he]=m.useState(!1),we=m.useRef(null),Ue=vs("rudder:issue-detail-main"),je=m.useCallback(Ve=>{we.current=Ve,Ue(Ve)},[Ue]),ke=m.useRef(null),Se=m.useRef(null),{data:oe,isLoading:fe,error:Ie}=Te({queryKey:V.issues.detail(r),queryFn:()=>fr.get(r),enabled:!!r}),ue=(oe==null?void 0:oe.orgId)??a??null,{followedIssueIds:be,isLoading:at,toggleFollowIssue:ve}=x1e(ue),me=oe?be.has(oe.id):!1,ye=se||at||!oe,qe=(oe==null?void 0:oe.orgId)??a;m.useEffect(()=>{!(oe!=null&&oe.orgId)||!oe.id||y1e(oe.orgId,oe.id,tk(oe.orgId))},[oe==null?void 0:oe.id,oe==null?void 0:oe.orgId]);const{data:Ce}=Te({queryKey:V.issues.comments(r),queryFn:()=>fr.listComments(r),enabled:!!r}),{data:X}=Te({queryKey:V.issues.activity(r),queryFn:()=>i2.forIssue(r),enabled:!!r}),{data:G}=Te({queryKey:V.issues.runs(r),queryFn:()=>i2.runsForIssue(r),enabled:!!r,refetchInterval:5e3}),{data:Ae}=Te({queryKey:V.issues.attachments(r),queryFn:()=>fr.listAttachments(r),enabled:!!r}),{data:Je}=Te({queryKey:V.issues.liveRuns(r),queryFn:()=>So.liveRunsForIssue(r),enabled:!!r,refetchInterval:3e3}),{data:ht}=Te({queryKey:V.issues.activeRun(r),queryFn:()=>So.activeRunForIssue(r),enabled:!!r,refetchInterval:3e3}),De=(Je??[]).length>0||!!ht,ft=m.useMemo(()=>dPn(u.state)??(w==="/messenger/issues"?{label:"Messenger",href:"/messenger"}:{label:"Issues",href:"/issues"}),[w,u.state]),dt=(oe==null?void 0:oe.ancestors)??mPn,yt=oe!=null&&oe.parentId?dt[0]??null:null,Mt=m.useMemo(()=>pPn({sourceBreadcrumb:ft,issue:oe,issueId:r}),[dt,oe==null?void 0:oe.id,oe==null?void 0:oe.identifier,oe==null?void 0:oe.title,r,ft]),Xe=m.useMemo(()=>{const Ve=new Set;for(const Vt of Je??[])Ve.add(Vt.id);return ht&&Ve.add(ht.id),Ve.size===0?G??[]:(G??[]).filter(Vt=>!Ve.has(Vt.runId))},[G,Je,ht]),{data:At}=Te({queryKey:V.issues.list(qe??"__none__"),queryFn:()=>fr.list(qe),enabled:!!qe}),{data:it}=Te({queryKey:V.organizations.libraryDocuments(qe??"__none__"),queryFn:()=>En.listLibraryDocuments(qe),enabled:!!qe}),Ee=(E==null?void 0:E.trim())??"",{data:mt}=Te({queryKey:["organizations",qe??"__none__","workspace-mention-files",Ee],queryFn:()=>En.listWorkspaceMentionFiles(qe,{query:Ee,limit:Ee?50:200}),enabled:!!qe}),{data:ot=[]}=Te({queryKey:V.issues.children(qe??"__none__",(oe==null?void 0:oe.id)??"__none__"),queryFn:()=>fr.list(qe,{parentId:oe.id}),enabled:!!qe&&!!(oe!=null&&oe.id)}),{data:xe}=Te({queryKey:V.agents.list(qe??"__none__"),queryFn:()=>_n.list(qe),enabled:!!qe}),{data:Ne}=Te({queryKey:V.organizationSkills.list(qe??"__none__"),queryFn:()=>Zu.list(qe),enabled:!!qe&&!!(oe!=null&&oe.assigneeAgentId)}),{data:We}=Te({queryKey:V.agents.skills((oe==null?void 0:oe.assigneeAgentId)??"__none__"),queryFn:()=>_n.skills(oe.assigneeAgentId,qe),enabled:!!qe&&!!(oe!=null&&oe.assigneeAgentId)}),{data:ze}=Te({queryKey:V.auth.session,queryFn:()=>el.getSession()}),{data:Ye}=Te({queryKey:V.projects.list(qe??"__none__"),queryFn:()=>Ii.list(qe),enabled:!!qe}),{data:_e}=Te({queryKey:V.access.currentBoardAccess,queryFn:()=>dc.getCurrentBoardAccess(),enabled:!!r}),Le=((An=ze==null?void 0:ze.user)==null?void 0:An.id)??((en=ze==null?void 0:ze.session)==null?void 0:en.userId)??null,Pe=((dr=_e==null?void 0:_e.user)==null?void 0:dr.id)??(_e==null?void 0:_e.userId)??Le,vt=(s??[]).find(Ve=>Ve.id===qe)??o,{orderedProjects:Be}=FM({projects:Ye??[],orgId:qe,userId:Le}),{slots:ut}=u9({slotTypes:["detailTab"],entityType:"issue",enabled:!!qe}),Et=m.useMemo(()=>ut.filter(Ve=>!Y9e(Ve)).map(Ve=>({value:`plugin:${Ve.pluginKey}:${Ve.id}`,label:Ve.displayName,slot:Ve})),[ut]),Zt=ut.find(Ve=>Y9e(Ve))??null,{data:Nn}=Te({queryKey:["plugins",Xat,G9e,qe??"__none__",(oe==null?void 0:oe.id)??r??"__none__",(Zt==null?void 0:Zt.pluginId)??"__none__"],queryFn:async()=>(await Ya.bridgeGetData(Zt.pluginId,G9e,{orgId:qe,issueId:oe.id},qe)).data,enabled:!!(qe&&(oe!=null&&oe.id)&&(Zt!=null&&Zt.pluginId))}),zn=m.useMemo(()=>{const Ve=new Map;for(const Vt of xe??[])Ve.set(Vt.id,Vt);return Ve},[xe]),Ze=m.useMemo(()=>new Map((Ye??[]).map(Ve=>[Ve.id,Ve])),[Ye]),Qt=oe!=null&&oe.assigneeAgentId?zn.get(oe.assigneeAgentId)??null:null,He=m.useMemo(()=>o9({agent:Qt,orgUrlKey:(vt==null?void 0:vt.urlKey)??"organization",organizationSkills:Ne,skillSnapshot:We}),[Ne,We,Qt,vt==null?void 0:vt.urlKey]),Rt=m.useMemo(()=>{var Qn,Gr;const Ve=[],Vt=[...xe??[]].filter(Cn=>Cn.status!=="terminated").sort((Cn,yr)=>Cn.name.localeCompare(yr.name));for(const Cn of Vt)Ve.push({id:`agent:${Cn.id}`,name:Qu(Cn),kind:"agent",agentId:Cn.id,agentIcon:Cn.icon,agentRole:Cn.role});for(const Cn of Be)Ve.push({id:`project:${Cn.id}`,name:Cn.name,kind:"project",projectId:Cn.id,projectColor:Cn.color,projectIcon:Cn.icon});for(const Cn of At??[]){if(Cn.id===(oe==null?void 0:oe.id))continue;const yr=Cn.projectId?Ze.get(Cn.projectId)??Cn.project??null:Cn.project??null,qn=Cn.assigneeAgentId?zn.get(Cn.assigneeAgentId)??null:null,mi=Cn.assigneeAgentId?(qn==null?void 0:qn.name)??Cn.assigneeAgentId.slice(0,8):MA(Cn.assigneeUserId,Le);Ve.push({id:`issue:${Cn.id}`,name:Cn.identifier?`${Cn.identifier} ${Cn.title}`:Cn.title,kind:"issue",searchText:[Cn.identifier,Cn.title,Cn.status,yr==null?void 0:yr.name,mi].filter(Boolean).join(" "),issueId:Cn.id,issueIdentifier:Cn.identifier,issueStatus:Cn.status,issueProjectName:(yr==null?void 0:yr.name)??null,issueProjectColor:(yr==null?void 0:yr.color)??null,issueProjectIcon:(yr==null?void 0:yr.icon)??null,issueAssigneeName:mi,issueAssigneeIcon:(qn==null?void 0:qn.icon)??null,issueAssigneeRole:(qn==null?void 0:qn.role)??null})}for(const Cn of it??[]){const yr=((Qn=Cn.issueLinks)==null?void 0:Qn[0])??null,qn=((Gr=Cn.title)==null?void 0:Gr.trim())||(yr?`${yr.issueIdentifier??yr.issueId.slice(0,8)} / ${yr.key}`:Cn.id.slice(0,8));Ve.push({id:`library-doc:${Cn.id}`,name:qn,kind:"library_doc",searchText:[qn,...(Cn.issueLinks??[]).flatMap(mi=>[mi.issueIdentifier,mi.issueTitle,mi.key])].filter(Boolean).join(" "),libraryDocumentId:Cn.id,libraryDocumentTitle:qn,libraryDocumentUpdatedAt:Cn.updatedAt,libraryDocumentPath:yr?`Migrated issue doc ${yr.issueIdentifier??yr.issueId.slice(0,8)}:${yr.key}`:"Doc"})}for(const Cn of(mt==null?void 0:mt.entries)??[])Ve.push({id:Cn.isDirectory?`library-directory:${Cn.path}`:`library-file:${Cn.path}`,name:Cn.displayLabel??Cn.name,kind:Cn.isDirectory?"library_directory":"library_file",searchText:`${Cn.name} ${Cn.path}`,libraryFilePath:Cn.isDirectory?null:Cn.path,libraryEntryId:Cn.isDirectory?null:Cn.libraryEntryId??null,libraryDirectoryPath:Cn.isDirectory?Cn.path:null});return Ve.push(...He),Ve},[zn,xe,At,Le,oe==null?void 0:oe.id,it,mt==null?void 0:mt.entries,Be,Ze,He]),In=m.useMemo(()=>[...ot].sort((Ve,Vt)=>new Date(Ve.createdAt).getTime()-new Date(Vt.createdAt).getTime()),[ot]),Zn=m.useMemo(()=>new Map((At??[]).map(Ve=>[Ve.id,Ve])),[At]),Xr=m.useMemo(()=>{if(!oe)return[];const Ve=z.trim().toLowerCase();return(At??[]).filter(Vt=>Vt.id!==oe.id).filter(Vt=>Vt.parentId!==oe.id).filter(Vt=>!(oe.ancestors??[]).some(Qn=>Qn.id===Vt.id)).filter(Vt=>Ve?`${Vt.identifier??""} ${Vt.title}`.toLowerCase().includes(Ve):!0).slice(0,12)},[At,z,oe]),qs=m.useMemo(()=>{const Ve=new Map,Vt=new Map;for(const Qn of G??[])Vt.set(Qn.runId,Qn.agentId);for(const Qn of X??[]){if(Qn.action!=="issue.comment_added"||!Qn.runId)continue;const Gr=Qn.details??{},Cn=typeof Gr.commentId=="string"?Gr.commentId:null;!Cn||Ve.has(Cn)||Ve.set(Cn,{runId:Qn.runId,runAgentId:Qn.agentId??Vt.get(Qn.runId)??null})}return(Ce??[]).map(Qn=>{const Gr=Ve.get(Qn.id);return Gr?{...Qn,...Gr}:Qn})},[X,Ce,G]),hr=m.useMemo(()=>{let Ve=0,Vt=0,Qn=0,Gr=0,Cn=!1,yr=!1;for(const qn of G??[]){const mi=nx(qn.usageJson),Na=nx(qn.resultJson),Ks=VC(mi,"inputTokens","input_tokens"),No=VC(mi,"outputTokens","output_tokens"),Pa=VC(mi,"cachedInputTokens","cached_input_tokens")+VC(mi,"cache_read_input_tokens")+VC(mi,"cache_creation_input_tokens"),ZA=Gc({provider:X9e(mi,"provider")??X9e(Na,"provider"),inputTokens:Ks,cachedInputTokens:Pa,outputTokens:No}),il=VRe(mi,Na);il>0&&(Cn=!0),Ks+No+Pa>0&&(yr=!0),Ve+=ZA.promptTokens,Vt+=No,Qn+=Pa,Gr+=il}return{input:Ve,output:Vt,cached:Qn,cost:Gr,totalTokens:Ve+Vt,hasCost:Cn,hasTokens:yr}},[G]),Fr=m.useMemo(()=>{var Vt;const Ve=[];Nn!=null&&Nn.linked&&Ve.push({id:"linear-linked-issue",createdAt:((Vt=Nn.latestIssue)==null?void 0:Vt.updatedAt)??Nn.link.updatedAt??Nn.link.importedAt,node:i.jsx($Pn,{data:Nn})});for(const Qn of X??[])OPn(Qn)&&Ve.push({id:Qn.id,createdAt:Qn.createdAt,node:i.jsx(zPn,{evt:Qn,agentMap:zn,currentBoardUserId:Pe,operatorDisplayName:y})});return Ve},[X,zn,Pe,Nn,y]),jt=()=>{const Ve=(oe==null?void 0:oe.orgId)??qe??a;c.invalidateQueries({queryKey:V.issues.detail(r)}),c.invalidateQueries({queryKey:V.issues.activity(r)}),c.invalidateQueries({queryKey:V.issues.runs(r)}),c.invalidateQueries({queryKey:V.issues.approvals(r)}),c.invalidateQueries({queryKey:V.issues.attachments(r)}),c.invalidateQueries({queryKey:V.issues.liveRuns(r)}),c.invalidateQueries({queryKey:V.issues.activeRun(r)}),oe!=null&&oe.id&&Ve&&c.invalidateQueries({queryKey:V.issues.children(Ve,oe.id)}),Ve&&(c.invalidateQueries({queryKey:V.issues.list(Ve)}),c.invalidateQueries({queryKey:V.issues.listTouchedByMe(Ve)}),c.invalidateQueries({queryKey:V.issues.listUnreadTouchedByMe(Ve)}),c.invalidateQueries({queryKey:V.sidebarBadges(Ve)}))},kt=pt({mutationFn:Ve=>fr.markRead(Ve),onSuccess:()=>{const Ve=(oe==null?void 0:oe.orgId)??qe??a;Ve&&(c.invalidateQueries({queryKey:V.issues.listTouchedByMe(Ve)}),c.invalidateQueries({queryKey:V.issues.listUnreadTouchedByMe(Ve)}),c.invalidateQueries({queryKey:V.sidebarBadges(Ve)}),vA(c,Ve))}}),nn=pt({mutationFn:Ve=>fr.update(r,Ve),onSuccess:Ve=>{c.setQueryData(V.issues.detail(r),Ve),c.setQueryData(V.issues.detail(Ve.id),Ve),Ve.identifier&&c.setQueryData(V.issues.detail(Ve.identifier),Ve),jt()}}),Ke=pt({mutationFn:()=>fr.remove(r),onSuccess:Ve=>{c.removeQueries({queryKey:V.issues.detail(r)}),c.removeQueries({queryKey:V.issues.detail(Ve.id)}),Ve.identifier&&c.removeQueries({queryKey:V.issues.detail(Ve.identifier)}),jt(),A({title:"Issue deleted",tone:"success"}),d("/issues/all")},onError:Ve=>{A({title:"Failed to delete issue",body:Ve instanceof Error?Ve.message:"Try again.",tone:"error"})}}),st=(oe==null?void 0:oe.identifier)??(oe!=null&&oe.id?oe.id.slice(0,8):r??"issue"),Ft=m.useCallback(async()=>{await g({title:`Delete ${st}?`,description:"This removes the issue from Rudder.",confirmLabel:"Delete",tone:"destructive"})&&(Ke.mutate(),O(!1))},[g,Ke,st]),Dn=pt({mutationFn:({childIssueId:Ve,status:Vt})=>fr.update(Ve,{status:Vt}),onMutate:({childIssueId:Ve})=>{W(Ve)},onSuccess:Ve=>{qe&&(oe!=null&&oe.id)&&c.setQueryData(V.issues.children(qe,oe.id),Vt=>(Vt==null?void 0:Vt.map(Qn=>Qn.id===Ve.id?{...Qn,...Ve}:Qn))??Vt),c.setQueryData(V.issues.detail(Ve.id),Ve),Ve.identifier&&c.setQueryData(V.issues.detail(Ve.identifier),Ve),qe&&(c.invalidateQueries({queryKey:V.issues.list(qe)}),c.invalidateQueries({queryKey:V.issues.listTouchedByMe(qe)}),c.invalidateQueries({queryKey:V.issues.listUnreadTouchedByMe(qe)}),c.invalidateQueries({queryKey:V.sidebarBadges(qe)}))},onError:Ve=>{A({title:"Failed to update sub-issue status",body:Ve instanceof Error?Ve.message:"Try again.",tone:"error"})},onSettled:(Ve,Vt,Qn)=>{F(Gr=>Gr===Qn.childIssueId?null:Gr),W(Gr=>Gr===Qn.childIssueId?null:Gr)}}),Rn=pt({mutationFn:({body:Ve,reopen:Vt})=>fr.addComment(r,Ve,Vt),onSuccess:()=>{jt(),c.invalidateQueries({queryKey:V.issues.comments(r)})}}),rt=pt({mutationFn:({commentId:Ve,body:Vt})=>fr.updateComment(r,Ve,Vt),onSuccess:Ve=>{c.setQueryData(V.issues.comment(r,Ve.id),Ve),jt(),c.invalidateQueries({queryKey:V.issues.comments(r)})}}),Yt=pt({mutationFn:Ve=>fr.deleteComment(r,Ve),onSuccess:Ve=>{c.setQueryData(V.issues.comment(r,Ve.id),Ve),jt(),c.invalidateQueries({queryKey:V.issues.comments(r)})}}),fn=pt({mutationFn:async({file:Ve,usage:Vt="issue"})=>{const Qn=(oe==null?void 0:oe.orgId)??qe??a;if(!Qn)throw new Error("No organization selected");return fr.uploadAttachment(Qn,r,Ve,{usage:Vt})},onSuccess:(Ve,Vt)=>{ee(null),(Vt.usage===void 0||Vt.usage==="issue")&&c.invalidateQueries({queryKey:V.issues.attachments(r)}),jt()},onError:Ve=>{ee(Ve instanceof Error?Ve.message:"Upload failed")}}),or=pt({mutationFn:async Ve=>{const Vt=(oe==null?void 0:oe.orgId)??qe??a;if(!Vt)throw new Error("No organization selected");return fr.attachWorkspaceFile(Vt,r,Ve)},onSuccess:()=>{ee(null),ce(!1),c.invalidateQueries({queryKey:V.issues.attachments(r)}),jt()},onError:Ve=>{ee(Ve instanceof Error?Ve.message:"Workspace attach failed")}}),xt=pt({mutationFn:Ve=>fr.deleteAttachment(Ve),onSuccess:()=>{ee(null),c.invalidateQueries({queryKey:V.issues.attachments(r)}),jt()},onError:Ve=>{ee(Ve instanceof Error?Ve.message:"Delete failed")}}),Xt=m.useCallback(()=>{if(!oe){A({title:"Issue is not ready",tone:"error"});return}d(hPn(oe))},[oe,d,A]),Fn=pt({mutationFn:async Ve=>{if(!oe)throw new Error("Issue is not ready");return fr.create(oe.orgId,{title:Ve,parentId:oe.id})},onSuccess:()=>{L(""),R(!1),jt()},onError:Ve=>{A({title:Ve instanceof Error?Ve.message:"Failed to create sub-issue",tone:"error"})}}),er=pt({mutationFn:async Ve=>{if(!oe)throw new Error("Issue is not ready");return fr.update(Ve.id,{parentId:oe.id})},onSuccess:(Ve,Vt)=>{B(!1),H(""),jt(),c.invalidateQueries({queryKey:V.issues.detail(Ve.id)}),Ve.identifier&&c.invalidateQueries({queryKey:V.issues.detail(Ve.identifier)}),oe!=null&&oe.orgId&&Vt.parentId&&c.invalidateQueries({queryKey:V.issues.children(oe.orgId,Vt.parentId)})},onError:Ve=>{A({title:Ve instanceof Error?Ve.message:"Failed to add existing issue",tone:"error"})}});m.useEffect(()=>{t||l(Mt.map((Ve,Vt)=>De&&Vt===Mt.length-1?{...Ve,label:`● ${Ve.label}`}:Ve))},[t,l,Mt,De]),m.useEffect(()=>{t||oe!=null&&oe.identifier&&r!==oe.identifier&&d(`${w}/${oe.identifier}`,{replace:!0,state:u.state})},[t,oe,r,w,d,u.state]),m.useLayoutEffect(()=>{if(t)return;const Ve=Vt=>{if(iQt(Vt)&&(Vt.preventDefault(),!(f!=null&&f()))){if(OQe()){d(-1);return}d(ft.href)}};return document.addEventListener("keydown",Ve,!0),()=>document.removeEventListener("keydown",Ve,!0)},[t,d,f,ft.href]),m.useEffect(()=>{t||oe!=null&&oe.id&&Se.current!==oe.id&&(Se.current=oe.id,kt.mutate(oe.id))},[t,oe==null?void 0:oe.id]);const zr=async()=>{oe&&(await navigator.clipboard.writeText(oe.identifier??oe.id),C(!0),A({title:"Copied issue ID",tone:"success"}),setTimeout(()=>C(!1),1500))},hs=async()=>{if(!oe||se||at)return;const Ve=!me;he(!0);try{await ve(oe.id),A({title:Ve?"Issue pinned":"Issue unpinned",tone:"success"})}catch(Vt){A({title:Ve?"Could not pin issue":"Could not unpin issue",body:Vt instanceof Error?Vt.message:void 0,tone:"error"})}finally{he(!1)}},to=async()=>{const Ve=M.trim();!Ve||Fn.isPending||await Fn.mutateAsync(Ve)};if(fe)return i.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."});if(Ie)return i.jsx("p",{className:"text-sm text-destructive",children:Ie.message});if(!oe)return null;const ns=async Ve=>{const Vt=Ve.target.files;if(!(!Vt||Vt.length===0)){for(const Qn of Array.from(Vt))await fn.mutateAsync({file:Qn,usage:"issue"});ke.current&&(ke.current.value="")}},ja=async Ve=>{Ve.preventDefault(),ne(!1);const Vt=Ve.dataTransfer.files;if(!(!Vt||Vt.length===0))for(const Qn of Array.from(Vt))await fn.mutateAsync({file:Qn,usage:"issue"})},Qi=Ve=>c9(Ve.contentType),Rr=Ve=>{const Vt=Ve.originalFilename??Ve.id;h({alt:Vt,name:Vt,src:Ve.contentPath,testId:"issue-attachment-image-preview-dialog",titleFallback:"Issue attachment preview"})},ta=Ae??[],Ca=ta.length>0,Uo=`${In.length}`,mo=fn.isPending||or.isPending,On=i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:ke,type:"file",accept:CPn,className:"hidden",onChange:ns,multiple:!0}),i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"quiet",size:"xs",disabled:mo,className:q("shadow-none",re&&"border-primary bg-primary/5"),title:mo?"Attaching":"Attach file",children:[mo?i.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(Wu,{className:"h-3.5 w-3.5"}),mo?"Attaching...":i.jsx("span",{className:"hidden sm:inline",children:"Attach"})]})}),i.jsxs(Di,{align:"end",className:"w-52",children:[i.jsxs(Gt,{onSelect:()=>{var Ve;(Ve=ke.current)==null||Ve.click()},children:[i.jsx(KS,{className:"h-4 w-4"}),"Upload from computer"]}),i.jsx(ko,{}),i.jsxs(Gt,{onSelect:()=>{ce(!0)},children:[i.jsx(ho,{className:"h-4 w-4"}),ji("attachFromLibrary",x)]})]})]})]}),Qe=[oe.id,oe.updatedAt,qs.length,Fr.length,In.length,ta.length].join(":"),It=({moreOpen:Ve,onMoreOpenChange:Vt,grouped:Qn=!1})=>i.jsxs("div",{className:q("flex items-center gap-1 shrink-0",Qn&&"rounded-full border border-border bg-background/80 p-1"),children:[i.jsxs(ie,{variant:"ghost",size:"sm",className:q("h-7 px-2 text-xs",Qn&&"rounded-full"),onClick:zr,title:`Copy ${st}`,children:[j?i.jsx(Zi,{className:"mr-1.5 h-3.5 w-3.5"}):i.jsx(sl,{className:"mr-1.5 h-3.5 w-3.5"}),j?"Copied":"Copy ID"]}),i.jsxs(ie,{variant:"ghost",size:"sm",className:q("h-7 px-2 text-xs",Qn&&"rounded-full"),onClick:Xt,children:[i.jsx(ka,{className:"mr-1.5 h-3.5 w-3.5"}),"Chat"]}),i.jsxs(es,{open:Ve,onOpenChange:Vt,children:[i.jsx(bs,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"sm",className:q("h-7 w-7 px-0 shrink-0",Qn&&"rounded-full"),"aria-label":"More issue actions",children:i.jsx(xl,{className:"h-4 w-4"})})}),i.jsxs(ts,{className:"w-48 p-1",align:"end",children:[i.jsxs("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-foreground hover:bg-accent/50 disabled:cursor-not-allowed disabled:opacity-60",onClick:()=>{hs(),Vt(!1)},disabled:ye,children:[se||at?i.jsx(yn,{className:"h-3 w-3 animate-spin"}):me?i.jsx(P3,{className:"h-3 w-3"}):i.jsx(Ih,{className:"h-3 w-3"}),at?"Loading pin state":me?"Unpin Issue":"Pin Issue"]}),i.jsx("div",{className:"my-1 h-px bg-border","aria-hidden":"true"}),i.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-destructive disabled:cursor-not-allowed disabled:opacity-60",onClick:()=>{Ft()},disabled:Ke.isPending,children:[Ke.isPending?i.jsx(yn,{className:"h-3 w-3 animate-spin"}):i.jsx(fi,{className:"h-3 w-3"}),"Delete Issue"]})]})]})]});return i.jsxs("div",{ref:je,"data-testid":t?"embedded-issue-detail":"issue-detail-main-scroll",className:"issue-detail-container h-full min-h-0 w-full scrollbar-auto-hide overflow-x-hidden overflow-y-auto overscroll-contain",children:[i.jsx(Vat,{rootRef:we,refreshKey:Qe}),i.jsxs("div",{className:"issue-detail-layout mx-auto min-h-full max-w-6xl","data-testid":"issue-detail-layout",children:[i.jsxs("section",{className:"issue-detail-heading min-w-0 space-y-3","data-testid":"issue-detail-heading","aria-label":"Issue identity and context",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[De&&i.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-cyan-500/10 border border-cyan-500/30 px-2 py-0.5 text-[10px] font-medium text-cyan-600 dark:text-cyan-400 shrink-0",children:[i.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[i.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-cyan-400 opacity-75"}),i.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cyan-400"})]}),"Live"]}),oe.originKind==="automation_execution"&&oe.originId&&i.jsxs(an,{to:`/automations/${oe.originId}`,className:"inline-flex items-center gap-1 rounded-full bg-violet-500/10 border border-violet-500/30 px-2 py-0.5 text-[10px] font-medium text-violet-600 dark:text-violet-400 shrink-0 hover:bg-violet-500/20 transition-colors",children:[i.jsx(y6,{className:"h-3 w-3"}),"Automation"]})]}),i.jsxs("div",{className:"flex items-center gap-0.5 md:hidden shrink-0",children:[i.jsx(ie,{variant:"ghost",size:"icon-xs",onClick:zr,title:"Copy issue ID",children:j?i.jsx(Zi,{className:"h-4 w-4"}):i.jsx(sl,{className:"h-4 w-4"})}),i.jsx(ie,{variant:"ghost",size:"icon-xs",onClick:Xt,title:"Open in chat",children:i.jsx(ka,{className:"h-4 w-4"})}),i.jsx(ie,{variant:"ghost",size:"icon-xs",onClick:()=>I(!0),title:"Properties",children:i.jsx(mM,{className:"h-4 w-4"})})]})]}),i.jsx(Em,{value:oe.title,onSave:Ve=>nn.mutateAsync({title:Ve}),as:"h2",className:"text-xl font-bold"}),i.jsx(iPn,{parentIssue:yt})]}),i.jsxs("aside",{className:"issue-detail-rail min-w-0",children:[i.jsx("div",{className:"issue-detail-actions min-w-0 items-center justify-end","data-testid":"issue-detail-actions",children:It({moreOpen:k,onMoreOpenChange:O,grouped:!0})}),i.jsx("div",{className:"issue-detail-properties min-w-0","data-testid":"issue-detail-sidebar",children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("section",{"aria-label":"Issue properties",className:"issue-detail-properties-panel rounded-lg border border-border bg-background/80 p-3",children:[i.jsx("div",{className:"mb-3 flex items-center justify-between gap-2",children:i.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:"Properties"})}),i.jsx(xU,{issue:oe,onUpdate:Ve=>nn.mutate(Ve),childIssues:In})]}),i.jsx(eje,{summary:hr})]})})]}),i.jsxs("div",{className:"issue-detail-body min-w-0 space-y-6","data-testid":"issue-detail-primary-content",children:[i.jsx(Em,{value:oe.description??"",onSave:Ve=>nn.mutateAsync({description:Ve}),as:"p",className:"text-[15px] leading-7 text-foreground",placeholder:"Add a description...",multiline:!0,editorEngine:"milkdown",alwaysEdit:!0,variant:"issue-description",mentions:Rt,onMentionQueryChange:_,imageUploadHandler:async Ve=>(await fn.mutateAsync({file:Ve,usage:"description_inline"})).contentPath}),i.jsx(C2,{slotTypes:["toolbarButton","contextMenuItem"],entityType:"issue",context:{orgId:oe.orgId,projectId:oe.projectId??null,entityId:oe.id,entityType:"issue"},className:"flex flex-wrap gap-2",itemClassName:"inline-flex",missingBehavior:"placeholder"}),i.jsx(p1e,{placementZones:["toolbarButton"],entityType:"issue",context:{orgId:oe.orgId,projectId:oe.projectId??null,entityId:oe.id,entityType:"issue"},className:"flex flex-wrap gap-2",itemClassName:"inline-flex"}),i.jsx(C2,{slotTypes:["taskDetailView"],entityType:"issue",context:{orgId:oe.orgId,projectId:oe.projectId??null,entityId:oe.id,entityType:"issue"},className:"space-y-3",itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"}),i.jsxs("section",{"aria-label":"Sub-issues",className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-foreground",children:[i.jsx(Dw,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:"Sub-issues"})]}),i.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[11px] text-muted-foreground",children:Uo})]}),i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",className:"h-8 gap-1.5 px-2.5 text-xs",disabled:Fn.isPending||er.isPending,children:[i.jsx(Ur,{className:"h-3.5 w-3.5"}),"Add sub-issue"]})}),i.jsxs(Di,{align:"end",children:[i.jsx(Gt,{onSelect:()=>{B(!1),R(!0),L("")},children:"Create new sub-issue"}),i.jsx(Gt,{onSelect:()=>{R(!1),L(""),B(!0)},children:"Add existing issue"})]})]})]}),T?i.jsxs("div",{className:"rounded-lg border border-border bg-background/80 p-2.5",children:[i.jsxs("form",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",onSubmit:Ve=>{Ve.preventDefault(),to()},children:[i.jsx(Vn,{value:M,onChange:Ve=>L(Ve.target.value),onKeyDown:Ve=>{Ve.key==="Escape"&&(Ve.preventDefault(),R(!1),L(""))},placeholder:"Add sub-issue title",autoFocus:!0,disabled:Fn.isPending,className:"h-9 text-sm"}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i.jsx(ie,{type:"submit",size:"sm",className:"h-8 px-3 text-xs",disabled:!M.trim()||Fn.isPending,children:"Create"}),i.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2.5 text-xs",onClick:()=>{R(!1),L("")},disabled:Fn.isPending,children:"Cancel"})]})]}),Fn.error instanceof Error?i.jsx("p",{className:"mt-2 text-xs text-destructive",children:Fn.error.message}):null]}):null,U?i.jsxs("div",{className:"rounded-lg border border-border bg-background/80 p-2.5",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 pb-2",children:[i.jsx(Vn,{value:z,onChange:Ve=>H(Ve.target.value),placeholder:"Search existing issues",autoFocus:!0,disabled:er.isPending,className:"h-8 text-sm"}),i.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2.5 text-xs",onClick:()=>{B(!1),H("")},disabled:er.isPending,children:"Cancel"})]}),i.jsx("div",{className:"max-h-64 overflow-y-auto pt-2",children:Xr.length===0?i.jsx("p",{className:"px-1 py-2 text-xs text-muted-foreground",children:"No matching issues."}):Xr.map(Ve=>{const Vt=Ve.identifier??Ve.id.slice(0,8),Qn=Ve.parentId?Zn.get(Ve.parentId)??null:null,Gr=Ve.projectId?Ze.get(Ve.projectId)??Ve.project??null:Ve.project??null,Cn=Qn?`Move from ${Qn.identifier??Qn.id.slice(0,8)}`:Gr&&Ve.projectId!==oe.projectId?Gr.name:"No parent";return i.jsxs("button",{type:"button",className:"grid w-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 rounded-md px-2 py-2 text-left text-sm transition-colors hover:bg-accent/40 disabled:cursor-wait disabled:opacity-60",onClick:()=>er.mutate(Ve),disabled:er.isPending,children:[i.jsx(ni,{status:Ve.status}),i.jsx("span",{className:"min-w-0 truncate",children:Ve.title}),i.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:Vt}),i.jsx("span",{className:"col-start-2 min-w-0 truncate text-xs text-muted-foreground",children:Cn})]},Ve.id)})})]}):null,In.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:"No sub-issues."}):i.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:In.map(Ve=>{var Cn,yr,qn,mi;const Vt=Ve.identifier??Ve.id,Qn=J===Ve.id,Gr=Q===Ve.id;return i.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2 text-sm transition-colors hover:bg-accent/20 last:border-b-0",children:[i.jsxs(es,{open:Qn,onOpenChange:Na=>{F(Na?Ve.id:null)},children:[i.jsx(bs,{asChild:!0,children:i.jsxs("button",{type:"button","aria-label":`Change status for ${Ve.title}`,className:"inline-flex shrink-0 items-center gap-2 rounded-md p-1 text-left transition-colors hover:bg-accent/50 disabled:cursor-wait disabled:opacity-60",disabled:Gr,children:[i.jsx(ni,{status:Ve.status}),i.jsx(ql,{priority:Ve.priority})]})}),i.jsx(ts,{className:"w-40 p-1",align:"start",children:jPn.map(Na=>i.jsxs(ie,{variant:"ghost",size:"sm",className:q("w-full justify-start gap-2 text-xs",Na===Ve.status&&"bg-accent"),onClick:()=>{Dn.mutate({childIssueId:Ve.id,status:Na})},children:[i.jsx(ni,{status:Na}),H$(Na)]},Na))})]}),i.jsxs(an,{to:`/issues/${Vt}`,state:u.state,className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i.jsx("span",{className:"max-w-28 shrink truncate font-mono text-xs text-muted-foreground",children:Vt}),i.jsx("span",{className:"truncate",children:Ve.title})]}),i.jsx("div",{className:"shrink-0",children:Ve.assigneeAgentId?(Cn=zn.get(Ve.assigneeAgentId))!=null&&Cn.name?i.jsx(uu,{name:((yr=zn.get(Ve.assigneeAgentId))==null?void 0:yr.name)??Ve.assigneeAgentId.slice(0,8),icon:(qn=zn.get(Ve.assigneeAgentId))==null?void 0:qn.icon,role:(mi=zn.get(Ve.assigneeAgentId))==null?void 0:mi.role,size:"sm"}):i.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:Ve.assigneeAgentId.slice(0,8)}):Ve.assigneeUserId?i.jsx(Jd,{name:sZ("user",Ve.assigneeUserId,Pe,y),size:"sm"}):null})]})]},Ve.id)})})]}),i.jsx(BPn,{issue:oe,libraryDocuments:it,libraryFiles:mt==null?void 0:mt.entries}),Ca?null:i.jsx("div",{className:"flex items-center justify-end gap-2 min-w-0",children:On}),Ca?i.jsxs("div",{className:q("space-y-3 rounded-lg transition-colors"),onDragEnter:Ve=>{Ve.preventDefault(),ne(!0)},onDragOver:Ve=>{Ve.preventDefault(),ne(!0)},onDragLeave:Ve=>{Ve.currentTarget.contains(Ve.relatedTarget)||ne(!1)},onDrop:Ve=>void ja(Ve),children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Attachments"}),On]}),$&&i.jsx("p",{className:"text-xs text-destructive",children:$}),i.jsx("div",{className:"space-y-2",children:ta.map(Ve=>{const Vt=Ve.originalFilename??Ve.id,Qn=Qi(Ve);return i.jsxs("div",{className:"rounded-md border border-border p-2",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Qn?i.jsx("button",{type:"button",className:"truncate text-left text-xs hover:underline",title:Vt,onClick:()=>Rr(Ve),children:Vt}):i.jsx("a",{href:Ve.contentPath,target:"_blank",rel:"noreferrer",className:"truncate text-xs hover:underline",title:Vt,children:Vt}),i.jsx("button",{type:"button",className:"text-muted-foreground hover:text-destructive",onClick:()=>xt.mutate(Ve.id),disabled:xt.isPending,title:"Delete attachment",children:i.jsx(fi,{className:"h-3.5 w-3.5"})})]}),i.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[Ve.contentType," · ",(Ve.byteSize/1024).toFixed(1)," KB"]}),Qn&&i.jsx(H2,{src:Ve.contentPath,alt:Vt,name:Vt,className:"max-h-56 object-contain bg-accent/10",loading:"lazy",previewTestId:"issue-attachment-image-preview-dialog",previewTitleFallback:"Issue attachment preview",triggerClassName:"max-h-56 overflow-hidden rounded border border-border",wrapperClassName:"mt-2"})]},Ve.id)})})]}):null,i.jsx(Nh,{}),i.jsxs("section",{"aria-label":"Activity",className:"flex flex-col space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[i.jsx(wq,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:"Activity"})]}),i.jsx(qst,{comments:qs,linkedRuns:Xe,activityItems:Fr,orgId:oe.orgId,projectId:oe.projectId,issueStatus:oe.status,agentMap:zn,draftKey:`rudder:issue-comment-draft:${oe.id}`,mentions:Rt,onMentionQueryChange:_,operatorDisplayName:y,currentUserId:Pe,hideHeading:!0,emptyMessage:"No activity yet.",escapeBackWhenEmpty:!0,fixedComposer:!0,fixedComposerTimelineScroll:!1,timelineScrollElementRef:we,onAdd:async(Ve,Vt)=>{await Rn.mutateAsync({body:Ve,reopen:Vt})},onUpdate:async(Ve,Vt)=>{await rt.mutateAsync({commentId:Ve,body:Vt})},onDelete:async Ve=>{await Yt.mutateAsync(Ve)},imageUploadHandler:async Ve=>(await fn.mutateAsync({file:Ve,usage:"comment_inline"})).contentPath,onAttachImage:async Ve=>{await fn.mutateAsync({file:Ve,usage:"comment_attachment"})},liveRunSlot:i.jsx(Iat,{issueId:r,orgId:oe.orgId})})]}),Et.length>0?i.jsx("div",{className:"space-y-3",children:Et.map(Ve=>i.jsxs("section",{className:"space-y-2",children:[i.jsx("h3",{className:"text-sm font-semibold",children:Ve.label}),i.jsx(f9,{slot:Ve.slot,context:{orgId:oe.orgId,orgPrefix:vt?hc(vt):null,projectId:oe.projectId??null,entityId:oe.id,entityType:"issue"},missingBehavior:"placeholder"})]},Ve.value))}):null]})]}),i.jsx(EU,{open:N,onOpenChange:I,children:i.jsxs(DU,{side:"bottom",className:"max-h-[85dvh] pb-[env(safe-area-inset-bottom)]",children:[i.jsx(RU,{children:i.jsx(LU,{className:"text-sm",children:"Properties"})}),i.jsx(m1e,{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"space-y-3 px-4 pb-4",children:[i.jsx(xU,{issue:oe,onUpdate:Ve=>nn.mutate(Ve),inline:!0,childIssues:In}),i.jsx(eje,{summary:hr})]})})]})}),i.jsx(qat,{}),i.jsx(TPn,{orgId:oe.orgId??qe??a,open:te,onOpenChange:ce,onAttach:Ve=>or.mutateAsync(Ve).then(()=>{}).catch(()=>{}),attaching:or.isPending,error:$})]})}const QPn=new Set([".avif",".bmp",".gif",".ico",".jpeg",".jpg",".png",".svg",".webp"]),UPn=new Set([".md",".markdown",".mdown",".mdx",".txt",".text"]),_ee="application/x-rudder-side-panel-tab",Mee="This file changed while you were editing it.";function VPn(e){if(typeof e!="string")return null;const t=e.trim();if(!t||t.length>J_)return null;if(/^data:image\/[a-z0-9.+-]+(?:;[^,]*)?,/i.test(t))return t;try{const n=new URL(t);return n.protocol==="http:"||n.protocol==="https:"?t:null}catch{return null}}function qPn({favicon:e,url:t}){var o;const n=VPn(e),r=(o=qO(t))==null?void 0:o.darkMode,[s,a]=m.useState(!1);return m.useEffect(()=>{a(!1)},[n]),n&&!s?i.jsx("img",{alt:"",className:q("size-3.5 shrink-0 rounded-[3px] object-contain",r==="invert"&&"dark:invert"),"data-dark-mode":r,"data-testid":"chat-side-panel-tab-browser-favicon",referrerPolicy:"no-referrer",src:n,onError:()=>a(!0)}):i.jsx(Vm,{"aria-hidden":!0,className:"size-3.5 shrink-0","data-testid":"chat-side-panel-tab-browser-fallback-icon"})}function KPn({enabled:e,issueId:t}){const n=Te({queryKey:V.issues.detail(t),queryFn:()=>fr.get(t),enabled:e});return n.isPending?i.jsx(yn,{"aria-hidden":!0,className:"size-3.5 shrink-0 animate-spin text-muted-foreground","data-testid":"chat-side-panel-tab-issue-loading-icon"}):n.isError||!n.data?i.jsx(zc,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-muted-foreground","data-testid":"chat-side-panel-tab-issue-fallback-icon"}):i.jsx(ni,{className:"size-3.5",dataSlot:"side-panel-tab-issue-status-icon",status:n.data.status})}function WPn({enabled:e,tab:t}){const n="size-3.5 shrink-0";return t.kind==="issue"?i.jsx(KPn,{enabled:e,issueId:t.issueId}):t.kind==="issue_proposal"?i.jsx(Sq,{"aria-hidden":!0,className:n}):t.kind==="automation"?i.jsx(I4,{"aria-hidden":!0,className:n}):t.kind==="chat"||t.kind==="side_chat"?i.jsx(ka,{"aria-hidden":!0,className:n}):t.kind==="subagents"||t.kind==="subagent"?i.jsx(_l,{"aria-hidden":!0,className:n}):t.kind==="library_directory"?i.jsx(ho,{"aria-hidden":!0,className:n}):t.kind==="library_document"?i.jsx(Fi,{"aria-hidden":!0,className:n}):t.kind==="library_entry"?t.path?i.jsx(Fi,{"aria-hidden":!0,className:n}):i.jsx(dM,{"aria-hidden":!0,className:n}):t.kind==="library_file"||t.kind==="local_file"?i.jsx(Fi,{"aria-hidden":!0,className:n}):t.kind==="organization_skill_file"?i.jsx(Fi,{"aria-hidden":!0,className:n}):t.kind==="local_apps"?i.jsx(Vf,{"aria-hidden":!0,className:n}):t.kind==="local_app"?i.jsx(k6,{className:n,identity:t,testId:"chat-side-panel-tab-local-app-icon"}):t.kind==="browser"?i.jsx(qPn,{favicon:t.favicon,url:t.url}):t.targetKind==="issue"?i.jsx(aM,{"aria-hidden":!0,className:n}):t.targetKind==="automation"?i.jsx(I4,{"aria-hidden":!0,className:n}):i.jsx(ka,{"aria-hidden":!0,className:n})}function ZPn(){const[e,t]=m.useState(()=>{var n;return typeof window<"u"&&!!((n=window.matchMedia)!=null&&n.call(window,"(max-width: 767px)").matches)});return m.useEffect(()=>{var s;if(typeof window>"u"||!window.matchMedia)return;const n=window.matchMedia("(max-width: 767px)"),r=()=>t(n.matches);return r(),(s=n.addEventListener)==null||s.call(n,"change",r),()=>{var a;return(a=n.removeEventListener)==null?void 0:a.call(n,"change",r)}},[]),e}function HPn(){return i.jsxs("div",{className:"space-y-3","data-testid":"chat-side-panel-loading",children:[i.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-[color:var(--surface-active)]"}),i.jsx("div",{className:"h-20 animate-pulse rounded-[var(--radius-lg)] bg-[color:var(--surface-active)]"}),i.jsx("div",{className:"h-28 animate-pulse rounded-[var(--radius-lg)] bg-[color:var(--surface-active)]"})]})}function XPn({browserAvailable:e,localAppsAvailable:t,sourceConversationId:n,onOpenTarget:r}){const s=[...n?[{label:"Side Chat",description:"Ask a focused follow-up without leaving the main chat.",icon:Sq,target:{kind:"side_chat",sourceConversationId:n,sourceMessageId:null,sourcePreview:null,conversationId:null,clientMutationId:crypto.randomUUID(),label:"Side Chat"}}]:[],...e?[{label:"Browser",description:"Keep a browser tab beside the current workspace.",icon:QLe,target:E4()}]:[],...t?[{label:"Local apps",description:"Run a reviewed project service beside this workspace.",icon:Vf,target:{kind:"local_apps",label:"Local apps"}}]:[],{label:"Library",description:"Browse workspace files with the Library tree.",icon:ho,target:{kind:"library_directory",directoryPath:"",label:"Library"}}];return i.jsxs("div",{className:"flex min-h-full flex-col justify-center py-6","data-testid":"chat-side-panel-empty-state",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Open a panel"}),i.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"Choose a workspace target to keep working without leaving this page."})]}),i.jsx("div",{className:"mt-5 grid gap-2",children:s.map(({label:a,description:o,icon:l,target:c})=>i.jsxs("button",{type:"button","data-testid":`chat-side-panel-empty-${a.toLowerCase().replaceAll(" ","-")}-target`,className:"flex items-center gap-3 rounded-[var(--radius-md)] border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-3 py-3 text-left text-sm transition-colors hover:bg-[color:var(--surface-active)]",onClick:()=>r(c),children:[i.jsx(l,{className:"h-4 w-4 text-muted-foreground"}),i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"block font-medium text-foreground",children:a}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:o})]})]},a))})]})}function GPn({browserAvailable:e,target:t,onOpenTarget:n}){const r={issue:{icon:aM,title:"Issue",body:"Open an issue link or use workspace search to load the editable task panel here.",actions:[{label:"Library",target:{kind:"library_directory",directoryPath:"",label:"Library"}},{label:"Chat",target:{kind:"placeholder",targetKind:"chat",label:"Chat"}}]},automation:{icon:_l,title:"Automation",body:"Open an automation link to inspect schedule state and pause or resume it without leaving this page.",actions:[{label:"Issue",target:{kind:"placeholder",targetKind:"issue",label:"Issue"}},{label:"Library",target:{kind:"library_directory",directoryPath:"",label:"Library"}}]},chat:{icon:ka,title:"Chat",body:"Open a chat reference to compare messages beside the current workspace.",actions:[{label:"Issue",target:{kind:"placeholder",targetKind:"issue",label:"Issue"}},{label:"Browser",target:E4()}]}}[t.targetKind],s=r.actions.filter(o=>e||o.target.kind!=="browser"),a=r.icon;return i.jsx("div",{className:"flex min-h-full flex-col justify-center py-6","data-testid":`chat-side-panel-${t.targetKind}-placeholder`,children:i.jsxs("div",{className:"mx-auto flex max-w-[18rem] flex-col items-center text-center",children:[i.jsx("span",{className:"inline-flex h-10 w-10 items-center justify-center rounded-full bg-[color:var(--surface-active)] text-muted-foreground",children:i.jsx(a,{className:"h-4 w-4"})}),i.jsx("h3",{className:"mt-3 text-base font-semibold text-foreground",children:r.title}),i.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:r.body}),i.jsx("div",{className:"mt-5 flex flex-wrap justify-center gap-2",children:s.map(o=>i.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:()=>n(o.target),children:o.label},o.label))})]})})}function YPn({issue:e,comments:t,commentId:n,onUpdate:r,onAddComment:s,updating:a,addingComment:o,currentUserId:l,agentMap:c,operatorDisplayName:d,expanded:u=!1}){var v;const[f,A]=m.useState(null),h=e.identifier??e.id.slice(0,8),g=((v=e.project)==null?void 0:v.name)??null,x=async w=>{A(null);try{await r(w)}catch(k){A(k instanceof Error?k.message:"Could not update this issue.")}},y=i.jsx(xU,{issue:e,onUpdate:w=>void x(w),showAuditSeparator:!1});return i.jsx("div",{className:"flex h-full min-h-0 flex-col","data-testid":"chat-side-panel-issue-view",children:i.jsxs("div",{className:q("grid h-full min-h-0 flex-1 gap-6",u?"xl:grid-cols-[minmax(0,1fr)_280px] xl:items-start":"scrollbar-auto-hide overflow-y-auto overscroll-contain pr-1"),"data-testid":"chat-side-panel-issue-scroll",children:[i.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col gap-5",children:[i.jsxs("div",{className:"shrink-0 space-y-3 pb-1",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsx(Em,{value:e.title,onSave:w=>x({title:w}),as:"h2",className:"min-w-0 flex-1 text-xl font-bold leading-7 text-foreground",placeholder:"Add a title..."}),i.jsx("span",{className:"mt-1 shrink-0 rounded-[calc(var(--radius-sm)-1px)] border border-[color:var(--border-soft)] px-2 py-0.5 text-xs text-muted-foreground",children:h})]}),u?i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx(Ds,{status:e.status}),i.jsx("span",{className:"inline-flex items-center gap-1.5 rounded-[calc(var(--radius-sm)-1px)] border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-2.5 py-1 text-xs font-medium text-muted-foreground shadow-[var(--shadow-sm)]",children:i.jsx(ql,{priority:e.priority,showLabel:!0})}),g?i.jsx("span",{className:"rounded-[calc(var(--radius-sm)-1px)] border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-2.5 py-1 text-xs font-medium text-muted-foreground shadow-[var(--shadow-sm)]",children:g}):null]}):null,u?null:i.jsx("section",{"aria-label":"Issue properties",className:"py-3",children:i.jsx(xU,{issue:e,onUpdate:w=>void x(w),showAuditFields:!1})}),i.jsx(Em,{value:e.description??"",onSave:w=>x({description:w.trim()||null}),as:"p",className:"text-[15px] leading-7 text-foreground",placeholder:"Add a description...",multiline:!0,editorEngine:"milkdown",alwaysEdit:!0,variant:"issue-description"}),f?i.jsx("div",{role:"alert",className:"rounded-[var(--radius-md)] border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null]}),i.jsxs("section",{className:"shrink-0 space-y-3 pb-3",children:[i.jsx("div",{className:"flex items-center justify-between gap-3",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-foreground",children:[i.jsx(Lc,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:"Sub-issues"})]}),i.jsx("span",{className:"rounded-sm border border-[color:var(--border-soft)] px-1.5 py-0.5 text-[11px] text-muted-foreground",children:"0"})]})}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"No sub-issues."})]}),i.jsxs("section",{"aria-label":"Activity",className:"space-y-2 py-1",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[i.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Activity"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:o?"Posting...":`${t.filter(w=>!w.deletedAt).length}`})]}),i.jsx("div",{className:"mb-3 space-y-3 text-sm text-muted-foreground",children:n?i.jsxs("div",{className:"rounded-[var(--radius-md)] border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-3 py-2",children:["Target comment: ",i.jsx("span",{className:"font-mono text-foreground",children:n})]}):null}),i.jsx(qst,{comments:t,orgId:e.orgId,projectId:e.projectId,issueStatus:e.status,agentMap:c,currentUserId:l,operatorDisplayName:d,hideHeading:!0,emptyMessage:"No comments yet.",draftKey:`rudder:side-panel-issue-comment-draft:${e.id}`,fixedComposer:!0,fixedComposerTimelineScroll:!1,onAdd:s})]})]}),u?i.jsx("aside",{className:"space-y-3 xl:sticky xl:top-0",children:i.jsxs("section",{"aria-label":"Issue properties",className:"rounded-lg border border-border bg-background/80 p-3",children:[i.jsx("div",{className:"mb-3 flex items-center justify-between gap-2",children:i.jsx("p",{className:"text-[11px] font-medium text-muted-foreground",children:"Properties"})}),y]})}):null]})})}function Gat(e){if(!e)return null;const t=e.split("/").at(-1)??e,n=t.lastIndexOf(".");return n===-1?null:t.slice(n).toLowerCase()}function JPn(e){const t=Gat(e);return t!==null&&QPn.has(t)}function eIn(e){const t=Gat(e);return t!==null&&UPn.has(t)}function tIn(e){var t;return((t=e.displayLabel)==null?void 0:t.trim())||e.name}function nIn(e){const t=e.split("/").filter(Boolean);return e==="skills"||t.length===3&&t[0]==="agents"&&t[2]==="skills"}function rIn(e){const t=e.split("/").filter(Boolean);return t.length===2&&t[0]==="skills"||t.length===4&&t[0]==="agents"&&t[2]==="skills"}function sIn(e){const t=e.split("/").filter(Boolean);return t.length===2&&t[0]==="projects"}function iIn({entry:e}){return e.entityType==="agent_workspace"?i.jsx("span",{"data-testid":"chat-side-panel-library-agent-icon",className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-muted-foreground",children:i.jsx(Ml,{icon:e.agentIcon,role:e.agentRole,className:"h-3.5 w-3.5 text-[12px]"})}):e.path==="agents"?i.jsx(Kv,{"data-testid":"chat-side-panel-library-agents-root-icon",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):nIn(e.path)?i.jsx(Lc,{"data-testid":"chat-side-panel-library-skills-root-icon",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):rIn(e.path)?i.jsx($Le,{"data-testid":"chat-side-panel-library-skill-folder-icon",className:"h-3.5 w-3.5 shrink-0 text-[#2f80ed]"}):sIn(e.path)?i.jsx(aze,{"data-testid":"chat-side-panel-library-project-icon",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):i.jsx(ho,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})}function aIn({entries:e,selectedOrganizationId:t,onOpenTarget:n,selectedPath:r}){return e.length===0?i.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"This folder is empty or unavailable."}):i.jsx("ul",{className:"space-y-0.5",children:e.map(s=>i.jsx(Yat,{entry:s,selectedOrganizationId:t,onOpenTarget:n,selectedPath:r},s.path))})}function Yat({entry:e,selectedOrganizationId:t,onOpenTarget:n,selectedPath:r,depth:s=0}){var A;const[a,o]=m.useState(!1),l=tIn(e),c=r===e.path,d=Te({queryKey:V.organizations.workspaceFiles(t??"__none__",e.path),queryFn:()=>En.listWorkspaceFiles(t,e.path),enabled:!!(t&&e.isDirectory&&a),refetchOnWindowFocus:!1}),u=((A=d.data)==null?void 0:A.entries)??[];if(e.isDirectory)return i.jsxs("li",{children:[i.jsx("div",{className:q("group flex w-full items-center rounded-md pr-1 text-sm text-foreground transition-[background-color,color,opacity,transform] duration-150",c?"bg-accent text-foreground":"hover:bg-accent/60"),style:{paddingLeft:`${s*14+8}px`},"data-workspace-entry-path":e.path,children:i.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 rounded-md py-1.5 pl-0 pr-2 text-left",onClick:()=>o(h=>!h),"aria-expanded":a,children:[i.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:a?i.jsx(Br,{className:"h-4 w-4"}):i.jsx(_i,{className:"h-4 w-4"})}),i.jsx(iIn,{entry:e}),i.jsx("div",{className:"min-w-0 flex-1",children:i.jsx("div",{className:"truncate font-medium",children:l})}),e.entityType==="agent_workspace"?i.jsx("span",{"aria-hidden":"true","data-testid":"chat-side-panel-library-agent-badge",className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-border bg-background px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Agent"}):null]})}),a?d.isPending?i.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",style:{paddingLeft:`${(s+1)*14+23}px`},children:"Loading files..."}):u.length>0?i.jsx("ul",{className:"space-y-0.5",children:u.map(h=>i.jsx(Yat,{entry:h,selectedOrganizationId:t,onOpenTarget:n,selectedPath:r,depth:s+1},h.path))}):null:null]});const f=JPn(e.path)?GLe:wM(e.path)?Vm:eIn(e.path)?Fi:b6;return i.jsx("li",{children:i.jsx("div",{className:q("group flex w-full items-center rounded-md pr-1 text-sm transition-[background-color,color,opacity,transform] duration-150",c?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:`${s*14+23}px`},"data-workspace-entry-path":e.path,children:i.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 rounded-md py-1.5 pl-0 pr-2 text-left",onClick:()=>n({kind:"library_file",filePath:e.path,label:l}),"aria-selected":c,children:[i.jsx(f,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:l})]})})})}function oIn({libraryFile:e,organizationId:t,sourceConversationId:n,markdown:r,sourceToolbar:s}){var re,ne,te,ce;const a=Wn(),o=e.filePath,l=e.content??"",c=m.useRef(null);c.current===null&&(c.current=$it(t,o,l));const d=c.current,u=m.useRef(null),f=m.useRef(null),[A,h]=m.useState(null),g=m.useRef(d.baseContent),x=m.useRef(l),y=m.useRef(d.content),v=m.useRef(null),w=m.useRef(!1),k=m.useRef(d.conflicted),O=m.useRef(0),j=m.useRef(!0),[C,N]=m.useState(d.content),[I,E]=m.useState(d.conflicted?"error":C===l?"saved":"saving"),[_,T]=m.useState(d.conflicted?Mee:null),[R,M]=m.useState(d.conflicted),[,L]=m.useState(0);y.current=C,x.current=l,m.useEffect(()=>(j.current=!0,()=>{j.current=!1,Dy(t,o,g.current,y.current)}),[o,t]),m.useEffect(()=>{if(l===g.current)return;if(l===y.current){g.current=l,k.current=!1,M(!1),E("saved"),T(null),r4(t,o);return}if(y.current===g.current){g.current=l,y.current=l,N(l),k.current=!1,M(!1),E("saved"),T(null),r4(t,o);return}v.current=null,k.current=!0,O.current+=1,M(!0),E("error"),T(Mee),Dy(t,o,g.current,y.current)},[o,t,l]);const U=m.useCallback((se,he)=>{const we=se.content??he;g.current=we,x.current=we,k.current=!1,j.current&&(M(!1),T(null)),a.setQueryData(V.organizations.workspaceFile(t,o),se),Dy(t,o,we,y.current),y.current!==we&&(v.current=y.current)},[o,t,a]),B=m.useCallback(async()=>{if(!w.current){w.current=!0;try{for(;v.current!==null;){const se=v.current,he=O.current;if(v.current=null,k.current)return;if(se!==g.current){j.current&&(E("saving"),T(null));try{const we=await En.updateWorkspaceFile(t,o,{content:se,expectedContent:g.current});if(he!==O.current)continue;U(we,se)}catch(we){if(he!==O.current)continue;let Ue=null;try{Ue=await En.readWorkspaceFile(t,o)}catch{}if(he!==O.current)continue;if(Ue&&(x.current=Ue.content??"",a.setQueryData(V.organizations.workspaceFile(t,o),Ue)),(Ue==null?void 0:Ue.content)===se){U(Ue,se);continue}if(Ue&&Ue.content!==g.current&&(v.current=null,k.current=!0,Dy(t,o,g.current,y.current)),j.current){E("error");const je=k.current;M(je),T(je?Mee:we instanceof Error?we.message:"Could not save this file.")}return}}}j.current&&E(v.current===null&&y.current===g.current?"saved":"saving")}finally{w.current=!1,v.current!==null&&!k.current&&B()}}},[U,o,t,a]),z=m.useCallback(se=>{v.current=se,B()},[B]);m.useEffect(()=>{if(Dy(t,o,g.current,C),k.current)return;if(C===g.current){E(w.current||v.current!==null?"saving":"saved"),T(null);return}const se=window.setTimeout(()=>z(C),700);return()=>window.clearTimeout(se)},[C,z,o,t]);const H=se=>{y.current=se,N(se),E(k.current?"error":"saving"),k.current||T(null),L(he=>he+1)},J=()=>{const se=x.current;O.current+=1,g.current=se,y.current=se,v.current=null,k.current=!1,N(se),M(!1),E("saved"),T(null),r4(t,o)},F=()=>{O.current+=1,g.current=x.current,k.current=!1,M(!1),E("saving"),T(null),z(y.current)},Q=r?r1e(C):{frontmatter:null,separator:"",body:C},W=f9n(Q.body),$=((ne=(re=u.current)==null?void 0:re.canUndo)==null?void 0:ne.call(re))??!1,ee=((ce=(te=u.current)==null?void 0:te.canRedo)==null?void 0:ce.call(te))??!1;return i.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col","data-testid":r?"chat-side-panel-library-markdown-editor":"chat-side-panel-library-text-editor",children:[s,r?i.jsxs("div",{ref:f,className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-5 pb-20 pt-5",children:[Q.frontmatter!==null?i.jsxs("details",{className:"group mb-6 rounded-md border border-[color:var(--border-soft)] bg-[color:var(--surface-page)]","data-chat-annotation-ignore":!0,"data-testid":"chat-side-panel-library-frontmatter-editor",children:[i.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-muted-foreground outline-none transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[i.jsx("span",{children:"Frontmatter"}),i.jsx(_i,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-90"})]}),i.jsx("textarea",{value:Q.frontmatter,onChange:se=>H(kU(se.currentTarget.value,Q.separator,Q.body)),spellCheck:!1,className:"block min-h-28 w-full resize-y border-t border-[color:var(--border-soft)] bg-transparent px-3 py-2 font-mono text-xs leading-5 text-foreground outline-none","aria-label":"Frontmatter"})]}):null,i.jsx(Au,{ref:u,engine:"milkdown",value:Q.body,onChange:se=>H(kU(Q.frontmatter,Q.separator,se)),bordered:!1,placeholder:"Write in Markdown...",contentClassName:"rudder-library-document-editor rudder-side-panel-library-document min-h-[420px] text-[15px] leading-7 text-foreground"},o)]}):i.jsx("div",{ref:f,className:"min-h-0 flex-1 pb-14",children:i.jsx(BT,{"data-testid":"chat-side-panel-library-text-source-editor",annotationSource:{surface:"workspace_file",sourceFilePath:o},ariaLabel:`${o||"Library file"} source editor`,filePath:o,value:C,onChange:H,onSelectionChange:h})}),i.jsx(qQe,{containerRef:f,conversationId:n,explicitSelection:r?void 0:A,saved:I==="saved"&&!R&&C===g.current,source:C,sourceIdentity:{surface:"workspace_file",sourceFilePath:o,sourceLibraryEntryId:e.libraryEntryId},sourceRenderMode:r?"markdown":"text",renderedSource:r?Q.body:C,renderedSourceOffset:r?C.length-Q.body.length:0}),i.jsxs("div",{className:"pointer-events-none absolute inset-x-3 bottom-3 flex min-w-0 items-end justify-between gap-3",children:[i.jsxs("div",{className:q("pointer-events-auto flex min-h-8 min-w-0 items-center gap-2 rounded-md border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-2.5 text-xs shadow-sm",I==="error"?"text-destructive":"text-muted-foreground"),role:I==="error"?"alert":"status",title:_??void 0,children:[i.jsx("span",{className:q("h-1.5 w-1.5 shrink-0 rounded-full",I==="error"?"bg-destructive":I==="saving"?"bg-[color:var(--accent-strong)]":"bg-emerald-500")}),i.jsxs("span",{className:"truncate",children:[R?"Conflict":I==="error"?"Save failed":I==="saving"?"Saving":"Saved",` · ${W.toLocaleString()} ${W===1?"word":"words"}`]}),R?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"shrink-0 font-medium text-foreground underline underline-offset-2",onClick:F,children:"Keep mine"}),i.jsx("button",{type:"button",className:"shrink-0 font-medium text-foreground underline underline-offset-2",onClick:J,children:"Use latest"})]}):I==="error"?i.jsx("button",{type:"button",className:"shrink-0 font-medium text-foreground underline underline-offset-2",onClick:()=>z(y.current),children:"Retry"}):null]}),r?i.jsx(id,{delayDuration:120,children:i.jsxs("div",{className:"pointer-events-auto flex shrink-0 items-center rounded-md border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] p-0.5 shadow-sm","data-testid":"chat-side-panel-library-history-controls",children:[i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground disabled:pointer-events-none disabled:opacity-35","aria-label":"Undo Markdown edit",disabled:!$,onClick:()=>{var se,he;(he=(se=u.current)==null?void 0:se.undo)==null||he.call(se),L(we=>we+1)},children:i.jsx(c9t,{className:"h-3.5 w-3.5"})})}),i.jsx(Gi,{side:"top",children:"Undo"})]}),i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground disabled:pointer-events-none disabled:opacity-35","aria-label":"Redo Markdown edit",disabled:!ee,onClick:()=>{var se,he;(he=(se=u.current)==null?void 0:se.redo)==null||he.call(se),L(we=>we+1)},children:i.jsx(aOt,{className:"h-3.5 w-3.5"})})}),i.jsx(Gi,{side:"top",children:"Redo"})]})]})}):null]})]})}function lIn({libraryFile:e,organizationId:t,sourceConversationId:n}){const{pushToast:r}=As(),{selectedOrganization:s}=Nr(),a=br(),o=Hr(),l=Sat(e),c=e.previewKind==="video"||e.previewKind==="audio",d=Oat(e),u=kat(e),f=e.previewKind==="text"&&e.content!==null&&!e.truncated,[A,h]=m.useState("preview"),g=e.filePath.split("/").filter(Boolean),x=g.length>3?["…",...g.slice(-2)]:g,[y,v]=m.useState([]),[w,k]=m.useState(!1),[O,j]=m.useState(null),[C,N]=m.useState(!1),I=Pn(),E=!!(e.rootPath&&(I!=null&&I.openWorkspaceFileInIde));m.useEffect(()=>{let J=!1;if(!E||!(I!=null&&I.listWorkspaceLaunchTargets)){v([]);return}return I.listWorkspaceLaunchTargets().then(F=>{J||v(F)}).catch(()=>{J||v([])}),()=>{J=!0}},[E,I]);const _=y.filter(J=>J.kind==="ide"&&J.id!=="xcode"||(J.kind==="terminal"||J.kind==="folder")&&!!(I!=null&&I.openWorkspaceFileLocation)),T=Yc(`/library?path=${encodeURIComponent(e.filePath)}`,s?hc(s):Ng(a.pathname)),R=async J=>{var F;if(!(!e.rootPath||!I)){j(J.id);try{J.kind==="app"||J.kind==="ide"?await I.openWorkspaceFileInIde(e.rootPath,e.filePath,J.id):await((F=I.openWorkspaceFileLocation)==null?void 0:F.call(I,e.rootPath,e.filePath,J.id)),r({title:`Opened in ${J.label}`,tone:"success"})}catch(Q){r({title:`Could not open in ${J.label}`,body:Q instanceof Error?Q.message:"Try another app.",tone:"error"})}finally{j(null)}}},M=i.jsxs(Mi,{open:w,onOpenChange:J=>{k(J),J&&N(!1)},children:[i.jsx(Ei,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1 px-2","aria-label":"Open file options",title:"Open file options",children:[i.jsx("span",{children:"Open"}),i.jsx(Br,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),i.jsxs(Di,{align:"end",className:"w-56",children:[i.jsxs(Gt,{onSelect:()=>o(T),children:[i.jsx(dM,{className:"h-4 w-4"}),i.jsx("span",{children:"Open in Library"})]}),E?i.jsxs(Gt,{disabled:O!==null,onSelect:()=>void R({id:"defaultApp",label:"Default app",kind:"app"}),children:[i.jsx(La,{className:"h-4 w-4"}),i.jsx("span",{children:"Default app"})]}):null,_.map(J=>i.jsxs(Gt,{disabled:O!==null,onSelect:()=>void R(J),children:[i.jsx(B2,{target:J,className:"h-4 w-4"}),i.jsx("span",{children:J.label})]},J.id))]})]}),L=A==="preview",U=L?"Show source":"Show table",B=L?b6:KOt,z=d?i.jsx(id,{delayDuration:120,children:i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0","aria-label":U,"data-testid":"chat-side-panel-library-file-mode-toggle",onClick:()=>h(L?"source":"preview"),children:i.jsx(B,{className:"h-4 w-4","aria-hidden":"true"})})}),i.jsx(Gi,{side:"bottom",sideOffset:8,children:U})]})}):null,H=l?Vm:e.previewKind==="video"?rue:e.previewKind==="audio"?nue:Fi;return i.jsxs("div",{className:"flex h-full min-h-[420px] flex-col","data-testid":"chat-side-panel-library-file-view",children:[i.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-3 border-b border-[color:var(--border-soft)] px-4","data-testid":"chat-side-panel-library-file-toolbar",children:[i.jsx(H,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),i.jsx(id,{delayDuration:120,children:i.jsxs(Hi,{open:C&&!w,onOpenChange:N,children:[i.jsx(Xi,{asChild:!0,children:i.jsx("nav",{"aria-label":"Library file path",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",tabIndex:0,children:x.map((J,F)=>{const Q=F===x.length-1;return i.jsxs("span",{className:"contents",children:[F>0?i.jsx(_i,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}):null,i.jsx("span",{className:q("truncate",Q?"max-w-[60%] shrink-0 font-medium text-foreground":"min-w-0 text-muted-foreground"),children:J})]},`${J}-${F}`)})})}),i.jsx(Gi,{side:"bottom",sideOffset:8,className:"max-w-[min(36rem,calc(100vw-2rem))] break-all text-left leading-5","data-testid":"chat-side-panel-library-full-path",children:e.filePath})]})}),z,!l&&!c?i.jsx("div",{className:"shrink-0","data-testid":"chat-side-panel-library-open-in",children:M}):null]}),f&&(u||!l&&!d||A==="source")?i.jsx(oIn,{libraryFile:e,organizationId:t,sourceConversationId:n,markdown:u,sourceToolbar:l?i.jsx(nZ,{viewMode:"source",onViewModeChange:h,openAction:i.jsx("div",{className:"shrink-0","data-testid":"chat-side-panel-library-open-in",children:M}),testIdPrefix:"chat-side-panel-library"}):void 0},`${t}:${e.filePath}`):i.jsxs(i.Fragment,{children:[u&&e.truncated?i.jsx("div",{className:"shrink-0 border-b border-[color:var(--border-soft)] px-4 py-2 text-xs text-muted-foreground","data-testid":"chat-side-panel-library-readonly-notice",role:"status",children:e.message??"This file is too large to edit in the Side Panel."}):null,i.jsx(jat,{file:e,organizationId:t,mode:A,onModeChange:h,htmlOpenAction:l?i.jsx("div",{className:"shrink-0","data-testid":"chat-side-panel-library-open-in",children:M}):void 0,mediaOpenAction:c?i.jsx("div",{className:"shrink-0","data-testid":"chat-side-panel-library-media-open-in",children:M}):void 0,testIdPrefix:"chat-side-panel-library"})]})]})}function cIn({file:e,label:t}){const[n,r]=m.useState("preview"),s=r1e(e.content),a=e.markdown;return i.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-testid":"chat-side-panel-skill-file-view",children:[i.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-3 border-b border-[color:var(--border-soft)] px-4",children:[i.jsx(Lc,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t}),i.jsx("div",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e.path})]}),i.jsx("span",{className:"shrink-0 rounded-full border border-border px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Read only"}),a?i.jsxs("div",{className:"flex shrink-0 items-center rounded-md border border-[color:var(--border-soft)] p-0.5","data-testid":"chat-side-panel-skill-view-toggle",children:[i.jsx("button",{type:"button",className:q("inline-flex h-7 w-7 items-center justify-center rounded-[4px] transition-colors",n==="preview"?"bg-[color:var(--surface-active)] text-foreground":"text-muted-foreground hover:text-foreground"),"aria-label":"Preview skill Markdown","aria-pressed":n==="preview",onClick:()=>r("preview"),children:i.jsx(k2,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),i.jsx("button",{type:"button",className:q("inline-flex h-7 w-7 items-center justify-center rounded-[4px] transition-colors",n==="source"?"bg-[color:var(--surface-active)] text-foreground":"text-muted-foreground hover:text-foreground"),"aria-label":"View skill Markdown source","aria-pressed":n==="source",onClick:()=>r("source"),children:i.jsx(tue,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):null]}),i.jsx("div",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-5 py-5",children:a&&n==="preview"?i.jsx(Bo,{className:"text-sm leading-7 text-foreground",children:s.body}):i.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words font-mono text-xs leading-6 text-foreground/85","data-testid":"chat-side-panel-skill-source",children:i.jsx("code",{children:e.content})})})]})}function Jat({contextReady:e=!0,expanded:t=!1,exiting:n=!1,onClose:r,onToggleExpanded:s,target:a,selectedOrganizationId:o}){var Ke,st,Ft,Dn,Rn,rt,Yt,fn,or;const l=R3(),c=cfe(),d=Yge(),{pushToast:u}=As(),f=br(),A=Hr(),[h,g]=m.useState(null),[x,y]=m.useState(null),[v,w]=m.useState(()=>new Set),[k,O]=m.useState(null),[j,C]=m.useState(!l.open),N=m.useRef(null),I=m.useRef(null),E=m.useRef(null),_=m.useRef(new Map),T=m.useRef(new Map),R=m.useRef(new Set),M=m.useRef(null),L=m.useRef(null),U=Wn(),B=DE(),z=ZPn(),{openTarget:H}=l,J=m.useCallback((xt,Xt)=>{Xt?_.current.set(xt,Xt):_.current.delete(xt)},[]),F=m.useCallback(()=>{const xt=`${f.pathname}${f.search}${f.hash}`,Xt=rK(f);gfe(xt),A("/instance/settings/browser",Xt?{state:Xt}:void 0)},[f,A]),Q=m.useCallback((xt,Xt)=>{Xt?T.current.set(xt,Xt):T.current.delete(xt)},[]),W=m.useCallback((xt,Xt)=>{if(xt.surface==="workspace_file"||xt.surface==="local_file"){(async()=>{try{let Fn=xt.sourceFilePath,er;if(xt.surface==="workspace_file"){if(!o)throw new Error("No organization selected");if(xt.sourceLibraryEntryId){const hs=await En.getLibraryEntry(o,xt.sourceLibraryEntryId);if(hs.status!=="active"||!hs.currentPath)throw new Error("Library source is unavailable");Fn=hs.currentPath}er=(await En.readWorkspaceFile(o,Fn)).content}else{const hs=Pn();if(!hs)throw new Error("Desktop file access is unavailable");er=(await hs.previewLocalFile(Fn)).content}if(er===null||await Lw(er)!==xt.sourceHash||er.slice(Math.max(0,xt.start-xt.prefix.length),xt.start)!==xt.prefix||er.slice(xt.end,xt.end+xt.suffix.length)!==xt.suffix)throw new Error("Annotation source changed");const zr=Fn.split(/[\\/]/u).filter(Boolean).at(-1)??Fn;BQe({surface:xt.surface,sourceFilePath:Fn,sourceHash:xt.sourceHash,sourceRenderMode:xt.sourceRenderMode,start:xt.start,end:xt.end}),l.openTarget(xt.surface==="workspace_file"?xt.sourceLibraryEntryId?{kind:"library_entry",entryId:xt.sourceLibraryEntryId,path:Fn,label:zr}:{kind:"library_file",filePath:Fn,label:zr}:{kind:"local_file",filePath:Fn,label:zr})}catch{u({title:"Source is no longer available",body:"The file was changed, moved without a Library identity, or deleted.",tone:"error"})}})();return}l.hidePanel(),A({pathname:`/messenger/chat/${xt.sourceConversationId}`,search:`?messageId=${encodeURIComponent(xt.sourceMessageId)}`},{state:Nat(xt,Xt)})},[A,u,o,l]),$=l.tabs,ee=m.useMemo(()=>$.filter(xt=>xt.kind==="browser"),[$]),re=m.useMemo(()=>$.filter(xt=>xt.kind==="local_app"),[$]),ne=m.useMemo(()=>!c||!o?[]:$.flatMap(xt=>{if(!_f(xt))return[];const Xt=xt.kind==="browser"?xt.viewInstanceId??xt.tabId:xt.viewInstanceId;return Xt?[{...xt,viewInstanceId:Xt}]:[]}),[c,o,$]),te=Cat({browserTargets:ee,organizationId:o}),ce=c&&o?c.getLiveBrowserCount(o):ee.length,se=ee.length<eP&&ce<Cv;m.useLayoutEffect(()=>{var Fn,er;if(z)return;if(l.open){C(!1);return}const xt=(Fn=N.current)==null?void 0:Fn.parentElement;if(!xt||!L.current){C(!0);return}if((er=window.matchMedia)!=null&&er.call(window,"(prefers-reduced-motion: reduce)").matches||xt.getBoundingClientRect().width<=.5){C(!0);return}const Xt=zr=>{zr.target!==xt||zr.propertyName!=="width"||C(!0)};return xt.addEventListener("transitionend",Xt),()=>xt.removeEventListener("transitionend",Xt)},[z,l.open]);const he=!!((Ke=Pn())!=null&&Ke.getBrowserPartition),we=he,Ue=Te({queryKey:V.health,queryFn:()=>FA.get()}),je=!!((Ft=(st=Pn())==null?void 0:st.localApps)!=null&&Ft.supported&&((Rn=(Dn=Ue.data)==null?void 0:Dn.features)!=null&&Rn.experimentalSitesEnabled));m.useEffect(()=>{!e||!a||a.kind==="browser"&&!we||a.kind==="local_apps"&&!je||H(a)},[we,e,je,H,a]),m.useEffect(()=>{if(!he)for(const xt of ee)l.closeTarget(gs(xt))},[ee,he,l]),m.useEffect(()=>{if(!je)for(const xt of re)l.closeTarget(gs(xt))},[re,je,l]);const ke=m.useMemo(()=>{if(!e||$.length===0||l.activeKey===null)return null;if(l.activeKey){const xt=$.find(Xt=>gs(Xt)===l.activeKey);if(xt)return xt}return $.at(-1)??null},[e,l.activeKey,$]),Se=(ke==null?void 0:ke.kind)==="issue"?ke:null,oe=(ke==null?void 0:ke.kind)==="issue_proposal"?ke:null,fe=(ke==null?void 0:ke.kind)==="chat"?ke:null,Ie=(ke==null?void 0:ke.kind)==="side_chat"?ke:null,ue=(ke==null?void 0:ke.kind)==="subagents"?ke:null,be=(ke==null?void 0:ke.kind)==="subagent"?ke:null,at=(ke==null?void 0:ke.kind)==="automation"?ke:null,ve=(ke==null?void 0:ke.kind)==="library_file"?ke:null,me=(ke==null?void 0:ke.kind)==="local_file"?ke:null,ye=(ke==null?void 0:ke.kind)==="organization_skill_file"?ke:null,qe=(ke==null?void 0:ke.kind)==="library_directory"?ke:null,Ce=(ke==null?void 0:ke.kind)==="library_entry"?ke:null,X=(ke==null?void 0:ke.kind)==="browser"?ke:null,G=(ke==null?void 0:ke.kind)==="local_apps"?ke:null;ke==null||ke.kind;const Ae=ke&&c&&_f(ke)&&(ke.kind==="browser"||ke.viewInstanceId)?ke:null,Je=X?gs(X):null,ht=(ke==null?void 0:ke.kind)==="placeholder"?ke:null,De=l.open||n,ft=l.contextKey.startsWith("chat:")&&l.contextKey.slice(5)||null,dt=m.useCallback(xt=>{var Fn,er;if((Fn=Pn())!=null&&Fn.onBrowserShortcut||!Je)return;const Xt=WEe({type:xt.type,key:xt.key,code:xt.code,meta:xt.metaKey,control:xt.ctrlKey,alt:xt.altKey,shift:xt.shiftKey},{isMac:navigator.platform.toLowerCase().includes("mac")});Xt&&(xt.preventDefault(),(er=_.current.get(Je))==null||er(Xt))},[Je]),yt=(ve==null?void 0:ve.filePath)??(Ce==null?void 0:Ce.path)??null,Mt=Te({queryKey:V.issues.detail((Se==null?void 0:Se.issueId)??"__none__"),queryFn:()=>fr.get(Se.issueId),enabled:De&&!!Se}),Xe=Te({queryKey:V.issues.comments((Se==null?void 0:Se.issueId)??"__none__"),queryFn:()=>fr.listComments(Se.issueId),enabled:De&&!!Se}),At=Te({queryKey:V.agents.list(o??"__none__"),queryFn:()=>_n.list(o),enabled:De&&!!o&&!!Se}),it=Te({queryKey:V.auth.session,queryFn:()=>el.getSession(),enabled:De&&!!Se}),Ee=pt({mutationFn:({issueId:xt,data:Xt})=>fr.update(xt,Xt),onSuccess:xt=>{U.setQueryData(V.issues.detail(xt.id),xt),U.invalidateQueries({queryKey:["issues"]}),U.invalidateQueries({queryKey:["messenger"]}),o&&U.invalidateQueries({queryKey:V.chats.workManifests(o)})}}),mt=pt({mutationFn:({issueId:xt,body:Xt,reopen:Fn})=>fr.addComment(xt,Xt,Fn),onSuccess:(xt,Xt)=>{U.setQueryData(V.issues.comment(Xt.issueId,xt.id),xt),U.setQueryData(V.issues.comments(Xt.issueId),Fn=>Fn?[...Fn,xt]:[xt]),U.invalidateQueries({queryKey:V.issues.detail(Xt.issueId)}),U.invalidateQueries({queryKey:V.issues.comments(Xt.issueId)}),U.invalidateQueries({queryKey:["messenger"]})}}),ot=Te({queryKey:V.chats.detail(o??"__none__",(fe==null?void 0:fe.conversationId)??"__none__"),queryFn:()=>rr.get(fe.conversationId),enabled:De&&!!o&&!!fe}),xe=Te({queryKey:V.chats.messages(o??"__none__",(fe==null?void 0:fe.conversationId)??"__none__"),queryFn:()=>rr.listMessages(o,fe.conversationId),enabled:De&&!!o&&!!fe}),Ne=Te({queryKey:V.organizations.workspaceFile(o??"__none__",yt??""),queryFn:()=>En.readWorkspaceFile(o,yt),enabled:De&&!!o&&!!yt}),We=Te({queryKey:V.organizationSkills.file(o??"__none__",(ye==null?void 0:ye.skillId)??"__none__",(ye==null?void 0:ye.filePath)??"SKILL.md"),queryFn:()=>Zu.file(o,ye.skillId,ye.filePath),enabled:De&&!!o&&!!ye}),ze=Te({queryKey:V.organizations.workspaceFiles(o??"__none__",(qe==null?void 0:qe.directoryPath)??""),queryFn:()=>En.listWorkspaceFiles(o,qe.directoryPath),enabled:De&&!!o&&!!qe}),Ye=!!(Se&&Mt.isPending||fe&&(ot.isPending||xe.isPending)||yt&&Ne.isPending||ye&&We.isPending||qe&&ze.isPending),_e=Mt.error??Xe.error??At.error??it.error??ot.error??xe.error??Ne.error??We.error??ze.error,Le=Se?Mt.data:null,Pe=Se?Xe.data??[]:[],vt=((Yt=(rt=it.data)==null?void 0:rt.user)==null?void 0:Yt.id)??((or=(fn=it.data)==null?void 0:fn.session)==null?void 0:or.userId)??null,Be=new Map((At.data??[]).map(xt=>[xt.id,xt])),ut=fe?ot.data:null,Et=fe?xe.data??[]:[],Zt=yt?Ne.data:null,Nn=ye?We.data:null,zn=qe?ze.data:null,Ze=ke?gs(ke):"empty",Qt=$.map(gs).join(`
|
|
1935
|
+
`,n=!1){const r=e.map(s=>s.map(xCn).join(",")).join(t);return n&&r.length>0?`${r}${t}`:r}const yCn=YO("inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap rounded-[var(--control-radius)] border text-sm font-medium transition-[color,background-color,border-color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:border-[color:var(--border-base)] data-[state=on]:bg-secondary data-[state=on]:text-secondary-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"border-transparent bg-transparent text-muted-foreground shadow-none hover:border-[color:var(--border-soft)] hover:bg-[color:var(--surface-active)] hover:text-foreground",outline:"border-[color:var(--border-base)] bg-[color:var(--surface-elevated)] text-muted-foreground shadow-none hover:bg-[color:var(--surface-active)] hover:text-foreground"},size:{default:"h-9 min-w-9 px-2",sm:"h-7 min-w-7 px-2 text-xs",lg:"h-10 min-w-10 px-2.5"}},defaultVariants:{variant:"default",size:"default"}}),dat=m.createContext({size:"default",variant:"default",spacing:0});function uat({className:e,variant:t,size:n,spacing:r=0,children:s,...a}){return i.jsx(jEe,{"data-slot":"toggle-group","data-variant":t,"data-size":n,"data-spacing":r,style:{"--gap":r},className:q("group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-[var(--control-radius)]",e),...a,children:i.jsx(dat.Provider,{value:{variant:t,size:n,spacing:r},children:s})})}function OU({className:e,children:t,variant:n,size:r,...s}){const a=m.useContext(dat);return i.jsx(CEe,{"data-slot":"toggle-group-item","data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:q(yCn({variant:a.variant||n,size:a.size||r}),"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10","data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-[var(--control-radius)] data-[spacing=0]:last:rounded-r-[var(--control-radius)] data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",e),...s,children:t})}const YL=new Map,BC="connected";function nZ({viewMode:e,onViewModeChange:t,networkMode:n,onNetworkModeChange:r,networkUnavailable:s=!1,onReload:a,openAction:o,testIdPrefix:l="workspace-file",className:c}){const d=s?"offline":n,u=d==="connected"?"Connected":"Offline",f=d==="connected"?pye:mye,A=s?"Network mode: Offline. Connected preview is unavailable while using the static Offline fallback.":d==="connected"?"Network mode: Connected. Runs artifact scripts and may send preview content to external HTTPS sites.":"Network mode: Offline. Local assets only; scripts and external requests are blocked.";return i.jsx("div",{className:q("workspace-html-preview-toolbar scrollbar-auto-hide flex min-h-10 shrink-0 items-center overflow-x-auto border-b border-border bg-[color:var(--surface-elevated)] px-1",c),"data-testid":`${l}-html-preview-toolbar`,children:i.jsxs("div",{className:"workspace-html-preview-toolbar-controls ml-auto flex min-w-max items-center gap-1",children:[i.jsxs(uat,{type:"single",variant:"outline",size:"sm",spacing:0,value:e,onValueChange:h=>{(h==="preview"||h==="source")&&t(h)},"aria-label":"HTML file mode",children:[i.jsxs(OU,{value:"preview",className:"px-2","aria-label":"Preview",title:"Preview",children:[i.jsx(Vm,{"data-icon":"inline-start"}),i.jsx("span",{className:"workspace-html-preview-mode-label",children:"Preview"})]}),i.jsxs(OU,{value:"source",className:"px-2","aria-label":"Source",title:"Source",children:[i.jsx(tue,{"data-icon":"inline-start"}),i.jsx("span",{className:"workspace-html-preview-mode-label",children:"Source"})]})]}),e==="preview"&&d&&r?i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,disabled:s,children:i.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"min-w-[6.5rem] justify-between","aria-label":A,"data-testid":`${l}-html-preview-network-menu`,children:[i.jsx(f,{"data-icon":"inline-start"}),i.jsx("span",{children:u}),i.jsx(Br,{className:"workspace-html-preview-network-chevron","data-icon":"inline-end"})]})}),i.jsx(Di,{align:"end",className:"w-72",children:i.jsxs(pLt,{children:[i.jsx(OI,{children:"Network access"}),i.jsxs(ofe,{value:d,onValueChange:h=>{(h==="connected"||h==="offline")&&r(h)},children:[i.jsxs(cB,{value:"connected",children:[i.jsx(pye,{}),i.jsxs("span",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{children:"Connected"}),i.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"Run scripts and allow HTTPS resources"})]})]}),i.jsxs(cB,{value:"offline",children:[i.jsx(mye,{}),i.jsxs("span",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{children:"Offline"}),i.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"Local assets only; block scripts"})]})]})]})]})})]}):null,o?i.jsx("div",{className:"workspace-html-preview-open-action shrink-0",children:o}):null,e==="preview"&&a?i.jsx(id,{delayDuration:120,children:i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Reload website preview",onClick:a,children:i.jsx(_A,{})})}),i.jsx(Gi,{children:"Reload preview"})]})}):null]})})}function vCn(e,t,n,r,s){const a=[e,t,n,s,r??""].join("\0"),o=YL.get(a);if(o)return o;const l=En.createWorkspaceWebPreviewSession(e,{entryPath:t,networkMode:n,...r===void 0?{}:{htmlContent:r}});YL.set(a,l);const c=()=>{YL.get(a)===l&&YL.delete(a)};return l.then(c,c),l}function fat({organizationId:e,filePath:t,htmlContent:n,testIdPrefix:r="workspace-file",className:s,viewMode:a="preview",onViewModeChange:o=()=>{},networkMode:l,onNetworkModeChange:c,openAction:d}){const u=`${e}:${t}`,[f,A]=m.useState({identity:u,mode:BC}),[h,g]=m.useState(0),[x,y]=m.useState({status:"loading",session:null,error:null}),v=f.identity===u?f.mode:BC,w=l??v;m.useEffect(()=>{f.identity!==u&&A({identity:u,mode:BC})},[u,f.identity]),m.useEffect(()=>{let j=!1;return y({status:"loading",session:null,error:null}),vCn(e,t,w,n,h).then(C=>{j||y({status:"ready",session:C,error:null})}).catch(C=>{j||y({status:"error",session:null,error:C instanceof Error?C.message:"Website preview could not be started."})}),()=>{j=!0}},[t,n,w,e,h]);const k=j=>{x.status==="error"||j===w||(l===void 0&&A({identity:u,mode:j}),c==null||c(j))},O=()=>{l===void 0&&A({identity:u,mode:BC}),c==null||c(BC),g(j=>j+1)};return i.jsxs("div",{className:q("flex min-h-[420px] flex-1 flex-col bg-white",s),"data-testid":`${r}-html-preview-frame`,children:[i.jsx(nZ,{viewMode:a,onViewModeChange:o,networkMode:w,onNetworkModeChange:k,networkUnavailable:x.status==="error",onReload:()=>g(j=>j+1),openAction:d,testIdPrefix:r}),x.status==="loading"?i.jsxs("div",{className:"flex min-h-[384px] flex-1 items-center justify-center text-muted-foreground","data-testid":`${r}-html-preview-loading`,role:"status",children:[i.jsx(yn,{className:"h-5 w-5 animate-spin"}),i.jsx("span",{className:"sr-only",children:"Loading website preview"})]}):x.status==="error"?i.jsxs("div",{className:"flex min-h-[384px] flex-1 flex-col","data-testid":`${r}-html-preview-error`,children:[i.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border bg-muted/40 px-3 py-2",role:"alert",children:[i.jsxs("p",{className:"min-w-0 text-xs leading-5 text-muted-foreground",children:["Multi-file preview is unavailable. Showing a static Offline document. ",x.error]}),i.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:O,children:[i.jsx(_A,{"data-icon":"inline-start"}),"Retry"]})]}),i.jsx("iframe",{"data-testid":`${r}-html-preview`,"data-preview-fallback":"static",title:t||"Library static HTML preview",srcDoc:VMt(n??""),sandbox:"",referrerPolicy:"no-referrer",className:"block min-h-[336px] w-full flex-1 border-0 bg-white"})]}):i.jsx("iframe",{"data-testid":`${r}-html-preview`,title:t||"Library website preview",src:x.session.previewUrl,sandbox:w==="connected"?"allow-scripts":"",referrerPolicy:"no-referrer",className:"block min-h-[384px] w-full flex-1 border-0 bg-white"},x.session.previewUrl)]})}function Xk(e){const t=e.split("/").filter(Boolean),n=[];for(let r=0;r<t.length-1;r+=1)n.push(t.slice(0,r+1).join("/"));return new Set(n)}function Aat(e){const t=e.split("/").filter(Boolean),n=[];for(let r=0;r<t.length;r+=1)n.push(t.slice(0,r+1).join("/"));return new Set(n)}function dl(e){const t=(e==null?void 0:e.trim())??"";return t.length>0?t:null}const hat="rudder.workspace.launchTargetId",mat="rudder.workspace.unsupportedFileLaunchTargetId",wCn="rudder.workspace.openFileTabs",kCn=["cursor","vscode","windsurf","zed","webstorm","intellij","xcode","terminal","warp","commandPrompt","powershell","finder"],SCn={fileTarget:!0,id:"defaultApp",label:"Default app",kind:"app"};function f1e(e){return kCn.includes(e)}function OCn(e){return e.kind==="ide"&&e.id!=="xcode"}function fw(e){return"fileTarget"in e}function QT(e){return[SCn,...e.filter(OCn).map(t=>({fileTarget:!0,id:t.id,label:t.label,kind:"ide",workspaceTarget:t}))]}function jCn(e,t){if(!t.canOpenFile)return[];const n=QT(e);return t.canOpenLocation?[...n,...e.filter(r=>r.kind==="folder"||r.kind==="terminal")]:n}function CCn(e,t){return e.find(n=>n.id===t)??e.find(n=>n.id==="defaultApp")??null}function NCn(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(mat);return e==="defaultApp"||f1e(e)?e:null}catch{return null}}function PCn(e){if(!(typeof window>"u"))try{window.localStorage.setItem(mat,e)}catch{}}function ICn(){if(typeof window>"u")return null;const e=window.localStorage.getItem(hat);return f1e(e)?e:null}function KP(e){typeof window>"u"||window.localStorage.setItem(hat,e)}function Xoe(e){return e&&f1e(e)?e:null}function TCn(e){return e.defaultPrevented||e.altKey||e.shiftKey||!e.metaKey&&!e.ctrlKey?!1:e.key.toLowerCase()==="w"}function jU(e){const t=new Set,n=[];for(const r of e){const s=dl(r??null);!s||t.has(s)||(t.add(s),n.push(s))}return n.slice(-24)}function pat(e){return`${wCn}:${e}`}function E7(e,t){const n=jU([...e,t]),r=dl(t??null);return{openFilePaths:n,selectedFilePath:r&&n.includes(r)?r:n[0]??null}}function Goe(e){var t;if(!e||typeof window>"u")return E7([],null);try{const n=(t=window.sessionStorage)==null?void 0:t.getItem(pat(e)),r=n?JSON.parse(n):null;if(Array.isArray(r))return E7(r,r[0]);if(r&&typeof r=="object"){const s=r;return E7(Array.isArray(s.openFilePaths)?s.openFilePaths:[],typeof s.selectedFilePath=="string"?s.selectedFilePath:null)}}catch{return E7([],null)}return E7([],null)}function _Cn(e,t,n){var r;if(!(!e||typeof window>"u"))try{const s=E7(t,n);(r=window.sessionStorage)==null||r.setItem(pat(e),JSON.stringify(s))}catch{}}function MCn(e,t){return e.includes(t)?e:jU([...e,t])}const ECn={cursor:{src:"/brands/cursor-app-icon.svg"}},DCn={vscode:{label:"VS",className:"bg-[#0078d4] text-white"},windsurf:{label:"W",className:"bg-[#14b8a6] text-white"},zed:{label:"Z",className:"bg-[#171717] text-white"},webstorm:{label:"WS",className:"bg-[#ec4899] text-white"},intellij:{label:"IJ",className:"bg-[#f97316] text-white"},xcode:{label:"XC",className:"bg-[#147efb] text-white"},commandPrompt:{label:"CMD",className:"bg-[#111827] text-white"},powershell:{label:"PS",className:"bg-[#2563eb] text-white"}};function B2({target:e,className:t}){const[n,r]=m.useState(!1),[s,a]=m.useState(!1),o=fw(e)?e.workspaceTarget:e,l=q("inline-flex h-5 w-5 shrink-0 items-center justify-center",t);if(o!=null&&o.iconDataUrl&&!n)return i.jsx("span",{"aria-hidden":"true",className:l,"data-workspace-launch-target-icon":e.id,children:i.jsx("img",{src:o.iconDataUrl,alt:"",className:"h-full w-full object-contain",onError:()=>r(!0)})});const c=o?ECn[o.id]:null;if(c&&!s)return i.jsx("span",{"aria-hidden":"true",className:l,"data-workspace-launch-target-icon":e.id,"data-fallback-icon":"true","data-brand-fallback":"true",children:i.jsx("img",{src:c.src,alt:"",className:"h-full w-full object-contain",onError:()=>a(!0)})});const d=o?DCn[o.id]:null;if(d)return i.jsx("span",{"aria-hidden":"true",className:q("inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[5px] border border-[color:var(--border-base)] text-[9px] font-semibold leading-none",d.className,t),"data-workspace-launch-target-icon":e.id,"data-fallback-icon":"true","data-app-specific-fallback":"true",children:d.label});const u=e.kind==="terminal"?pM:e.kind==="folder"?q2:e.kind==="app"?La:tue;return i.jsx("span",{"aria-hidden":"true",className:q("inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[5px] border border-[color:var(--border-base)] bg-[color:var(--surface-page)] text-foreground",t),"data-workspace-launch-target-icon":e.id,"data-fallback-icon":"true",children:i.jsx(u,{className:"h-[72%] w-[72%]"})})}function Yoe({rootPath:e,targets:t,openingTargetId:n,onOpenTarget:r,className:s,contentAlign:a="end",testId:o="org-workspaces-launcher",targetTestIdPrefix:l="org-workspaces-launch-target"}){return t.length===0?null:i.jsxs(Mi,{children:[i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(Ei,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:q("h-7 w-7 rounded-md text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground",s),"aria-label":"Open Library menu",disabled:n!==null,"data-testid":o,children:n?i.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(La,{className:"h-3.5 w-3.5"})})})}),i.jsx(Gi,{children:"Open Library"})]}),i.jsx(Di,{align:a,sideOffset:8,className:"w-60 whitespace-nowrap p-1",children:t.map(c=>i.jsxs(Gt,{className:"h-9 gap-2 rounded-[6px]",disabled:n!==null,"data-testid":`${l}-${c.id}`,onSelect:()=>{r(e,c,"workspace")},children:[n===c.id?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(B2,{target:c}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:c.label}),i.jsx("span",{className:"text-[11px] capitalize text-muted-foreground",children:c.kind})]},c.id))})]})}function RCn({targets:e,currentTarget:t,openingTargetId:n,onOpenTarget:r}){const s=n!==null;return i.jsx("div",{className:"flex h-full min-h-[360px] items-center justify-center px-6 py-10",children:i.jsxs("div",{className:"flex max-w-md flex-col items-center text-center",children:[i.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"This file can’t be previewed or edited in Rudder."}),t&&e.length>0?i.jsxs("div",{className:"mt-4 inline-flex h-9 items-stretch rounded-md border border-[color:var(--border-base)] bg-[color:var(--surface-page)]",children:[i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-10 rounded-r-none border-r border-[color:var(--border-base)]","aria-label":`Open file with ${t.label}`,disabled:s,"data-testid":"org-workspaces-unsupported-file-open-current",onClick:()=>r(t),children:s?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(B2,{target:t})})}),i.jsx(Gi,{className:"pointer-events-none",children:`Open with ${t.label}`})]}),i.jsxs(Mi,{children:[i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(Ei,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-8 rounded-l-none","aria-label":"Choose how to open file",disabled:s,"data-testid":"org-workspaces-unsupported-file-launcher",children:i.jsx(Br,{className:"h-3.5 w-3.5"})})})}),i.jsx(Gi,{className:"pointer-events-none",children:"Choose how to open file"})]}),i.jsx(Di,{align:"center",sideOffset:8,className:"w-60 whitespace-nowrap p-1",children:e.map(a=>i.jsxs(Gt,{className:"h-9 gap-2 rounded-[6px]",disabled:s,"data-testid":`org-workspaces-unsupported-file-target-${a.id}`,onSelect:()=>r(a),children:[n===a.id?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(B2,{target:a}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.label})]},a.id))})]})]}):null]})})}function LCn({onOpenInLibrary:e,targets:t,openingTargetId:n,onOpenTarget:r,testId:s="workspace-file-open-menu"}){return t.length===0?null:i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1 px-2","aria-label":"Open file options",disabled:n!==null,"data-testid":s,children:[n?i.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(La,{className:"h-3.5 w-3.5"}),i.jsx("span",{children:"Open"}),i.jsx(Br,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),i.jsxs(Di,{align:"center",sideOffset:8,className:"w-60 whitespace-nowrap p-1",children:[e?i.jsxs(Gt,{className:"h-9 gap-2 rounded-[6px]",onSelect:e,children:[i.jsx(dM,{className:"h-4 w-4","aria-hidden":!0}),i.jsx("span",{children:"Open in Library"})]}):null,t.map(a=>i.jsxs(Gt,{className:"h-9 gap-2 rounded-[6px]",disabled:n!==null,"data-testid":`${s}-target-${a.id}`,onSelect:()=>r(a),children:[i.jsx(B2,{target:a}),i.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.label})]},a.id))]})]})}const zCn="/assets/pdf.worker.min-yatZIOMy.mjs",$Cn=640,O9e=280,FCn=2,j9e=16384,BCn=16777216,C9e=16384,gat=.6,xat=2,N9e=.2;let P9e=null;function QCn(){return P9e??(P9e=Wt(()=>import("./pdf-CcZYcL52.js"),[]).then(e=>(e.GlobalWorkerOptions.workerSrc=zCn,e))),P9e}function I9e(e){return Math.min(xat,Math.max(gat,e))}function bat({className:e,showOpenAction:t=!1,src:n,testId:r,title:s}){const a=m.useRef(null),o=m.useRef(null),l=m.useRef(null),[c,d]=m.useState($Cn),[u,f]=m.useState(null),[A,h]=m.useState(null),[g,x]=m.useState(!0),[y,v]=m.useState(1),[w,k]=m.useState(""),[O,j]=m.useState(null),[C,N]=m.useState(!1),[I,E]=m.useState(1),_=(u==null?void 0:u.numPages)??0;return m.useEffect(()=>{const T=a.current;if(!T)return;const R=(U=T.getBoundingClientRect().width)=>{U>0&&d(Math.max(O9e,U))},M=()=>R();if(R(),typeof ResizeObserver>"u")return window.addEventListener("resize",M),()=>window.removeEventListener("resize",M);const L=new ResizeObserver(U=>{var B;R((B=U[0])==null?void 0:B.contentRect.width)});return L.observe(T),()=>L.disconnect()},[]),m.useEffect(()=>{let T=!1,R=null;return f(null),h(null),x(!0),v(1),k(""),j(null),E(1),QCn().then(M=>T?null:(R=M.getDocument({url:n,withCredentials:!0}),R.promise)).then(M=>{if(M){if(T){R==null||R.destroy();return}f(M),x(!1)}}).catch(M=>{T||(h(M instanceof Error?M.message:"The PDF could not be loaded."),x(!1))}),()=>{var M;T=!0,(M=l.current)==null||M.cancel(),l.current=null,R&&R.destroy()}},[n]),m.useEffect(()=>{var R;if(!u)return;let T=!1;return(R=l.current)==null||R.cancel(),l.current=null,h(null),j(null),N(!0),u.getPage(y).then(async M=>{if(T)return;const L=o.current;if(!L)return;const U=L.getContext("2d");if(!U)throw new Error("Canvas rendering is unavailable.");const B=M.getViewport({scale:1}),J=Math.max(O9e-32,c-32)/B.width*I,F=M.getViewport({scale:J}),Q=Math.min(1,C9e/Math.max(1,F.width),C9e/Math.max(1,F.height)),W=J*Q,$=Q<1?M.getViewport({scale:W}):F,ee=Math.min(window.devicePixelRatio||1,FCn),re=M.getViewport({scale:W*ee}),ne=re.width*re.height,te=Math.min(1,Math.sqrt(BCn/Math.max(1,ne)),j9e/Math.max(1,re.width),j9e/Math.max(1,re.height)),ce=te<1?M.getViewport({scale:W*ee*te}):re;L.width=Math.max(1,Math.floor(ce.width)),L.height=Math.max(1,Math.floor(ce.height)),L.style.width=`${Math.floor($.width)}px`,L.style.height=`${Math.floor($.height)}px`;const se=M.render({canvasContext:U,viewport:ce});l.current=se,await se.promise,T||j(y)}).catch(M=>{T||M instanceof Error&&M.name==="RenderingCancelledException"||h(M instanceof Error?M.message:"The PDF page could not be rendered.")}).finally(()=>{T||N(!1)}),()=>{var M;T=!0,(M=l.current)==null||M.cancel(),l.current=null}},[c,u,y,I]),m.useEffect(()=>{if(!u)return;let T=!1;return k(""),u.getPage(y).then(R=>R.getTextContent()).then(R=>R.items.map(M=>"str"in M?M.str:"").filter(Boolean).join(" ").trim()).then(R=>{T||k(R)}).catch(()=>{T||k("")}),()=>{T=!0}},[u,y]),i.jsxs("div",{className:q("flex min-h-0 flex-1 flex-col bg-[color:var(--surface-page)]",e),"data-pdf-src":n,"data-testid":r,children:[i.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Previous PDF page",title:"Previous page",disabled:g||y<=1,onClick:()=>v(T=>Math.max(1,T-1)),children:i.jsx(iM,{className:"h-4 w-4"})}),i.jsx("span",{className:"w-20 text-center text-xs tabular-nums text-muted-foreground","data-testid":`${r}-page-indicator`,children:_>0?`${y} / ${_}`:"- / -"}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Next PDF page",title:"Next page",disabled:g||y>=_,onClick:()=>v(T=>Math.min(_,T+1)),children:i.jsx(_i,{className:"h-4 w-4"})})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Zoom out PDF",title:"Zoom out",disabled:g||I<=gat,onClick:()=>E(T=>I9e(T-N9e)),children:i.jsx(D9t,{className:"h-4 w-4"})}),i.jsxs("span",{className:"w-10 text-center text-xs tabular-nums text-muted-foreground",children:[Math.round(I*100),"%"]}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Zoom in PDF",title:"Zoom in",disabled:g||I>=xat,onClick:()=>E(T=>I9e(T+N9e)),children:i.jsx(M9t,{className:"h-4 w-4"})}),t?i.jsxs("a",{href:n,target:"_blank",rel:"noreferrer",className:"ml-1 inline-flex h-7 items-center gap-1.5 rounded-[4px] px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[i.jsx(La,{className:"h-3.5 w-3.5","aria-hidden":"true"}),i.jsx("span",{children:"Open"})]}):null]})]}),i.jsxs("div",{ref:a,className:"scrollbar-auto-hide relative flex min-h-[360px] flex-1 items-start justify-center overflow-auto bg-[#ececec] p-4 dark:bg-[#202020]",role:"region","aria-label":`PDF preview: ${s}`,children:[i.jsx("canvas",{ref:o,"aria-hidden":"true",className:q("block max-w-none bg-white shadow-[0_1px_4px_rgba(0,0,0,0.2)]",O===y?"visible":"invisible"),"data-rendered-page":O??void 0,"data-testid":`${r}-canvas`}),O===y?i.jsxs("p",{className:"sr-only","data-testid":`${r}-text-content`,children:["Page ",y," of ",_,". ",w||"This page contains no extractable text."]}):null,g||C?i.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted-foreground",role:"status","aria-label":"Loading PDF preview",children:i.jsx(yn,{className:"h-5 w-5 animate-spin"})}):null,A?i.jsxs("div",{className:"absolute inset-0 flex items-center justify-center px-6 text-center text-sm text-muted-foreground",role:"alert",children:["Could not preview this PDF. ",A]}):null]})]})}function yat({kind:e,src:t,contentType:n,title:r,openAction:s,className:a,testId:o="workspace-media-preview"}){const l=`${e}:${t}`,[c,d]=m.useState(null),u=c===l,f=`${r||`Library ${e}`} ${e} preview`,A=e==="video"?rue:nue,h=i.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i.jsx(ie,{asChild:!0,variant:"outline",size:"sm",className:"h-8 gap-1.5",children:i.jsxs("a",{href:t,download:!0,children:[i.jsx(pg,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Download"]})}),s]});return m.useEffect(()=>{d(null)},[l]),u?i.jsx("div",{className:q("flex min-h-[320px] flex-1 items-center justify-center px-6 py-10",a),"data-testid":`${o}-fallback`,role:"alert",children:i.jsxs("div",{className:"flex max-w-md flex-col items-center text-center",children:[i.jsx(A,{className:"h-8 w-8 text-muted-foreground","aria-hidden":"true"}),i.jsxs("p",{className:"mt-3 text-sm font-medium text-foreground",children:["This ",e," can’t be played in this browser."]}),i.jsx("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"The file may use a codec your browser does not support. Download it or open it with another app."}),i.jsx("div",{className:"mt-4",children:h})]})}):i.jsxs("div",{className:q("flex min-h-[320px] min-w-0 flex-1 flex-col bg-accent/10",a),"data-testid":`${o}-frame`,"data-workspace-media-preview":e,children:[i.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-4",children:e==="video"?i.jsx("video",{"aria-label":f,className:"h-auto w-full max-h-full max-w-5xl rounded-md bg-black shadow-sm",controls:!0,playsInline:!0,preload:"metadata",src:t,"data-content-type":n??void 0,"data-testid":o,onError:()=>d(l),onLoadedMetadata:()=>d(null)},l):i.jsx("audio",{"aria-label":f,className:"w-full max-w-2xl",controls:!0,preload:"metadata",src:t,"data-content-type":n??void 0,"data-testid":o,onError:()=>d(l),onLoadedMetadata:()=>d(null)},l)}),i.jsx("div",{className:"shrink-0 border-t border-[color:var(--border-soft)] bg-[color:var(--surface-page)] px-3 py-2",children:h})]})}function UCn({cacheKey:e,kind:t,src:n,contentType:r,title:s,targets:a,openingTargetId:o,onOpenTarget:l,scrollRef:c}){return t==="pdf"?i.jsx("div",{ref:c,"data-testid":"org-workspaces-pdf-preview-scroll",className:"scrollbar-auto-hide flex h-full min-h-[420px] flex-col overflow-hidden bg-[color:var(--surface-page)]",children:i.jsx(bat,{className:"h-full min-h-[420px]",showOpenAction:!0,src:n,testId:"org-workspaces-pdf-preview",title:s})}):i.jsx(yat,{kind:t,src:n,contentType:r,title:s,openAction:i.jsx(LCn,{targets:a,openingTargetId:o,onOpenTarget:l,testId:"org-workspaces-media-open-menu"}),className:"h-full min-h-[420px]",testId:`org-workspaces-${t}-preview`},e)}const VCn=[".md",".markdown",".mdown",".mdx"],qCn=[".csv"],KCn=500,WCn=100;function vat(e){var t;return((t=e==null?void 0:e.toLowerCase().split(";")[0])==null?void 0:t.trim())??""}function wat(e,t){const n=(e==null?void 0:e.toLowerCase())??"";return t.some(r=>n.endsWith(r))}function kat(e){return e.previewKind==="text"&&e.content!==null&&(wat(e.filePath,VCn)||vat(e.contentType)==="text/markdown")}function Sat(e){return e.previewKind==="text"&&e.content!==null&&(wM(e.filePath)||W$e(e.contentType))}function Oat(e){return e.previewKind==="text"&&e.content!==null&&(wat(e.filePath,qCn)||vat(e.contentType)==="text/csv")}function ZCn({content:e,testId:t}){const n=d1e(e),r=n.rows.slice(0,KCn+1);let s=1;for(const A of r)s=Math.max(s,A.length);const{rows:a,columnCount:o}=u1e(r.map(A=>A.slice(0,WCn))),l=a[0]??Array.from({length:o},()=>""),c=a.slice(1),d=Math.max(0,n.rows.length-1-c.length),u=Math.max(0,s-o),f=[d>0?`${d.toLocaleString()} more data rows`:null,u>0?`${u.toLocaleString()} more columns`:null].filter(A=>A!==null);return i.jsxs("div",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-auto","data-testid":t,role:"region","aria-label":"CSV preview",children:[i.jsxs("table",{className:"w-max min-w-full border-separate border-spacing-0 text-left text-sm","aria-label":"CSV preview table",children:[i.jsxs("caption",{className:"sr-only",children:["CSV preview with ",n.rows.length," rows and ",o," visible columns"]}),i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",className:"sticky left-0 top-0 z-20 w-12 border-b border-r border-border bg-[color:var(--surface-page)] px-3 py-2 text-center text-xs font-medium text-muted-foreground",children:"#"}),l.map((A,h)=>i.jsx("th",{scope:"col",className:"sticky top-0 z-10 min-w-[10rem] border-b border-r border-border bg-[color:var(--surface-page)] px-3 py-2 font-semibold text-foreground",children:A||`Column ${h+1}`},h))]})}),i.jsx("tbody",{children:c.map((A,h)=>i.jsxs("tr",{children:[i.jsx("th",{scope:"row",className:"sticky left-0 z-10 border-b border-r border-border bg-[color:var(--surface-page)] px-3 py-2 text-center text-xs font-medium text-muted-foreground",children:h+2}),A.map((g,x)=>i.jsx("td",{className:"max-w-[28rem] whitespace-pre-wrap border-b border-r border-border px-3 py-2 align-top leading-6 text-foreground",children:g},x))]},h))})]}),f.length>0?i.jsxs("p",{className:"sticky bottom-0 border-t border-border bg-[color:var(--surface-page)] px-4 py-2 text-xs text-muted-foreground",role:"status",children:["Showing a bounded table preview. Open Source to inspect ",f.join(" and "),"."]}):null]})}function jat({file:e,organizationId:t,mode:n="preview",onModeChange:r=()=>{},htmlOpenAction:s,mediaOpenAction:a,testIdPrefix:o="workspace-file"}){const l=`${t}:${e.filePath}`,[c,d]=m.useState({identity:l,mode:"connected"}),u=c.identity===l?c.mode:"connected";return m.useEffect(()=>{d(f=>f.identity===l?f:{identity:l,mode:"connected"})},[l]),e.previewKind==="text"&&e.content!==null?Sat(e)?n==="preview"?i.jsx(fat,{organizationId:t,filePath:e.filePath,htmlContent:e.content,viewMode:n,onViewModeChange:r,networkMode:u,onNetworkModeChange:f=>{d({identity:l,mode:f})},openAction:s,testIdPrefix:o},`${t}:${e.filePath}`):i.jsxs("div",{className:"flex min-h-[420px] flex-1 flex-col","data-testid":`${o}-html-source-frame`,children:[i.jsx(nZ,{viewMode:n,onViewModeChange:r,openAction:s,testIdPrefix:o}),i.jsx(BT,{"data-testid":`${o}-code-preview`,ariaLabel:`${e.filePath||"Library file"} source`,filePath:e.filePath,value:e.content,readOnly:!0})]}):kat(e)?i.jsx("article",{className:"scrollbar-auto-hide min-h-0 min-w-0 flex-1 overflow-y-auto px-5 py-5","data-testid":`${o}-markdown-preview`,"aria-label":`${e.filePath||"Library file"} preview`,children:i.jsx(Bo,{className:"rudder-library-document-editor rudder-readable-document rudder-side-panel-library-document mx-auto w-full max-w-[880px] text-[15px] leading-7 text-foreground",enableCodeBlockCopy:!0,children:e.content})}):Oat(e)&&n==="preview"?i.jsx(ZCn,{content:e.content,testId:`${o}-csv-preview`}):i.jsx(BT,{"data-testid":`${o}-code-preview`,ariaLabel:`${e.filePath||"Library file"} source`,filePath:e.filePath,value:e.content,readOnly:!0}):e.previewKind==="image"&&e.contentPath?i.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-4","data-testid":`${o}-image-preview-frame`,children:i.jsx(H2,{"data-testid":`${o}-image-preview`,src:e.contentPath,alt:e.filePath,name:e.filePath||"Library image preview",className:"max-h-full max-w-full object-contain",previewTestId:`${o}-image-preview-dialog`,previewTitleFallback:"Library image preview",triggerClassName:"max-h-full",wrapperClassName:"max-h-full"})}):e.previewKind==="pdf"&&e.contentPath?i.jsx("div",{className:"flex min-h-[420px] flex-1","data-testid":`${o}-pdf-preview-frame`,children:i.jsx(bat,{className:"min-h-[420px]",src:e.contentPath,testId:`${o}-pdf-preview`,title:e.filePath||"Library PDF preview"})}):(e.previewKind==="video"||e.previewKind==="audio")&&e.contentPath?i.jsx(yat,{kind:e.previewKind,src:e.contentPath,contentType:e.contentType,title:e.filePath||`Library ${e.previewKind}`,openAction:a,testId:`${o}-${e.previewKind}-preview`},`${t}:${e.filePath}`):i.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-center","data-testid":`${o}-preview-unavailable`,children:i.jsx("p",{className:"max-w-sm text-sm leading-6 text-muted-foreground",children:e.message??"No inline preview is available for this file."})})}const QC="desktop-local-file";function HCn(e){return e.base64?`data:${e.contentType};base64,${e.base64}`:null}function XCn(e){return{source:"org_root",rootPath:e.parentPath,repoUrl:null,filePath:e.canonicalPath,libraryEntryId:null,mentionHref:null,markdownLink:null,rootExists:!0,content:e.content,contentType:e.contentType,previewKind:e.previewKind==="image"||e.previewKind==="pdf"?e.previewKind:"text",contentPath:HCn(e),message:null,truncated:e.truncated}}function GCn(e,t){const n=e instanceof Error?e.message:"";return/\bENOENT\b|no such file or directory/iu.test(n)?"Could not resolve the file location recorded by this run. The file may have moved, or an older transcript may not include the command's original working directory.":n||`Could not preview ${t}.`}function YCn({preview:e,sourceConversationId:t,onPreviewChange:n}){const r=Pn(),s=e.content??"",o=m.useRef($it(QC,e.canonicalPath,s)).current,l=m.useRef(o.baseContent),c=m.useRef(o.content),d=m.useRef(s),u=m.useRef(!1),f=m.useRef(null),A=m.useRef(o.conflicted),[h,g]=m.useState(o.content),[x,y]=m.useState(o.conflicted?"error":o.content===s?"saved":"saving"),[v,w]=m.useState(o.conflicted?"This file changed outside Rudder. Choose which version to keep.":null),[k,O]=m.useState(o.conflicted),j=m.useRef(null),[C,N]=m.useState(null),I=m.useCallback(U=>{const B=U.content??c.current;l.current=B,d.current=B,A.current=!1,O(!1),w(null),n(U),Dy(QC,e.canonicalPath,B,c.current),c.current!==B&&(f.current=c.current)},[n,e.canonicalPath]);m.useEffect(()=>()=>{Dy(QC,e.canonicalPath,l.current,c.current)},[e.canonicalPath]);const E=m.useCallback(async()=>{if(!(!r||u.current)){u.current=!0;try{for(;f.current!==null;){const U=f.current;if(f.current=null,!(A.current||U===l.current)){y("saving"),w(null);try{const B=await r.updateLocalFile(e.canonicalPath,{content:U,expectedContent:l.current,writeCapability:e.writeCapability??""});I(B)}catch(B){let z=null;try{z=await r.previewLocalFile(e.canonicalPath)}catch{}if((z==null?void 0:z.content)===U){I(z);continue}z&&z.content!==null&&z.content!==l.current&&(d.current=z.content,A.current=!0,O(!0)),y("error"),w(A.current?"This file changed outside Rudder. Choose which version to keep.":B instanceof Error?B.message:"Could not save this file.");return}}}y(c.current===l.current?"saved":"saving")}finally{u.current=!1,f.current!==null&&!A.current&&E()}}},[I,r,e.canonicalPath]);m.useEffect(()=>{if(Dy(QC,e.canonicalPath,l.current,h),A.current||h===l.current)return;y("saving");const U=window.setTimeout(()=>{f.current=h,E()},700);return()=>window.clearTimeout(U)},[h,E,e.canonicalPath]);const _=U=>{c.current=U,g(U),y(A.current?"error":"saving"),A.current||w(null)},T=()=>{l.current=d.current,A.current=!1,O(!1),y("saving"),w(null),f.current=c.current,E()},R=()=>{const U=d.current;l.current=U,c.current=U,f.current=null,A.current=!1,O(!1),g(U),y("saved"),w(null),r4(QC,e.canonicalPath)},M=()=>{f.current=c.current,E()},L=e.previewKind==="markdown"?r1e(h):{frontmatter:null,separator:"",body:h};return i.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col","data-testid":"chat-side-panel-local-file-editor",children:[e.previewKind==="markdown"?i.jsxs("div",{ref:j,className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-5 pb-16 pt-5",children:[L.frontmatter!==null?i.jsxs("details",{className:"group mb-6 rounded-md border border-border bg-muted/20","data-chat-annotation-ignore":!0,children:[i.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-muted-foreground [&::-webkit-details-marker]:hidden",children:[i.jsx("span",{children:"Frontmatter"}),i.jsx(_i,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-90"})]}),i.jsx("textarea",{value:L.frontmatter,onChange:U=>_(kU(U.currentTarget.value,L.separator,L.body)),spellCheck:!1,className:"block min-h-28 w-full resize-y border-t border-border bg-transparent px-3 py-2 font-mono text-xs leading-5 text-foreground outline-none","aria-label":"Frontmatter"})]}):null,i.jsx(Au,{engine:"milkdown",value:L.body,onChange:U=>_(kU(L.frontmatter,L.separator,U)),bordered:!1,placeholder:"Write in Markdown...",contentClassName:"rudder-library-document-editor rudder-readable-document rudder-side-panel-library-document mx-auto min-h-[420px] w-full max-w-[880px] text-[15px] leading-7 text-foreground"},e.canonicalPath)]}):i.jsx("div",{ref:j,className:"min-h-0 flex-1 pb-14",children:i.jsx(BT,{"data-testid":"chat-side-panel-local-file-source-editor",annotationSource:{surface:"local_file",sourceFilePath:e.canonicalPath},ariaLabel:`${e.fileName} source editor`,filePath:e.canonicalPath,value:h,onChange:_,onSelectionChange:N})}),i.jsx(qQe,{containerRef:j,conversationId:t,explicitSelection:e.previewKind==="markdown"?void 0:C,saved:x==="saved"&&!k&&h===l.current,source:h,sourceIdentity:{surface:"local_file",sourceFilePath:e.canonicalPath},sourceRenderMode:e.previewKind==="markdown"?"markdown":"text",renderedSource:e.previewKind==="markdown"?L.body:h,renderedSourceOffset:e.previewKind==="markdown"?h.length-L.body.length:0}),i.jsxs("div",{className:`absolute bottom-3 left-3 z-10 flex min-h-8 items-center gap-2 rounded-md border border-border bg-[color:var(--surface-elevated)] px-2.5 text-xs shadow-sm ${x==="error"?"text-destructive":"text-muted-foreground"}`,role:x==="error"?"alert":"status",title:v??void 0,children:[i.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${x==="error"?"bg-destructive":x==="saving"?"bg-[color:var(--accent-strong)]":"bg-emerald-500"}`}),i.jsx("span",{children:k?"Conflict":x==="error"?"Save failed":x==="saving"?"Saving":"Saved"}),k?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:T,children:"Keep mine"}),i.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:R,children:"Use latest"})]}):x==="error"?i.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:M,children:"Retry"}):null]})]})}function JCn({targetPath:e,label:t,sourceConversationId:n=null}){const r=Pn(),[s,a]=m.useState(null),[o,l]=m.useState(()=>r?null:"Local file previews are available in the Rudder Desktop app."),[c,d]=m.useState(!!r);m.useEffect(()=>{let A=!1;if(!r){a(null),d(!1),l("Local file previews are available in the Rudder Desktop app.");return}return d(!0),l(null),r.previewLocalFile(e).then(h=>{A||a(h)}).catch(h=>{A||(a(null),l(GCn(h,t)))}).finally(()=>{A||d(!1)}),()=>{A=!0}},[r,t,e]);const u=m.useMemo(()=>s?XCn(s):null,[s]),f=async()=>{if(!(!r||!s))try{await r.openPath(s.canonicalPath)}catch(A){l(A instanceof Error?A.message:`Could not open ${t}.`)}};return c?i.jsxs("div",{className:"flex min-h-[16rem] items-center justify-center text-sm text-muted-foreground",role:"status",children:[i.jsx(yn,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":!0}),"Loading ",t]}):o||!s||!u?i.jsx("div",{className:"p-4",children:i.jsx("div",{role:"alert",className:"rounded-[var(--radius-md)] border border-border bg-muted/20 px-3 py-3 text-sm text-muted-foreground",children:o??`Could not preview ${t}.`})}):i.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-testid":"chat-side-panel-local-file-view",children:[i.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b border-border px-4 py-3",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:s.fileName||t}),i.jsx("div",{className:"truncate text-xs text-muted-foreground",title:s.parentPath,children:s.parentPath})]}),i.jsxs("button",{type:"button",className:"inline-flex h-8 items-center gap-1.5 rounded-[var(--radius-sm)] border border-border px-2.5 text-xs text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",onClick:()=>void f(),children:[i.jsx(La,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Open"]})]}),s.truncated?i.jsx("div",{className:"shrink-0 border-b border-border bg-amber-500/10 px-4 py-2 text-xs text-amber-800 dark:text-amber-200",role:"status",children:"Showing a bounded preview. Open the file to inspect the complete content."}):null,!s.truncated&&s.content!==null?i.jsx(YCn,{preview:s,sourceConversationId:n,onPreviewChange:a}):i.jsx(jat,{file:u,organizationId:"local-transcript-file",testIdPrefix:"transcript-local-file"})]})}function CU(e){return Array.isArray(e)?`[${e.map(CU).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).filter(([,n])=>n!==void 0).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>`${JSON.stringify(n)}:${CU(r)}`).join(",")}}`:JSON.stringify(e)}function eNn(e){const t=Math.max(0,e.debounceMs??350),n=e.retryDelaysMs??[120,400],r=Math.max(1,e.maxRememberedSuccesses??32),s=new Map,a=new Map,o=new Set,l=(x,y)=>{for(a.delete(x),a.set(x,y);a.size>r;){const v=a.keys().next().value;if(v===void 0)break;a.delete(v)}},c=x=>{const y=s.get(x);if(y)return y;const v={timer:null,pending:null,failed:null,running:null};return s.set(x,v),v},d=x=>new Promise(y=>{setTimeout(y,Math.max(0,x))}),u=x=>{const y=s.get(x);if(!y)return Promise.resolve();if(o.has(x))return y.running??Promise.resolve();if(y.timer&&(clearTimeout(y.timer),y.timer=null),y.running)return y.running;if(!y.pending&&y.failed&&(y.pending=y.failed,y.failed=null),!y.pending)return Promise.resolve();const v=(async()=>{for(;y.pending&&!o.has(x);){let w=y.pending;y.pending=null;let k=!1;for(let O=0;O<=n.length&&!o.has(x);O+=1){y.pending&&(w=y.pending,y.pending=null,O=0);try{if(await e.update(w.organizationId,w.savedViewId,w.metadata),o.has(x))break;l(x,w.fingerprint),y.failed=null,k=!0;break}catch{if(o.has(x))break;if(O>=n.length){y.failed=y.pending??w,y.pending=null;break}await d(n[O]??0)}}if(o.has(x)){y.pending=null,y.failed=null;break}if(!k&&!y.pending)break}})();return y.running=v,v.finally(()=>{y.running===v&&(y.running=null),o.has(x)&&s.delete(x)}),v},f=x=>{if(o.has(x.savedViewId))return;const y=CU(x.metadata),v=a.get(x.savedViewId),w=s.get(x.savedViewId);if(v?v===y:!w&&y===CU(x.persistedMetadata))return;const k=c(x.savedViewId);k.pending={organizationId:x.organizationId,savedViewId:x.savedViewId,metadata:x.metadata,fingerprint:y},k.failed=null,!k.running&&(k.timer&&clearTimeout(k.timer),k.timer=setTimeout(()=>{k.timer=null,u(x.savedViewId)},t))},A=x=>{o.add(x),a.delete(x);const y=s.get(x);y&&(y.timer&&clearTimeout(y.timer),y.timer=null,y.pending=null,y.failed=null,y.running||s.delete(x))},h=async x=>{const y=s.get(x);if(y)for(await u(x);y.running||y.pending;)y.running&&await y.running,y.pending&&await u(x)};return{schedule:f,cancelSavedView:A,flushSavedView:h,flushAll:async()=>{await Promise.all([...s.keys()].map(h))}}}function Joe(e){return e.viewInstanceId??e.tabId}function T9e(e,t){return{target:{kind:"browser",tabId:e.tabId,url:e.url,viewInstanceId:Joe(e)},title:e.label,subtitle:e.url,favicon:e.favicon!==void 0?e.favicon:t.target.url===e.url?t.favicon:null}}function Cat({browserTargets:e,organizationId:t}){const n=Wn(),r=m.useMemo(()=>eNn({update:async(f,A,h)=>{await Es.updateSavedView(f,A,h),n.invalidateQueries({queryKey:V.messenger.customGroups(f)})}}),[n]),s=Te({queryKey:V.messenger.customGroups(t??"__none__"),queryFn:()=>Es.listCustomGroups(t),enabled:!!(t&&e.length>0)}),a=m.useMemo(()=>s.data&&!Array.isArray(s.data)?s.data.groups:[],[s.data]),o=m.useMemo(()=>a.flatMap(f=>f.entries).filter(f=>f.item.type==="saved_view"),[a]),l=m.useMemo(()=>new Set(o.map(f=>f.item.type==="saved_view"?f.item.savedView.id:"")),[o]),c=m.useRef(new Map);m.useLayoutEffect(()=>{var A,h;if(!t)return;const f=new Map;for(const g of e){const x=Joe(g),y=o.find(j=>j.item.type==="saved_view"&&j.item.savedView.targetPayload.kind==="browser"&&j.item.savedView.targetPayload.viewInstanceId===x),v=(y==null?void 0:y.item.type)==="saved_view"?y.item.savedView:null,w=(v==null?void 0:v.targetPayload.kind)==="browser"?{target:v.targetPayload,title:v.title,subtitle:v.subtitle,favicon:v.favicon}:null,k=(v==null?void 0:v.targetPayload.kind)==="browser"?v.id:s.isSuccess?null:((A=g.savedViewRecovery)==null?void 0:A.id)??null,O=w??(s.isSuccess?null:((h=g.savedViewRecovery)==null?void 0:h.persistedMetadata)??null);s.isSuccess&&g.savedViewRecovery&&!l.has(g.savedViewRecovery.id)&&r.cancelSavedView(g.savedViewRecovery.id),!(!k||!O)&&(f.set(x,{savedViewId:k,persistedMetadata:O}),r.schedule({organizationId:t,savedViewId:k,metadata:T9e(g,O),persistedMetadata:O}))}for(const[g,x]of c.current)f.has(g)||(s.isSuccess&&!l.has(x.savedViewId)?r.cancelSavedView(x.savedViewId):r.flushSavedView(x.savedViewId));c.current=f},[e,s.isSuccess,t,r,o,l]),m.useEffect(()=>()=>{r.flushAll()},[r]);const d=m.useCallback(f=>{const A=f.savedViewRecovery;if(s.isSuccess&&A&&!l.has(A.id))return r.cancelSavedView(A.id),Promise.resolve();const h=c.current.get(Joe(f)),g=h&&(!s.isSuccess||o.some(x=>x.item.type==="saved_view"&&x.item.savedView.id===h.savedViewId))?h:!s.isSuccess&&A?{savedViewId:A.id,persistedMetadata:A.persistedMetadata}:null;return!g||!t?Promise.resolve():(r.schedule({organizationId:t,savedViewId:g.savedViewId,metadata:T9e(f,g.persistedMetadata),persistedMetadata:g.persistedMetadata}),r.flushSavedView(g.savedViewId))},[s.isSuccess,t,r,o,l]);return{flushAll:m.useCallback(()=>r.flushAll(),[r]),flushTarget:d}}function DE(){const{data:e}=Te({queryKey:V.instance.profileSettings,queryFn:()=>fo.getProfile(),staleTime:Wo});return Dfe(e==null?void 0:e.nickname)}const NU="chatResponseAnnotationSource";function A1e(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Nat(e,t,n){return{...A1e(n),[NU]:{annotation:e,ordinal:t}}}function tNn(e){const t=A1e(e)[NU];if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t,r=VDe.safeParse(n.annotation);return!r.success||typeof n.ordinal!="number"||!Number.isInteger(n.ordinal)||n.ordinal<1?null:{annotation:r.data,ordinal:n.ordinal}}function nNn(e){const t=A1e(e);if(!(NU in t))return e;const{[NU]:n,...r}=t;return Object.keys(r).length>0?r:null}const rNn=YO("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-[calc(var(--radius-sm)-1px)] border px-2.5 py-1 text-xs font-medium whitespace-nowrap [&>svg]:size-3 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,background-color,border-color,box-shadow]",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-[color:color-mix(in_oklab,var(--border-soft)_94%,transparent)] bg-secondary text-secondary-foreground [a&]:hover:bg-[color:var(--surface-active)]",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/80",outline:"border-[color:var(--border-base)] bg-[color:color-mix(in_oklab,var(--surface-elevated)_98%,transparent)] text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"border-transparent bg-transparent [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function $i({className:e,variant:t="default",asChild:n=!1,...r}){const s=n?ice:"span";return i.jsx(s,{"data-slot":"badge","data-variant":t,className:q(rNn({variant:t}),e),...r})}function Zo({...e}){return i.jsx(XMe,{"data-slot":"select",...e})}function Pat({...e}){return i.jsx(m1t,{"data-slot":"select-group",...e})}function Ho({...e}){return i.jsx(YMe,{"data-slot":"select-value",...e})}function Xo({className:e,size:t="default",children:n,...r}){return i.jsxs(GMe,{"data-slot":"select-trigger","data-size":t,className:q("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-fit items-center justify-between gap-[var(--control-gap)] rounded-[var(--control-radius)] border bg-[color:var(--input-background)] px-[var(--control-padding-x-sm)] py-2 text-[length:var(--control-font-size)] whitespace-nowrap shadow-none transition-[color,box-shadow,border-color,background-color] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[var(--control-height-sm)] data-[size=sm]:h-[var(--control-height-xs)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-[var(--control-icon-size)]",e),...r,children:[n,i.jsx(JMe,{asChild:!0,children:i.jsx(Br,{className:"size-4 opacity-50"})})]})}function Go({className:e,children:t,position:n="item-aligned",align:r="center",...s}){return i.jsx(eEe,{children:i.jsxs(tEe,{"data-slot":"select-content",className:q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[var(--menu-min-width)] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-[var(--menu-radius)] border border-[color:var(--border-base)] shadow-[var(--shadow-md)]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:r,...s,children:[i.jsx(sNn,{}),i.jsx(nEe,{className:q("p-[var(--menu-padding)]",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),i.jsx(iNn,{})]})})}function Vs({className:e,children:t,icon:n,...r}){return i.jsxs(rEe,{"data-slot":"select-item",className:q("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex min-h-[var(--menu-item-min-height)] w-full cursor-default items-center gap-[var(--control-gap)] rounded-[var(--menu-item-radius)] py-[var(--menu-item-padding-y)] pr-8 pl-2 text-[length:var(--menu-item-font-size)] outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-[var(--control-icon-size)] *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[n?i.jsx("span",{"aria-hidden":"true",className:"flex size-4 shrink-0 items-center justify-center text-muted-foreground",children:n}):null,i.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:i.jsx(p1t,{children:i.jsx(Zi,{className:"size-4"})})}),i.jsx(sEe,{children:i.jsx("span",{className:"min-w-0 truncate",children:t})})]})}function sNn({className:e,...t}){return i.jsx(g1t,{"data-slot":"select-scroll-up-button",className:q("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(kq,{className:"size-4"})})}function iNn({className:e,...t}){return i.jsx(x1t,{"data-slot":"select-scroll-down-button",className:q("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(Br,{className:"size-4"})})}function ma({icon:e,message:t,action:n,onAction:r,className:s}){return i.jsxs("div",{className:q("surface-panel mx-auto flex max-w-xl flex-col items-center justify-center rounded-[var(--radius-xl)] px-8 py-14 text-center",s),children:[i.jsx("div",{className:"mb-5 flex h-16 w-16 items-center justify-center rounded-[calc(var(--radius-md)+4px)] border border-[color:var(--border-soft)] bg-[color:color-mix(in_oklab,var(--surface-proposal)_72%,transparent)]",children:i.jsx(e,{className:"h-8 w-8 text-[color:var(--accent-base)]"})}),i.jsx("p",{className:"font-display text-[1.5rem] leading-tight text-foreground",children:"Nothing here yet"}),i.jsx("p",{className:"mt-3 max-w-md text-sm leading-6 text-muted-foreground",children:t}),n&&r&&i.jsxs(ie,{onClick:r,className:"mt-6",children:[i.jsx(Ur,{className:"h-4 w-4 mr-1.5"}),n]})]})}function Oee(e){return e?typeof e=="string"?e:e.toISOString():null}function _9e(e){return e==="queued"||e==="running"}function Iat({issueId:e,orgId:t}){const n=Wn(),[r,s]=m.useState(new Set),{data:a}=Te({queryKey:V.issues.liveRuns(e),queryFn:()=>So.liveRunsForIssue(e),enabled:!!e,refetchInterval:3e3}),{data:o}=Te({queryKey:V.issues.activeRun(e),queryFn:()=>So.activeRunForIssue(e),enabled:!!e,refetchInterval:3e3}),l=m.useMemo(()=>{const g=new Map;for(const x of a??[])g.set(x.id,x);return o&&g.set(o.id,{id:o.id,status:o.status,invocationSource:o.invocationSource,triggerDetail:o.triggerDetail,startedAt:Oee(o.startedAt),finishedAt:Oee(o.finishedAt),createdAt:Oee(o.createdAt)??new Date().toISOString(),agentId:o.agentId,agentName:o.agentName,agentRuntimeType:o.agentRuntimeType,issueId:e}),[...g.values()].sort((x,y)=>new Date(y.createdAt).getTime()-new Date(x.createdAt).getTime())},[o,e,a]),{transcriptByRun:c,hasOutputForRun:d}=_E({runs:l,orgId:t}),u=l.some(g=>_9e(g.status)),{data:f}=Te({queryKey:V.agents.list(t??"__none__"),queryFn:()=>_n.list(t),enabled:!!t&&l.length>0}),A=m.useMemo(()=>new Map((f??[]).map(g=>[g.id,g])),[f]),h=async g=>{s(x=>new Set(x).add(g));try{await So.cancel(g),n.invalidateQueries({queryKey:V.issues.liveRuns(e)}),n.invalidateQueries({queryKey:V.issues.activeRun(e)})}finally{s(x=>{const y=new Set(x);return y.delete(g),y})}};return l.length===0?null:i.jsxs("div",{"data-active-surface":u?"live-run":void 0,className:q("overflow-hidden rounded-xl border border-cyan-500/25 bg-background/80 shadow-[0_18px_50px_rgba(6,182,212,0.08)]",u&&"active-surface-ring"),children:[i.jsxs("div",{className:"border-b border-border/60 bg-cyan-500/[0.04] px-4 py-3",children:[i.jsx("div",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-cyan-700 dark:text-cyan-300",children:"Live Runs"}),i.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Streamed with the same transcript UI used on the full run detail page."})]}),i.jsx("div",{className:"divide-y divide-border/60",children:l.map(g=>{const x=_9e(g.status),y=c.get(g.id)??[],v=A.get(g.agentId)??null,w=Aq(g.startedAt??g.createdAt,x?null:g.finishedAt);return i.jsxs("section",{className:"px-4 py-4",children:[i.jsxs("div",{className:"mb-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx(an,{to:`/agents/${g.agentId}`,className:"inline-flex hover:underline",children:v?i.jsx(uu,{name:v.name,icon:v.icon,role:v.role,size:"sm"}):i.jsx(Jd,{name:g.agentName,size:"sm"})}),i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[i.jsx(an,{to:`/agents/${g.agentId}/runs/${g.id}`,className:"inline-flex items-center rounded-full border border-border/70 bg-background/70 px-2 py-1 font-mono hover:border-cyan-500/30 hover:text-foreground",children:g.id.slice(0,8)}),i.jsx(Ds,{status:g.status}),i.jsx("span",{children:Ja(g.startedAt??g.createdAt)}),w?i.jsx("span",{children:x?`Live for ${w}`:`Ran for ${w}`}):null]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[x&&i.jsxs("button",{onClick:()=>h(g.id),disabled:r.has(g.id),className:"inline-flex items-center gap-1 rounded-full border border-red-500/20 bg-red-500/[0.06] px-2.5 py-1 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-500/[0.12] dark:text-red-300 disabled:opacity-50",children:[i.jsx(T3,{className:"h-2.5 w-2.5",fill:"currentColor"}),r.has(g.id)?"Stopping…":"Stop"]}),i.jsxs(an,{to:`/agents/${g.agentId}/runs/${g.id}`,className:"inline-flex items-center gap-1 rounded-full border border-border/70 bg-background/70 px-2.5 py-1 text-[11px] font-medium text-cyan-700 transition-colors hover:border-cyan-500/30 hover:text-cyan-600 dark:text-cyan-300",children:["Open run",i.jsx(La,{className:"h-3 w-3"})]})]})]}),i.jsx("div",{className:"max-h-[320px] overflow-y-auto pr-1",children:i.jsx(jg,{entries:y,density:"compact",limit:8,streaming:x,collapseStdout:!0,presentation:"chat",emptyMessage:d(g.id)?"Waiting for transcript parsing...":"Waiting for run output..."})})]},g.id)})})]})}function Co({variant:e="list"}){return e==="dashboard"?i.jsxs("div",{className:"space-y-6",children:[i.jsx(un,{className:"h-32 w-full border border-border"}),i.jsx("div",{className:"grid grid-cols-2 gap-2 xl:grid-cols-4",children:Array.from({length:4}).map((t,n)=>i.jsx(un,{className:"h-24 w-full"},n))}),i.jsx("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:Array.from({length:4}).map((t,n)=>i.jsx(un,{className:"h-44 w-full"},n))}),i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsx(un,{className:"h-72 w-full"}),i.jsx(un,{className:"h-72 w-full"})]})]}):e==="approvals"?i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsx(un,{className:"h-9 w-44"})}),i.jsx("div",{className:"grid gap-3",children:Array.from({length:3}).map((t,n)=>i.jsx(un,{className:"h-36 w-full"},n))})]}):e==="costs"?i.jsxs("div",{className:"space-y-6",children:[i.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Array.from({length:6}).map((t,n)=>i.jsx(un,{className:"h-9 w-28"},n))}),i.jsx(un,{className:"h-40 w-full"}),i.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[i.jsx(un,{className:"h-72 w-full"}),i.jsx(un,{className:"h-72 w-full"})]})]}):e==="inbox"?i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(un,{className:"h-9 w-56"}),i.jsx(un,{className:"h-8 w-40"})]}),i.jsx("div",{className:"space-y-5",children:Array.from({length:3}).map((t,n)=>i.jsxs("div",{className:"space-y-2",children:[i.jsx(un,{className:"h-4 w-40"}),i.jsx("div",{className:"space-y-1 border border-border",children:Array.from({length:3}).map((r,s)=>i.jsx(un,{className:"h-14 w-full rounded-none"},s))})]},n))})]}):e==="detail"?i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx(un,{className:"h-3 w-64"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(un,{className:"h-6 w-6"}),i.jsx(un,{className:"h-6 w-6"}),i.jsx(un,{className:"h-7 w-48"})]}),i.jsx(un,{className:"h-4 w-40"})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(un,{className:"h-10 w-full"}),i.jsx(un,{className:"h-32 w-full"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(un,{className:"h-8 w-24"}),i.jsx(un,{className:"h-8 w-24"}),i.jsx(un,{className:"h-8 w-24"})]}),i.jsx(un,{className:"h-24 w-full"}),i.jsx(un,{className:"h-24 w-full"})]})]}):e==="issues-list"?i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[i.jsx(un,{className:"h-9 w-64"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(un,{className:"h-8 w-16"}),i.jsx(un,{className:"h-8 w-16"}),i.jsx(un,{className:"h-8 w-16"}),i.jsx(un,{className:"h-8 w-24"})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(un,{className:"h-4 w-40"}),i.jsx("div",{className:"space-y-1",children:Array.from({length:8}).map((t,n)=>i.jsx(un,{className:"h-11 w-full rounded-none"},n))})]})]}):i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[i.jsx(un,{className:"h-9 w-44"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(un,{className:"h-8 w-20"}),i.jsx(un,{className:"h-8 w-24"})]})]}),i.jsx("div",{className:"space-y-1",children:Array.from({length:7}).map((t,n)=>i.jsx(un,{className:"h-11 w-full rounded-none"},n))})]})}const ele=[{value:"every_minute",label:"Every minute"},{value:"every_hour",label:"Every hour"},{value:"every_day",label:"Every day"},{value:"weekdays",label:"Weekdays"},{value:"weekly",label:"Weekly"},{value:"monthly",label:"Monthly"},{value:"custom",label:"Custom (cron)"}],Tat=Array.from({length:24},(e,t)=>({value:String(t),label:String(t).padStart(2,"0")})),jee=Array.from({length:12},(e,t)=>({value:String(t*5),label:String(t*5).padStart(2,"0")})),PU=[{value:"1",label:"Mon"},{value:"2",label:"Tue"},{value:"3",label:"Wed"},{value:"4",label:"Thu"},{value:"5",label:"Fri"},{value:"6",label:"Sat"},{value:"0",label:"Sun"}],M9e=Array.from({length:31},(e,t)=>({value:String(t+1),label:String(t+1)})),aNn={every_minute:"每分钟",every_hour:"每小时",every_day:"每天",weekdays:"工作日",weekly:"每周",monthly:"每月",custom:"自定义 cron"},oNn={1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",0:"周日"};function E9e(e,t){var n;return t==="zh-CN"?aNn[e]:((n=ele.find(r=>r.value===e))==null?void 0:n.label)??e}function D9e(e,t){var n;return t==="zh-CN"?oNn[e]??e:((n=PU.find(r=>r.value===e))==null?void 0:n.label)??e}function tle(e){const t={hour:"10",minute:"0",dayOfWeek:"1",dayOfMonth:"1"};if(!e||!e.trim())return{preset:"every_day",...t};const n=e.trim().split(/\s+/);if(n.length!==5)return{preset:"custom",...t};const[r,s,a,,o]=n;return r==="*"&&s==="*"&&a==="*"&&o==="*"?{preset:"every_minute",...t}:s==="*"&&a==="*"&&o==="*"?{preset:"every_hour",...t,minute:r==="*"?"0":r}:a==="*"&&o==="*"&&s!=="*"?{preset:"every_day",...t,hour:s,minute:r==="*"?"0":r}:a==="*"&&o==="1-5"&&s!=="*"?{preset:"weekdays",...t,hour:s,minute:r==="*"?"0":r}:a==="*"&&/^\d$/.test(o)&&s!=="*"?{preset:"weekly",...t,hour:s,minute:r==="*"?"0":r,dayOfWeek:o}:/^\d{1,2}$/.test(a)&&o==="*"&&s!=="*"?{preset:"monthly",...t,hour:s,minute:r==="*"?"0":r,dayOfMonth:a}:{preset:"custom",...t}}function lNn(e,t,n,r,s){switch(e){case"every_minute":return"* * * * *";case"every_hour":return`${n} * * * *`;case"every_day":return`${n} ${t} * * *`;case"weekdays":return`${n} ${t} * * 1-5`;case"weekly":return`${n} ${t} * * ${r}`;case"monthly":return`${n} ${t} ${s} * *`;case"custom":return""}}function IU(e,t){var d,u;const{preset:n,hour:r,minute:s,dayOfWeek:a,dayOfMonth:o}=tle(e),c=`${(((d=Tat.find(f=>f.value===r))==null?void 0:d.label)??`${r}`).padStart(2,"0")}:${s.padStart(2,"0")}`;switch(n){case"every_minute":return t==="zh-CN"?"每分钟":"Every minute";case"every_hour":return t==="zh-CN"?`每小时 ${Number(s)} 分`:`Every hour at :${s.padStart(2,"0")}`;case"every_day":return t==="zh-CN"?`每天 ${c}`:`Every day at ${c}`;case"weekdays":return t==="zh-CN"?`工作日 ${c}`:`Weekdays at ${c}`;case"weekly":{const A=t==="zh-CN"?{1:"一",2:"二",3:"三",4:"四",5:"五",6:"六",0:"日"}[a]??a:((u=PU.find(h=>h.value===a))==null?void 0:u.label)??a;return t==="zh-CN"?`每周${A} ${c}`:`Every ${A} at ${c}`}case"monthly":return t==="zh-CN"?`每月 ${o} 日 ${c}`:`Monthly on the ${o}${cNn(Number(o))} at ${c}`;case"custom":return e||(t==="zh-CN"?"未设置日程":"No schedule set")}}function cNn(e){const t=["th","st","nd","rd"],n=e%100;return t[(n-20)%10]||t[n]||t[0]}function rZ({value:e,onChange:t,variant:n="default"}){const r=m.useMemo(()=>tle(e),[e]),[s,a]=m.useState(r.preset),[o,l]=m.useState(r.hour),[c,d]=m.useState(r.minute),[u,f]=m.useState(r.dayOfWeek),[A,h]=m.useState(r.dayOfMonth),[g,x]=m.useState(s==="custom"?e:""),{locale:y}=as();m.useEffect(()=>{const O=tle(e);a(O.preset),l(O.hour),d(O.minute),f(O.dayOfWeek),h(O.dayOfMonth),O.preset==="custom"&&x(e)},[e]);const v=m.useCallback((O,j,C,N,I,E)=>{t(O==="custom"?E:lNn(O,j,C,N,I))},[t]),w=O=>{a(O),O==="custom"?x(e):v(O,o,c,u,A,g)},k=O=>{const[j,C]=O.split(":");if(j===void 0||C===void 0)return;const N=String(Number(j)),I=String(Number(C));l(N),d(I),v(s,N,I,u,A,g)};if(n==="compact"){const O=s!=="every_minute"&&s!=="every_hour"&&s!=="custom";return i.jsxs("div",{className:"space-y-2",children:[i.jsxs(Zo,{value:s,onValueChange:j=>w(j),children:[i.jsx(Xo,{className:"h-12 w-full rounded-md border-border/75 bg-background/60 px-3 text-base shadow-none md:text-sm",children:i.jsx(Ho,{placeholder:y==="zh-CN"?"选择频率...":"Choose frequency..."})}),i.jsx(Go,{children:ele.map(j=>i.jsx(Vs,{value:j.value,children:E9e(j.value,y)},j.value))})]}),O?i.jsx(Vn,{type:"time",step:300,value:`${o.padStart(2,"0")}:${c.padStart(2,"0")}`,onChange:j=>k(j.target.value),className:"h-12 rounded-md border-border/75 bg-background/60 text-base shadow-none md:text-sm"}):null,s==="every_hour"?i.jsxs(Zo,{value:c,onValueChange:j=>{d(j),v(s,o,j,u,A,g)},children:[i.jsx(Xo,{className:"h-12 w-full rounded-md border-border/75 bg-background/60 px-3 text-base shadow-none md:text-sm",children:i.jsx(Ho,{})}),i.jsx(Go,{children:jee.map(j=>i.jsxs(Vs,{value:j.value,children:[":",j.label]},j.value))})]}):null,s==="weekly"?i.jsxs(Zo,{value:u,onValueChange:j=>{f(j),v(s,o,c,j,A,g)},children:[i.jsx(Xo,{className:"h-12 w-full rounded-md border-border/75 bg-background/60 px-3 text-base shadow-none md:text-sm",children:i.jsx(Ho,{})}),i.jsx(Go,{children:PU.map(j=>i.jsx(Vs,{value:j.value,children:D9e(j.value,y)},j.value))})]}):null,s==="monthly"?i.jsxs(Zo,{value:A,onValueChange:j=>{h(j),v(s,o,c,u,j,g)},children:[i.jsx(Xo,{className:"h-12 w-full rounded-md border-border/75 bg-background/60 px-3 text-base shadow-none md:text-sm",children:i.jsx(Ho,{})}),i.jsx(Go,{children:M9e.map(j=>i.jsx(Vs,{value:j.value,children:j.label},j.value))})]}):null,s==="custom"?i.jsx(Vn,{value:g,onChange:j=>{x(j.target.value),v("custom",o,c,u,A,j.target.value)},placeholder:"0 10 * * *",className:"h-12 rounded-md border-border/75 bg-background/60 font-mono text-sm shadow-none"}):null]})}return i.jsxs("div",{className:"space-y-3",children:[i.jsxs(Zo,{value:s,onValueChange:O=>w(O),children:[i.jsx(Xo,{className:"w-full",children:i.jsx(Ho,{placeholder:y==="zh-CN"?"选择频率...":"Choose frequency..."})}),i.jsx(Go,{children:ele.map(O=>i.jsx(Vs,{value:O.value,children:E9e(O.value,y)},O.value))})]}),s==="custom"?i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Vn,{value:g,onChange:O=>{x(O.target.value),v("custom",o,c,u,A,O.target.value)},placeholder:"0 10 * * *",className:"font-mono text-sm"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:y==="zh-CN"?"五个字段:分钟 小时 日期 月份 星期":"Five fields: minute hour day-of-month month day-of-week"})]}):i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s!=="every_minute"&&s!=="every_hour"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:y==="zh-CN"?"时间":"at"}),i.jsxs(Zo,{value:o,onValueChange:O=>{l(O),v(s,O,c,u,A,g)},children:[i.jsx(Xo,{className:"w-[120px]",children:i.jsx(Ho,{})}),i.jsx(Go,{children:Tat.map(O=>i.jsx(Vs,{value:O.value,children:O.label},O.value))})]}),i.jsx("span",{className:"text-sm text-muted-foreground",children:":"}),i.jsxs(Zo,{value:c,onValueChange:O=>{d(O),v(s,o,O,u,A,g)},children:[i.jsx(Xo,{className:"w-[80px]",children:i.jsx(Ho,{})}),i.jsx(Go,{children:jee.map(O=>i.jsx(Vs,{value:O.value,children:O.label},O.value))})]})]}),s==="every_hour"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:y==="zh-CN"?"第几分钟":"at minute"}),i.jsxs(Zo,{value:c,onValueChange:O=>{d(O),v(s,o,O,u,A,g)},children:[i.jsx(Xo,{className:"w-[80px]",children:i.jsx(Ho,{})}),i.jsx(Go,{children:jee.map(O=>i.jsxs(Vs,{value:O.value,children:[":",O.label]},O.value))})]})]}),s==="weekly"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:y==="zh-CN"?"在":"on"}),i.jsx("div",{className:"flex gap-1",children:PU.map(O=>i.jsx(ie,{type:"button",variant:u===O.value?"default":"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>{f(O.value),v(s,o,c,O.value,A,g)},children:D9e(O.value,y)},O.value))})]}),s==="monthly"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:y==="zh-CN"?"日期":"on day"}),i.jsxs(Zo,{value:A,onValueChange:O=>{h(O),v(s,o,c,u,O,g)},children:[i.jsx(Xo,{className:"w-[80px]",children:i.jsx(Ho,{})}),i.jsx(Go,{children:M9e.map(O=>i.jsx(Vs,{value:O.value,children:O.label},O.value))})]})]})]})]})}const _at=m.createContext(null);function Mat({children:e,manageDocumentTitle:t=!0}){const[n,r]=m.useState([]),[s,a]=m.useState(null),o=m.useCallback(c=>{r(c)},[]),l=m.useCallback(c=>{a(c)},[]);return m.useEffect(()=>{if(t)if(n.length===0)document.title="Rudder";else{const c=[...n].reverse().flatMap(d=>{const u=[d.label];return d.sublabel&&u.push(d.sublabel),u});document.title=`${c.join(" · ")} · Rudder`}},[n,t]),i.jsx(_at.Provider,{value:{breadcrumbs:n,setBreadcrumbs:o,headerActions:s,setHeaderActions:l},children:e})}function ea(){const e=m.useContext(_at);if(!e)throw new Error("useBreadcrumbs must be used within BreadcrumbProvider");return e}const dNn={coalesce_if_active:{en:"coalesce if active","zh-CN":"有运行时合并"},always_enqueue:{en:"always enqueue","zh-CN":"始终排队"},skip_if_active:{en:"skip if active","zh-CN":"有运行时跳过"},skip_missed:{en:"skip missed","zh-CN":"跳过错过窗口"},enqueue_missed_with_cap:{en:"enqueue missed with cap","zh-CN":"限量补跑错过窗口"}},Eat={coalesce_if_active:{en:"Keep one follow-up run queued while an active run is still working.","zh-CN":"当前运行仍在执行时,只保留一个后续运行排队。"},always_enqueue:{en:"Queue every trigger occurrence, even if several runs stack up.","zh-CN":"每次触发都进入队列,即使多个运行堆积。"},skip_if_active:{en:"Drop overlapping trigger occurrences while the automation is already active.","zh-CN":"自动化已有运行时,丢弃重叠触发。"}},Dat={skip_missed:{en:"Ignore schedule windows that were missed while the automation or scheduler was paused.","zh-CN":"忽略自动化或调度器暂停期间错过的计划窗口。"},enqueue_missed_with_cap:{en:"Catch up missed schedule windows in capped batches after recovery.","zh-CN":"恢复后按上限分批补跑错过的计划窗口。"}};function Rat(e,t){return e[t]??e.en}function TU(e,t){return Rat(dNn[e]??{en:e.replaceAll("_"," "),"zh-CN":e.replaceAll("_"," ")},t)}function _U(e,t,n){const r=e[t];return r?Rat(r,n):t.replaceAll("_"," ")}function R9e(e,t,n){const r={};return e.kind==="schedule"&&(r.cronExpression=t.cronExpression.trim(),r.timezone=e.timezone??n),e.kind==="webhook"&&(r.signingMode=t.signingMode,r.replayWindowSec=Number(t.replayWindowSec||"300")),r}const uNn=["coalesce_if_active","always_enqueue","skip_if_active"],fNn=["skip_missed","enqueue_missed_with_cap"],ANn=["bearer","hmac_sha256"];function Cee(e,t){return e.includes(t)?e:[...e,t]}function Nee(e,t){return e.filter(n=>n!==t)}function L9e(e){e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}function Lat(e){if(e===null)return"null";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length===0?"[]":e.map(t=>Lat(t)).join(", ");try{return JSON.stringify(e)}catch{return"[unserializable]"}}function oA(e,t){const n=e==null?void 0:e[t];return typeof n=="string"&&n.trim()?n:null}function MU(e,t="en"){return UO(t,e.replaceAll("_"," "))}function ek(e,t="en"){return e==="schedule"?t==="zh-CN"?"日程触发器":"Schedule trigger":e==="webhook"?t==="zh-CN"?"Webhook 触发器":"Webhook trigger":e?t==="zh-CN"?`${MU(e,t)}触发器`:`${MU(e,t)} trigger`:t==="zh-CN"?"触发器":"Trigger"}function hNn(e,t="en"){return e==="manual"?t==="zh-CN"?"手动运行":"Manual run":e==="schedule"?t==="zh-CN"?"计划运行":"Scheduled run":e==="webhook"?t==="zh-CN"?"Webhook 运行":"Webhook run":MU(e,t)}function nle(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}function UC(e,t){return e?Ja(e):t}function X8(e,t="en"){return e?e.kind==="schedule"&&e.cronExpression?IU(e.cronExpression,t):e.kind==="webhook"?t==="zh-CN"?"Webhook 触发器":"Webhook trigger":ek(e.kind,t):"No triggers configured"}function mNn(e){return e.triggerCount===0?"No trigger":e.hasAssignee?e.latestRunStatus==="failed"?"Last failed":e.hasLiveRun?"Active run":"Normal":"No owner"}function Pee({title:e,children:t,card:n=!1}){return i.jsxs("section",{className:"space-y-2.5",children:[i.jsx("h2",{className:q("font-medium text-muted-foreground",n?"text-sm":"text-xs"),children:e}),i.jsx("div",{className:q("space-y-2.5",n&&"rounded-md border border-border/70 bg-card/70 px-3.5 py-2.5"),children:t})]})}function JL({label:e,children:t}){return i.jsxs("div",{className:"grid grid-cols-[76px_minmax(0,1fr)] items-center gap-3 text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:e}),i.jsx("div",{className:"min-w-0 text-right text-foreground",children:t})]})}function ny({label:e,children:t,align:n="center"}){return i.jsxs("div",{className:q("flex gap-3 py-1.5",n==="start"?"items-start":"items-center"),children:[i.jsx("span",{className:"w-20 shrink-0 text-xs text-muted-foreground",children:e}),i.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t})]})}function ez({children:e}){return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:e}),i.jsx(Br,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80"})]})}function pNn({trigger:e,onSave:t,onRotate:n,onDelete:r,isSaving:s,isDeleting:a,isRotating:o,saveError:l}){const{confirm:c}=ri(),{locale:d}=as(),[u,f]=m.useState(!1),[A,h]=m.useState({cronExpression:e.cronExpression??"",signingMode:e.signingMode??"bearer",replayWindowSec:String(e.replayWindowSec??300)}),g=m.useRef(!0);m.useEffect(()=>{h({cronExpression:e.cronExpression??"",signingMode:e.signingMode??"bearer",replayWindowSec:String(e.replayWindowSec??300)}),g.current=!0},[e]);const x=m.useMemo(()=>e.kind==="schedule"?A.cronExpression!==(e.cronExpression??""):e.kind==="webhook"?A.signingMode!==(e.signingMode??"bearer")||A.replayWindowSec!==String(e.replayWindowSec??300):!1,[A,e]),y=e.kind!=="schedule"||A.cronExpression.trim().length>0,v=e.kind==="schedule"?e.cronExpression?IU(e.cronExpression,d):d==="zh-CN"?"未设置日程":"No schedule":e.kind==="webhook"?d==="zh-CN"?"Webhook 触发器":"Webhook trigger":d==="zh-CN"?"API 触发器":"API trigger",w=e.kind==="schedule"&&e.nextRunAt?`${d==="zh-CN"?"下次:":"Next: "}${Ja(e.nextRunAt)}`:e.kind==="webhook"?"Webhook":"API",k=v,O=w,j=a?d==="zh-CN"?"删除中...":"Deleting...":o?d==="zh-CN"?"轮换中...":"Rotating...":s?d==="zh-CN"?"保存中...":"Saving...":l?d==="zh-CN"?"保存失败":"Save failed":y?x?d==="zh-CN"?"自动保存中...":"Autosaving...":d==="zh-CN"?"已同步":"In sync":d==="zh-CN"?"需要日程":"Needs schedule",C=a||o||s||x?"border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300":l?"border-destructive/40 bg-destructive/10 text-destructive":y?"border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-border/70 bg-muted/20 text-muted-foreground",N=j!==(d==="zh-CN"?"已同步":"In sync");return m.useEffect(()=>{if(g.current){g.current=!1;return}if(!x||!y)return;const I=window.setTimeout(()=>{t(e.id,R9e(e,A,nle()))},650);return()=>window.clearTimeout(I)},[y,A,x,t,e]),i.jsxs(es,{open:u,onOpenChange:f,children:[i.jsxs("div",{className:"flex min-h-12 min-w-0 items-center gap-2 rounded-md border border-border/60 bg-background/25 px-3 py-2",children:[i.jsx(bs,{asChild:!0,children:i.jsxs("button",{type:"button",className:"group flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Edit trigger","data-testid":"automation-trigger-menu-button",children:[i.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[i.jsx("span",{className:"block truncate text-sm font-medium",title:k,children:k}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",title:O,children:O})]}),i.jsx(Br,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180"})]})}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[N?i.jsx($i,{variant:"outline",className:C,children:j}):null,i.jsx(ie,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-destructive","aria-label":"Delete trigger",disabled:a,onClick:async()=>{await c({title:`Delete ${e.kind==="schedule"?"schedule":e.kind} trigger?`,description:`It will stop new ${e.kind} activations.`,confirmLabel:"Delete",tone:"destructive"})&&r(e.id)},children:i.jsx(fi,{className:"h-3.5 w-3.5"})})]})]}),i.jsxs(ts,{"data-testid":"automation-trigger-editor-body",align:"end",side:"left",sideOffset:8,className:"automation-trigger-menu-content glass-popover w-[min(320px,calc(100vw-2rem))] space-y-3 rounded-md p-3 text-foreground",children:[i.jsx("div",{className:"px-1 text-sm font-medium text-muted-foreground",children:e.kind==="schedule"?d==="zh-CN"?"日程":"Schedule":ek(e.kind,d)}),i.jsxs("div",{className:"grid gap-2",children:[e.kind==="schedule"&&i.jsxs("div",{className:"grid gap-1.5",children:[i.jsx(ya,{className:"px-1 text-xs text-muted-foreground",children:d==="zh-CN"?"日程":"Schedule"}),i.jsx(rZ,{variant:"compact",value:A.cronExpression,onChange:I=>h(E=>({...E,cronExpression:I}))})]}),e.kind==="webhook"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid gap-1.5",children:[i.jsx(ya,{className:"px-1 text-xs text-muted-foreground",children:d==="zh-CN"?"签名模式":"Signing mode"}),i.jsxs(Zo,{value:A.signingMode,onValueChange:I=>h(E=>({...E,signingMode:I})),children:[i.jsx(Xo,{className:"h-8",children:i.jsx(Ho,{})}),i.jsx(Go,{children:ANn.map(I=>i.jsx(Vs,{value:I,children:I},I))})]})]}),i.jsxs("div",{className:"grid gap-1.5",children:[i.jsx(ya,{className:"px-1 text-xs text-muted-foreground",children:d==="zh-CN"?"重放窗口":"Replay window"}),i.jsx(Vn,{value:A.replayWindowSec,className:"h-8",onChange:I=>h(E=>({...E,replayWindowSec:I.target.value}))})]})]})]}),e.lastResult||e.kind==="webhook"||l?i.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.lastResult&&i.jsxs("span",{className:"text-xs text-muted-foreground",children:[d==="zh-CN"?"最近:":"Last: ",e.lastResult]}),l?i.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-destructive",children:[i.jsx("span",{children:l}),y?i.jsx(ie,{variant:"ghost",size:"xs",className:"h-6 px-2 text-destructive hover:text-destructive",onClick:()=>t(e.id,R9e(e,A,nle())),children:d==="zh-CN"?"重试保存":"Retry save"}):null]}):null,i.jsx("div",{className:"ml-auto flex items-center gap-2",children:e.kind==="webhook"&&i.jsxs(ie,{variant:"outline",size:"sm",disabled:o,onClick:()=>n(e.id),children:[i.jsx(_A,{className:"mr-1.5 h-3.5 w-3.5"}),o?d==="zh-CN"?"轮换中...":"Rotating...":d==="zh-CN"?"轮换密钥":"Rotate secret"]})})]}):null]})]})}function z9e({children:e,onClose:t,surface:n}){return i.jsxs("div",{className:"scrollbar-auto-hide h-full min-h-0 overflow-y-auto overscroll-contain","data-testid":"automation-detail-shell","data-surface":n,children:[n==="side_panel"?i.jsx("header",{"data-testid":"automation-detail-panel-header",className:"sticky top-3 z-20 mx-3 mt-3 rounded-[var(--radius-md)] border border-border/70 bg-background/95 px-3 py-2 backdrop-blur sm:mx-4 sm:px-4",children:i.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Automation"}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":"Close automation detail",title:"Close automation detail",onClick:t,children:i.jsx(Ls,{className:"h-4 w-4"})})]})}):null,i.jsx("div",{className:"p-4 sm:p-5",children:e})]})}function h1e({automationId:e,embedded:t=!1,onClose:n,onOpenRunChat:r,surface:s}={}){var zn,Ze,Qt;const a=s??(t?"side_panel":"page"),o=a!=="page",{automationId:l}=Qo(),c=e??l,{selectedOrganizationId:d,selectedOrganization:u}=Nr(),{confirm:f}=ri(),{setBreadcrumbs:A,setHeaderActions:h}=ea(),g=Wn(),x=Hr(),{pushToast:y}=As(),{locale:v}=as(),w=m.useRef(null),k=m.useRef(null),O=m.useRef(null),j=m.useRef(null),C=m.useRef(null),N=m.useRef(null),I=m.useRef(null),[E,_]=m.useState(null),[T,R]=m.useState(null),[M,L]=m.useState(!1),[U,B]=m.useState(!1),[z,H]=m.useState([]),[J,F]=m.useState([]),[Q,W]=m.useState([]),[$,ee]=m.useState({}),[re,ne]=m.useState({kind:"schedule",cronExpression:"0 10 * * *",signingMode:"bearer",replayWindowSec:"300"}),[te,ce]=m.useState({title:"",description:"",projectId:"",assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",outputMode:"track_issue",chatConversationId:"",notifyOnIssueCreated:!1}),{data:se,isLoading:he,error:we}=Te({queryKey:V.automations.detail(c),queryFn:()=>yd.get(c),enabled:!!c}),Ue=(zn=se==null?void 0:se.activeIssue)==null?void 0:zn.id,{data:je}=Te({queryKey:V.issues.liveRuns(Ue),queryFn:()=>So.liveRunsForIssue(Ue),enabled:!!Ue,refetchInterval:3e3}),ke=(je??[]).length>0,{data:Se}=Te({queryKey:V.automations.runs(c),queryFn:()=>yd.listRuns(c),enabled:!!c,refetchInterval:ke?3e3:!1}),oe=m.useMemo(()=>({triggerIds:(se==null?void 0:se.triggers.map(He=>He.id))??[],runIds:(Se==null?void 0:Se.map(He=>He.id))??[]}),[se==null?void 0:se.triggers,Se]),{data:fe}=Te({queryKey:[...V.automations.activity(d,c),oe.triggerIds.join(","),oe.runIds.join(",")],queryFn:()=>yd.activity(d,c,oe),enabled:!!d&&!!c&&!!se}),{data:Ie}=Te({queryKey:V.agents.list(d),queryFn:()=>_n.list(d),enabled:!!d}),{data:ue}=Te({queryKey:V.projects.list(d),queryFn:()=>Ii.list(d),enabled:!!d}),{data:be}=Te({queryKey:V.issues.list(d),queryFn:()=>fr.list(d),enabled:!!d}),{data:at}=Te({queryKey:V.organizationSkills.list(d??"__none__"),queryFn:()=>Zu.list(d),enabled:!!d&&!!te.assigneeAgentId}),{data:ve}=Te({queryKey:V.agents.skills(te.assigneeAgentId||"__none__"),queryFn:()=>_n.skills(te.assigneeAgentId,d),enabled:!!d&&!!te.assigneeAgentId}),me=m.useMemo(()=>se?{title:se.title,description:se.description??"",projectId:se.projectId??"",assigneeAgentId:se.assigneeAgentId,priority:se.priority,concurrencyPolicy:se.concurrencyPolicy,catchUpPolicy:se.catchUpPolicy,outputMode:se.outputMode,chatConversationId:"",notifyOnIssueCreated:se.notifyOnIssueCreated}:null,[se]),ye=m.useMemo(()=>me?te.title!==me.title||te.description!==me.description||te.projectId!==me.projectId||te.assigneeAgentId!==me.assigneeAgentId||te.priority!==me.priority||te.concurrencyPolicy!==me.concurrencyPolicy||te.catchUpPolicy!==me.catchUpPolicy||te.outputMode!==me.outputMode||te.notifyOnIssueCreated!==me.notifyOnIssueCreated:!1,[te,me]),qe=!!(te.title.trim()&&te.assigneeAgentId),Ce=m.useMemo(()=>JSON.stringify({title:te.title,description:te.description.trim()||null,projectId:te.projectId||null,assigneeAgentId:te.assigneeAgentId,priority:te.priority,concurrencyPolicy:te.concurrencyPolicy,catchUpPolicy:te.catchUpPolicy,outputMode:te.outputMode,chatConversationId:null,notifyOnIssueCreated:te.notifyOnIssueCreated}),[te]);m.useEffect(()=>{if(!se||(o||A([{label:"Automations",href:"/automations"},{label:se.title}]),!me))return;const He=w.current!==se.id;(He||!ye)&&(ce(me),w.current=se.id,He&&(k.current=null))},[se,me,o,ye,A]),m.useEffect(()=>{L9e(O.current)},[te.title,se==null?void 0:se.id]),m.useEffect(()=>()=>{I.current&&window.clearTimeout(I.current)},[]);const X=async(He,Rt,In)=>{try{await navigator.clipboard.writeText(Rt),R(In),I.current&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{R(Zn=>Zn===In?null:Zn)},1800),y({title:`${He} copied`,tone:"success"})}catch(Zn){y({title:`Failed to copy ${He.toLowerCase()}`,body:Zn instanceof Error?Zn.message:"Clipboard access was denied.",tone:"error"})}},G=pt({mutationFn:He=>yd.update(c,{...He,projectId:He.projectId||null,instructions:He.description.trim()||null,chatConversationId:null}),onSuccess:async()=>{await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})])},onError:He=>{k.current=null,y({title:"Failed to save automation",body:He instanceof Error?He.message:"Rudder could not save the automation.",tone:"error"})}});m.useEffect(()=>{if(!se||!ye||!qe||G.isPending||k.current===Ce)return;const He=te,Rt=window.setTimeout(()=>{k.current=Ce,G.mutate(He)},700);return()=>window.clearTimeout(Rt)},[se,qe,te,Ce,ye,G]);const Ae=pt({mutationFn:()=>yd.run(c),onSuccess:async He=>{y({title:"Automation run started",tone:"success"}),await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.runs(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})]),He.linkedChatConversationId&&(r?r(He.linkedChatConversationId):x(`/messenger/chat/${He.linkedChatConversationId}`))},onError:He=>{y({title:"Automation run failed",body:He instanceof Error?He.message:"Rudder could not start the automation run.",tone:"error"})}}),Je=pt({mutationFn:()=>yd.delete(c),onSuccess:()=>{n?n():x("/automations"),y({title:"Automation deleted",tone:"success"}),Promise.all([g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})])},onError:He=>{y({title:"Failed to delete automation",body:He instanceof Error?He.message:"Rudder could not delete the automation.",tone:"error"})}}),ht=pt({mutationFn:He=>yd.update(c,{status:He}),onSuccess:async(He,Rt)=>{y({title:"Automation saved",body:Rt==="paused"?"Automation paused.":"Automation enabled.",tone:"success"}),await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)})])},onError:He=>{y({title:"Failed to update automation",body:He instanceof Error?He.message:"Rudder could not update the automation.",tone:"error"})}});m.useEffect(()=>{if(o)return;if(!d||!se){h(null);return}const He=se.status==="active",Rt=He?"Disable automation":"Enable automation";return h(i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md px-1 text-xs text-muted-foreground",children:[i.jsx(zA,{checked:He,size:"md",tone:"success","aria-label":Rt,title:Rt,disabled:ht.isPending,onClick:()=>ht.mutate(He?"paused":"active")}),i.jsx("span",{className:"min-w-5 tabular-nums",children:He?"On":"Off"})]}),i.jsx(ie,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive","aria-label":"Delete automation",title:"Delete automation",disabled:Je.isPending,onClick:async()=>{await f({title:`Delete "${se.title}"?`,description:"This will permanently remove the automation and stop future runs.",confirmLabel:"Delete",tone:"destructive"})&&Je.mutate()},children:Je.isPending?i.jsx(_A,{className:"h-4 w-4 animate-spin"}):i.jsx(fi,{className:"h-4 w-4"})}),i.jsxs(ie,{variant:"default",size:"sm",className:"border-white/70 bg-white px-2 text-black shadow-none hover:bg-white/90 min-[420px]:min-w-[92px] min-[420px]:px-3","aria-label":"Run now",disabled:Ae.isPending||!He,onClick:()=>Ae.mutate(),children:[i.jsx(SA,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"hidden min-[420px]:inline",children:Ae.isPending?"Starting...":"Run now"})]})]})),()=>h(null)},[se==null?void 0:se.id,se==null?void 0:se.status,se==null?void 0:se.title,Je.isPending,o,Ae.isPending,d,h,ht.isPending]);const De=pt({mutationFn:async()=>yd.createTrigger(c,{kind:re.kind,...re.kind==="schedule"?{cronExpression:re.cronExpression.trim(),timezone:nle()}:{},...re.kind==="webhook"?{signingMode:re.signingMode,replayWindowSec:Number(re.replayWindowSec||"300")}:{}}),onSuccess:async He=>{He.secretMaterial&&_({title:"Webhook trigger created",webhookUrl:He.secretMaterial.webhookUrl,webhookSecret:He.secretMaterial.webhookSecret}),await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})]),B(!1)},onError:He=>{y({title:"Failed to add trigger",body:He instanceof Error?He.message:"Rudder could not create the trigger.",tone:"error"})}}),ft=pt({mutationFn:({id:He,patch:Rt})=>yd.updateTrigger(He,Rt),onSuccess:async()=>{await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})])},onError:He=>{y({title:"Failed to update trigger",body:He instanceof Error?He.message:"Rudder could not update the trigger.",tone:"error"})}}),dt=m.useCallback((He,Rt)=>{H(In=>Cee(In,He)),ee(In=>{if(!(He in In))return In;const Zn={...In};return delete Zn[He],Zn}),ft.mutate({id:He,patch:Rt},{onError:In=>{ee(Zn=>({...Zn,[He]:In instanceof Error?In.message:"Rudder could not update the trigger."}))},onSettled:()=>{H(In=>Nee(In,He))}})},[ft]),yt=pt({mutationFn:He=>yd.deleteTrigger(He),onSuccess:async(He,Rt)=>{await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.list(d)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})]),ee(In=>{if(!(Rt in In))return In;const Zn={...In};return delete Zn[Rt],Zn})},onError:He=>{y({title:"Failed to delete trigger",body:He instanceof Error?He.message:"Rudder could not delete the trigger.",tone:"error"})}}),Mt=pt({mutationFn:He=>yd.rotateTriggerSecret(He),onSuccess:async He=>{_({title:"Webhook secret rotated",webhookUrl:He.secretMaterial.webhookUrl,webhookSecret:He.secretMaterial.webhookSecret}),await Promise.all([g.invalidateQueries({queryKey:V.automations.detail(c)}),g.invalidateQueries({queryKey:V.automations.activity(d,c)})])},onError:He=>{y({title:"Failed to rotate webhook secret",body:He instanceof Error?He.message:"Rudder could not rotate the webhook secret.",tone:"error"})}}),Xe=m.useMemo(()=>new Map((Ie??[]).map(He=>[He.id,He])),[Ie]),At=m.useMemo(()=>new Map((ue??[]).map(He=>[He.id,He])),[ue]),it=m.useMemo(()=>ME(),[se==null?void 0:se.id]),Ee=m.useMemo(()=>RT((Ie??[]).filter(He=>He.status!=="terminated"),it).map(He=>({id:He.id,label:Qu(He),searchText:`${He.name} ${He.role} ${He.title??""}`})),[Ie,it]),mt=m.useMemo(()=>(ue??[]).map(He=>({id:He.id,label:He.name,searchText:He.description??""})),[ue]),ot=te.assigneeAgentId?Xe.get(te.assigneeAgentId)??null:null,xe=te.projectId?At.get(te.projectId)??null:null,Ne=m.useMemo(()=>new Map(((se==null?void 0:se.triggers)??[]).map(He=>[He.id,He])),[se==null?void 0:se.triggers]),We=m.useMemo(()=>o9({agent:ot,orgUrlKey:(u==null?void 0:u.urlKey)??"organization",organizationSkills:at,skillSnapshot:ve}),[at,ve,ot,u==null?void 0:u.urlKey]),ze=m.useMemo(()=>SM({agents:Ie,projects:ue,issues:be,skillMentionOptions:We}),[Ie,be,ue,We]),Ye=m.useMemo(()=>{const He=new Set((Se??[]).map(kt=>kt.id)),Rt=[],In=(kt,nn)=>kt?i.jsx("span",{children:kt},nn):null,Zn=kt=>{var Ke;if(!kt)return null;const nn=Xe.get(kt);return nn?Qu(nn):((Ke=se==null?void 0:se.assignee)==null?void 0:Ke.id)===kt?se.assignee.name:"Selected agent"},Xr=(kt,nn)=>{const st=(kt?Ne.get(kt):null)??nn;if(!st)return null;const Ft=X8(st,v),Dn=ek(st.kind,v);return Ft&&Ft!==Dn?`${Dn}: ${Ft}`:Dn},qs=(kt,nn)=>v!=="zh-CN"?`${kt==="added"?"Added":kt==="updated"?"Updated":"Removed"} ${nn.toLowerCase()}`:`${kt==="added"?"添加了":kt==="updated"?"更新了":"移除了"}${nn}`,hr=(kt,nn,Ke)=>{const st=hNn(kt,v);switch(nn){case"issue_created":return v==="zh-CN"?`${st}创建了执行任务`:`${st} opened an execution issue`;case"running":return v==="zh-CN"?Ke==="chat_output"?`${st}已启动聊天运行`:`${st}正在执行`:Ke==="chat_output"?`${st} started a chat run`:`${st} is in progress`;case"failed":return v==="zh-CN"?`${st}失败`:`${st} failed`;case"coalesced":return v==="zh-CN"?`${st}已合并到活跃运行`:`${st} joined an active run`;case"skipped":return v==="zh-CN"?`${st}已跳过`:`${st} skipped`;case"completed":return v==="zh-CN"?`${st}已完成`:`${st} completed`;default:return`${st} ${MU(nn,v)}`}},Fr=kt=>kt?kt.startsWith("Schedule trigger: ")?`for ${kt.replace("Schedule trigger: ","")}`:v==="zh-CN"&&kt.startsWith("日程触发器: ")?`用于${kt.replace("日程触发器: ","")}`:kt:null,jt=kt=>{const nn=kt.details??null,Ke=[];let st=kt.action.replaceAll("."," "),Ft=!1;if(kt.action==="automation.created"){const Rn=oA(nn,"title");st=Rn?v==="zh-CN"?`创建了“${Rn}”`:`Created "${Rn}"`:v==="zh-CN"?"创建了自动化":"Created automation",Ke.push(In(v==="zh-CN"?`分配给 ${Zn(oA(nn,"assigneeAgentId"))??"智能体"}`:`Assigned to ${Zn(oA(nn,"assigneeAgentId"))??"agent"}`,"assignee"))}else if(kt.action==="automation.updated"){const Rn=oA(nn,"title");st=Rn?v==="zh-CN"?`更新了“${Rn}”的自动化设置`:`Updated automation settings for "${Rn}"`:v==="zh-CN"?"更新了自动化设置":"Updated automation settings"}else if(kt.action==="automation.deleted"){const Rn=oA(nn,"title");st=Rn?v==="zh-CN"?`删除了“${Rn}”`:`Deleted "${Rn}"`:v==="zh-CN"?"删除了自动化":"Deleted automation"}else if(kt.action==="automation.trigger_created"){const Rn=Ne.get(kt.entityId),rt=(Rn==null?void 0:Rn.kind)??oA(nn,"kind");st=qs("added",ek(rt,v)),Ke.push(In(Fr(Xr(kt.entityId,{kind:oA(nn,"kind")??"trigger",cronExpression:(Rn==null?void 0:Rn.cronExpression)??null,label:(Rn==null?void 0:Rn.label)??null})),"trigger"))}else if(kt.action==="automation.trigger_updated"){const Rn=Ne.get(kt.entityId),rt=(Rn==null?void 0:Rn.kind)??oA(nn,"kind");st=qs("updated",ek(rt,v)),Ke.push(In(Fr(Xr(kt.entityId,{kind:oA(nn,"kind")??"trigger",cronExpression:null})),"trigger"))}else if(kt.action==="automation.trigger_deleted")st=qs("removed",ek(oA(nn,"kind"),v));else if(kt.action==="automation.trigger_secret_rotated")st=v==="zh-CN"?"已轮换 Webhook 密钥":"Webhook secret rotated";else if(kt.action==="automation.run_triggered"){const Rn=oA(nn,"source")??"run",rt=oA(nn,"status")??"started";st=hr(Rn,rt,oA(nn,"outputMode")??(se==null?void 0:se.outputMode));const Yt=Xr(oA(nn,"triggerId"),null);Ke.push(In(Fr(Yt),"trigger"))}else Ft=!0,Object.entries(nn??{}).filter(([Rn])=>!["automationId","triggerId","assigneeAgentId","projectId"].includes(Rn)).slice(0,2).forEach(([Rn,rt])=>{Ke.push(i.jsxs("span",{children:[i.jsxs("span",{className:"text-muted-foreground/70",children:[Rn.replaceAll("_"," "),":"]})," ",Lat(rt)]},Rn))});const Dn=Ke.filter(Boolean);Rt.push({id:`event:${kt.id}`,title:st,details:Dn.length>0||!Ft?Dn:[i.jsx("span",{children:"Activity recorded"},"fallback")],createdAt:kt.createdAt,sortAt:new Date(kt.createdAt).getTime()})};for(const kt of Se??(se==null?void 0:se.recentRuns)??[]){const nn=[],Ke=Xr(kt.triggerId,kt.trigger?{...kt.trigger,cronExpression:null}:null),st=Fr(Ke);st&&nn.push(i.jsx("span",{children:st},"trigger")),kt.linkedIssue&&nn.push(i.jsx(an,{to:`/issues/${kt.linkedIssue.identifier??kt.linkedIssue.id}`,className:"whitespace-nowrap font-medium text-foreground hover:underline",children:kt.linkedIssue.identifier??kt.linkedIssue.title},"issue")),kt.linkedChatConversation&&nn.push(i.jsx(an,{to:`/messenger/chat/${kt.linkedChatConversation.id}`,className:"whitespace-nowrap font-medium text-foreground hover:underline",children:kt.linkedChatConversation.title},"chat")),kt.failureReason&&nn.push(i.jsx("span",{children:kt.failureReason},"failure")),Rt.push({id:`run:${kt.id}`,title:hr(kt.source,kt.status,se==null?void 0:se.outputMode),details:nn,createdAt:kt.triggeredAt,sortAt:new Date(kt.triggeredAt).getTime()})}for(const kt of fe??[])kt.action!=="automation.updated"&&(kt.action==="automation.run_triggered"&&kt.entityType==="automation_run"&&He.has(kt.entityId)||jt(kt));return Rt.sort((kt,nn)=>nn.sortAt-kt.sortAt).slice(0,10)},[fe,Xe,se,Se,v,At,Ne]);if(!d)return i.jsx(ma,{icon:y6,message:"Select an organization to view automations."});if(he)return o?i.jsx(z9e,{onClose:n,surface:a==="workbench"?"workbench":"side_panel",children:i.jsx(Co,{variant:"issues-list"})}):i.jsx(Co,{variant:"issues-list"});if(we||!se){const He=we instanceof Error?we.message:"Automation not found";return o?i.jsx(z9e,{onClose:n,surface:a==="workbench"?"workbench":"side_panel",children:i.jsx("p",{className:"text-sm text-destructive",children:He})}):i.jsx("p",{className:"pt-6 text-sm text-destructive",children:He})}const _e=se.status==="active",Le=_e?"Active":"Paused",Pe=G.isPending?"Saving...":qe?ye?"Autosaving...":"In sync":"Needs fields",vt=G.isPending||ye?"text-amber-600":"text-muted-foreground",Be=[...se.triggers].filter(He=>He.enabled).sort((He,Rt)=>{const In=He.nextRunAt?new Date(He.nextRunAt).getTime():Number.POSITIVE_INFINITY,Zn=Rt.nextRunAt?new Date(Rt.nextRunAt).getTime():Number.POSITIVE_INFINITY;return In-Zn})[0]??se.triggers[0]??null,ut=(Se==null?void 0:Se[0])??se.recentRuns[0]??null,Et=((Ze=se.activeIssue)==null?void 0:Ze.identifier)??((Qt=se.activeIssue)==null?void 0:Qt.id.slice(0,8))??null,Zt=re.kind!=="schedule"||re.cronExpression.trim().length>0,Nn=mNn({status:se.status,triggerCount:se.triggers.length,hasAssignee:!!te.assigneeAgentId,hasLiveRun:ke,latestRunStatus:ut==null?void 0:ut.status});return i.jsxs("div",{className:q("pb-8",o&&"scrollbar-auto-hide h-full min-h-0 overflow-y-auto overscroll-contain"),"data-testid":"automation-detail-shell","data-surface":a,children:[a==="side_panel"?i.jsx("header",{"data-testid":"automation-detail-panel-header",className:"sticky top-3 z-20 mx-3 mt-3 rounded-[var(--radius-md)] border border-border/70 bg-card/95 px-3 py-2 backdrop-blur sm:mx-4 sm:px-4",children:i.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs font-medium",children:[i.jsx("span",{className:q("h-2 w-2 shrink-0 rounded-full",_e?"bg-emerald-500":"bg-muted-foreground/45")}),i.jsx("span",{className:"truncate",children:Le}),i.jsx("span",{className:q("truncate font-normal",vt),children:Pe})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":"Automation actions",title:"Automation actions",children:i.jsx(xl,{className:"h-4 w-4"})})}),i.jsxs(Di,{align:"end",children:[i.jsxs(Gt,{disabled:Ae.isPending||!_e,onClick:()=>Ae.mutate(),children:[i.jsx(SA,{className:"h-4 w-4"}),Ae.isPending?"Starting...":"Run now"]}),i.jsx(ko,{}),i.jsxs(Gt,{variant:"destructive",disabled:Je.isPending,onClick:async()=>{await f({title:`Delete "${se.title}"?`,description:"This will permanently remove the automation and stop future runs.",confirmLabel:"Delete",tone:"destructive"})&&Je.mutate()},children:[i.jsx(fi,{className:"h-4 w-4"}),"Delete"]})]})]}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":_e?"Pause automation":"Enable automation",title:_e?"Pause automation":"Enable automation",disabled:ht.isPending,onClick:()=>ht.mutate(_e?"paused":"active"),children:_e?i.jsx(Tq,{className:"h-4 w-4"}):i.jsx(SA,{className:"h-4 w-4"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":"Close automation detail",title:"Close automation detail",onClick:n,children:i.jsx(Ls,{className:"h-4 w-4"})})]})]})}):null,E&&i.jsxs("div",{className:q("relative mb-4 rounded-md border border-blue-500/30 bg-blue-500/5 p-4 pr-12 text-sm",o&&"mx-4 mt-4 sm:mx-5"),children:[i.jsxs("div",{className:"mb-3",children:[i.jsx("p",{className:"font-medium",children:E.title}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Save this now. Rudder will not show the secret value again."})]}),i.jsx(ie,{variant:"ghost",size:"icon-xs",className:"absolute right-4 top-4","aria-label":"Dismiss secret notice",onClick:()=>{_(null),R(null)},children:i.jsx(Ls,{className:"h-3.5 w-3.5"})}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Vn,{value:E.webhookUrl,readOnly:!0,className:"flex-1"}),i.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>X("Webhook URL",E.webhookUrl,"url"),children:[T==="url"?i.jsx(Zi,{className:"mr-1 h-3.5 w-3.5"}):i.jsx(sl,{className:"mr-1 h-3.5 w-3.5"}),T==="url"?"Copied":"URL"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Vn,{value:E.webhookSecret,readOnly:!0,className:"flex-1"}),i.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>X("Webhook secret",E.webhookSecret,"secret"),children:[T==="secret"?i.jsx(Zi,{className:"mr-1 h-3.5 w-3.5"}):i.jsx(sl,{className:"mr-1 h-3.5 w-3.5"}),T==="secret"?"Copied":"Secret"]})]})]})]}),i.jsxs("div",{className:q("grid min-w-0 grid-cols-[minmax(0,1fr)] gap-6 px-4 pt-3 sm:px-5",o?"pb-4":"lg:grid-cols-[minmax(0,1fr)_300px] lg:px-6 xl:grid-cols-[minmax(0,1fr)_320px] 2xl:grid-cols-[minmax(0,1fr)_340px]"),children:[i.jsxs("main",{className:q("min-w-0 space-y-6",o&&"contents"),children:[i.jsxs("section",{className:q("max-w-none space-y-3",o&&"order-1"),children:[a==="workbench"?i.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 border-b border-border/60 pb-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs font-medium",children:[i.jsx("span",{className:q("h-2 w-2 shrink-0 rounded-full",_e?"bg-emerald-500":"bg-muted-foreground/45")}),i.jsx("span",{className:"truncate",children:Le}),i.jsx("span",{className:q("truncate font-normal",vt),children:Pe})]}),i.jsxs(ie,{type:"button",variant:"default",size:"sm",className:"shrink-0","aria-label":"Run now",disabled:Ae.isPending||!_e,onClick:()=>Ae.mutate(),children:[Ae.isPending?i.jsx(_A,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(SA,{className:"h-3.5 w-3.5"}),Ae.isPending?"Starting...":"Run now"]})]}):null,i.jsx("textarea",{ref:O,className:q("min-h-[34px] w-full resize-none overflow-hidden bg-transparent font-semibold leading-tight outline-none placeholder:text-muted-foreground/50",o?"text-xl":"text-[1.45rem] sm:text-[1.6rem]"),placeholder:"Automation title",rows:1,value:te.title,onChange:He=>{ce(Rt=>({...Rt,title:He.target.value})),L9e(He.target)},onKeyDown:He=>{var Rt,In,Zn,Xr;if(He.key==="Enter"&&!He.metaKey&&!He.ctrlKey&&!He.nativeEvent.isComposing){He.preventDefault(),(Rt=j.current)==null||Rt.focus();return}He.key==="Tab"&&!He.shiftKey&&(He.preventDefault(),te.assigneeAgentId?te.projectId?(In=j.current)==null||In.focus():(Zn=N.current)==null||Zn.focus():(Xr=C.current)==null||Xr.focus())}}),i.jsx("div",{"data-testid":"automation-overview-strip",className:q("border-y border-border/60 bg-transparent py-2.5",o&&"hidden"),children:i.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-sm",children:[i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i.jsx("span",{className:q("h-2 w-2 rounded-full",_e?"bg-emerald-500":"bg-muted-foreground/45")}),i.jsx("span",{className:"text-foreground",children:Le})]}),ke?i.jsxs("span",{className:"inline-flex items-center gap-1.5 text-blue-700 dark:text-blue-300",children:[i.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-500"}),"In progress"]}):null,i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"text-muted-foreground",children:"Repeats"})," ",i.jsx("span",{className:"text-foreground",children:X8(Be,v)})]}),i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"text-muted-foreground",children:"Next"})," ",i.jsx("span",{className:"text-foreground",children:UC(Be==null?void 0:Be.nextRunAt,"-")})]}),se.activeIssue&&Et?i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"text-muted-foreground",children:"Issue"})," ",i.jsx(an,{to:`/issues/${Et}`,className:"text-muted-foreground underline-offset-4 hover:text-foreground hover:underline",children:Et})]}):null]})}),i.jsx(Au,{ref:j,value:te.description,onChange:He=>ce(Rt=>({...Rt,description:He})),mentions:ze,placeholder:"Add instructions...",bordered:!0,className:q("bg-background/40",o&&"rounded-md"),contentClassName:q("text-[15px] leading-7 text-foreground/90",o?"min-h-[220px]":"min-h-[180px] md:min-h-[240px]")})]}),i.jsxs("section",{"aria-label":o?"Previous runs":"Activity",className:q("space-y-3 border-t border-border/70 pt-4",o&&"order-3"),children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[o?null:i.jsx(wq,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:o?"Previous runs":"Activity"})]}),ke&&Ue&&se?i.jsx(Iat,{issueId:Ue,orgId:se.orgId}):null,Ye.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:"No activity yet."}):i.jsx("div",{"data-testid":"automation-activity-list",className:"relative space-y-1 before:absolute before:bottom-2 before:left-[7.5px] before:top-2 before:w-px before:bg-border/70",children:Ye.map(He=>i.jsxs("div",{"data-testid":"automation-activity-row",className:"grid min-h-8 grid-cols-[16px_minmax(0,1fr)] gap-x-2 rounded-sm py-1 text-xs text-muted-foreground sm:grid-cols-[16px_minmax(0,1fr)_auto] sm:items-center",children:[i.jsx("span",{"aria-hidden":"true",className:"relative z-10 row-span-2 flex h-full min-h-6 w-4 items-start justify-center pt-[7px] sm:row-span-1 sm:items-center sm:pt-0",children:i.jsx("span",{className:"h-2 w-2 rounded-full border border-background bg-muted-foreground/40 shadow-[0_0_0_2px_hsl(var(--background))]"})}),i.jsxs("span",{"data-testid":"automation-activity-summary",className:"flex min-w-0 items-baseline gap-x-1.5 overflow-hidden whitespace-nowrap",children:[i.jsx("span",{className:"min-w-0 truncate text-foreground/90",children:He.title}),He.details.length>0&&i.jsx("span",{"data-testid":"automation-activity-details",className:"inline-flex min-w-0 items-baseline gap-x-1.5 overflow-hidden text-muted-foreground",children:He.details.map((Rt,In)=>i.jsxs("span",{className:"min-w-0 truncate",children:[In>0&&i.jsx("span",{className:"mr-1.5 text-border",children:"·"}),Rt]},In))})]}),i.jsx("span",{"data-testid":"automation-activity-time",className:"col-start-2 shrink-0 text-muted-foreground/70 sm:col-start-auto",children:px(He.createdAt)})]},He.id))})]})]}),i.jsx("aside",{className:q("min-w-0 border-t border-border/70 pt-4",o?"order-2":"lg:sticky lg:top-20 lg:self-start lg:border-t-0 lg:pt-0"),children:i.jsxs("div",{"data-testid":"automation-configuration-card",className:q("min-w-0 space-y-6",o?"border-0 bg-transparent p-0":"rounded-md border border-border/70 bg-card/85 p-4 shadow-sm"),children:[i.jsxs(Pee,{title:o?"Details":"Configuration",card:o,children:[i.jsx(ny,{label:"Assignee",children:i.jsx("div",{"data-testid":"automation-detail-agent-control",className:"min-w-0 flex-1",children:i.jsx(Hp,{ref:C,value:te.assigneeAgentId,options:Ee,placeholder:"Select assignee",noneLabel:"No assignee",searchPlaceholder:"Search assignees...",emptyMessage:"No assignees found.",className:"-mx-1 min-h-7 w-full justify-between border-0 bg-transparent px-1 py-0.5 text-sm font-medium shadow-none hover:bg-accent/50",onChange:He=>{He&&NO(He),ce(Rt=>({...Rt,assigneeAgentId:He}))},onConfirm:()=>{var He,Rt;te.projectId?(He=j.current)==null||He.focus():(Rt=N.current)==null||Rt.focus()},renderTriggerValue:He=>He?i.jsx(ez,{children:ot?i.jsxs(i.Fragment,{children:[i.jsx(Ml,{icon:ot.icon,role:ot.role,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"truncate",children:He.label})]}):i.jsx("span",{className:"truncate",children:He.label})}):i.jsx(ez,{children:i.jsx("span",{className:"text-muted-foreground",children:"Select assignee"})}),renderOption:He=>{if(!He.id)return i.jsx("span",{className:"truncate",children:He.label});const Rt=Xe.get(He.id);return i.jsxs(i.Fragment,{children:[Rt?i.jsx(Ml,{icon:Rt.icon,role:Rt.role,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):null,i.jsx("span",{className:"truncate",children:He.label})]})}})})}),i.jsx(ny,{label:"Output",children:i.jsxs(Zo,{value:te.outputMode,onValueChange:He=>ce(Rt=>({...Rt,outputMode:He,chatConversationId:"",notifyOnIssueCreated:He==="track_issue"?Rt.notifyOnIssueCreated:!1})),children:[i.jsx(Xo,{size:"sm",className:"-mx-1 h-7 w-fit border-0 bg-transparent px-1 py-0.5 text-sm shadow-none hover:bg-accent/50",children:i.jsx(Ho,{})}),i.jsxs(Go,{children:[i.jsx(Vs,{value:"track_issue",children:"Track as issue"}),i.jsx(Vs,{value:"chat_output",children:"Send to chat"})]})]})}),te.outputMode==="track_issue"?i.jsx(ny,{label:"Follow created issues",children:i.jsx(zA,{checked:te.notifyOnIssueCreated,size:"sm","aria-label":"Follow issues created by this automation",title:"Follow issues created by this automation",onClick:()=>ce(He=>({...He,notifyOnIssueCreated:!He.notifyOnIssueCreated}))})}):null,o?null:i.jsxs(i.Fragment,{children:[i.jsx(ny,{label:"Repeats",children:i.jsx("span",{className:"min-w-0 truncate text-sm text-foreground",title:X8(Be,v),children:X8(Be,v)})}),i.jsx(ny,{label:"Next run",children:i.jsx("span",{className:"min-w-0 truncate text-sm text-muted-foreground",title:UC(Be==null?void 0:Be.nextRunAt,"-"),children:UC(Be==null?void 0:Be.nextRunAt,"-")})})]}),i.jsx(ny,{label:"Project",children:i.jsx("div",{"data-testid":"automation-detail-project-control",className:"min-w-0 flex-1",children:i.jsx(Hp,{ref:N,value:te.projectId,options:mt,placeholder:"No project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",className:"-mx-1 min-h-7 w-full justify-between border-0 bg-transparent px-1 py-0.5 text-sm font-medium shadow-none hover:bg-accent/50",onChange:He=>ce(Rt=>({...Rt,projectId:He})),onConfirm:()=>{var He;return(He=j.current)==null?void 0:He.focus()},renderTriggerValue:He=>He&&xe?i.jsxs(ez,{children:[i.jsx(Ao,{color:xe.color,icon:xe.icon,size:"xs"}),i.jsx("span",{className:"truncate",children:He.label})]}):i.jsx(ez,{children:i.jsx("span",{className:"text-muted-foreground",children:"No project"})}),renderOption:He=>{if(!He.id)return i.jsx("span",{className:"truncate",children:He.label});const Rt=At.get(He.id);return i.jsxs(i.Fragment,{children:[i.jsx(Ao,{color:Rt==null?void 0:Rt.color,icon:Rt==null?void 0:Rt.icon,size:"xs"}),i.jsx("span",{className:"truncate",children:He.label})]})}})})})]}),i.jsxs(j6,{open:M,onOpenChange:L,"data-testid":"automation-delivery-rules-section",className:"overflow-hidden rounded-md border border-border/70 bg-background/35",children:[i.jsxs(sK,{className:"flex w-full items-center justify-between gap-4 px-3 py-2.5 text-left text-sm font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i.jsx("span",{children:"Delivery rules"}),M?i.jsx(Br,{className:"h-4 w-4"}):i.jsx(_i,{className:"h-4 w-4"})]}),i.jsx(C6,{className:"border-t border-border/60 p-3",children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(ya,{className:"text-xs",children:"Concurrency"}),i.jsxs(Zo,{value:te.concurrencyPolicy,onValueChange:He=>ce(Rt=>({...Rt,concurrencyPolicy:He})),children:[i.jsx(Xo,{size:"sm",className:"w-full bg-background/60",children:i.jsx(Ho,{})}),i.jsx(Go,{children:uNn.map(He=>i.jsx(Vs,{value:He,children:TU(He,v)},He))})]}),i.jsx("p",{className:"text-xs leading-4 text-muted-foreground",children:_U(Eat,te.concurrencyPolicy,v)})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(ya,{className:"text-xs",children:"Catch-up"}),i.jsxs(Zo,{value:te.catchUpPolicy,onValueChange:He=>ce(Rt=>({...Rt,catchUpPolicy:He})),children:[i.jsx(Xo,{size:"sm",className:"w-full bg-background/60",children:i.jsx(Ho,{})}),i.jsx(Go,{children:fNn.map(He=>i.jsx(Vs,{value:He,children:TU(He,v)},He))})]}),i.jsx("p",{className:"text-xs leading-4 text-muted-foreground",children:_U(Dat,te.catchUpPolicy,v)})]})]})})]}),i.jsxs(Pee,{title:o?"Frequency":"Triggers",children:[o?i.jsxs("div",{className:"divide-y divide-border/60 rounded-md border border-border/70 bg-card/70 px-3.5",children:[i.jsx(ny,{label:"Repeat",children:i.jsx("span",{className:"min-w-0 truncate text-sm text-foreground",title:X8(Be,v),children:X8(Be,v)})}),i.jsx(ny,{label:"Next run",children:i.jsx("span",{className:"min-w-0 truncate text-sm text-muted-foreground",title:UC(Be==null?void 0:Be.nextRunAt,"-"),children:UC(Be==null?void 0:Be.nextRunAt,"-")})})]}):null,i.jsxs(es,{open:U,onOpenChange:B,children:[i.jsx(bs,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"automation-trigger-menu-trigger group w-full justify-center rounded-md bg-background/55 shadow-none","data-testid":"automation-add-trigger-button",children:["Add trigger",i.jsx(Br,{className:"h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180"})]})}),i.jsxs(ts,{"data-testid":"automation-add-trigger-card",align:"center",side:"bottom",sideOffset:8,collisionPadding:16,className:"automation-trigger-menu-content glass-popover max-h-[min(28rem,var(--radix-popover-content-available-height))] w-[min(320px,calc(100vw-2rem))] overflow-y-auto rounded-md p-3 text-foreground",children:[i.jsx("div",{className:"px-1 text-sm font-medium text-muted-foreground",children:"Schedule"}),i.jsx(rZ,{variant:"compact",value:re.cronExpression,onChange:He=>ne(Rt=>({...Rt,kind:"schedule",cronExpression:He}))}),i.jsx(ie,{className:"w-full justify-center",size:"sm",onClick:()=>De.mutate(),disabled:De.isPending||!Zt,children:De.isPending?"Adding...":"Create trigger"})]})]}),i.jsx("div",{"data-testid":"automation-triggers-list",className:"space-y-3",children:se.triggers.length===0?i.jsx("div",{className:"rounded-md border border-dashed border-border/80 px-3 py-4 text-sm text-muted-foreground",children:"No triggers configured yet."}):se.triggers.map(He=>i.jsx(pNn,{trigger:He,onSave:dt,onRotate:Rt=>{W(In=>Cee(In,Rt)),Mt.mutate(Rt,{onSettled:()=>W(In=>Nee(In,Rt))})},onDelete:Rt=>{F(In=>Cee(In,Rt)),yt.mutate(Rt,{onSettled:()=>F(In=>Nee(In,Rt))})},isSaving:z.includes(He.id),isDeleting:J.includes(He.id),isRotating:Q.includes(He.id),saveError:$[He.id]??null},He.id))})]}),o?null:i.jsxs(Pee,{title:"Run status",children:[i.jsx(JL,{label:"Last ran",children:i.jsx("span",{className:"truncate",children:ut?px(ut.triggeredAt):"-"})}),i.jsx(JL,{label:"Edits",children:i.jsx("span",{className:vt,children:Pe})}),i.jsx(JL,{label:"Risk",children:i.jsx("span",{className:"truncate",children:Nn})}),ke?i.jsx(JL,{label:"Run",children:i.jsx($i,{variant:"outline",className:"border-blue-500/40 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:"In progress"})}):null]})]})})]})]})}const gNn=Object.freeze(Object.defineProperty({__proto__:null,AutomationDetail:h1e},Symbol.toStringTag,{value:"Module"}));function xNn({...e}){return i.jsx(Qpt,{"data-slot":"context-menu",...e})}function bNn({onClickCapture:e,onKeyDown:t,...n}){return i.jsx(Upt,{"data-slot":"context-menu-trigger",...n,onClickCapture:r=>{e==null||e(r),!(r.defaultPrevented||r.currentTarget.dataset.state!=="open")&&(r.preventDefault(),r.stopPropagation())},onKeyDown:r=>{if(t==null||t(r),r.defaultPrevented||!(r.key==="ContextMenu"||r.code==="ContextMenu"||r.key==="F10"&&r.shiftKey))return;r.preventDefault(),r.stopPropagation();const a=r.currentTarget,o=a.getBoundingClientRect();a.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,button:2,clientX:o.left+Math.min(16,o.width/2),clientY:o.bottom,view:window}))}})}function yNn({className:e,...t}){return i.jsx(Vpt,{children:i.jsx(qpt,{"data-slot":"context-menu-content",className:q("motion-surface-pop bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md",e),...t})})}function Iee({className:e,inset:t,...n}){return i.jsx(Kpt,{"data-slot":"context-menu-item","data-inset":t,className:q("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...n})}function $9e({className:e,...t}){return i.jsx(Wpt,{"data-slot":"context-menu-separator",className:q("bg-border -mx-1 my-1 h-px",e),...t})}function vNn({children:e,closeDisabled:t,isMobile:n,moveInProgress:r,organizationId:s,tab:a,onClose:o,onOpenInNewTab:l,onMoveSideChat:c}){const[d,u]=m.useState(!1),f=a.kind==="side_chat"?a:null,A=Te({queryKey:V.chats.detail(s??"__none__",(f==null?void 0:f.conversationId)??"__side-chat-draft__"),queryFn:()=>rr.get(f.conversationId),enabled:d&&!!(s&&(f!=null&&f.conversationId))}),h=A.data??null,g=!!(f!=null&&f.conversationId&&(A.isPending||A.isFetching)),x=!!(f!=null&&f.conversationId&&!r&&!g&&!A.isError&&(h==null?void 0:h.sideChatState)==="active"&&!mit(h)),y=f!=null&&f.conversationId?r||g?"Checking whether this Side Chat can be moved…":x?"Make this Side Chat a regular Messenger chat. This tab will close.":"This Side Chat can no longer be moved. Close it instead.":"Send a message first to create this Side Chat.";return i.jsxs(xNn,{onOpenChange:v=>{u(v),v&&(f!=null&&f.conversationId)&&A.refetch()},children:[i.jsx(bNn,{asChild:!0,children:e}),i.jsxs(yNn,{"data-testid":"chat-side-panel-tab-context-menu",className:"surface-overlay z-[70] w-48 text-foreground",onContextMenu:v=>v.preventDefault(),children:[f?i.jsxs(i.Fragment,{children:[i.jsx(id,{delayDuration:300,children:i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsxs(Iee,{"aria-disabled":x?void 0:"true","data-disabled":x?void 0:"",onSelect:v=>{if(!x){v.preventDefault();return}c(f)},children:[i.jsx(ka,{}),"Move to Messenger"]})}),i.jsx(Gi,{side:n?"bottom":"left",align:n?"start":"center",collisionPadding:8,className:"z-[80] max-w-[calc(100vw-1rem)] whitespace-normal sm:max-w-xs",children:y})]})}),i.jsx($9e,{})]}):null,_f(a)?i.jsxs(i.Fragment,{children:[i.jsxs(Iee,{onSelect:()=>l(a),children:[i.jsx(U8t,{}),"Open in new tab"]}),i.jsx($9e,{})]}):null,i.jsxs(Iee,{"aria-disabled":t?"true":void 0,"data-disabled":t?"":void 0,onSelect:v=>{if(t){v.preventDefault();return}o(a)},children:[i.jsx(Ls,{}),"Close"]})]})]})}function m1e({className:e,children:t,...n}){return i.jsxs(qgt,{"data-slot":"scroll-area",className:q("relative flex flex-col overflow-hidden",e),...n,children:[i.jsx(Kgt,{"data-slot":"scroll-area-viewport",className:"flex-1 min-h-0 w-full focus-visible:ring-ring/50 rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),i.jsx(wNn,{}),i.jsx(Wgt,{})]})}function wNn({className:e,orientation:t="vertical",...n}){return i.jsx(AMe,{"data-slot":"scroll-area-scrollbar",orientation:t,className:q("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:i.jsx(gMe,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function EU({...e}){return i.jsx(E_,{"data-slot":"sheet",...e})}function kNn({...e}){return i.jsx(WIe,{"data-slot":"sheet-trigger",...e})}function SNn({...e}){return i.jsx(D_,{"data-slot":"sheet-portal",...e})}function ONn({className:e,...t}){return i.jsx(R_,{"data-slot":"sheet-overlay",className:q("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function DU({className:e,children:t,side:n="right",showCloseButton:r=!0,...s}){return i.jsxs(SNn,{children:[i.jsx(ONn,{}),i.jsxs(zO,{"data-slot":"sheet-content",className:q("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition [animation-timing-function:var(--motion-ease-enter)] data-[state=closed]:duration-[var(--motion-duration-standard)] data-[state=open]:duration-[var(--motion-duration-emphasis)] motion-reduce:animate-none motion-reduce:transition-none",n==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",n==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",n==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",n==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...s,children:[t,r&&i.jsxs($O,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[i.jsx(Ls,{className:"size-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function RU({className:e,...t}){return i.jsx("div",{"data-slot":"sheet-header",className:q("flex flex-col gap-1.5 p-4",e),...t})}function jNn({className:e,...t}){return i.jsx("div",{"data-slot":"sheet-footer",className:q("mt-auto flex flex-col gap-2 p-4",e),...t})}function LU({className:e,...t}){return i.jsx(L_,{"data-slot":"sheet-title",className:q("text-foreground font-semibold",e),...t})}function CNn({className:e,...t}){return i.jsx(ZIe,{"data-slot":"sheet-description",className:q("text-muted-foreground text-sm",e),...t})}const NNn=new Set(["detailTab","taskDetailView","contextMenuItem","commentAnnotation","commentContextMenuItem","projectSidebarItem","toolbarButton"]),zat=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(","),PNn=1e3,INn=new Set(jDe),$at=m.createContext(null);function TNn(e){return e instanceof Error&&e.message?e.message:"Unknown error"}function _Nn(e,t,n){return{orgId:e.orgId??null,orgPrefix:e.orgPrefix??null,projectId:e.projectId??(e.entityType==="project"?e.entityId??null:null),entityId:e.entityId??null,entityType:e.entityType??null,userId:n,renderEnvironment:t}}function MNn(e){if(!e)return;const t=e.querySelector(zat);if(t){t.focus();return}e.focus()}function ENn(e,t){if(t.key!=="Tab")return;const n=Array.from(e.querySelectorAll(zat)).filter(o=>!o.hasAttribute("disabled")&&o.tabIndex!==-1);if(n.length===0){t.preventDefault(),e.focus();return}const r=n[0],s=n[n.length-1],a=document.activeElement;if(t.shiftKey&&a===r){t.preventDefault(),s.focus();return}!t.shiftKey&&a===s&&(t.preventDefault(),r.focus())}function DNn(e){switch(e){case"projectSidebarItem":return"justify-start h-auto px-3 py-1 text-[12px] font-normal text-muted-foreground hover:text-foreground";case"contextMenuItem":case"commentContextMenuItem":return"justify-start h-7 w-full px-2 text-xs font-normal";case"sidebar":case"sidebarPanel":return"justify-start h-8 w-full";case"toolbarButton":case"globalToolbarButton":return"h-8";default:return"h-8"}}function Fat(e){switch(e){case"compact":return{width:"min(28rem, calc(100vw - 2rem))"};case"wide":return{width:"min(64rem, calc(100vw - 2rem))"};case"full":return{width:"calc(100vw - 2rem)",height:"calc(100vh - 2rem)"};case"inline":return{width:"min(24rem, calc(100vw - 2rem))"};case"default":default:return{width:"min(40rem, calc(100vw - 2rem))"}}}function RNn(e){const t=e.sourceRect,n=Fat(e.bounds).width??"min(24rem, calc(100vw - 2rem))";if(!t)return{width:n,maxHeight:"min(70vh, 36rem)",top:"4rem",left:"50%",transform:"translateX(-50%)"};const r=Math.min(t.bottom+8,window.innerHeight-32),s=Math.min(Math.max(t.left,16),Math.max(16,window.innerWidth-360));return{width:n,maxHeight:"min(70vh, 36rem)",top:r,left:s}}function LNn(e){return typeof e=="string"&&INn.has(e)}function Bat(e){const t=e.enabled??!0,{data:n,isLoading:r,error:s}=Te({queryKey:V.plugins.uiContributions,queryFn:()=>Ya.listUiContributions(),enabled:t}),a=m.useMemo(()=>[...e.placementZones].sort().join("|"),[e.placementZones]),o=m.useMemo(()=>{const c=new Map;for(const d of n??[])c.set(d.pluginId,d);return c},[n]);return{launchers:m.useMemo(()=>{var u;const c=new Set(a.split("|").filter(Boolean)),d=[];for(const f of n??[])for(const A of f.launchers)c.has(A.placementZone)&&(NNn.has(A.placementZone)&&(!e.entityType||!((u=A.entityTypes)!=null&&u.includes(e.entityType)))||d.push({...A,pluginId:f.pluginId,pluginKey:f.pluginKey,pluginDisplayName:f.displayName,pluginVersion:f.version,uiEntryFile:f.uiEntryFile}));return d.sort((f,A)=>{const h=f.order??Number.MAX_SAFE_INTEGER,g=A.order??Number.MAX_SAFE_INTEGER;if(h!==g)return h-g;const x=f.pluginDisplayName.localeCompare(A.pluginDisplayName);return x!==0?x:f.displayName.localeCompare(A.displayName)}),d},[n,e.entityType,a]),contributionsByPluginId:o,isLoading:t&&r,errorMessage:s?TNn(s):null}}async function zNn(e,t){const n=t.action.target,r=r3e(t.pluginKey,n);return r||(await d$t(e),r3e(t.pluginKey,n))}function $Nn({pluginId:e,hostContext:t,children:n}){const r=m.useMemo(()=>({pluginId:e,hostContext:t}),[e,t]);return i.jsx(Afe.Provider,{value:r,children:n})}class FNn extends m.Component{constructor(){super(...arguments);ai(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,r){console.error("Plugin launcher render failed",{pluginKey:this.props.launcher.pluginKey,launcherId:this.props.launcher.id,error:n,info:r.componentStack})}render(){return this.state.hasError?i.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive",children:[this.props.launcher.pluginDisplayName,": failed to render"]}):this.props.children}}function BNn({instance:e,renderEnvironment:t}){var l,c;const n=e.component,{data:r}=Te({queryKey:V.auth.session,queryFn:()=>el.getSession()}),s=((l=r==null?void 0:r.user)==null?void 0:l.id)??((c=r==null?void 0:r.session)==null?void 0:c.userId)??null,a=m.useMemo(()=>_Nn(e.hostContext,t,s),[e.hostContext,t,s]);if(!n)return t.environment==="iframe"?i.jsx("iframe",{src:`/_plugins/${encodeURIComponent(e.launcher.pluginId)}/ui/${e.launcher.action.target}`,title:`${e.launcher.pluginDisplayName} ${e.launcher.displayName}`,className:"h-full min-h-[24rem] w-full rounded-md border border-border bg-background"}):i.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive",children:[e.launcher.pluginDisplayName,': could not resolve launcher target "',e.launcher.action.target,'".']});if(n.kind==="web-component")return m.createElement(n.tagName,{className:"block w-full",pluginLauncher:e.launcher,pluginContext:a});const o=m.createElement(n.component,{launcher:e.launcher,context:a});return i.jsx(FNn,{launcher:e.launcher,children:i.jsx($Nn,{pluginId:e.launcher.pluginId,hostContext:a,children:o})})}function QNn({instance:e,stackIndex:t,isTopmost:n,requestBounds:r,closeLauncher:s}){const a=m.useRef(null),o=m.useId();m.useEffect(()=>{if(!n)return;const A=requestAnimationFrame(()=>{MNn(a.current)});return()=>cancelAnimationFrame(A)},[n]),m.useEffect(()=>{if(!n)return;const A=h=>{if(a.current){if(h.key==="Escape"){h.preventDefault(),s(e.key,{reason:"escapeKey",nativeEvent:h});return}ENn(a.current,h)}};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[s,e.key,n]);const l=m.useMemo(()=>{var A;return{environment:((A=e.launcher.render)==null?void 0:A.environment)??"hostOverlay",launcherId:e.launcher.id,bounds:e.bounds,requestModalBounds:h=>r(e.key,h),closeLifecycle:{onBeforeClose:h=>(e.beforeCloseHandlers.add(h),()=>e.beforeCloseHandlers.delete(h)),onClose:h=>(e.closeHandlers.add(h),()=>e.closeHandlers.delete(h))}}},[e,r]),c=PNn+t*20,d=e.launcher.action.type,u=d==="openPopover"?RNn(e):Fat(e.bounds),f=d==="openDrawer"?"fixed right-0 top-0 h-full max-w-[min(44rem,100vw)] overflow-hidden border-l border-border bg-background shadow-2xl":d==="openPopover"?"fixed overflow-hidden rounded-xl border border-border bg-background shadow-2xl":"fixed left-1/2 top-1/2 max-h-[calc(100vh-2rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-2xl border border-border bg-background shadow-2xl";return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 bg-black/45",style:{zIndex:c},"aria-hidden":"true",onMouseDown:A=>{n&&A.target===A.currentTarget&&s(e.key,{reason:"backdrop",nativeEvent:A})}}),i.jsxs("div",{ref:a,role:"dialog","aria-modal":"true","aria-labelledby":o,tabIndex:-1,className:f,style:{zIndex:c+1,...d==="openDrawer"?{width:u.width??"min(44rem, 100vw)"}:u},onMouseDown:A=>A.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center gap-3 border-b border-border px-4 py-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h2",{id:o,className:"truncate text-sm font-semibold",children:e.launcher.displayName}),i.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.launcher.pluginDisplayName})]}),i.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>void s(e.key,{reason:"programmatic"}),children:"Close"})]}),i.jsx("div",{className:q("overflow-auto p-4",d==="openDrawer"?"h-[calc(100%-3.5rem)]":"max-h-[calc(100vh-7rem)]"),children:i.jsx(BNn,{instance:e,renderEnvironment:l})})]})]})}function UNn({children:e}){const[t,n]=m.useState([]),r=m.useRef(t);r.current=t;const s=br(),a=Hr(),o=m.useCallback(async(u,f)=>{const A=r.current.find(h=>h.key===u);if(A){for(const h of[...A.beforeCloseHandlers])await h(f);n(h=>h.filter(g=>g.key!==u)),queueMicrotask(()=>{for(const h of[...A.closeHandlers])h(f);A.sourceElement&&document.contains(A.sourceElement)&&A.sourceElement.focus()})}},[]);m.useEffect(()=>{t.length!==0&&Promise.all(t.map(u=>o(u.key,{reason:"hostNavigation"})))},[s.key]);const l=m.useCallback(async(u,f)=>{LNn(f.bounds)&&n(A=>A.map(h=>h.key===u?{...h,bounds:f.bounds}:h))},[]),c=m.useCallback(async(u,f,A,h)=>{var g;switch(u.action.type){case"navigate":a(u.action.target);return;case"deepLink":/^https?:\/\//.test(u.action.target)?window.open(u.action.target,"_blank","noopener,noreferrer"):a(u.action.target);return;case"performAction":await Ya.bridgePerformAction(u.pluginId,u.action.target,u.action.params,f.orgId??null);return;case"openModal":case"openDrawer":case"openPopover":{const x=await zNn(A,u),y=(h==null?void 0:h.getBoundingClientRect())??null,v={key:`${u.pluginId}:${u.id}:${Date.now()}:${Math.random().toString(36).slice(2,8)}`,launcher:u,hostContext:f,contribution:A,component:x,sourceElement:h??null,sourceRect:y,bounds:((g=u.render)==null?void 0:g.bounds)??"default",beforeCloseHandlers:new Set,closeHandlers:new Set};n(w=>[...w,v]);return}}},[a]),d=m.useMemo(()=>({activateLauncher:c}),[c]);return i.jsxs($at.Provider,{value:d,children:[e,t.map((u,f)=>i.jsx(QNn,{instance:u,stackIndex:f,isTopmost:f===t.length-1,requestBounds:l,closeLauncher:o},u.key))]})}function VNn(){const e=m.useContext($at);if(!e)throw new Error("usePluginLauncherRuntime must be used within PluginLauncherProvider");return e}function qNn({launcher:e,placementZone:t,onClick:n}){return i.jsx(ie,{type:"button",variant:t==="toolbarButton"||t==="globalToolbarButton"?"outline":"ghost",size:"sm",className:DNn(t),onClick:n,children:e.displayName})}function p1e({placementZones:e,context:t,entityType:n,className:r,itemClassName:s,errorClassName:a}){const{activateLauncher:o}=VNn(),{launchers:l,contributionsByPluginId:c,errorMessage:d}=Bat({placementZones:e,entityType:n,orgId:t.orgId,enabled:!!t.orgId});return d?i.jsxs("div",{className:q("rounded-md border border-destructive/30 bg-destructive/5 px-2 py-1 text-xs text-destructive",a),children:["Plugin launchers unavailable: ",d]}):l.length===0?null:i.jsx("div",{className:r,children:l.map(u=>i.jsx("div",{className:s,children:i.jsx(qNn,{launcher:u,placementZone:u.placementZone,onClick:f=>{const A=c.get(u.pluginId);A&&o(u,t,A,f.currentTarget)}})},`${u.pluginKey}:${u.id}`))})}const KNn="mark[data-issue-find-highlight='true']",Qat="rudder-issue-find-highlight",rle="rudder-issue-find-highlight-active",WNn=["[data-issue-find-ui]","input","textarea","select","script","style","noscript","[aria-hidden='true']"].join(","),Uat="color-mix(in oklab, #f4c430 62%, transparent)",ZNn="color-mix(in oklab, var(--accent-base) 58%, #f4c430)",HNn="0 0 0 1px color-mix(in oklab, var(--accent-strong) 62%, transparent)";function XNn(e){e.style.borderRadius="2px",e.style.background=Uat,e.style.color="inherit",e.style.padding="0 1px"}function Tee(e,t){var n;return((n=e.ownerDocument.defaultView)==null?void 0:n.NodeFilter[t])??(t==="FILTER_ACCEPT"?1:t==="FILTER_REJECT"?2:4)}function g1e(e){var n;const t=e.defaultView;return!((n=t==null?void 0:t.CSS)!=null&&n.highlights)||!t.Highlight?null:{Highlight:t.Highlight,highlights:t.CSS.highlights}}function GNn(e){const t=e instanceof HTMLElement?e:null;return t?t.isContentEditable?!0:!!t.closest("input, textarea, select, [contenteditable='true']"):!1}function YNn(e){return e.defaultPrevented||e.key.toLowerCase()!=="f"||!e.metaKey&&!e.ctrlKey?!1:!e.altKey&&!e.shiftKey}function Z$(e){const t=g1e(e.ownerDocument);t==null||t.highlights.delete(Qat),t==null||t.highlights.delete(rle);const n=Array.from(e.querySelectorAll(KNn));for(const r of n){const s=r.parentNode;if(s){for(;r.firstChild;)s.insertBefore(r.firstChild,r);s.removeChild(r),s.normalize()}}}function JNn(e){return e.isContentEditable||e.matches("[contenteditable='true']")}function ePn(e,t){var a,o;const n=e.parentElement;if(!n||n.closest(WNn))return!1;const r=n.ownerDocument.activeElement,s=n.closest("[contenteditable='true']");return s&&t.mode==="css"&&!t.canUseCssHighlights||(a=t.skipElement)!=null&&a.contains(n)&&(!JNn(t.skipElement)||!t.canUseCssHighlights)?!1:s&&r instanceof Node&&s.contains(r)?t.canUseCssHighlights:!!((o=e.nodeValue)!=null&&o.trim())}function tPn(e,t,n={}){Z$(e);const r=t.trim();if(!r)return[];const s=e.ownerDocument,a=n.mode==="css"?g1e(s):null,o=!!a,l=[],c=s.createTreeWalker(e,Tee(e,"SHOW_TEXT"),{acceptNode:h=>ePn(h,{canUseCssHighlights:o,mode:n.mode??"mark",skipElement:n.skipElement})?Tee(e,"FILTER_ACCEPT"):Tee(e,"FILTER_REJECT")});let d=c.nextNode();for(;d;)l.push(d),d=c.nextNode();const u=[],f=r.toLocaleLowerCase(),A=r.length;for(const h of l){const g=h.nodeValue??"",x=g.toLocaleLowerCase();let y=0,v=x.indexOf(f,y);if(v===-1)continue;if(a){for(;v!==-1;){const k=s.createRange();k.setStart(h,v),k.setEnd(h,v+A),u.push(k),y=v+A,v=x.indexOf(f,y)}continue}const w=s.createDocumentFragment();for(;v!==-1;){v>y&&w.append(s.createTextNode(g.slice(y,v)));const k=s.createElement("mark");k.dataset.issueFindHighlight="true",k.className="issue-find-highlight",XNn(k),k.textContent=g.slice(v,v+A),w.append(k),u.push(k),y=v+A,v=x.indexOf(f,y)}y<g.length&&w.append(s.createTextNode(g.slice(y))),h.replaceWith(w)}if(a&&u.length>0){const h=u.filter(g=>g instanceof Range);a.highlights.set(Qat,new a.Highlight(...h))}return u}function F9e(e,t){let n=null;const r=e.find(o=>o instanceof Range)??null,s=(r==null?void 0:r.startContainer.ownerDocument)??null,a=s?g1e(s):null;if(a){const o=e[t]instanceof Range?e[t]:null;return o?(a.highlights.set(rle,new a.Highlight(o)),n=o):a.highlights.delete(rle),n}for(let o=0;o<e.length;o+=1){const l=e[o];if(!(l instanceof HTMLElement))continue;const c=o===t;l.dataset.issueFindActive=c?"true":"false",l.classList.toggle("issue-find-highlight--active",c),l.style.background=c?ZNn:Uat,l.style.boxShadow=c?HNn:"",c&&(n=l)}return n}function B9e(e){var r,s;if(!e)return;if(e instanceof HTMLElement){(r=e.scrollIntoView)==null||r.call(e,{block:"center",inline:"nearest",behavior:"smooth"});return}const t=e.startContainer.parentNode,n=t instanceof HTMLElement?t:null;(s=n==null?void 0:n.scrollIntoView)==null||s.call(n,{block:"center",inline:"nearest",behavior:"smooth"})}function nPn(){return typeof document>"u"?!1:!!(document.querySelector("[role='dialog']")||document.querySelector("[data-radix-popper-content-wrapper]"))}function rPn(e){return e.key==="Escape"&&!e.defaultPrevented&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey}function Vat({rootRef:e,disabled:t=!1,refreshKey:n,searchLabel:r="Find in issue",highlightMode:s="mark"}){const[a,o]=m.useState(!1),[l,c]=m.useState(""),[d,u]=m.useState(0),[f,A]=m.useState(0),h=m.useRef(null),g=m.useRef([]),x=m.useRef(0),y=m.useRef(""),v=m.useRef(null),w=m.useCallback(()=>{requestAnimationFrame(()=>{var C,N;(C=h.current)==null||C.focus(),(N=h.current)==null||N.select()})},[]),k=m.useCallback(()=>{const C=e.current;C&&Z$(C),g.current=[],x.current=0,y.current="",v.current=null,o(!1),c(""),u(0),A(0)},[e]),O=m.useCallback(C=>{const N=g.current;if(N.length===0){x.current=0,A(0);return}const I=(x.current+C+N.length)%N.length;x.current=I,A(I);const E=F9e(N,I);B9e(E)},[]);if(m.useEffect(()=>{t&&a&&k()},[k,t,a]),m.useEffect(()=>{const C=N=>{if(t)return;if(YNn(N)){if(nPn())return;const _=N.target instanceof HTMLElement?N.target:null;v.current=(_==null?void 0:_.closest("input, textarea, select, [contenteditable='true']"))??null,N.preventDefault(),o(!0),w();return}if(!a||!rPn(N))return;const I=N.target instanceof HTMLElement?N.target:null;!(I!=null&&I.closest("[data-issue-find-ui]"))&&GNn(N.target)||(N.preventDefault(),k())};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[k,t,w,a]),m.useLayoutEffect(()=>{const C=e.current;if(!C||!a)return;const N=tPn(C,l,{mode:s,skipElement:v.current});g.current=N,u(N.length);const I=l.trim(),E=y.current!==I;y.current=I;const _=N.length===0||E?0:Math.min(x.current,N.length-1);x.current=_,A(_);const T=F9e(N,_);return I&&T&&B9e(T),()=>{Z$(C),g.current=[]}},[s,a,l,n,e]),m.useEffect(()=>()=>{const C=e.current;C&&Z$(C)},[e]),!a)return null;const j=d===0?"0 of 0":`${f+1} of ${d}`;return i.jsxs("div",{"data-issue-find-ui":!0,role:"search","aria-label":r,className:"fixed right-4 top-4 z-50 flex w-[min(420px,calc(100vw-2rem))] items-center gap-1 rounded-md border border-border bg-popover p-1.5 text-popover-foreground shadow-md",children:[i.jsx(Pl,{className:"ml-1 h-4 w-4 shrink-0 text-muted-foreground"}),i.jsx(Vn,{ref:h,value:l,onChange:C=>c(C.target.value),onKeyDown:C=>{if(C.key==="Enter"){C.preventDefault(),O(C.shiftKey?-1:1);return}if(C.key==="ArrowDown"){C.preventDefault(),O(1);return}if(C.key==="ArrowUp"){C.preventDefault(),O(-1);return}C.key==="Escape"&&(C.preventDefault(),k())},className:"h-7 min-w-0 flex-1 border-0 bg-transparent px-1 text-sm shadow-none focus-visible:ring-0",placeholder:"Find","aria-label":r}),i.jsx("span",{className:"min-w-14 shrink-0 text-right text-xs tabular-nums text-muted-foreground",children:j}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Previous match",disabled:d===0,onClick:()=>O(-1),children:i.jsx(Xde,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Next match",disabled:d===0,onClick:()=>O(1),children:i.jsx(RLe,{className:"h-3.5 w-3.5"})}),i.jsx(ie,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Close find",onClick:k,children:i.jsx(Ls,{className:"h-3.5 w-3.5"})})]})}function sPn(e){return e.identifier??e.id.slice(0,8)}function iPn({parentIssue:e}){if(!e)return null;const t=sPn(e);return i.jsxs("div",{"aria-label":"Parent issue context",className:"flex min-w-0 items-center gap-2 text-sm leading-5 text-muted-foreground",children:[i.jsx("span",{className:"shrink-0",children:"Sub-issue of"}),i.jsxs(an,{to:tM(e),className:"inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md px-1 py-0.5 text-foreground transition-colors hover:bg-accent/50",children:[i.jsx(ni,{status:e.status,className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"max-w-28 shrink truncate font-mono text-xs text-muted-foreground",children:t}),i.jsx("span",{className:"min-w-0 truncate",children:e.title})]}),i.jsx(Dw,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"})]})}function Q9e(){const e=document.getElementById("main-content");if(e instanceof HTMLElement){const t=window.getComputedStyle(e).overflowY;if((t==="auto"||t==="scroll"||t==="overlay")&&e.scrollHeight>e.clientHeight+1)return{type:"element",element:e}}return{type:"window"}}function aPn(e){return e.type==="element"?e.element.scrollHeight-e.element.scrollTop-e.element.clientHeight:(document.scrollingElement??document.documentElement).scrollHeight-window.scrollY-window.innerHeight}function qat(){const[e,t]=m.useState(!1);m.useEffect(()=>{const r=()=>{t(aPn(Q9e())>300)},s=document.getElementById("main-content");return r(),s==null||s.addEventListener("scroll",r,{passive:!0}),window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),()=>{s==null||s.removeEventListener("scroll",r),window.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[]);const n=m.useCallback(()=>{const r=Q9e();if(r.type==="element"){r.element.scrollTo({top:r.element.scrollHeight,behavior:"smooth"});return}const s=document.scrollingElement??document.documentElement;window.scrollTo({top:s.scrollHeight,behavior:"smooth"})},[]);return e?i.jsx("button",{onClick:n,className:"fixed bottom-[calc(1.5rem+5rem+env(safe-area-inset-bottom))] right-6 z-40 flex h-9 w-9 items-center justify-center rounded-full border border-border bg-background shadow-md hover:bg-accent transition-colors md:bottom-6","aria-label":"Scroll to bottom",children:i.jsx(RLe,{className:"h-4 w-4"})}):null}const Kat="rudder:starred-issues";function oPn(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(Kat);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.length>0):[]}catch{return[]}}function U9e(){if(!(typeof window>"u"))try{window.localStorage.removeItem(Kat)}catch{}}function x1e(e){const t=Wn(),n=m.useRef(null),r=m.useRef(null),s=Te({queryKey:V.issues.follows(e??"__none__"),queryFn:()=>fr.listFollows(e),enabled:!!e}),a=m.useMemo(()=>new Set((s.data??[]).map(l=>l.issueId)),[s.data]);m.useEffect(()=>{if(!e||!s.isSuccess||n.current===e||r.current===e)return;const l=oPn();if(l.length===0){n.current=e;return}const c=l.filter(d=>!a.has(d));if(c.length===0){U9e(),n.current=e;return}r.current=e,Promise.allSettled(c.map(d=>fr.follow(d))).then(async d=>{r.current=null,!d.some(f=>f.status==="rejected")&&(U9e(),n.current=e,await t.invalidateQueries({queryKey:V.issues.follows(e)}),await t.invalidateQueries({queryKey:V.issues.list(e)}),await vA(t,e),await t.invalidateQueries({queryKey:V.messenger.issues(e)}))})},[a,s.isSuccess,e,t]);const o=m.useCallback(async l=>{e&&(a.has(l)?await fr.unfollow(l):await fr.follow(l),await t.invalidateQueries({queryKey:V.issues.follows(e)}),await t.invalidateQueries({queryKey:V.issues.list(e)}),await vA(t,e),await t.invalidateQueries({queryKey:V.messenger.issues(e)}))},[a,e,t]);return{follows:s.data??[],followedIssueIds:a,isLoading:s.isLoading,error:s.error instanceof Error?s.error:null,toggleFollowIssue:o}}function sZ(e,t,n,r){return e==="system"?"System":e==="user"?n&&t===n?Dfe(r):"Board":t||"Unknown"}function lPn(e,t,n,r){var s;return e.actorType==="agent"?((s=t.get(e.actorId))==null?void 0:s.name)??e.actorId??"Unknown":sZ(e.actorType,e.actorId,n,r)}function cPn(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.label=="string"&&typeof t.href=="string"}function zU(e,t){return{issueDetailBreadcrumb:{label:e,href:t}}}function dPn(e){if(typeof e!="object"||e===null)return null;const t=e.issueDetailBreadcrumb;return cPn(t)?t:null}const V9e={addFromLibrary:{en:"Add from Library","zh-CN":"从文档添加"},attachFromLibrary:{en:"Attach from Library","zh-CN":"从文档添加"},attachFromLibraryDescription:{en:"Choose a file to copy into this issue's attachments.","zh-CN":"选择要复制到此任务附件的文件。"},agentPrivateSkillsHelp:{en:"Agent-private skills belong to this agent only. Edit them in Library, then enable them here when you want Rudder to load them.","zh-CN":"智能体私有技能只属于当前智能体。先在文档中编辑,需要 Rudder 加载时再在这里启用。"},couldNotLoadLibraryFiles:{en:"Could not load Library files","zh-CN":"无法加载文档文件"},editInLibrary:{en:"Edit in Library","zh-CN":"在文档中编辑"},findInLibrary:{en:"Find in Library","zh-CN":"在文档中查找"},importSkillsIntoLibraryFirst:{en:"Import or scan skills into Library first, then enable them here.","zh-CN":"请先将技能导入或扫描到文档中,然后在这里启用。"},legacyLibraryDocument:{en:"Legacy Library document","zh-CN":"旧版文档"},library:{en:"Library","zh-CN":"文档"},libraryFiles:{en:"Library files","zh-CN":"文档文件"},linkedLibrary:{en:"Linked Library","zh-CN":"关联文档"},liveLibraryFile:{en:"live Library file","zh-CN":"实时文档文件"},liveLibraryFolder:{en:"live Library folder","zh-CN":"实时文档文件夹"},liveLibraryLink:{en:"live Library link","zh-CN":"实时文档链接"},noLibraryFiles:{en:"No Library files available.","zh-CN":"暂无文档文件。"},noMatchingLibraryFiles:{en:"No matching Library files.","zh-CN":"没有匹配的文档文件。"},projectContextHelp:{en:"Attach the codebases, Library files, URLs, and external systems agents should use for this project.","zh-CN":"添加这个项目中智能体应使用的代码库、文档文件、URL 和外部系统。"},organizationSkillsHelp:{en:"Bundled Rudder skills are locked on. Community presets and other organization skills stay optional; Library-backed skills can be edited from Library.","zh-CN":"内置 Rudder 技能固定开启。社区预设和其他组织技能保持可选;由文档库支持的技能可在文档中编辑。"},resourceNotFoundInProjectLibrary:{en:"Resource not found in this project Library.","zh-CN":"在这个项目文档中未找到资源。"},searchLibraryPlaceholder:{en:"Search Library or paste relative path","zh-CN":"搜索文档或粘贴相对路径"},libraryDocumentUnavailable:{en:"This Library document could not be found or is not available in this organization.","zh-CN":"找不到这个文档,或它在当前组织中不可用。"},readOnlyInLibrary:{en:"This file is rendered read-only in Library.","zh-CN":"这个文件在文档中以只读方式呈现。"},cannotRenderInLibrary:{en:"This file cannot be rendered in Library.","zh-CN":"这个文件无法在文档中呈现。"},useThisLibraryPath:{en:"Use this Library path","zh-CN":"使用这个文档路径"}};function ji(e,t){return V9e[e][t]??V9e[e].en}const Wat="rudder:recent-issues",uPn=50,sle="rudder:recent-issues-changed";function b1e(e){return[...new Set(e.filter(t=>typeof t=="string"&&t.length>0))]}function q9e(e){if(typeof window>"u")return{exists:!1,values:[]};try{const t=window.localStorage.getItem(e);if(t===null)return{exists:!1,values:[]};const n=JSON.parse(t);return Array.isArray(n)?{exists:!0,values:b1e(n)}:{exists:!0,values:[]}}catch{return{exists:!1,values:[]}}}function Zat(e){return`${Wat}:${e}`}function tk(e){if(!e)return[];const t=q9e(Zat(e));return t.exists?t.values:q9e(Wat).values}function fPn(e,t){const n=b1e(t).slice(0,uPn);if(typeof window>"u")return n;try{window.localStorage.setItem(Zat(e),JSON.stringify(n))}catch{}try{window.dispatchEvent(new CustomEvent(sle,{detail:{orgId:e,issueIds:n}}))}catch{}return n}function y1e(e,t,n){return fPn(e,[t,...n])}function APn(e,t){const n=new Map(t.map(r=>[r.id,r]));return b1e(e).map(r=>n.get(r)).filter(r=>!!r)}function hPn(e){const t=new URLSearchParams({issueId:e.id});return e.projectId&&t.set("projectId",e.projectId),e.assigneeAgentId&&t.set("agentId",e.assigneeAgentId),`/messenger/chat?${t.toString()}`}const mPn=[];function pPn(e){var s,a,o,l,c;const t=((s=e.issue)==null?void 0:s.title)??e.issueId??"Issue",n=((a=e.issue)==null?void 0:a.identifier)??((o=e.issue)!=null&&o.id?e.issue.id.slice(0,8):null),r=n&&((l=e.issue)!=null&&l.title)?`${n} ${e.issue.title}`:t;return[e.sourceBreadcrumb,...[...((c=e.issue)==null?void 0:c.ancestors)??[]].reverse().map(d=>({label:d.title,href:`/issues/${d.identifier??d.id}`})),{label:r}]}const gPn={assigneeAgentId:"assignee",assigneeUserId:"assignee",assigneeAgentRuntimeOverrides:"assignee runtime overrides",billingCode:"billing code",executionWorkspaceId:"run workspace",executionWorkspacePreference:"run workspace preference",executionWorkspaceSettings:"run workspace settings",goalId:"goal",hiddenAt:"visibility",labelIds:"labels",parentId:"parent issue",projectId:"project",projectWorkspaceId:"project workspace",requestDepth:"request depth",reviewerAgentId:"reviewer",reviewerUserId:"reviewer"},K9e={"issue.created":"created the issue","issue.updated":"updated the issue","issue.checked_out":"checked out the issue","issue.released":"released the issue","issue.comment_updated":"edited a comment","issue.comment_deleted":"deleted a comment","issue.code_committed":"committed code","issue.passive_followup_queued":"queued passive follow-up","issue.closure_needs_operator_review":"needs operator review for close-out","issue.review_decision_recorded":"recorded a reviewer decision","issue.attachment_added":"added an attachment","issue.attachment_removed":"removed an attachment","issue.approval_linked":"linked an approval","issue.approval_unlinked":"unlinked an approval","issue.document_created":"created a document","issue.document_updated":"updated a document","issue.document_deleted":"deleted a document","issue.deleted":"deleted the issue","agent.created":"created an agent","agent.updated":"updated the agent","agent.paused":"paused the agent","agent.resumed":"resumed the agent","agent.terminated":"terminated the agent","heartbeat.invoked":"invoked a heartbeat","heartbeat.cancelled":"cancelled a heartbeat","approval.created":"requested approval","approval.approved":"approved","approval.rejected":"rejected"},xPn=new Set(["issue.comment_updated","issue.comment_deleted","issue.deleted"]);function I5(e){return typeof e!="string"?String(e??"none"):e.replace(/_/g," ")}function bPn(e){return gPn[e]??e.replace(/Id$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()}function zN(e){return e!=null&&e!==""}function yPn(e,t,n){return zN(t)&&zN(n)?`changed the ${e}`:zN(t)?`set the ${e}`:zN(n)?`cleared the ${e}`:`updated the ${e}`}function vPn(e,t){return MA(e,t)??e.slice(0,8)}function tz(e,t,n){var r;return e?typeof e.agentId=="string"&&e.agentId?((r=t.get(e.agentId))==null?void 0:r.name)??e.agentId.slice(0,8):typeof e.userId=="string"&&e.userId?vPn(e.userId,n):null:null}function W9e(e){return e.toLabel?e.fromLabel?`${e.changedVerb} from ${e.fromLabel} to ${e.toLabel}`:`${e.assignedVerb} to ${e.toLabel}`:e.fromLabel?`${e.clearedVerb} ${e.fromLabel}`:e.unassignedVerb}function nx(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function Z9e(e){const t=nx(e);return!t||typeof t.id!="string"?null:{id:t.id,identifier:typeof t.identifier=="string"?t.identifier:null,title:typeof t.title=="string"?t.title:null}}function wPn(e){return e.identifier||e.title||e.id.slice(0,8)}function kPn(e){return`/issues/${e.identifier??e.id}`}function H9e(e){return i.jsx(an,{to:kPn(e),className:"underline underline-offset-4 hover:text-foreground",children:wPn(e)})}function Hat(e){return uq(e)}function SPn(e){return ORe(e.action,e.details)}function OPn(e){return!(e.action==="issue.comment_added"||xPn.has(e.action)||e.action==="issue.document_updated"||e.action==="issue.updated"&&Hat(e.details).length===0||SPn(e))}function VC(e,...t){if(!e)return 0;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return 0}function X9e(e,...t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}return null}const jPn=["backlog","todo","in_progress","in_review","done","cancelled","blocked"],CPn="image/*,application/pdf,text/plain,text/markdown,application/json,text/csv,text/html,.md,.markdown",Xat="rudder.linear",NPn="linear-issue-tab",G9e="issue-link";function H$(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function Y9e(e){return e.pluginKey===Xat&&e.id===NPn}function PPn(e){var t;return((t=e.displayLabel)==null?void 0:t.trim())||e.name}function IPn(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function TPn({orgId:e,open:t,onOpenChange:n,onAttach:r,attaching:s,error:a}){var g;const[o,l]=m.useState(""),[c,d]=m.useState(null);m.useEffect(()=>{t&&(l(""),d(null))},[t,e]);const u=Te({queryKey:V.organizations.workspaceFiles(e??"__none__",o),queryFn:()=>En.listWorkspaceFiles(e,o),enabled:t&&!!e,refetchOnWindowFocus:!1}),f=((g=u.data)==null?void 0:g.entries)??[],A=o.length>0,{locale:h}=as();return i.jsx(ws,{open:t,onOpenChange:n,children:i.jsxs(Ps,{className:"sm:max-w-xl",children:[i.jsxs(Ai,{children:[i.jsx(Js,{className:"text-base",children:ji("attachFromLibrary",h)}),i.jsx(wi,{children:ji("attachFromLibraryDescription",h)})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex min-h-8 items-center gap-2 rounded-md border border-border bg-muted/20 px-2 text-xs text-muted-foreground",children:[i.jsx("span",{className:"font-medium text-foreground",children:"/"}),i.jsx("span",{className:"truncate",children:o||ji("libraryFiles",h)})]}),i.jsx("div",{className:"h-[320px] overflow-hidden rounded-md border border-border",children:u.isLoading?i.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[i.jsx(yn,{className:"h-4 w-4 animate-spin"}),"Loading files..."]}):u.error?i.jsx("div",{className:"p-3 text-sm text-destructive",children:u.error instanceof Error?u.error.message:ji("couldNotLoadLibraryFiles",h)}):f.length===0&&!A?i.jsx("div",{className:"p-3 text-sm text-muted-foreground",children:ji("noLibraryFiles",h)}):i.jsx(m1e,{className:"h-full",children:i.jsxs("div",{className:"space-y-0.5 p-1.5",children:[A?i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:()=>{l(IPn(o)),d(null)},children:[i.jsx(_i,{className:"h-3.5 w-3.5 rotate-180"}),"Parent folder"]}):null,f.map(x=>{const y=PPn(x),v=c===x.path;return x.isDirectory?i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent/60",onClick:()=>{l(x.path),d(null)},children:[i.jsx(ho,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"truncate font-medium",children:y})]},x.path):i.jsxs("button",{type:"button",className:q("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors",v?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),onClick:()=>d(x.path),onDoubleClick:()=>void r(x.path),children:[i.jsx(b6,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:y})]},x.path)})]})})}),c?i.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:["Selected: ",c]}):null,a?i.jsx("p",{className:"text-xs text-destructive",children:a}):null]}),i.jsxs(aa,{children:[i.jsx(ie,{type:"button",variant:"ghost",onClick:()=>n(!1),disabled:s,children:"Cancel"}),i.jsxs(ie,{type:"button",onClick:()=>c?void r(c):void 0,disabled:!c||s,children:[s?i.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(Wu,{className:"h-3.5 w-3.5"}),"Attach"]})]})]})})}function _Pn(e,t,n,r){if(e==="issue.code_committed"&&t){const s=typeof t.shortSha=="string"?t.shortSha:null,a=typeof t.subject=="string"?t.subject:null;if(s&&a)return`committed ${s}: ${a}`;if(s)return`committed ${s}`}if(e==="issue.updated"&&t){const s=t._previous??{},a=[];if(t.status!==void 0){const l=s.status;a.push(l?`moved from ${H$(I5(l))} to ${H$(I5(t.status))}`:`moved to ${H$(I5(t.status))}`)}if(t.priority!==void 0){const l=s.priority;a.push(l?`changed the priority from ${sd(I5(l))} to ${sd(I5(t.priority))}`:`changed the priority to ${sd(I5(t.priority))}`)}if(t.assigneeAgentId!==void 0||t.assigneeUserId!==void 0){const l=nx(s.assignee),c=tz(l??{agentId:s.assigneeAgentId,userId:s.assigneeUserId},n,r),d=tz({agentId:t.assigneeAgentId,userId:t.assigneeUserId},n,r);a.push(W9e({toLabel:d,fromLabel:c,assignedVerb:"assigned the issue",changedVerb:"reassigned the issue",clearedVerb:"unassigned the issue from",unassignedVerb:"unassigned the issue"}))}if(t.reviewerAgentId!==void 0||t.reviewerUserId!==void 0){const l=nx(s.reviewer),c=tz(l??{agentId:s.reviewerAgentId,userId:s.reviewerUserId},n,r),d=tz({agentId:t.reviewerAgentId,userId:t.reviewerUserId},n,r);a.push(W9e({toLabel:d,fromLabel:c,assignedVerb:"set the reviewer",changedVerb:"changed the reviewer",clearedVerb:"cleared the reviewer from",unassignedVerb:"cleared the reviewer"}))}t.title!==void 0&&a.push("updated the title"),t.description!==void 0&&a.push("updated the description");const o=new Set(["assigneeAgentId","assigneeUserId","description","priority","reviewerAgentId","reviewerUserId","status","title"]);for(const l of Hat(t).filter(c=>!o.has(c)))a.push(yPn(bPn(l),t[l],s[l]));if(a.length>0)return a.join(", ")}if((e==="issue.document_created"||e==="issue.document_updated"||e==="issue.document_deleted")&&t){const s=typeof t.key=="string"?t.key:"document",a=typeof t.title=="string"&&t.title?` (${t.title})`:"";return`${K9e[e]??e} ${s}${a}`}if(e==="issue.passive_followup_queued"&&t){const s=typeof t.attempt=="number"?t.attempt:null,a=typeof t.maxAttempts=="number"?t.maxAttempts:null,o=typeof t.followupRunId=="string"?t.followupRunId:null;return`queued passive follow-up${s&&a?` (${s}/${a})`:""}${o?` as run ${o.slice(0,8)}`:""}`}if(e==="issue.closure_needs_operator_review"&&t){const s=typeof t.attempts=="number"?t.attempts:null;return s?`stopped passive follow-up after ${s} attempts; operator review needed`:"stopped passive follow-up; operator review needed"}return e==="issue.review_decision_recorded"&&t?`recorded reviewer decision: ${typeof t.decision=="string"?I5(t.decision):"unknown"}`:K9e[e]??e.replace(/[._]/g," ")}function MPn(e){const t=nx(e.details);return(typeof(t==null?void 0:t.conversationTitle)=="string"?t.conversationTitle.trim():"")||`Chat ${e.entityId.slice(0,8)}`}function EPn(e,t,n){const r=nx(e.details);if(e.action==="issue.updated"&&r&&Object.prototype.hasOwnProperty.call(r,"parentId")){const s=nx(r._previous),a=nx(r._references),o=Z9e(a==null?void 0:a.parentIssue),l=Z9e(a==null?void 0:a.previousParentIssue);if(o)return i.jsxs(i.Fragment,{children:[zN(s==null?void 0:s.parentId)?"changed the parent issue to ":"set the parent issue to ",H9e(o)]});if(l)return i.jsxs(i.Fragment,{children:["cleared the parent issue ",H9e(l)]})}if(e.entityType==="chat"){const s=`/chat/${e.entityId}`,a=MPn(e),o=i.jsx(an,{to:s,className:"underline underline-offset-4 hover:text-foreground",children:a});if(e.action==="chat.issue_converted")return i.jsxs(i.Fragment,{children:["created this issue from ",o]});if(e.action==="chat.context_linked")return i.jsxs(i.Fragment,{children:["linked this issue in ",o]});if(e.action==="chat.created")return i.jsxs(i.Fragment,{children:["started ",o," with this issue linked"]})}if(e.action==="issue.approval_linked"||e.action==="issue.approval_unlinked"){const s=typeof(r==null?void 0:r.approvalId)=="string"?r.approvalId:null;if(s){const a=e.action==="issue.approval_linked"?"linked":"unlinked";return i.jsxs(i.Fragment,{children:[a," ",i.jsx(an,{to:`/messenger/approvals/${s}`,className:"underline underline-offset-4 hover:text-foreground",children:"an approval"})]})}}return _Pn(e.action,r,t,n)}function DPn({evt:e,agentMap:t,currentBoardUserId:n,operatorDisplayName:r}){const s=e.actorId;if(e.actorType==="agent"){const a=t.get(s);return(a==null?void 0:a.name)??s.slice(0,8)}return sZ(e.actorType,s,n,r)}function RPn(e){const t=nx(e.details);return e.action==="issue.updated"&&typeof(t==null?void 0:t.status)=="string"?t.status:e.action==="issue.checked_out"?"in_progress":e.action==="issue.released"?"done":null}function LPn({evt:e}){const t=RPn(e);return i.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center","aria-hidden":"true",children:t?i.jsx(ni,{status:t,className:"h-4 w-4"}):i.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground/45"})})}function zPn({evt:e,agentMap:t,currentBoardUserId:n,operatorDisplayName:r}){const s=DPn({evt:e,agentMap:t,currentBoardUserId:n,operatorDisplayName:r}),a=EPn(e,t,n),o=Ti(e.createdAt);return i.jsxs("div",{"data-testid":"issue-activity-row",className:"grid min-h-8 grid-cols-[16px_minmax(0,1fr)] items-center gap-2 rounded-sm border border-transparent py-1 pl-3 pr-2 text-xs text-muted-foreground",children:[i.jsx(LPn,{evt:e}),i.jsxs("span",{"data-testid":"issue-activity-summary",className:"flex min-w-0 items-center gap-1.5 whitespace-nowrap leading-5",children:[i.jsx("span",{className:"max-w-[9rem] shrink-0 truncate font-medium text-foreground",children:s}),i.jsxs("span",{className:"min-w-0 truncate",children:[" ",a]}),i.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground/90",children:[" · ",o]})]})]})}function $Pn({data:e}){var A,h,g;const t=e.latestIssue,n=e.link,r=(t==null?void 0:t.identifier)??n.linearIdentifier,s=(t==null?void 0:t.title)??n.linearTitle,a=(t==null?void 0:t.url)??n.linearUrl,o=((A=t==null?void 0:t.description)==null?void 0:A.trim())??"",l=(t==null?void 0:t.team.name)??n.teamName,c=(t==null?void 0:t.state.name)??n.stateName,d=((h=t==null?void 0:t.project)==null?void 0:h.name)??n.projectName,u=((g=t==null?void 0:t.assignee)==null?void 0:g.name)??null,f=(t==null?void 0:t.updatedAt)??n.updatedAt;return i.jsxs("section",{className:"rounded-lg border border-border bg-card/70 p-3 text-sm","data-testid":"issue-activity-linear-link",children:[i.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0 space-y-1",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx("span",{className:"text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground",children:"Linked Linear issue"}),i.jsx("span",{className:"rounded-full border border-border bg-muted/40 px-2 py-0.5 font-mono text-[11px] text-muted-foreground",children:r})]}),i.jsx("div",{className:"font-medium text-foreground",children:s}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11px] text-muted-foreground",children:[i.jsx("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:l}),i.jsx("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:c}),d?i.jsx("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:d}):null,u?i.jsx("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:u}):null,i.jsxs("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:["Updated ",Ti(f)]}),i.jsxs("span",{className:"rounded-full border border-border bg-background/70 px-2 py-0.5",children:["Imported ",Ti(n.importedAt)]})]})]}),i.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",className:"inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:["Open in Linear",i.jsx(La,{className:"h-3 w-3"})]})]}),e.staleReason?i.jsx("div",{className:"mt-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-2 py-1.5 text-xs text-amber-700 dark:text-amber-200",children:e.staleReason}):null,o?i.jsx("p",{className:"mt-3 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:o}):null]})}function FPn(e){var n,r;if((n=e.title)!=null&&n.trim())return e.title.trim();const t=((r=e.issueLinks)==null?void 0:r[0])??null;return t?`${t.issueIdentifier??t.issueId.slice(0,8)} / ${t.key}`:`Document ${e.id.slice(0,8)}`}function J9e({kind:e}){const t=e==="folder"?ho:Fi;return i.jsx("span",{"aria-hidden":"true","data-testid":"linked-library-resource-icon","data-kind":e,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border bg-muted/35 text-muted-foreground",children:i.jsx(t,{className:"h-4 w-4"})})}function BPn({issue:e,libraryDocuments:t,libraryFiles:n}){const{locale:r}=as(),s=new Set(Rxt(e.description??"")),a=new Set(Lxt(e.description??"")),o=new Set(zxt(e.description??"")),l=new Map((t??[]).map(h=>[h.id,h])),c=new Map((n??[]).map(h=>[h.path,h])),d=new Map,u=new Map;for(const h of s){const g=l.get(h);g&&d.set(g.id,g)}for(const h of a){const g=c.get(h)??{name:h.split("/").pop()||h,path:h,isDirectory:!1};u.set(g.path,g)}for(const h of o){const g=c.get(h)??{name:h.split("/").pop()||h,path:h,isDirectory:!0};u.set(g.path,g)}const f=[...d.values()].sort((h,g)=>new Date(g.updatedAt).getTime()-new Date(h.updatedAt).getTime()),A=[...u.values()].sort((h,g)=>h.path.localeCompare(g.path));return f.length===0&&A.length===0?null:i.jsxs("section",{className:"space-y-3","aria-label":ji("linkedLibrary",r),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Fi,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),i.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:ji("library",r)}),i.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[11px] text-muted-foreground",children:f.length+A.length})]}),i.jsxs("div",{className:"grid gap-2",children:[A.map(h=>i.jsxs(an,{to:h.isDirectory?`/library?directory=${encodeURIComponent(h.path)}`:`/library?path=${encodeURIComponent(h.path)}`,className:"flex items-center justify-between gap-3 rounded-lg border border-border bg-background/70 px-3 py-2 text-sm transition-colors hover:bg-accent/35",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[i.jsx(J9e,{kind:h.isDirectory?"folder":"file"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"truncate font-medium text-foreground",children:h.name}),i.jsxs("div",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:[h.isDirectory?ji("liveLibraryFolder",r):ji("liveLibraryFile",r)," / ",h.path]})]})]}),i.jsx("span",{className:"shrink-0 rounded-full border border-border px-2 py-0.5 text-[11px] text-muted-foreground",children:h.isDirectory?"folder":"file"})]},h.path)),f.map(h=>{var y;const g=FPn(h),x=((y=h.issueLinks)==null?void 0:y[0])??null;return i.jsxs(an,{to:`/library?doc=${encodeURIComponent(h.id)}`,className:"flex items-center justify-between gap-3 rounded-lg border border-border bg-background/70 px-3 py-2 text-sm transition-colors hover:bg-accent/35",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[i.jsx(J9e,{kind:"doc"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"truncate font-medium text-foreground",children:g}),i.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground",children:[i.jsx("span",{children:ji("liveLibraryLink",r)}),x?i.jsxs(i.Fragment,{children:[i.jsx("span",{"aria-hidden":"true",children:"/"}),i.jsxs("span",{className:"truncate",children:["migrated from ",x.issueIdentifier??x.issueId.slice(0,8),":",x.key]})]}):null]})]})]}),i.jsxs("span",{className:"shrink-0 rounded-full border border-border px-2 py-0.5 text-[11px] text-muted-foreground",children:["r",h.latestRevisionNumber]})]},h.id)})]})]})}function eje({summary:e}){return!e.hasCost&&!e.hasTokens?null:i.jsxs("section",{className:"rounded-lg border border-border bg-background/80 p-3",children:[i.jsx("div",{className:"mb-2 text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:"Cost"}),i.jsxs("div",{className:"space-y-1.5 text-xs text-muted-foreground tabular-nums",children:[e.hasCost?i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Spend"}),i.jsxs("span",{className:"font-medium text-foreground",children:["$",e.cost.toFixed(4)]})]}):null,e.hasTokens?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Total tokens"}),i.jsx("span",{className:"font-medium text-foreground",children:Yr(e.totalTokens)})]}),i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Input"}),i.jsx("span",{children:Yr(e.input)})]}),i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Output"}),i.jsx("span",{children:Yr(e.output)})]}),e.cached>0?i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{children:"Cached"}),i.jsx("span",{children:Yr(e.cached)})]}):null]}):null]})]})}function $U({embeddedIssueId:e=null,embedded:t=!1}={}){var An,en,dr;const n=Qo(),r=e??n.issueId,{organizations:s,selectedOrganizationId:a,selectedOrganization:o}=Nr(),{setBreadcrumbs:l}=ea(),c=Wn(),d=Hr(),u=br(),f=vQe(),{pushToast:A}=As(),{openImagePreview:h}=OM(),{confirm:g}=ri(),{locale:x}=as(),y=DE(),w=rl(u.pathname).startsWith("/messenger/issues")?"/messenger/issues":"/issues",[k,O]=m.useState(!1),[j,C]=m.useState(!1),[N,I]=m.useState(!1),[E,_]=m.useState(null),[T,R]=m.useState(!1),[M,L]=m.useState(""),[U,B]=m.useState(!1),[z,H]=m.useState(""),[J,F]=m.useState(null),[Q,W]=m.useState(null),[$,ee]=m.useState(null),[re,ne]=m.useState(!1),[te,ce]=m.useState(!1),[se,he]=m.useState(!1),we=m.useRef(null),Ue=vs("rudder:issue-detail-main"),je=m.useCallback(Ve=>{we.current=Ve,Ue(Ve)},[Ue]),ke=m.useRef(null),Se=m.useRef(null),{data:oe,isLoading:fe,error:Ie}=Te({queryKey:V.issues.detail(r),queryFn:()=>fr.get(r),enabled:!!r}),ue=(oe==null?void 0:oe.orgId)??a??null,{followedIssueIds:be,isLoading:at,toggleFollowIssue:ve}=x1e(ue),me=oe?be.has(oe.id):!1,ye=se||at||!oe,qe=(oe==null?void 0:oe.orgId)??a;m.useEffect(()=>{!(oe!=null&&oe.orgId)||!oe.id||y1e(oe.orgId,oe.id,tk(oe.orgId))},[oe==null?void 0:oe.id,oe==null?void 0:oe.orgId]);const{data:Ce}=Te({queryKey:V.issues.comments(r),queryFn:()=>fr.listComments(r),enabled:!!r}),{data:X}=Te({queryKey:V.issues.activity(r),queryFn:()=>i2.forIssue(r),enabled:!!r}),{data:G}=Te({queryKey:V.issues.runs(r),queryFn:()=>i2.runsForIssue(r),enabled:!!r,refetchInterval:5e3}),{data:Ae}=Te({queryKey:V.issues.attachments(r),queryFn:()=>fr.listAttachments(r),enabled:!!r}),{data:Je}=Te({queryKey:V.issues.liveRuns(r),queryFn:()=>So.liveRunsForIssue(r),enabled:!!r,refetchInterval:3e3}),{data:ht}=Te({queryKey:V.issues.activeRun(r),queryFn:()=>So.activeRunForIssue(r),enabled:!!r,refetchInterval:3e3}),De=(Je??[]).length>0||!!ht,ft=m.useMemo(()=>dPn(u.state)??(w==="/messenger/issues"?{label:"Messenger",href:"/messenger"}:{label:"Issues",href:"/issues"}),[w,u.state]),dt=(oe==null?void 0:oe.ancestors)??mPn,yt=oe!=null&&oe.parentId?dt[0]??null:null,Mt=m.useMemo(()=>pPn({sourceBreadcrumb:ft,issue:oe,issueId:r}),[dt,oe==null?void 0:oe.id,oe==null?void 0:oe.identifier,oe==null?void 0:oe.title,r,ft]),Xe=m.useMemo(()=>{const Ve=new Set;for(const Vt of Je??[])Ve.add(Vt.id);return ht&&Ve.add(ht.id),Ve.size===0?G??[]:(G??[]).filter(Vt=>!Ve.has(Vt.runId))},[G,Je,ht]),{data:At}=Te({queryKey:V.issues.list(qe??"__none__"),queryFn:()=>fr.list(qe),enabled:!!qe}),{data:it}=Te({queryKey:V.organizations.libraryDocuments(qe??"__none__"),queryFn:()=>En.listLibraryDocuments(qe),enabled:!!qe}),Ee=(E==null?void 0:E.trim())??"",{data:mt}=Te({queryKey:["organizations",qe??"__none__","workspace-mention-files",Ee],queryFn:()=>En.listWorkspaceMentionFiles(qe,{query:Ee,limit:Ee?50:200}),enabled:!!qe}),{data:ot=[]}=Te({queryKey:V.issues.children(qe??"__none__",(oe==null?void 0:oe.id)??"__none__"),queryFn:()=>fr.list(qe,{parentId:oe.id}),enabled:!!qe&&!!(oe!=null&&oe.id)}),{data:xe}=Te({queryKey:V.agents.list(qe??"__none__"),queryFn:()=>_n.list(qe),enabled:!!qe}),{data:Ne}=Te({queryKey:V.organizationSkills.list(qe??"__none__"),queryFn:()=>Zu.list(qe),enabled:!!qe&&!!(oe!=null&&oe.assigneeAgentId)}),{data:We}=Te({queryKey:V.agents.skills((oe==null?void 0:oe.assigneeAgentId)??"__none__"),queryFn:()=>_n.skills(oe.assigneeAgentId,qe),enabled:!!qe&&!!(oe!=null&&oe.assigneeAgentId)}),{data:ze}=Te({queryKey:V.auth.session,queryFn:()=>el.getSession()}),{data:Ye}=Te({queryKey:V.projects.list(qe??"__none__"),queryFn:()=>Ii.list(qe),enabled:!!qe}),{data:_e}=Te({queryKey:V.access.currentBoardAccess,queryFn:()=>dc.getCurrentBoardAccess(),enabled:!!r}),Le=((An=ze==null?void 0:ze.user)==null?void 0:An.id)??((en=ze==null?void 0:ze.session)==null?void 0:en.userId)??null,Pe=((dr=_e==null?void 0:_e.user)==null?void 0:dr.id)??(_e==null?void 0:_e.userId)??Le,vt=(s??[]).find(Ve=>Ve.id===qe)??o,{orderedProjects:Be}=FM({projects:Ye??[],orgId:qe,userId:Le}),{slots:ut}=u9({slotTypes:["detailTab"],entityType:"issue",enabled:!!qe}),Et=m.useMemo(()=>ut.filter(Ve=>!Y9e(Ve)).map(Ve=>({value:`plugin:${Ve.pluginKey}:${Ve.id}`,label:Ve.displayName,slot:Ve})),[ut]),Zt=ut.find(Ve=>Y9e(Ve))??null,{data:Nn}=Te({queryKey:["plugins",Xat,G9e,qe??"__none__",(oe==null?void 0:oe.id)??r??"__none__",(Zt==null?void 0:Zt.pluginId)??"__none__"],queryFn:async()=>(await Ya.bridgeGetData(Zt.pluginId,G9e,{orgId:qe,issueId:oe.id},qe)).data,enabled:!!(qe&&(oe!=null&&oe.id)&&(Zt!=null&&Zt.pluginId))}),zn=m.useMemo(()=>{const Ve=new Map;for(const Vt of xe??[])Ve.set(Vt.id,Vt);return Ve},[xe]),Ze=m.useMemo(()=>new Map((Ye??[]).map(Ve=>[Ve.id,Ve])),[Ye]),Qt=oe!=null&&oe.assigneeAgentId?zn.get(oe.assigneeAgentId)??null:null,He=m.useMemo(()=>o9({agent:Qt,orgUrlKey:(vt==null?void 0:vt.urlKey)??"organization",organizationSkills:Ne,skillSnapshot:We}),[Ne,We,Qt,vt==null?void 0:vt.urlKey]),Rt=m.useMemo(()=>{var Qn,Gr;const Ve=[],Vt=[...xe??[]].filter(Cn=>Cn.status!=="terminated").sort((Cn,yr)=>Cn.name.localeCompare(yr.name));for(const Cn of Vt)Ve.push({id:`agent:${Cn.id}`,name:Qu(Cn),kind:"agent",agentId:Cn.id,agentIcon:Cn.icon,agentRole:Cn.role});for(const Cn of Be)Ve.push({id:`project:${Cn.id}`,name:Cn.name,kind:"project",projectId:Cn.id,projectColor:Cn.color,projectIcon:Cn.icon});for(const Cn of At??[]){if(Cn.id===(oe==null?void 0:oe.id))continue;const yr=Cn.projectId?Ze.get(Cn.projectId)??Cn.project??null:Cn.project??null,qn=Cn.assigneeAgentId?zn.get(Cn.assigneeAgentId)??null:null,mi=Cn.assigneeAgentId?(qn==null?void 0:qn.name)??Cn.assigneeAgentId.slice(0,8):MA(Cn.assigneeUserId,Le);Ve.push({id:`issue:${Cn.id}`,name:Cn.identifier?`${Cn.identifier} ${Cn.title}`:Cn.title,kind:"issue",searchText:[Cn.identifier,Cn.title,Cn.status,yr==null?void 0:yr.name,mi].filter(Boolean).join(" "),issueId:Cn.id,issueIdentifier:Cn.identifier,issueStatus:Cn.status,issueProjectName:(yr==null?void 0:yr.name)??null,issueProjectColor:(yr==null?void 0:yr.color)??null,issueProjectIcon:(yr==null?void 0:yr.icon)??null,issueAssigneeName:mi,issueAssigneeIcon:(qn==null?void 0:qn.icon)??null,issueAssigneeRole:(qn==null?void 0:qn.role)??null})}for(const Cn of it??[]){const yr=((Qn=Cn.issueLinks)==null?void 0:Qn[0])??null,qn=((Gr=Cn.title)==null?void 0:Gr.trim())||(yr?`${yr.issueIdentifier??yr.issueId.slice(0,8)} / ${yr.key}`:Cn.id.slice(0,8));Ve.push({id:`library-doc:${Cn.id}`,name:qn,kind:"library_doc",searchText:[qn,...(Cn.issueLinks??[]).flatMap(mi=>[mi.issueIdentifier,mi.issueTitle,mi.key])].filter(Boolean).join(" "),libraryDocumentId:Cn.id,libraryDocumentTitle:qn,libraryDocumentUpdatedAt:Cn.updatedAt,libraryDocumentPath:yr?`Migrated issue doc ${yr.issueIdentifier??yr.issueId.slice(0,8)}:${yr.key}`:"Doc"})}for(const Cn of(mt==null?void 0:mt.entries)??[])Ve.push({id:Cn.isDirectory?`library-directory:${Cn.path}`:`library-file:${Cn.path}`,name:Cn.displayLabel??Cn.name,kind:Cn.isDirectory?"library_directory":"library_file",searchText:`${Cn.name} ${Cn.path}`,libraryFilePath:Cn.isDirectory?null:Cn.path,libraryEntryId:Cn.isDirectory?null:Cn.libraryEntryId??null,libraryDirectoryPath:Cn.isDirectory?Cn.path:null});return Ve.push(...He),Ve},[zn,xe,At,Le,oe==null?void 0:oe.id,it,mt==null?void 0:mt.entries,Be,Ze,He]),In=m.useMemo(()=>[...ot].sort((Ve,Vt)=>new Date(Ve.createdAt).getTime()-new Date(Vt.createdAt).getTime()),[ot]),Zn=m.useMemo(()=>new Map((At??[]).map(Ve=>[Ve.id,Ve])),[At]),Xr=m.useMemo(()=>{if(!oe)return[];const Ve=z.trim().toLowerCase();return(At??[]).filter(Vt=>Vt.id!==oe.id).filter(Vt=>Vt.parentId!==oe.id).filter(Vt=>!(oe.ancestors??[]).some(Qn=>Qn.id===Vt.id)).filter(Vt=>Ve?`${Vt.identifier??""} ${Vt.title}`.toLowerCase().includes(Ve):!0).slice(0,12)},[At,z,oe]),qs=m.useMemo(()=>{const Ve=new Map,Vt=new Map;for(const Qn of G??[])Vt.set(Qn.runId,Qn.agentId);for(const Qn of X??[]){if(Qn.action!=="issue.comment_added"||!Qn.runId)continue;const Gr=Qn.details??{},Cn=typeof Gr.commentId=="string"?Gr.commentId:null;!Cn||Ve.has(Cn)||Ve.set(Cn,{runId:Qn.runId,runAgentId:Qn.agentId??Vt.get(Qn.runId)??null})}return(Ce??[]).map(Qn=>{const Gr=Ve.get(Qn.id);return Gr?{...Qn,...Gr}:Qn})},[X,Ce,G]),hr=m.useMemo(()=>{let Ve=0,Vt=0,Qn=0,Gr=0,Cn=!1,yr=!1;for(const qn of G??[]){const mi=nx(qn.usageJson),Na=nx(qn.resultJson),Ks=VC(mi,"inputTokens","input_tokens"),No=VC(mi,"outputTokens","output_tokens"),Pa=VC(mi,"cachedInputTokens","cached_input_tokens")+VC(mi,"cache_read_input_tokens")+VC(mi,"cache_creation_input_tokens"),ZA=Gc({provider:X9e(mi,"provider")??X9e(Na,"provider"),inputTokens:Ks,cachedInputTokens:Pa,outputTokens:No}),il=VRe(mi,Na);il>0&&(Cn=!0),Ks+No+Pa>0&&(yr=!0),Ve+=ZA.promptTokens,Vt+=No,Qn+=Pa,Gr+=il}return{input:Ve,output:Vt,cached:Qn,cost:Gr,totalTokens:Ve+Vt,hasCost:Cn,hasTokens:yr}},[G]),Fr=m.useMemo(()=>{var Vt;const Ve=[];Nn!=null&&Nn.linked&&Ve.push({id:"linear-linked-issue",createdAt:((Vt=Nn.latestIssue)==null?void 0:Vt.updatedAt)??Nn.link.updatedAt??Nn.link.importedAt,node:i.jsx($Pn,{data:Nn})});for(const Qn of X??[])OPn(Qn)&&Ve.push({id:Qn.id,createdAt:Qn.createdAt,node:i.jsx(zPn,{evt:Qn,agentMap:zn,currentBoardUserId:Pe,operatorDisplayName:y})});return Ve},[X,zn,Pe,Nn,y]),jt=()=>{const Ve=(oe==null?void 0:oe.orgId)??qe??a;c.invalidateQueries({queryKey:V.issues.detail(r)}),c.invalidateQueries({queryKey:V.issues.activity(r)}),c.invalidateQueries({queryKey:V.issues.runs(r)}),c.invalidateQueries({queryKey:V.issues.approvals(r)}),c.invalidateQueries({queryKey:V.issues.attachments(r)}),c.invalidateQueries({queryKey:V.issues.liveRuns(r)}),c.invalidateQueries({queryKey:V.issues.activeRun(r)}),oe!=null&&oe.id&&Ve&&c.invalidateQueries({queryKey:V.issues.children(Ve,oe.id)}),Ve&&(c.invalidateQueries({queryKey:V.issues.list(Ve)}),c.invalidateQueries({queryKey:V.issues.listTouchedByMe(Ve)}),c.invalidateQueries({queryKey:V.issues.listUnreadTouchedByMe(Ve)}),c.invalidateQueries({queryKey:V.sidebarBadges(Ve)}))},kt=pt({mutationFn:Ve=>fr.markRead(Ve),onSuccess:()=>{const Ve=(oe==null?void 0:oe.orgId)??qe??a;Ve&&(c.invalidateQueries({queryKey:V.issues.listTouchedByMe(Ve)}),c.invalidateQueries({queryKey:V.issues.listUnreadTouchedByMe(Ve)}),c.invalidateQueries({queryKey:V.sidebarBadges(Ve)}),vA(c,Ve))}}),nn=pt({mutationFn:Ve=>fr.update(r,Ve),onSuccess:Ve=>{c.setQueryData(V.issues.detail(r),Ve),c.setQueryData(V.issues.detail(Ve.id),Ve),Ve.identifier&&c.setQueryData(V.issues.detail(Ve.identifier),Ve),jt()}}),Ke=pt({mutationFn:()=>fr.remove(r),onSuccess:Ve=>{c.removeQueries({queryKey:V.issues.detail(r)}),c.removeQueries({queryKey:V.issues.detail(Ve.id)}),Ve.identifier&&c.removeQueries({queryKey:V.issues.detail(Ve.identifier)}),jt(),A({title:"Issue deleted",tone:"success"}),d("/issues/all")},onError:Ve=>{A({title:"Failed to delete issue",body:Ve instanceof Error?Ve.message:"Try again.",tone:"error"})}}),st=(oe==null?void 0:oe.identifier)??(oe!=null&&oe.id?oe.id.slice(0,8):r??"issue"),Ft=m.useCallback(async()=>{await g({title:`Delete ${st}?`,description:"This removes the issue from Rudder.",confirmLabel:"Delete",tone:"destructive"})&&(Ke.mutate(),O(!1))},[g,Ke,st]),Dn=pt({mutationFn:({childIssueId:Ve,status:Vt})=>fr.update(Ve,{status:Vt}),onMutate:({childIssueId:Ve})=>{W(Ve)},onSuccess:Ve=>{qe&&(oe!=null&&oe.id)&&c.setQueryData(V.issues.children(qe,oe.id),Vt=>(Vt==null?void 0:Vt.map(Qn=>Qn.id===Ve.id?{...Qn,...Ve}:Qn))??Vt),c.setQueryData(V.issues.detail(Ve.id),Ve),Ve.identifier&&c.setQueryData(V.issues.detail(Ve.identifier),Ve),qe&&(c.invalidateQueries({queryKey:V.issues.list(qe)}),c.invalidateQueries({queryKey:V.issues.listTouchedByMe(qe)}),c.invalidateQueries({queryKey:V.issues.listUnreadTouchedByMe(qe)}),c.invalidateQueries({queryKey:V.sidebarBadges(qe)}))},onError:Ve=>{A({title:"Failed to update sub-issue status",body:Ve instanceof Error?Ve.message:"Try again.",tone:"error"})},onSettled:(Ve,Vt,Qn)=>{F(Gr=>Gr===Qn.childIssueId?null:Gr),W(Gr=>Gr===Qn.childIssueId?null:Gr)}}),Rn=pt({mutationFn:({body:Ve,reopen:Vt})=>fr.addComment(r,Ve,Vt),onSuccess:()=>{jt(),c.invalidateQueries({queryKey:V.issues.comments(r)})}}),rt=pt({mutationFn:({commentId:Ve,body:Vt})=>fr.updateComment(r,Ve,Vt),onSuccess:Ve=>{c.setQueryData(V.issues.comment(r,Ve.id),Ve),jt(),c.invalidateQueries({queryKey:V.issues.comments(r)})}}),Yt=pt({mutationFn:Ve=>fr.deleteComment(r,Ve),onSuccess:Ve=>{c.setQueryData(V.issues.comment(r,Ve.id),Ve),jt(),c.invalidateQueries({queryKey:V.issues.comments(r)})}}),fn=pt({mutationFn:async({file:Ve,usage:Vt="issue"})=>{const Qn=(oe==null?void 0:oe.orgId)??qe??a;if(!Qn)throw new Error("No organization selected");return fr.uploadAttachment(Qn,r,Ve,{usage:Vt})},onSuccess:(Ve,Vt)=>{ee(null),(Vt.usage===void 0||Vt.usage==="issue")&&c.invalidateQueries({queryKey:V.issues.attachments(r)}),jt()},onError:Ve=>{ee(Ve instanceof Error?Ve.message:"Upload failed")}}),or=pt({mutationFn:async Ve=>{const Vt=(oe==null?void 0:oe.orgId)??qe??a;if(!Vt)throw new Error("No organization selected");return fr.attachWorkspaceFile(Vt,r,Ve)},onSuccess:()=>{ee(null),ce(!1),c.invalidateQueries({queryKey:V.issues.attachments(r)}),jt()},onError:Ve=>{ee(Ve instanceof Error?Ve.message:"Workspace attach failed")}}),xt=pt({mutationFn:Ve=>fr.deleteAttachment(Ve),onSuccess:()=>{ee(null),c.invalidateQueries({queryKey:V.issues.attachments(r)}),jt()},onError:Ve=>{ee(Ve instanceof Error?Ve.message:"Delete failed")}}),Xt=m.useCallback(()=>{if(!oe){A({title:"Issue is not ready",tone:"error"});return}d(hPn(oe))},[oe,d,A]),Fn=pt({mutationFn:async Ve=>{if(!oe)throw new Error("Issue is not ready");return fr.create(oe.orgId,{title:Ve,parentId:oe.id})},onSuccess:()=>{L(""),R(!1),jt()},onError:Ve=>{A({title:Ve instanceof Error?Ve.message:"Failed to create sub-issue",tone:"error"})}}),er=pt({mutationFn:async Ve=>{if(!oe)throw new Error("Issue is not ready");return fr.update(Ve.id,{parentId:oe.id})},onSuccess:(Ve,Vt)=>{B(!1),H(""),jt(),c.invalidateQueries({queryKey:V.issues.detail(Ve.id)}),Ve.identifier&&c.invalidateQueries({queryKey:V.issues.detail(Ve.identifier)}),oe!=null&&oe.orgId&&Vt.parentId&&c.invalidateQueries({queryKey:V.issues.children(oe.orgId,Vt.parentId)})},onError:Ve=>{A({title:Ve instanceof Error?Ve.message:"Failed to add existing issue",tone:"error"})}});m.useEffect(()=>{t||l(Mt.map((Ve,Vt)=>De&&Vt===Mt.length-1?{...Ve,label:`● ${Ve.label}`}:Ve))},[t,l,Mt,De]),m.useEffect(()=>{t||oe!=null&&oe.identifier&&r!==oe.identifier&&d(`${w}/${oe.identifier}`,{replace:!0,state:u.state})},[t,oe,r,w,d,u.state]),m.useLayoutEffect(()=>{if(t)return;const Ve=Vt=>{if(iQt(Vt)&&(Vt.preventDefault(),!(f!=null&&f()))){if(OQe()){d(-1);return}d(ft.href)}};return document.addEventListener("keydown",Ve,!0),()=>document.removeEventListener("keydown",Ve,!0)},[t,d,f,ft.href]),m.useEffect(()=>{t||oe!=null&&oe.id&&Se.current!==oe.id&&(Se.current=oe.id,kt.mutate(oe.id))},[t,oe==null?void 0:oe.id]);const zr=async()=>{oe&&(await navigator.clipboard.writeText(oe.identifier??oe.id),C(!0),A({title:"Copied issue ID",tone:"success"}),setTimeout(()=>C(!1),1500))},hs=async()=>{if(!oe||se||at)return;const Ve=!me;he(!0);try{await ve(oe.id),A({title:Ve?"Issue pinned":"Issue unpinned",tone:"success"})}catch(Vt){A({title:Ve?"Could not pin issue":"Could not unpin issue",body:Vt instanceof Error?Vt.message:void 0,tone:"error"})}finally{he(!1)}},to=async()=>{const Ve=M.trim();!Ve||Fn.isPending||await Fn.mutateAsync(Ve)};if(fe)return i.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."});if(Ie)return i.jsx("p",{className:"text-sm text-destructive",children:Ie.message});if(!oe)return null;const ns=async Ve=>{const Vt=Ve.target.files;if(!(!Vt||Vt.length===0)){for(const Qn of Array.from(Vt))await fn.mutateAsync({file:Qn,usage:"issue"});ke.current&&(ke.current.value="")}},ja=async Ve=>{Ve.preventDefault(),ne(!1);const Vt=Ve.dataTransfer.files;if(!(!Vt||Vt.length===0))for(const Qn of Array.from(Vt))await fn.mutateAsync({file:Qn,usage:"issue"})},Qi=Ve=>c9(Ve.contentType),Rr=Ve=>{const Vt=Ve.originalFilename??Ve.id;h({alt:Vt,name:Vt,src:Ve.contentPath,testId:"issue-attachment-image-preview-dialog",titleFallback:"Issue attachment preview"})},ta=Ae??[],Ca=ta.length>0,Uo=`${In.length}`,mo=fn.isPending||or.isPending,On=i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:ke,type:"file",accept:CPn,className:"hidden",onChange:ns,multiple:!0}),i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"quiet",size:"xs",disabled:mo,className:q("shadow-none",re&&"border-primary bg-primary/5"),title:mo?"Attaching":"Attach file",children:[mo?i.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):i.jsx(Wu,{className:"h-3.5 w-3.5"}),mo?"Attaching...":i.jsx("span",{className:"hidden sm:inline",children:"Attach"})]})}),i.jsxs(Di,{align:"end",className:"w-52",children:[i.jsxs(Gt,{onSelect:()=>{var Ve;(Ve=ke.current)==null||Ve.click()},children:[i.jsx(KS,{className:"h-4 w-4"}),"Upload from computer"]}),i.jsx(ko,{}),i.jsxs(Gt,{onSelect:()=>{ce(!0)},children:[i.jsx(ho,{className:"h-4 w-4"}),ji("attachFromLibrary",x)]})]})]})]}),Qe=[oe.id,oe.updatedAt,qs.length,Fr.length,In.length,ta.length].join(":"),It=({moreOpen:Ve,onMoreOpenChange:Vt,grouped:Qn=!1})=>i.jsxs("div",{className:q("flex items-center gap-1 shrink-0",Qn&&"rounded-full border border-border bg-background/80 p-1"),children:[i.jsxs(ie,{variant:"ghost",size:"sm",className:q("h-7 px-2 text-xs",Qn&&"rounded-full"),onClick:zr,title:`Copy ${st}`,children:[j?i.jsx(Zi,{className:"mr-1.5 h-3.5 w-3.5"}):i.jsx(sl,{className:"mr-1.5 h-3.5 w-3.5"}),j?"Copied":"Copy ID"]}),i.jsxs(ie,{variant:"ghost",size:"sm",className:q("h-7 px-2 text-xs",Qn&&"rounded-full"),onClick:Xt,children:[i.jsx(ka,{className:"mr-1.5 h-3.5 w-3.5"}),"Chat"]}),i.jsxs(es,{open:Ve,onOpenChange:Vt,children:[i.jsx(bs,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"sm",className:q("h-7 w-7 px-0 shrink-0",Qn&&"rounded-full"),"aria-label":"More issue actions",children:i.jsx(xl,{className:"h-4 w-4"})})}),i.jsxs(ts,{className:"w-48 p-1",align:"end",children:[i.jsxs("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-foreground hover:bg-accent/50 disabled:cursor-not-allowed disabled:opacity-60",onClick:()=>{hs(),Vt(!1)},disabled:ye,children:[se||at?i.jsx(yn,{className:"h-3 w-3 animate-spin"}):me?i.jsx(P3,{className:"h-3 w-3"}):i.jsx(Ih,{className:"h-3 w-3"}),at?"Loading pin state":me?"Unpin Issue":"Pin Issue"]}),i.jsx("div",{className:"my-1 h-px bg-border","aria-hidden":"true"}),i.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-destructive disabled:cursor-not-allowed disabled:opacity-60",onClick:()=>{Ft()},disabled:Ke.isPending,children:[Ke.isPending?i.jsx(yn,{className:"h-3 w-3 animate-spin"}):i.jsx(fi,{className:"h-3 w-3"}),"Delete Issue"]})]})]})]});return i.jsxs("div",{ref:je,"data-testid":t?"embedded-issue-detail":"issue-detail-main-scroll",className:"issue-detail-container h-full min-h-0 w-full scrollbar-auto-hide overflow-x-hidden overflow-y-auto overscroll-contain",children:[i.jsx(Vat,{rootRef:we,refreshKey:Qe}),i.jsxs("div",{className:"issue-detail-layout mx-auto min-h-full max-w-6xl","data-testid":"issue-detail-layout",children:[i.jsxs("section",{className:"issue-detail-heading min-w-0 space-y-3","data-testid":"issue-detail-heading","aria-label":"Issue identity and context",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[De&&i.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-cyan-500/10 border border-cyan-500/30 px-2 py-0.5 text-[10px] font-medium text-cyan-600 dark:text-cyan-400 shrink-0",children:[i.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[i.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-cyan-400 opacity-75"}),i.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cyan-400"})]}),"Live"]}),oe.originKind==="automation_execution"&&oe.originId&&i.jsxs(an,{to:`/automations/${oe.originId}`,className:"inline-flex items-center gap-1 rounded-full bg-violet-500/10 border border-violet-500/30 px-2 py-0.5 text-[10px] font-medium text-violet-600 dark:text-violet-400 shrink-0 hover:bg-violet-500/20 transition-colors",children:[i.jsx(y6,{className:"h-3 w-3"}),"Automation"]})]}),i.jsxs("div",{className:"flex items-center gap-0.5 md:hidden shrink-0",children:[i.jsx(ie,{variant:"ghost",size:"icon-xs",onClick:zr,title:"Copy issue ID",children:j?i.jsx(Zi,{className:"h-4 w-4"}):i.jsx(sl,{className:"h-4 w-4"})}),i.jsx(ie,{variant:"ghost",size:"icon-xs",onClick:Xt,title:"Open in chat",children:i.jsx(ka,{className:"h-4 w-4"})}),i.jsx(ie,{variant:"ghost",size:"icon-xs",onClick:()=>I(!0),title:"Properties",children:i.jsx(mM,{className:"h-4 w-4"})})]})]}),i.jsx(Em,{value:oe.title,onSave:Ve=>nn.mutateAsync({title:Ve}),as:"h2",className:"text-xl font-bold"}),i.jsx(iPn,{parentIssue:yt})]}),i.jsxs("aside",{className:"issue-detail-rail min-w-0",children:[i.jsx("div",{className:"issue-detail-actions min-w-0 items-center justify-end","data-testid":"issue-detail-actions",children:It({moreOpen:k,onMoreOpenChange:O,grouped:!0})}),i.jsx("div",{className:"issue-detail-properties min-w-0","data-testid":"issue-detail-sidebar",children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("section",{"aria-label":"Issue properties",className:"issue-detail-properties-panel rounded-lg border border-border bg-background/80 p-3",children:[i.jsx("div",{className:"mb-3 flex items-center justify-between gap-2",children:i.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:"Properties"})}),i.jsx(xU,{issue:oe,onUpdate:Ve=>nn.mutate(Ve),childIssues:In})]}),i.jsx(eje,{summary:hr})]})})]}),i.jsxs("div",{className:"issue-detail-body min-w-0 space-y-6","data-testid":"issue-detail-primary-content",children:[i.jsx(Em,{value:oe.description??"",onSave:Ve=>nn.mutateAsync({description:Ve}),as:"p",className:"text-[15px] leading-7 text-foreground",placeholder:"Add a description...",multiline:!0,editorEngine:"milkdown",alwaysEdit:!0,variant:"issue-description",mentions:Rt,onMentionQueryChange:_,imageUploadHandler:async Ve=>(await fn.mutateAsync({file:Ve,usage:"description_inline"})).contentPath}),i.jsx(C2,{slotTypes:["toolbarButton","contextMenuItem"],entityType:"issue",context:{orgId:oe.orgId,projectId:oe.projectId??null,entityId:oe.id,entityType:"issue"},className:"flex flex-wrap gap-2",itemClassName:"inline-flex",missingBehavior:"placeholder"}),i.jsx(p1e,{placementZones:["toolbarButton"],entityType:"issue",context:{orgId:oe.orgId,projectId:oe.projectId??null,entityId:oe.id,entityType:"issue"},className:"flex flex-wrap gap-2",itemClassName:"inline-flex"}),i.jsx(C2,{slotTypes:["taskDetailView"],entityType:"issue",context:{orgId:oe.orgId,projectId:oe.projectId??null,entityId:oe.id,entityType:"issue"},className:"space-y-3",itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"}),i.jsxs("section",{"aria-label":"Sub-issues",className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-foreground",children:[i.jsx(Dw,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:"Sub-issues"})]}),i.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[11px] text-muted-foreground",children:Uo})]}),i.jsxs(Mi,{children:[i.jsx(Ei,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",className:"h-8 gap-1.5 px-2.5 text-xs",disabled:Fn.isPending||er.isPending,children:[i.jsx(Ur,{className:"h-3.5 w-3.5"}),"Add sub-issue"]})}),i.jsxs(Di,{align:"end",children:[i.jsx(Gt,{onSelect:()=>{B(!1),R(!0),L("")},children:"Create new sub-issue"}),i.jsx(Gt,{onSelect:()=>{R(!1),L(""),B(!0)},children:"Add existing issue"})]})]})]}),T?i.jsxs("div",{className:"rounded-lg border border-border bg-background/80 p-2.5",children:[i.jsxs("form",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",onSubmit:Ve=>{Ve.preventDefault(),to()},children:[i.jsx(Vn,{value:M,onChange:Ve=>L(Ve.target.value),onKeyDown:Ve=>{Ve.key==="Escape"&&(Ve.preventDefault(),R(!1),L(""))},placeholder:"Add sub-issue title",autoFocus:!0,disabled:Fn.isPending,className:"h-9 text-sm"}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i.jsx(ie,{type:"submit",size:"sm",className:"h-8 px-3 text-xs",disabled:!M.trim()||Fn.isPending,children:"Create"}),i.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2.5 text-xs",onClick:()=>{R(!1),L("")},disabled:Fn.isPending,children:"Cancel"})]})]}),Fn.error instanceof Error?i.jsx("p",{className:"mt-2 text-xs text-destructive",children:Fn.error.message}):null]}):null,U?i.jsxs("div",{className:"rounded-lg border border-border bg-background/80 p-2.5",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 pb-2",children:[i.jsx(Vn,{value:z,onChange:Ve=>H(Ve.target.value),placeholder:"Search existing issues",autoFocus:!0,disabled:er.isPending,className:"h-8 text-sm"}),i.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2.5 text-xs",onClick:()=>{B(!1),H("")},disabled:er.isPending,children:"Cancel"})]}),i.jsx("div",{className:"max-h-64 overflow-y-auto pt-2",children:Xr.length===0?i.jsx("p",{className:"px-1 py-2 text-xs text-muted-foreground",children:"No matching issues."}):Xr.map(Ve=>{const Vt=Ve.identifier??Ve.id.slice(0,8),Qn=Ve.parentId?Zn.get(Ve.parentId)??null:null,Gr=Ve.projectId?Ze.get(Ve.projectId)??Ve.project??null:Ve.project??null,Cn=Qn?`Move from ${Qn.identifier??Qn.id.slice(0,8)}`:Gr&&Ve.projectId!==oe.projectId?Gr.name:"No parent";return i.jsxs("button",{type:"button",className:"grid w-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 rounded-md px-2 py-2 text-left text-sm transition-colors hover:bg-accent/40 disabled:cursor-wait disabled:opacity-60",onClick:()=>er.mutate(Ve),disabled:er.isPending,children:[i.jsx(ni,{status:Ve.status}),i.jsx("span",{className:"min-w-0 truncate",children:Ve.title}),i.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:Vt}),i.jsx("span",{className:"col-start-2 min-w-0 truncate text-xs text-muted-foreground",children:Cn})]},Ve.id)})})]}):null,In.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:"No sub-issues."}):i.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:In.map(Ve=>{var Cn,yr,qn,mi;const Vt=Ve.identifier??Ve.id,Qn=J===Ve.id,Gr=Q===Ve.id;return i.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2 text-sm transition-colors hover:bg-accent/20 last:border-b-0",children:[i.jsxs(es,{open:Qn,onOpenChange:Na=>{F(Na?Ve.id:null)},children:[i.jsx(bs,{asChild:!0,children:i.jsxs("button",{type:"button","aria-label":`Change status for ${Ve.title}`,className:"inline-flex shrink-0 items-center gap-2 rounded-md p-1 text-left transition-colors hover:bg-accent/50 disabled:cursor-wait disabled:opacity-60",disabled:Gr,children:[i.jsx(ni,{status:Ve.status}),i.jsx(ql,{priority:Ve.priority})]})}),i.jsx(ts,{className:"w-40 p-1",align:"start",children:jPn.map(Na=>i.jsxs(ie,{variant:"ghost",size:"sm",className:q("w-full justify-start gap-2 text-xs",Na===Ve.status&&"bg-accent"),onClick:()=>{Dn.mutate({childIssueId:Ve.id,status:Na})},children:[i.jsx(ni,{status:Na}),H$(Na)]},Na))})]}),i.jsxs(an,{to:`/issues/${Vt}`,state:u.state,className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i.jsx("span",{className:"max-w-28 shrink truncate font-mono text-xs text-muted-foreground",children:Vt}),i.jsx("span",{className:"truncate",children:Ve.title})]}),i.jsx("div",{className:"shrink-0",children:Ve.assigneeAgentId?(Cn=zn.get(Ve.assigneeAgentId))!=null&&Cn.name?i.jsx(uu,{name:((yr=zn.get(Ve.assigneeAgentId))==null?void 0:yr.name)??Ve.assigneeAgentId.slice(0,8),icon:(qn=zn.get(Ve.assigneeAgentId))==null?void 0:qn.icon,role:(mi=zn.get(Ve.assigneeAgentId))==null?void 0:mi.role,size:"sm"}):i.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:Ve.assigneeAgentId.slice(0,8)}):Ve.assigneeUserId?i.jsx(Jd,{name:sZ("user",Ve.assigneeUserId,Pe,y),size:"sm"}):null})]})]},Ve.id)})})]}),i.jsx(BPn,{issue:oe,libraryDocuments:it,libraryFiles:mt==null?void 0:mt.entries}),Ca?null:i.jsx("div",{className:"flex items-center justify-end gap-2 min-w-0",children:On}),Ca?i.jsxs("div",{className:q("space-y-3 rounded-lg transition-colors"),onDragEnter:Ve=>{Ve.preventDefault(),ne(!0)},onDragOver:Ve=>{Ve.preventDefault(),ne(!0)},onDragLeave:Ve=>{Ve.currentTarget.contains(Ve.relatedTarget)||ne(!1)},onDrop:Ve=>void ja(Ve),children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Attachments"}),On]}),$&&i.jsx("p",{className:"text-xs text-destructive",children:$}),i.jsx("div",{className:"space-y-2",children:ta.map(Ve=>{const Vt=Ve.originalFilename??Ve.id,Qn=Qi(Ve);return i.jsxs("div",{className:"rounded-md border border-border p-2",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Qn?i.jsx("button",{type:"button",className:"truncate text-left text-xs hover:underline",title:Vt,onClick:()=>Rr(Ve),children:Vt}):i.jsx("a",{href:Ve.contentPath,target:"_blank",rel:"noreferrer",className:"truncate text-xs hover:underline",title:Vt,children:Vt}),i.jsx("button",{type:"button",className:"text-muted-foreground hover:text-destructive",onClick:()=>xt.mutate(Ve.id),disabled:xt.isPending,title:"Delete attachment",children:i.jsx(fi,{className:"h-3.5 w-3.5"})})]}),i.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[Ve.contentType," · ",(Ve.byteSize/1024).toFixed(1)," KB"]}),Qn&&i.jsx(H2,{src:Ve.contentPath,alt:Vt,name:Vt,className:"max-h-56 object-contain bg-accent/10",loading:"lazy",previewTestId:"issue-attachment-image-preview-dialog",previewTitleFallback:"Issue attachment preview",triggerClassName:"max-h-56 overflow-hidden rounded border border-border",wrapperClassName:"mt-2"})]},Ve.id)})})]}):null,i.jsx(Nh,{}),i.jsxs("section",{"aria-label":"Activity",className:"flex flex-col space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[i.jsx(wq,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:"Activity"})]}),i.jsx(qst,{comments:qs,linkedRuns:Xe,activityItems:Fr,orgId:oe.orgId,projectId:oe.projectId,issueStatus:oe.status,agentMap:zn,draftKey:`rudder:issue-comment-draft:${oe.id}`,mentions:Rt,onMentionQueryChange:_,operatorDisplayName:y,currentUserId:Pe,hideHeading:!0,emptyMessage:"No activity yet.",escapeBackWhenEmpty:!0,fixedComposer:!0,fixedComposerTimelineScroll:!1,timelineScrollElementRef:we,onAdd:async(Ve,Vt)=>{await Rn.mutateAsync({body:Ve,reopen:Vt})},onUpdate:async(Ve,Vt)=>{await rt.mutateAsync({commentId:Ve,body:Vt})},onDelete:async Ve=>{await Yt.mutateAsync(Ve)},imageUploadHandler:async Ve=>(await fn.mutateAsync({file:Ve,usage:"comment_inline"})).contentPath,onAttachImage:async Ve=>{await fn.mutateAsync({file:Ve,usage:"comment_attachment"})},liveRunSlot:i.jsx(Iat,{issueId:r,orgId:oe.orgId})})]}),Et.length>0?i.jsx("div",{className:"space-y-3",children:Et.map(Ve=>i.jsxs("section",{className:"space-y-2",children:[i.jsx("h3",{className:"text-sm font-semibold",children:Ve.label}),i.jsx(f9,{slot:Ve.slot,context:{orgId:oe.orgId,orgPrefix:vt?hc(vt):null,projectId:oe.projectId??null,entityId:oe.id,entityType:"issue"},missingBehavior:"placeholder"})]},Ve.value))}):null]})]}),i.jsx(EU,{open:N,onOpenChange:I,children:i.jsxs(DU,{side:"bottom",className:"max-h-[85dvh] pb-[env(safe-area-inset-bottom)]",children:[i.jsx(RU,{children:i.jsx(LU,{className:"text-sm",children:"Properties"})}),i.jsx(m1e,{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"space-y-3 px-4 pb-4",children:[i.jsx(xU,{issue:oe,onUpdate:Ve=>nn.mutate(Ve),inline:!0,childIssues:In}),i.jsx(eje,{summary:hr})]})})]})}),i.jsx(qat,{}),i.jsx(TPn,{orgId:oe.orgId??qe??a,open:te,onOpenChange:ce,onAttach:Ve=>or.mutateAsync(Ve).then(()=>{}).catch(()=>{}),attaching:or.isPending,error:$})]})}const QPn=new Set([".avif",".bmp",".gif",".ico",".jpeg",".jpg",".png",".svg",".webp"]),UPn=new Set([".md",".markdown",".mdown",".mdx",".txt",".text"]),_ee="application/x-rudder-side-panel-tab",Mee="This file changed while you were editing it.";function VPn(e){if(typeof e!="string")return null;const t=e.trim();if(!t||t.length>J_)return null;if(/^data:image\/[a-z0-9.+-]+(?:;[^,]*)?,/i.test(t))return t;try{const n=new URL(t);return n.protocol==="http:"||n.protocol==="https:"?t:null}catch{return null}}function qPn({favicon:e,url:t}){var o;const n=VPn(e),r=(o=qO(t))==null?void 0:o.darkMode,[s,a]=m.useState(!1);return m.useEffect(()=>{a(!1)},[n]),n&&!s?i.jsx("img",{alt:"",className:q("size-3.5 shrink-0 rounded-[3px] object-contain",r==="invert"&&"dark:invert"),"data-dark-mode":r,"data-testid":"chat-side-panel-tab-browser-favicon",referrerPolicy:"no-referrer",src:n,onError:()=>a(!0)}):i.jsx(Vm,{"aria-hidden":!0,className:"size-3.5 shrink-0","data-testid":"chat-side-panel-tab-browser-fallback-icon"})}function KPn({enabled:e,issueId:t}){const n=Te({queryKey:V.issues.detail(t),queryFn:()=>fr.get(t),enabled:e});return n.isPending?i.jsx(yn,{"aria-hidden":!0,className:"size-3.5 shrink-0 animate-spin text-muted-foreground","data-testid":"chat-side-panel-tab-issue-loading-icon"}):n.isError||!n.data?i.jsx(zc,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-muted-foreground","data-testid":"chat-side-panel-tab-issue-fallback-icon"}):i.jsx(ni,{className:"size-3.5",dataSlot:"side-panel-tab-issue-status-icon",status:n.data.status})}function WPn({enabled:e,tab:t}){const n="size-3.5 shrink-0";return t.kind==="issue"?i.jsx(KPn,{enabled:e,issueId:t.issueId}):t.kind==="issue_proposal"?i.jsx(Sq,{"aria-hidden":!0,className:n}):t.kind==="automation"?i.jsx(I4,{"aria-hidden":!0,className:n}):t.kind==="chat"||t.kind==="side_chat"?i.jsx(ka,{"aria-hidden":!0,className:n}):t.kind==="subagents"||t.kind==="subagent"?i.jsx(_l,{"aria-hidden":!0,className:n}):t.kind==="library_directory"?i.jsx(ho,{"aria-hidden":!0,className:n}):t.kind==="library_document"?i.jsx(Fi,{"aria-hidden":!0,className:n}):t.kind==="library_entry"?t.path?i.jsx(Fi,{"aria-hidden":!0,className:n}):i.jsx(dM,{"aria-hidden":!0,className:n}):t.kind==="library_file"||t.kind==="local_file"?i.jsx(Fi,{"aria-hidden":!0,className:n}):t.kind==="organization_skill_file"?i.jsx(Fi,{"aria-hidden":!0,className:n}):t.kind==="local_apps"?i.jsx(Vf,{"aria-hidden":!0,className:n}):t.kind==="local_app"?i.jsx(k6,{className:n,identity:t,testId:"chat-side-panel-tab-local-app-icon"}):t.kind==="browser"?i.jsx(qPn,{favicon:t.favicon,url:t.url}):t.targetKind==="issue"?i.jsx(aM,{"aria-hidden":!0,className:n}):t.targetKind==="automation"?i.jsx(I4,{"aria-hidden":!0,className:n}):i.jsx(ka,{"aria-hidden":!0,className:n})}function ZPn(){const[e,t]=m.useState(()=>{var n;return typeof window<"u"&&!!((n=window.matchMedia)!=null&&n.call(window,"(max-width: 767px)").matches)});return m.useEffect(()=>{var s;if(typeof window>"u"||!window.matchMedia)return;const n=window.matchMedia("(max-width: 767px)"),r=()=>t(n.matches);return r(),(s=n.addEventListener)==null||s.call(n,"change",r),()=>{var a;return(a=n.removeEventListener)==null?void 0:a.call(n,"change",r)}},[]),e}function HPn(){return i.jsxs("div",{className:"space-y-3","data-testid":"chat-side-panel-loading",children:[i.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-[color:var(--surface-active)]"}),i.jsx("div",{className:"h-20 animate-pulse rounded-[var(--radius-lg)] bg-[color:var(--surface-active)]"}),i.jsx("div",{className:"h-28 animate-pulse rounded-[var(--radius-lg)] bg-[color:var(--surface-active)]"})]})}function XPn({browserAvailable:e,localAppsAvailable:t,sourceConversationId:n,onOpenTarget:r}){const s=[...n?[{label:"Side Chat",description:"Ask a focused follow-up without leaving the main chat.",icon:Sq,target:{kind:"side_chat",sourceConversationId:n,sourceMessageId:null,sourcePreview:null,conversationId:null,clientMutationId:crypto.randomUUID(),label:"Side Chat"}}]:[],...e?[{label:"Browser",description:"Keep a browser tab beside the current workspace.",icon:QLe,target:E4()}]:[],...t?[{label:"Local apps",description:"Run a reviewed project service beside this workspace.",icon:Vf,target:{kind:"local_apps",label:"Local apps"}}]:[],{label:"Library",description:"Browse workspace files with the Library tree.",icon:ho,target:{kind:"library_directory",directoryPath:"",label:"Library"}}];return i.jsxs("div",{className:"flex min-h-full flex-col justify-center py-6","data-testid":"chat-side-panel-empty-state",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Open a panel"}),i.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"Choose a workspace target to keep working without leaving this page."})]}),i.jsx("div",{className:"mt-5 grid gap-2",children:s.map(({label:a,description:o,icon:l,target:c})=>i.jsxs("button",{type:"button","data-testid":`chat-side-panel-empty-${a.toLowerCase().replaceAll(" ","-")}-target`,className:"flex items-center gap-3 rounded-[var(--radius-md)] border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-3 py-3 text-left text-sm transition-colors hover:bg-[color:var(--surface-active)]",onClick:()=>r(c),children:[i.jsx(l,{className:"h-4 w-4 text-muted-foreground"}),i.jsxs("span",{className:"min-w-0",children:[i.jsx("span",{className:"block font-medium text-foreground",children:a}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:o})]})]},a))})]})}function GPn({browserAvailable:e,target:t,onOpenTarget:n}){const r={issue:{icon:aM,title:"Issue",body:"Open an issue link or use workspace search to load the editable task panel here.",actions:[{label:"Library",target:{kind:"library_directory",directoryPath:"",label:"Library"}},{label:"Chat",target:{kind:"placeholder",targetKind:"chat",label:"Chat"}}]},automation:{icon:_l,title:"Automation",body:"Open an automation link to inspect schedule state and pause or resume it without leaving this page.",actions:[{label:"Issue",target:{kind:"placeholder",targetKind:"issue",label:"Issue"}},{label:"Library",target:{kind:"library_directory",directoryPath:"",label:"Library"}}]},chat:{icon:ka,title:"Chat",body:"Open a chat reference to compare messages beside the current workspace.",actions:[{label:"Issue",target:{kind:"placeholder",targetKind:"issue",label:"Issue"}},{label:"Browser",target:E4()}]}}[t.targetKind],s=r.actions.filter(o=>e||o.target.kind!=="browser"),a=r.icon;return i.jsx("div",{className:"flex min-h-full flex-col justify-center py-6","data-testid":`chat-side-panel-${t.targetKind}-placeholder`,children:i.jsxs("div",{className:"mx-auto flex max-w-[18rem] flex-col items-center text-center",children:[i.jsx("span",{className:"inline-flex h-10 w-10 items-center justify-center rounded-full bg-[color:var(--surface-active)] text-muted-foreground",children:i.jsx(a,{className:"h-4 w-4"})}),i.jsx("h3",{className:"mt-3 text-base font-semibold text-foreground",children:r.title}),i.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:r.body}),i.jsx("div",{className:"mt-5 flex flex-wrap justify-center gap-2",children:s.map(o=>i.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:()=>n(o.target),children:o.label},o.label))})]})})}function YPn({issue:e,comments:t,commentId:n,onUpdate:r,onAddComment:s,updating:a,addingComment:o,currentUserId:l,agentMap:c,operatorDisplayName:d,expanded:u=!1}){var v;const[f,A]=m.useState(null),h=e.identifier??e.id.slice(0,8),g=((v=e.project)==null?void 0:v.name)??null,x=async w=>{A(null);try{await r(w)}catch(k){A(k instanceof Error?k.message:"Could not update this issue.")}},y=i.jsx(xU,{issue:e,onUpdate:w=>void x(w),showAuditSeparator:!1});return i.jsx("div",{className:"flex h-full min-h-0 flex-col","data-testid":"chat-side-panel-issue-view",children:i.jsxs("div",{className:q("grid h-full min-h-0 flex-1 gap-6",u?"xl:grid-cols-[minmax(0,1fr)_280px] xl:items-start":"scrollbar-auto-hide overflow-y-auto overscroll-contain pr-1"),"data-testid":"chat-side-panel-issue-scroll",children:[i.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col gap-5",children:[i.jsxs("div",{className:"shrink-0 space-y-3 pb-1",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsx(Em,{value:e.title,onSave:w=>x({title:w}),as:"h2",className:"min-w-0 flex-1 text-xl font-bold leading-7 text-foreground",placeholder:"Add a title..."}),i.jsx("span",{className:"mt-1 shrink-0 rounded-[calc(var(--radius-sm)-1px)] border border-[color:var(--border-soft)] px-2 py-0.5 text-xs text-muted-foreground",children:h})]}),u?i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx(Ds,{status:e.status}),i.jsx("span",{className:"inline-flex items-center gap-1.5 rounded-[calc(var(--radius-sm)-1px)] border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-2.5 py-1 text-xs font-medium text-muted-foreground shadow-[var(--shadow-sm)]",children:i.jsx(ql,{priority:e.priority,showLabel:!0})}),g?i.jsx("span",{className:"rounded-[calc(var(--radius-sm)-1px)] border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-2.5 py-1 text-xs font-medium text-muted-foreground shadow-[var(--shadow-sm)]",children:g}):null]}):null,u?null:i.jsx("section",{"aria-label":"Issue properties",className:"py-3",children:i.jsx(xU,{issue:e,onUpdate:w=>void x(w),showAuditFields:!1})}),i.jsx(Em,{value:e.description??"",onSave:w=>x({description:w.trim()||null}),as:"p",className:"text-[15px] leading-7 text-foreground",placeholder:"Add a description...",multiline:!0,editorEngine:"milkdown",alwaysEdit:!0,variant:"issue-description"}),f?i.jsx("div",{role:"alert",className:"rounded-[var(--radius-md)] border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null]}),i.jsxs("section",{className:"shrink-0 space-y-3 pb-3",children:[i.jsx("div",{className:"flex items-center justify-between gap-3",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-foreground",children:[i.jsx(Lc,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:"Sub-issues"})]}),i.jsx("span",{className:"rounded-sm border border-[color:var(--border-soft)] px-1.5 py-0.5 text-[11px] text-muted-foreground",children:"0"})]})}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"No sub-issues."})]}),i.jsxs("section",{"aria-label":"Activity",className:"space-y-2 py-1",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[i.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Activity"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:o?"Posting...":`${t.filter(w=>!w.deletedAt).length}`})]}),i.jsx("div",{className:"mb-3 space-y-3 text-sm text-muted-foreground",children:n?i.jsxs("div",{className:"rounded-[var(--radius-md)] border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-3 py-2",children:["Target comment: ",i.jsx("span",{className:"font-mono text-foreground",children:n})]}):null}),i.jsx(qst,{comments:t,orgId:e.orgId,projectId:e.projectId,issueStatus:e.status,agentMap:c,currentUserId:l,operatorDisplayName:d,hideHeading:!0,emptyMessage:"No comments yet.",draftKey:`rudder:side-panel-issue-comment-draft:${e.id}`,fixedComposer:!0,fixedComposerTimelineScroll:!1,onAdd:s})]})]}),u?i.jsx("aside",{className:"space-y-3 xl:sticky xl:top-0",children:i.jsxs("section",{"aria-label":"Issue properties",className:"rounded-lg border border-border bg-background/80 p-3",children:[i.jsx("div",{className:"mb-3 flex items-center justify-between gap-2",children:i.jsx("p",{className:"text-[11px] font-medium text-muted-foreground",children:"Properties"})}),y]})}):null]})})}function Gat(e){if(!e)return null;const t=e.split("/").at(-1)??e,n=t.lastIndexOf(".");return n===-1?null:t.slice(n).toLowerCase()}function JPn(e){const t=Gat(e);return t!==null&&QPn.has(t)}function eIn(e){const t=Gat(e);return t!==null&&UPn.has(t)}function tIn(e){var t;return((t=e.displayLabel)==null?void 0:t.trim())||e.name}function nIn(e){const t=e.split("/").filter(Boolean);return e==="skills"||t.length===3&&t[0]==="agents"&&t[2]==="skills"}function rIn(e){const t=e.split("/").filter(Boolean);return t.length===2&&t[0]==="skills"||t.length===4&&t[0]==="agents"&&t[2]==="skills"}function sIn(e){const t=e.split("/").filter(Boolean);return t.length===2&&t[0]==="projects"}function iIn({entry:e}){return e.entityType==="agent_workspace"?i.jsx("span",{"data-testid":"chat-side-panel-library-agent-icon",className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-muted-foreground",children:i.jsx(Ml,{icon:e.agentIcon,role:e.agentRole,className:"h-3.5 w-3.5 text-[12px]"})}):e.path==="agents"?i.jsx(Kv,{"data-testid":"chat-side-panel-library-agents-root-icon",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):nIn(e.path)?i.jsx(Lc,{"data-testid":"chat-side-panel-library-skills-root-icon",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):rIn(e.path)?i.jsx($Le,{"data-testid":"chat-side-panel-library-skill-folder-icon",className:"h-3.5 w-3.5 shrink-0 text-[#2f80ed]"}):sIn(e.path)?i.jsx(aze,{"data-testid":"chat-side-panel-library-project-icon",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):i.jsx(ho,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})}function aIn({entries:e,selectedOrganizationId:t,onOpenTarget:n,selectedPath:r}){return e.length===0?i.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"This folder is empty or unavailable."}):i.jsx("ul",{className:"space-y-0.5",children:e.map(s=>i.jsx(Yat,{entry:s,selectedOrganizationId:t,onOpenTarget:n,selectedPath:r},s.path))})}function Yat({entry:e,selectedOrganizationId:t,onOpenTarget:n,selectedPath:r,depth:s=0}){var A;const[a,o]=m.useState(!1),l=tIn(e),c=r===e.path,d=Te({queryKey:V.organizations.workspaceFiles(t??"__none__",e.path),queryFn:()=>En.listWorkspaceFiles(t,e.path),enabled:!!(t&&e.isDirectory&&a),refetchOnWindowFocus:!1}),u=((A=d.data)==null?void 0:A.entries)??[];if(e.isDirectory)return i.jsxs("li",{children:[i.jsx("div",{className:q("group flex w-full items-center rounded-md pr-1 text-sm text-foreground transition-[background-color,color,opacity,transform] duration-150",c?"bg-accent text-foreground":"hover:bg-accent/60"),style:{paddingLeft:`${s*14+8}px`},"data-workspace-entry-path":e.path,children:i.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 rounded-md py-1.5 pl-0 pr-2 text-left",onClick:()=>o(h=>!h),"aria-expanded":a,children:[i.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:a?i.jsx(Br,{className:"h-4 w-4"}):i.jsx(_i,{className:"h-4 w-4"})}),i.jsx(iIn,{entry:e}),i.jsx("div",{className:"min-w-0 flex-1",children:i.jsx("div",{className:"truncate font-medium",children:l})}),e.entityType==="agent_workspace"?i.jsx("span",{"aria-hidden":"true","data-testid":"chat-side-panel-library-agent-badge",className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-border bg-background px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Agent"}):null]})}),a?d.isPending?i.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",style:{paddingLeft:`${(s+1)*14+23}px`},children:"Loading files..."}):u.length>0?i.jsx("ul",{className:"space-y-0.5",children:u.map(h=>i.jsx(Yat,{entry:h,selectedOrganizationId:t,onOpenTarget:n,selectedPath:r,depth:s+1},h.path))}):null:null]});const f=JPn(e.path)?GLe:wM(e.path)?Vm:eIn(e.path)?Fi:b6;return i.jsx("li",{children:i.jsx("div",{className:q("group flex w-full items-center rounded-md pr-1 text-sm transition-[background-color,color,opacity,transform] duration-150",c?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:`${s*14+23}px`},"data-workspace-entry-path":e.path,children:i.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 rounded-md py-1.5 pl-0 pr-2 text-left",onClick:()=>n({kind:"library_file",filePath:e.path,label:l}),"aria-selected":c,children:[i.jsx(f,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:l})]})})})}function oIn({libraryFile:e,organizationId:t,sourceConversationId:n,markdown:r,sourceToolbar:s}){var re,ne,te,ce;const a=Wn(),o=e.filePath,l=e.content??"",c=m.useRef(null);c.current===null&&(c.current=$it(t,o,l));const d=c.current,u=m.useRef(null),f=m.useRef(null),[A,h]=m.useState(null),g=m.useRef(d.baseContent),x=m.useRef(l),y=m.useRef(d.content),v=m.useRef(null),w=m.useRef(!1),k=m.useRef(d.conflicted),O=m.useRef(0),j=m.useRef(!0),[C,N]=m.useState(d.content),[I,E]=m.useState(d.conflicted?"error":C===l?"saved":"saving"),[_,T]=m.useState(d.conflicted?Mee:null),[R,M]=m.useState(d.conflicted),[,L]=m.useState(0);y.current=C,x.current=l,m.useEffect(()=>(j.current=!0,()=>{j.current=!1,Dy(t,o,g.current,y.current)}),[o,t]),m.useEffect(()=>{if(l===g.current)return;if(l===y.current){g.current=l,k.current=!1,M(!1),E("saved"),T(null),r4(t,o);return}if(y.current===g.current){g.current=l,y.current=l,N(l),k.current=!1,M(!1),E("saved"),T(null),r4(t,o);return}v.current=null,k.current=!0,O.current+=1,M(!0),E("error"),T(Mee),Dy(t,o,g.current,y.current)},[o,t,l]);const U=m.useCallback((se,he)=>{const we=se.content??he;g.current=we,x.current=we,k.current=!1,j.current&&(M(!1),T(null)),a.setQueryData(V.organizations.workspaceFile(t,o),se),Dy(t,o,we,y.current),y.current!==we&&(v.current=y.current)},[o,t,a]),B=m.useCallback(async()=>{if(!w.current){w.current=!0;try{for(;v.current!==null;){const se=v.current,he=O.current;if(v.current=null,k.current)return;if(se!==g.current){j.current&&(E("saving"),T(null));try{const we=await En.updateWorkspaceFile(t,o,{content:se,expectedContent:g.current});if(he!==O.current)continue;U(we,se)}catch(we){if(he!==O.current)continue;let Ue=null;try{Ue=await En.readWorkspaceFile(t,o)}catch{}if(he!==O.current)continue;if(Ue&&(x.current=Ue.content??"",a.setQueryData(V.organizations.workspaceFile(t,o),Ue)),(Ue==null?void 0:Ue.content)===se){U(Ue,se);continue}if(Ue&&Ue.content!==g.current&&(v.current=null,k.current=!0,Dy(t,o,g.current,y.current)),j.current){E("error");const je=k.current;M(je),T(je?Mee:we instanceof Error?we.message:"Could not save this file.")}return}}}j.current&&E(v.current===null&&y.current===g.current?"saved":"saving")}finally{w.current=!1,v.current!==null&&!k.current&&B()}}},[U,o,t,a]),z=m.useCallback(se=>{v.current=se,B()},[B]);m.useEffect(()=>{if(Dy(t,o,g.current,C),k.current)return;if(C===g.current){E(w.current||v.current!==null?"saving":"saved"),T(null);return}const se=window.setTimeout(()=>z(C),700);return()=>window.clearTimeout(se)},[C,z,o,t]);const H=se=>{y.current=se,N(se),E(k.current?"error":"saving"),k.current||T(null),L(he=>he+1)},J=()=>{const se=x.current;O.current+=1,g.current=se,y.current=se,v.current=null,k.current=!1,N(se),M(!1),E("saved"),T(null),r4(t,o)},F=()=>{O.current+=1,g.current=x.current,k.current=!1,M(!1),E("saving"),T(null),z(y.current)},Q=r?r1e(C):{frontmatter:null,separator:"",body:C},W=f9n(Q.body),$=((ne=(re=u.current)==null?void 0:re.canUndo)==null?void 0:ne.call(re))??!1,ee=((ce=(te=u.current)==null?void 0:te.canRedo)==null?void 0:ce.call(te))??!1;return i.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col","data-testid":r?"chat-side-panel-library-markdown-editor":"chat-side-panel-library-text-editor",children:[s,r?i.jsxs("div",{ref:f,className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-5 pb-20 pt-5",children:[Q.frontmatter!==null?i.jsxs("details",{className:"group mb-6 rounded-md border border-[color:var(--border-soft)] bg-[color:var(--surface-page)]","data-chat-annotation-ignore":!0,"data-testid":"chat-side-panel-library-frontmatter-editor",children:[i.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-muted-foreground outline-none transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[i.jsx("span",{children:"Frontmatter"}),i.jsx(_i,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-90"})]}),i.jsx("textarea",{value:Q.frontmatter,onChange:se=>H(kU(se.currentTarget.value,Q.separator,Q.body)),spellCheck:!1,className:"block min-h-28 w-full resize-y border-t border-[color:var(--border-soft)] bg-transparent px-3 py-2 font-mono text-xs leading-5 text-foreground outline-none","aria-label":"Frontmatter"})]}):null,i.jsx(Au,{ref:u,engine:"milkdown",value:Q.body,onChange:se=>H(kU(Q.frontmatter,Q.separator,se)),bordered:!1,placeholder:"Write in Markdown...",contentClassName:"rudder-library-document-editor rudder-readable-document rudder-side-panel-library-document mx-auto min-h-[420px] w-full max-w-[880px] text-[15px] leading-7 text-foreground"},o)]}):i.jsx("div",{ref:f,className:"min-h-0 flex-1 pb-14",children:i.jsx(BT,{"data-testid":"chat-side-panel-library-text-source-editor",annotationSource:{surface:"workspace_file",sourceFilePath:o},ariaLabel:`${o||"Library file"} source editor`,filePath:o,value:C,onChange:H,onSelectionChange:h})}),i.jsx(qQe,{containerRef:f,conversationId:n,explicitSelection:r?void 0:A,saved:I==="saved"&&!R&&C===g.current,source:C,sourceIdentity:{surface:"workspace_file",sourceFilePath:o,sourceLibraryEntryId:e.libraryEntryId},sourceRenderMode:r?"markdown":"text",renderedSource:r?Q.body:C,renderedSourceOffset:r?C.length-Q.body.length:0}),i.jsxs("div",{className:"pointer-events-none absolute inset-x-3 bottom-3 flex min-w-0 items-end justify-between gap-3",children:[i.jsxs("div",{className:q("pointer-events-auto flex min-h-8 min-w-0 items-center gap-2 rounded-md border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-2.5 text-xs shadow-sm",I==="error"?"text-destructive":"text-muted-foreground"),role:I==="error"?"alert":"status",title:_??void 0,children:[i.jsx("span",{className:q("h-1.5 w-1.5 shrink-0 rounded-full",I==="error"?"bg-destructive":I==="saving"?"bg-[color:var(--accent-strong)]":"bg-emerald-500")}),i.jsxs("span",{className:"truncate",children:[R?"Conflict":I==="error"?"Save failed":I==="saving"?"Saving":"Saved",` · ${W.toLocaleString()} ${W===1?"word":"words"}`]}),R?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"shrink-0 font-medium text-foreground underline underline-offset-2",onClick:F,children:"Keep mine"}),i.jsx("button",{type:"button",className:"shrink-0 font-medium text-foreground underline underline-offset-2",onClick:J,children:"Use latest"})]}):I==="error"?i.jsx("button",{type:"button",className:"shrink-0 font-medium text-foreground underline underline-offset-2",onClick:()=>z(y.current),children:"Retry"}):null]}),r?i.jsx(id,{delayDuration:120,children:i.jsxs("div",{className:"pointer-events-auto flex shrink-0 items-center rounded-md border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] p-0.5 shadow-sm","data-testid":"chat-side-panel-library-history-controls",children:[i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground disabled:pointer-events-none disabled:opacity-35","aria-label":"Undo Markdown edit",disabled:!$,onClick:()=>{var se,he;(he=(se=u.current)==null?void 0:se.undo)==null||he.call(se),L(we=>we+1)},children:i.jsx(c9t,{className:"h-3.5 w-3.5"})})}),i.jsx(Gi,{side:"top",children:"Undo"})]}),i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground disabled:pointer-events-none disabled:opacity-35","aria-label":"Redo Markdown edit",disabled:!ee,onClick:()=>{var se,he;(he=(se=u.current)==null?void 0:se.redo)==null||he.call(se),L(we=>we+1)},children:i.jsx(aOt,{className:"h-3.5 w-3.5"})})}),i.jsx(Gi,{side:"top",children:"Redo"})]})]})}):null]})]})}function lIn({libraryFile:e,organizationId:t,sourceConversationId:n}){const{pushToast:r}=As(),{selectedOrganization:s}=Nr(),a=br(),o=Hr(),l=Sat(e),c=e.previewKind==="video"||e.previewKind==="audio",d=Oat(e),u=kat(e),f=e.previewKind==="text"&&e.content!==null&&!e.truncated,[A,h]=m.useState("preview"),g=e.filePath.split("/").filter(Boolean),x=g.length>3?["…",...g.slice(-2)]:g,[y,v]=m.useState([]),[w,k]=m.useState(!1),[O,j]=m.useState(null),[C,N]=m.useState(!1),I=Pn(),E=!!(e.rootPath&&(I!=null&&I.openWorkspaceFileInIde));m.useEffect(()=>{let J=!1;if(!E||!(I!=null&&I.listWorkspaceLaunchTargets)){v([]);return}return I.listWorkspaceLaunchTargets().then(F=>{J||v(F)}).catch(()=>{J||v([])}),()=>{J=!0}},[E,I]);const _=y.filter(J=>J.kind==="ide"&&J.id!=="xcode"||(J.kind==="terminal"||J.kind==="folder")&&!!(I!=null&&I.openWorkspaceFileLocation)),T=Yc(`/library?path=${encodeURIComponent(e.filePath)}`,s?hc(s):Ng(a.pathname)),R=async J=>{var F;if(!(!e.rootPath||!I)){j(J.id);try{J.kind==="app"||J.kind==="ide"?await I.openWorkspaceFileInIde(e.rootPath,e.filePath,J.id):await((F=I.openWorkspaceFileLocation)==null?void 0:F.call(I,e.rootPath,e.filePath,J.id)),r({title:`Opened in ${J.label}`,tone:"success"})}catch(Q){r({title:`Could not open in ${J.label}`,body:Q instanceof Error?Q.message:"Try another app.",tone:"error"})}finally{j(null)}}},M=i.jsxs(Mi,{open:w,onOpenChange:J=>{k(J),J&&N(!1)},children:[i.jsx(Ei,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1 px-2","aria-label":"Open file options",title:"Open file options",children:[i.jsx("span",{children:"Open"}),i.jsx(Br,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),i.jsxs(Di,{align:"end",className:"w-56",children:[i.jsxs(Gt,{onSelect:()=>o(T),children:[i.jsx(dM,{className:"h-4 w-4"}),i.jsx("span",{children:"Open in Library"})]}),E?i.jsxs(Gt,{disabled:O!==null,onSelect:()=>void R({id:"defaultApp",label:"Default app",kind:"app"}),children:[i.jsx(La,{className:"h-4 w-4"}),i.jsx("span",{children:"Default app"})]}):null,_.map(J=>i.jsxs(Gt,{disabled:O!==null,onSelect:()=>void R(J),children:[i.jsx(B2,{target:J,className:"h-4 w-4"}),i.jsx("span",{children:J.label})]},J.id))]})]}),L=A==="preview",U=L?"Show source":"Show table",B=L?b6:KOt,z=d?i.jsx(id,{delayDuration:120,children:i.jsxs(Hi,{children:[i.jsx(Xi,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0","aria-label":U,"data-testid":"chat-side-panel-library-file-mode-toggle",onClick:()=>h(L?"source":"preview"),children:i.jsx(B,{className:"h-4 w-4","aria-hidden":"true"})})}),i.jsx(Gi,{side:"bottom",sideOffset:8,children:U})]})}):null,H=l?Vm:e.previewKind==="video"?rue:e.previewKind==="audio"?nue:Fi;return i.jsxs("div",{className:"flex h-full min-h-[420px] flex-col","data-testid":"chat-side-panel-library-file-view",children:[i.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-3 border-b border-[color:var(--border-soft)] px-4","data-testid":"chat-side-panel-library-file-toolbar",children:[i.jsx(H,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),i.jsx(id,{delayDuration:120,children:i.jsxs(Hi,{open:C&&!w,onOpenChange:N,children:[i.jsx(Xi,{asChild:!0,children:i.jsx("nav",{"aria-label":"Library file path",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",tabIndex:0,children:x.map((J,F)=>{const Q=F===x.length-1;return i.jsxs("span",{className:"contents",children:[F>0?i.jsx(_i,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}):null,i.jsx("span",{className:q("truncate",Q?"max-w-[60%] shrink-0 font-medium text-foreground":"min-w-0 text-muted-foreground"),children:J})]},`${J}-${F}`)})})}),i.jsx(Gi,{side:"bottom",sideOffset:8,className:"max-w-[min(36rem,calc(100vw-2rem))] break-all text-left leading-5","data-testid":"chat-side-panel-library-full-path",children:e.filePath})]})}),z,!l&&!c?i.jsx("div",{className:"shrink-0","data-testid":"chat-side-panel-library-open-in",children:M}):null]}),f&&(u||!l&&!d||A==="source")?i.jsx(oIn,{libraryFile:e,organizationId:t,sourceConversationId:n,markdown:u,sourceToolbar:l?i.jsx(nZ,{viewMode:"source",onViewModeChange:h,openAction:i.jsx("div",{className:"shrink-0","data-testid":"chat-side-panel-library-open-in",children:M}),testIdPrefix:"chat-side-panel-library"}):void 0},`${t}:${e.filePath}`):i.jsxs(i.Fragment,{children:[u&&e.truncated?i.jsx("div",{className:"shrink-0 border-b border-[color:var(--border-soft)] px-4 py-2 text-xs text-muted-foreground","data-testid":"chat-side-panel-library-readonly-notice",role:"status",children:e.message??"This file is too large to edit in the Side Panel."}):null,i.jsx(jat,{file:e,organizationId:t,mode:A,onModeChange:h,htmlOpenAction:l?i.jsx("div",{className:"shrink-0","data-testid":"chat-side-panel-library-open-in",children:M}):void 0,mediaOpenAction:c?i.jsx("div",{className:"shrink-0","data-testid":"chat-side-panel-library-media-open-in",children:M}):void 0,testIdPrefix:"chat-side-panel-library"})]})]})}function cIn({file:e,label:t}){const[n,r]=m.useState("preview"),s=r1e(e.content),a=e.markdown;return i.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-testid":"chat-side-panel-skill-file-view",children:[i.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-3 border-b border-[color:var(--border-soft)] px-4",children:[i.jsx(Lc,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t}),i.jsx("div",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e.path})]}),i.jsx("span",{className:"shrink-0 rounded-full border border-border px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Read only"}),a?i.jsxs("div",{className:"flex shrink-0 items-center rounded-md border border-[color:var(--border-soft)] p-0.5","data-testid":"chat-side-panel-skill-view-toggle",children:[i.jsx("button",{type:"button",className:q("inline-flex h-7 w-7 items-center justify-center rounded-[4px] transition-colors",n==="preview"?"bg-[color:var(--surface-active)] text-foreground":"text-muted-foreground hover:text-foreground"),"aria-label":"Preview skill Markdown","aria-pressed":n==="preview",onClick:()=>r("preview"),children:i.jsx(k2,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),i.jsx("button",{type:"button",className:q("inline-flex h-7 w-7 items-center justify-center rounded-[4px] transition-colors",n==="source"?"bg-[color:var(--surface-active)] text-foreground":"text-muted-foreground hover:text-foreground"),"aria-label":"View skill Markdown source","aria-pressed":n==="source",onClick:()=>r("source"),children:i.jsx(tue,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):null]}),i.jsx("div",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-5 py-5",children:a&&n==="preview"?i.jsx(Bo,{className:"rudder-readable-document mx-auto w-full max-w-[880px] text-sm leading-7 text-foreground",children:s.body}):i.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words font-mono text-xs leading-6 text-foreground/85","data-testid":"chat-side-panel-skill-source",children:i.jsx("code",{children:e.content})})})]})}function Jat({contextReady:e=!0,expanded:t=!1,exiting:n=!1,onClose:r,onToggleExpanded:s,target:a,selectedOrganizationId:o}){var Ke,st,Ft,Dn,Rn,rt,Yt,fn,or;const l=R3(),c=cfe(),d=Yge(),{pushToast:u}=As(),f=br(),A=Hr(),[h,g]=m.useState(null),[x,y]=m.useState(null),[v,w]=m.useState(()=>new Set),[k,O]=m.useState(null),[j,C]=m.useState(!l.open),N=m.useRef(null),I=m.useRef(null),E=m.useRef(null),_=m.useRef(new Map),T=m.useRef(new Map),R=m.useRef(new Set),M=m.useRef(null),L=m.useRef(null),U=Wn(),B=DE(),z=ZPn(),{openTarget:H}=l,J=m.useCallback((xt,Xt)=>{Xt?_.current.set(xt,Xt):_.current.delete(xt)},[]),F=m.useCallback(()=>{const xt=`${f.pathname}${f.search}${f.hash}`,Xt=rK(f);gfe(xt),A("/instance/settings/browser",Xt?{state:Xt}:void 0)},[f,A]),Q=m.useCallback((xt,Xt)=>{Xt?T.current.set(xt,Xt):T.current.delete(xt)},[]),W=m.useCallback((xt,Xt)=>{if(xt.surface==="workspace_file"||xt.surface==="local_file"){(async()=>{try{let Fn=xt.sourceFilePath,er;if(xt.surface==="workspace_file"){if(!o)throw new Error("No organization selected");if(xt.sourceLibraryEntryId){const hs=await En.getLibraryEntry(o,xt.sourceLibraryEntryId);if(hs.status!=="active"||!hs.currentPath)throw new Error("Library source is unavailable");Fn=hs.currentPath}er=(await En.readWorkspaceFile(o,Fn)).content}else{const hs=Pn();if(!hs)throw new Error("Desktop file access is unavailable");er=(await hs.previewLocalFile(Fn)).content}if(er===null||await Lw(er)!==xt.sourceHash||er.slice(Math.max(0,xt.start-xt.prefix.length),xt.start)!==xt.prefix||er.slice(xt.end,xt.end+xt.suffix.length)!==xt.suffix)throw new Error("Annotation source changed");const zr=Fn.split(/[\\/]/u).filter(Boolean).at(-1)??Fn;BQe({surface:xt.surface,sourceFilePath:Fn,sourceHash:xt.sourceHash,sourceRenderMode:xt.sourceRenderMode,start:xt.start,end:xt.end}),l.openTarget(xt.surface==="workspace_file"?xt.sourceLibraryEntryId?{kind:"library_entry",entryId:xt.sourceLibraryEntryId,path:Fn,label:zr}:{kind:"library_file",filePath:Fn,label:zr}:{kind:"local_file",filePath:Fn,label:zr})}catch{u({title:"Source is no longer available",body:"The file was changed, moved without a Library identity, or deleted.",tone:"error"})}})();return}l.hidePanel(),A({pathname:`/messenger/chat/${xt.sourceConversationId}`,search:`?messageId=${encodeURIComponent(xt.sourceMessageId)}`},{state:Nat(xt,Xt)})},[A,u,o,l]),$=l.tabs,ee=m.useMemo(()=>$.filter(xt=>xt.kind==="browser"),[$]),re=m.useMemo(()=>$.filter(xt=>xt.kind==="local_app"),[$]),ne=m.useMemo(()=>!c||!o?[]:$.flatMap(xt=>{if(!_f(xt))return[];const Xt=xt.kind==="browser"?xt.viewInstanceId??xt.tabId:xt.viewInstanceId;return Xt?[{...xt,viewInstanceId:Xt}]:[]}),[c,o,$]),te=Cat({browserTargets:ee,organizationId:o}),ce=c&&o?c.getLiveBrowserCount(o):ee.length,se=ee.length<eP&&ce<Cv;m.useLayoutEffect(()=>{var Fn,er;if(z)return;if(l.open){C(!1);return}const xt=(Fn=N.current)==null?void 0:Fn.parentElement;if(!xt||!L.current){C(!0);return}if((er=window.matchMedia)!=null&&er.call(window,"(prefers-reduced-motion: reduce)").matches||xt.getBoundingClientRect().width<=.5){C(!0);return}const Xt=zr=>{zr.target!==xt||zr.propertyName!=="width"||C(!0)};return xt.addEventListener("transitionend",Xt),()=>xt.removeEventListener("transitionend",Xt)},[z,l.open]);const he=!!((Ke=Pn())!=null&&Ke.getBrowserPartition),we=he,Ue=Te({queryKey:V.health,queryFn:()=>FA.get()}),je=!!((Ft=(st=Pn())==null?void 0:st.localApps)!=null&&Ft.supported&&((Rn=(Dn=Ue.data)==null?void 0:Dn.features)!=null&&Rn.experimentalSitesEnabled));m.useEffect(()=>{!e||!a||a.kind==="browser"&&!we||a.kind==="local_apps"&&!je||H(a)},[we,e,je,H,a]),m.useEffect(()=>{if(!he)for(const xt of ee)l.closeTarget(gs(xt))},[ee,he,l]),m.useEffect(()=>{if(!je)for(const xt of re)l.closeTarget(gs(xt))},[re,je,l]);const ke=m.useMemo(()=>{if(!e||$.length===0||l.activeKey===null)return null;if(l.activeKey){const xt=$.find(Xt=>gs(Xt)===l.activeKey);if(xt)return xt}return $.at(-1)??null},[e,l.activeKey,$]),Se=(ke==null?void 0:ke.kind)==="issue"?ke:null,oe=(ke==null?void 0:ke.kind)==="issue_proposal"?ke:null,fe=(ke==null?void 0:ke.kind)==="chat"?ke:null,Ie=(ke==null?void 0:ke.kind)==="side_chat"?ke:null,ue=(ke==null?void 0:ke.kind)==="subagents"?ke:null,be=(ke==null?void 0:ke.kind)==="subagent"?ke:null,at=(ke==null?void 0:ke.kind)==="automation"?ke:null,ve=(ke==null?void 0:ke.kind)==="library_file"?ke:null,me=(ke==null?void 0:ke.kind)==="local_file"?ke:null,ye=(ke==null?void 0:ke.kind)==="organization_skill_file"?ke:null,qe=(ke==null?void 0:ke.kind)==="library_directory"?ke:null,Ce=(ke==null?void 0:ke.kind)==="library_entry"?ke:null,X=(ke==null?void 0:ke.kind)==="browser"?ke:null,G=(ke==null?void 0:ke.kind)==="local_apps"?ke:null;ke==null||ke.kind;const Ae=ke&&c&&_f(ke)&&(ke.kind==="browser"||ke.viewInstanceId)?ke:null,Je=X?gs(X):null,ht=(ke==null?void 0:ke.kind)==="placeholder"?ke:null,De=l.open||n,ft=l.contextKey.startsWith("chat:")&&l.contextKey.slice(5)||null,dt=m.useCallback(xt=>{var Fn,er;if((Fn=Pn())!=null&&Fn.onBrowserShortcut||!Je)return;const Xt=WEe({type:xt.type,key:xt.key,code:xt.code,meta:xt.metaKey,control:xt.ctrlKey,alt:xt.altKey,shift:xt.shiftKey},{isMac:navigator.platform.toLowerCase().includes("mac")});Xt&&(xt.preventDefault(),(er=_.current.get(Je))==null||er(Xt))},[Je]),yt=(ve==null?void 0:ve.filePath)??(Ce==null?void 0:Ce.path)??null,Mt=Te({queryKey:V.issues.detail((Se==null?void 0:Se.issueId)??"__none__"),queryFn:()=>fr.get(Se.issueId),enabled:De&&!!Se}),Xe=Te({queryKey:V.issues.comments((Se==null?void 0:Se.issueId)??"__none__"),queryFn:()=>fr.listComments(Se.issueId),enabled:De&&!!Se}),At=Te({queryKey:V.agents.list(o??"__none__"),queryFn:()=>_n.list(o),enabled:De&&!!o&&!!Se}),it=Te({queryKey:V.auth.session,queryFn:()=>el.getSession(),enabled:De&&!!Se}),Ee=pt({mutationFn:({issueId:xt,data:Xt})=>fr.update(xt,Xt),onSuccess:xt=>{U.setQueryData(V.issues.detail(xt.id),xt),U.invalidateQueries({queryKey:["issues"]}),U.invalidateQueries({queryKey:["messenger"]}),o&&U.invalidateQueries({queryKey:V.chats.workManifests(o)})}}),mt=pt({mutationFn:({issueId:xt,body:Xt,reopen:Fn})=>fr.addComment(xt,Xt,Fn),onSuccess:(xt,Xt)=>{U.setQueryData(V.issues.comment(Xt.issueId,xt.id),xt),U.setQueryData(V.issues.comments(Xt.issueId),Fn=>Fn?[...Fn,xt]:[xt]),U.invalidateQueries({queryKey:V.issues.detail(Xt.issueId)}),U.invalidateQueries({queryKey:V.issues.comments(Xt.issueId)}),U.invalidateQueries({queryKey:["messenger"]})}}),ot=Te({queryKey:V.chats.detail(o??"__none__",(fe==null?void 0:fe.conversationId)??"__none__"),queryFn:()=>rr.get(fe.conversationId),enabled:De&&!!o&&!!fe}),xe=Te({queryKey:V.chats.messages(o??"__none__",(fe==null?void 0:fe.conversationId)??"__none__"),queryFn:()=>rr.listMessages(o,fe.conversationId),enabled:De&&!!o&&!!fe}),Ne=Te({queryKey:V.organizations.workspaceFile(o??"__none__",yt??""),queryFn:()=>En.readWorkspaceFile(o,yt),enabled:De&&!!o&&!!yt}),We=Te({queryKey:V.organizationSkills.file(o??"__none__",(ye==null?void 0:ye.skillId)??"__none__",(ye==null?void 0:ye.filePath)??"SKILL.md"),queryFn:()=>Zu.file(o,ye.skillId,ye.filePath),enabled:De&&!!o&&!!ye}),ze=Te({queryKey:V.organizations.workspaceFiles(o??"__none__",(qe==null?void 0:qe.directoryPath)??""),queryFn:()=>En.listWorkspaceFiles(o,qe.directoryPath),enabled:De&&!!o&&!!qe}),Ye=!!(Se&&Mt.isPending||fe&&(ot.isPending||xe.isPending)||yt&&Ne.isPending||ye&&We.isPending||qe&&ze.isPending),_e=Mt.error??Xe.error??At.error??it.error??ot.error??xe.error??Ne.error??We.error??ze.error,Le=Se?Mt.data:null,Pe=Se?Xe.data??[]:[],vt=((Yt=(rt=it.data)==null?void 0:rt.user)==null?void 0:Yt.id)??((or=(fn=it.data)==null?void 0:fn.session)==null?void 0:or.userId)??null,Be=new Map((At.data??[]).map(xt=>[xt.id,xt])),ut=fe?ot.data:null,Et=fe?xe.data??[]:[],Zt=yt?Ne.data:null,Nn=ye?We.data:null,zn=qe?ze.data:null,Ze=ke?gs(ke):"empty",Qt=$.map(gs).join(`
|
|
1936
1936
|
`);m.useLayoutEffect(()=>{if(!l.open)return;const xt=window.requestAnimationFrame(()=>{const Xt=E.current,Fn=I.current;if(!Xt||!Fn)return;const er=Xt.getBoundingClientRect(),zr=Fn.getBoundingClientRect(),hs=zr.left-er.left,to=zr.right-er.right;hs<0?Xt.scrollLeft+=hs:to>0&&(Xt.scrollLeft+=to)});return()=>window.cancelAnimationFrame(xt)},[Ze,t,z,l.open,Qt]),m.useEffect(()=>{const xt=E.current;if(!xt||typeof ResizeObserver>"u")return;const Xt=new ResizeObserver(()=>{const Fn=I.current;if(!Fn)return;const er=xt.getBoundingClientRect(),zr=Fn.getBoundingClientRect(),hs=zr.left-er.left,to=zr.right-er.right;hs<0?xt.scrollLeft+=hs:to>0&&(xt.scrollLeft+=to)});return Xt.observe(xt),()=>Xt.disconnect()},[l.open,Qt]);const He=xt=>{if(xt.kind==="browser"&&!we||xt.kind==="local_apps"&&!je)return;const Xt=l.openTarget(xt,{allowNewBrowserGuest:xt.kind!=="browser"||se});!Xt.admitted&&Xt.reason==="browser_capacity"&&u({title:"Browser tab limit reached",body:`Close a Browser tab to open another. Side Panel and Main share ${Cv} live tabs.`,tone:"error"})},Rt=(xt,Xt)=>l.replaceTarget(xt,Xt),In=m.useCallback(xt=>{if($.length<2)return;const Xt=ke?$.findIndex(zr=>gs(zr)===gs(ke)):-1,Fn=((Xt<0?0:Xt)+xt+$.length)%$.length,er=$[Fn];er&&l.setActiveKey(gs(er))},[ke,l,$]),Zn=m.useCallback(xt=>{if(!c||!o||!_f(xt))return;const Xt=xt.kind==="browser"?xt.viewInstanceId??xt.tabId:xt.viewInstanceId;Xt&&c.disposeSurface(jI(o,{...xt,viewInstanceId:Xt}))},[c,o]),Xr=async xt=>{if(o&&(d!=null&&d.isMoving(o,l.contextKey,xt)))return;o&&(d==null||d.discard(o,l.contextKey,xt));const Xt=gs(xt);if(xt.kind==="browser"){await te.flushTarget(xt),l.closeTarget(Xt),Zn(xt);return}if(xt.kind!=="side_chat"){l.closeTarget(Xt),Zn(xt);return}if(M.current!==Xt&&!R.current.has(Xt)){R.current.add(Xt),w(new Set(R.current));try{const Fn=T.current.get(xt.clientMutationId),er=Fn?await Fn():xt.conversationId?await rr.destroySideChat(xt.conversationId).then(()=>xt.conversationId):null;er&&(U.removeQueries({queryKey:V.chats.detail(o??"__none__",er)}),U.removeQueries({queryKey:V.chats.messages(o??"__none__",er)})),l.closeTarget(Xt),er&&er!==xt.conversationId&&l.closeTarget(gs({...xt,conversationId:er}))}catch(Fn){if(Fn instanceof Xl&&(Fn.status===404||Fn.status===409)){if(xt.conversationId){const er=V.chats.detail(o??"__none__",xt.conversationId);Fn.status===404?(U.removeQueries({queryKey:er}),U.removeQueries({queryKey:V.chats.messages(o??"__none__",xt.conversationId)})):(U.invalidateQueries({queryKey:er}),U.invalidateQueries({queryKey:["messenger",o]}))}l.closeTarget(Xt);return}u({title:"Could not close Side Chat",body:Fn instanceof Error?Fn.message:"Try again.",tone:"error"})}finally{R.current.delete(Xt),w(new Set(R.current))}}};m.useEffect(()=>l.registerCloseRequestHandler(Xr),[Xr,l]);const qs=pt({mutationFn:xt=>rr.keepSideChat(xt.conversationId),onSuccess:(xt,Xt)=>{U.setQueryData(V.chats.detail(o??"__none__",xt.id),xt),U.invalidateQueries({queryKey:["messenger",o]}),l.closeTarget(gs(Xt)),u({title:"Moved to Messenger",body:"This is now a normal Messenger chat.",tone:"success"});const Fn=Ng(f.pathname);A(Yc(`/messenger/chat/${xt.id}`,Fn))},onError:(xt,Xt)=>{U.invalidateQueries({queryKey:V.chats.detail(o??"__none__",Xt.conversationId??"__side-chat-draft__")}),u({title:"Could not move Side Chat",body:xt instanceof Error?xt.message:"Try again.",tone:"error"})}}),hr=xt=>{const Xt=gs(xt);M.current||R.current.has(Xt)||(M.current=Xt,O(Xt),qs.mutateAsync(xt).catch(()=>{}).finally(()=>{M.current===Xt&&(M.current=null,O(null))}))},Fr=(zn==null?void 0:zn.entries)??[],jt=Fr.filter(xt=>!xt.isDirectory).length,kt=Fr.length-jt,nn=i.jsxs("aside",{ref:N,onKeyDownCapture:dt,"data-testid":"chat-side-panel",className:q("flex min-h-0 shrink-0 flex-col gap-1.5 bg-transparent",z?"motion-chat-side-panel motion-panel-reveal fixed inset-x-3 bottom-3 top-[4.75rem] z-[60] w-auto":"h-full w-full",z&&n&&"translate-x-4 scale-[0.985] opacity-0",!e&&"hidden",z&&!l.open&&!n&&"hidden"),"aria-label":"Side Panel","aria-hidden":!e||void 0,children:[i.jsx("div",{className:q("workspace-tab-header-card workspace-main-card relative z-10 flex shrink-0 flex-col overflow-visible rounded-[var(--desktop-workspace-radius)]",z&&"!bg-[color:var(--surface-page)] shadow-[0_24px_90px_-36px_rgb(0_0_0/0.75)]"),children:i.jsxs("div",{role:"tablist","aria-label":"Side Panel targets","data-testid":"chat-side-panel-tabs",className:"workspace-tab-strip flex shrink-0 items-center gap-1 overflow-hidden px-2 py-1.5",children:[i.jsx("div",{ref:E,"data-testid":"chat-side-panel-tab-scroller",className:"scrollbar-auto-hide flex min-w-0 flex-1 gap-1 overflow-x-auto",children:$.map(xt=>{const Xt=gs(xt),Fn=Xt===Ze,er=h===Xt,zr=v.has(Xt),hs=!!(o&&(d!=null&&d.isMoving(o,l.contextKey,xt))),to=hs||xt.kind==="side_chat"&&(k===Xt||zr);return i.jsx(vNn,{closeDisabled:to,isMobile:z,moveInProgress:hs||k!==null||zr,organizationId:o,tab:xt,onClose:ns=>void Xr(ns),onOpenInNewTab:ns=>{l.openTargetInNewTab(ns.kind==="browser"?E4(ns.url):ns)},onMoveSideChat:hr,children:i.jsxs("div",{ref:Fn?I:void 0,role:"presentation","data-side-panel-tab-key":Xt,"data-dragging":er?"true":void 0,"data-drop-position":(x==null?void 0:x.key)===Xt?x.position:void 0,onDragStart:ns=>{g(Xt),ns.dataTransfer.effectAllowed="move",ns.dataTransfer.setData(_ee,Xt)},onDragOver:ns=>{const ja=h??ns.dataTransfer.getData(_ee);if(!ja||ja===Xt)return;ns.preventDefault(),ns.dataTransfer.dropEffect="move";const Qi=ns.currentTarget.getBoundingClientRect(),Rr=ns.clientX<Qi.left+Qi.width/2?"before":"after";y({key:Xt,position:Rr})},onDrop:ns=>{ns.preventDefault();const ja=h??ns.dataTransfer.getData(_ee);if(ja&&ja!==Xt){const Qi=ns.currentTarget.getBoundingClientRect(),Rr=ns.clientX<Qi.left+Qi.width/2?"before":"after";l.reorderTarget(ja,Xt,Rr)}g(null),y(null)},onDragEnd:()=>{g(null),y(null)},className:q("workspace-tab-pill group relative flex h-7 max-w-[12.5rem] shrink-0 items-center rounded-full border pr-1 transition-[color,background-color,border-color,box-shadow,opacity]",xt.kind==="browser"&&"w-[12.5rem]",Fn?"border-[color:var(--border-strong)] bg-[color:var(--surface-active)] text-foreground":"border-transparent text-muted-foreground hover:bg-[color:var(--surface-active)] hover:text-foreground",er&&"opacity-50",(x==null?void 0:x.key)===Xt&&x.position==="before"&&"shadow-[-3px_0_0_0_var(--accent)]",(x==null?void 0:x.key)===Xt&&x.position==="after"&&"shadow-[3px_0_0_0_var(--accent)]"),children:[i.jsxs("button",{type:"button",role:"tab",draggable:!hs&&!z&&$.length>1,"aria-selected":Fn,"data-testid":"chat-side-panel-tab","data-view-instance-id":_f(xt)?xt.kind==="browser"?xt.viewInstanceId??xt.tabId:xt.viewInstanceId:void 0,"data-browser-favicon":xt.kind==="browser"?xt.favicon:void 0,"data-side-panel-tab-kind":xt.kind,className:"flex min-w-0 flex-1 cursor-grab items-center gap-1.5 rounded-l-full px-2.5 py-1 text-left text-xs active:cursor-grabbing focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",onClick:()=>{hs||l.setActiveKey(Xt)},children:[i.jsx(WPn,{enabled:De,tab:xt}),i.jsx("span",{className:"min-w-0 truncate",children:hs?`${xt.label} · Moving…`:xt.label})]}),i.jsx("button",{type:"button",draggable:!1,"data-testid":"chat-side-panel-tab-close","aria-label":`Close ${xt.label} tab`,disabled:to,className:"pointer-events-none inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-muted-foreground opacity-0 transition-[color,background-color,opacity] group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 hover:bg-[color:var(--surface-panel)] hover:text-foreground focus-visible:pointer-events-auto focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-40",onClick:ns=>{ns.stopPropagation(),!to&&Xr(xt)},children:i.jsx(Ls,{className:"h-3 w-3"})})]})},Xt)})}),i.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[i.jsx("button",{type:"button","data-testid":"chat-side-panel-add-tab","aria-label":"Add Side Panel tab",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",onClick:l.openEmpty,children:i.jsx(Ur,{className:"h-3.5 w-3.5"})}),i.jsx(COn,{contextKey:l.contextKey,organizationId:o,target:ke}),s?i.jsx("button",{type:"button","data-testid":"chat-side-panel-expand-toggle","aria-label":t?"Restore Side Panel width":"Expand Side Panel",title:t?"Restore Side Panel width":"Expand Side Panel",className:"inline-flex h-7 w-7 items-center justify-center rounded-[calc(var(--radius-sm)-1px)] text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",onClick:s,children:t?i.jsx(AM,{className:"h-3.5 w-3.5"}):i.jsx(wv,{className:"h-3.5 w-3.5"})}):null,i.jsx("button",{type:"button","data-testid":"chat-side-panel-collapse","aria-label":"Close Side Panel",title:"Close Side Panel",className:"inline-flex h-7 w-7 items-center justify-center rounded-[calc(var(--radius-sm)-1px)] text-muted-foreground transition-colors hover:bg-[color:var(--surface-active)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",onClick:r??l.hidePanel,children:i.jsx(bI,{className:"h-3.5 w-3.5"})})]})]})}),i.jsx("div",{className:q("workspace-tab-content-card workspace-main-card flex min-h-0 min-w-0 max-w-full flex-1 flex-col overflow-hidden rounded-[var(--desktop-workspace-radius)]",z&&"!bg-[color:var(--surface-page)]"),children:i.jsxs("div",{className:q("scrollbar-auto-hide min-h-0 min-w-0 max-w-full flex-1",Ae||G||Se||oe||me||ye||Ie||ue||be?"overflow-hidden":"overflow-y-auto px-4 py-4",Se&&!X&&"px-4 py-4"),"data-testid":"chat-side-panel-scroll-body",children:[ne.map(xt=>{const Xt=gs(xt),Fn=Xt===Ze,er=jI(o,xt),zr=`side:${l.contextKey}:${er}`;return i.jsx(oBe,{active:Fn,callbacks:{annotationConversationId:ft,canOpenNewTab:se,onCloseTarget:hs=>{Xr(hs)},onCycleTab:In,onOpenBrowserSettings:F,onOpenTarget:He,onRegisterShortcutController:J,onReplaceTarget:hs=>Rt(Xt,hs)},className:q("h-full min-h-0 min-w-0 max-w-full",Fn?"block":"hidden"),hostId:zr,ownerId:zr,runtimeId:er,target:xt,"aria-hidden":!Fn},er)}),c?null:ee.map(xt=>{const Xt=gs(xt),Fn=Xt===Ze;return i.jsx("div",{className:q("h-full min-h-0",Fn?"block":"hidden"),"aria-hidden":!Fn,children:i.jsx(tBe,{active:Fn,canOpenNewTab:se,surface:"side_panel",target:xt,targetKey:Xt,onOpenBrowserSettings:F,onOpenTarget:He,onReplaceTarget:Rt,onCloseTarget:Xr,onCycleTab:In,onRegisterShortcutController:J})},Xt)}),!c&&je?re.map(xt=>{const Xt=gs(xt),Fn=Xt===Ze;return i.jsx("div",{className:q("h-full min-h-0",Fn?"block":"hidden"),"aria-hidden":!Fn,children:i.jsx(qFe,{active:Fn,target:xt})},Xt)}):null,Ae?null:ke?Ye?i.jsx("div",{className:q(yt&&"px-4 py-4"),children:i.jsx(HPn,{})}):_e?i.jsx("div",{className:q(yt&&"px-4 py-4"),children:i.jsx("div",{role:"alert",className:"rounded-[var(--radius-lg)] border border-destructive/30 bg-destructive/10 px-3 py-3 text-sm text-destructive",children:_e instanceof Error?_e.message:"Could not load this Side Panel target."})}):Se&&Le?t?i.jsx($U,{embedded:!0,embeddedIssueId:Le.id}):i.jsx(YPn,{issue:Le,comments:Pe,commentId:Se.commentId,updating:Ee.isPending,addingComment:mt.isPending,currentUserId:vt,agentMap:Be,operatorDisplayName:B,expanded:t,onUpdate:xt=>Ee.mutateAsync({issueId:Le.id,data:xt}),onAddComment:async(xt,Xt)=>{await mt.mutateAsync({issueId:Le.id,body:xt,...Xt===void 0?{}:{reopen:Xt}})}}):oe?i.jsx("div",{className:"h-full min-h-0","data-testid":"chat-side-panel-issue-proposal-view",children:i.jsx(Jpn,{targetKey:gs(oe)})}):at?i.jsx("div",{className:"h-full min-h-0","data-testid":"chat-side-panel-automation-view",children:i.jsx(h1e,{automationId:at.automationId,embedded:!0,onClose:()=>Xr(at)},at.automationId)}):G?i.jsx(kLt,{onOpenTarget:He}):ht?i.jsx(GPn,{browserAvailable:we,target:ht,onOpenTarget:He}):Ie&&o?i.jsx(r9n,{organizationId:o,target:Ie,onRegisterCloseHandler:Q,onReplaceTarget:Rt,onSelectResponseAnnotation:W}):ue&&o?i.jsx(d9n,{organizationId:o,target:ue}):be?i.jsx(a9n,{target:be}):fe?i.jsxs("div",{className:"space-y-4","data-testid":"chat-side-panel-chat-view",children:[i.jsxs("div",{className:"rounded-[var(--radius-lg)] border border-[color:var(--border-soft)] bg-[color:var(--surface-elevated)] px-3 py-3",children:[i.jsx("h3",{className:"text-base font-semibold text-foreground",children:ut?jy(ut):ke.label}),ut!=null&&ut.summary?i.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:ut.summary}):null,i.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[Et.length," message",Et.length===1?"":"s"]})]}),i.jsx("div",{className:"space-y-2",children:Et.slice(-3).map(xt=>i.jsxs("div",{className:q("rounded-[var(--radius-md)] border border-[color:var(--border-soft)] px-3 py-2 text-sm",xt.id===fe.messageId&&"border-[color:var(--accent-base)] bg-[color:color-mix(in_oklab,var(--accent-base)_10%,transparent)]"),children:[i.jsx("div",{className:"mb-1 text-[11px] uppercase tracking-[0.12em] text-muted-foreground",children:xt.role}),i.jsx("p",{className:"line-clamp-4 whitespace-pre-wrap text-muted-foreground",children:xt.body||xt.kind})]},xt.id))})]}):yt&&Zt&&o?i.jsx(lIn,{libraryFile:Zt,organizationId:o,sourceConversationId:ft},Zt.filePath):me?i.jsx(JCn,{targetPath:me.filePath,label:me.label,sourceConversationId:ft},me.filePath):ye&&Nn?i.jsx(cIn,{file:Nn,label:ye.label},`${ye.skillId}:${ye.filePath}`):qe?i.jsxs("div",{className:"flex min-h-full flex-col","data-testid":"chat-side-panel-library-directory-view",children:[zn?i.jsxs("div",{className:"shrink-0 px-2 pb-3 text-sm",children:[i.jsx("div",{className:"truncate font-medium text-foreground",children:zn.directoryPath||"Library root"}),i.jsxs("div",{className:"mt-1 text-xs text-muted-foreground","data-testid":"chat-side-panel-library-file-count",children:[jt," file",jt===1?"":"s"," · ",kt," folder",kt===1?"":"s"]})]}):null,i.jsx("div",{className:"-mx-2 min-h-0 flex-1 border-t border-border px-2 py-2",children:i.jsx(aIn,{entries:Fr,selectedOrganizationId:o,onOpenTarget:He,selectedPath:qe.directoryPath})})]}):i.jsx("p",{className:"text-sm text-muted-foreground",children:"Open this target in the full page for details."}):i.jsx(XPn,{browserAvailable:we,localAppsAvailable:je,sourceConversationId:ft,onOpenTarget:He})]})})]});return z?!l.open&&!n?null:typeof document<"u"?qa.createPortal(nn,document.body):nn:l.open?(L.current=nn,nn):!j||ne.length>0||ee.length>0||re.length>0?L.current:null}function s4({scope:e="global",requestedPrefix:t}){const{t:n}=as(),r=br(),{setBreadcrumbs:s}=ea(),{organizations:a,selectedOrganization:o}=Nr();m.useEffect(()=>{s([{label:n("notFound.breadcrumb")}])},[s,n]);const l=o??a[0]??null,c=l?`/${hc(l)}${cc}`:cc,d=`${r.pathname}${r.search}${r.hash}`,u=t==null?void 0:t.toUpperCase(),f=n(e==="invalid_organization_prefix"?"notFound.title.organization":"notFound.title.page"),A=e==="invalid_organization_prefix"?n("notFound.description.organization",{prefix:u??n("notFound.unknown")}):n("notFound.description.page");return i.jsx("div",{className:"mx-auto max-w-2xl py-10",children:i.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 p-2",children:i.jsx(zf,{className:"h-5 w-5 text-destructive"})}),i.jsxs("div",{children:[i.jsx("h1",{className:"text-xl font-semibold",children:f}),i.jsx("p",{className:"text-sm text-muted-foreground",children:A})]})]}),i.jsxs("div",{className:"mt-4 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[n("notFound.requestedPath")," ",i.jsx("code",{className:"font-mono",children:d})]}),i.jsx("div",{className:"mt-5 flex flex-wrap gap-2",children:i.jsx(ie,{asChild:!0,children:i.jsxs(an,{to:c,children:[i.jsx(QLe,{className:"mr-1.5 h-4 w-4"}),n("notFound.goHome")]})})})]})})}const dIn=new Set([".avif",".bmp",".gif",".ico",".jpeg",".jpg",".png",".svg",".webp"]),uIn=new Set([".csv"]),fIn=new Set([".md",".markdown",".mdown",".mdx"]),AIn=new Set([".md",".markdown",".mdown",".mdx",".txt",".text"]),hIn=new Set([".mp4",".m4v",".mov",".webm",".ogv",".avi",".mkv"]),mIn=new Set([".mp3",".m4a",".aac",".wav",".ogg",".oga",".opus",".flac"]),pIn=/data:image\/[a-z0-9.+-]+(?:;[a-z0-9.+_-]+(?:=[a-z0-9.+_-]+)?)*,/i,tje="Embedded image data URLs are not allowed in Library files. Upload the image and reference the asset URL instead.";function gIn(e){return pIn.test(e)}function xIn(e){return`library/${(e??"untitled").replace(/\.[^/.]+$/,"").split("/").map(n=>(n.replace(/[^a-zA-Z0-9_-]+/g,"_").replace(/_{2,}/g,"_").replace(/^_+|_+$/g,"")||"file").slice(0,40)).join("/")}`.slice(0,120).replace(/\/+$/g,"")||"library"}function X3(e){if(!e)return null;const t=e.split("/").at(-1)??e,n=t.lastIndexOf(".");return n===-1?null:t.slice(n).toLowerCase()}function bIn(e){const t=X3(e);return t!==null&&dIn.has(t)}function yIn(e){const t=X3(e);return t!==null&&fIn.has(t)}function vIn(e){const t=X3(e);return t!==null&&uIn.has(t)}function wIn(e){var t;return typeof e=="string"&&((t=e.toLowerCase().split(";")[0])==null?void 0:t.trim())==="text/csv"}function kIn(e){const t=X3(e);return t!==null&&AIn.has(t)}function SIn(e){const t=X3(e);return t!==null&&hIn.has(t)}function OIn(e){const t=X3(e);return t!==null&&mIn.has(t)}function jIn(e){const t=X3(e);if(!t)return"Document";switch(t){case".md":case".markdown":case".mdown":return"Markdown";case".mdx":return"MDX";case".json":return"JSON";case".jsonl":return"JSONL";case".csv":return"CSV";case".html":return"HTML";case".txt":case".text":return"Text";default:return t.slice(1).toUpperCase()}}function nje(e){const t=e.match(/[\p{L}\p{N}]+(?:[-'][\p{L}\p{N}]+)*/gu);return(t==null?void 0:t.length)??0}function rje(e){return`${e.toLocaleString()} ${e===1?"word":"words"}`}function sje(e){const t=e.match(/^(---\r?\n[\s\S]*?\r?\n---)(\r?\n|$)/);return t?{frontmatter:t[1]??"",frontmatterSeparator:t[2]??`
|
|
1937
1937
|
`,body:e.slice(t[0].length)}:{frontmatter:null,frontmatterSeparator:"",body:e}}function ije(e,t,n){return e===null?n:`${e}${t||`
|
|
1938
1938
|
`}${n}`}const CIn=new Set([".md",".markdown",".mdown",".mdx",".txt",".text",".css",".csv",".html",".htm",".js",".json",".jsonl",".jsx",".log",".py",".toml",".ts",".tsx",".xml",".yaml",".yml"]),NIn=new Set(["application/json","application/javascript","application/typescript","application/xml","application/x-yaml","text/csv","text/html","text/javascript","text/markdown","text/plain","text/xml","text/yaml"]),PIn=new Set(["HEARTBEAT.MD","MEMORY.MD","SOUL.MD","TOOLS.MD"]),IIn=new Set(["memory","skills"]),v1e="application/x-rudder-workspace-entry",TIn="[data-workspace-entry-path]";function Y0(e){var t;return((t=e.displayLabel)==null?void 0:t.trim())||e.name}function Gk(e){return`skills/${e.slug}`}function ile(e,t){return`${Gk(e)}/${t.split("/").filter(Boolean).join("/")}`}function _In(e){const t=e.split("/").filter(Boolean);return t.length===2&&t[0]==="skills"||t.length===4&&t[0]==="agents"&&t[2]==="skills"}function MIn(e){const t=e.split("/").filter(Boolean);return e==="skills"||t.length===3&&t[0]==="agents"&&t[2]==="skills"}function d6(e){const t=dl(e.workspaceEditPath);return!!(t&&t.startsWith(`${Gk(e)}/`))}function EIn(e){const t=e.fileInventory.map(n=>dl(n.path)).filter(n=>!!n);return t.length>0?t:["SKILL.md"]}function DIn(e,t,n){const r=n??[],s=dl(e)??"";if(s==="skills"){const d=new Set(t.map(u=>u.path));return r.filter(u=>!d6(u)).map(u=>{var f;return{name:u.slug,displayLabel:((f=u.name)==null?void 0:f.trim())||u.slug,path:Gk(u),isDirectory:!0,virtualSkillId:u.id,virtualSkillReadOnlyReason:u.editableReason,virtualSkillSourceLabel:u.sourceLabel}}).filter(u=>!d.has(u.path))}const a=r.find(d=>{if(d6(d))return!1;const u=Gk(d);return s===u||s.startsWith(`${u}/`)});if(!a)return[];const o=Gk(a),l=s===o?"":s.slice(o.length+1),c=new Map;for(const d of EIn(a)){if(l&&d!==l&&!d.startsWith(`${l}/`))continue;const u=l?d.slice(l.length+1):d,[f]=u.split("/");if(!f)continue;const A=l?`${l}/${f}`:f,h=u.includes("/"),g=`${o}/${A}`;c.set(g,{name:f,displayLabel:f,path:g,isDirectory:h,virtualSkillId:a.id,virtualSkillFilePath:h?null:A,virtualSkillReadOnlyReason:a.editableReason,virtualSkillSourceLabel:a.sourceLabel})}return[...c.values()].sort((d,u)=>Number(u.isDirectory)-Number(d.isDirectory)||Y0(d).localeCompare(Y0(u)))}function w1e(e,t,n){if((dl(e)??"")==="")return!(n??[]).some(o=>!d6(o))||t.some(o=>o.path==="skills")?t:[...t,{name:"skills",displayLabel:"skills",path:"skills",isDirectory:!0}].sort((o,l)=>Number(l.isDirectory)-Number(o.isDirectory)||Y0(o).localeCompare(Y0(l)));const s=DIn(e,t,n);return s.length===0?t:[...t,...s].sort((a,o)=>Number(o.isDirectory)-Number(a.isDirectory)||Y0(a).localeCompare(Y0(o)))}function eot(e){return`projects/${e.urlKey||e.id}`}function iZ(e){return`${eot(e)}/resources`}function tot(e,t){return`${iZ(e)}/${t.id}`}function RIn(e){const t=new Map;for(const n of e??[])t.set(eot(n),{project:n,resources:[...n.resources].sort((r,s)=>r.sortOrder-s.sortOrder||r.resource.name.localeCompare(s.resource.name))});return t}function ale(e,t){if(!t)return null;for(const n of e){const r=n.resources.find(s=>s.id===t);if(r)return{project:n,attachment:r,path:tot(n,r)}}return null}function _O(e){if(e==="agents")return!0;const t=e.split("/").filter(Boolean);return t.length===2&&t[0]==="agents"}function k1e(e){var n;const t=e.split("/").filter(Boolean);return t.length===3?t[0]==="agents"&&t[2]==="instructions":t.length===4&&t[0]==="agents"&&t[2]==="instructions"?PIn.has(((n=t[3])==null?void 0:n.toUpperCase())??""):!1}function gf(e){var n;const t=(e??"").split("/").filter(Boolean);return t.length===4&&t[0]==="agents"&&t[2]==="instructions"&&((n=t[3])==null?void 0:n.toUpperCase())==="HEARTBEAT.MD"}function S1e(e){var n;const t=e.split("/").filter(Boolean);return t.length>=3&&t[0]==="agents"&&IIn.has(((n=t[2])==null?void 0:n.toLowerCase())??"")}function aZ(e){var t;return((t=e.split("/").filter(Boolean)[0])==null?void 0:t.toLowerCase())==="skills"}function MO(e){return!_O(e)&&!aZ(e)}function O1e(e){return!_O(e.path)&&!k1e(e.path)&&!S1e(e.path)&&!aZ(e.path)}function j1e(e){return O1e(e)}function C1e(e){return!_O(e.path)&&!k1e(e.path)&&!S1e(e.path)&&!aZ(e.path)}function N1e(e){return e.entityType==="orphaned_agent_workspace"&&_O(e.path)&&e.path!=="agents"?!0:!_O(e.path)&&!k1e(e.path)&&!S1e(e.path)&&!aZ(e.path)&&!not(e.path)}function not(e){const t=e.split("/").filter(Boolean);return t.length===2&&t[0]==="projects"}function UT(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Aw(e,t,n){return e===t?n:e.startsWith(`${t}/`)?`${n}${e.slice(t.length)}`:e}function VT(e,t){return!O1e(e)||!MO(t)||e.path===t||e.isDirectory&&t.startsWith(`${e.path}/`)?!1:UT(e.path)!==t}function P1e(e){return Array.from(e.types).includes(v1e)}function zv(e){return Array.from(e.types).includes("Files")||e.files.length>0}function LIn(e){var r;const t=((r=e.type.toLowerCase().split(";")[0])==null?void 0:r.trim())??"";if(t.startsWith("text/")||NIn.has(t))return!0;const n=X3(e.name);return n!==null&&CIn.has(n)}function I1e(e){const t=Array.from(e.files),n=t.filter(r=>qT(r.name)&&LIn(r));return{supported:n,unsupportedCount:t.length-n.length}}function rot(e){return e.target instanceof HTMLElement&&!!e.target.closest(TIn)}function qT(e){const t=e.trim();return!!t&&t!=="."&&t!==".."&&!t.includes("/")&&!t.includes("\\")}function T1e(e,t){return e?`${e}/${t}`:t}function pv(e,t){return e?`${e.replace(/\/+$/,"")}/${t}`:t}function sot(e,t,n){return n?Mxt(n,t,e):Dxt(e,t)}function zIn(e,t){return`[${t.replace(/([\\[\]])/g,"\\$1")}](/library?directory=${encodeURIComponent(e)})`}function iot(e){const t=Y0(e);return e.isDirectory?zIn(e.path,t):sot(e.path,t,e.libraryEntryId)}function nz(e){return e.split("/").filter(Boolean).at(-1)??e}function $In(e,t,n,r){const s=e.split("/").filter(Boolean),a={label:r,path:"",isFile:!1,kind:"folder"};return s.length===0?[a]:[a,...s.map((o,l)=>{const c=s.slice(0,l+1).join("/"),d=n==="file"&&l===s.length-1;if(s[0]==="agents"&&l===1){const u=t.get(o);return{label:u?Y0(u):o,path:c,isFile:d,kind:"agent_workspace",agentIcon:(u==null?void 0:u.agentIcon)??null,agentRole:(u==null?void 0:u.agentRole)??null}}return{label:o,path:c,isFile:d,kind:o==="agents"&&l===0?"agents_root":d?"file":"folder"}})]}function FIn(e,t){if(!t)return e;const n=Gk(t);return e.map(r=>{var s;return r.path===n?{...r,label:((s=t.name)==null?void 0:s.trim())||t.slug}:r})}const BIn=["Install or import a skill into this Rudder organization.","","Source or command:","<paste a GitHub URL, local path, or skills.sh command here>","","After importing, verify it appears in Library / skills and explain whether it is editable or read-only."].join(`
|