import{j as o,b6 as f,at as w,ao as R,T as S,W as d}from"./vendor-mui-core-DnR6WYuU.js";import{r as a}from"./vendor-react-CTtPmzVP.js";import{a as m,h as j}from"./vendor-hooks-DpqqC65c.js";import{V as h}from"./vendor-ux-KtPBvlG0.js";import{q as C}from"./index-DGg3AL9l.js";const I=1e3;function x({blocklet:t}){const{meta:u}=t,{t:i}=h(),[l,s]=a.useState("starting"),[p,e]=a.useState(t.status),r=m(()=>{const c=u.title||u.name;return{starting:i("blocklet.startingProgress.starting",{name:c}),running:i("blocklet.startingProgress.success",{name:c}),stopped:i("blocklet.startingProgress.failed",{name:c}),error:i("blocklet.startingProgress.failed",{name:c})}},[i,u]);a.useEffect(()=>{p!==t.status&&(s(t.status),e(""))},[t.status,p]),j(()=>{e(t.status),C.isBlockletRunning(t)&&s(t.status)});const n=m(()=>l==="running"?R[600]:["stopped","error"].includes(l)?"error":"primary",[l]);return o.jsx(S,{display:"flex",alignItems:"center",fontSize:14,lineHeight:1,gap:1,color:n,children:r[l]})}x.propTypes={blocklet:d.object.isRequired};function P({blocklets:t=[],children:u,debounce:i=!0,status:l=""}){const[s,p]=a.useState(null),[e,r]=a.useState(0),n=a.useRef(null),c=a.useRef(!1);a.useEffect(()=>{if(s&&n.current){const g=n.current.style.display;n.current.style.display="flex",r(n.current.offsetHeight),n.current.style.display=g}},[s,t]);const b=a.useMemo(()=>l==="starting"?o.jsx(f,{ref:n,display:"flex",flexDirection:"column",gap:.5,maxHeight:200,sx:{overflowY:"auto",p:2,display:s?"flex":"none",position:"fixed",top:s?s.getBoundingClientRect().top-10-e:0,left:s?s.getBoundingClientRect().left+s.offsetWidth/2:0,transform:"translateX(-50%)",backgroundColor:"white",boxShadow:"0px 2px 4px rgba(0,0,0,0.1)",borderRadius:"4px",zIndex:1300},children:t.map(g=>o.jsx(x,{blocklet:g},g.meta.did))}):null,[t,s,e,l]),y=g=>{(c.current||!i)&&(p(g.currentTarget),c.current=!1)},v=()=>{p(null),l==="starting"&&(c.current=!0)};return o.jsxs(o.Fragment,{children:[o.jsx("span",{onMouseEnter:y,onMouseLeave:v,style:{cursor:"pointer"},children:u}),b]})}P.propTypes={blocklets:d.array.isRequired,children:d.node.isRequired,debounce:d.bool,status:d.string};function E({blocklets:t=[]}){const{t:u}=h(),[i,l]=a.useState(0),s=m(()=>t.length===0?[]:t.map(e=>{const r=e.meta.title||e.meta.name;return e.status==="running"?null:`${u("blocklet.startingProgress.starting",{name:r})}`}).filter(Boolean),[t,u]);if(a.useEffect(()=>{if(!s.length)return;let e=0;const r=setInterval(()=>{e++,e>=s.length&&(e=0),l(e)},I);return()=>{clearInterval(r)}},[s]),t.length===0)return null;const p=e=>{let r="message-before";return i===e?r="show-message":i<e&&(r="message-after"),r};return o.jsx(z,{direction:"column",alignItems:"center",justifyContent:"center",gap:1,children:o.jsx("div",{className:"waiter-message",children:s.map((e,r)=>{const n=p(r);return o.jsxs("div",{children:[o.jsx("span",{className:`message-block ${n}`,children:e}),o.jsx("span",{className:`placeholder-message ${n}`,children:e})]},r)})})})}E.propTypes={blocklets:d.array.isRequired};const z=w(f)`
  .waiter-message {
    position: relative;
    width: 100%;
    font-size: 16px;
    text-align: center;
    overflow: hidden;
    color: ${({theme:t})=>t.palette.primary.main};
    cursor: pointer;
    .message-block {
      position: absolute;
      left: 0;
      width: 100%;
      opacity: 0;
      transition: all ease 0.3s;
      user-select: none;
      &.message-before {
        transform: translate(-20px, 0);
      }
      &.message-after {
        transform: translate(20px, 0);
      }
      &.show-message {
        transform: translate(0, 0);
        opacity: 1;
        user-select: text;
        z-index: 2;
      }
    }

    .placeholder-message {
      user-select: none;
      display: none;
      opacity: 0;
      &.show-message {
        display: block;
      }
    }
  }
`,H={minWidth:200,position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:0,height:"100%",backgroundColor:"rgba(0, 0, 0, 0.1)",transition:"width 0.8s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:0,borderRadius:1},"&::before":{content:'""',position:"absolute",top:0,left:"0",height:"100%",background:"linear-gradient(90deg, rgba(212,249,248,0.01) 0%, rgba(212,249,248,0.05) 100%)",zIndex:1,pointerEvents:"none",transition:"width 0.8s cubic-bezier(0.68, -0.6, 0.32, 1.6) 0s",borderRadius:1},"&.Mui-disabled":{backgroundColor:"primary.main",color:"white"},"& .MuiCircularProgress-root":{color:"primary.contrastText",zIndex:2}};export{P,E as S,H as p};
