botmux 2.114.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/backend/riff-backend.d.ts +15 -0
- package/dist/adapters/backend/riff-backend.d.ts.map +1 -1
- package/dist/adapters/backend/riff-backend.js +9 -3
- package/dist/adapters/backend/riff-backend.js.map +1 -1
- package/dist/core/dashboard-ipc-server.js +2 -2
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/dashboard/compat.d.ts +19 -0
- package/dist/dashboard/compat.d.ts.map +1 -0
- package/dist/dashboard/compat.js +38 -0
- package/dist/dashboard/compat.js.map +1 -0
- package/dist/dashboard/stale-chunk-module.d.ts +3 -0
- package/dist/dashboard/stale-chunk-module.d.ts.map +1 -0
- package/dist/dashboard/stale-chunk-module.js +55 -0
- package/dist/dashboard/stale-chunk-module.js.map +1 -0
- package/dist/dashboard/web/app.d.ts.map +1 -1
- package/dist/dashboard/web/app.js +64 -2
- package/dist/dashboard/web/app.js.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.js +9 -7
- package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
- package/dist/dashboard/web/i18n.js +10 -10
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/sessions-page.js +2 -2
- package/dist/dashboard/web/sessions-page.js.map +1 -1
- package/dist/dashboard/web/stale-chunk-reload.d.ts +16 -0
- package/dist/dashboard/web/stale-chunk-reload.d.ts.map +1 -0
- package/dist/dashboard/web/stale-chunk-reload.js +51 -0
- package/dist/dashboard/web/stale-chunk-reload.js.map +1 -0
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/{bot-defaults-page-SRCBF7Z3.js → bot-defaults-page-MBORWWP7.js} +5 -5
- package/dist/dashboard-web/chunks/{chunk-3H6MVXXU.js → chunk-4QTBR7UF.js} +2 -2
- package/dist/dashboard-web/chunks/{chunk-77KD4TK2.js → chunk-7STGZ5BX.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-D2I5F4MY.js → chunk-EIO5AWDA.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-NGRUZCXP.js → chunk-G43RUPUN.js} +1 -1
- package/dist/dashboard-web/chunks/{connectors-page-RM3BJVMV.js → connectors-page-LKDT4WBG.js} +1 -1
- package/dist/dashboard-web/chunks/{groups-page-3D4YSYLA.js → groups-page-XKIWJ2TP.js} +1 -1
- package/dist/dashboard-web/chunks/{insights-page-CRFJKA54.js → insights-page-CBEZCYKV.js} +1 -1
- package/dist/dashboard-web/chunks/{monitor-room-HLK3XDT2.js → monitor-room-AQTHAWXA.js} +1 -1
- package/dist/dashboard-web/chunks/{monitoring-page-E3SNZFFN.js → monitoring-page-2R4NCNBQ.js} +1 -1
- package/dist/dashboard-web/chunks/{office-page-MKQ2TENK.js → office-page-5M6MQIIL.js} +1 -1
- package/dist/dashboard-web/chunks/{overview-page-ICFKKRLV.js → overview-page-N22HDZ2V.js} +1 -1
- package/dist/dashboard-web/chunks/{roles-page-2DFJ7YRU.js → roles-page-J6K2HWFX.js} +1 -1
- package/dist/dashboard-web/chunks/{schedules-page-S4WDIXH5.js → schedules-page-CGAQCB4J.js} +1 -1
- package/dist/dashboard-web/chunks/{sessions-page-4XWGUGB5.js → sessions-page-WJ2QYTIE.js} +2 -2
- package/dist/dashboard-web/chunks/{settings-page-OBTE4LYP.js → settings-page-GLRWV5KU.js} +1 -1
- package/dist/dashboard-web/chunks/{skills-page-CTRQJR47.js → skills-page-KQVW42QU.js} +1 -1
- package/dist/dashboard-web/chunks/{team-federation-page-GICLDKJP.js → team-federation-page-5PYUOV5M.js} +1 -1
- package/dist/dashboard-web/chunks/{v3-page-DI55IRL5.js → v3-page-DXPFILRZ.js} +1 -1
- package/dist/dashboard-web/chunks/{whiteboards-page-7KFWMILV.js → whiteboards-page-NUH6VZ4I.js} +1 -1
- package/dist/dashboard.js +26 -0
- package/dist/dashboard.js.map +1 -1
- package/dist/desktop/main/auto-start.d.ts +17 -0
- package/dist/desktop/main/auto-start.d.ts.map +1 -0
- package/dist/desktop/main/auto-start.js +37 -0
- package/dist/desktop/main/auto-start.js.map +1 -0
- package/dist/desktop/main/dashboard-compat.d.ts +25 -0
- package/dist/desktop/main/dashboard-compat.d.ts.map +1 -0
- package/dist/desktop/main/dashboard-compat.js +117 -0
- package/dist/desktop/main/dashboard-compat.js.map +1 -0
- package/dist/desktop/main/external-runtime.d.ts +29 -0
- package/dist/desktop/main/external-runtime.d.ts.map +1 -0
- package/dist/desktop/main/external-runtime.js +202 -0
- package/dist/desktop/main/external-runtime.js.map +1 -0
- package/dist/desktop/main/ipc.d.ts +20 -0
- package/dist/desktop/main/ipc.d.ts.map +1 -0
- package/dist/desktop/main/ipc.js +241 -0
- package/dist/desktop/main/ipc.js.map +1 -0
- package/dist/desktop/main/log-service.d.ts +4 -0
- package/dist/desktop/main/log-service.d.ts.map +1 -0
- package/dist/desktop/main/log-service.js +53 -0
- package/dist/desktop/main/log-service.js.map +1 -0
- package/dist/desktop/main/login-item.d.ts +10 -0
- package/dist/desktop/main/login-item.d.ts.map +1 -0
- package/dist/desktop/main/login-item.js +11 -0
- package/dist/desktop/main/login-item.js.map +1 -0
- package/dist/desktop/main/node-command.d.ts +22 -0
- package/dist/desktop/main/node-command.d.ts.map +1 -0
- package/dist/desktop/main/node-command.js +56 -0
- package/dist/desktop/main/node-command.js.map +1 -0
- package/dist/desktop/main/paths.d.ts +11 -0
- package/dist/desktop/main/paths.d.ts.map +1 -0
- package/dist/desktop/main/paths.js +13 -0
- package/dist/desktop/main/paths.js.map +1 -0
- package/dist/desktop/main/pm2-apps.d.ts +15 -0
- package/dist/desktop/main/pm2-apps.d.ts.map +1 -0
- package/dist/desktop/main/pm2-apps.js +97 -0
- package/dist/desktop/main/pm2-apps.js.map +1 -0
- package/dist/desktop/main/runtime-service.d.ts +49 -0
- package/dist/desktop/main/runtime-service.d.ts.map +1 -0
- package/dist/desktop/main/runtime-service.js +297 -0
- package/dist/desktop/main/runtime-service.js.map +1 -0
- package/dist/desktop/main/runtime-source.d.ts +17 -0
- package/dist/desktop/main/runtime-source.d.ts.map +1 -0
- package/dist/desktop/main/runtime-source.js +61 -0
- package/dist/desktop/main/runtime-source.js.map +1 -0
- package/dist/desktop/main/tray.d.ts +10 -0
- package/dist/desktop/main/tray.d.ts.map +1 -0
- package/dist/desktop/main/tray.js +27 -0
- package/dist/desktop/main/tray.js.map +1 -0
- package/dist/desktop/main/window.d.ts +16 -0
- package/dist/desktop/main/window.d.ts.map +1 -0
- package/dist/desktop/main/window.js +113 -0
- package/dist/desktop/main/window.js.map +1 -0
- package/dist/desktop/main.d.ts +2 -0
- package/dist/desktop/main.d.ts.map +1 -0
- package/dist/desktop/main.js +175 -0
- package/dist/desktop/main.js.map +1 -0
- package/dist/desktop/preload.d.ts +2 -0
- package/dist/desktop/preload.d.ts.map +1 -0
- package/dist/desktop/preload.js +24 -0
- package/dist/desktop/preload.js.map +1 -0
- package/dist/desktop/renderer/app.d.ts +35 -0
- package/dist/desktop/renderer/app.d.ts.map +1 -0
- package/dist/desktop/renderer/app.js +945 -0
- package/dist/desktop/renderer/app.js.map +1 -0
- package/dist/desktop/renderer/dashboard-url.d.ts +13 -0
- package/dist/desktop/renderer/dashboard-url.d.ts.map +1 -0
- package/dist/desktop/renderer/dashboard-url.js +98 -0
- package/dist/desktop/renderer/dashboard-url.js.map +1 -0
- package/dist/desktop/renderer/runtime-state.d.ts +8 -0
- package/dist/desktop/renderer/runtime-state.d.ts.map +1 -0
- package/dist/desktop/renderer/runtime-state.js +67 -0
- package/dist/desktop/renderer/runtime-state.js.map +1 -0
- package/dist/desktop/shared/types.d.ts +48 -0
- package/dist/desktop/shared/types.d.ts.map +1 -0
- package/dist/desktop/shared/types.js +2 -0
- package/dist/desktop/shared/types.js.map +1 -0
- package/dist/desktop/smoke.d.ts +28 -0
- package/dist/desktop/smoke.d.ts.map +1 -0
- package/dist/desktop/smoke.js +258 -0
- package/dist/desktop/smoke.js.map +1 -0
- package/dist/utils/version-info.d.ts +25 -0
- package/dist/utils/version-info.d.ts.map +1 -0
- package/dist/utils/version-info.js +48 -0
- package/dist/utils/version-info.js.map +1 -0
- package/package.json +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as w}from"./chunk-
|
|
1
|
+
import{b as w}from"./chunk-EIO5AWDA.js";import"./chunk-4QTBR7UF.js";import{a as p}from"./chunk-SYC6D5XU.js";import{a as S,d as x}from"./chunk-5THX4DI2.js";import{c as g}from"./chunk-7SZRL6FY.js";var n=g(S(),1);var e=g(x(),1),u=78222186;function y(t){return(t/1048576).toFixed(0)}function T(){let t=w(),[i,a]=(0,n.useState)(null),[c,l]=(0,n.useState)(""),[m,h]=(0,n.useState)(!1),d=(0,n.useRef)(null),r=(0,n.useRef)(!1),v=()=>{d.current&&(clearTimeout(d.current),d.current=null)};async function f(){if(!r.current)try{let s=await fetch("/api/game/status");if(r.current)return;if(!s.ok){a({state:"absent",received:0,total:u});return}let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch{r.current||(d.current=setTimeout(()=>{f()},1500))}}(0,n.useEffect)(()=>(r.current=!1,f(),()=>{r.current=!0,v()}),[]);async function b(){v(),h(!0),a({state:"downloading",received:0,total:u});try{let s=await fetch("/api/game/download",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({proxy:c.trim()})});if(r.current)return;if(!s.ok)throw new Error(`HTTP ${s.status}`);let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch(s){if(r.current)return;a({state:"error",received:0,total:u,error:s instanceof Error?s.message:String(s)})}finally{r.current||h(!1)}}return i?.state==="ready"?(0,e.jsx)("div",{className:"office-frame-shell",children:(0,e.jsx)("iframe",{className:"office-game-frame",src:"/game/index.html",title:"HD2D Office",allow:"autoplay"})}):(0,e.jsx)(P,{status:i??{state:"absent",received:0,total:u},title:t("nav.office"),proxy:c,starting:m,onProxyChange:l,onStart:()=>{b()}})}function P(t){let i=t.status.total||u,a=(0,n.useMemo)(()=>i?Math.min(100,Math.round(t.status.received/i*100)):0,[t.status.received,i]),c=t.status.state==="downloading",l=t.status.state==="error";return(0,e.jsxs)("div",{style:{margin:"auto",textAlign:"center",maxWidth:440,padding:32,color:"var(--fg,#e6e6e6)"},children:[(0,e.jsx)("h1",{style:{fontSize:18,fontWeight:600,lineHeight:1.2,margin:"0 0 8px"},children:t.title}),(0,e.jsxs)("div",{style:{fontSize:13,opacity:.7,lineHeight:1.7,marginBottom:20},children:["\u628A\u6BCF\u4E2A\u4F1A\u8BDD\u53D8\u6210\u529E\u516C\u5BA4\u91CC\u7684\u4E00\u4E2A\u673A\u5668\u4EBA\uFF0C\u5B9E\u65F6\u6620\u5C04\u5C4F\u5E55\u72B6\u6001\u3002",(0,e.jsx)("br",{}),"\u9996\u6B21\u8FDB\u5165\u9700\u4E0B\u8F7D\u7EA6 ",y(i)," MB \u6E38\u620F\u8D44\u6E90\uFF08\u4EC5\u4E00\u6B21\uFF0C\u4E4B\u540E\u672C\u5730\u7F13\u5B58\uFF09\u3002"]}),l?(0,e.jsxs)("div",{style:{color:"#e06c75",fontSize:12,marginBottom:14},children:["\u4E0A\u6B21\u4E0B\u8F7D\u5931\u8D25\uFF1A",t.status.error??"\u672A\u77E5\u9519\u8BEF",(0,e.jsx)("br",{}),(0,e.jsx)("span",{style:{opacity:.7},children:"\u586B\u4EE3\u7406\u540E\u70B9\u91CD\u8BD5"})]}):null,c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{background:"var(--surface-muted)",borderRadius:"var(--radius-lg)",height:10,overflow:"hidden",marginBottom:10},children:(0,e.jsx)("div",{style:{height:"100%",width:`${a}%`,background:"var(--accent)",transition:"width .3s"}})}),(0,e.jsxs)("div",{style:{fontSize:12,opacity:.7},children:["\u4E0B\u8F7D\u4E2D... ",y(t.status.received)," / ",y(i)," MB\uFF08",a,"%\uFF09"]})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("input",{id:"hd2d-proxy",className:"office-proxy-input",type:"text",value:t.proxy,onChange:m=>t.onProxyChange(m.currentTarget.value),placeholder:"HTTP \u4EE3\u7406\uFF08\u53EF\u9009\uFF0C\u5982 http://127.0.0.1:7890\uFF09"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.5,marginBottom:14,textAlign:"left"},children:"\u8FDE\u4E0D\u4E0A GitHub \u65F6\u586B\u4EE3\u7406\uFF08\u4EC5\u7528\u4E8E\u4E0B\u8F7D\u672C\u8D44\u6E90\uFF0C\u4F1A\u8BB0\u4F4F\uFF09\u3002\u7559\u7A7A\u8D70\u76F4\u8FDE/\u7CFB\u7EDF\u4EE3\u7406\u73AF\u5883\u53D8\u91CF\u3002"}),(0,e.jsxs)("button",{id:"hd2d-load",type:"button",className:"page-primary-action office-load-button",disabled:t.starting,onClick:t.onStart,children:[l?"\u91CD\u8BD5":"\u52A0\u8F7D\u529E\u516C\u5BA4","\uFF08\u7EA6 ",y(i)," MB\uFF09"]})]})]})}function B(t){let i={maxWidth:t.style.maxWidth,padding:t.style.padding,flex:t.style.flex,minHeight:t.style.minHeight,minWidth:t.style.minWidth,display:t.style.display,overflow:t.style.overflow};t.style.maxWidth="none",t.style.padding="0",t.style.flex="1 1 auto",t.style.minHeight="0",t.style.minWidth="0",t.style.display="flex",t.style.overflow="hidden";let a=p(t,(0,e.jsx)(T,{}));return()=>{a(),t.style.maxWidth=i.maxWidth,t.style.padding=i.padding,t.style.flex=i.flex,t.style.minHeight=i.minHeight,t.style.minWidth=i.minWidth,t.style.display=i.display,t.style.overflow=i.overflow}}export{B as renderOfficePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Q,b as j}from"./chunk-
|
|
1
|
+
import{a as Q,b as j}from"./chunk-7STGZ5BX.js";import{a as J,b as A}from"./chunk-EIO5AWDA.js";import{b as H,d as M,e as T,f as O,j as W,l as x,m as I,n as P,o as X,q as G}from"./chunk-I35DXGM4.js";import{A as $,C,D as q,E as y,F as f,G as h,u as L,w as k}from"./chunk-4QTBR7UF.js";import{a as V}from"./chunk-SYC6D5XU.js";import{a as ae,d as K}from"./chunk-5THX4DI2.js";import{c as R}from"./chunk-7SZRL6FY.js";var r=R(ae(),1);var t=R(K(),1),re=new Set(["working","analyzing","active","starting"]),le=new Set(["idle","dormant"]),ee="botmux.overview.teamExpanded",te="botmux.overview.activeSort",_=5,z=1,ce=260;function ve(){try{return window.localStorage.getItem(ee)==="1"}catch{return!1}}function de(e){try{window.localStorage.setItem(ee,e?"1":"0")}catch{}}function me(e){return e==="attention"?"attention":"time"}function ue(){try{return me(window.localStorage.getItem(te))}catch{return"time"}}function we(e){try{window.localStorage.setItem(te,e)}catch{}}function pe(e,s){let o=(i,a)=>Number(a.lastMessageAt??0)-Number(i.lastMessageAt??0);return s==="attention"?[...e].sort((i,a)=>{let m=f(i)?0:1,l=f(a)?0:1;if(m!==l)return m-l;if(m===0){let p=h(i)-h(a);if(p!==0)return p}return o(i,a)}):[...e].sort(o)}function fe(e){return String(e??"unknown").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function ge(e,s){let o=String(e??"unknown"),i=`sessions.status.${o}`,a=s(i);return a===i?o:a}function Se(e){if(!e)return z*_;let s=window.getComputedStyle(e).gridTemplateColumns.split(/\s+/).filter(i=>Number.parseFloat(i)>0);return Math.max(1,s.length||_)*z}function be(e,s){if(!e)return;let o=document.querySelector(".sidebar");if(!o||window.matchMedia("(max-width: 980px)").matches){e.style.removeProperty(s);return}let i=o.getBoundingClientRect().bottom,a=e.getBoundingClientRect().top,l=`${Math.max(ce,Math.round(i-a))}px`;e.style.getPropertyValue(s)!==l&&e.style.setProperty(s,l)}function he({card:e}){let s=A(),o=!e.online&&e.active.length===0,i=e.attention.length>0,a=e.busy.length>0,m=i?"warn":a?"busy":o?"off":"ok",l;if(i){let v=[...e.attention].sort((g,S)=>h(g)-h(S))[0];l=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:(y(v.title)||v.sessionId).slice(0,60)})," \xB7 ",f(v)??""]})}else if(a){let v=[...e.busy].sort((g,S)=>Number(S.lastMessageAt??0)-Number(g.lastMessageAt??0))[0];l=(0,t.jsx)("b",{children:(y(v.title)||v.sessionId).slice(0,60)})}else o?l=s("overview.botOffline"):l=s("overview.botIdle");let p=i?(0,t.jsx)("span",{className:"tag tag-warn",children:s("overview.botNeedsYou")}):a?(0,t.jsx)("span",{className:"tag tag-run",children:s("overview.botBusy",{count:e.busy.length})}):o?(0,t.jsx)("span",{className:"tag tag-off",children:s("overview.botOff")}):(0,t.jsx)("span",{className:"tag tag-ok",children:s("overview.botReady")});return(0,t.jsxs)("article",{className:`mate${i?" mate-attn":""}${o?" mate-off":""}`,children:[(0,t.jsxs)("div",{className:"mate-top",children:[(0,t.jsx)(H,{html:k({name:e.botName,larkAppId:e.larkAppId,avatarUrl:e.botAvatarUrl,dot:m})}),(0,t.jsxs)("div",{className:"mate-id",children:[(0,t.jsx)("b",{children:e.botName}),(0,t.jsx)("span",{className:"mate-role",children:e.cliId})]})]}),(0,t.jsx)("div",{className:"mate-task",children:l}),(0,t.jsxs)("div",{className:"mate-foot",children:[p,(0,t.jsx)("span",{children:e.lastActiveAt?s("overview.lastActive",{time:L(e.lastActiveAt)}):s("common.never")})]})]})}function Ae({session:e}){let s=A(),o=C(e),i=String(e.status??"unknown"),a=f(e);return(0,t.jsxs)(I,{kind:"session",children:[(0,t.jsx)(H,{html:k({name:o,larkAppId:e.larkAppId,size:"sm"})}),(0,t.jsxs)(P,{children:[(0,t.jsx)("b",{children:(y(e.title)||e.sessionId).slice(0,64)}),(0,t.jsxs)("span",{children:[o," \xB7 ",q(e)??e.cliId??"unknown"," \xB7 ",L(e.lastMessageAt)]})]}),(0,t.jsx)(X,{children:a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("a",{className:"overview-list-action",href:"#/sessions",children:s("strip.handle")}),(0,t.jsx)("span",{className:"status overview-list-status status-attention",children:a})]}):(0,t.jsx)("span",{className:`status overview-list-status status-${fe(i)}`,children:ge(i,s)})})]})}function Ne({schedule:e,timeZone:s}){let o=e.nextRunAt?new Date(e.nextRunAt).toLocaleString(void 0,s?{timeZone:s,timeZoneName:"short"}:void 0):"-";return(0,t.jsxs)(I,{kind:"schedule",children:[(0,t.jsxs)(P,{children:[(0,t.jsx)("strong",{children:e.name??e.id}),(0,t.jsxs)("span",{children:[C(e)," \xB7 ",e.parsed?.display??""]})]}),(0,t.jsx)("span",{className:"overview-list-meta",children:(0,t.jsx)(W,{text:o,showPopover:!1,durationMs:2600})})]})}function ye({mode:e,onModeChange:s}){let o=A(),i=o(e==="attention"?"overview.sortAttentionFirst":"overview.sortByTime");return(0,t.jsx)(G,{className:"overview-active-sort-menu",label:i,value:e,options:[{value:"time",label:o("overview.sortByTime")},{value:"attention",label:o("overview.sortAttentionFirst")}],onChange:s})}function Me(){let e=A(),s=(0,r.useRef)(null),o=(0,r.useRef)(null),i=(0,r.useRef)(null),[a,m]=(0,r.useState)(ve),[l,p]=(0,r.useState)(ue),[v,g]=(0,r.useState)(z*_),[S,D]=(0,r.useState)(0),{sessions:N,schedules:B,scheduleTimeZone:ne}=J(n=>({sessions:[...n.sessions.values()],schedules:[...n.schedules.values()],scheduleTimeZone:n.scheduleTimeZone}));(0,r.useEffect)(()=>{let n=0,d=()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let w=Se(s.current);g(c=>c===w?c:w)})};d();let u=typeof ResizeObserver>"u"||!s.current?null:new ResizeObserver(d);return u&&s.current&&u.observe(s.current),window.addEventListener("resize",d),()=>{window.cancelAnimationFrame(n),u?.disconnect(),window.removeEventListener("resize",d)}},[]),(0,r.useEffect)(()=>{Q().then(()=>D(n=>n+1)),$().then(()=>D(n=>n+1))},[]);let F=(0,r.useMemo)(()=>N.filter(n=>n.status!=="closed"),[N]),b=(0,r.useMemo)(()=>j(N),[N,S]),U=a?b:b.slice(0,v),Y=(0,r.useMemo)(()=>pe(F.filter(n=>f(n)||re.has(n.status)||le.has(n.status)),l).slice(0,7),[F,l]),E=(0,r.useMemo)(()=>B.filter(n=>n.nextRunAt).sort((n,d)=>Date.parse(n.nextRunAt)-Date.parse(d.nextRunAt)).slice(0,5),[B]);(0,r.useEffect)(()=>{let n=[{el:o.current,propertyName:"--active-sessions-min-height"},{el:i.current,propertyName:"--schedules-panel-min-height"}].filter(c=>!!c.el);if(!n.length)return;let d=0,u=()=>{window.cancelAnimationFrame(d),d=window.requestAnimationFrame(()=>{for(let c of n)be(c.el,c.propertyName)})};u();let w=typeof ResizeObserver>"u"?null:new ResizeObserver(u);if(w){for(let ie of n)w.observe(ie.el);let c=document.querySelector(".sidebar"),Z=n[0].el.closest(".page");c&&w.observe(c),Z&&w.observe(Z)}return window.addEventListener("resize",u),()=>{window.cancelAnimationFrame(d),w?.disconnect(),window.removeEventListener("resize",u);for(let c of n)c.el.style.removeProperty(c.propertyName)}},[a,v,b.length,E.length]);let se=()=>{m(n=>(de(!n),!n))},oe=n=>{p(n),we(n)};return(0,t.jsxs)("section",{className:"page hero-page",children:[(0,t.jsx)("div",{className:"page-heading",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"eyebrow",children:e("app.subtitle")}),(0,t.jsx)("h1",{children:e("overview.title")})]})}),(0,t.jsxs)("div",{className:"overview-layout",children:[(0,t.jsxs)("div",{className:"overview-main",children:[(0,t.jsxs)("section",{className:"overview-block team-section",children:[(0,t.jsx)(M,{title:e("overview.team"),count:e("overview.teamCount",{count:b.length}),hint:e("overview.teamHint"),children:(0,t.jsx)(O,{children:(0,t.jsx)(T,{href:"#/bot-defaults",children:e("overview.viewAllPlain")})})}),(0,t.jsx)("div",{className:"team-grid",id:"team-grid",ref:s,children:U.length?U.map(n=>(0,t.jsx)(he,{card:n},n.larkAppId??n.botName)):(0,t.jsx)("div",{className:"empty",children:e("overview.noSessions")})}),b.length>v?(0,t.jsx)("button",{type:"button",className:"team-toggle",id:"team-toggle",onClick:se,children:e(a?"overview.teamCollapse":"overview.teamExpand")}):null]}),(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(M,{title:e("overview.activeSessions"),children:(0,t.jsxs)(O,{children:[(0,t.jsx)(ye,{mode:l,onModeChange:oe}),(0,t.jsx)(T,{href:"#/sessions",children:e("overview.viewAllPlain")})]})}),(0,t.jsx)("section",{className:"panel active-sessions-panel",ref:o,children:(0,t.jsx)(x,{id:"recent-sessions",children:Y.length?Y.map(n=>(0,t.jsx)(Ae,{session:n},n.sessionId)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSessions")})})})]})]}),(0,t.jsx)("aside",{className:"overview-side",children:(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(M,{title:e("overview.nextSchedules"),children:(0,t.jsx)(T,{href:"#/schedules",children:e("overview.viewAllPlain")})}),(0,t.jsx)("section",{className:"panel schedules-panel",ref:i,children:(0,t.jsx)(x,{id:"next-schedules",children:E.length?E.map(n=>(0,t.jsx)(Ne,{schedule:n,timeZone:ne},n.id)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSchedules")})})})]})})]})]})}function Ce(e){e.classList.add("overview-root");let s=V(e,(0,t.jsx)(Me,{}));return()=>{s(),e.classList.remove("overview-root")}}export{Ce as renderOverviewPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Oe,b as He,c as Ve,d as _e}from"./chunk-R3FXBFQH.js";import{b as Ue}from"./chunk-D2I5F4MY.js";import{b as Fe,c as ne,h as le,p as se}from"./chunk-I35DXGM4.js";import{A as $e,w as je}from"./chunk-3H6MVXXU.js";import{a as re}from"./chunk-SYC6D5XU.js";import{a as Jt,d as De}from"./chunk-5THX4DI2.js";import{c as oe}from"./chunk-7SZRL6FY.js";var l=oe(Jt(),1);var w=32768,Je=Math.floor(w*.95),Kt=/^[A-Za-z0-9._-]{1,64}$/;function ae(n){return Kt.test(n)&&n!=="."&&n!==".."}function Ke(n=location.hash){let[,t=""]=n.split("?");return new URLSearchParams(t).get("chatId")?.trim()||null}function ie(n,t){return Ve(n,t)}function de(n){return new TextEncoder().encode(n).length}function ce(n){return n.memberBots.filter(t=>t.inChat&&t.hasRole).length}function We(n){return n.memberBots.filter(t=>t.inChat).length}function D(n,t){return t?n.find(o=>o.larkAppId===t):void 0}function qe(n,t){let o=t.toLowerCase();return o?n.filter(i=>{let d=i.chatId.toLowerCase().includes(o)||(i.name??"").toLowerCase().includes(o),y=i.memberBots.some(p=>p.larkAppId.toLowerCase().includes(o)||(p.botName??"").toLowerCase().includes(o));return d||y}):n}function Ye(n,t){let o=t.toLowerCase();return n.filter(i=>!o||i.profileId.toLowerCase().includes(o))}async function C(n){return n.json().catch(()=>({}))}async function ze(){let n=await fetch("/api/groups"),t=await C(n);return{bots:(t.bots??[]).map(o=>({larkAppId:o.larkAppId,botName:o.botName??o.larkAppId,botAvatarUrl:o.botAvatarUrl})),groups:(t.chats??[]).map(o=>({chatId:o.chatId,name:o.name??o.chatId,memberBots:(o.memberBots??[]).map(i=>({larkAppId:i.larkAppId,botName:i.botName??i.larkAppId,inChat:i.inChat??!1,hasRole:i.hasRole??!1,oncallChat:i.oncallChat??null}))}))}}async function Xe(){let n=await fetch("/api/role-profiles");return(await C(n)).profiles??[]}async function x(n){let t=await fetch(`/api/role-profiles/${encodeURIComponent(n)}`);return(await C(t)).entries??[]}async function pe(n,t){let o=await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`);return C(o)}async function Ze(n,t,o,i){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:o,injectMode:i})})).ok}async function Qe(n,t,o){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({injectMode:o})})).ok}async function et(n,t){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"DELETE"})).ok}async function tt(n,t){let o=await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`);return C(o)}async function ot(n,t,o){return(await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:o,allowEmpty:!0})})).ok}async function rt(n,t){return(await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"DELETE"})).ok}async function nt(n,t){let o=await Promise.all(t.map(async p=>{try{let c=await fetch(`/api/role-profiles/${encodeURIComponent(p.profileId)}`),f=await C(c);return[p.profileId,Array.isArray(f.entries)?f.entries:[]]}catch{return[p.profileId,[]]}})),i=new Set,d=[];for(let p of n)for(let c of p.memberBots){if(!c.inChat||!c.hasRole)continue;let f=ie(c.larkAppId,p.chatId);i.has(f)||(i.add(f),d.push({larkAppId:c.larkAppId,chatId:p.chatId}))}let y=await _e(d);return{entriesByProfile:new Map(o),effectiveRolesByBot:y}}async function lt(n){let t=await fetch(`/api/role-profiles/${encodeURIComponent(n.profileId)}/apply`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({chatId:n.chatId,larkAppId:n.larkAppId,force:n.force,preview:n.preview})}),o=await C(t);return{larkAppId:n.larkAppId,ok:t.ok&&o.ok!==!1,status:t.status,error:o.error,wouldRefuse:o.wouldRefuse}}var e=oe(De(),1);function Wt(){let n=(0,l.useRef)(!0);return(0,l.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]),n}function qt(){let n=(0,l.useRef)(new Set);return(0,l.useEffect)(()=>()=>{for(let t of n.current)window.clearTimeout(t);n.current.clear()},[]),(0,l.useCallback)((t,o)=>{let i=window.setTimeout(()=>{n.current.delete(i),t()},o);return n.current.add(i),i},[])}function it(n){return(0,e.jsx)(Fe,{html:je({name:n.bot.botName,larkAppId:n.bot.larkAppId,avatarUrl:n.bot.botAvatarUrl,size:"sm"})})}function dt(n){let t=Ue(),o=Wt(),i=qt(),[d,y]=(0,l.useState)([]),[p,c]=(0,l.useState)([]),[f,P]=(0,l.useState)([]),[ct,ue]=(0,l.useState)({entriesByProfile:new Map,effectiveRolesByBot:new Map}),[pt,F]=(0,l.useState)(!1),[ft,J]=(0,l.useState)(!0),[ut,K]=(0,l.useState)(!0),[W,mt]=(0,l.useState)(""),[q,vt]=(0,l.useState)(""),[ht,me]=(0,l.useState)(()=>new Set),[v,ve]=(0,l.useState)(null),[h,he]=(0,l.useState)(null),[yt,U]=(0,l.useState)(null),[R,O]=(0,l.useState)(""),[S,E]=(0,l.useState)("every"),[ye,ge]=(0,l.useState)(!1),[Ie,be]=(0,l.useState)(!1),[gt,Pe]=(0,l.useState)(!1),[It,Y]=(0,l.useState)(null),[bt,Re]=(0,l.useState)(null),[m,Pt]=(0,l.useState)(null),[I,ke]=(0,l.useState)(null),[B,M]=(0,l.useState)([]),[L,H]=(0,l.useState)(""),[k,G]=(0,l.useState)(null),[Ne,Rt]=(0,l.useState)(!1),[we,Ce]=(0,l.useState)(()=>new Set),[Ae,xe]=(0,l.useState)(!1),[Se,Ee]=(0,l.useState)(!1),[kt,z]=(0,l.useState)(null),[Nt,T]=(0,l.useState)({kind:"idle"}),Be=(0,l.useRef)(0),j=(0,l.useRef)(0),Me=(0,l.useRef)(null),X=v?d.find(r=>r.chatId===v):void 0,wt=X&&h?X.memberBots.find(r=>r.larkAppId===h):void 0,Z=I?p.find(r=>r.larkAppId===I):void 0,Ct=D(B,I),Q=k?d.find(r=>r.chatId===k):void 0,V=Q?.memberBots.filter(r=>r.inChat)??[],At=V.map(r=>r.larkAppId).join("\0"),xt=B.map(r=>r.larkAppId).sort().join("\0"),St=(0,l.useMemo)(()=>qe(d,W),[d,W]),Et=(0,l.useMemo)(()=>Ye(f,q),[f,q]),ee=de(R),te=de(L),_=(0,l.useCallback)((r,s,a=!1)=>{let u=Date.now()+Math.random();r({text:s,isError:a,id:u}),i(()=>{r(g=>g?.id===u?null:g)},a?3e3:2e3)},[i]),b=(0,l.useCallback)(async(r,s)=>{try{let a=await nt(r,s);if(!o.current)return;ue(a),F(!0)}catch{if(!o.current)return;ue({entriesByProfile:new Map,effectiveRolesByBot:new Map}),F(!0)}},[o]),N=(0,l.useCallback)(async()=>{let r=await ze();return o.current&&(y(r.groups),c(r.bots)),r},[o]),$=(0,l.useCallback)(async()=>{let r=await Xe();return o.current&&P(r),r},[o]),Le=(0,l.useCallback)(async()=>{J(!0),K(!0),F(!1);try{let r=await N();if(!o.current)return;let s=await $();if(!o.current||(await $e(),!o.current))return;if(me(new Set(r.groups.filter(a=>ce(a)>0).map(a=>a.chatId))),n.tab==="profiles"){let a=Ke();G(u=>u||(a&&r.groups.some(g=>g.chatId===a)?a:r.groups[0]?.chatId??null))}else G(a=>a??r.groups[0]?.chatId??null);J(!1),K(!1),b(r.groups,s)}catch{if(!o.current)return;J(!1),K(!1),F(!0)}},[o,n.tab,N,$,b]);(0,l.useEffect)(()=>{Le()},[Le]),(0,l.useEffect)(()=>{k||d.length===0||G(d[0].chatId)},[d,k]),(0,l.useEffect)(()=>{let r=new Set(V.filter(s=>!!D(B,s.larkAppId)).map(s=>s.larkAppId));Ce(r),T({kind:"idle"})},[xt,At]);async function Bt(r,s){let a=++Be.current;ve(r),he(s);let u=await pe(s,r);!o.current||a!==Be.current||(U(u),O(u.content??""),E(u.injectMode==="once"?"once":"every"),Y(null),Re(null))}async function Mt(){let r=await N();if(o.current&&(b(r.groups,f),v&&h)){let s=await pe(h,v);if(!o.current)return;U(s),O(s.content??""),E(s.injectMode==="once"?"once":"every")}}async function Lt(){if(!(!v||!h)){ge(!0);try{let r=await Ze(h,v,R,S);if(!o.current)return;if(r){let s=await N();if(!o.current)return;U(a=>a&&{...a,content:R,hasRole:!0,injectMode:S}),b(s.groups,f),_(Y,t("roles.saved"))}else _(Y,R.trim().length===0?t("roles.emptyError"):t("roles.saveFailed"),!0)}finally{o.current&&ge(!1)}}}async function Gt(){if(!(!v||!h)&&confirm(t("roles.confirmDelete"))){be(!0);try{let r=await et(h,v);if(!o.current)return;if(r){let s=await N();if(!o.current)return;ve(null),he(null),U(null),O(""),E("every"),b(s.groups,f)}}finally{o.current&&be(!1)}}}async function Tt(r){if(!v||!h)return;let s=S;E(r),Pe(!0);try{let a=await Qe(h,v,r);if(!o.current)return;a||E(s),_(Re,t(a?"roles.saved":"roles.saveFailed"),!a)}finally{o.current&&Pe(!1)}}async function Ge(r){let s=r.trim();if(!ae(s))return;let a=++j.current;Pt(s),ke(null),H(""),T({kind:"idle"}),G(g=>g??d[0]?.chatId??null);let u=await x(s);!o.current||a!==j.current||(M(u),z(null))}async function jt(r){if(!m)return;let s=++j.current;ke(r);let a=await tt(m,r);if(!o.current||s!==j.current)return;H(a.content??"");let u=await x(m);!o.current||s!==j.current||(M(u),z(null))}async function $t(){let r=await N();if(!o.current)return;let s=await $();if(o.current){if(m){let a=await x(m);if(!o.current)return;M(a)}b(r.groups,s)}}async function Dt(){let r=Me.current,s=r?.value.trim()??"";if(s){if(!ae(s)){r?.setCustomValidity(t("roles.profileIdInvalid")),r?.reportValidity();return}r?.setCustomValidity(""),await Ge(s),o.current&&(location.hash.startsWith("#/roles/profile")||(location.hash="#/roles/profile"))}}async function Ft(){if(!(!m||!I)){xe(!0);try{let r=await ot(m,I,L);if(!o.current)return;let s=await $();if(!o.current)return;let a=await x(m);if(!o.current)return;M(a),b(d,s),_(z,t(r?"roles.saved":"roles.saveFailed"),!r)}finally{o.current&&xe(!1)}}}async function Ut(){if(!(!m||!I)&&confirm(t("roles.confirmDeleteProfileEntry"))){Ee(!0);try{if(await rt(m,I),!o.current)return;H("");let r=await $();if(!o.current)return;let s=await x(m);if(!o.current)return;M(s),b(d,r)}finally{o.current&&Ee(!1)}}}function Ot(r,s){Ce(a=>{let u=new Set(a);return s?u.add(r):u.delete(r),u})}async function Te(r){if(!m)return;let s=k??d[0]?.chatId;if(!s)return;let a=[...we];if(a.length===0){T({kind:"text",text:t("roles.applyPickBots")});return}T({kind:"text",text:"..."});let u=await Promise.all(a.map(g=>lt({profileId:m,chatId:s,larkAppId:g,force:Ne,preview:r})));if(o.current&&(T({kind:"results",preview:r,results:u}),!r)){let g=await N();if(!o.current)return;b(g.groups,f)}}let Ht=ye||ee>w||R.trim().length===0,Vt=Ae||te>w||L.trim().length===0,A=n.tab==="profiles",_t=(0,e.jsxs)("nav",{className:"roles-subnav insight-tabs",role:"tablist","aria-label":t("roles.title"),children:[(0,e.jsx)("a",{href:"#/roles",className:`itab${A?"":" on"}`,role:"tab","aria-selected":!A,children:t("roles.tabGroups")}),(0,e.jsx)("a",{href:"#/roles/profile",className:`itab${A?" on":""}`,role:"tab","aria-selected":A,children:t("roles.tabProfiles")})]});return(0,e.jsxs)("section",{className:"page roles-page",children:[(0,e.jsxs)("div",{className:"page-heading roles-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("nav.roles")}),(0,e.jsx)("h1",{children:t("roles.title")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:_t})]}),(0,e.jsxs)("div",{id:"roles-by-group-view",className:"roles-layout",hidden:A,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-search",placeholder:t("roles.search"),value:W,onChange:r=>mt(r.target.value)}),(0,e.jsx)(le,{id:"roles-refresh",label:t("roles.refresh"),onClick:()=>{Mt()}})]}),(0,e.jsx)("div",{id:"roles-tree",className:"roles-tree",children:ft?(0,e.jsx)(ne,{label:t("common.loading")}):(0,e.jsx)(zt,{groups:St,profiles:f,context:ct,contextLoaded:pt,expandedGroups:ht,selectedGroupId:v,selectedBotId:h,tr:t,onToggleGroup:r=>me(s=>Yt(s,r)),onSelectBot:(r,s)=>{Bt(r,s)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:!v||!h?(0,e.jsx)("div",{id:"roles-editor-empty",className:"roles-editor-empty",children:t("roles.selectHint")}):(0,e.jsxs)("div",{id:"roles-editor-form",className:"roles-editor-form",children:[(0,e.jsxs)("div",{className:"roles-editor-head",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{id:"roles-editor-group-name",children:X?.name??v}),(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{id:"roles-editor-bot-name",children:wt?.botName??h})]}),(0,e.jsx)("div",{className:"roles-editor-meta",children:(0,e.jsxs)("span",{id:"roles-editor-chat-id",className:"roles-editor-meta-line",children:[v," \xB7 ",h]})})]}),(0,e.jsxs)("div",{className:"roles-editor-actions roles-editor-head-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-delete",className:"danger",style:{display:yt?.hasRole?"":"none"},disabled:Ie,onClick:()=>{Gt()},children:Ie?"...":t("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-save",className:"primary",disabled:Ht,onClick:()=>{Lt()},children:ye?"...":t("roles.save")})]})]}),(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:t("roles.injectModeLabel")}),(0,e.jsx)(se,{id:"roles-editor-inject-mode",className:"roles-inline-menu",ariaLabel:t("roles.injectModeLabel"),disabled:gt,label:t(S==="once"?"roles.injectModeOnce":"roles.injectModeEvery"),value:S,options:[{value:"every",label:t("roles.injectModeEvery")},{value:"once",label:t("roles.injectModeOnce")}],onChange:r=>{Tt(r==="once"?"once":"every")}}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:t("roles.injectModeHint")}),(0,e.jsx)(fe,{flash:bt})]}),(0,e.jsx)("textarea",{id:"roles-editor-textarea",placeholder:t("roles.editorPlaceholder"),rows:14,value:R,onChange:r=>O(r.target.value)}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-editor-bytecount",className:st(ee),children:[ee," / ",w," bytes"]}),(0,e.jsx)(fe,{flash:It})]}),(0,e.jsx)(at,{content:R,tr:t,id:"roles-preview"})]})})]}),(0,e.jsxs)("div",{id:"roles-profiles-view",className:"roles-layout roles-profiles-layout",hidden:!A,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header roles-profile-create dashboard-toolbar",children:[(0,e.jsx)("input",{type:"text",id:"roles-profile-id",placeholder:t("roles.profileIdPlaceholder"),maxLength:64,ref:Me,onChange:r=>r.currentTarget.setCustomValidity("")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-select",onClick:()=>{Dt()},children:t("roles.openProfile")})]}),(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-profile-search",placeholder:t("roles.profileSearch"),value:q,onChange:r=>vt(r.target.value)}),(0,e.jsx)(le,{id:"roles-profile-refresh",label:t("roles.refresh"),onClick:()=>{$t()}})]}),(0,e.jsx)("div",{id:"roles-profile-list",className:"roles-tree",children:ut?(0,e.jsx)(ne,{label:t("common.loading")}):(0,e.jsx)(Zt,{profiles:Et,selectedProfileId:m,tr:t,onSelect:r=>{Ge(r)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:m?(0,e.jsxs)("div",{id:"roles-profile-detail",className:"roles-editor-form roles-profile-detail",children:[(0,e.jsx)("div",{className:"roles-profile-title",children:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{children:m}),Z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{children:Z.botName??Z.larkAppId})]}):null]}),(0,e.jsx)("div",{className:"roles-editor-meta-line",children:t("roles.profileRuntimeHint")})]})}),(0,e.jsxs)("div",{className:"roles-profile-grid",children:[(0,e.jsxs)("div",{className:"roles-profile-bots",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:t("roles.profileBots")}),(0,e.jsx)("div",{className:"roles-profile-bot-list",children:p.map(r=>{let s=!!D(B,r.larkAppId),a=I===r.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row roles-profile-bot-row ${a?"selected":""}`,"data-profile-bot-id":r.larkAppId,onClick:()=>{jt(r.larkAppId)},children:[(0,e.jsx)(it,{bot:r}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:r.botName??r.larkAppId}),(0,e.jsx)("div",{className:"roles-bot-id",children:r.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${s?"has-role":"no-role"}`,children:t(s?"roles.configured":"roles.unconfigured")})]},r.larkAppId)})})]}),(0,e.jsx)("div",{className:"roles-profile-editor",children:I?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"roles-profile-editor-head",children:[(0,e.jsxs)("span",{id:"roles-profile-bytecount",className:st(te),children:[te," / ",w," bytes"]}),(0,e.jsxs)("div",{className:"roles-editor-actions roles-editor-head-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-delete",className:"danger",style:{display:Ct?"":"none"},disabled:Se,onClick:()=>{Ut()},children:Se?"...":t("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-save",className:"primary",disabled:Vt,onClick:()=>{Ft()},children:Ae?"...":t("roles.saveEntry")})]})]}),(0,e.jsx)("textarea",{id:"roles-profile-textarea",placeholder:t("roles.profileEditorPlaceholder"),rows:12,value:L,onChange:r=>H(r.target.value)}),(0,e.jsx)("div",{className:"roles-editor-footer",children:(0,e.jsx)(fe,{flash:kt})}),(0,e.jsx)(at,{content:L,tr:t,id:"roles-profile-preview"})]}):(0,e.jsx)("div",{className:"roles-editor-empty roles-profile-inline-empty",children:t("roles.profileBotSelectHint")})})]}),(0,e.jsxs)("div",{className:"roles-profile-apply",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:t("roles.applyToGroup")}),(0,e.jsxs)("div",{className:"roles-profile-apply-controls",children:[(0,e.jsx)(se,{id:"roles-profile-apply-group",className:"roles-apply-group-menu",ariaLabel:t("roles.applyToGroup"),disabled:d.length===0,label:Q?.name??k??t("roles.noChats"),value:k??"",options:d.map(r=>({value:r.chatId,label:r.name??r.chatId})),onChange:r=>G(r)}),(0,e.jsxs)("label",{className:"roles-profile-force",children:[(0,e.jsx)("input",{type:"checkbox",id:"roles-profile-apply-force",checked:Ne,onChange:r=>Rt(r.target.checked)})," ",t("roles.applyForce")]})]}),(0,e.jsx)("div",{id:"roles-profile-apply-bots",children:!Q||V.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.noChats")}):V.map(r=>{let s=!!D(B,r.larkAppId);return(0,e.jsxs)("label",{className:"checkbox-row roles-profile-apply-bot",children:[(0,e.jsx)("input",{type:"checkbox",name:"profile-apply-bot",value:r.larkAppId,checked:we.has(r.larkAppId),onChange:a=>Ot(r.larkAppId,a.target.checked)}),(0,e.jsx)("span",{children:r.botName??r.larkAppId}),(0,e.jsx)("small",{children:t(s?"roles.configured":"roles.profileMissing")})]},r.larkAppId)})}),(0,e.jsxs)("div",{className:"roles-editor-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-preview-apply",onClick:()=>{Te(!0)},children:t("roles.previewApply")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-apply",className:"primary",onClick:()=>{Te(!1)},children:t("roles.applyProfile")})]}),(0,e.jsx)("div",{id:"roles-profile-apply-status",className:"roles-profile-status",children:(0,e.jsx)(Qt,{status:Nt,bots:p,tr:t})})]})]}):(0,e.jsx)("div",{id:"roles-profile-empty",className:"roles-editor-empty",children:t("roles.profileSelectHint")})})]})]})}function Yt(n,t){let o=new Set(n);return o.has(t)?o.delete(t):o.add(t),o}function st(n){return`roles-bytecount ${n>Je?"warn":""} ${n>w?"over":""}`}function fe(n){return n.flash?(0,e.jsxs)("span",{className:`roles-saved-flash ${n.flash.isError?"roles-save-error":""}`,children:[" ",n.flash.text]}):null}function zt(n){let{tr:t}=n;return n.groups.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.noChats")}):(0,e.jsx)(e.Fragment,{children:n.groups.map(o=>{let i=n.expandedGroups.has(o.chatId),d=o.memberBots.filter(c=>c.inChat),y=ce(o),p=We(o);return(0,e.jsxs)("div",{className:"roles-group-section",children:[(0,e.jsxs)("div",{className:`roles-group-row ${i?"expanded":""} ${n.selectedGroupId===o.chatId&&!n.selectedBotId?"selected":""}`,"data-group-id":o.chatId,onClick:()=>n.onToggleGroup(o.chatId),children:[(0,e.jsx)("span",{className:"roles-group-arrow",children:i?"\u25BE":"\u25B8"}),(0,e.jsx)("span",{className:"roles-group-icon","aria-hidden":"true",children:(0,e.jsxs)("svg",{viewBox:"0 0 16 16",children:[(0,e.jsx)("circle",{cx:"5.6",cy:"5.8",r:"2.4"}),(0,e.jsx)("path",{d:"M1.8 13.2c.5-2.4 2-3.6 3.8-3.6s3.3 1.2 3.8 3.6"}),(0,e.jsx)("circle",{cx:"11",cy:"6.8",r:"1.9"}),(0,e.jsx)("path",{d:"M9.8 12.6c.4-1.7 1.5-2.6 2.8-2.6 1 0 1.9.5 2.4 1.6"})]})}),(0,e.jsxs)("div",{className:"roles-group-info",children:[(0,e.jsx)("div",{className:"roles-group-name",children:o.name??o.chatId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[y,"/",p," ",t("roles.botsWithRoles")]}),(0,e.jsx)(Xt,{group:o,profiles:n.profiles,context:n.context,loaded:n.contextLoaded,tr:t})]}),(0,e.jsx)("span",{className:"roles-group-chevron"})]}),(0,e.jsx)("div",{className:"roles-bot-list",children:i?d.map(c=>{let f=n.selectedGroupId===o.chatId&&n.selectedBotId===c.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row ${f?"selected":""}`,"data-group-id":o.chatId,"data-bot-id":c.larkAppId,onClick:P=>{P.stopPropagation(),n.onSelectBot(o.chatId,c.larkAppId)},children:[(0,e.jsx)("span",{className:"roles-bot-indent"}),(0,e.jsx)(it,{bot:c}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:c.botName}),(0,e.jsx)("div",{className:"roles-bot-id",children:c.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${c.hasRole?"has-role":"no-role"}`,children:c.hasRole?t("roles.configured"):t("roles.unconfigured")})]},c.larkAppId)}):null})]},o.chatId)})})}function Xt(n){let{group:t,profiles:o,context:i,loaded:d,tr:y}=n;if(!o.length||!d)return null;let p=new Map;for(let P of t.memberBots)P.inChat&&p.set(P.larkAppId,i.effectiveRolesByBot.get(ie(P.larkAppId,t.chatId))??null);if(!Oe(p))return null;let c=He(t.memberBots,o,i.entriesByProfile,p)[0];if(!c)return(0,e.jsx)("div",{className:"roles-profile-match muted",children:y("groups.profileStatusUnmatched")});let f=c.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`roles-profile-match ${c.kind}`,children:y(f,{name:c.profileId,matched:c.matched,total:c.total,chat:c.chatMatched})})}function at(n){return(0,e.jsx)("div",{id:n.id,className:"roles-preview",children:n.content.trim()?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("strong",{children:n.tr("roles.preview")}),(0,e.jsx)("pre",{children:n.content})]}):(0,e.jsx)("small",{children:n.tr("roles.previewEmpty")})})}function Zt(n){let{tr:t}=n;return n.profiles.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.profileEmpty")}):(0,e.jsx)(e.Fragment,{children:n.profiles.map(o=>{let i=n.selectedProfileId===o.profileId,d=(o.botEntries??[]).some(y=>y.hasEntry);return(0,e.jsxs)("div",{className:`roles-profile-row ${i?"selected":""}`,"data-profile-id":o.profileId,onClick:()=>n.onSelect(o.profileId),children:[(0,e.jsxs)("div",{className:"roles-profile-row-main",children:[(0,e.jsx)("div",{className:"roles-profile-name",children:o.profileId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[o.entryCount," ",t("roles.profileEntries")]})]}),(0,e.jsx)("span",{className:`roles-badge ${d?"has-role":"no-role"}`,children:t(d?"roles.configured":"roles.profileMissing")})]},o.profileId)})})}function Qt(n){let{status:t,bots:o,tr:i}=n;return t.kind==="idle"?null:t.kind==="text"?(0,e.jsx)(e.Fragment,{children:t.text}):(0,e.jsx)(e.Fragment,{children:t.results.map(d=>{let p=o.find(f=>f.larkAppId===d.larkAppId)?.botName??d.larkAppId,c=d.ok?t.preview?d.wouldRefuse?i("roles.applyWouldRefuse"):i("roles.applyPreviewOk"):i("roles.applyOk"):`${i("roles.applyFailed")}: ${String(d.error??`HTTP ${d.status}`)}`;return(0,e.jsxs)("div",{children:[p,": ",c]},d.larkAppId)})})}function io(n){return re(n,(0,e.jsx)(dt,{tab:"groups"}))}function co(n){return re(n,(0,e.jsx)(dt,{tab:"profiles"}))}export{co as renderRoleProfilesPage,io as renderRolesPage};
|
|
1
|
+
import{a as Oe,b as He,c as Ve,d as _e}from"./chunk-R3FXBFQH.js";import{b as Ue}from"./chunk-EIO5AWDA.js";import{b as Fe,c as ne,h as le,p as se}from"./chunk-I35DXGM4.js";import{A as $e,w as je}from"./chunk-4QTBR7UF.js";import{a as re}from"./chunk-SYC6D5XU.js";import{a as Jt,d as De}from"./chunk-5THX4DI2.js";import{c as oe}from"./chunk-7SZRL6FY.js";var l=oe(Jt(),1);var w=32768,Je=Math.floor(w*.95),Kt=/^[A-Za-z0-9._-]{1,64}$/;function ae(n){return Kt.test(n)&&n!=="."&&n!==".."}function Ke(n=location.hash){let[,t=""]=n.split("?");return new URLSearchParams(t).get("chatId")?.trim()||null}function ie(n,t){return Ve(n,t)}function de(n){return new TextEncoder().encode(n).length}function ce(n){return n.memberBots.filter(t=>t.inChat&&t.hasRole).length}function We(n){return n.memberBots.filter(t=>t.inChat).length}function D(n,t){return t?n.find(o=>o.larkAppId===t):void 0}function qe(n,t){let o=t.toLowerCase();return o?n.filter(i=>{let d=i.chatId.toLowerCase().includes(o)||(i.name??"").toLowerCase().includes(o),y=i.memberBots.some(p=>p.larkAppId.toLowerCase().includes(o)||(p.botName??"").toLowerCase().includes(o));return d||y}):n}function Ye(n,t){let o=t.toLowerCase();return n.filter(i=>!o||i.profileId.toLowerCase().includes(o))}async function C(n){return n.json().catch(()=>({}))}async function ze(){let n=await fetch("/api/groups"),t=await C(n);return{bots:(t.bots??[]).map(o=>({larkAppId:o.larkAppId,botName:o.botName??o.larkAppId,botAvatarUrl:o.botAvatarUrl})),groups:(t.chats??[]).map(o=>({chatId:o.chatId,name:o.name??o.chatId,memberBots:(o.memberBots??[]).map(i=>({larkAppId:i.larkAppId,botName:i.botName??i.larkAppId,inChat:i.inChat??!1,hasRole:i.hasRole??!1,oncallChat:i.oncallChat??null}))}))}}async function Xe(){let n=await fetch("/api/role-profiles");return(await C(n)).profiles??[]}async function x(n){let t=await fetch(`/api/role-profiles/${encodeURIComponent(n)}`);return(await C(t)).entries??[]}async function pe(n,t){let o=await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`);return C(o)}async function Ze(n,t,o,i){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:o,injectMode:i})})).ok}async function Qe(n,t,o){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({injectMode:o})})).ok}async function et(n,t){return(await fetch(`/api/roles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"DELETE"})).ok}async function tt(n,t){let o=await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`);return C(o)}async function ot(n,t,o){return(await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:o,allowEmpty:!0})})).ok}async function rt(n,t){return(await fetch(`/api/role-profiles/${encodeURIComponent(n)}/${encodeURIComponent(t)}`,{method:"DELETE"})).ok}async function nt(n,t){let o=await Promise.all(t.map(async p=>{try{let c=await fetch(`/api/role-profiles/${encodeURIComponent(p.profileId)}`),f=await C(c);return[p.profileId,Array.isArray(f.entries)?f.entries:[]]}catch{return[p.profileId,[]]}})),i=new Set,d=[];for(let p of n)for(let c of p.memberBots){if(!c.inChat||!c.hasRole)continue;let f=ie(c.larkAppId,p.chatId);i.has(f)||(i.add(f),d.push({larkAppId:c.larkAppId,chatId:p.chatId}))}let y=await _e(d);return{entriesByProfile:new Map(o),effectiveRolesByBot:y}}async function lt(n){let t=await fetch(`/api/role-profiles/${encodeURIComponent(n.profileId)}/apply`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({chatId:n.chatId,larkAppId:n.larkAppId,force:n.force,preview:n.preview})}),o=await C(t);return{larkAppId:n.larkAppId,ok:t.ok&&o.ok!==!1,status:t.status,error:o.error,wouldRefuse:o.wouldRefuse}}var e=oe(De(),1);function Wt(){let n=(0,l.useRef)(!0);return(0,l.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]),n}function qt(){let n=(0,l.useRef)(new Set);return(0,l.useEffect)(()=>()=>{for(let t of n.current)window.clearTimeout(t);n.current.clear()},[]),(0,l.useCallback)((t,o)=>{let i=window.setTimeout(()=>{n.current.delete(i),t()},o);return n.current.add(i),i},[])}function it(n){return(0,e.jsx)(Fe,{html:je({name:n.bot.botName,larkAppId:n.bot.larkAppId,avatarUrl:n.bot.botAvatarUrl,size:"sm"})})}function dt(n){let t=Ue(),o=Wt(),i=qt(),[d,y]=(0,l.useState)([]),[p,c]=(0,l.useState)([]),[f,P]=(0,l.useState)([]),[ct,ue]=(0,l.useState)({entriesByProfile:new Map,effectiveRolesByBot:new Map}),[pt,F]=(0,l.useState)(!1),[ft,J]=(0,l.useState)(!0),[ut,K]=(0,l.useState)(!0),[W,mt]=(0,l.useState)(""),[q,vt]=(0,l.useState)(""),[ht,me]=(0,l.useState)(()=>new Set),[v,ve]=(0,l.useState)(null),[h,he]=(0,l.useState)(null),[yt,U]=(0,l.useState)(null),[R,O]=(0,l.useState)(""),[S,E]=(0,l.useState)("every"),[ye,ge]=(0,l.useState)(!1),[Ie,be]=(0,l.useState)(!1),[gt,Pe]=(0,l.useState)(!1),[It,Y]=(0,l.useState)(null),[bt,Re]=(0,l.useState)(null),[m,Pt]=(0,l.useState)(null),[I,ke]=(0,l.useState)(null),[B,M]=(0,l.useState)([]),[L,H]=(0,l.useState)(""),[k,G]=(0,l.useState)(null),[Ne,Rt]=(0,l.useState)(!1),[we,Ce]=(0,l.useState)(()=>new Set),[Ae,xe]=(0,l.useState)(!1),[Se,Ee]=(0,l.useState)(!1),[kt,z]=(0,l.useState)(null),[Nt,T]=(0,l.useState)({kind:"idle"}),Be=(0,l.useRef)(0),j=(0,l.useRef)(0),Me=(0,l.useRef)(null),X=v?d.find(r=>r.chatId===v):void 0,wt=X&&h?X.memberBots.find(r=>r.larkAppId===h):void 0,Z=I?p.find(r=>r.larkAppId===I):void 0,Ct=D(B,I),Q=k?d.find(r=>r.chatId===k):void 0,V=Q?.memberBots.filter(r=>r.inChat)??[],At=V.map(r=>r.larkAppId).join("\0"),xt=B.map(r=>r.larkAppId).sort().join("\0"),St=(0,l.useMemo)(()=>qe(d,W),[d,W]),Et=(0,l.useMemo)(()=>Ye(f,q),[f,q]),ee=de(R),te=de(L),_=(0,l.useCallback)((r,s,a=!1)=>{let u=Date.now()+Math.random();r({text:s,isError:a,id:u}),i(()=>{r(g=>g?.id===u?null:g)},a?3e3:2e3)},[i]),b=(0,l.useCallback)(async(r,s)=>{try{let a=await nt(r,s);if(!o.current)return;ue(a),F(!0)}catch{if(!o.current)return;ue({entriesByProfile:new Map,effectiveRolesByBot:new Map}),F(!0)}},[o]),N=(0,l.useCallback)(async()=>{let r=await ze();return o.current&&(y(r.groups),c(r.bots)),r},[o]),$=(0,l.useCallback)(async()=>{let r=await Xe();return o.current&&P(r),r},[o]),Le=(0,l.useCallback)(async()=>{J(!0),K(!0),F(!1);try{let r=await N();if(!o.current)return;let s=await $();if(!o.current||(await $e(),!o.current))return;if(me(new Set(r.groups.filter(a=>ce(a)>0).map(a=>a.chatId))),n.tab==="profiles"){let a=Ke();G(u=>u||(a&&r.groups.some(g=>g.chatId===a)?a:r.groups[0]?.chatId??null))}else G(a=>a??r.groups[0]?.chatId??null);J(!1),K(!1),b(r.groups,s)}catch{if(!o.current)return;J(!1),K(!1),F(!0)}},[o,n.tab,N,$,b]);(0,l.useEffect)(()=>{Le()},[Le]),(0,l.useEffect)(()=>{k||d.length===0||G(d[0].chatId)},[d,k]),(0,l.useEffect)(()=>{let r=new Set(V.filter(s=>!!D(B,s.larkAppId)).map(s=>s.larkAppId));Ce(r),T({kind:"idle"})},[xt,At]);async function Bt(r,s){let a=++Be.current;ve(r),he(s);let u=await pe(s,r);!o.current||a!==Be.current||(U(u),O(u.content??""),E(u.injectMode==="once"?"once":"every"),Y(null),Re(null))}async function Mt(){let r=await N();if(o.current&&(b(r.groups,f),v&&h)){let s=await pe(h,v);if(!o.current)return;U(s),O(s.content??""),E(s.injectMode==="once"?"once":"every")}}async function Lt(){if(!(!v||!h)){ge(!0);try{let r=await Ze(h,v,R,S);if(!o.current)return;if(r){let s=await N();if(!o.current)return;U(a=>a&&{...a,content:R,hasRole:!0,injectMode:S}),b(s.groups,f),_(Y,t("roles.saved"))}else _(Y,R.trim().length===0?t("roles.emptyError"):t("roles.saveFailed"),!0)}finally{o.current&&ge(!1)}}}async function Gt(){if(!(!v||!h)&&confirm(t("roles.confirmDelete"))){be(!0);try{let r=await et(h,v);if(!o.current)return;if(r){let s=await N();if(!o.current)return;ve(null),he(null),U(null),O(""),E("every"),b(s.groups,f)}}finally{o.current&&be(!1)}}}async function Tt(r){if(!v||!h)return;let s=S;E(r),Pe(!0);try{let a=await Qe(h,v,r);if(!o.current)return;a||E(s),_(Re,t(a?"roles.saved":"roles.saveFailed"),!a)}finally{o.current&&Pe(!1)}}async function Ge(r){let s=r.trim();if(!ae(s))return;let a=++j.current;Pt(s),ke(null),H(""),T({kind:"idle"}),G(g=>g??d[0]?.chatId??null);let u=await x(s);!o.current||a!==j.current||(M(u),z(null))}async function jt(r){if(!m)return;let s=++j.current;ke(r);let a=await tt(m,r);if(!o.current||s!==j.current)return;H(a.content??"");let u=await x(m);!o.current||s!==j.current||(M(u),z(null))}async function $t(){let r=await N();if(!o.current)return;let s=await $();if(o.current){if(m){let a=await x(m);if(!o.current)return;M(a)}b(r.groups,s)}}async function Dt(){let r=Me.current,s=r?.value.trim()??"";if(s){if(!ae(s)){r?.setCustomValidity(t("roles.profileIdInvalid")),r?.reportValidity();return}r?.setCustomValidity(""),await Ge(s),o.current&&(location.hash.startsWith("#/roles/profile")||(location.hash="#/roles/profile"))}}async function Ft(){if(!(!m||!I)){xe(!0);try{let r=await ot(m,I,L);if(!o.current)return;let s=await $();if(!o.current)return;let a=await x(m);if(!o.current)return;M(a),b(d,s),_(z,t(r?"roles.saved":"roles.saveFailed"),!r)}finally{o.current&&xe(!1)}}}async function Ut(){if(!(!m||!I)&&confirm(t("roles.confirmDeleteProfileEntry"))){Ee(!0);try{if(await rt(m,I),!o.current)return;H("");let r=await $();if(!o.current)return;let s=await x(m);if(!o.current)return;M(s),b(d,r)}finally{o.current&&Ee(!1)}}}function Ot(r,s){Ce(a=>{let u=new Set(a);return s?u.add(r):u.delete(r),u})}async function Te(r){if(!m)return;let s=k??d[0]?.chatId;if(!s)return;let a=[...we];if(a.length===0){T({kind:"text",text:t("roles.applyPickBots")});return}T({kind:"text",text:"..."});let u=await Promise.all(a.map(g=>lt({profileId:m,chatId:s,larkAppId:g,force:Ne,preview:r})));if(o.current&&(T({kind:"results",preview:r,results:u}),!r)){let g=await N();if(!o.current)return;b(g.groups,f)}}let Ht=ye||ee>w||R.trim().length===0,Vt=Ae||te>w||L.trim().length===0,A=n.tab==="profiles",_t=(0,e.jsxs)("nav",{className:"roles-subnav insight-tabs",role:"tablist","aria-label":t("roles.title"),children:[(0,e.jsx)("a",{href:"#/roles",className:`itab${A?"":" on"}`,role:"tab","aria-selected":!A,children:t("roles.tabGroups")}),(0,e.jsx)("a",{href:"#/roles/profile",className:`itab${A?" on":""}`,role:"tab","aria-selected":A,children:t("roles.tabProfiles")})]});return(0,e.jsxs)("section",{className:"page roles-page",children:[(0,e.jsxs)("div",{className:"page-heading roles-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("nav.roles")}),(0,e.jsx)("h1",{children:t("roles.title")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:_t})]}),(0,e.jsxs)("div",{id:"roles-by-group-view",className:"roles-layout",hidden:A,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-search",placeholder:t("roles.search"),value:W,onChange:r=>mt(r.target.value)}),(0,e.jsx)(le,{id:"roles-refresh",label:t("roles.refresh"),onClick:()=>{Mt()}})]}),(0,e.jsx)("div",{id:"roles-tree",className:"roles-tree",children:ft?(0,e.jsx)(ne,{label:t("common.loading")}):(0,e.jsx)(zt,{groups:St,profiles:f,context:ct,contextLoaded:pt,expandedGroups:ht,selectedGroupId:v,selectedBotId:h,tr:t,onToggleGroup:r=>me(s=>Yt(s,r)),onSelectBot:(r,s)=>{Bt(r,s)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:!v||!h?(0,e.jsx)("div",{id:"roles-editor-empty",className:"roles-editor-empty",children:t("roles.selectHint")}):(0,e.jsxs)("div",{id:"roles-editor-form",className:"roles-editor-form",children:[(0,e.jsxs)("div",{className:"roles-editor-head",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{id:"roles-editor-group-name",children:X?.name??v}),(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{id:"roles-editor-bot-name",children:wt?.botName??h})]}),(0,e.jsx)("div",{className:"roles-editor-meta",children:(0,e.jsxs)("span",{id:"roles-editor-chat-id",className:"roles-editor-meta-line",children:[v," \xB7 ",h]})})]}),(0,e.jsxs)("div",{className:"roles-editor-actions roles-editor-head-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-delete",className:"danger",style:{display:yt?.hasRole?"":"none"},disabled:Ie,onClick:()=>{Gt()},children:Ie?"...":t("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-save",className:"primary",disabled:Ht,onClick:()=>{Lt()},children:ye?"...":t("roles.save")})]})]}),(0,e.jsxs)("div",{className:"roles-editor-inject",children:[(0,e.jsx)("span",{className:"roles-field-label",children:t("roles.injectModeLabel")}),(0,e.jsx)(se,{id:"roles-editor-inject-mode",className:"roles-inline-menu",ariaLabel:t("roles.injectModeLabel"),disabled:gt,label:t(S==="once"?"roles.injectModeOnce":"roles.injectModeEvery"),value:S,options:[{value:"every",label:t("roles.injectModeEvery")},{value:"once",label:t("roles.injectModeOnce")}],onChange:r=>{Tt(r==="once"?"once":"every")}}),(0,e.jsx)("span",{className:"roles-editor-inject-hint",children:t("roles.injectModeHint")}),(0,e.jsx)(fe,{flash:bt})]}),(0,e.jsx)("textarea",{id:"roles-editor-textarea",placeholder:t("roles.editorPlaceholder"),rows:14,value:R,onChange:r=>O(r.target.value)}),(0,e.jsxs)("div",{className:"roles-editor-footer",children:[(0,e.jsxs)("span",{id:"roles-editor-bytecount",className:st(ee),children:[ee," / ",w," bytes"]}),(0,e.jsx)(fe,{flash:It})]}),(0,e.jsx)(at,{content:R,tr:t,id:"roles-preview"})]})})]}),(0,e.jsxs)("div",{id:"roles-profiles-view",className:"roles-layout roles-profiles-layout",hidden:!A,children:[(0,e.jsxs)("div",{className:"roles-tree-panel",children:[(0,e.jsxs)("div",{className:"roles-tree-header roles-profile-create dashboard-toolbar",children:[(0,e.jsx)("input",{type:"text",id:"roles-profile-id",placeholder:t("roles.profileIdPlaceholder"),maxLength:64,ref:Me,onChange:r=>r.currentTarget.setCustomValidity("")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-select",onClick:()=>{Dt()},children:t("roles.openProfile")})]}),(0,e.jsxs)("div",{className:"roles-tree-header dashboard-toolbar",children:[(0,e.jsx)("input",{type:"search",id:"roles-profile-search",placeholder:t("roles.profileSearch"),value:q,onChange:r=>vt(r.target.value)}),(0,e.jsx)(le,{id:"roles-profile-refresh",label:t("roles.refresh"),onClick:()=>{$t()}})]}),(0,e.jsx)("div",{id:"roles-profile-list",className:"roles-tree",children:ut?(0,e.jsx)(ne,{label:t("common.loading")}):(0,e.jsx)(Zt,{profiles:Et,selectedProfileId:m,tr:t,onSelect:r=>{Ge(r)}})})]}),(0,e.jsx)("div",{className:"roles-editor-panel",children:m?(0,e.jsxs)("div",{id:"roles-profile-detail",className:"roles-editor-form roles-profile-detail",children:[(0,e.jsx)("div",{className:"roles-profile-title",children:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"roles-editor-breadcrumb",children:[(0,e.jsx)("span",{children:m}),Z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"roles-breadcrumb-sep",children:"\u203A"}),(0,e.jsx)("span",{children:Z.botName??Z.larkAppId})]}):null]}),(0,e.jsx)("div",{className:"roles-editor-meta-line",children:t("roles.profileRuntimeHint")})]})}),(0,e.jsxs)("div",{className:"roles-profile-grid",children:[(0,e.jsxs)("div",{className:"roles-profile-bots",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:t("roles.profileBots")}),(0,e.jsx)("div",{className:"roles-profile-bot-list",children:p.map(r=>{let s=!!D(B,r.larkAppId),a=I===r.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row roles-profile-bot-row ${a?"selected":""}`,"data-profile-bot-id":r.larkAppId,onClick:()=>{jt(r.larkAppId)},children:[(0,e.jsx)(it,{bot:r}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:r.botName??r.larkAppId}),(0,e.jsx)("div",{className:"roles-bot-id",children:r.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${s?"has-role":"no-role"}`,children:t(s?"roles.configured":"roles.unconfigured")})]},r.larkAppId)})})]}),(0,e.jsx)("div",{className:"roles-profile-editor",children:I?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"roles-profile-editor-head",children:[(0,e.jsxs)("span",{id:"roles-profile-bytecount",className:st(te),children:[te," / ",w," bytes"]}),(0,e.jsxs)("div",{className:"roles-editor-actions roles-editor-head-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-delete",className:"danger",style:{display:Ct?"":"none"},disabled:Se,onClick:()=>{Ut()},children:Se?"...":t("roles.delete")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-save",className:"primary",disabled:Vt,onClick:()=>{Ft()},children:Ae?"...":t("roles.saveEntry")})]})]}),(0,e.jsx)("textarea",{id:"roles-profile-textarea",placeholder:t("roles.profileEditorPlaceholder"),rows:12,value:L,onChange:r=>H(r.target.value)}),(0,e.jsx)("div",{className:"roles-editor-footer",children:(0,e.jsx)(fe,{flash:kt})}),(0,e.jsx)(at,{content:L,tr:t,id:"roles-profile-preview"})]}):(0,e.jsx)("div",{className:"roles-editor-empty roles-profile-inline-empty",children:t("roles.profileBotSelectHint")})})]}),(0,e.jsxs)("div",{className:"roles-profile-apply",children:[(0,e.jsx)("div",{className:"roles-profile-section-title",children:t("roles.applyToGroup")}),(0,e.jsxs)("div",{className:"roles-profile-apply-controls",children:[(0,e.jsx)(se,{id:"roles-profile-apply-group",className:"roles-apply-group-menu",ariaLabel:t("roles.applyToGroup"),disabled:d.length===0,label:Q?.name??k??t("roles.noChats"),value:k??"",options:d.map(r=>({value:r.chatId,label:r.name??r.chatId})),onChange:r=>G(r)}),(0,e.jsxs)("label",{className:"roles-profile-force",children:[(0,e.jsx)("input",{type:"checkbox",id:"roles-profile-apply-force",checked:Ne,onChange:r=>Rt(r.target.checked)})," ",t("roles.applyForce")]})]}),(0,e.jsx)("div",{id:"roles-profile-apply-bots",children:!Q||V.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.noChats")}):V.map(r=>{let s=!!D(B,r.larkAppId);return(0,e.jsxs)("label",{className:"checkbox-row roles-profile-apply-bot",children:[(0,e.jsx)("input",{type:"checkbox",name:"profile-apply-bot",value:r.larkAppId,checked:we.has(r.larkAppId),onChange:a=>Ot(r.larkAppId,a.target.checked)}),(0,e.jsx)("span",{children:r.botName??r.larkAppId}),(0,e.jsx)("small",{children:t(s?"roles.configured":"roles.profileMissing")})]},r.larkAppId)})}),(0,e.jsxs)("div",{className:"roles-editor-actions",children:[(0,e.jsx)("button",{type:"button",id:"roles-profile-preview-apply",onClick:()=>{Te(!0)},children:t("roles.previewApply")}),(0,e.jsx)("button",{type:"button",id:"roles-profile-apply",className:"primary",onClick:()=>{Te(!1)},children:t("roles.applyProfile")})]}),(0,e.jsx)("div",{id:"roles-profile-apply-status",className:"roles-profile-status",children:(0,e.jsx)(Qt,{status:Nt,bots:p,tr:t})})]})]}):(0,e.jsx)("div",{id:"roles-profile-empty",className:"roles-editor-empty",children:t("roles.profileSelectHint")})})]})]})}function Yt(n,t){let o=new Set(n);return o.has(t)?o.delete(t):o.add(t),o}function st(n){return`roles-bytecount ${n>Je?"warn":""} ${n>w?"over":""}`}function fe(n){return n.flash?(0,e.jsxs)("span",{className:`roles-saved-flash ${n.flash.isError?"roles-save-error":""}`,children:[" ",n.flash.text]}):null}function zt(n){let{tr:t}=n;return n.groups.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.noChats")}):(0,e.jsx)(e.Fragment,{children:n.groups.map(o=>{let i=n.expandedGroups.has(o.chatId),d=o.memberBots.filter(c=>c.inChat),y=ce(o),p=We(o);return(0,e.jsxs)("div",{className:"roles-group-section",children:[(0,e.jsxs)("div",{className:`roles-group-row ${i?"expanded":""} ${n.selectedGroupId===o.chatId&&!n.selectedBotId?"selected":""}`,"data-group-id":o.chatId,onClick:()=>n.onToggleGroup(o.chatId),children:[(0,e.jsx)("span",{className:"roles-group-arrow",children:i?"\u25BE":"\u25B8"}),(0,e.jsx)("span",{className:"roles-group-icon","aria-hidden":"true",children:(0,e.jsxs)("svg",{viewBox:"0 0 16 16",children:[(0,e.jsx)("circle",{cx:"5.6",cy:"5.8",r:"2.4"}),(0,e.jsx)("path",{d:"M1.8 13.2c.5-2.4 2-3.6 3.8-3.6s3.3 1.2 3.8 3.6"}),(0,e.jsx)("circle",{cx:"11",cy:"6.8",r:"1.9"}),(0,e.jsx)("path",{d:"M9.8 12.6c.4-1.7 1.5-2.6 2.8-2.6 1 0 1.9.5 2.4 1.6"})]})}),(0,e.jsxs)("div",{className:"roles-group-info",children:[(0,e.jsx)("div",{className:"roles-group-name",children:o.name??o.chatId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[y,"/",p," ",t("roles.botsWithRoles")]}),(0,e.jsx)(Xt,{group:o,profiles:n.profiles,context:n.context,loaded:n.contextLoaded,tr:t})]}),(0,e.jsx)("span",{className:"roles-group-chevron"})]}),(0,e.jsx)("div",{className:"roles-bot-list",children:i?d.map(c=>{let f=n.selectedGroupId===o.chatId&&n.selectedBotId===c.larkAppId;return(0,e.jsxs)("div",{className:`roles-bot-row ${f?"selected":""}`,"data-group-id":o.chatId,"data-bot-id":c.larkAppId,onClick:P=>{P.stopPropagation(),n.onSelectBot(o.chatId,c.larkAppId)},children:[(0,e.jsx)("span",{className:"roles-bot-indent"}),(0,e.jsx)(it,{bot:c}),(0,e.jsxs)("div",{className:"roles-bot-info",children:[(0,e.jsx)("div",{className:"roles-bot-name",children:c.botName}),(0,e.jsx)("div",{className:"roles-bot-id",children:c.larkAppId})]}),(0,e.jsx)("span",{className:`roles-badge ${c.hasRole?"has-role":"no-role"}`,children:c.hasRole?t("roles.configured"):t("roles.unconfigured")})]},c.larkAppId)}):null})]},o.chatId)})})}function Xt(n){let{group:t,profiles:o,context:i,loaded:d,tr:y}=n;if(!o.length||!d)return null;let p=new Map;for(let P of t.memberBots)P.inChat&&p.set(P.larkAppId,i.effectiveRolesByBot.get(ie(P.larkAppId,t.chatId))??null);if(!Oe(p))return null;let c=He(t.memberBots,o,i.entriesByProfile,p)[0];if(!c)return(0,e.jsx)("div",{className:"roles-profile-match muted",children:y("groups.profileStatusUnmatched")});let f=c.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`roles-profile-match ${c.kind}`,children:y(f,{name:c.profileId,matched:c.matched,total:c.total,chat:c.chatMatched})})}function at(n){return(0,e.jsx)("div",{id:n.id,className:"roles-preview",children:n.content.trim()?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("strong",{children:n.tr("roles.preview")}),(0,e.jsx)("pre",{children:n.content})]}):(0,e.jsx)("small",{children:n.tr("roles.previewEmpty")})})}function Zt(n){let{tr:t}=n;return n.profiles.length===0?(0,e.jsx)("div",{className:"roles-empty",children:t("roles.profileEmpty")}):(0,e.jsx)(e.Fragment,{children:n.profiles.map(o=>{let i=n.selectedProfileId===o.profileId,d=(o.botEntries??[]).some(y=>y.hasEntry);return(0,e.jsxs)("div",{className:`roles-profile-row ${i?"selected":""}`,"data-profile-id":o.profileId,onClick:()=>n.onSelect(o.profileId),children:[(0,e.jsxs)("div",{className:"roles-profile-row-main",children:[(0,e.jsx)("div",{className:"roles-profile-name",children:o.profileId}),(0,e.jsxs)("div",{className:"roles-group-meta",children:[o.entryCount," ",t("roles.profileEntries")]})]}),(0,e.jsx)("span",{className:`roles-badge ${d?"has-role":"no-role"}`,children:t(d?"roles.configured":"roles.profileMissing")})]},o.profileId)})})}function Qt(n){let{status:t,bots:o,tr:i}=n;return t.kind==="idle"?null:t.kind==="text"?(0,e.jsx)(e.Fragment,{children:t.text}):(0,e.jsx)(e.Fragment,{children:t.results.map(d=>{let p=o.find(f=>f.larkAppId===d.larkAppId)?.botName??d.larkAppId,c=d.ok?t.preview?d.wouldRefuse?i("roles.applyWouldRefuse"):i("roles.applyPreviewOk"):i("roles.applyOk"):`${i("roles.applyFailed")}: ${String(d.error??`HTTP ${d.status}`)}`;return(0,e.jsxs)("div",{children:[p,": ",c]},d.larkAppId)})})}function io(n){return re(n,(0,e.jsx)(dt,{tab:"groups"}))}function co(n){return re(n,(0,e.jsx)(dt,{tab:"profiles"}))}export{co as renderRoleProfilesPage,io as renderRolesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C,b as w}from"./chunk-
|
|
1
|
+
import{a as C,b as w}from"./chunk-EIO5AWDA.js";import{l as A,m as T,n as R,o as O,p as $}from"./chunk-I35DXGM4.js";import"./chunk-4QTBR7UF.js";import{a as N}from"./chunk-SYC6D5XU.js";import{a as D,d as S}from"./chunk-5THX4DI2.js";import{c as k}from"./chunk-7SZRL6FY.js";var o=k(D(),1);var s=k(S(),1),I=1e3;function L(e,n){if(!e)return"\u2014";try{return new Date(e).toLocaleString(void 0,n?{timeZone:n,timeZoneName:"short"}:void 0)}catch{return e}}function M(e,n){let d=n.q.toLowerCase();return e.filter(t=>!n.kind||t.parsed?.kind===n.kind).filter(t=>!n.enabledOnly||t.enabled).filter(t=>!d||JSON.stringify(t).toLowerCase().includes(d)).sort((t,i)=>{if(t.enabled!==i.enabled)return t.enabled?-1:1;let h=t.nextRunAt?Date.parse(t.nextRunAt):1/0,u=i.nextRunAt?Date.parse(i.nextRunAt):1/0;return h-u})}function q(e,n){return e.deliver==="new-topic"?n("schedules.deliveryNewTopic"):e.deliver==="local"?n("schedules.deliveryLocal"):n("schedules.deliveryOrigin")}function E(e){return e.repeat?`${e.repeat.completed}/${e.repeat.times??"\u221E"}`:"\u2014"}function K(e){return new Promise(n=>window.setTimeout(n,e))}function Z(e){let{schedule:n,scheduleTimeZone:d,tr:t}=e,i=String(n.parsed?.kind??"unknown"),h=n.enabled?"pause":"resume",u=`${n.id}:${h}`,g=`${n.id}:run`,f=`${n.id}:delivery`;return(0,s.jsxs)(T,{kind:"schedule",className:"schedule-list-row","data-id":n.id,children:[(0,s.jsxs)(R,{children:[(0,s.jsxs)("div",{className:"schedule-row-head",children:[(0,s.jsx)("b",{children:n.name??n.id}),(0,s.jsx)("span",{className:`schedule-state ${n.enabled?"enabled":"paused"}`,children:n.enabled?t("schedules.enabled"):t("schedules.paused")})]}),(0,s.jsxs)("div",{className:"schedule-row-meta",children:[(0,s.jsx)("span",{children:n.botName??n.larkAppId??"-"}),(0,s.jsx)("span",{children:"\xB7"}),(0,s.jsx)("code",{children:n.parsed?.display??"?"})]}),(0,s.jsxs)("div",{className:"schedule-chip-strip",children:[(0,s.jsx)("span",{children:i}),(0,s.jsxs)("span",{children:[t("schedules.delivery"),": ",q(n,t)]}),(0,s.jsxs)("span",{children:[t("schedules.next"),": ",L(n.nextRunAt,d)]}),(0,s.jsxs)("span",{children:[t("schedules.last"),": ",L(n.lastRunAt,d),n.lastStatus==="error"?" \xB7 error":""]}),(0,s.jsxs)("span",{children:[t("schedules.repeat"),": ",E(n)]})]})]}),(0,s.jsx)(O,{children:(0,s.jsxs)("div",{className:"schedule-actions",children:[(0,s.jsx)(F,{op:"run",label:t("schedules.runNow"),pending:e.pending===g,feedback:e.feedback[g]??null,onClick:()=>e.onAction(n.id,"run")}),(0,s.jsx)(U,{checked:!!n.enabled,pending:e.pending===u,feedback:e.feedback[u]??null,tr:t,onClick:()=>e.onAction(n.id,h)}),n.deliver==="local"?null:(0,s.jsx)(F,{op:"delivery",label:n.deliver==="new-topic"?t("schedules.useOrigin"):t("schedules.useNewTopic"),pending:e.pending===f,feedback:e.feedback[f]??null,onClick:()=>e.onAction(n.id,"delivery")})]})})]})}function _(){let e=w(),{scheduleRows:n,scheduleTimeZone:d}=C(c=>({scheduleRows:[...c.schedules.values()],scheduleTimeZone:c.scheduleTimeZone})),[t,i]=(0,o.useState)({q:"",kind:"",enabledOnly:!1}),[h,u]=(0,o.useState)(null),[g,f]=(0,o.useState)({}),m=(0,o.useRef)(new Map),v=(0,o.useMemo)(()=>M(n,t),[n,t]);(0,o.useEffect)(()=>()=>{m.current.forEach(c=>window.clearTimeout(c)),m.current.clear()},[]);function x(c,l){f(b=>({...b,[c]:l}));let r=m.current.get(c);r&&window.clearTimeout(r);let p=window.setTimeout(()=>{f(b=>{let a={...b};return delete a[c],a}),m.current.delete(c)},l==="success"?1600:2200);m.current.set(c,p)}async function P(c,l){let r=`${c}:${l}`,p=performance.now(),b="success";u(r);try{let a=await fetch(`/api/schedules/${encodeURIComponent(c)}/${l}`,{method:"POST"}),y=await a.json().catch(()=>({}));if(!a.ok||y.ok===!1)throw new Error(`Failed: ${a.status} ${y?.error??""}`.trim())}catch{b="error"}finally{if(l==="run"){let a=I-(performance.now()-p);a>0&&await K(a)}x(r,b),u(a=>a===r?null:a)}}return(0,s.jsxs)("section",{className:"page schedules-page",children:[(0,s.jsx)("div",{className:"page-heading",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"eyebrow",children:e("nav.schedules")}),(0,s.jsx)("h1",{children:e("schedules.title")})]})}),(0,s.jsxs)("form",{id:"sched-filters",className:"filters dashboard-toolbar",children:[(0,s.jsx)("input",{type:"search",name:"q",placeholder:e("schedules.search"),value:t.q,onChange:c=>{let l=c.currentTarget.value;i(r=>({...r,q:l}))}}),(0,s.jsx)($,{id:"sched-kind-menu",ariaLabel:e("schedules.anyKind"),label:t.kind||e("schedules.anyKind"),value:t.kind,options:[{value:"",label:e("schedules.anyKind")},{value:"cron",label:"cron"},{value:"interval",label:"interval"},{value:"once",label:"once"}],onChange:c=>i(l=>({...l,kind:c}))}),(0,s.jsxs)("label",{className:"filter-toggle",children:[(0,s.jsx)("input",{type:"checkbox",name:"enabled",checked:t.enabledOnly,onChange:c=>{let l=c.currentTarget.checked;i(r=>({...r,enabledOnly:l}))}}),(0,s.jsx)("span",{className:"filter-toggle-label",children:e("schedules.enabledOnly")}),(0,s.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"})]}),(0,s.jsx)("span",{className:"schedules-toolbar-spacer","aria-hidden":"true"}),(0,s.jsxs)("span",{className:"schedules-toolbar-count",children:[v.length,"/",n.length]})]}),(0,s.jsx)("section",{className:"overview-block schedules-list-section",children:(0,s.jsx)("div",{className:"schedules-list-wrap",children:v.length===0?(0,s.jsx)("div",{id:"schedules-tbody",className:"empty schedules-list-empty",children:e("schedules.empty")}):(0,s.jsx)(A,{id:"schedules-tbody",className:"schedules-list",children:v.map(c=>(0,s.jsx)(Z,{schedule:c,scheduleTimeZone:d,pending:h,feedback:g,tr:e,onAction:(l,r)=>{P(l,r)}},c.id))})})})]})}function B(e,n,d,t,i){return d?i(e==="run"?"schedules.running":"schedules.saving"):t==="success"?i(e==="run"?"schedules.runDone":"schedules.saved"):t==="error"?i("schedules.failed"):n}function F(e){let n=w(),d=e.feedback?` is-${e.feedback}`:"";return(0,s.jsx)("button",{type:"button",className:`schedule-action-button${e.pending?" is-pending":""}${d}`,"data-op":e.op,disabled:e.pending,onClick:e.onClick,children:(0,s.jsx)("span",{className:"schedule-action-label",children:B(e.op,e.label,e.pending,e.feedback,n)})})}function U(e){let n=e.feedback==="error"?e.tr("schedules.failed"):e.checked?e.tr("schedules.enabled"):e.tr("schedules.paused");return(0,s.jsxs)("button",{type:"button",className:`schedule-enabled-switch${e.checked?" is-on":""}${e.pending?" is-pending":""}${e.feedback?` is-${e.feedback}`:""}`,"aria-pressed":e.checked,disabled:e.pending,onClick:e.onClick,children:[(0,s.jsx)("span",{className:"schedule-enabled-switch-label",children:n}),(0,s.jsx)("span",{className:"schedule-enabled-switch-track","aria-hidden":"true",children:(0,s.jsx)("span",{})})]})}function j(e){return N(e,(0,s.jsx)(_,{}))}export{M as filterSchedules,L as fmtScheduleDate,j as renderSchedulesPage};
|