tide-commander 1.199.0 → 1.199.2
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/CHANGELOG.md +14 -0
- package/dist/assets/{AudioPlayer-CusBq3ON.js → AudioPlayer-XaWiU7f4.js} +1 -1
- package/dist/assets/{BossLogsModal-B1PLdne_.js → BossLogsModal-1tI-leZQ.js} +1 -1
- package/dist/assets/{BossSpawnModal-DQN_2lzh.js → BossSpawnModal-CRoChH0J.js} +1 -1
- package/dist/assets/{ControlsModal-D4JsU4VU.js → ControlsModal-Cu7kwhct.js} +1 -1
- package/dist/assets/{DockerLogsModal-BuCiJ02l.js → DockerLogsModal-DFAiOsWH.js} +1 -1
- package/dist/assets/{EmbeddedEditor-CBaRvdh1.js → EmbeddedEditor-hnSknX5L.js} +1 -1
- package/dist/assets/{FcStdViewer-CpJhmVIt.js → FcStdViewer-B_cbRz1w.js} +1 -1
- package/dist/assets/{GcodeViewer-B8BHZMmG.js → GcodeViewer-CFgwEZ6g.js} +1 -1
- package/dist/assets/{GlbViewer-DdVYw2Jh.js → GlbViewer-14WSSXX7.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-Cj0r8z52.js → GmailOAuthSetup-waw2142C.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-BO0udRUZ.js → GoogleOAuthSetup-Bo59grtp.js} +1 -1
- package/dist/assets/{IframeModal-CecB4A27.js → IframeModal-B3M77grB.js} +1 -1
- package/dist/assets/{IntegrationsPanel-BVnzRrTb.js → IntegrationsPanel-BLHrC0GX.js} +2 -2
- package/dist/assets/{LogViewerModal-CNbfgDQK.js → LogViewerModal-CitlmDgQ.js} +1 -1
- package/dist/assets/{MonitoringModal-CUXXMqLv.js → MonitoringModal-BcKOCSRM.js} +1 -1
- package/dist/assets/{OrbitControls-DS7gPhsZ.js → OrbitControls-ANLmgNeR.js} +1 -1
- package/dist/assets/{PM2LogsModal-DFAuRDwm.js → PM2LogsModal-DrHpuMNf.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-DT5-U0A8.js → RestoreArchivedAreaModal-DcD3vdUJ.js} +1 -1
- package/dist/assets/{Scene2DCanvas-DqakJMdS.js → Scene2DCanvas-DKUcFYZW.js} +1 -1
- package/dist/assets/SceneManager-DPojKMM-.js +104 -0
- package/dist/assets/{SkillsPanel-1hYjREqo.js → SkillsPanel-CUW0prbh.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-C6EtUfP8.js → SlackMultiInstanceSetup-YFYeZ94t.js} +1 -1
- package/dist/assets/{SpawnModal-BmMZFOUj.js → SpawnModal-DPvq-R5b.js} +1 -1
- package/dist/assets/{StatisticsModal-mmqE6JaF.js → StatisticsModal-Dt-Hof51.js} +1 -1
- package/dist/assets/{StlViewer-D0XChi1U.js → StlViewer-GyyomEax.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-CBISWK7c.js → SubordinateAssignmentModal-ahzGBjr4.js} +1 -1
- package/dist/assets/{ThreeAreaSelector-C_7zwy_Q.js → ThreeAreaSelector-Bj_mL6NG.js} +1 -1
- package/dist/assets/{ThreeViewShortcuts-DZZmjQAV.js → ThreeViewShortcuts-CKtE3yZV.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-Bwd5-VGg.js → TriggerManagerPanel-DtdbOk9B.js} +1 -1
- package/dist/assets/{VideoPlayer-BuFPsPNu.js → VideoPlayer-Crq-MwPS.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-DxQfrs71.js → WorkflowEditorPanel-CitR9Em3.js} +1 -1
- package/dist/assets/{abnfDiagram-VRR7QNED-AhR0vtDs.js → abnfDiagram-VRR7QNED-QFcuJYPe.js} +1 -1
- package/dist/assets/{arc-CTR1mrNz.js → arc-CLuSzQ4E.js} +1 -1
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-DrsB_-NW.js → architectureDiagram-ZJ3FMSHR-DlhVck93.js} +1 -1
- package/dist/assets/{area-logos-D_dodLqh.js → area-logos-DYARiYqI.js} +1 -1
- package/dist/assets/{blockDiagram-677ZJIJ3-Bf6BktPD.js → blockDiagram-677ZJIJ3-CJwOmsfj.js} +1 -1
- package/dist/assets/{c4Diagram-LMCZKHZV--UrsSHrg.js → c4Diagram-LMCZKHZV-OsgCNPWJ.js} +1 -1
- package/dist/assets/channel-cpl_NpAy.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DajcrDU0.js → chunk-2Q5K7J3B-KG-L7vvm.js} +1 -1
- package/dist/assets/{chunk-32BRIVSS-BoJToPN6.js → chunk-32BRIVSS-BXGbqO9v.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-CWyIsEjs.js → chunk-5VM5RSS4-BWXkm8f0.js} +1 -1
- package/dist/assets/{chunk-EX3LRPZG-BxQt59EY.js → chunk-EX3LRPZG-7-8ulJ19.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-CcltxnxE.js → chunk-JWPE2WC7-mkwFN5xu.js} +1 -1
- package/dist/assets/{chunk-MOJQB5TN-CoFz0cis.js → chunk-MOJQB5TN-WEfWznKE.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-CqD5SIAs.js → chunk-RYQCIY6F-ByP5odu4.js} +1 -1
- package/dist/assets/{chunk-V7JOEXUC-B38vYRK3.js → chunk-V7JOEXUC-yWHmp1L1.js} +1 -1
- package/dist/assets/{chunk-VR4S4FIN-CVwpBl0T.js → chunk-VR4S4FIN-DHbZaHzt.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-DznOU5hd.js → chunk-XXDRQBXY-SNa-Wh3U.js} +1 -1
- package/dist/assets/classDiagram-OUVF2IWQ-D_lsO4mm.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-D_lsO4mm.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-B1uTqWwQ.js → cose-bilkent-JH36ORCC-CyxHYUhP.js} +1 -1
- package/dist/assets/{cynefin-VYW2F7L2-DgpqdGRT.js → cynefin-VYW2F7L2-BvwjSDiQ.js} +1 -1
- package/dist/assets/{cynefinDiagram-TSTJHNR4-Ld74Dvow.js → cynefinDiagram-TSTJHNR4-C8doInhn.js} +1 -1
- package/dist/assets/{dagre-VKFMJZFB-DAp2Br8X.js → dagre-VKFMJZFB-BNDcupek.js} +1 -1
- package/dist/assets/{diagram-FQU43EPY-CaMUb0eE.js → diagram-FQU43EPY-Bst0bBnQ.js} +1 -1
- package/dist/assets/{diagram-G47NLZAW-kTOq861A.js → diagram-G47NLZAW-CfEv0aTY.js} +1 -1
- package/dist/assets/{diagram-NH7WQ7WH-LWZrE7zu.js → diagram-NH7WQ7WH-B7MYvWXL.js} +1 -1
- package/dist/assets/{diagram-OA4YK3LP-Csm-frID.js → diagram-OA4YK3LP-BIzII0d2.js} +1 -1
- package/dist/assets/{diagram-WEI45ONY-BconZEMM.js → diagram-WEI45ONY-D5yd1HWr.js} +1 -1
- package/dist/assets/{ebnfDiagram-CCIWWBDH-Cr5xwAgl.js → ebnfDiagram-CCIWWBDH-gyhVYUos.js} +1 -1
- package/dist/assets/{erDiagram-Q63AITRT-76P2E9Q6.js → erDiagram-Q63AITRT-Duz-DwfE.js} +1 -1
- package/dist/assets/{flowDiagram-23GEKE2U-CciJAjTA.js → flowDiagram-23GEKE2U-CrnARkmw.js} +1 -1
- package/dist/assets/{ganttDiagram-NO4QXBWP-D7VgBp68.js → ganttDiagram-NO4QXBWP-D6cBteIN.js} +1 -1
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-CxICR8Bg.js → gitGraphDiagram-IHSO6WYX-CMHfr_lR.js} +1 -1
- package/dist/assets/{index-Cd53q1WZ.js → index-2427ATYD.js} +3 -3
- package/dist/assets/{index-lQifR7XC.js → index-B1vOCcI-.js} +1 -1
- package/dist/assets/index-B5wHDczA.js +2 -0
- package/dist/assets/{index-BNsHVfai.js → index-CbMtvQTH.js} +1 -1
- package/dist/assets/{index-DzzLdCr9.js → index-D5O_0aq9.js} +1 -1
- package/dist/assets/{index-Bfmfqbw7.js → index-D5pIRxFm.js} +1 -1
- package/dist/assets/index-DJKuwqJG.js +2 -0
- package/dist/assets/{index-Dc4yP2fA.js → index-DeqoOoo6.js} +3 -3
- package/dist/assets/{index-Z0bYekBH.js → index-fiC5OXgR.js} +1 -1
- package/dist/assets/{infoDiagram-FWYZ7A6U-h-R7gGrP.js → infoDiagram-FWYZ7A6U-Mvk2Mpp3.js} +1 -1
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-D1RbbiMz.js → ishikawaDiagram-FXEZZL3T-DXsaNDYg.js} +1 -1
- package/dist/assets/{journeyDiagram-5HDEW3XC-BnNUbZMI.js → journeyDiagram-5HDEW3XC-6QlK8xHN.js} +1 -1
- package/dist/assets/{kanban-definition-HUTT4EX6-kX3kneLI.js → kanban-definition-HUTT4EX6-D5EeRs07.js} +1 -1
- package/dist/assets/{linear-DC5X1tTJ.js → linear-D_aP9MD5.js} +1 -1
- package/dist/assets/main-B2ZLroL1.css +1 -0
- package/dist/assets/{main-Bb9H5jmt.js → main-Dk3qq80S.js} +156 -156
- package/dist/assets/{mermaid.core-BE33DHym.js → mermaid.core-CEculPxD.js} +4 -4
- package/dist/assets/{mindmap-definition-LN4V7U3C-CY3A4tSH.js → mindmap-definition-LN4V7U3C-Vjj9vgEN.js} +1 -1
- package/dist/assets/{pegDiagram-2B236MQR-B99ZSEym.js → pegDiagram-2B236MQR-B-AwbaoO.js} +1 -1
- package/dist/assets/{pieDiagram-ENE6RG2P-7PsmMteT.js → pieDiagram-ENE6RG2P-D5o1UYPK.js} +1 -1
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-DjShiKUv.js → quadrantDiagram-ABIIQ3AL-Bl_Rbmz-.js} +1 -1
- package/dist/assets/{railroadDiagram-RFXS5EU6-B6KuCiHH.js → railroadDiagram-RFXS5EU6-CW-qy1dp.js} +1 -1
- package/dist/assets/{requirementDiagram-TGXJPOKE-k_7TCScw.js → requirementDiagram-TGXJPOKE-DGUQpy3K.js} +1 -1
- package/dist/assets/{sankeyDiagram-HTMAVEWB-D2YbTfpK.js → sankeyDiagram-HTMAVEWB-CUlWZH9G.js} +1 -1
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-CuYh53OC.js → sequenceDiagram-DBY2YBRQ-CeDVJrbJ.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-D4_qcFkr.js → sizeCapture-X5ZJPWSS-BGSL3ofq.js} +1 -1
- package/dist/assets/{stateDiagram-2N3HPSRC-DO9QVMBT.js → stateDiagram-2N3HPSRC-9A8tAPIu.js} +1 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-DzVFFq0g.js +1 -0
- package/dist/assets/{swimlanes-5IMT3BWC-gMS-z6zh.js → swimlanes-5IMT3BWC-CipRR1uk.js} +2 -2
- package/dist/assets/swimlanesDiagram-G3AALYLV-XDQw-C4e.js +8 -0
- package/dist/assets/{timeline-definition-FHXFAJF6-CUmQCwOG.js → timeline-definition-FHXFAJF6-IgrCsFe-.js} +1 -1
- package/dist/assets/{vendor-three-CBPuP1jE.js → vendor-three-DYBBrXTx.js} +1 -1
- package/dist/assets/{vennDiagram-L72KCM5P-CIP-5b8u.js → vennDiagram-L72KCM5P-okSGsDy3.js} +1 -1
- package/dist/assets/{wardleyDiagram-EHGQE667-DlQqKMjr.js → wardleyDiagram-EHGQE667-G0RLggUt.js} +1 -1
- package/dist/assets/{web-DmAaMs-2.js → web-B5BfOO5C.js} +1 -1
- package/dist/assets/{web-D42BXPx5.js → web-BPOqvnJL.js} +1 -1
- package/dist/assets/{web-DVkGXGfI.js → web-Q8DwQW0W.js} +1 -1
- package/dist/assets/{xychartDiagram-FW5EYKEG-CekYCp3d.js → xychartDiagram-FW5EYKEG-DtVJEFyI.js} +1 -1
- package/dist/build-info.json +1 -1
- package/dist/index.html +3 -3
- package/dist/src/packages/server/app.js +26 -1
- package/dist/src/packages/server/claude/backend.js +5 -4
- package/dist/src/packages/server/claude/runner/stdout-pipeline.js +29 -30
- package/dist/src/packages/server/claude/runner/watchdog.js +2 -1
- package/dist/src/packages/server/claude/session-loader.js +141 -81
- package/dist/src/packages/server/data/index.js +35 -2
- package/dist/src/packages/server/routes/perf.js +50 -39
- package/dist/src/packages/server/services/git-watch-service.js +14 -2
- package/dist/src/packages/server/services/runtime-service.js +85 -39
- package/dist/src/packages/server/websocket/handler.js +33 -8
- package/dist/src/packages/server/websocket/listeners/runtime-listeners.js +5 -2
- package/package.json +3 -1
- package/dist/assets/SceneManager-htGN7YfA.js +0 -104
- package/dist/assets/channel-BkokQZXi.js +0 -1
- package/dist/assets/classDiagram-OUVF2IWQ-DibSrtP1.js +0 -1
- package/dist/assets/classDiagram-v2-EOCWNBFH-DibSrtP1.js +0 -1
- package/dist/assets/index-C8zT43_7.js +0 -2
- package/dist/assets/index-WhxnTPGa.js +0 -2
- package/dist/assets/main-CSv15YYo.css +0 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-CekJ4qac.js +0 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-CfPVdXRk.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as t,c as S,d as y,j as e,I as B}from"./main-Bb9H5jmt.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-CBPuP1jE.js";function oe({integration:o,onSave:f,onCancel:z}){const[r,I]=t.useState(o.values.authMethod||"oauth2"),[g,L]=t.useState(o.values.clientId||""),[v,q]=t.useState(""),[w,K]=t.useState(o.values.redirectBaseUrl||""),[m,$]=t.useState(""),[j,Y]=t.useState(o.values.impersonateEmail||""),[p,E]=t.useState(String(o.values.pollingIntervalMs??3e4)),[x,O]=t.useState(o.values.defaultApprovalKeywords||"approved,aprobado,autorizado,yes,ok"),[M,G]=t.useState(null),[n,T]=t.useState(null),[c,d]=t.useState(!1),[P,i]=t.useState(null),[U,F]=t.useState(!1),[H,J]=t.useState(!1),[N,W]=t.useState(!1),[b,h]=t.useState(o.status.connected?"connected":"credentials"),k=r==="oauth2"&&o.values.clientId==="********"&&o.values.clientSecret==="********",s=t.useRef(null),_=t.useRef(o.status.connected),u=t.useCallback(async()=>{try{const a=await S(y("/api/email/status"));if(a.ok){const l=await a.json();T(l),l.authenticated&&(h("connected"),s.current&&(clearInterval(s.current),s.current=null))}}catch(a){console.error("Failed to fetch Gmail status:",a)}},[]);t.useEffect(()=>{const a=o.status.connected,l=_.current;a&&!l&&b!=="connected"?h("connected"):!a&&l&&b==="connected"&&h("credentials"),_.current=a},[o.status.connected]),t.useEffect(()=>(u(),()=>{s.current&&clearInterval(s.current)}),[u]);const R=async()=>{const a=await S(y("/api/email/auth/url"));if(!a.ok){const A=await a.json().catch(()=>({}));throw new Error(A.error||`HTTP ${a.status}`)}const l=await a.json();if(!l.url)throw new Error("OAuth URL is empty");G(l.url),i(null),h("authorize"),s.current&&clearInterval(s.current),s.current=setInterval(u,3e3)},X=async()=>{d(!0),i(null);try{await R()}catch(a){i(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{d(!1)}},Q=async()=>{if(!g.trim()){i("Client ID is required");return}d(!0),i(null);try{const a={authMethod:"oauth2",redirectBaseUrl:w.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x};g.trim()&&g.trim()!=="********"&&(a.clientId=g.trim()),v.trim()&&v.trim()!=="********"&&(a.clientSecret=v.trim()),await f(a),await R()}catch(a){const l=a instanceof Error?a.message:"Failed to get OAuth URL";i(l)}finally{d(!1)}},V=async()=>{if(!m.trim()){i("Service Account JSON is required");return}if(!j.trim()){i("Impersonate Email is required");return}try{const a=JSON.parse(m.trim());if(!a.client_email||!a.private_key){i("Service Account JSON must contain client_email and private_key");return}}catch{i("Invalid JSON in Service Account field");return}d(!0),i(null);try{await f({authMethod:"service_account",serviceAccountJson:m.trim(),impersonateEmail:j.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x}),await new Promise(a=>setTimeout(a,1e3)),await u()}catch(a){const l=a instanceof Error?a.message:"Failed to save service account";i(l)}finally{d(!1)}},Z=async()=>{F(!0),i(null);try{await f({pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x})}catch(a){i(a instanceof Error?a.message:"Failed to save settings")}finally{F(!1)}},ee=async()=>{const a=!(n!=null&&n.pollingActive);J(!0),i(null);try{const l=a?"/api/email/polling/start":"/api/email/polling/stop",A=a?{intervalMs:parseInt(p)||3e4}:{},C=await S(y(l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)});if(!C.ok){const te=await C.json().catch(()=>({}));throw new Error(te.error||`HTTP ${C.status}`)}await u()}catch(l){i(l instanceof Error?l.message:"Failed to toggle polling")}finally{J(!1)}},ae=async()=>{d(!0),i(null);try{await f({refreshToken:"",serviceAccountJson:"",impersonateEmail:""}),T(null),G(null),h("credentials"),await u()}catch(a){i(a instanceof Error?a.message:"Failed to disconnect")}finally{d(!1)}},D=!!o.values.serviceAccountJson;return e.jsxs("div",{className:"gmail-oauth-setup",children:[P&&e.jsx("div",{className:"gmail-oauth-error",children:P}),b==="credentials"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsxs("div",{className:"gmail-oauth-field",style:{marginBottom:24},children:[e.jsx("label",{className:"integration-field-label",children:"Authentication Method"}),e.jsxs("div",{className:"gmail-auth-method-selector",children:[e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="oauth2"?"active":""}`,onClick:()=>{I("oauth2"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(B,{name:"key",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"OAuth 2.0"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Browser login flow"})]}),e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="service_account"?"active":""}`,onClick:()=>{I("service_account"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(B,{name:"robot",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"Service Account"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Domain-wide delegation"})]})]})]}),r==="oauth2"&&k&&!N&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("div",{className:"gmail-oauth-shared-banner",children:[e.jsxs("div",{className:"gmail-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"gmail-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants Gmail access."})]})]}),r==="oauth2"&&(!k||N)&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"Google Cloud Console"}),". Enable the Gmail API and (optionally) the Calendar API. Set the redirect URI to:"," ",e.jsx("code",{className:"gmail-oauth-code",children:w.trim()?`${w.trim().replace(/\/$/,"")}/api/email/auth/callback`:y("/api/email/auth/callback")})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:g,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>L(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:v,placeholder:o.values.clientSecret?"(saved)":"Enter client secret",onChange:a=>q(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:w,placeholder:"http://localhost:6200",onChange:a=>K(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]})]}),r==="service_account"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Service Account Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Use a Google service account with"," ",e.jsx("a",{href:"https://admin.google.com/ac/owl/domainwidedelegation",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"domain-wide delegation"})," ","enabled. The service account must be authorized for Gmail scopes in Google Workspace Admin."]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Service Account JSON ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:m,placeholder:D?"(saved — paste new JSON to replace)":"Paste the full service account JSON key file contents",onChange:a=>$(a.target.value),rows:6,spellCheck:!1}),e.jsx("span",{className:"integration-field-description",children:"The JSON key file downloaded from Google Cloud Console containing client_email and private_key."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Impersonate Email ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"email",className:"integration-field-input",value:j,placeholder:"user@yourdomain.com",onChange:a=>Y(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"The email address to impersonate via domain-wide delegation. Must be a user in your Google Workspace domain."})]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"How often to check for new emails. Default: 30000 (30s)."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2}),e.jsx("span",{className:"integration-field-description",children:"Comma-separated keywords that indicate email approval."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Cancel"}),r==="oauth2"&&k&&!N?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>W(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:X,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]}):r==="oauth2"?e.jsx("button",{type:"button",className:"integration-btn save",onClick:Q,disabled:c||!g.trim(),children:c?"Saving...":"Save & Authorize"}):e.jsx("button",{type:"button",className:"integration-btn save",onClick:V,disabled:c||!j.trim()||!m.trim()&&!D,children:c?"Connecting...":"Save & Connect"})]})]}),b==="authorize"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Authorize Gmail Access"}),e.jsx("p",{className:"gmail-oauth-help",children:"Click the link below to authorize Tide Commander to access your Gmail account. After granting access, you will be redirected back and the connection will be established automatically."}),M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"gmail-oauth-waiting",children:[e.jsx("span",{className:"gmail-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{s.current&&(clearInterval(s.current),s.current=null),h("credentials")},children:"Back"})})]}),b==="connected"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Gmail Connected"}),e.jsxs("div",{className:"gmail-oauth-connected-info",children:[e.jsx("span",{className:"gmail-oauth-connected-badge",children:"Connected"}),(n==null?void 0:n.emailAddress)&&e.jsx("span",{className:"gmail-oauth-email",children:n.emailAddress}),e.jsx("span",{className:"gmail-oauth-auth-type",children:r==="service_account"?"Service Account":"OAuth 2.0"})]}),e.jsxs("div",{className:"gmail-polling-toggle-row",children:[e.jsxs("div",{className:"gmail-polling-toggle-info",children:[e.jsx("div",{className:"gmail-polling-toggle-label",children:"Automatic Polling"}),e.jsx("div",{className:"gmail-polling-toggle-status",children:n!=null&&n.pollingActive?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot active"}),"Active",n.lastChecked&&e.jsxs("span",{className:"gmail-polling-last",children:["— last checked ",new Date(n.lastChecked).toLocaleTimeString()]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot paused"}),"Paused — new emails will not be ingested"]})})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":!!(n!=null&&n.pollingActive),"aria-label":"Toggle automatic polling",className:`gmail-polling-switch ${n!=null&&n.pollingActive?"on":"off"}`,onClick:ee,disabled:H,children:e.jsx("span",{className:"gmail-polling-switch-thumb"})})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn",style:{backgroundColor:"#f38ba8",color:"#1e1e2e"},onClick:ae,disabled:c,children:c?"Disconnecting...":"Disconnect"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:Z,disabled:U,children:U?"Saving...":"Save Settings"})]})]}),e.jsx("style",{children:`
|
|
1
|
+
import{r as t,c as S,d as y,j as e,I as B}from"./main-Dk3qq80S.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function oe({integration:o,onSave:f,onCancel:z}){const[r,I]=t.useState(o.values.authMethod||"oauth2"),[g,L]=t.useState(o.values.clientId||""),[v,q]=t.useState(""),[w,K]=t.useState(o.values.redirectBaseUrl||""),[m,$]=t.useState(""),[j,Y]=t.useState(o.values.impersonateEmail||""),[p,E]=t.useState(String(o.values.pollingIntervalMs??3e4)),[x,O]=t.useState(o.values.defaultApprovalKeywords||"approved,aprobado,autorizado,yes,ok"),[M,G]=t.useState(null),[n,T]=t.useState(null),[c,d]=t.useState(!1),[P,i]=t.useState(null),[U,F]=t.useState(!1),[H,J]=t.useState(!1),[N,W]=t.useState(!1),[b,h]=t.useState(o.status.connected?"connected":"credentials"),k=r==="oauth2"&&o.values.clientId==="********"&&o.values.clientSecret==="********",s=t.useRef(null),_=t.useRef(o.status.connected),u=t.useCallback(async()=>{try{const a=await S(y("/api/email/status"));if(a.ok){const l=await a.json();T(l),l.authenticated&&(h("connected"),s.current&&(clearInterval(s.current),s.current=null))}}catch(a){console.error("Failed to fetch Gmail status:",a)}},[]);t.useEffect(()=>{const a=o.status.connected,l=_.current;a&&!l&&b!=="connected"?h("connected"):!a&&l&&b==="connected"&&h("credentials"),_.current=a},[o.status.connected]),t.useEffect(()=>(u(),()=>{s.current&&clearInterval(s.current)}),[u]);const R=async()=>{const a=await S(y("/api/email/auth/url"));if(!a.ok){const A=await a.json().catch(()=>({}));throw new Error(A.error||`HTTP ${a.status}`)}const l=await a.json();if(!l.url)throw new Error("OAuth URL is empty");G(l.url),i(null),h("authorize"),s.current&&clearInterval(s.current),s.current=setInterval(u,3e3)},X=async()=>{d(!0),i(null);try{await R()}catch(a){i(a instanceof Error?a.message:"Failed to get OAuth URL")}finally{d(!1)}},Q=async()=>{if(!g.trim()){i("Client ID is required");return}d(!0),i(null);try{const a={authMethod:"oauth2",redirectBaseUrl:w.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x};g.trim()&&g.trim()!=="********"&&(a.clientId=g.trim()),v.trim()&&v.trim()!=="********"&&(a.clientSecret=v.trim()),await f(a),await R()}catch(a){const l=a instanceof Error?a.message:"Failed to get OAuth URL";i(l)}finally{d(!1)}},V=async()=>{if(!m.trim()){i("Service Account JSON is required");return}if(!j.trim()){i("Impersonate Email is required");return}try{const a=JSON.parse(m.trim());if(!a.client_email||!a.private_key){i("Service Account JSON must contain client_email and private_key");return}}catch{i("Invalid JSON in Service Account field");return}d(!0),i(null);try{await f({authMethod:"service_account",serviceAccountJson:m.trim(),impersonateEmail:j.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x}),await new Promise(a=>setTimeout(a,1e3)),await u()}catch(a){const l=a instanceof Error?a.message:"Failed to save service account";i(l)}finally{d(!1)}},Z=async()=>{F(!0),i(null);try{await f({pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:x})}catch(a){i(a instanceof Error?a.message:"Failed to save settings")}finally{F(!1)}},ee=async()=>{const a=!(n!=null&&n.pollingActive);J(!0),i(null);try{const l=a?"/api/email/polling/start":"/api/email/polling/stop",A=a?{intervalMs:parseInt(p)||3e4}:{},C=await S(y(l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)});if(!C.ok){const te=await C.json().catch(()=>({}));throw new Error(te.error||`HTTP ${C.status}`)}await u()}catch(l){i(l instanceof Error?l.message:"Failed to toggle polling")}finally{J(!1)}},ae=async()=>{d(!0),i(null);try{await f({refreshToken:"",serviceAccountJson:"",impersonateEmail:""}),T(null),G(null),h("credentials"),await u()}catch(a){i(a instanceof Error?a.message:"Failed to disconnect")}finally{d(!1)}},D=!!o.values.serviceAccountJson;return e.jsxs("div",{className:"gmail-oauth-setup",children:[P&&e.jsx("div",{className:"gmail-oauth-error",children:P}),b==="credentials"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsxs("div",{className:"gmail-oauth-field",style:{marginBottom:24},children:[e.jsx("label",{className:"integration-field-label",children:"Authentication Method"}),e.jsxs("div",{className:"gmail-auth-method-selector",children:[e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="oauth2"?"active":""}`,onClick:()=>{I("oauth2"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(B,{name:"key",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"OAuth 2.0"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Browser login flow"})]}),e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${r==="service_account"?"active":""}`,onClick:()=>{I("service_account"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:e.jsx(B,{name:"robot",size:14})}),e.jsx("span",{className:"gmail-auth-method-label",children:"Service Account"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Domain-wide delegation"})]})]})]}),r==="oauth2"&&k&&!N&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("div",{className:"gmail-oauth-shared-banner",children:[e.jsxs("div",{className:"gmail-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"gmail-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants Gmail access."})]})]}),r==="oauth2"&&(!k||N)&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"Google Cloud Console"}),". Enable the Gmail API and (optionally) the Calendar API. Set the redirect URI to:"," ",e.jsx("code",{className:"gmail-oauth-code",children:w.trim()?`${w.trim().replace(/\/$/,"")}/api/email/auth/callback`:y("/api/email/auth/callback")})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:g,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>L(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:v,placeholder:o.values.clientSecret?"(saved)":"Enter client secret",onChange:a=>q(a.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:w,placeholder:"http://localhost:6200",onChange:a=>K(a.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]})]}),r==="service_account"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Service Account Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Use a Google service account with"," ",e.jsx("a",{href:"https://admin.google.com/ac/owl/domainwidedelegation",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"domain-wide delegation"})," ","enabled. The service account must be authorized for Gmail scopes in Google Workspace Admin."]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Service Account JSON ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:m,placeholder:D?"(saved — paste new JSON to replace)":"Paste the full service account JSON key file contents",onChange:a=>$(a.target.value),rows:6,spellCheck:!1}),e.jsx("span",{className:"integration-field-description",children:"The JSON key file downloaded from Google Cloud Console containing client_email and private_key."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Impersonate Email ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"email",className:"integration-field-input",value:j,placeholder:"user@yourdomain.com",onChange:a=>Y(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"The email address to impersonate via domain-wide delegation. Must be a user in your Google Workspace domain."})]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"How often to check for new emails. Default: 30000 (30s)."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2}),e.jsx("span",{className:"integration-field-description",children:"Comma-separated keywords that indicate email approval."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Cancel"}),r==="oauth2"&&k&&!N?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>W(!0),disabled:c,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:X,disabled:c,children:c?"Loading...":"Authorize with existing credentials"})]}):r==="oauth2"?e.jsx("button",{type:"button",className:"integration-btn save",onClick:Q,disabled:c||!g.trim(),children:c?"Saving...":"Save & Authorize"}):e.jsx("button",{type:"button",className:"integration-btn save",onClick:V,disabled:c||!j.trim()||!m.trim()&&!D,children:c?"Connecting...":"Save & Connect"})]})]}),b==="authorize"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Authorize Gmail Access"}),e.jsx("p",{className:"gmail-oauth-help",children:"Click the link below to authorize Tide Commander to access your Gmail account. After granting access, you will be redirected back and the connection will be established automatically."}),M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"gmail-oauth-waiting",children:[e.jsx("span",{className:"gmail-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{s.current&&(clearInterval(s.current),s.current=null),h("credentials")},children:"Back"})})]}),b==="connected"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Gmail Connected"}),e.jsxs("div",{className:"gmail-oauth-connected-info",children:[e.jsx("span",{className:"gmail-oauth-connected-badge",children:"Connected"}),(n==null?void 0:n.emailAddress)&&e.jsx("span",{className:"gmail-oauth-email",children:n.emailAddress}),e.jsx("span",{className:"gmail-oauth-auth-type",children:r==="service_account"?"Service Account":"OAuth 2.0"})]}),e.jsxs("div",{className:"gmail-polling-toggle-row",children:[e.jsxs("div",{className:"gmail-polling-toggle-info",children:[e.jsx("div",{className:"gmail-polling-toggle-label",children:"Automatic Polling"}),e.jsx("div",{className:"gmail-polling-toggle-status",children:n!=null&&n.pollingActive?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot active"}),"Active",n.lastChecked&&e.jsxs("span",{className:"gmail-polling-last",children:["— last checked ",new Date(n.lastChecked).toLocaleTimeString()]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"gmail-polling-dot paused"}),"Paused — new emails will not be ingested"]})})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":!!(n!=null&&n.pollingActive),"aria-label":"Toggle automatic polling",className:`gmail-polling-switch ${n!=null&&n.pollingActive?"on":"off"}`,onClick:ee,disabled:H,children:e.jsx("span",{className:"gmail-polling-switch-thumb"})})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>E(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:x,onChange:a=>O(a.target.value),rows:2})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:z,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn",style:{backgroundColor:"#f38ba8",color:"#1e1e2e"},onClick:ae,disabled:c,children:c?"Disconnecting...":"Disconnect"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:Z,disabled:U,children:U?"Saving...":"Save Settings"})]})]}),e.jsx("style",{children:`
|
|
2
2
|
.gmail-oauth-setup {
|
|
3
3
|
padding: 0;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r,c as E,d as y,j as e}from"./main-
|
|
1
|
+
import{r,c as E,d as y,j as e}from"./main-Dk3qq80S.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function F({integration:o,onSave:k,onCancel:x}){const[g,G]=r.useState(o.values.GOOGLE_CLIENT_ID||""),[f,O]=r.useState(""),[m,A]=r.useState(o.values.GOOGLE_REDIRECT_BASE_URL||""),[N,z]=r.useState(null),[a,S]=r.useState(null),[l,h]=r.useState(!1),[C,s]=r.useState(null),[L,w]=r.useState(!1),I=o.values.GOOGLE_CLIENT_ID==="********"&&o.values.GOOGLE_CLIENT_SECRET==="********",[b,p]=r.useState(o.status.needsReauth?"expired":o.status.connected?"connected":"credentials"),n=r.useRef(null),j=r.useCallback(async(t=!1)=>{try{const d={gmail:"/api/email/status","google-calendar":"/api/calendar/status","google-drive":"/api/drive/status"}[o.id]||"/api/calendar/status",u=await E(y(t?`${d}?probe=1`:d));if(u.ok){const c=await u.json();S(c),c.needsReauth?p("expired"):c.authenticated&&p("connected"),(c.authenticated||c.needsReauth)&&n.current&&(clearInterval(n.current),n.current=null)}}catch(i){console.error("Failed to fetch Google auth status:",i)}},[o.id]);r.useEffect(()=>(j(!0),()=>{n.current&&clearInterval(n.current)}),[j]);const v=async()=>{const i={gmail:"/api/email/auth/url","google-calendar":"/api/calendar/auth/url","google-drive":"/api/drive/auth/url"}[o.id]||"/api/calendar/auth/url",d=await E(y(i));if(!d.ok){const c=await d.json().catch(()=>({}));throw new Error(c.error||`HTTP ${d.status}`)}const u=await d.json();if(!u.url)throw new Error("OAuth URL is empty");z(u.url),s(null),p("authorize"),n.current&&clearInterval(n.current),n.current=setInterval(j,3e3)},R=async()=>{h(!0),s(null);try{await v()}catch(t){s(t instanceof Error?t.message:"Failed to get OAuth URL")}finally{h(!1)}},_=async()=>{if(!g.trim()){s("Client ID is required");return}h(!0),s(null);try{const t={GOOGLE_REDIRECT_BASE_URL:m.trim()};g.trim()&&g.trim()!=="********"&&(t.GOOGLE_CLIENT_ID=g.trim()),f.trim()&&(t.GOOGLE_CLIENT_SECRET=f.trim()),console.log("Saving Google OAuth config...",t),await k(t),console.log("Config saved successfully"),await v()}catch(t){const i=t instanceof Error?t.message:"Failed to get OAuth URL";console.error("Error in handleSaveCredentials:",i,t),s(i)}finally{h(!1)}};return e.jsxs("div",{className:"google-oauth-setup",children:[C&&e.jsx("div",{className:"google-oauth-error",children:C}),b==="credentials"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google OAuth Credentials"}),I&&!L?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"google-oauth-shared-banner",children:[e.jsxs("div",{className:"google-oauth-shared-title",children:[e.jsx("span",{children:"✓"}),e.jsx("span",{children:"Credentials already configured"})]}),e.jsx("div",{className:"google-oauth-shared-body",children:"Existing Google OAuth credentials (Client ID and Secret) are saved in your secrets store — they're shared between Gmail, Calendar, and Drive. You may still need to re-authorize once so the refresh token grants access to this service."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>w(!0),disabled:l,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:R,disabled:l,children:l?"Loading...":"Authorize with existing credentials"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"google-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"google-oauth-link",children:"Google Cloud Console"}),". Enable the relevant API (Gmail, Calendar, or Drive). Set the redirect URI to:"," ",e.jsx("code",{className:"google-oauth-code",children:(()=>{const t=o.id==="gmail"?"/api/email/auth/callback":o.id==="google-drive"?"/api/drive/auth/callback":"/api/calendar/auth/callback",i=m.trim();return i?`${i.replace(/\/$/,"")}${t}`:y(t)})()})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:g,placeholder:"xxxx.apps.googleusercontent.com",onChange:t=>G(t.target.value)})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:f,placeholder:o.values.GOOGLE_CLIENT_SECRET?"(saved)":"Enter client secret",onChange:t=>O(t.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"OAuth Redirect Base URL"}),e.jsx("input",{type:"text",className:"integration-field-input",value:m,placeholder:"http://localhost:6200",onChange:t=>A(t.target.value),autoComplete:"off"}),e.jsxs("span",{className:"integration-field-description",style:{display:"block",marginTop:7,color:"#7f849c",fontSize:12},children:["Override the base URL used to build the OAuth redirect (e.g. ",e.jsx("code",{children:"http://commander.local:10003"}),"). Shared across Gmail, Calendar, and Drive. Leave empty to use the server's local address. Google does not accept raw IPs — use a domain (you can map one in ",e.jsx("code",{children:"/etc/hosts"}),")."]})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:_,disabled:l||!g.trim(),children:l?"Saving...":"Save & Authorize"})]})]})]}),b==="authorize"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Authorize Google Access"}),e.jsx("p",{className:"google-oauth-help",children:"Click the link below to authorize Tide Commander to access your Google account. After granting access, you will be redirected back and the connection will be established automatically."}),N&&e.jsx("a",{href:N,target:"_blank",rel:"noopener noreferrer",className:"google-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"google-oauth-waiting",children:[e.jsx("span",{className:"google-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{n.current&&(clearInterval(n.current),n.current=null),p("credentials")},children:"Back"})})]}),b==="expired"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google Authorization Expired"}),e.jsxs("div",{className:"google-oauth-expired-banner",children:[e.jsxs("div",{className:"google-oauth-expired-title",children:[e.jsx("span",{children:"⚠"}),e.jsx("span",{children:(a==null?void 0:a.tokenState)==="invalid_client"?"OAuth credentials rejected":"Token expired — reconnect required"})]}),e.jsx("div",{className:"google-oauth-expired-body",children:(a==null?void 0:a.tokenState)==="invalid_client"?e.jsx(e.Fragment,{children:"Google rejected the Client ID / Client Secret. Confirm the OAuth client still exists in the Google Cloud Console, then re-enter the credentials."}):e.jsxs(e.Fragment,{children:["Google rejected the stored refresh token, so Gmail, Calendar, and Drive can no longer act on your account — they all share this one token. This normally happens when access is revoked, the account password changed, or the OAuth consent screen is still in ",e.jsx("strong",{children:"Testing"})," mode (Google expires those refresh tokens after 7 days — publish the app to stop it recurring)."]})}),(a==null?void 0:a.error)&&e.jsx("div",{className:"google-oauth-expired-detail",children:a.error})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:x,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn secondary",onClick:()=>{w(!0),p("credentials")},disabled:l,children:"Edit credentials"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:async()=>{h(!0),s(null);try{await v()}catch(t){s(t instanceof Error?t.message:"Failed to get OAuth URL")}finally{h(!1)}},disabled:l,children:l?"Loading...":"Reconnect Google"})]})]}),b==="connected"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google Connected"}),e.jsxs("div",{className:"google-oauth-connected-info",children:[e.jsx("span",{className:"google-oauth-connected-badge",children:"Connected"}),(a==null?void 0:a.emailAddress)&&e.jsx("span",{className:"google-oauth-email",children:a.emailAddress})]}),e.jsx("p",{className:"google-oauth-help",children:"Your Google account has been successfully connected."}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:async()=>{await k({}),x()},children:"Close"})})]}),e.jsx("style",{children:`
|
|
2
2
|
.google-oauth-setup {
|
|
3
3
|
padding: 0;
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as K,r as a,j as e}from"./main-
|
|
1
|
+
import{u as K,r as a,j as e}from"./main-Dk3qq80S.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function se({url:l,title:W,isOpen:g,onClose:I,initialWidth:H=480,initialHeight:B=360,minWidth:M=320,minHeight:b=240}){const{t:n}=K(["terminal","common"]),[Z,h]=a.useState(!0),[L,k]=a.useState(!1),[o,$]=a.useState({width:H,height:B}),[s,y]=a.useState(null),[f,z]=a.useState(1),[O,R]=a.useState(!1),[T,X]=a.useState(!1),N=a.useRef(null),U=a.useRef(null),d=a.useRef(null),r=a.useRef(null);a.useEffect(()=>{if(g&&!s){const t=Math.max(50,(window.innerWidth-o.width)/2),c=Math.max(50,(window.innerHeight-o.height)/2);y({x:t,y:c})}},[g,s,o.width,o.height]),a.useEffect(()=>{h(!0),k(!1)},[l]);const A=a.useCallback(()=>{h(!1)},[]),V=a.useCallback(()=>{h(!1),k(!0)},[]),Y=a.useCallback(()=>{N.current&&(h(!0),k(!1),N.current.src=l)},[l]),_=a.useCallback(()=>{window.open(l,"_blank")},[l]),q=a.useCallback(()=>{z(t=>Math.min(2,t+.25))},[]),F=a.useCallback(()=>{z(t=>Math.max(.25,t-.25))},[]),G=a.useCallback(()=>{z(1)},[]),J=a.useCallback(t=>{if(t.target.closest(".iframe-modal-btn"))return;t.preventDefault(),R(!0),d.current={startX:t.clientX,startY:t.clientY,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0};const c=m=>{if(!d.current)return;const w=m.clientX-d.current.startX,j=m.clientY-d.current.startY;y({x:Math.max(0,Math.min(window.innerWidth-100,d.current.startPosX+w)),y:Math.max(0,Math.min(window.innerHeight-50,d.current.startPosY+j))})},x=()=>{d.current=null,R(!1),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",x)},[s]),i=a.useCallback((t,c)=>{t.preventDefault(),t.stopPropagation(),X(!0);const x={startX:t.clientX,startY:t.clientY,startW:o.width,startH:o.height,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0,direction:c};r.current=x;const m=j=>{if(!r.current)return;const p=j.clientX-r.current.startX,C=j.clientY-r.current.startY,v=r.current.direction;let E=r.current.startW,D=r.current.startH,P=r.current.startPosX,S=r.current.startPosY;if(v.includes("e")&&(E=Math.max(M,r.current.startW+p)),v.includes("w")){const u=r.current.startW-p;u>=M&&(E=u,P=r.current.startPosX+p)}if(v.includes("s")&&(D=Math.max(b,r.current.startH+C)),v.includes("n")){const u=r.current.startH-C;u>=b&&(D=u,S=r.current.startPosY+C)}$({width:E,height:D}),y({x:P,y:S})},w=()=>{r.current=null,X(!1),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",w)},[o,s,M,b]);return g?e.jsxs("div",{ref:U,className:`iframe-modal ${O?"dragging":""} ${T?"resizing":""}`,style:{left:(s==null?void 0:s.x)??0,top:(s==null?void 0:s.y)??0,width:o.width,height:o.height},children:[e.jsxs("div",{className:"iframe-modal-toolbar",onMouseDown:J,children:[e.jsx("div",{className:"iframe-modal-title",title:l,children:W||l}),e.jsxs("div",{className:"iframe-modal-actions",children:[e.jsx("button",{className:"iframe-modal-btn",onClick:F,title:n("terminal:iframeModal.zoomOut"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsxs("button",{className:"iframe-modal-btn iframe-modal-zoom-label",onClick:G,title:n("terminal:iframeModal.resetZoom"),children:[Math.round(f*100),"%"]}),e.jsx("button",{className:"iframe-modal-btn",onClick:q,title:n("terminal:iframeModal.zoomIn"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),e.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsx("div",{className:"iframe-modal-separator"}),e.jsx("button",{className:"iframe-modal-btn",onClick:Y,title:n("terminal:iframeModal.refresh"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M23 4v6h-6M1 20v-6h6"}),e.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}),e.jsx("button",{className:"iframe-modal-btn",onClick:_,title:n("terminal:iframeModal.openInBrowser"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}),e.jsx("button",{className:"iframe-modal-btn iframe-modal-close",onClick:I,title:n("common:buttons.close"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsxs("div",{className:"iframe-modal-content",children:[Z&&e.jsxs("div",{className:"iframe-modal-loading",children:[e.jsx("div",{className:"iframe-modal-spinner"}),e.jsx("span",{children:n("common:status.loading")})]}),L&&e.jsxs("div",{className:"iframe-modal-error",children:[e.jsx("span",{children:n("terminal:iframeModal.failedToLoad")}),e.jsx("button",{onClick:Y,children:n("terminal:iframeModal.retry")})]}),e.jsx("iframe",{ref:N,src:l,className:"iframe-modal-frame",onLoad:A,onError:V,style:{display:L?"none":"block",transform:`scale(${f})`,transformOrigin:"top left",width:`${100/f}%`,height:`${100/f}%`}})]}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-n",onMouseDown:t=>i(t,"n")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-s",onMouseDown:t=>i(t,"s")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-e",onMouseDown:t=>i(t,"e")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-w",onMouseDown:t=>i(t,"w")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-ne",onMouseDown:t=>i(t,"ne")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-nw",onMouseDown:t=>i(t,"nw")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-se",onMouseDown:t=>i(t,"se")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-sw",onMouseDown:t=>i(t,"sw")})]}):null}export{se as IframeModal,se as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GmailOAuthSetup-
|
|
2
|
-
import{r as d,c as R,d as w,j as e,U as P,a1 as T}from"./main-Bb9H5jmt.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-CBPuP1jE.js";const z={"gmail-oauth":d.lazy(()=>T(()=>import("./GmailOAuthSetup-Cj0r8z52.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.GmailOAuthSetup}))),"google-oauth":d.lazy(()=>T(()=>import("./GoogleOAuthSetup-BO0udRUZ.js"),__vite__mapDeps([5,1,2,3,4])).then(n=>({default:n.GoogleOAuthSetup}))),"slack-multi-instance":d.lazy(()=>T(()=>import("./SlackMultiInstanceSetup-C6EtUfP8.js"),__vite__mapDeps([6,1,2,3,4])).then(n=>({default:n.SlackMultiInstanceSetup})))},A={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅","google-drive":"📁",docx:"📄"},B={gmail:"Send and receive emails through Gmail. Supports OAuth 2.0 authentication for secure access to your inbox.",slack:"Connect to Slack workspaces. Send messages, receive notifications, and integrate with channels.",jira:"Manage Jira issues and projects. Create tickets, track progress, and handle service desk requests.","google-calendar":"Access Google Calendar events. Create, update, and monitor calendar entries.","google-drive":"Read, create, and edit files in Google Drive. Search and manage folders.",docx:"Generate and manipulate DOCX documents. Create reports, templates, and formatted documents."},E={gmail:["Google Cloud Console project","OAuth 2.0 credentials (Client ID & Secret)","Gmail API enabled"],slack:["Bot token (xoxb-) with App-Level Token for real-time Socket Mode, OR User token (xoxp-) for polling mode (~30-60s lag, no Slack app config needed)","For Socket Mode: enable Socket Mode + Event Subscriptions; subscribe to bot events message.channels, message.groups, message.im","Required scopes: channels:history, channels:read, chat:write, groups:history, groups:read, im:history, im:read, users:read","Polling mode (xoxp-) mirrors all channels/groups/DMs the user is a member of — supports xoxp- user tokens that cannot use Socket Mode"],jira:["Jira Cloud instance URL","API Token (from Atlassian account)","Account email address"],"google-calendar":["Google Cloud Console project","OAuth 2.0 credentials","Calendar API enabled"],"google-drive":["Google Cloud Console project","OAuth 2.0 credentials (Client ID & Secret)","Google Drive API enabled"],docx:["No external credentials required","Templates directory (optional)"]},s={overlay:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,backdropFilter:"blur(4px)",animation:"fadeIn 0.15s ease-out"},modal:{background:"var(--surface-0, #1e1e2e)",borderRadius:12,border:"1px solid var(--border, #313244)",width:"90vw",maxWidth:720,maxHeight:"85vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.5)",animation:"slideUp 0.2s ease-out"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)"},headerTitle:{fontSize:16,fontWeight:600,color:"var(--text-primary, #cdd6f4)",display:"flex",alignItems:"center",gap:8},closeBtn:{background:"none",border:"none",color:"var(--text-secondary, #a6adc8)",fontSize:20,cursor:"pointer",padding:"4px 8px",borderRadius:6,lineHeight:1},tabs:{display:"flex",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)",overflowX:"auto",scrollbarWidth:"none"},tab:n=>({padding:"10px 16px",background:"none",border:"none",borderBottom:n?"2px solid var(--accent, #89b4fa)":"2px solid transparent",color:n?"var(--accent, #89b4fa)":"var(--text-secondary, #a6adc8)",fontSize:13,fontWeight:n?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap",transition:"color 0.15s, border-color 0.15s",flexShrink:0}),tabStatus:(n,u)=>({width:6,height:6,borderRadius:"50%",background:u?"#f38ba8":n?"#a6e3a1":"#fab387",flexShrink:0}),body:{flex:1,overflow:"auto",padding:20},integrationHeader:{display:"flex",alignItems:"flex-start",gap:12,marginBottom:16},iconCircle:{width:44,height:44,borderRadius:10,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,flexShrink:0},integrationMeta:{flex:1},integrationName:{fontSize:15,fontWeight:600,color:"var(--text-primary, #cdd6f4)",marginBottom:4,display:"flex",alignItems:"center",gap:8},description:{fontSize:13,color:"var(--text-secondary, #a6adc8)",lineHeight:1.5},statusBadge:(n,u)=>({display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600,background:u?"rgba(243, 139, 168, 0.15)":n?"rgba(166, 227, 161, 0.15)":"rgba(250, 179, 135, 0.15)",color:u?"#f38ba8":n?"#a6e3a1":"#fab387"}),section:{marginTop:16,padding:12,borderRadius:8,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)"},sectionTitle:{fontSize:12,fontWeight:600,color:"var(--text-secondary, #a6adc8)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:8},requirementList:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},requirementItem:{fontSize:12,color:"var(--text-secondary, #a6adc8)",display:"flex",alignItems:"center",gap:6},formSection:{marginTop:16},formSectionTitle:{fontSize:12,fontWeight:600,color:"var(--text-secondary, #a6adc8)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:12}};function O({integration:n,onSave:u,onCancel:x}){const[p,I]=d.useState({...n.values}),[b,h]=d.useState({}),[f,C]=d.useState(!1),[m,v]=d.useState(!1);d.useEffect(()=>{I({...n.values}),h({}),v(!1)},[n.id]);const y=(r,l)=>{I(o=>({...o,[r]:l})),h(o=>{const i={...o};return delete i[r],i}),v(!1)},k=async r=>{r.preventDefault();const l={};for(const o of n.schema)if(o.required&&!p[o.key]&&p[o.key]!==0&&p[o.key]!==!1&&(l[o.key]=`${o.label} is required`),o.validate){const i=o.validate(p[o.key]);i&&(l[o.key]=i)}if(Object.keys(l).length>0){h(l);return}C(!0);try{await u(p),v(!0),setTimeout(()=>v(!1),3e3)}catch(o){h({_form:String(o)})}finally{C(!1)}},S=new Map;for(const r of n.schema){const l=r.group||"";S.has(l)||S.set(l,[]),S.get(l).push(r)}const a={display:"flex",flexDirection:"column",gap:4,marginBottom:12},t={fontSize:13,fontWeight:500,color:"var(--text-primary, #cdd6f4)"},c={padding:"8px 10px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"var(--surface-0, #1e1e2e)",color:"var(--text-primary, #cdd6f4)",fontSize:13,outline:"none",width:"100%",boxSizing:"border-box"},g={fontSize:11,color:"var(--text-secondary, #a6adc8)"},j={fontSize:11,color:"#f38ba8"},_=r=>{var o;const l=p[r.key]??r.defaultValue??"";switch(r.type){case"boolean":return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--text-primary, #cdd6f4)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!l,onChange:i=>y(r.key,i.target.checked)}),r.label]});case"select":return e.jsxs("select",{style:c,value:String(l),onChange:i=>y(r.key,i.target.value),children:[e.jsx("option",{value:"",children:r.placeholder||"Select..."}),(o=r.options)==null?void 0:o.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]});case"textarea":return e.jsx("textarea",{style:{...c,resize:"vertical",minHeight:80},value:String(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value),rows:4});case"number":return e.jsx("input",{type:"number",style:c,value:l===""?"":Number(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value===""?"":Number(i.target.value))});case"password":return e.jsx("input",{type:"password",style:c,value:String(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value),autoComplete:"off"});default:return e.jsx("input",{type:r.type,style:c,value:String(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value)})}};return e.jsxs("form",{onSubmit:k,children:[b._form&&e.jsx("div",{style:{...j,marginBottom:12,padding:"8px 10px",borderRadius:6,background:"rgba(243, 139, 168, 0.1)"},children:b._form}),Array.from(S.entries()).map(([r,l])=>e.jsxs("div",{children:[r&&e.jsx("div",{style:{...s.sectionTitle,marginTop:16,marginBottom:8},children:r}),l.map(o=>e.jsxs("div",{style:a,children:[o.type!=="boolean"&&e.jsxs("label",{style:t,children:[o.label,o.required&&e.jsx("span",{style:{color:"#f38ba8",marginLeft:2},children:"*"})]}),_(o),o.description&&e.jsx("span",{style:g,children:o.description}),b[o.key]&&e.jsx("span",{style:j,children:b[o.key]})]},o.key))]},r||"_default")),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,paddingTop:12,borderTop:"1px solid var(--border, #313244)"},children:[e.jsx("button",{type:"button",onClick:x,style:{padding:"8px 16px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"none",color:"var(--text-secondary, #a6adc8)",fontSize:13,cursor:"pointer"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:f,style:{padding:"8px 16px",borderRadius:6,border:"none",background:m?"#a6e3a1":"var(--accent, #89b4fa)",color:"#1e1e2e",fontSize:13,fontWeight:600,cursor:f?"wait":"pointer",opacity:f?.7:1},children:f?"Saving...":m?"Saved":"Save Configuration"})]})]})}function M({isOpen:n,onClose:u,initialTab:x}){const[p,I]=d.useState([]),[b,h]=d.useState(x||null),[f,C]=d.useState(!0),[m,v]=d.useState(null),y=d.useRef(x||null),k=d.useCallback(async()=>{try{const t=await R(w("/api/integrations"));if(!t.ok)throw new Error(`HTTP ${t.status}`);const c=await t.json();I(c),v(null),h(g=>{const j=g||x||(c.length>0?c[0].id:null);return y.current=j,j})}catch(t){v(`Failed to load integrations: ${t}`)}finally{C(!1)}},[x]);d.useEffect(()=>{n&&(C(!0),k(),x&&h(x))},[n,x]);const S=d.useCallback(async(t,c)=>{const g=await R(w(`/api/integrations/${t}/config`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!g.ok){const j=await g.json().catch(()=>({}));throw new Error(j.error||`HTTP ${g.status}`)}await k()},[k]);if(!n)return null;const a=p.find(t=>t.id===b);return e.jsx("div",{style:s.overlay,onClick:u,children:e.jsxs("div",{style:s.modal,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:s.header,children:[e.jsxs("div",{style:s.headerTitle,children:[e.jsx("span",{children:"🔌"}),e.jsx("span",{children:"Integrations"})]}),e.jsx("button",{style:s.closeBtn,onClick:u,title:"Close",children:"×"})]}),f&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-secondary, #a6adc8)"},children:"Loading integrations..."}),m&&e.jsxs("div",{style:{padding:20,textAlign:"center"},children:[e.jsx("div",{style:{color:"#f38ba8",marginBottom:8},children:m}),e.jsx("button",{onClick:k,style:{padding:"6px 12px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"none",color:"var(--text-primary, #cdd6f4)",cursor:"pointer",fontSize:13},children:"Retry"})]}),!f&&!m&&p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:s.tabs,children:p.map(t=>e.jsxs("button",{style:s.tab(b===t.id),onClick:()=>h(t.id),children:[e.jsx("span",{children:A[t.id]||"🔌"}),e.jsx("span",{children:t.name}),e.jsx("span",{style:s.tabStatus(t.status.connected,!!t.status.error)})]},t.id))}),e.jsx("div",{style:s.body,children:a&&e.jsxs("div",{children:[e.jsxs("div",{style:s.integrationHeader,children:[e.jsx("div",{style:s.iconCircle,children:A[a.id]||"🔌"}),e.jsxs("div",{style:s.integrationMeta,children:[e.jsxs("div",{style:s.integrationName,children:[a.name,e.jsx("span",{style:s.statusBadge(a.status.connected,!!a.status.error),children:a.status.needsReauth?"⚠ Token Expired — Reconnect":a.status.error?"✗ Error":a.status.connected?"✓ Connected":"⚠ Not Configured"}),a.id==="slack"&&(()=>{var g;const t=((g=a.values)==null?void 0:g.currentMode)||"none";if(t==="none")return null;const c=t==="polling"?"Polling":"Socket";return e.jsx("span",{style:{marginLeft:8,padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:500,background:"rgba(137, 180, 250, 0.15)",color:"#89b4fa",border:"1px solid rgba(137, 180, 250, 0.3)"},title:t==="polling"?"Web API polling (xoxp- user token)":"Real-time Socket Mode (xoxb- bot token)",children:c})})()]}),e.jsx("div",{style:s.description,children:B[a.id]||a.description})]})]}),a.status.error&&e.jsxs("div",{style:{...s.section,borderColor:"rgba(243, 139, 168, 0.3)",background:"rgba(243, 139, 168, 0.05)"},children:[e.jsx("div",{style:{...s.sectionTitle,color:"#f38ba8"},children:"Error"}),e.jsx("div",{style:{fontSize:12,color:"#f38ba8"},children:a.status.error})]}),E[a.id]&&e.jsxs("div",{style:s.section,children:[e.jsx("div",{style:s.sectionTitle,children:"Requirements"}),e.jsx("ul",{style:s.requirementList,children:E[a.id].map((t,c)=>e.jsxs("li",{style:s.requirementItem,children:[e.jsx("span",{style:{color:"var(--accent, #89b4fa)"},children:"•"}),t]},c))})]}),e.jsxs("div",{style:s.formSection,children:[e.jsx("div",{style:s.formSectionTitle,children:"Configuration"}),a.customComponent&&z[a.customComponent]?e.jsx(d.Suspense,{fallback:e.jsx("div",{style:{color:"var(--text-secondary)",fontSize:13},children:"Loading..."}),children:P.createElement(z[a.customComponent],{key:a.id,integration:a,onSave:t=>S(a.id,t),onCancel:u})}):e.jsx(O,{integration:a,onSave:t=>S(a.id,t),onCancel:u})]})]})})]}),!f&&!m&&p.length===0&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-secondary, #a6adc8)"},children:"No integrations available."})]})})}export{M as IntegrationsPanel};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GmailOAuthSetup-waw2142C.js","assets/main-Dk3qq80S.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-DYBBrXTx.js","assets/main-B2ZLroL1.css","assets/GoogleOAuthSetup-Bo59grtp.js","assets/SlackMultiInstanceSetup-YFYeZ94t.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as d,c as R,d as w,j as e,U as P,a1 as T}from"./main-Dk3qq80S.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";const z={"gmail-oauth":d.lazy(()=>T(()=>import("./GmailOAuthSetup-waw2142C.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.GmailOAuthSetup}))),"google-oauth":d.lazy(()=>T(()=>import("./GoogleOAuthSetup-Bo59grtp.js"),__vite__mapDeps([5,1,2,3,4])).then(n=>({default:n.GoogleOAuthSetup}))),"slack-multi-instance":d.lazy(()=>T(()=>import("./SlackMultiInstanceSetup-YFYeZ94t.js"),__vite__mapDeps([6,1,2,3,4])).then(n=>({default:n.SlackMultiInstanceSetup})))},A={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅","google-drive":"📁",docx:"📄"},B={gmail:"Send and receive emails through Gmail. Supports OAuth 2.0 authentication for secure access to your inbox.",slack:"Connect to Slack workspaces. Send messages, receive notifications, and integrate with channels.",jira:"Manage Jira issues and projects. Create tickets, track progress, and handle service desk requests.","google-calendar":"Access Google Calendar events. Create, update, and monitor calendar entries.","google-drive":"Read, create, and edit files in Google Drive. Search and manage folders.",docx:"Generate and manipulate DOCX documents. Create reports, templates, and formatted documents."},E={gmail:["Google Cloud Console project","OAuth 2.0 credentials (Client ID & Secret)","Gmail API enabled"],slack:["Bot token (xoxb-) with App-Level Token for real-time Socket Mode, OR User token (xoxp-) for polling mode (~30-60s lag, no Slack app config needed)","For Socket Mode: enable Socket Mode + Event Subscriptions; subscribe to bot events message.channels, message.groups, message.im","Required scopes: channels:history, channels:read, chat:write, groups:history, groups:read, im:history, im:read, users:read","Polling mode (xoxp-) mirrors all channels/groups/DMs the user is a member of — supports xoxp- user tokens that cannot use Socket Mode"],jira:["Jira Cloud instance URL","API Token (from Atlassian account)","Account email address"],"google-calendar":["Google Cloud Console project","OAuth 2.0 credentials","Calendar API enabled"],"google-drive":["Google Cloud Console project","OAuth 2.0 credentials (Client ID & Secret)","Google Drive API enabled"],docx:["No external credentials required","Templates directory (optional)"]},s={overlay:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,backdropFilter:"blur(4px)",animation:"fadeIn 0.15s ease-out"},modal:{background:"var(--surface-0, #1e1e2e)",borderRadius:12,border:"1px solid var(--border, #313244)",width:"90vw",maxWidth:720,maxHeight:"85vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.5)",animation:"slideUp 0.2s ease-out"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)"},headerTitle:{fontSize:16,fontWeight:600,color:"var(--text-primary, #cdd6f4)",display:"flex",alignItems:"center",gap:8},closeBtn:{background:"none",border:"none",color:"var(--text-secondary, #a6adc8)",fontSize:20,cursor:"pointer",padding:"4px 8px",borderRadius:6,lineHeight:1},tabs:{display:"flex",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)",overflowX:"auto",scrollbarWidth:"none"},tab:n=>({padding:"10px 16px",background:"none",border:"none",borderBottom:n?"2px solid var(--accent, #89b4fa)":"2px solid transparent",color:n?"var(--accent, #89b4fa)":"var(--text-secondary, #a6adc8)",fontSize:13,fontWeight:n?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap",transition:"color 0.15s, border-color 0.15s",flexShrink:0}),tabStatus:(n,u)=>({width:6,height:6,borderRadius:"50%",background:u?"#f38ba8":n?"#a6e3a1":"#fab387",flexShrink:0}),body:{flex:1,overflow:"auto",padding:20},integrationHeader:{display:"flex",alignItems:"flex-start",gap:12,marginBottom:16},iconCircle:{width:44,height:44,borderRadius:10,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,flexShrink:0},integrationMeta:{flex:1},integrationName:{fontSize:15,fontWeight:600,color:"var(--text-primary, #cdd6f4)",marginBottom:4,display:"flex",alignItems:"center",gap:8},description:{fontSize:13,color:"var(--text-secondary, #a6adc8)",lineHeight:1.5},statusBadge:(n,u)=>({display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600,background:u?"rgba(243, 139, 168, 0.15)":n?"rgba(166, 227, 161, 0.15)":"rgba(250, 179, 135, 0.15)",color:u?"#f38ba8":n?"#a6e3a1":"#fab387"}),section:{marginTop:16,padding:12,borderRadius:8,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)"},sectionTitle:{fontSize:12,fontWeight:600,color:"var(--text-secondary, #a6adc8)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:8},requirementList:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},requirementItem:{fontSize:12,color:"var(--text-secondary, #a6adc8)",display:"flex",alignItems:"center",gap:6},formSection:{marginTop:16},formSectionTitle:{fontSize:12,fontWeight:600,color:"var(--text-secondary, #a6adc8)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:12}};function O({integration:n,onSave:u,onCancel:x}){const[p,I]=d.useState({...n.values}),[b,h]=d.useState({}),[f,C]=d.useState(!1),[m,v]=d.useState(!1);d.useEffect(()=>{I({...n.values}),h({}),v(!1)},[n.id]);const y=(r,l)=>{I(o=>({...o,[r]:l})),h(o=>{const i={...o};return delete i[r],i}),v(!1)},k=async r=>{r.preventDefault();const l={};for(const o of n.schema)if(o.required&&!p[o.key]&&p[o.key]!==0&&p[o.key]!==!1&&(l[o.key]=`${o.label} is required`),o.validate){const i=o.validate(p[o.key]);i&&(l[o.key]=i)}if(Object.keys(l).length>0){h(l);return}C(!0);try{await u(p),v(!0),setTimeout(()=>v(!1),3e3)}catch(o){h({_form:String(o)})}finally{C(!1)}},S=new Map;for(const r of n.schema){const l=r.group||"";S.has(l)||S.set(l,[]),S.get(l).push(r)}const a={display:"flex",flexDirection:"column",gap:4,marginBottom:12},t={fontSize:13,fontWeight:500,color:"var(--text-primary, #cdd6f4)"},c={padding:"8px 10px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"var(--surface-0, #1e1e2e)",color:"var(--text-primary, #cdd6f4)",fontSize:13,outline:"none",width:"100%",boxSizing:"border-box"},g={fontSize:11,color:"var(--text-secondary, #a6adc8)"},j={fontSize:11,color:"#f38ba8"},_=r=>{var o;const l=p[r.key]??r.defaultValue??"";switch(r.type){case"boolean":return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--text-primary, #cdd6f4)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!l,onChange:i=>y(r.key,i.target.checked)}),r.label]});case"select":return e.jsxs("select",{style:c,value:String(l),onChange:i=>y(r.key,i.target.value),children:[e.jsx("option",{value:"",children:r.placeholder||"Select..."}),(o=r.options)==null?void 0:o.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]});case"textarea":return e.jsx("textarea",{style:{...c,resize:"vertical",minHeight:80},value:String(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value),rows:4});case"number":return e.jsx("input",{type:"number",style:c,value:l===""?"":Number(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value===""?"":Number(i.target.value))});case"password":return e.jsx("input",{type:"password",style:c,value:String(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value),autoComplete:"off"});default:return e.jsx("input",{type:r.type,style:c,value:String(l),placeholder:r.placeholder,onChange:i=>y(r.key,i.target.value)})}};return e.jsxs("form",{onSubmit:k,children:[b._form&&e.jsx("div",{style:{...j,marginBottom:12,padding:"8px 10px",borderRadius:6,background:"rgba(243, 139, 168, 0.1)"},children:b._form}),Array.from(S.entries()).map(([r,l])=>e.jsxs("div",{children:[r&&e.jsx("div",{style:{...s.sectionTitle,marginTop:16,marginBottom:8},children:r}),l.map(o=>e.jsxs("div",{style:a,children:[o.type!=="boolean"&&e.jsxs("label",{style:t,children:[o.label,o.required&&e.jsx("span",{style:{color:"#f38ba8",marginLeft:2},children:"*"})]}),_(o),o.description&&e.jsx("span",{style:g,children:o.description}),b[o.key]&&e.jsx("span",{style:j,children:b[o.key]})]},o.key))]},r||"_default")),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,paddingTop:12,borderTop:"1px solid var(--border, #313244)"},children:[e.jsx("button",{type:"button",onClick:x,style:{padding:"8px 16px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"none",color:"var(--text-secondary, #a6adc8)",fontSize:13,cursor:"pointer"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:f,style:{padding:"8px 16px",borderRadius:6,border:"none",background:m?"#a6e3a1":"var(--accent, #89b4fa)",color:"#1e1e2e",fontSize:13,fontWeight:600,cursor:f?"wait":"pointer",opacity:f?.7:1},children:f?"Saving...":m?"Saved":"Save Configuration"})]})]})}function M({isOpen:n,onClose:u,initialTab:x}){const[p,I]=d.useState([]),[b,h]=d.useState(x||null),[f,C]=d.useState(!0),[m,v]=d.useState(null),y=d.useRef(x||null),k=d.useCallback(async()=>{try{const t=await R(w("/api/integrations"));if(!t.ok)throw new Error(`HTTP ${t.status}`);const c=await t.json();I(c),v(null),h(g=>{const j=g||x||(c.length>0?c[0].id:null);return y.current=j,j})}catch(t){v(`Failed to load integrations: ${t}`)}finally{C(!1)}},[x]);d.useEffect(()=>{n&&(C(!0),k(),x&&h(x))},[n,x]);const S=d.useCallback(async(t,c)=>{const g=await R(w(`/api/integrations/${t}/config`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!g.ok){const j=await g.json().catch(()=>({}));throw new Error(j.error||`HTTP ${g.status}`)}await k()},[k]);if(!n)return null;const a=p.find(t=>t.id===b);return e.jsx("div",{style:s.overlay,onClick:u,children:e.jsxs("div",{style:s.modal,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:s.header,children:[e.jsxs("div",{style:s.headerTitle,children:[e.jsx("span",{children:"🔌"}),e.jsx("span",{children:"Integrations"})]}),e.jsx("button",{style:s.closeBtn,onClick:u,title:"Close",children:"×"})]}),f&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-secondary, #a6adc8)"},children:"Loading integrations..."}),m&&e.jsxs("div",{style:{padding:20,textAlign:"center"},children:[e.jsx("div",{style:{color:"#f38ba8",marginBottom:8},children:m}),e.jsx("button",{onClick:k,style:{padding:"6px 12px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"none",color:"var(--text-primary, #cdd6f4)",cursor:"pointer",fontSize:13},children:"Retry"})]}),!f&&!m&&p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:s.tabs,children:p.map(t=>e.jsxs("button",{style:s.tab(b===t.id),onClick:()=>h(t.id),children:[e.jsx("span",{children:A[t.id]||"🔌"}),e.jsx("span",{children:t.name}),e.jsx("span",{style:s.tabStatus(t.status.connected,!!t.status.error)})]},t.id))}),e.jsx("div",{style:s.body,children:a&&e.jsxs("div",{children:[e.jsxs("div",{style:s.integrationHeader,children:[e.jsx("div",{style:s.iconCircle,children:A[a.id]||"🔌"}),e.jsxs("div",{style:s.integrationMeta,children:[e.jsxs("div",{style:s.integrationName,children:[a.name,e.jsx("span",{style:s.statusBadge(a.status.connected,!!a.status.error),children:a.status.needsReauth?"⚠ Token Expired — Reconnect":a.status.error?"✗ Error":a.status.connected?"✓ Connected":"⚠ Not Configured"}),a.id==="slack"&&(()=>{var g;const t=((g=a.values)==null?void 0:g.currentMode)||"none";if(t==="none")return null;const c=t==="polling"?"Polling":"Socket";return e.jsx("span",{style:{marginLeft:8,padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:500,background:"rgba(137, 180, 250, 0.15)",color:"#89b4fa",border:"1px solid rgba(137, 180, 250, 0.3)"},title:t==="polling"?"Web API polling (xoxp- user token)":"Real-time Socket Mode (xoxb- bot token)",children:c})})()]}),e.jsx("div",{style:s.description,children:B[a.id]||a.description})]})]}),a.status.error&&e.jsxs("div",{style:{...s.section,borderColor:"rgba(243, 139, 168, 0.3)",background:"rgba(243, 139, 168, 0.05)"},children:[e.jsx("div",{style:{...s.sectionTitle,color:"#f38ba8"},children:"Error"}),e.jsx("div",{style:{fontSize:12,color:"#f38ba8"},children:a.status.error})]}),E[a.id]&&e.jsxs("div",{style:s.section,children:[e.jsx("div",{style:s.sectionTitle,children:"Requirements"}),e.jsx("ul",{style:s.requirementList,children:E[a.id].map((t,c)=>e.jsxs("li",{style:s.requirementItem,children:[e.jsx("span",{style:{color:"var(--accent, #89b4fa)"},children:"•"}),t]},c))})]}),e.jsxs("div",{style:s.formSection,children:[e.jsx("div",{style:s.formSectionTitle,children:"Configuration"}),a.customComponent&&z[a.customComponent]?e.jsx(d.Suspense,{fallback:e.jsx("div",{style:{color:"var(--text-secondary)",fontSize:13},children:"Loading..."}),children:P.createElement(z[a.customComponent],{key:a.id,integration:a,onSave:t=>S(a.id,t),onCancel:u})}):e.jsx(O,{integration:a,onSave:t=>S(a.id,t),onCancel:u})]})]})})]}),!f&&!m&&p.length===0&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-secondary, #a6adc8)"},children:"No integrations available."})]})})}export{M as IntegrationsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as me,r as l,g as ge,j as e,I as xe,h as fe}from"./main-
|
|
1
|
+
import{u as me,r as l,g as ge,j as e,I as xe,h as fe}from"./main-Dk3qq80S.js";function je({isOpen:E,onClose:L,onMinimize:P,title:B,icon:U,lines:c,isStreaming:F,onClear:J,emptyMessage:V,streamingIndicatorLabel:X,headerInfo:Y,isLoading:W,extraToolbar:Z,extraFooter:O,modalClassName:ee}){const{t:a}=me(["terminal","common"]),[u,$]=l.useState(""),[h,w]=l.useState(!1),[f,S]=l.useState(!1),[M,I]=l.useState(""),[k,p]=l.useState(!0),[R,te]=l.useState(!0),[se,Q]=l.useState(null),[r,le]=l.useState([]),[m,j]=l.useState(0),[v,ne]=l.useState(!1),[T,re]=l.useState(5),[_,C]=l.useState(null),[y,ae]=l.useState(!0),o=l.useRef(null),D=l.useRef(null),A=l.useRef(null),H=l.useRef(!1),q=l.useRef(0),K=l.useMemo(()=>c.map(t=>t.text),[c]),b=l.useMemo(()=>{if(!u)return C(null),null;try{const t=v?u:u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(t,"gi");return C(null),s}catch(t){return C(t.message),null}},[u,v]),N=l.useMemo(()=>{if(!b)return[];const t=[];for(let s=0;s<K.length;s++)b.test(K[s])&&t.push(s),b.lastIndex=0;return t},[K,b]);l.useEffect(()=>{le(N),m>=N.length&&j(Math.max(0,N.length-1))},[N]);const oe=l.useMemo(()=>{const t=c.map((i,x)=>({entry:i,originalIndex:x}));if(!u||!b||y)return t;if(N.length===0)return[];const s=new Set;for(const i of N){const x=Math.max(0,i-T),de=Math.min(c.length-1,i+T);for(let G=x;G<=de;G++)s.add(G)}const n=Array.from(s).sort((i,x)=>i-x),d=[];for(let i=0;i<n.length;i++){const x=n[i];i>0&&x-n[i-1]>1&&d.push({entry:{text:"",lineNumber:-1},originalIndex:-1,isSeparator:!0}),d.push({entry:c[x],originalIndex:x})}return d},[c,u,b,N,T,y]);l.useEffect(()=>{k&&o.current&&c.length>q.current&&(H.current=!0,requestAnimationFrame(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight),setTimeout(()=>{H.current=!1},50)})),q.current=c.length},[c.length,k]),l.useEffect(()=>{h&&D.current&&D.current.focus()},[h]),l.useEffect(()=>{f&&A.current&&A.current.focus()},[f]);const g=l.useCallback(t=>{if(!o.current)return;const n=t*18;o.current.scrollTop=n-100,Q(t),setTimeout(()=>Q(null),2e3)},[]);l.useEffect(()=>{if(!E)return;const t=s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),h?w(!1):f?S(!1):L();return}if(s.key==="/"&&!h&&!f&&(s.preventDefault(),w(!0)),s.key==="g"&&s.ctrlKey&&(s.preventDefault(),S(!0)),s.key==="End"&&s.ctrlKey&&o.current&&(o.current.scrollTop=o.current.scrollHeight),s.key==="Home"&&s.ctrlKey&&o.current&&(o.current.scrollTop=0),(s.key==="F3"||s.key==="Enter"&&h)&&r.length>0)if(s.preventDefault(),s.shiftKey){const n=(m-1+r.length)%r.length;j(n),g(r[n])}else{const n=(m+1)%r.length;j(n),g(r[n])}if(!h&&!f&&r.length>0){if(s.key==="n"&&!s.ctrlKey){s.preventDefault();const n=(m+1)%r.length;j(n),g(r[n])}else if(s.key==="N"){s.preventDefault();const n=(m-1+r.length)%r.length;j(n),g(r[n])}}!h&&!f&&o.current&&(s.key==="j"?(s.preventDefault(),o.current.scrollTop+=60,p(!1)):s.key==="k"?(s.preventDefault(),o.current.scrollTop-=60,p(!1)):s.key==="G"&&!s.ctrlKey?(s.preventDefault(),o.current.scrollTop=o.current.scrollHeight,p(!0)):s.key==="g"&&!s.ctrlKey&&(s.preventDefault(),o.current.scrollTop=0,p(!1)))};return window.addEventListener("keydown",t,{capture:!0}),()=>window.removeEventListener("keydown",t,{capture:!0})},[E,h,f,r,m,L,g]);const z=l.useCallback(()=>{const t=parseInt(M,10);!isNaN(t)&&t>0&&t<=c.length&&(g(t-1),p(!1)),S(!1),I("")},[M,c.length,g]),ce=l.useCallback(()=>{if(H.current||!o.current)return;const{scrollTop:t,scrollHeight:s,clientHeight:n}=o.current,d=s-t-n<50;!d&&k&&p(!1),d&&!k&&p(!0)},[k]),ie=l.useCallback(t=>{if(!u||!b)return t;const s=v?u:u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");try{const n=new RegExp(`(${s})`,"gi");return t.replace(n,'<mark class="search-highlight">$1</mark>')}catch{return t}},[u,b,v]),{handleMouseDown:ue,handleClick:he}=ge(L);return E?e.jsx("div",{className:"pm2-logs-modal-overlay",onMouseDown:ue,onClick:he,children:e.jsxs("div",{className:`pm2-logs-modal ${ee||""}`,children:[e.jsxs("div",{className:"pm2-logs-modal-header",children:[e.jsxs("div",{className:"header-left",children:[e.jsx("span",{className:"modal-icon",children:U}),e.jsx("span",{className:"modal-title",title:B,children:B}),F&&e.jsxs("span",{className:"streaming-indicator",title:"Live streaming",children:[e.jsx("span",{className:"pulse"}),X||a("terminal:logs.live")]}),Y]}),e.jsxs("div",{className:"header-right",children:[e.jsx("span",{className:"line-count",children:a("terminal:logs.lines",{count:c.length})}),P&&e.jsx("button",{className:"modal-close",onClick:P,title:"Minimize — dock below the terminal input",children:e.jsx(xe,{name:"arrow-down",size:14})}),e.jsx("button",{className:"modal-close",onClick:L,title:a("terminal:logs.closeEsc"),children:"×"})]})]}),e.jsxs("div",{className:"pm2-logs-modal-toolbar",children:[e.jsxs("div",{className:"toolbar-left",children:[e.jsxs("button",{className:`toolbar-btn ${h?"active":""}`,onClick:()=>w(!h),title:a("terminal:logs.searchShortcut"),children:["🔍 ",a("terminal:logs.search")]}),e.jsxs("button",{className:"toolbar-btn",onClick:()=>S(!0),title:a("terminal:logs.goToLineShortcut"),children:["⏬ ",a("terminal:logs.goToLine")]}),Z,e.jsxs("button",{className:`toolbar-btn ${R?"active":""}`,onClick:()=>te(!R),title:a("terminal:logs.toggleWrap"),children:["↩ ",a("terminal:logs.wrap")]}),e.jsxs("button",{className:`toolbar-btn ${k?"active":""}`,onClick:()=>p(!k),title:a("terminal:logs.autoScrollToBottom"),children:["↓ ",a("terminal:logs.auto")]})]}),e.jsx("div",{className:"toolbar-right",children:e.jsxs("button",{className:"toolbar-btn danger",onClick:J,title:a("terminal:logs.clear"),children:["🗑 ",a("terminal:logs.clear")]})})]}),h&&e.jsxs("div",{className:"pm2-logs-search-bar",children:[e.jsx("input",{ref:D,type:"text",placeholder:a(v?"terminal:logs.regexPlaceholder":"terminal:logs.searchPlaceholder"),value:u,onChange:t=>{$(t.target.value),j(0)},onKeyDown:t=>{t.key==="Escape"&&(w(!1),$(""),C(null))}}),e.jsx("button",{className:`toolbar-btn small ${v?"active":""}`,onClick:()=>ne(!v),title:"Toggle regex mode",children:".*"}),e.jsx("button",{className:`toolbar-btn small ${y?"active":""}`,onClick:()=>ae(!y),title:y?"Show all lines (highlight matches)":"Show only context around matches",children:y?"All":"Ctx"}),e.jsxs("div",{className:`context-control ${y?"hidden":""}`,title:"Lines of context around matches",children:[e.jsx("label",{children:"±"}),e.jsx("input",{type:"number",min:"0",max:"100",value:T,onChange:t=>re(Math.max(0,parseInt(t.target.value)||0)),className:"context-input"})]}),e.jsx("button",{className:"toolbar-btn small",onClick:()=>{if(r.length===0)return;const t=(m-1+r.length)%r.length;j(t),g(r[t])},disabled:r.length===0,title:"Previous match (Shift+F3)",children:"▲"}),e.jsx("button",{className:"toolbar-btn small",onClick:()=>{if(r.length===0)return;const t=(m+1)%r.length;j(t),g(r[t])},disabled:r.length===0,title:"Next match (F3)",children:"▼"}),u&&e.jsx("span",{className:"match-count",children:_?e.jsx("span",{className:"regex-error",title:_,children:a("terminal:logs.invalidRegex")}):r.length>0?`${m+1}/${r.length}`:a("terminal:logs.noMatches")}),e.jsx("button",{className:"search-close",onClick:()=>{w(!1),$(""),C(null)},children:"×"})]}),f&&e.jsxs("div",{className:"pm2-logs-goto-line",children:[e.jsxs("label",{children:[a("terminal:logs.goToLineLabel"),":"]}),e.jsx("input",{ref:A,type:"number",min:"1",max:c.length,placeholder:`1-${c.length}`,value:M,onChange:t=>I(t.target.value),onKeyDown:t=>{t.key==="Enter"?z():t.key==="Escape"&&(S(!1),I(""))}}),e.jsx("button",{onClick:z,children:a("terminal:logs.go")}),e.jsx("button",{onClick:()=>S(!1),children:a("common:buttons.cancel")})]}),e.jsx("div",{ref:o,className:`pm2-logs-content ${R?"wrap":"nowrap"}`,onScroll:ce,children:c.length===0?e.jsx("div",{className:"logs-empty",children:W||F?e.jsxs("div",{className:"logs-loading",children:[e.jsx("span",{className:"logs-loading-spinner","aria-hidden":"true"}),e.jsx("span",{children:V||a(W?"terminal:logs.loadingLogs":"terminal:logs.waitingForLogs")})]}):e.jsx("span",{children:V||a("terminal:logs.noLogs")})}):e.jsx("div",{className:"logs-lines",children:oe.map((t,s)=>{if("isSeparator"in t&&t.isSeparator)return e.jsxs("div",{className:"log-separator",children:[e.jsx("span",{className:"separator-line"}),e.jsx("span",{className:"separator-label",children:"…"}),e.jsx("span",{className:"separator-line"})]},`sep-${s}`);const{entry:n,originalIndex:d}=t,i=u&&N.includes(d);return e.jsxs("div",{className:`log-line ${se===d?"highlighted":""} ${r[m]===d?"current-match":""} ${i?"match-line":""} ${n.isError?"error-line":""}`,children:[e.jsx("span",{className:"line-number",children:n.lineNumber}),n.sourceLabel&&e.jsxs("span",{className:"boss-log-source",style:{color:n.sourceColor},children:["[",n.sourceLabel,"]"]}),e.jsx("span",{className:"line-content",dangerouslySetInnerHTML:{__html:ie(fe(n.text))}})]},d)})})}),e.jsxs("div",{className:"pm2-logs-modal-footer",children:[e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"j"}),"/",e.jsx("kbd",{children:"k"})," Scroll"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"g"}),"/",e.jsx("kbd",{children:"G"})," Top/Bottom"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"/"})," Search"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"n"}),"/",e.jsx("kbd",{children:"N"})," Next/Prev match"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"Ctrl+G"})," Go to line"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"Esc"})," Close"]}),O]})]})}):null}export{je as L};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as g,c as D,d as O,j as e,I as H,s as se}from"./main-Bb9H5jmt.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-CBPuP1jE.js";const ae=[{id:"triggers",label:"Triggers",icon:"bolt"},{id:"workflows",label:"Workflows",icon:"gear"},{id:"instances",label:"Instances",icon:"refresh"},{id:"messages",label:"Messages",icon:"chat"},{id:"stats",label:"Stats",icon:"dashboard"}],ne={trigger:"#89b4fa",slack:"#cba6f7",email:"#f9e2af",calendar:"#a6e3a1",document:"#fab387",jira:"#89dceb",workflow:"#f38ba8",system:"#6c7086",step:"#f38ba8",variable_change:"#cba6f7",approval:"#a6e3a1",audit:"#6c7086"},re={trigger:"Trigger",slack:"Slack",email:"Email",calendar:"Calendar",document:"Document",jira:"Jira",workflow:"Workflow",system:"System",step:"Step",variable_change:"Variable",approval:"Approval",audit:"Audit"};function he({isOpen:r,onClose:s}){const[n,B]=g.useState("triggers"),[T,M]=g.useState([]),[y,x]=g.useState(!0),[_,j]=g.useState(null),[z,F]=g.useState("24h"),[R,$]=g.useState(""),[W,N]=g.useState(null),[m,p]=g.useState({}),[i,C]=g.useState(!1),[t,c]=g.useState(null),[d,b]=g.useState([]),l=g.useCallback(async()=>{if(!(n==="stats"||n==="instances")){x(!0);try{const o=Date.now(),h={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5,all:0},w=h[z]>0?String(o-h[z]):void 0;let k=[];if(n==="triggers"){const v=new URLSearchParams({limit:"200"});w&&v.set("since",w);const S=await D(O(`/api/events/triggers?${v}`));if(!S.ok){j(`HTTP ${S.status}`);return}k=((await S.json()).events||[]).map(E=>({type:"trigger",timestamp:E.firedAt,data:E}))}else if(n==="workflows"){const v=new URLSearchParams({limit:"200",category:"workflow"});w&&v.set("since",w);const S=await D(O(`/api/events/audit?${v}`));if(!S.ok){j(`HTTP ${S.status}`);return}k=((await S.json()).entries||[]).map(E=>({type:"workflow",timestamp:E.createdAt,data:E}))}else if(n==="messages"){const v=new URLSearchParams({limit:"200"}),S=new URLSearchParams({limit:"200"}),V=new URLSearchParams({limit:"200"});w&&(v.set("since",w),S.set("since",w));const[E,X,q]=await Promise.all([D(O(`/api/events/slack?${v}`)),D(O(`/api/events/email?${S}`)),D(O(`/api/events/approvals?${V}`))]);if(E.ok){const P=await E.json();for(const I of P.messages||[])k.push({type:"slack",timestamp:I.receivedAt,data:I})}if(X.ok){const P=await X.json();for(const I of P.messages||[])k.push({type:"email",timestamp:I.receivedAt,data:I})}if(q.ok){const P=await q.json();for(const I of P.events||[])k.push({type:"approval",timestamp:I.recordedAt,data:I})}k.sort((P,I)=>I.timestamp-P.timestamp)}M(k),j(null)}catch(o){j(`Failed to load events: ${o}`)}finally{x(!1)}}},[n,z]),f=g.useCallback(async()=>{x(!0);try{const[o,h]=await Promise.all([D(O("/api/events/stats")),D(O("/api/integrations"))]);if(o.ok&&c(await o.json()),h.ok){const w=await h.json();b(Array.isArray(w)?w:[])}j(null)}catch(o){j(`Failed to load stats: ${o}`)}finally{x(!1)}},[]);g.useEffect(()=>{r&&(n==="stats"?f():l())},[r,n,l,f]);const u=T.filter(o=>{if(!R)return!0;const h=R.toLowerCase();return JSON.stringify(o.data).toLowerCase().includes(h)});if(!r)return null;const A=d.filter(o=>o.status.connected).length;return e.jsx("div",{style:a.overlay,onClick:s,children:e.jsxs("div",{style:a.modal,onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:a.header,children:[e.jsxs("div",{style:a.headerTitle,children:[e.jsx(H,{name:"dashboard",size:16}),e.jsx("span",{children:"Monitoring & Logs"})]}),e.jsx("button",{style:a.closeBtn,onClick:s,title:"Close",children:"×"})]}),e.jsx("div",{style:a.tabs,children:ae.map(o=>e.jsxs("button",{style:a.tab(n===o.id),onClick:()=>{B(o.id),$(""),N(null)},children:[e.jsx(H,{name:o.icon,size:14}),e.jsx("span",{children:o.label})]},o.id))}),n!=="stats"&&n!=="instances"&&e.jsxs("div",{style:a.filters,children:[e.jsx("div",{style:{display:"flex",gap:4},children:["1h","6h","24h","7d","all"].map(o=>e.jsx("button",{style:{...a.timeBtn,background:z===o?"#89b4fa":"transparent",color:z===o?"#1e1e2e":"#a6adc8"},onClick:()=>F(o),children:o},o))}),e.jsx("input",{style:a.searchInput,placeholder:"Search events...",value:R,onChange:o=>$(o.target.value)}),e.jsx("button",{style:a.refreshBtn,onClick:l,children:"Refresh"})]}),e.jsx("div",{style:a.content,children:n==="stats"?e.jsx(ie,{loading:y,error:_,stats:t,integrations:d,connectedCount:A,onRefresh:f}):n==="instances"?e.jsx(de,{}):e.jsx(oe,{loading:y,error:_,entries:u,expandedId:W,matcherResults:m,loadingMatchers:i,onToggleExpand:async(o,h)=>{var w;if(W===o){N(null);return}if(N(o),!m[o]){C(!0);try{let k="";if((h==null?void 0:h.type)==="trigger"&&((w=h==null?void 0:h.data)!=null&&w.id))k=`/api/triggers/events/${h.data.id}/matchers`;else if(h&&["slack","email","approval"].includes(h.type)){const v=h.data,S=v.ts||v.messageId||v.email_id;S&&h.type&&(k=`/api/triggers/matchers/by-source/${h.type}/${encodeURIComponent(S)}`)}if(k){const v=await D(O(k));if(v.ok){const S=await v.json();p(V=>({...V,[o]:S.matchers||[]}))}}}catch(k){console.error("Failed to fetch matchers:",k)}finally{C(!1)}}}})}),n!=="stats"&&n!=="instances"&&e.jsx("div",{style:a.footer,children:e.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:[u.length," event",u.length!==1?"s":""," shown",R&&` (filtered from ${T.length})`]})})]})})}function oe({loading:r,error:s,entries:n,expandedId:B,matcherResults:T,loadingMatchers:M,onToggleExpand:y}){return r?e.jsx("div",{style:{color:"#a6adc8",padding:20},children:"Loading events..."}):s?e.jsx("div",{style:{color:"#f38ba8",padding:20},children:s}):n.length===0?e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No events found for the selected filters."}):e.jsx(e.Fragment,{children:n.map((x,_)=>{var W;const j=`${x.type}-${x.timestamp}-${_}`,z=B===j,F=ne[x.type]||"#6c7086",R=le(x),$=new Date(x.timestamp);return e.jsxs("div",{style:{...a.eventRow,borderLeft:`3px solid ${F}`,background:z?"rgba(137,180,250,0.05)":"transparent"},onClick:()=>y(j,x),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{...a.tag,background:`${F}22`,color:F},children:re[x.type]||x.type}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:12,flex:1},children:R}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:[$.toLocaleTimeString()," ",$.toLocaleDateString()]})]}),z&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{style:a.detail,children:JSON.stringify(x.data,null,2)}),T[j]&&e.jsxs("div",{style:{marginTop:12,borderTop:"1px solid #313244",paddingTop:12},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},children:x.type==="trigger"?"Matcher Results":"Trigger Evaluations"}),M?e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"Loading matchers..."}):((W=T[j])==null?void 0:W.length)===0?e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"No matchers evaluated"}):(()=>{const N=T[j];if(x.type!=="trigger"){const m=new Map;for(const p of N){const i=String(p.trigger_id||"unknown");m.has(i)||m.set(i,[]),m.get(i).push(p)}return Array.from(m.entries()).map(([p,i])=>{var C;return e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs("div",{style:{color:"#cdd6f4",fontSize:11,fontWeight:500,marginBottom:6,paddingBottom:4,borderBottom:"1px solid #45475a"},children:["Trigger: ",String(((C=i[0])==null?void 0:C.trigger_name)||p)]}),i.map((t,c)=>{const d=t.matched===1||t.matched===!0,b=d?"#a6e3a1":"#f38ba8",l=t.confidence??null,f=String(t.matcher_name||"unknown"),u=t.reason?String(t.reason):"";return e.jsxs("div",{style:{display:"flex",gap:8,padding:"6px 10px",background:"#313244",borderRadius:4,marginBottom:4,fontSize:11},children:[e.jsx("span",{style:{color:b,fontWeight:600,minWidth:50},children:d?e.jsx(H,{name:"check",size:12}):e.jsx(H,{name:"cross",size:12})}),e.jsx("span",{style:{color:"#cdd6f4",flex:1},children:f}),l!==null&&e.jsxs("span",{style:{color:"#a6adc8"},children:["(",(l*100).toFixed(0),"%)"]}),u&&e.jsx("span",{style:{color:"#6c7086",fontSize:10},children:u})]},c)})]},p)})}else return N.map((m,p)=>{const i=m.matched===1||m.matched===!0,C=i?"#a6e3a1":"#f38ba8",t=m.confidence??null,c=String(m.matcher_name||"unknown"),d=m.reason?String(m.reason):"";return e.jsxs("div",{style:{display:"flex",gap:8,padding:"6px 10px",background:"#313244",borderRadius:4,marginBottom:4,fontSize:11},children:[e.jsx("span",{style:{color:C,fontWeight:600,minWidth:50},children:i?e.jsxs(e.Fragment,{children:[e.jsx(H,{name:"check",size:12})," MATCH"]}):e.jsxs(e.Fragment,{children:[e.jsx(H,{name:"cross",size:12})," FAIL"]})}),e.jsx("span",{style:{color:"#cdd6f4",flex:1},children:c}),t!==null&&e.jsxs("span",{style:{color:"#a6adc8"},children:["(",(t*100).toFixed(0),"%)"]}),d&&e.jsx("span",{style:{color:"#6c7086",fontSize:10},children:d})]},p)})})()]})]})]},j)})})}function ie({loading:r,error:s,stats:n,integrations:B,connectedCount:T,onRefresh:M}){return r?e.jsx("div",{style:{color:"#a6adc8",padding:20},children:"Loading stats..."}):s?e.jsx("div",{style:{color:"#f38ba8",padding:20},children:s}):e.jsxs("div",{style:{padding:20},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:16},children:e.jsx("button",{style:a.refreshBtn,onClick:M,children:"Refresh"})}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:a.section,children:[e.jsx("h3",{style:a.sectionTitle,children:"Workflows"}),e.jsxs("div",{style:a.grid,children:[e.jsx(U,{label:"Active",value:n.activeWorkflows,color:"#89b4fa"}),e.jsx(U,{label:"Completed",value:n.completedWorkflows,color:"#a6e3a1"}),e.jsx(U,{label:"Failed",value:n.failedWorkflows,color:"#f38ba8"})]})]}),e.jsxs("div",{style:a.section,children:[e.jsx("h3",{style:a.sectionTitle,children:"Events (Today)"}),e.jsxs("div",{style:a.grid,children:[e.jsx(U,{label:"Triggers Fired",value:n.triggersFiredToday,color:"#f9e2af"}),e.jsx(U,{label:"Slack Messages",value:n.slackMessageCount,color:"#cba6f7"}),e.jsx(U,{label:"Emails",value:n.emailCount,color:"#fab387"})]})]}),e.jsxs("div",{style:a.section,children:[e.jsxs("h3",{style:a.sectionTitle,children:["Integrations (",T,"/",B.length," connected)"]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[B.map(y=>e.jsxs("div",{style:a.integrationRow,children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:13},children:y.name}),e.jsx("span",{style:{...a.statusBadge,background:y.status.connected?"rgba(166,227,161,0.15)":"rgba(108,112,134,0.15)",color:y.status.connected?"#a6e3a1":"#6c7086"},children:y.status.error?"Error":y.status.connected?"Connected":"Disconnected"})]},y.id)),B.length===0&&e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"No integrations configured"})]})]})]}),!n&&e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No stats available. The event store may not have any data yet."})]})}function U({label:r,value:s,color:n}){return e.jsxs("div",{style:a.card,children:[e.jsx("div",{style:{color:n,fontSize:28,fontWeight:700,lineHeight:1},children:s}),e.jsx("div",{style:{color:"#a6adc8",fontSize:11,marginTop:4},children:r})]})}function le(r){const s=r.data;switch(r.type){case"trigger":return`Trigger "${s.triggerName||s.triggerId}" ${s.status||"fired"}`;case"slack":return`${s.direction==="outbound"?"Sent":"Received"} in #${s.channelName||s.channelId}: ${K(s.text,60)}`;case"email":return`${s.direction==="outbound"?"Sent to":"From"} ${s.direction==="outbound"?s.toAddresses:s.fromAddress}: ${K(s.subject,50)}`;case"approval":return`${s.approved?"Approved":"Rejected"} by ${s.approverEmail}`;case"document":return`Generated "${s.outputFilename}" from template "${s.templateName}"`;case"calendar":return`Calendar event ${s.action}: "${s.summary}"`;case"jira":return`${s.ticketKey} ${s.action}: ${K(s.summary,50)}`;case"step":return`Workflow step: ${s.toStateName} (${s.status})`;case"variable_change":return`Variable "${s.variableName}" changed by ${s.changedBy}`;case"audit":return`[${(s.level||"info").toUpperCase()}] ${s.category}: ${s.action}`;default:return JSON.stringify(s).slice(0,80)}}function K(r,s){return r?r.length>s?r.slice(0,s)+"...":r:""}const G={running:"#a6e3a1",paused:"#f9e2af",completed:"#89b4fa",failed:"#f38ba8",cancelled:"#6c7086"},Q={action:"#89b4fa",wait:"#f9e2af",decision:"#cba6f7",end:"#6c7086"};let Y=null,Z,ee;function te(){const r=se.getState(),s=r.workflowDefinitions??new Map,n=r.workflowInstances??new Map;return Y&&Z===s&&ee===n||(Z=s,ee=n,Y={definitions:s,instances:n}),Y}function ce(){return g.useSyncExternalStore(r=>se.subscribe(r),te,te)}function de(){var C;const{definitions:r,instances:s}=ce(),[n,B]=g.useState("all"),[T,M]=g.useState("all"),[y,x]=g.useState(""),[_,j]=g.useState(null),[z,F]=g.useState(null),[R,$]=g.useState(null),W=g.useMemo(()=>Array.from(s.values()),[s]),N=g.useMemo(()=>Array.from(r.values()),[r]),m=g.useMemo(()=>W.filter(t=>{if(n!=="all"&&t.status!==n||T!=="all"&&t.workflowDefId!==T)return!1;if(y){const c=y.toLowerCase();return t.workflowName.toLowerCase().includes(c)||t.id.toLowerCase().includes(c)||JSON.stringify(t.variables).toLowerCase().includes(c)}return!0}).sort((t,c)=>c.updatedAt-t.updatedAt),[W,n,T,y]),p=_?s.get(_):null,i=R?s.get(R):null;if(i){const t=r.get(i.workflowDefId),c=t==null?void 0:t.states.find(f=>f.id===i.currentStateId),d=G[i.status]||"#6c7086",b={},l={};for(const[f,u]of Object.entries(i.variables))f.startsWith("wi_")?b[f]=u:l[f]=u;return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("button",{style:{...a.refreshBtn,fontSize:12},onClick:()=>$(null),children:"Back"}),e.jsxs("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:["Debug: ",i.workflowName]}),e.jsx("span",{style:{...a.tag,background:`${d}22`,color:d},children:i.status})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8,marginBottom:16},children:[e.jsx(L,{label:"ID",value:i.id}),e.jsx(L,{label:"Def ID",value:i.workflowDefId}),e.jsx(L,{label:"Current State",value:(c==null?void 0:c.name)||i.currentStateId}),e.jsx(L,{label:"State Type",value:(c==null?void 0:c.type)||"unknown"}),e.jsx(L,{label:"Created",value:J(i.createdAt)}),e.jsx(L,{label:"Updated",value:J(i.updatedAt)}),i.completedAt&&e.jsx(L,{label:"Completed",value:J(i.completedAt)}),i.error&&e.jsx(L,{label:"Error",value:i.error,color:"#f38ba8"}),e.jsx(L,{label:"Steps",value:String(((C=i.history)==null?void 0:C.length)??0)})]}),Object.keys(l).length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"User Variables"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(l,null,2)})]}),Object.keys(b).length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Internal Variables (wi_*)"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(b,null,2)})]}),c&&c.transitions.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Available Transitions"}),c.transitions.map(f=>{var u;return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 10px",background:"#313244",borderRadius:4,marginBottom:4},children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:12},children:f.name}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10},children:[f.condition.type," → ",((u=t==null?void 0:t.states.find(A=>A.id===f.targetStateId))==null?void 0:u.name)||f.targetStateId]})]},f.id)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Raw JSON"}),e.jsx("pre",{style:{...a.detail,maxHeight:400},children:JSON.stringify(i,null,2)})]})]})}if(p){const t=r.get(p.workflowDefId),c=G[p.status]||"#6c7086";return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("button",{style:{...a.refreshBtn,fontSize:12},onClick:()=>{j(null),F(null)},children:"Back"}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:p.workflowName}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10,fontFamily:"monospace"},children:["(",p.id.slice(0,8),")"]}),e.jsx("span",{style:{...a.tag,background:`${c}22`,color:c},children:p.status}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{style:{...a.refreshBtn,fontFamily:"monospace",fontSize:10},onClick:()=>$(p.id),children:"{..}"})]}),e.jsxs("div",{style:{display:"flex",gap:16,color:"#6c7086",fontSize:11,marginBottom:12},children:[e.jsxs("span",{children:["Created: ",J(p.createdAt)]}),e.jsxs("span",{children:["Updated: ",J(p.updatedAt)]}),p.error&&e.jsxs("span",{style:{color:"#f38ba8"},children:["Error: ",p.error]})]}),e.jsxs("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:["Timeline (",p.history.length," step",p.history.length!==1?"s":"",")"]}),p.history.length===0&&e.jsx("div",{style:{color:"#6c7086",fontSize:12,padding:16},children:"No steps recorded yet."}),p.history.map((d,b)=>{const l=t==null?void 0:t.states.find(A=>A.id===d.toStateId),f=z===b,u=l&&Q[l.type]||"#6c7086";return e.jsxs("div",{style:{padding:"10px 12px",borderLeft:`3px solid ${u}`,borderBottom:"1px solid #313244",cursor:"pointer",background:f?"rgba(137,180,250,0.05)":"transparent",marginLeft:8},onClick:()=>F(f?null:b),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:u,flexShrink:0}}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:12,fontWeight:500},children:(l==null?void 0:l.name)||d.toStateId}),l&&e.jsx("span",{style:{...a.tag,background:`${u}22`,color:u},children:l.type}),d.transitionName&&e.jsxs("span",{style:{color:"#6c7086",fontSize:10},children:['via "',d.transitionName,'"']}),e.jsx("div",{style:{flex:1}}),e.jsx("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:J(d.timestamp)})]}),f&&e.jsxs("div",{style:{marginTop:8,paddingLeft:20},children:[d.fromStateId&&e.jsxs("div",{style:{color:"#6c7086",fontSize:11,marginBottom:2},children:[e.jsx("span",{style:{fontWeight:600,fontSize:10,textTransform:"uppercase"},children:"From: "}),e.jsx("span",{style:{fontFamily:"monospace"},children:d.fromStateId})]}),d.details&&e.jsxs("div",{style:{marginTop:6},children:[e.jsx("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:"Agent Reasoning / Summary"}),e.jsx("div",{style:{padding:10,background:"#181825",borderRadius:6,border:"1px solid #313244",fontSize:12,color:"#cdd6f4",lineHeight:1.5,whiteSpace:"pre-wrap"},children:d.details})]}),(l==null?void 0:l.description)&&e.jsxs("div",{style:{marginTop:6,color:"#a6adc8",fontSize:11},children:[e.jsx("span",{style:{color:"#6c7086",fontWeight:600,fontSize:10,textTransform:"uppercase"},children:"Description: "}),l.description]}),d.variables&&Object.keys(d.variables).length>0&&e.jsxs("div",{style:{marginTop:6},children:[e.jsx("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:"Variables at this step"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(d.variables,null,2)})]}),(l==null?void 0:l.action)&&e.jsxs("div",{style:{marginTop:6},children:[e.jsxs("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:["Action (",l.action.type,")"]}),e.jsx("pre",{style:a.detail,children:JSON.stringify(l.action,null,2)})]})]})]},b)})]})}return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:12,flexWrap:"wrap"},children:[e.jsxs("select",{style:{background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"5px 10px",color:"#cdd6f4",fontSize:12,outline:"none"},value:T,onChange:t=>M(t.target.value),children:[e.jsx("option",{value:"all",children:"All Workflows"}),N.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx("div",{style:{display:"flex",gap:4},children:["all","running","paused","completed","failed","cancelled"].map(t=>e.jsx("button",{style:{...a.timeBtn,background:n===t?t==="all"?"#89b4fa":G[t]||"#89b4fa":"transparent",color:n===t?"#1e1e2e":"#a6adc8",borderColor:n===t?"transparent":"#45475a",textTransform:"capitalize"},onClick:()=>B(t),children:t},t))}),e.jsx("input",{style:a.searchInput,placeholder:"Search instances...",value:y,onChange:t=>x(t.target.value)}),e.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:[m.length,"/",W.length]})]}),m.length===0?e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No workflow instances found."}):m.map(t=>{var f,u;const c=r.get(t.workflowDefId),d=G[t.status]||"#6c7086",b=c==null?void 0:c.states.find(A=>A.id===t.currentStateId),l=b&&Q[b.type]||"#6c7086";return e.jsxs("div",{style:{...a.eventRow,display:"flex",alignItems:"center",gap:12,borderLeft:`3px solid ${d}`},onClick:()=>j(t.id),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:t.workflowName}),e.jsx("span",{style:{...a.tag,background:`${d}22`,color:d},children:t.status})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:2},children:[e.jsx("span",{style:{color:"#6c7086",fontSize:10,fontFamily:"monospace"},children:t.id.slice(0,8)}),b&&e.jsxs("span",{style:{color:l,fontSize:10},children:["@ ",b.name]}),e.jsxs("span",{style:{color:"#45475a",fontSize:10},children:[((f=t.history)==null?void 0:f.length)??0," step",(((u=t.history)==null?void 0:u.length)??0)!==1?"s":""]})]})]}),e.jsx("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:pe(t.updatedAt)}),e.jsx("button",{style:{background:"transparent",border:"1px solid #45475a",borderRadius:4,padding:"3px 6px",color:"#6c7086",fontSize:10,fontFamily:"monospace",cursor:"pointer"},onClick:A=>{A.stopPropagation(),$(t.id)},title:"Debug view",children:"{..}"})]},t.id)})]})}function L({label:r,value:s,color:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,padding:"8px 10px",background:"#313244",borderRadius:6},children:[e.jsx("span",{style:{color:"#6c7086",fontSize:10,textTransform:"uppercase",letterSpacing:.5},children:r}),e.jsx("span",{style:{color:n||"#cdd6f4",fontSize:12,fontFamily:"monospace",wordBreak:"break-all"},children:s})]})}function pe(r){return new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function J(r){const s=new Date(r);return`${s.toLocaleDateString()} ${s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}`}const a={overlay:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,backdropFilter:"blur(4px)"},modal:{background:"var(--surface-0, #1e1e2e)",borderRadius:12,border:"1px solid var(--border, #313244)",width:"90vw",maxWidth:1e3,height:"85vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.5)"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)"},headerTitle:{fontSize:16,fontWeight:600,color:"var(--text-primary, #cdd6f4)",display:"flex",alignItems:"center",gap:8},closeBtn:{background:"none",border:"none",color:"var(--text-secondary, #a6adc8)",fontSize:20,cursor:"pointer",padding:"4px 8px",borderRadius:6,lineHeight:1},tabs:{display:"flex",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)",overflowX:"auto",scrollbarWidth:"none"},tab:r=>({padding:"10px 16px",background:"none",border:"none",borderBottom:r?"2px solid var(--accent, #89b4fa)":"2px solid transparent",color:r?"var(--accent, #89b4fa)":"var(--text-secondary, #a6adc8)",fontSize:13,fontWeight:r?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap",transition:"color 0.15s, border-color 0.15s",flexShrink:0}),filters:{display:"flex",gap:8,alignItems:"center",padding:"10px 20px",borderBottom:"1px solid var(--border, #313244)",flexWrap:"wrap"},timeBtn:{border:"1px solid #45475a",borderRadius:4,padding:"4px 8px",fontSize:10,fontWeight:600,cursor:"pointer"},searchInput:{background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"5px 10px",color:"#cdd6f4",fontSize:12,flex:1,minWidth:120,outline:"none"},refreshBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:6,padding:"5px 12px",color:"#a6adc8",fontSize:11,cursor:"pointer"},content:{flex:1,overflow:"auto",padding:"0 20px"},eventRow:{padding:"8px 12px",borderBottom:"1px solid #313244",cursor:"pointer",transition:"background 0.1s"},tag:{fontSize:10,fontWeight:600,padding:"2px 6px",borderRadius:4,whiteSpace:"nowrap"},detail:{marginTop:8,padding:10,background:"#181825",borderRadius:6,fontSize:11,fontFamily:"monospace",color:"#a6adc8",overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-all"},footer:{padding:"8px 20px",borderTop:"1px solid #313244"},section:{marginBottom:24},sectionTitle:{color:"#a6adc8",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:12,margin:0},grid:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},card:{background:"#313244",borderRadius:8,padding:"16px 14px",textAlign:"center"},integrationRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 12px",background:"#313244",borderRadius:6},statusBadge:{fontSize:10,fontWeight:600,padding:"3px 8px",borderRadius:4}};export{he as MonitoringModal};
|
|
1
|
+
import{r as g,c as D,d as O,j as e,I as H,s as se}from"./main-Dk3qq80S.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";const ae=[{id:"triggers",label:"Triggers",icon:"bolt"},{id:"workflows",label:"Workflows",icon:"gear"},{id:"instances",label:"Instances",icon:"refresh"},{id:"messages",label:"Messages",icon:"chat"},{id:"stats",label:"Stats",icon:"dashboard"}],ne={trigger:"#89b4fa",slack:"#cba6f7",email:"#f9e2af",calendar:"#a6e3a1",document:"#fab387",jira:"#89dceb",workflow:"#f38ba8",system:"#6c7086",step:"#f38ba8",variable_change:"#cba6f7",approval:"#a6e3a1",audit:"#6c7086"},re={trigger:"Trigger",slack:"Slack",email:"Email",calendar:"Calendar",document:"Document",jira:"Jira",workflow:"Workflow",system:"System",step:"Step",variable_change:"Variable",approval:"Approval",audit:"Audit"};function he({isOpen:r,onClose:s}){const[n,B]=g.useState("triggers"),[T,M]=g.useState([]),[y,x]=g.useState(!0),[_,j]=g.useState(null),[z,F]=g.useState("24h"),[R,$]=g.useState(""),[W,N]=g.useState(null),[m,p]=g.useState({}),[i,C]=g.useState(!1),[t,c]=g.useState(null),[d,b]=g.useState([]),l=g.useCallback(async()=>{if(!(n==="stats"||n==="instances")){x(!0);try{const o=Date.now(),h={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5,all:0},w=h[z]>0?String(o-h[z]):void 0;let k=[];if(n==="triggers"){const v=new URLSearchParams({limit:"200"});w&&v.set("since",w);const S=await D(O(`/api/events/triggers?${v}`));if(!S.ok){j(`HTTP ${S.status}`);return}k=((await S.json()).events||[]).map(E=>({type:"trigger",timestamp:E.firedAt,data:E}))}else if(n==="workflows"){const v=new URLSearchParams({limit:"200",category:"workflow"});w&&v.set("since",w);const S=await D(O(`/api/events/audit?${v}`));if(!S.ok){j(`HTTP ${S.status}`);return}k=((await S.json()).entries||[]).map(E=>({type:"workflow",timestamp:E.createdAt,data:E}))}else if(n==="messages"){const v=new URLSearchParams({limit:"200"}),S=new URLSearchParams({limit:"200"}),V=new URLSearchParams({limit:"200"});w&&(v.set("since",w),S.set("since",w));const[E,X,q]=await Promise.all([D(O(`/api/events/slack?${v}`)),D(O(`/api/events/email?${S}`)),D(O(`/api/events/approvals?${V}`))]);if(E.ok){const P=await E.json();for(const I of P.messages||[])k.push({type:"slack",timestamp:I.receivedAt,data:I})}if(X.ok){const P=await X.json();for(const I of P.messages||[])k.push({type:"email",timestamp:I.receivedAt,data:I})}if(q.ok){const P=await q.json();for(const I of P.events||[])k.push({type:"approval",timestamp:I.recordedAt,data:I})}k.sort((P,I)=>I.timestamp-P.timestamp)}M(k),j(null)}catch(o){j(`Failed to load events: ${o}`)}finally{x(!1)}}},[n,z]),f=g.useCallback(async()=>{x(!0);try{const[o,h]=await Promise.all([D(O("/api/events/stats")),D(O("/api/integrations"))]);if(o.ok&&c(await o.json()),h.ok){const w=await h.json();b(Array.isArray(w)?w:[])}j(null)}catch(o){j(`Failed to load stats: ${o}`)}finally{x(!1)}},[]);g.useEffect(()=>{r&&(n==="stats"?f():l())},[r,n,l,f]);const u=T.filter(o=>{if(!R)return!0;const h=R.toLowerCase();return JSON.stringify(o.data).toLowerCase().includes(h)});if(!r)return null;const A=d.filter(o=>o.status.connected).length;return e.jsx("div",{style:a.overlay,onClick:s,children:e.jsxs("div",{style:a.modal,onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:a.header,children:[e.jsxs("div",{style:a.headerTitle,children:[e.jsx(H,{name:"dashboard",size:16}),e.jsx("span",{children:"Monitoring & Logs"})]}),e.jsx("button",{style:a.closeBtn,onClick:s,title:"Close",children:"×"})]}),e.jsx("div",{style:a.tabs,children:ae.map(o=>e.jsxs("button",{style:a.tab(n===o.id),onClick:()=>{B(o.id),$(""),N(null)},children:[e.jsx(H,{name:o.icon,size:14}),e.jsx("span",{children:o.label})]},o.id))}),n!=="stats"&&n!=="instances"&&e.jsxs("div",{style:a.filters,children:[e.jsx("div",{style:{display:"flex",gap:4},children:["1h","6h","24h","7d","all"].map(o=>e.jsx("button",{style:{...a.timeBtn,background:z===o?"#89b4fa":"transparent",color:z===o?"#1e1e2e":"#a6adc8"},onClick:()=>F(o),children:o},o))}),e.jsx("input",{style:a.searchInput,placeholder:"Search events...",value:R,onChange:o=>$(o.target.value)}),e.jsx("button",{style:a.refreshBtn,onClick:l,children:"Refresh"})]}),e.jsx("div",{style:a.content,children:n==="stats"?e.jsx(ie,{loading:y,error:_,stats:t,integrations:d,connectedCount:A,onRefresh:f}):n==="instances"?e.jsx(de,{}):e.jsx(oe,{loading:y,error:_,entries:u,expandedId:W,matcherResults:m,loadingMatchers:i,onToggleExpand:async(o,h)=>{var w;if(W===o){N(null);return}if(N(o),!m[o]){C(!0);try{let k="";if((h==null?void 0:h.type)==="trigger"&&((w=h==null?void 0:h.data)!=null&&w.id))k=`/api/triggers/events/${h.data.id}/matchers`;else if(h&&["slack","email","approval"].includes(h.type)){const v=h.data,S=v.ts||v.messageId||v.email_id;S&&h.type&&(k=`/api/triggers/matchers/by-source/${h.type}/${encodeURIComponent(S)}`)}if(k){const v=await D(O(k));if(v.ok){const S=await v.json();p(V=>({...V,[o]:S.matchers||[]}))}}}catch(k){console.error("Failed to fetch matchers:",k)}finally{C(!1)}}}})}),n!=="stats"&&n!=="instances"&&e.jsx("div",{style:a.footer,children:e.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:[u.length," event",u.length!==1?"s":""," shown",R&&` (filtered from ${T.length})`]})})]})})}function oe({loading:r,error:s,entries:n,expandedId:B,matcherResults:T,loadingMatchers:M,onToggleExpand:y}){return r?e.jsx("div",{style:{color:"#a6adc8",padding:20},children:"Loading events..."}):s?e.jsx("div",{style:{color:"#f38ba8",padding:20},children:s}):n.length===0?e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No events found for the selected filters."}):e.jsx(e.Fragment,{children:n.map((x,_)=>{var W;const j=`${x.type}-${x.timestamp}-${_}`,z=B===j,F=ne[x.type]||"#6c7086",R=le(x),$=new Date(x.timestamp);return e.jsxs("div",{style:{...a.eventRow,borderLeft:`3px solid ${F}`,background:z?"rgba(137,180,250,0.05)":"transparent"},onClick:()=>y(j,x),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{...a.tag,background:`${F}22`,color:F},children:re[x.type]||x.type}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:12,flex:1},children:R}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:[$.toLocaleTimeString()," ",$.toLocaleDateString()]})]}),z&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{style:a.detail,children:JSON.stringify(x.data,null,2)}),T[j]&&e.jsxs("div",{style:{marginTop:12,borderTop:"1px solid #313244",paddingTop:12},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},children:x.type==="trigger"?"Matcher Results":"Trigger Evaluations"}),M?e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"Loading matchers..."}):((W=T[j])==null?void 0:W.length)===0?e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"No matchers evaluated"}):(()=>{const N=T[j];if(x.type!=="trigger"){const m=new Map;for(const p of N){const i=String(p.trigger_id||"unknown");m.has(i)||m.set(i,[]),m.get(i).push(p)}return Array.from(m.entries()).map(([p,i])=>{var C;return e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs("div",{style:{color:"#cdd6f4",fontSize:11,fontWeight:500,marginBottom:6,paddingBottom:4,borderBottom:"1px solid #45475a"},children:["Trigger: ",String(((C=i[0])==null?void 0:C.trigger_name)||p)]}),i.map((t,c)=>{const d=t.matched===1||t.matched===!0,b=d?"#a6e3a1":"#f38ba8",l=t.confidence??null,f=String(t.matcher_name||"unknown"),u=t.reason?String(t.reason):"";return e.jsxs("div",{style:{display:"flex",gap:8,padding:"6px 10px",background:"#313244",borderRadius:4,marginBottom:4,fontSize:11},children:[e.jsx("span",{style:{color:b,fontWeight:600,minWidth:50},children:d?e.jsx(H,{name:"check",size:12}):e.jsx(H,{name:"cross",size:12})}),e.jsx("span",{style:{color:"#cdd6f4",flex:1},children:f}),l!==null&&e.jsxs("span",{style:{color:"#a6adc8"},children:["(",(l*100).toFixed(0),"%)"]}),u&&e.jsx("span",{style:{color:"#6c7086",fontSize:10},children:u})]},c)})]},p)})}else return N.map((m,p)=>{const i=m.matched===1||m.matched===!0,C=i?"#a6e3a1":"#f38ba8",t=m.confidence??null,c=String(m.matcher_name||"unknown"),d=m.reason?String(m.reason):"";return e.jsxs("div",{style:{display:"flex",gap:8,padding:"6px 10px",background:"#313244",borderRadius:4,marginBottom:4,fontSize:11},children:[e.jsx("span",{style:{color:C,fontWeight:600,minWidth:50},children:i?e.jsxs(e.Fragment,{children:[e.jsx(H,{name:"check",size:12})," MATCH"]}):e.jsxs(e.Fragment,{children:[e.jsx(H,{name:"cross",size:12})," FAIL"]})}),e.jsx("span",{style:{color:"#cdd6f4",flex:1},children:c}),t!==null&&e.jsxs("span",{style:{color:"#a6adc8"},children:["(",(t*100).toFixed(0),"%)"]}),d&&e.jsx("span",{style:{color:"#6c7086",fontSize:10},children:d})]},p)})})()]})]})]},j)})})}function ie({loading:r,error:s,stats:n,integrations:B,connectedCount:T,onRefresh:M}){return r?e.jsx("div",{style:{color:"#a6adc8",padding:20},children:"Loading stats..."}):s?e.jsx("div",{style:{color:"#f38ba8",padding:20},children:s}):e.jsxs("div",{style:{padding:20},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:16},children:e.jsx("button",{style:a.refreshBtn,onClick:M,children:"Refresh"})}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:a.section,children:[e.jsx("h3",{style:a.sectionTitle,children:"Workflows"}),e.jsxs("div",{style:a.grid,children:[e.jsx(U,{label:"Active",value:n.activeWorkflows,color:"#89b4fa"}),e.jsx(U,{label:"Completed",value:n.completedWorkflows,color:"#a6e3a1"}),e.jsx(U,{label:"Failed",value:n.failedWorkflows,color:"#f38ba8"})]})]}),e.jsxs("div",{style:a.section,children:[e.jsx("h3",{style:a.sectionTitle,children:"Events (Today)"}),e.jsxs("div",{style:a.grid,children:[e.jsx(U,{label:"Triggers Fired",value:n.triggersFiredToday,color:"#f9e2af"}),e.jsx(U,{label:"Slack Messages",value:n.slackMessageCount,color:"#cba6f7"}),e.jsx(U,{label:"Emails",value:n.emailCount,color:"#fab387"})]})]}),e.jsxs("div",{style:a.section,children:[e.jsxs("h3",{style:a.sectionTitle,children:["Integrations (",T,"/",B.length," connected)"]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[B.map(y=>e.jsxs("div",{style:a.integrationRow,children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:13},children:y.name}),e.jsx("span",{style:{...a.statusBadge,background:y.status.connected?"rgba(166,227,161,0.15)":"rgba(108,112,134,0.15)",color:y.status.connected?"#a6e3a1":"#6c7086"},children:y.status.error?"Error":y.status.connected?"Connected":"Disconnected"})]},y.id)),B.length===0&&e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"No integrations configured"})]})]})]}),!n&&e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No stats available. The event store may not have any data yet."})]})}function U({label:r,value:s,color:n}){return e.jsxs("div",{style:a.card,children:[e.jsx("div",{style:{color:n,fontSize:28,fontWeight:700,lineHeight:1},children:s}),e.jsx("div",{style:{color:"#a6adc8",fontSize:11,marginTop:4},children:r})]})}function le(r){const s=r.data;switch(r.type){case"trigger":return`Trigger "${s.triggerName||s.triggerId}" ${s.status||"fired"}`;case"slack":return`${s.direction==="outbound"?"Sent":"Received"} in #${s.channelName||s.channelId}: ${K(s.text,60)}`;case"email":return`${s.direction==="outbound"?"Sent to":"From"} ${s.direction==="outbound"?s.toAddresses:s.fromAddress}: ${K(s.subject,50)}`;case"approval":return`${s.approved?"Approved":"Rejected"} by ${s.approverEmail}`;case"document":return`Generated "${s.outputFilename}" from template "${s.templateName}"`;case"calendar":return`Calendar event ${s.action}: "${s.summary}"`;case"jira":return`${s.ticketKey} ${s.action}: ${K(s.summary,50)}`;case"step":return`Workflow step: ${s.toStateName} (${s.status})`;case"variable_change":return`Variable "${s.variableName}" changed by ${s.changedBy}`;case"audit":return`[${(s.level||"info").toUpperCase()}] ${s.category}: ${s.action}`;default:return JSON.stringify(s).slice(0,80)}}function K(r,s){return r?r.length>s?r.slice(0,s)+"...":r:""}const G={running:"#a6e3a1",paused:"#f9e2af",completed:"#89b4fa",failed:"#f38ba8",cancelled:"#6c7086"},Q={action:"#89b4fa",wait:"#f9e2af",decision:"#cba6f7",end:"#6c7086"};let Y=null,Z,ee;function te(){const r=se.getState(),s=r.workflowDefinitions??new Map,n=r.workflowInstances??new Map;return Y&&Z===s&&ee===n||(Z=s,ee=n,Y={definitions:s,instances:n}),Y}function ce(){return g.useSyncExternalStore(r=>se.subscribe(r),te,te)}function de(){var C;const{definitions:r,instances:s}=ce(),[n,B]=g.useState("all"),[T,M]=g.useState("all"),[y,x]=g.useState(""),[_,j]=g.useState(null),[z,F]=g.useState(null),[R,$]=g.useState(null),W=g.useMemo(()=>Array.from(s.values()),[s]),N=g.useMemo(()=>Array.from(r.values()),[r]),m=g.useMemo(()=>W.filter(t=>{if(n!=="all"&&t.status!==n||T!=="all"&&t.workflowDefId!==T)return!1;if(y){const c=y.toLowerCase();return t.workflowName.toLowerCase().includes(c)||t.id.toLowerCase().includes(c)||JSON.stringify(t.variables).toLowerCase().includes(c)}return!0}).sort((t,c)=>c.updatedAt-t.updatedAt),[W,n,T,y]),p=_?s.get(_):null,i=R?s.get(R):null;if(i){const t=r.get(i.workflowDefId),c=t==null?void 0:t.states.find(f=>f.id===i.currentStateId),d=G[i.status]||"#6c7086",b={},l={};for(const[f,u]of Object.entries(i.variables))f.startsWith("wi_")?b[f]=u:l[f]=u;return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("button",{style:{...a.refreshBtn,fontSize:12},onClick:()=>$(null),children:"Back"}),e.jsxs("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:["Debug: ",i.workflowName]}),e.jsx("span",{style:{...a.tag,background:`${d}22`,color:d},children:i.status})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8,marginBottom:16},children:[e.jsx(L,{label:"ID",value:i.id}),e.jsx(L,{label:"Def ID",value:i.workflowDefId}),e.jsx(L,{label:"Current State",value:(c==null?void 0:c.name)||i.currentStateId}),e.jsx(L,{label:"State Type",value:(c==null?void 0:c.type)||"unknown"}),e.jsx(L,{label:"Created",value:J(i.createdAt)}),e.jsx(L,{label:"Updated",value:J(i.updatedAt)}),i.completedAt&&e.jsx(L,{label:"Completed",value:J(i.completedAt)}),i.error&&e.jsx(L,{label:"Error",value:i.error,color:"#f38ba8"}),e.jsx(L,{label:"Steps",value:String(((C=i.history)==null?void 0:C.length)??0)})]}),Object.keys(l).length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"User Variables"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(l,null,2)})]}),Object.keys(b).length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Internal Variables (wi_*)"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(b,null,2)})]}),c&&c.transitions.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Available Transitions"}),c.transitions.map(f=>{var u;return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 10px",background:"#313244",borderRadius:4,marginBottom:4},children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:12},children:f.name}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10},children:[f.condition.type," → ",((u=t==null?void 0:t.states.find(A=>A.id===f.targetStateId))==null?void 0:u.name)||f.targetStateId]})]},f.id)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Raw JSON"}),e.jsx("pre",{style:{...a.detail,maxHeight:400},children:JSON.stringify(i,null,2)})]})]})}if(p){const t=r.get(p.workflowDefId),c=G[p.status]||"#6c7086";return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("button",{style:{...a.refreshBtn,fontSize:12},onClick:()=>{j(null),F(null)},children:"Back"}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:p.workflowName}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10,fontFamily:"monospace"},children:["(",p.id.slice(0,8),")"]}),e.jsx("span",{style:{...a.tag,background:`${c}22`,color:c},children:p.status}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{style:{...a.refreshBtn,fontFamily:"monospace",fontSize:10},onClick:()=>$(p.id),children:"{..}"})]}),e.jsxs("div",{style:{display:"flex",gap:16,color:"#6c7086",fontSize:11,marginBottom:12},children:[e.jsxs("span",{children:["Created: ",J(p.createdAt)]}),e.jsxs("span",{children:["Updated: ",J(p.updatedAt)]}),p.error&&e.jsxs("span",{style:{color:"#f38ba8"},children:["Error: ",p.error]})]}),e.jsxs("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:["Timeline (",p.history.length," step",p.history.length!==1?"s":"",")"]}),p.history.length===0&&e.jsx("div",{style:{color:"#6c7086",fontSize:12,padding:16},children:"No steps recorded yet."}),p.history.map((d,b)=>{const l=t==null?void 0:t.states.find(A=>A.id===d.toStateId),f=z===b,u=l&&Q[l.type]||"#6c7086";return e.jsxs("div",{style:{padding:"10px 12px",borderLeft:`3px solid ${u}`,borderBottom:"1px solid #313244",cursor:"pointer",background:f?"rgba(137,180,250,0.05)":"transparent",marginLeft:8},onClick:()=>F(f?null:b),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:u,flexShrink:0}}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:12,fontWeight:500},children:(l==null?void 0:l.name)||d.toStateId}),l&&e.jsx("span",{style:{...a.tag,background:`${u}22`,color:u},children:l.type}),d.transitionName&&e.jsxs("span",{style:{color:"#6c7086",fontSize:10},children:['via "',d.transitionName,'"']}),e.jsx("div",{style:{flex:1}}),e.jsx("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:J(d.timestamp)})]}),f&&e.jsxs("div",{style:{marginTop:8,paddingLeft:20},children:[d.fromStateId&&e.jsxs("div",{style:{color:"#6c7086",fontSize:11,marginBottom:2},children:[e.jsx("span",{style:{fontWeight:600,fontSize:10,textTransform:"uppercase"},children:"From: "}),e.jsx("span",{style:{fontFamily:"monospace"},children:d.fromStateId})]}),d.details&&e.jsxs("div",{style:{marginTop:6},children:[e.jsx("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:"Agent Reasoning / Summary"}),e.jsx("div",{style:{padding:10,background:"#181825",borderRadius:6,border:"1px solid #313244",fontSize:12,color:"#cdd6f4",lineHeight:1.5,whiteSpace:"pre-wrap"},children:d.details})]}),(l==null?void 0:l.description)&&e.jsxs("div",{style:{marginTop:6,color:"#a6adc8",fontSize:11},children:[e.jsx("span",{style:{color:"#6c7086",fontWeight:600,fontSize:10,textTransform:"uppercase"},children:"Description: "}),l.description]}),d.variables&&Object.keys(d.variables).length>0&&e.jsxs("div",{style:{marginTop:6},children:[e.jsx("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:"Variables at this step"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(d.variables,null,2)})]}),(l==null?void 0:l.action)&&e.jsxs("div",{style:{marginTop:6},children:[e.jsxs("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:["Action (",l.action.type,")"]}),e.jsx("pre",{style:a.detail,children:JSON.stringify(l.action,null,2)})]})]})]},b)})]})}return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:12,flexWrap:"wrap"},children:[e.jsxs("select",{style:{background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"5px 10px",color:"#cdd6f4",fontSize:12,outline:"none"},value:T,onChange:t=>M(t.target.value),children:[e.jsx("option",{value:"all",children:"All Workflows"}),N.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx("div",{style:{display:"flex",gap:4},children:["all","running","paused","completed","failed","cancelled"].map(t=>e.jsx("button",{style:{...a.timeBtn,background:n===t?t==="all"?"#89b4fa":G[t]||"#89b4fa":"transparent",color:n===t?"#1e1e2e":"#a6adc8",borderColor:n===t?"transparent":"#45475a",textTransform:"capitalize"},onClick:()=>B(t),children:t},t))}),e.jsx("input",{style:a.searchInput,placeholder:"Search instances...",value:y,onChange:t=>x(t.target.value)}),e.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:[m.length,"/",W.length]})]}),m.length===0?e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No workflow instances found."}):m.map(t=>{var f,u;const c=r.get(t.workflowDefId),d=G[t.status]||"#6c7086",b=c==null?void 0:c.states.find(A=>A.id===t.currentStateId),l=b&&Q[b.type]||"#6c7086";return e.jsxs("div",{style:{...a.eventRow,display:"flex",alignItems:"center",gap:12,borderLeft:`3px solid ${d}`},onClick:()=>j(t.id),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:t.workflowName}),e.jsx("span",{style:{...a.tag,background:`${d}22`,color:d},children:t.status})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:2},children:[e.jsx("span",{style:{color:"#6c7086",fontSize:10,fontFamily:"monospace"},children:t.id.slice(0,8)}),b&&e.jsxs("span",{style:{color:l,fontSize:10},children:["@ ",b.name]}),e.jsxs("span",{style:{color:"#45475a",fontSize:10},children:[((f=t.history)==null?void 0:f.length)??0," step",(((u=t.history)==null?void 0:u.length)??0)!==1?"s":""]})]})]}),e.jsx("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:pe(t.updatedAt)}),e.jsx("button",{style:{background:"transparent",border:"1px solid #45475a",borderRadius:4,padding:"3px 6px",color:"#6c7086",fontSize:10,fontFamily:"monospace",cursor:"pointer"},onClick:A=>{A.stopPropagation(),$(t.id)},title:"Debug view",children:"{..}"})]},t.id)})]})}function L({label:r,value:s,color:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,padding:"8px 10px",background:"#313244",borderRadius:6},children:[e.jsx("span",{style:{color:"#6c7086",fontSize:10,textTransform:"uppercase",letterSpacing:.5},children:r}),e.jsx("span",{style:{color:n||"#cdd6f4",fontSize:12,fontFamily:"monospace",wordBreak:"break-all"},children:s})]})}function pe(r){return new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function J(r){const s=new Date(r);return`${s.toLocaleDateString()} ${s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}`}const a={overlay:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,backdropFilter:"blur(4px)"},modal:{background:"var(--surface-0, #1e1e2e)",borderRadius:12,border:"1px solid var(--border, #313244)",width:"90vw",maxWidth:1e3,height:"85vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.5)"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)"},headerTitle:{fontSize:16,fontWeight:600,color:"var(--text-primary, #cdd6f4)",display:"flex",alignItems:"center",gap:8},closeBtn:{background:"none",border:"none",color:"var(--text-secondary, #a6adc8)",fontSize:20,cursor:"pointer",padding:"4px 8px",borderRadius:6,lineHeight:1},tabs:{display:"flex",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)",overflowX:"auto",scrollbarWidth:"none"},tab:r=>({padding:"10px 16px",background:"none",border:"none",borderBottom:r?"2px solid var(--accent, #89b4fa)":"2px solid transparent",color:r?"var(--accent, #89b4fa)":"var(--text-secondary, #a6adc8)",fontSize:13,fontWeight:r?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap",transition:"color 0.15s, border-color 0.15s",flexShrink:0}),filters:{display:"flex",gap:8,alignItems:"center",padding:"10px 20px",borderBottom:"1px solid var(--border, #313244)",flexWrap:"wrap"},timeBtn:{border:"1px solid #45475a",borderRadius:4,padding:"4px 8px",fontSize:10,fontWeight:600,cursor:"pointer"},searchInput:{background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"5px 10px",color:"#cdd6f4",fontSize:12,flex:1,minWidth:120,outline:"none"},refreshBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:6,padding:"5px 12px",color:"#a6adc8",fontSize:11,cursor:"pointer"},content:{flex:1,overflow:"auto",padding:"0 20px"},eventRow:{padding:"8px 12px",borderBottom:"1px solid #313244",cursor:"pointer",transition:"background 0.1s"},tag:{fontSize:10,fontWeight:600,padding:"2px 6px",borderRadius:4,whiteSpace:"nowrap"},detail:{marginTop:8,padding:10,background:"#181825",borderRadius:6,fontSize:11,fontFamily:"monospace",color:"#a6adc8",overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-all"},footer:{padding:"8px 20px",borderTop:"1px solid #313244"},section:{marginBottom:24},sectionTitle:{color:"#a6adc8",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:12,margin:0},grid:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},card:{background:"#313244",borderRadius:8,padding:"16px 14px",textAlign:"center"},integrationRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 12px",background:"#313244",borderRadius:6},statusBadge:{fontSize:10,fontWeight:600,padding:"3px 8px",borderRadius:4}};export{he as MonitoringModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as S,V as p,M as u,T as _,Q as E,S as P,a as c,R as w,P as O,b as R}from"./vendor-three-CBPuP1jE.js";const D={type:"change"},b={type:"start"},M={type:"end"},f=new w,T=new O,j=Math.cos(70*R.DEG2RAD),n=new p,r=2*Math.PI,o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},y=1e-6;class X extends S{constructor(t,e=null){super(t,e),this.state=o.NONE,this.enabled=!0,this.target=new p,this.cursor=new p,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.ROTATE,MIDDLE:u.DOLLY,RIGHT:u.PAN},this.touches={ONE:_.ROTATE,TWO:_.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new p,this._lastQuaternion=new E,this._lastTargetPosition=new p,this._quat=new E().setFromUnitVectors(t.up,new p(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new P,this._sphericalDelta=new P,this._scale=1,this._panOffset=new p,this._rotateStart=new c,this._rotateEnd=new c,this._rotateDelta=new c,this._panStart=new c,this._panEnd=new c,this._panDelta=new c,this._dollyStart=new c,this._dollyEnd=new c,this._dollyDelta=new c,this._dollyDirection=new p,this._mouse=new c,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=L.bind(this),this._onPointerDown=A.bind(this),this._onPointerUp=x.bind(this),this._onContextMenu=Z.bind(this),this._onMouseWheel=N.bind(this),this._onKeyDown=Y.bind(this),this._onTouchStart=I.bind(this),this._onTouchMove=U.bind(this),this._onMouseDown=C.bind(this),this._onMouseMove=k.bind(this),this._interceptControlDown=z.bind(this),this._interceptControlUp=K.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(D),this.update(),this.state=o.NONE}update(t=null){const e=this.object.position;n.copy(e).sub(this.target),n.applyQuaternion(this._quat),this._spherical.setFromVector3(n),this.autoRotate&&this.state===o.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,a=this.maxAzimuthAngle;isFinite(s)&&isFinite(a)&&(s<-Math.PI?s+=r:s>Math.PI&&(s-=r),a<-Math.PI?a+=r:a>Math.PI&&(a-=r),s<=a?this._spherical.theta=Math.max(s,Math.min(a,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+a)/2?Math.max(s,this._spherical.theta):Math.min(a,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let h=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const l=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),h=l!=this._spherical.radius}if(n.setFromSpherical(this._spherical),n.applyQuaternion(this._quatInverse),e.copy(this.target).add(n),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let l=null;if(this.object.isPerspectiveCamera){const d=n.length();l=this._clampDistance(d*this._scale);const m=d-l;this.object.position.addScaledVector(this._dollyDirection,m),this.object.updateMatrixWorld(),h=!!m}else if(this.object.isOrthographicCamera){const d=new p(this._mouse.x,this._mouse.y,0);d.unproject(this.object);const m=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),h=m!==this.object.zoom;const g=new p(this._mouse.x,this._mouse.y,0);g.unproject(this.object),this.object.position.sub(g).add(d),this.object.updateMatrixWorld(),l=n.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;l!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(l).add(this.object.position):(f.origin.copy(this.object.position),f.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(f.direction))<j?this.object.lookAt(this.target):(T.setFromNormalAndCoplanarPoint(this.object.up,this.target),f.intersectPlane(T,this.target))))}else if(this.object.isOrthographicCamera){const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),l!==this.object.zoom&&(this.object.updateProjectionMatrix(),h=!0)}return this._scale=1,this._performCursorZoom=!1,h||this._lastPosition.distanceToSquared(this.object.position)>y||8*(1-this._lastQuaternion.dot(this.object.quaternion))>y||this._lastTargetPosition.distanceToSquared(this.target)>y?(this.dispatchEvent(D),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?r/60*this.autoRotateSpeed*t:r/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){n.setFromMatrixColumn(e,0),n.multiplyScalar(-t),this._panOffset.add(n)}_panUp(t,e){this.screenSpacePanning===!0?n.setFromMatrixColumn(e,1):(n.setFromMatrixColumn(e,0),n.crossVectors(this.object.up,n)),n.multiplyScalar(t),this._panOffset.add(n)}_pan(t,e){const s=this.domElement;if(this.object.isPerspectiveCamera){const a=this.object.position;n.copy(a).sub(this.target);let h=n.length();h*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*h/s.clientHeight,this.object.matrix),this._panUp(2*e*h/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),a=t-s.left,h=e-s.top,l=s.width,d=s.height;this._mouse.x=a/l*2-1,this._mouse.y=-(h/d)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(r*this._rotateDelta.x/e.clientHeight),this._rotateUp(r*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(r*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-r*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(r*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-r*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._rotateStart.set(s,a)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._panStart.set(s,a)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),s=t.pageX-e.x,a=t.pageY-e.y,h=Math.sqrt(s*s+a*a);this._dollyStart.set(0,h)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const s=this._getSecondPointerPosition(t),a=.5*(t.pageX+s.x),h=.5*(t.pageY+s.y);this._rotateEnd.set(a,h)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(r*this._rotateDelta.x/e.clientHeight),this._rotateUp(r*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._panEnd.set(s,a)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),s=t.pageX-e.x,a=t.pageY-e.y,h=Math.sqrt(s*s+a*a);this._dollyEnd.set(0,h),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const l=(t.pageX+e.x)*.5,d=(t.pageY+e.y)*.5;this._updateZoomParameters(l,d)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new c,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,s={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function A(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function L(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function x(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(M),this.state=o.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function C(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case u.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=o.DOLLY;break;case u.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=o.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=o.ROTATE}break;case u.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=o.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=o.PAN}break;default:this.state=o.NONE}this.state!==o.NONE&&this.dispatchEvent(b)}function k(i){switch(this.state){case o.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case o.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case o.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function N(i){this.enabled===!1||this.enableZoom===!1||this.state!==o.NONE||(i.preventDefault(),this.dispatchEvent(b),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(M))}function Y(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function I(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case _.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=o.TOUCH_ROTATE;break;case _.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=o.TOUCH_PAN;break;default:this.state=o.NONE}break;case 2:switch(this.touches.TWO){case _.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=o.TOUCH_DOLLY_PAN;break;case _.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=o.TOUCH_DOLLY_ROTATE;break;default:this.state=o.NONE}break;default:this.state=o.NONE}this.state!==o.NONE&&this.dispatchEvent(b)}function U(i){switch(this._trackPointer(i),this.state){case o.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case o.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case o.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case o.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=o.NONE}}function Z(i){this.enabled!==!1&&i.preventDefault()}function z(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function K(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}export{X as O};
|
|
1
|
+
import{C as S,V as p,M as u,T as _,Q as E,S as P,a as c,R as w,P as O,b as R}from"./vendor-three-DYBBrXTx.js";const D={type:"change"},b={type:"start"},M={type:"end"},f=new w,T=new O,j=Math.cos(70*R.DEG2RAD),n=new p,r=2*Math.PI,o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},y=1e-6;class X extends S{constructor(t,e=null){super(t,e),this.state=o.NONE,this.enabled=!0,this.target=new p,this.cursor=new p,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.ROTATE,MIDDLE:u.DOLLY,RIGHT:u.PAN},this.touches={ONE:_.ROTATE,TWO:_.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new p,this._lastQuaternion=new E,this._lastTargetPosition=new p,this._quat=new E().setFromUnitVectors(t.up,new p(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new P,this._sphericalDelta=new P,this._scale=1,this._panOffset=new p,this._rotateStart=new c,this._rotateEnd=new c,this._rotateDelta=new c,this._panStart=new c,this._panEnd=new c,this._panDelta=new c,this._dollyStart=new c,this._dollyEnd=new c,this._dollyDelta=new c,this._dollyDirection=new p,this._mouse=new c,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=L.bind(this),this._onPointerDown=A.bind(this),this._onPointerUp=x.bind(this),this._onContextMenu=Z.bind(this),this._onMouseWheel=N.bind(this),this._onKeyDown=Y.bind(this),this._onTouchStart=I.bind(this),this._onTouchMove=U.bind(this),this._onMouseDown=C.bind(this),this._onMouseMove=k.bind(this),this._interceptControlDown=z.bind(this),this._interceptControlUp=K.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(D),this.update(),this.state=o.NONE}update(t=null){const e=this.object.position;n.copy(e).sub(this.target),n.applyQuaternion(this._quat),this._spherical.setFromVector3(n),this.autoRotate&&this.state===o.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,a=this.maxAzimuthAngle;isFinite(s)&&isFinite(a)&&(s<-Math.PI?s+=r:s>Math.PI&&(s-=r),a<-Math.PI?a+=r:a>Math.PI&&(a-=r),s<=a?this._spherical.theta=Math.max(s,Math.min(a,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+a)/2?Math.max(s,this._spherical.theta):Math.min(a,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let h=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const l=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),h=l!=this._spherical.radius}if(n.setFromSpherical(this._spherical),n.applyQuaternion(this._quatInverse),e.copy(this.target).add(n),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let l=null;if(this.object.isPerspectiveCamera){const d=n.length();l=this._clampDistance(d*this._scale);const m=d-l;this.object.position.addScaledVector(this._dollyDirection,m),this.object.updateMatrixWorld(),h=!!m}else if(this.object.isOrthographicCamera){const d=new p(this._mouse.x,this._mouse.y,0);d.unproject(this.object);const m=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),h=m!==this.object.zoom;const g=new p(this._mouse.x,this._mouse.y,0);g.unproject(this.object),this.object.position.sub(g).add(d),this.object.updateMatrixWorld(),l=n.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;l!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(l).add(this.object.position):(f.origin.copy(this.object.position),f.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(f.direction))<j?this.object.lookAt(this.target):(T.setFromNormalAndCoplanarPoint(this.object.up,this.target),f.intersectPlane(T,this.target))))}else if(this.object.isOrthographicCamera){const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),l!==this.object.zoom&&(this.object.updateProjectionMatrix(),h=!0)}return this._scale=1,this._performCursorZoom=!1,h||this._lastPosition.distanceToSquared(this.object.position)>y||8*(1-this._lastQuaternion.dot(this.object.quaternion))>y||this._lastTargetPosition.distanceToSquared(this.target)>y?(this.dispatchEvent(D),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?r/60*this.autoRotateSpeed*t:r/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){n.setFromMatrixColumn(e,0),n.multiplyScalar(-t),this._panOffset.add(n)}_panUp(t,e){this.screenSpacePanning===!0?n.setFromMatrixColumn(e,1):(n.setFromMatrixColumn(e,0),n.crossVectors(this.object.up,n)),n.multiplyScalar(t),this._panOffset.add(n)}_pan(t,e){const s=this.domElement;if(this.object.isPerspectiveCamera){const a=this.object.position;n.copy(a).sub(this.target);let h=n.length();h*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*h/s.clientHeight,this.object.matrix),this._panUp(2*e*h/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),a=t-s.left,h=e-s.top,l=s.width,d=s.height;this._mouse.x=a/l*2-1,this._mouse.y=-(h/d)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(r*this._rotateDelta.x/e.clientHeight),this._rotateUp(r*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(r*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-r*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(r*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-r*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._rotateStart.set(s,a)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._panStart.set(s,a)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),s=t.pageX-e.x,a=t.pageY-e.y,h=Math.sqrt(s*s+a*a);this._dollyStart.set(0,h)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const s=this._getSecondPointerPosition(t),a=.5*(t.pageX+s.x),h=.5*(t.pageY+s.y);this._rotateEnd.set(a,h)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(r*this._rotateDelta.x/e.clientHeight),this._rotateUp(r*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._panEnd.set(s,a)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),s=t.pageX-e.x,a=t.pageY-e.y,h=Math.sqrt(s*s+a*a);this._dollyEnd.set(0,h),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const l=(t.pageX+e.x)*.5,d=(t.pageY+e.y)*.5;this._updateZoomParameters(l,d)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new c,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,s={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function A(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function L(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function x(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(M),this.state=o.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function C(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case u.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=o.DOLLY;break;case u.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=o.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=o.ROTATE}break;case u.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=o.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=o.PAN}break;default:this.state=o.NONE}this.state!==o.NONE&&this.dispatchEvent(b)}function k(i){switch(this.state){case o.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case o.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case o.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function N(i){this.enabled===!1||this.enableZoom===!1||this.state!==o.NONE||(i.preventDefault(),this.dispatchEvent(b),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(M))}function Y(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function I(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case _.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=o.TOUCH_ROTATE;break;case _.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=o.TOUCH_PAN;break;default:this.state=o.NONE}break;case 2:switch(this.touches.TWO){case _.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=o.TOUCH_DOLLY_PAN;break;case _.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=o.TOUCH_DOLLY_ROTATE;break;default:this.state=o.NONE}break;default:this.state=o.NONE}this.state!==o.NONE&&this.dispatchEvent(b)}function U(i){switch(this._trackPointer(i),this.state){case o.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case o.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case o.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case o.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=o.NONE}}function Z(i){this.enabled!==!1&&i.preventDefault()}function z(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function K(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}export{X as O};
|