import{r as d,j as c}from"./react.6693569e.js";import{s as r,c as f}from"./index.ab3d776b.js";/* empty css               *//* empty css              */import{R as S}from"./Header.1d32b19c.js";import{g as x,R as g,a as v,L as C}from"./AppEntry.44f4db06.js";import{o as y}from"./mobxreact.esm.d8ee88ee.js";import{u as h}from"./ColorPicker.0ba20714.js";import{T as m,B as L}from"./antd.e57bc55d.js";import"./index.f92af1bb.js";import"./index.0a6cc9fb.js";/* empty css              *//* empty css              */import"./App.4008d6a0.js";import"./antd.5e666edb.js";const _="_pageTabs_1h9xx_1",E="_tabs_1h9xx_7",p={pageTabs:_,tabs:E};class T{constructor(){this._subscribers={}}publish(s,a,...o){var l;(l=this._subscribers[s])==null||l.forEach(t=>t(a,...o))}addEventListener(s,a){this._subscribers[s]||(this._subscribers[s]=[]),this._subscribers[s].push(a)}removeEventListener(s,a){this._subscribers[s]=this._subscribers[s].filter(o=>o!==a)}}const w=new T,u=w,k=y(({route:e})=>{const s=d.exports.useRef(null),a=d.exports.useMemo(()=>{if(e.currentUri)return{uri:e.currentUri};if(!e.entry||e.subEntry)return{uri:e.uri};const[t,i]=e.entry.slice(7).split("/");let n="";try{n=new URL(e.uri).searchParams.toString()}catch{}return{appId:t,entry:i,search:n}},[e,e.currentUri]),o=d.exports.useMemo(()=>({colors:{...r.routeStore.currentColors},...f(e.params),accessToken:r.authStore.accessToken}),[e.params,r.authStore.accessToken,r.routeStore.currentColors]),l=d.exports.useCallback(x({onTitleChange(t){const i=r.routeStore.tabs.find(n=>n.id===e.id);i.title=t,e.id===r.routeStore.current.id&&(r.routeStore.current.title=t),r.routeStore.tabs=[...r.routeStore.tabs]},onCloseWindow(){try{r.routeStore.remove(e.id)}catch{}},getCurrentTabKey(){return e.id}}),[e.id]);return d.exports.useEffect(()=>{const t=i=>{var n;i===e.id&&((n=s.current)==null||n.reload())};return u.addEventListener("refresh",t),()=>u.removeEventListener("refresh",t)},[e.id]),c(g,{ref:s,src:a,onMethod:l,params:o,onLocationChange:t=>e.currentUri=t})}),M=({route:e})=>{const s=d.exports.useRef(null),a=d.exports.useCallback(v({onTitleChange(t){const i=r.routeStore.tabs.find(n=>n.id===e.id);i.title=t,e.id===r.routeStore.current.id&&(r.routeStore.current.title=t),r.routeStore.tabs=[...r.routeStore.tabs]},onCloseWindow(){try{const t=r.routeStore.tabs.findIndex(i=>i.id===e.id);r.routeStore.tabs.splice(t,1),r.routeStore.tabs=[...r.routeStore.tabs],r.routeStore.current=r.routeStore.tabs[0],r.routeStore.save()}catch{}}}),[e.id]);d.exports.useEffect(()=>{const t=i=>{var n;i===e.id&&((n=s==null?void 0:s.current)==null||n.reload())};return u.addEventListener("refresh",t),()=>u.removeEventListener("refresh",t)},[e.id]);const o=d.exports.useMemo(()=>{var n,b;const[t,i]=((b=(n=e==null?void 0:e.entry)==null?void 0:n.slice(7))==null?void 0:b.split("/"))||[];return i},[]),l=d.exports.useMemo(()=>(e==null?void 0:e.params)||{},[e.params]);return c("div",{style:{width:"100%",height:"100%",border:"0",overflow:"auto",position:"relative"},children:c(C,{ref:s,entry:o,params:l,onMethod:a})})},q=({})=>{const e=h(()=>r.routeStore.current),s=h(()=>r.routeStore.tabs),a=d.exports.useCallback((o,l)=>{l==="remove"&&r.routeStore.remove(o)},[]);return c("div",{className:p.pageTabs,children:c(m,{activeKey:e.id,type:"editable-card",className:p.tabs,hideAdd:!0,tabBarExtraContent:{left:c(L,{style:{marginLeft:"8px"},type:"link",icon:c(S,{}),onClick:()=>{u.publish("refresh",e.id)}})},onChange:o=>r.routeStore.switch(o),onEdit:a,children:s.map(o=>c(m.TabPane,{tab:c("span",{children:o.title}),closable:s.length>1,children:o.internal?c(M,{route:o}):c(k,{route:o})},o.id))})})};export{q as default};
