expxagents 0.17.12 → 0.17.13
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/dashboard/assets/{BufferResource-BrF1rqIh.js → BufferResource-B_sVBYMj.js} +1 -1
- package/dist/dashboard/assets/{CanvasRenderer-Bvvt4cGi.js → CanvasRenderer-hkP-z9TW.js} +1 -1
- package/dist/dashboard/assets/{JarvisView-Ex2_oCYo.js → JarvisView-CHa8xTzb.js} +1 -1
- package/dist/dashboard/assets/{RenderTargetSystem-Mwb4-kdq.js → RenderTargetSystem-Cdw74k9b.js} +1 -1
- package/dist/dashboard/assets/{ThreeBackground-WzYXg5Xd.js → ThreeBackground-CjnKNeeJ.js} +1 -1
- package/dist/dashboard/assets/{WebGLRenderer-C9oCtm3q.js → WebGLRenderer-DnjjNW5h.js} +1 -1
- package/dist/dashboard/assets/{WebGPURenderer-DLRzrHD6.js → WebGPURenderer-Bg-RJB1D.js} +1 -1
- package/dist/dashboard/assets/{browserAll-BrawnolA.js → browserAll-Bld8lsfV.js} +1 -1
- package/dist/dashboard/assets/{index-C_3Uus7Y.js → index-8sDRFo37.js} +5 -5
- package/dist/dashboard/assets/{webworkerAll-BcgX8OcC.js → webworkerAll-CcL19ShU.js} +1 -1
- package/dist/dashboard/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ThreeBackground-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ThreeBackground-CjnKNeeJ.js","assets/three-BZk_I9Ly.js","assets/browserAll-Bld8lsfV.js","assets/webworkerAll-CcL19ShU.js","assets/WebGPURenderer-Bg-RJB1D.js","assets/BufferResource-B_sVBYMj.js","assets/RenderTargetSystem-Cdw74k9b.js","assets/WebGLRenderer-DnjjNW5h.js","assets/CanvasRenderer-hkP-z9TW.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const l of s.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();const F3="modulepreload",G3=function(e){return"/"+e},XS={},ou=function(t,n,i){let r=Promise.resolve();if(n&&n.length>0){let l=function(p){return Promise.all(p.map(m=>Promise.resolve(m).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),f=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=l(n.map(p=>{if(p=G3(p),p in XS)return;XS[p]=!0;const m=p.endsWith(".css"),g=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${g}`))return;const x=document.createElement("link");if(x.rel=m?"stylesheet":F3,m||(x.as="script"),x.crossOrigin="",x.href=p,f&&x.setAttribute("nonce",f),document.head.appendChild(x),m)return new Promise((v,S)=>{x.addEventListener("load",v),x.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${p}`)))})}))}function s(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return r.then(l=>{for(const c of l||[])c.status==="rejected"&&s(c.reason);return t().catch(s)})};function du(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var sb={exports:{}},Xp={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -58,7 +58,7 @@ Error generating stack: `+y.message+`
|
|
|
58
58
|
* @license MIT
|
|
59
59
|
*/var rE="popstate";function aE(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function J3(e={}){function t(i,r){var p;let s=(p=r.state)==null?void 0:p.masked,{pathname:l,search:c,hash:f}=s||i.location;return Hv("",{pathname:l,search:c,hash:f},r.state&&r.state.usr||null,r.state&&r.state.key||"default",s?{pathname:i.location.pathname,search:i.location.search,hash:i.location.hash}:void 0)}function n(i,r){return typeof r=="string"?r:km(r)}return tO(t,n,null,e)}function Wn(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function _l(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function eO(){return Math.random().toString(36).substring(2,10)}function sE(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Hv(e,t,n=null,i,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?_h(t):t,state:n,key:t&&t.key||i||eO(),unstable_mask:r}}function km({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function _h(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let i=e.indexOf("?");i>=0&&(t.search=e.substring(i),e=e.substring(0,i)),e&&(t.pathname=e)}return t}function tO(e,t,n,i={}){let{window:r=document.defaultView,v5Compat:s=!1}=i,l=r.history,c="POP",f=null,p=m();p==null&&(p=0,l.replaceState({...l.state,idx:p},""));function m(){return(l.state||{idx:null}).idx}function g(){c="POP";let T=m(),C=T==null?null:T-p;p=T,f&&f({action:c,location:A.location,delta:C})}function x(T,C){c="PUSH";let N=aE(T)?T:Hv(A.location,T,C);p=m()+1;let R=sE(N,p),O=A.createHref(N.unstable_mask||N);try{l.pushState(R,"",O)}catch(H){if(H instanceof DOMException&&H.name==="DataCloneError")throw H;r.location.assign(O)}s&&f&&f({action:c,location:A.location,delta:1})}function v(T,C){c="REPLACE";let N=aE(T)?T:Hv(A.location,T,C);p=m();let R=sE(N,p),O=A.createHref(N.unstable_mask||N);l.replaceState(R,"",O),s&&f&&f({action:c,location:A.location,delta:0})}function S(T){return nO(T)}let A={get action(){return c},get location(){return e(r,l)},listen(T){if(f)throw new Error("A history only accepts one active listener");return r.addEventListener(rE,g),f=T,()=>{r.removeEventListener(rE,g),f=null}},createHref(T){return t(r,T)},createURL:S,encodeLocation(T){let C=S(T);return{pathname:C.pathname,search:C.search,hash:C.hash}},push:x,replace:v,go(T){return l.go(T)}};return A}function nO(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Wn(n,"No window.location.(origin|href) available to create URL");let i=typeof e=="string"?e:km(e);return i=i.replace(/ $/,"%20"),!t&&i.startsWith("//")&&(i=n+i),new URL(i,n)}function MC(e,t,n="/"){return iO(e,t,n,!1)}function iO(e,t,n,i){let r=typeof t=="string"?_h(t):t,s=sc(r.pathname||"/",n);if(s==null)return null;let l=RC(e);rO(l);let c=null;for(let f=0;c==null&&f<l.length;++f){let p=mO(s);c=hO(l[f],p,i)}return c}function RC(e,t=[],n=[],i="",r=!1){let s=(l,c,f=r,p)=>{let m={relativePath:p===void 0?l.path||"":p,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(i)&&f)return;Wn(m.relativePath.startsWith(i),`Absolute route path "${m.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(i.length)}let g=po([i,m.relativePath]),x=n.concat(m);l.children&&l.children.length>0&&(Wn(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${g}".`),RC(l.children,t,x,g,f)),!(l.path==null&&!l.index)&&t.push({path:g,score:dO(g,l.index),routesMeta:x})};return e.forEach((l,c)=>{var f;if(l.path===""||!((f=l.path)!=null&&f.includes("?")))s(l,c);else for(let p of kC(l.path))s(l,c,!0,p)}),t}function kC(e){let t=e.split("/");if(t.length===0)return[];let[n,...i]=t,r=n.endsWith("?"),s=n.replace(/\?$/,"");if(i.length===0)return r?[s,""]:[s];let l=kC(i.join("/")),c=[];return c.push(...l.map(f=>f===""?s:[s,f].join("/"))),r&&c.push(...l),c.map(f=>e.startsWith("/")&&f===""?"/":f)}function rO(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:fO(t.routesMeta.map(i=>i.childrenIndex),n.routesMeta.map(i=>i.childrenIndex)))}var aO=/^:[\w-]+$/,sO=3,lO=2,oO=1,cO=10,uO=-2,lE=e=>e==="*";function dO(e,t){let n=e.split("/"),i=n.length;return n.some(lE)&&(i+=uO),t&&(i+=lO),n.filter(r=>!lE(r)).reduce((r,s)=>r+(aO.test(s)?sO:s===""?oO:cO),i)}function fO(e,t){return e.length===t.length&&e.slice(0,-1).every((i,r)=>i===t[r])?e[e.length-1]-t[t.length-1]:0}function hO(e,t,n=!1){let{routesMeta:i}=e,r={},s="/",l=[];for(let c=0;c<i.length;++c){let f=i[c],p=c===i.length-1,m=s==="/"?t:t.slice(s.length)||"/",g=w0({path:f.relativePath,caseSensitive:f.caseSensitive,end:p},m),x=f.route;if(!g&&p&&n&&!i[i.length-1].route.index&&(g=w0({path:f.relativePath,caseSensitive:f.caseSensitive,end:!1},m)),!g)return null;Object.assign(r,g.params),l.push({params:r,pathname:po([s,g.pathname]),pathnameBase:bO(po([s,g.pathnameBase])),route:x}),g.pathnameBase!=="/"&&(s=po([s,g.pathnameBase]))}return l}function w0(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,i]=pO(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let s=r[0],l=s.replace(/(.)\/+$/,"$1"),c=r.slice(1);return{params:i.reduce((p,{paramName:m,isOptional:g},x)=>{if(m==="*"){let S=c[x]||"";l=s.slice(0,s.length-S.length).replace(/(.)\/+$/,"$1")}const v=c[x];return g&&!v?p[m]=void 0:p[m]=(v||"").replace(/%2F/g,"/"),p},{}),pathname:s,pathnameBase:l,pattern:e}}function pO(e,t=!1,n=!0){_l(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let i=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,c,f,p,m)=>{if(i.push({paramName:c,isOptional:f!=null}),f){let g=m.charAt(p+l.length);return g&&g!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(i.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),i]}function mO(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return _l(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function sc(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,i=e.charAt(n);return i&&i!=="/"?null:e.slice(n)||"/"}var gO=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function yO(e,t="/"){let{pathname:n,search:i="",hash:r=""}=typeof e=="string"?_h(e):e,s;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?s=oE(n.substring(1),"/"):s=oE(n,t)):s=t,{pathname:s,search:vO(i),hash:_O(r)}}function oE(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function fb(e,t,n,i){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(i)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function xO(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function V1(e){let t=xO(e);return t.map((n,i)=>i===t.length-1?n.pathname:n.pathnameBase)}function W0(e,t,n,i=!1){let r;typeof e=="string"?r=_h(e):(r={...e},Wn(!r.pathname||!r.pathname.includes("?"),fb("?","pathname","search",r)),Wn(!r.pathname||!r.pathname.includes("#"),fb("#","pathname","hash",r)),Wn(!r.search||!r.search.includes("#"),fb("#","search","hash",r)));let s=e===""||r.pathname==="",l=s?"/":r.pathname,c;if(l==null)c=n;else{let g=t.length-1;if(!i&&l.startsWith("..")){let x=l.split("/");for(;x[0]==="..";)x.shift(),g-=1;r.pathname=x.join("/")}c=g>=0?t[g]:"/"}let f=yO(r,c),p=l&&l!=="/"&&l.endsWith("/"),m=(s||l===".")&&n.endsWith("/");return!f.pathname.endsWith("/")&&(p||m)&&(f.pathname+="/"),f}var po=e=>e.join("/").replace(/\/\/+/g,"/"),bO=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),vO=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,_O=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,SO=class{constructor(e,t,n,i=!1){this.status=e,this.statusText=t||"",this.internal=i,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function EO(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function wO(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var NC=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function OC(e,t){let n=e;if(typeof n!="string"||!gO.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let i=n,r=!1;if(NC)try{let s=new URL(window.location.href),l=n.startsWith("//")?new URL(s.protocol+n):new URL(n),c=sc(l.pathname,t);l.origin===s.origin&&c!=null?n=c+l.search+l.hash:r=!0}catch{_l(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:r,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var DC=["POST","PUT","PATCH","DELETE"];new Set(DC);var TO=["GET",...DC];new Set(TO);var Sh=j.createContext(null);Sh.displayName="DataRouter";var Q0=j.createContext(null);Q0.displayName="DataRouterState";var CO=j.createContext(!1),zC=j.createContext({isTransitioning:!1});zC.displayName="ViewTransition";var AO=j.createContext(new Map);AO.displayName="Fetchers";var MO=j.createContext(null);MO.displayName="Await";var ss=j.createContext(null);ss.displayName="Navigation";var $m=j.createContext(null);$m.displayName="Location";var El=j.createContext({outlet:null,matches:[],isDataRoute:!1});El.displayName="Route";var X1=j.createContext(null);X1.displayName="RouteError";var BC="REACT_ROUTER_ERROR",RO="REDIRECT",kO="ROUTE_ERROR_RESPONSE";function NO(e){if(e.startsWith(`${BC}:${RO}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function OO(e){if(e.startsWith(`${BC}:${kO}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new SO(t.status,t.statusText,t.data)}catch{}}function DO(e,{relative:t}={}){Wn(Eh(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:i}=j.useContext(ss),{hash:r,pathname:s,search:l}=Wm(e,{relative:t}),c=s;return n!=="/"&&(c=s==="/"?n:po([n,s])),i.createHref({pathname:c,search:l,hash:r})}function Eh(){return j.useContext($m)!=null}function wl(){return Wn(Eh(),"useLocation() may be used only in the context of a <Router> component."),j.useContext($m).location}var LC="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function jC(e){j.useContext(ss).static||j.useLayoutEffect(e)}function Z0(){let{isDataRoute:e}=j.useContext(El);return e?KO():zO()}function zO(){Wn(Eh(),"useNavigate() may be used only in the context of a <Router> component.");let e=j.useContext(Sh),{basename:t,navigator:n}=j.useContext(ss),{matches:i}=j.useContext(El),{pathname:r}=wl(),s=JSON.stringify(V1(i)),l=j.useRef(!1);return jC(()=>{l.current=!0}),j.useCallback((f,p={})=>{if(_l(l.current,LC),!l.current)return;if(typeof f=="number"){n.go(f);return}let m=W0(f,JSON.parse(s),r,p.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:po([t,m.pathname])),(p.replace?n.replace:n.push)(m,p.state,p)},[t,n,s,r,e])}var BO=j.createContext(null);function LO(e){let t=j.useContext(El).outlet;return j.useMemo(()=>t&&j.createElement(BO.Provider,{value:e},t),[t,e])}function Wm(e,{relative:t}={}){let{matches:n}=j.useContext(El),{pathname:i}=wl(),r=JSON.stringify(V1(n));return j.useMemo(()=>W0(e,JSON.parse(r),i,t==="path"),[e,r,i,t])}function jO(e,t){return IC(e,t)}function IC(e,t,n){var T;Wn(Eh(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=j.useContext(ss),{matches:r}=j.useContext(El),s=r[r.length-1],l=s?s.params:{},c=s?s.pathname:"/",f=s?s.pathnameBase:"/",p=s&&s.route;{let C=p&&p.path||"";HC(c,!p||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
60
60
|
|
|
61
|
-
Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let m=wl(),g;if(t){let C=typeof t=="string"?_h(t):t;Wn(f==="/"||((T=C.pathname)==null?void 0:T.startsWith(f)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${f}" but pathname "${C.pathname}" was given in the \`location\` prop.`),g=C}else g=m;let x=g.pathname||"/",v=x;if(f!=="/"){let C=f.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(C.length).join("/")}let S=MC(e,{pathname:v});_l(p||S!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),_l(S==null||S[S.length-1].route.element!==void 0||S[S.length-1].route.Component!==void 0||S[S.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let A=FO(S&&S.map(C=>Object.assign({},C,{params:Object.assign({},l,C.params),pathname:po([f,i.encodeLocation?i.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?f:po([f,i.encodeLocation?i.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),r,n);return t&&A?j.createElement($m.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...g},navigationType:"POP"}},A):A}function IO(){let e=XO(),t=EO(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:i},s={padding:"2px 4px",backgroundColor:i},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=j.createElement(j.Fragment,null,j.createElement("p",null,"💿 Hey developer 👋"),j.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",j.createElement("code",{style:s},"ErrorBoundary")," or"," ",j.createElement("code",{style:s},"errorElement")," prop on your route.")),j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:r},n):null,l)}var UO=j.createElement(IO,null),UC=class extends j.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=OO(e.digest);n&&(e=n)}let t=e!==void 0?j.createElement(El.Provider,{value:this.props.routeContext},j.createElement(X1.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?j.createElement(HO,{error:e},t):t}};UC.contextType=CO;var hb=new WeakMap;function HO({children:e,error:t}){let{basename:n}=j.useContext(ss);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let i=NO(t.digest);if(i){let r=hb.get(t);if(r)throw r;let s=OC(i.location,n);if(NC&&!hb.get(t))if(s.isExternal||i.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:i.replace}));throw hb.set(t,l),l}return j.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return e}function PO({routeContext:e,match:t,children:n}){let i=j.useContext(Sh);return i&&i.static&&i.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=t.route.id),j.createElement(El.Provider,{value:e},n)}function FO(e,t=[],n){let i=n==null?void 0:n.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(t.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let r=e,s=i==null?void 0:i.errors;if(s!=null){let m=r.findIndex(g=>g.route.id&&(s==null?void 0:s[g.route.id])!==void 0);Wn(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),r=r.slice(0,Math.min(r.length,m+1))}let l=!1,c=-1;if(n&&i){l=i.renderFallback;for(let m=0;m<r.length;m++){let g=r[m];if((g.route.HydrateFallback||g.route.hydrateFallbackElement)&&(c=m),g.route.id){let{loaderData:x,errors:v}=i,S=g.route.loader&&!x.hasOwnProperty(g.route.id)&&(!v||v[g.route.id]===void 0);if(g.route.lazy||S){n.isStatic&&(l=!0),c>=0?r=r.slice(0,c+1):r=[r[0]];break}}}}let f=n==null?void 0:n.onError,p=i&&f?(m,g)=>{var x,v;f(m,{location:i.location,params:((v=(x=i.matches)==null?void 0:x[0])==null?void 0:v.params)??{},unstable_pattern:wO(i.matches),errorInfo:g})}:void 0;return r.reduceRight((m,g,x)=>{let v,S=!1,A=null,T=null;i&&(v=s&&g.route.id?s[g.route.id]:void 0,A=g.route.errorElement||UO,l&&(c<0&&x===0?(HC("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),S=!0,T=null):c===x&&(S=!0,T=g.route.hydrateFallbackElement||null)));let C=t.concat(r.slice(0,x+1)),N=()=>{let R;return v?R=A:S?R=T:g.route.Component?R=j.createElement(g.route.Component,null):g.route.element?R=g.route.element:R=m,j.createElement(PO,{match:g,routeContext:{outlet:m,matches:C,isDataRoute:i!=null},children:R})};return i&&(g.route.ErrorBoundary||g.route.errorElement||x===0)?j.createElement(UC,{location:i.location,revalidation:i.revalidation,component:A,error:v,children:N(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:p}):N()},null)}function K1(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function GO(e){let t=j.useContext(Sh);return Wn(t,K1(e)),t}function qO(e){let t=j.useContext(Q0);return Wn(t,K1(e)),t}function YO(e){let t=j.useContext(El);return Wn(t,K1(e)),t}function $1(e){let t=YO(e),n=t.matches[t.matches.length-1];return Wn(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function VO(){return $1("useRouteId")}function XO(){var i;let e=j.useContext(X1),t=qO("useRouteError"),n=$1("useRouteError");return e!==void 0?e:(i=t.errors)==null?void 0:i[n]}function KO(){let{router:e}=GO("useNavigate"),t=$1("useNavigate"),n=j.useRef(!1);return jC(()=>{n.current=!0}),j.useCallback(async(r,s={})=>{_l(n.current,LC),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...s}))},[e,t])}var cE={};function HC(e,t,n){!t&&!cE[e]&&(cE[e]=!0,_l(!1,n))}j.memo($O);function $O({routes:e,future:t,state:n,isStatic:i,onError:r}){return IC(e,void 0,{state:n,isStatic:i,onError:r})}function WO({to:e,replace:t,state:n,relative:i}){Wn(Eh(),"<Navigate> may be used only in the context of a <Router> component.");let{static:r}=j.useContext(ss);_l(!r,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=j.useContext(El),{pathname:l}=wl(),c=Z0(),f=W0(e,V1(s),l,i==="path"),p=JSON.stringify(f);return j.useEffect(()=>{c(JSON.parse(p),{replace:t,state:n,relative:i})},[c,p,i,t,n]),null}function uE(e){return LO(e.context)}function ca(e){Wn(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function QO({basename:e="/",children:t=null,location:n,navigationType:i="POP",navigator:r,static:s=!1,unstable_useTransitions:l}){Wn(!Eh(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),f=j.useMemo(()=>({basename:c,navigator:r,static:s,unstable_useTransitions:l,future:{}}),[c,r,s,l]);typeof n=="string"&&(n=_h(n));let{pathname:p="/",search:m="",hash:g="",state:x=null,key:v="default",unstable_mask:S}=n,A=j.useMemo(()=>{let T=sc(p,c);return T==null?null:{location:{pathname:T,search:m,hash:g,state:x,key:v,unstable_mask:S},navigationType:i}},[c,p,m,g,x,v,i,S]);return _l(A!=null,`<Router basename="${c}"> is not able to match the URL "${p}${m}${g}" because it does not start with the basename, so the <Router> won't render anything.`),A==null?null:j.createElement(ss.Provider,{value:f},j.createElement($m.Provider,{children:t,value:A}))}function ZO({children:e,location:t}){return jO(Pv(e),t)}function Pv(e,t=[]){let n=[];return j.Children.forEach(e,(i,r)=>{if(!j.isValidElement(i))return;let s=[...t,r];if(i.type===j.Fragment){n.push.apply(n,Pv(i.props.children,s));return}Wn(i.type===ca,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Wn(!i.props.index||!i.props.children,"An index route cannot have child routes.");let l={id:i.props.id||s.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(l.children=Pv(i.props.children,s)),n.push(l)}),n}var h0="get",p0="application/x-www-form-urlencoded";function J0(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function JO(e){return J0(e)&&e.tagName.toLowerCase()==="button"}function e4(e){return J0(e)&&e.tagName.toLowerCase()==="form"}function t4(e){return J0(e)&&e.tagName.toLowerCase()==="input"}function n4(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function i4(e,t){return e.button===0&&(!t||t==="_self")&&!n4(e)}var Ay=null;function r4(){if(Ay===null)try{new FormData(document.createElement("form"),0),Ay=!1}catch{Ay=!0}return Ay}var a4=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function pb(e){return e!=null&&!a4.has(e)?(_l(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${p0}"`),null):e}function s4(e,t){let n,i,r,s,l;if(e4(e)){let c=e.getAttribute("action");i=c?sc(c,t):null,n=e.getAttribute("method")||h0,r=pb(e.getAttribute("enctype"))||p0,s=new FormData(e)}else if(JO(e)||t4(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let f=e.getAttribute("formaction")||c.getAttribute("action");if(i=f?sc(f,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||h0,r=pb(e.getAttribute("formenctype"))||pb(c.getAttribute("enctype"))||p0,s=new FormData(c,e),!r4()){let{name:p,type:m,value:g}=e;if(m==="image"){let x=p?`${p}.`:"";s.append(`${x}x`,"0"),s.append(`${x}y`,"0")}else p&&s.append(p,g)}}else{if(J0(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=h0,i=null,r=p0,l=e}return s&&r==="text/plain"&&(l=s,s=void 0),{action:i,method:n.toLowerCase(),encType:r,formData:s,body:l}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function W1(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function l4(e,t,n,i){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?r.pathname.endsWith("/")?r.pathname=`${r.pathname}_.${i}`:r.pathname=`${r.pathname}.${i}`:r.pathname==="/"?r.pathname=`_root.${i}`:t&&sc(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${i}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${i}`,r}async function o4(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function c4(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function u4(e,t,n){let i=await Promise.all(e.map(async r=>{let s=t.routes[r.route.id];if(s){let l=await o4(s,n);return l.links?l.links():[]}return[]}));return p4(i.flat(1).filter(c4).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function dE(e,t,n,i,r,s){let l=(f,p)=>n[p]?f.route.id!==n[p].route.id:!0,c=(f,p)=>{var m;return n[p].pathname!==f.pathname||((m=n[p].route.path)==null?void 0:m.endsWith("*"))&&n[p].params["*"]!==f.params["*"]};return s==="assets"?t.filter((f,p)=>l(f,p)||c(f,p)):s==="data"?t.filter((f,p)=>{var g;let m=i.routes[f.route.id];if(!m||!m.hasLoader)return!1;if(l(f,p)||c(f,p))return!0;if(f.route.shouldRevalidate){let x=f.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:((g=n[0])==null?void 0:g.params)||{},nextUrl:new URL(e,window.origin),nextParams:f.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function d4(e,t,{includeHydrateFallback:n}={}){return f4(e.map(i=>{let r=t.routes[i.route.id];if(!r)return[];let s=[r.module];return r.clientActionModule&&(s=s.concat(r.clientActionModule)),r.clientLoaderModule&&(s=s.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(s=s.concat(r.hydrateFallbackModule)),r.imports&&(s=s.concat(r.imports)),s}).flat(1))}function f4(e){return[...new Set(e)]}function h4(e){let t={},n=Object.keys(e).sort();for(let i of n)t[i]=e[i];return t}function p4(e,t){let n=new Set;return new Set(t),e.reduce((i,r)=>{let s=JSON.stringify(h4(r));return n.has(s)||(n.add(s),i.push({key:s,link:r})),i},[])}function PC(){let e=j.useContext(Sh);return W1(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function m4(){let e=j.useContext(Q0);return W1(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Q1=j.createContext(void 0);Q1.displayName="FrameworkContext";function FC(){let e=j.useContext(Q1);return W1(e,"You must render this element inside a <HydratedRouter> element"),e}function g4(e,t){let n=j.useContext(Q1),[i,r]=j.useState(!1),[s,l]=j.useState(!1),{onFocus:c,onBlur:f,onMouseEnter:p,onMouseLeave:m,onTouchStart:g}=t,x=j.useRef(null);j.useEffect(()=>{if(e==="render"&&l(!0),e==="viewport"){let A=C=>{C.forEach(N=>{l(N.isIntersecting)})},T=new IntersectionObserver(A,{threshold:.5});return x.current&&T.observe(x.current),()=>{T.disconnect()}}},[e]),j.useEffect(()=>{if(i){let A=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(A)}}},[i]);let v=()=>{r(!0)},S=()=>{r(!1),l(!1)};return n?e!=="intent"?[s,x,{}]:[s,x,{onFocus:$p(c,v),onBlur:$p(f,S),onMouseEnter:$p(p,v),onMouseLeave:$p(m,S),onTouchStart:$p(g,v)}]:[!1,x,{}]}function $p(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function y4({page:e,...t}){let{router:n}=PC(),i=j.useMemo(()=>MC(n.routes,e,n.basename),[n.routes,e,n.basename]);return i?j.createElement(b4,{page:e,matches:i,...t}):null}function x4(e){let{manifest:t,routeModules:n}=FC(),[i,r]=j.useState([]);return j.useEffect(()=>{let s=!1;return u4(e,t,n).then(l=>{s||r(l)}),()=>{s=!0}},[e,t,n]),i}function b4({page:e,matches:t,...n}){let i=wl(),{future:r,manifest:s,routeModules:l}=FC(),{basename:c}=PC(),{loaderData:f,matches:p}=m4(),m=j.useMemo(()=>dE(e,t,p,s,i,"data"),[e,t,p,s,i]),g=j.useMemo(()=>dE(e,t,p,s,i,"assets"),[e,t,p,s,i]),x=j.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let A=new Set,T=!1;if(t.forEach(N=>{var O;let R=s.routes[N.route.id];!R||!R.hasLoader||(!m.some(H=>H.route.id===N.route.id)&&N.route.id in f&&((O=l[N.route.id])!=null&&O.shouldRevalidate)||R.hasClientLoader?T=!0:A.add(N.route.id))}),A.size===0)return[];let C=l4(e,c,r.unstable_trailingSlashAwareDataRequests,"data");return T&&A.size>0&&C.searchParams.set("_routes",t.filter(N=>A.has(N.route.id)).map(N=>N.route.id).join(",")),[C.pathname+C.search]},[c,r.unstable_trailingSlashAwareDataRequests,f,i,s,m,t,e,l]),v=j.useMemo(()=>d4(g,s),[g,s]),S=x4(g);return j.createElement(j.Fragment,null,x.map(A=>j.createElement("link",{key:A,rel:"prefetch",as:"fetch",href:A,...n})),v.map(A=>j.createElement("link",{key:A,rel:"modulepreload",href:A,...n})),S.map(({key:A,link:T})=>j.createElement("link",{key:A,nonce:n.nonce,...T,crossOrigin:T.crossOrigin??n.crossOrigin})))}function v4(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var _4=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{_4&&(window.__reactRouterVersion="7.13.1")}catch{}function S4({basename:e,children:t,unstable_useTransitions:n,window:i}){let r=j.useRef();r.current==null&&(r.current=J3({window:i,v5Compat:!0}));let s=r.current,[l,c]=j.useState({action:s.action,location:s.location}),f=j.useCallback(p=>{n===!1?c(p):j.startTransition(()=>c(p))},[n]);return j.useLayoutEffect(()=>s.listen(f),[s,f]),j.createElement(QO,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:s,unstable_useTransitions:n})}var GC=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qC=j.forwardRef(function({onClick:t,discover:n="render",prefetch:i="none",relative:r,reloadDocument:s,replace:l,unstable_mask:c,state:f,target:p,to:m,preventScrollReset:g,viewTransition:x,unstable_defaultShouldRevalidate:v,...S},A){let{basename:T,navigator:C,unstable_useTransitions:N}=j.useContext(ss),R=typeof m=="string"&&GC.test(m),O=OC(m,T);m=O.to;let H=DO(m,{relative:r}),D=wl(),F=null;if(c){let $=W0(c,[],D.unstable_mask?D.unstable_mask.pathname:"/",!0);T!=="/"&&($.pathname=$.pathname==="/"?T:po([T,$.pathname])),F=C.createHref($)}let[Z,V,Y]=g4(i,S),P=T4(m,{replace:l,unstable_mask:c,state:f,target:p,preventScrollReset:g,relative:r,viewTransition:x,unstable_defaultShouldRevalidate:v,unstable_useTransitions:N});function q($){t&&t($),$.defaultPrevented||P($)}let ne=!(O.isExternal||s),I=j.createElement("a",{...S,...Y,href:(ne?F:void 0)||O.absoluteURL||H,onClick:ne?q:t,ref:v4(A,V),target:p,"data-discover":!R&&n==="render"?"true":void 0});return Z&&!R?j.createElement(j.Fragment,null,I,j.createElement(y4,{page:H})):I});qC.displayName="Link";var YC=j.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:i="",end:r=!1,style:s,to:l,viewTransition:c,children:f,...p},m){let g=Wm(l,{relative:p.relative}),x=wl(),v=j.useContext(Q0),{navigator:S,basename:A}=j.useContext(ss),T=v!=null&&k4(g)&&c===!0,C=S.encodeLocation?S.encodeLocation(g).pathname:g.pathname,N=x.pathname,R=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;n||(N=N.toLowerCase(),R=R?R.toLowerCase():null,C=C.toLowerCase()),R&&A&&(R=sc(R,A)||R);const O=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let H=N===C||!r&&N.startsWith(C)&&N.charAt(O)==="/",D=R!=null&&(R===C||!r&&R.startsWith(C)&&R.charAt(C.length)==="/"),F={isActive:H,isPending:D,isTransitioning:T},Z=H?t:void 0,V;typeof i=="function"?V=i(F):V=[i,H?"active":null,D?"pending":null,T?"transitioning":null].filter(Boolean).join(" ");let Y=typeof s=="function"?s(F):s;return j.createElement(qC,{...p,"aria-current":Z,className:V,ref:m,style:Y,to:l,viewTransition:c},typeof f=="function"?f(F):f)});YC.displayName="NavLink";var E4=j.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:i,replace:r,state:s,method:l=h0,action:c,onSubmit:f,relative:p,preventScrollReset:m,viewTransition:g,unstable_defaultShouldRevalidate:x,...v},S)=>{let{unstable_useTransitions:A}=j.useContext(ss),T=M4(),C=R4(c,{relative:p}),N=l.toLowerCase()==="get"?"get":"post",R=typeof c=="string"&&GC.test(c),O=H=>{if(f&&f(H),H.defaultPrevented)return;H.preventDefault();let D=H.nativeEvent.submitter,F=(D==null?void 0:D.getAttribute("formmethod"))||l,Z=()=>T(D||H.currentTarget,{fetcherKey:t,method:F,navigate:n,replace:r,state:s,relative:p,preventScrollReset:m,viewTransition:g,unstable_defaultShouldRevalidate:x});A&&n!==!1?j.startTransition(()=>Z()):Z()};return j.createElement("form",{ref:S,method:N,action:C,onSubmit:i?f:O,...v,"data-discover":!R&&e==="render"?"true":void 0})});E4.displayName="Form";function w4(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function VC(e){let t=j.useContext(Sh);return Wn(t,w4(e)),t}function T4(e,{target:t,replace:n,unstable_mask:i,state:r,preventScrollReset:s,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:f,unstable_useTransitions:p}={}){let m=Z0(),g=wl(),x=Wm(e,{relative:l});return j.useCallback(v=>{if(i4(v,t)){v.preventDefault();let S=n!==void 0?n:km(g)===km(x),A=()=>m(e,{replace:S,unstable_mask:i,state:r,preventScrollReset:s,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:f});p?j.startTransition(()=>A()):A()}},[g,m,x,n,i,r,t,e,s,l,c,f,p])}var C4=0,A4=()=>`__${String(++C4)}__`;function M4(){let{router:e}=VC("useSubmit"),{basename:t}=j.useContext(ss),n=VO(),i=e.fetch,r=e.navigate;return j.useCallback(async(s,l={})=>{let{action:c,method:f,encType:p,formData:m,body:g}=s4(s,t);if(l.navigate===!1){let x=l.fetcherKey||A4();await i(x,n,l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:g,formMethod:l.method||f,formEncType:l.encType||p,flushSync:l.flushSync})}else await r(l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:g,formMethod:l.method||f,formEncType:l.encType||p,replace:l.replace,state:l.state,fromRouteId:n,flushSync:l.flushSync,viewTransition:l.viewTransition})},[i,r,t,n])}function R4(e,{relative:t}={}){let{basename:n}=j.useContext(ss),i=j.useContext(El);Wn(i,"useFormAction must be used inside a RouteContext");let[r]=i.matches.slice(-1),s={...Wm(e||".",{relative:t})},l=wl();if(e==null){s.search=l.search;let c=new URLSearchParams(s.search),f=c.getAll("index");if(f.some(m=>m==="")){c.delete("index"),f.filter(g=>g).forEach(g=>c.append("index",g));let m=c.toString();s.search=m?`?${m}`:""}}return(!e||e===".")&&r.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:po([n,s.pathname])),km(s)}function k4(e,{relative:t}={}){let n=j.useContext(zC);Wn(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=VC("useViewTransitionState"),r=Wm(e,{relative:t});if(!n.isTransitioning)return!1;let s=sc(n.currentLocation.pathname,i)||n.currentLocation.pathname,l=sc(n.nextLocation.pathname,i)||n.nextLocation.pathname;return w0(r.pathname,l)!=null||w0(r.pathname,s)!=null}AC();const fE=e=>{let t;const n=new Set,i=(p,m)=>{const g=typeof p=="function"?p(t):p;if(!Object.is(g,t)){const x=t;t=m??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(v=>v(t,x))}},r=()=>t,c={setState:i,getState:r,getInitialState:()=>f,subscribe:p=>(n.add(p),()=>n.delete(p))},f=t=e(i,r,c);return c},N4=(e=>e?fE(e):fE),O4=e=>e;function D4(e,t=O4){const n=fm.useSyncExternalStore(e.subscribe,fm.useCallback(()=>t(e.getState()),[e,t]),fm.useCallback(()=>t(e.getInitialState()),[e,t]));return fm.useDebugValue(n),n}const hE=e=>{const t=N4(e),n=i=>D4(t,i);return Object.assign(n,t),n},fu=(e=>e?hE(e):hE),gl=fu(e=>({user:null,isAuthenticated:!1,loading:!1,error:null,login:async(t,n)=>{e({loading:!0,error:null});try{const i=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:n}),credentials:"include"}),r=await i.json();if(!i.ok){e({loading:!1,error:r.error||"Login failed"});return}e({user:r.user,isAuthenticated:!0,loading:!1,error:null})}catch{e({loading:!1,error:"Network error"})}},logout:async()=>{try{await fetch("/api/auth/logout",{method:"POST",credentials:"include"})}catch{}e({user:null,isAuthenticated:!1,error:null})},checkAuth:async()=>{e({loading:!0});try{const t=await fetch("/api/auth/me",{credentials:"include"});if(t.ok){const n=await t.json();e({user:n.user,isAuthenticated:!0,loading:!1})}else e({user:null,isAuthenticated:!1,loading:!1})}catch{e({user:null,isAuthenticated:!1,loading:!1})}},reset:()=>e({user:null,isAuthenticated:!1,loading:!1,error:null})})),vr=fu((e,t)=>({squads:[],selectedSquad:null,activeStates:{},uiComponents:{},fetchSquads:async()=>{try{const n=await fetch("/api/squads",{credentials:"include"});if(n.ok){const i=await n.json();e({squads:i.squads})}}catch{}},selectSquad:n=>e({selectedSquad:n}),setSquadState:(n,i)=>e(r=>({activeStates:{...r.activeStates,[n]:i}})),clearSquadState:n=>e(i=>{const{[n]:r,...s}=i.activeStates;return{activeStates:s}}),setUiComponents:(n,i)=>e(r=>({uiComponents:{...r.uiComponents,[n]:i}})),reset:()=>e({squads:[],selectedSquad:null,activeStates:{},uiComponents:{}})}));let z4=0;function pE(){return`local-${Date.now()}-${++z4}`}const rr=fu((e,t)=>({conversations:[],messages:[],conversationId:null,streaming:!1,streamingText:"",activity:null,error:null,addUserMessage:n=>{const i={id:pE(),role:"user",content:n,createdAt:new Date().toISOString()};e(r=>{const s=r.conversationId,l=s&&!r.messages.some(c=>c.role==="user")?r.conversations.map(c=>c.id===s?{...c,preview:n.slice(0,80)}:c):r.conversations;return{messages:[...r.messages,i],error:null,conversations:l}})},setConversationId:n=>{e({conversationId:n})},startStreaming:()=>{e({streaming:!0,streamingText:"",activity:null,error:null})},appendChunk:n=>{e(i=>({streamingText:i.streamingText+n,activity:null}))},setActivity:n=>{e({activity:n})},finishStreaming:n=>{const{streamingText:i}=t(),r={id:n,role:"assistant",content:i,createdAt:new Date().toISOString()};e(s=>({messages:[...s.messages,r],streaming:!1,streamingText:"",activity:null}))},addAgentDm:n=>{const i={id:pE(),role:"agent_dm",content:n.content,agentId:n.agentId,agentName:n.agentName,createdAt:new Date().toISOString()};e(r=>({messages:[...r.messages,i]}))},setError:n=>{e({error:n,streaming:!1,streamingText:"",activity:null})},loadConversations:async n=>{try{const i=await fetch(`/api/squads/${n}/conversations`,{credentials:"include"});if(!i.ok)return;const s=((await i.json()).data||[]).map(l=>({id:l.id,createdAt:l.created_at,preview:""}));for(const l of s)try{const c=await fetch(`/api/conversations/${l.id}/messages?limit=1`,{credentials:"include"});if(c.ok){const p=((await c.json()).data||[])[0];p&&(l.preview=p.content.slice(0,80))}}catch{}e({conversations:s})}catch{}},selectConversation:async n=>{e({conversationId:n,messages:[],streaming:!1,streamingText:"",activity:null,error:null});try{const i=await fetch(`/api/conversations/${n}/messages`,{credentials:"include"});if(!i.ok)return;const s=((await i.json()).data||[]).map(l=>({id:l.id,role:l.role,content:l.content,agentId:l.agent_id??void 0,agentName:l.agent_name??void 0,createdAt:l.created_at}));e({messages:s})}catch{}},deleteConversation:async(n,i)=>{try{if(!(await fetch(`/api/conversations/${n}`,{method:"DELETE",credentials:"include"})).ok)return;const{conversationId:s}=t();e(l=>({conversations:l.conversations.filter(c=>c.id!==n)})),s===n&&e({conversationId:null,messages:[]})}catch{}},loadHistory:async n=>{try{const i=await fetch(`/api/squads/${n}/conversations`,{credentials:"include"});if(!i.ok)return;const r=await i.json();if(!r.data||r.data.length===0){e({conversationId:null,messages:[],conversations:[]});return}const s=(r.data||[]).map(g=>({id:g.id,createdAt:g.created_at,preview:""})),l=r.data[0];e({conversationId:l.id,conversations:s});const c=await fetch(`/api/conversations/${l.id}/messages`,{credentials:"include"});if(!c.ok)return;const p=((await c.json()).data||[]).map(g=>({id:g.id,role:g.role,content:g.content,agentId:g.agent_id??void 0,agentName:g.agent_name??void 0,createdAt:g.created_at})),m=p.find(g=>g.role==="user");if(m){const g=s.findIndex(x=>x.id===l.id);g>=0&&(s[g].preview=m.content.slice(0,80))}e({messages:p,conversations:s});for(const g of s)if(g.id!==l.id)try{const x=await fetch(`/api/conversations/${g.id}/messages?limit=1`,{credentials:"include"});if(x.ok){const S=((await x.json()).data||[])[0];S&&(g.preview=S.content.slice(0,80))}}catch{}e({conversations:[...s]})}catch{}},reset:()=>e({conversations:[],messages:[],conversationId:null,streaming:!1,streamingText:"",error:null})}));function B4(e){const n=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`,i=new WebSocket(n),r=[];let s=!0;function l(c){i.readyState===WebSocket.OPEN?i.send(JSON.stringify(c)):i.readyState===WebSocket.CONNECTING&&r.push(c)}return i.onopen=()=>{var c,f;s||(f=(c=e.current).onReconnect)==null||f.call(c),s=!1;for(const p of r)i.send(JSON.stringify(p));r.length=0},i.onmessage=c=>{var f,p,m,g,x,v,S,A,T,C,N,R,O,H,D,F,Z,V,Y;try{const P=JSON.parse(c.data),q=e.current;switch(P.type){case"squad:state":(f=q.onSquadState)==null||f.call(q,P.squadName,P.state);break;case"squad:inactive":(p=q.onSquadInactive)==null||p.call(q,P.squadName,P.reason);break;case"chat:chunk":(m=q.onChatChunk)==null||m.call(q,P.squadName,P.conversationId,P.delta);break;case"chat:activity":(g=q.onChatActivity)==null||g.call(q,P.squadName,P.tool,P.summary);break;case"chat:done":(x=q.onChatDone)==null||x.call(q,P.squadName,P.conversationId,P.messageId);break;case"chat:error":(v=q.onChatError)==null||v.call(q,P.squadName,P.error);break;case"chat:agent_dm":(S=q.onChatAgentDm)==null||S.call(q,P.squadName,P.conversationId,P.agentId,P.agentName,P.message);break;case"chat:conversation_created":(A=q.onChatConversationCreated)==null||A.call(q,P.squadName,P.conversationId);break;case"agent:output_chunk":(T=q.onAgentOutputChunk)==null||T.call(q,P.squadName,P.agentId,P.agentName,P.delta);break;case"agent:step_start":(C=q.onAgentStepStart)==null||C.call(q,P.squadName,P.agentId,P.agentName,P.stepIndex,P.stepLabel);break;case"agent:step_complete":(N=q.onAgentStepComplete)==null||N.call(q,P.squadName,P.agentId,P.agentName,P.stepIndex,P.stepLabel);break;case"squad:checkpoint":(R=q.onSquadCheckpoint)==null||R.call(q,P.squadName,P.agentId,P.agentName,P.question);break;case"schedule:started":(O=q.onScheduleStarted)==null||O.call(q,P.squadName,P.jobId,P.attempt);break;case"schedule:chunk":(H=q.onScheduleChunk)==null||H.call(q,P.squadName,P.jobId,P.delta);break;case"schedule:done":(D=q.onScheduleDone)==null||D.call(q,P.squadName,P.jobId,P.summary,P.attempt);break;case"schedule:error":(F=q.onScheduleError)==null||F.call(q,P.squadName,P.jobId,P.error,P.attempt,P.willRetry);break;case"schedule:status_changed":(Z=q.onScheduleStatusChanged)==null||Z.call(q,P.squadName,P.status);break;case"kanban:task_updated":(V=q.onKanbanTaskUpdated)==null||V.call(q,P);break;case"a2ui:update":(Y=q.onA2uiUpdate)==null||Y.call(q,P.squadName,P.components);break}}catch{}},{subscribe:c=>{l({type:"squad:subscribe",squadName:c})},unsubscribe:c=>{l({type:"squad:unsubscribe",squadName:c})},sendChat:(c,f,p)=>{const m={type:"chat:send",squadName:c,message:f};p&&p.length>0&&(m.files=p),l(m)},newConversation:c=>{l({type:"chat:new_conversation",squadName:c})},sendCheckpointResponse:(c,f)=>{l({type:"squad:checkpoint_response",squadName:c,answer:f})},disconnect:()=>{i.close()}}}function L4(e={}){const t=j.useRef(null),n=j.useRef(e),i=j.useRef(new Set);n.current=e,j.useEffect(()=>{const p=B4(n);t.current=p;for(const m of i.current)p.subscribe(m);return()=>{p.disconnect()}},[]);const r=j.useCallback(p=>{var m;i.current.add(p),(m=t.current)==null||m.subscribe(p)},[]),s=j.useCallback(p=>{var m;i.current.delete(p),(m=t.current)==null||m.unsubscribe(p)},[]),l=j.useCallback((p,m,g)=>{var x;(x=t.current)==null||x.sendChat(p,m,g)},[]),c=j.useCallback(p=>{var m;(m=t.current)==null||m.newConversation(p)},[]),f=j.useCallback((p,m)=>{var g;(g=t.current)==null||g.sendCheckpointResponse(p,m)},[]);return{subscribe:r,unsubscribe:s,sendChat:l,newConversation:c,sendCheckpointResponse:f}}function j4(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),i=e%60,r=s=>s.toString().padStart(2,"0");return t>0?`${t}h ${r(n)}m ${r(i)}s`:`${n}m ${r(i)}s`}function I4({state:e}){const[t,n]=j.useState(0);return j.useEffect(()=>{if(!(e!=null&&e.startedAt)||e.status!=="running"){n(0);return}const i=new Date(e.startedAt).getTime(),r=()=>n(Math.floor((Date.now()-i)/1e3));r();const s=setInterval(r,1e3);return()=>clearInterval(s)},[e==null?void 0:e.startedAt,e==null?void 0:e.status]),_.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",height:"var(--statusbar-height)",padding:"0 var(--sp-4)",background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:e?_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[_.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:e.status==="running"?"var(--status-active)":e.status==="checkpoint"?"var(--status-warning)":"var(--status-idle)",boxShadow:e.status==="running"?"0 0 8px var(--status-active-glow)":"none",animation:e.status==="running"?"statusPulse 2s ease-in-out infinite":"none"}}),_.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Step ",e.step.current,"/",e.step.total]}),_.jsx("span",{style:{color:"var(--border-strong)"},children:"│"}),_.jsx("span",{children:e.step.label})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[e.handoff&&_.jsxs("span",{style:{color:"var(--accent)"},children:[e.handoff.from," → ",e.handoff.to]}),e.status==="running"&&_.jsx("span",{style:{color:"var(--text-secondary)"},children:j4(t)})]})]}):_.jsxs(_.Fragment,{children:[_.jsx("span",{children:"Ready"}),_.jsx("span",{children:"ExpxAgents Mission Control"})]})})}let Fv=null;function U4(e){Fv=e}function XC(e,t,n){Fv&&Fv(e,t,n)}let Gv=null;function H4(e){Gv=e}function P4(e){Gv&&Gv(e)}let qv=null;function F4(e){qv=e}function G4(e,t){qv&&qv(e,t)}const m0=32,fl=96,iu=64,pt={floor:13158600,floorHighlight:14211288,floorGrout:12105912,wall:15261904,wallTrim:11577496,baseboard:7035464,desk:15263976,deskTop:16119285,deskShadow:13684944,deskLeg:1710618,deskEdge:14737632,monitor:2236976,monitorScreen:1981020,monitorScreenGlow:2773120,monitorStand:3355456,keyboard:3355456,keyboardKey:4473941,chairSeat:2899536,chairBack:3426654,chairBase:4473924,chairWheel:3355443,plant:5025616,plantDark:3706428,plantLight:6732650,pot:9133628,potRim:10515018,soil:4863264,bookshelf:8020808,bookshelfEdge:9139029,bookColors:[15022389,2001125,4431943,16750592,9315498,35195,16635957],rug:6044974,rugPattern:8016448,rugBorder:4861472},Yv=[5227511,5025616,16750592,15022389,9315498,16771899],q4={idle:8947848,working:5025616,delivering:5227511,done:5025616,checkpoint:16750592},Br={counter:4073251,counterTop:6111287,machine:3622735,machineTop:4545124,machineLight:5025616,cup:14142664,cupShadow:12364452,saucer:14735052,sink:7901340,faucet:11583173,menu:5125166},Wa={table:6111287,tableTop:7162945,tableEdge:5125166,tableLeg:4073251,chair:3622735,chairSeat:4545124,chairBack:5533306,carpet:2503224,carpetPattern:3030340,whiteboard:15527921,whiteboardFrame:7901340},md={background:1713022,backgroundGlow:2635155,statusRunning:5025616,statusIdle:8947848,statusCheckpoint:16750592,statusCompleted:5025616},au={floor:11579568,tile:11053224,grout:10066329,stripe:12632256},la={floor:14477552,tile:12966120,tileGrout:11453652,wall:14740208,stall:11583173,stallDoor:9479342,sink:15527921,sinkBowl:16777215,mirror:11789820,mirrorFrame:7901340,toilet:16448250,toiletSeat:15658734,pipe:9479342},Aa={floor:6111287,carpet:5125166,carpetBorder:4073251,desk:4073251,deskTop:6111287,deskEdge:2890510,chair:1713022,chairSeat:2635155,window:8508666,windowFrame:5533306,windowSill:7901340,bookshelf:7162945,globe:4367861,nameplate:16766720},ah={wall:7901340,wallHighlight:10795204,doorFrame:6111287},ir={floor:16115411,tile:15259072,tileGrout:13942952,counter:6111287,counterTop:7951688,fridge:15527921,fridgeDoor:14737632,fridgeHandle:10395294,table:9268835,tableTop:10586239,chair:7162945,coffeeMaker:3622735,coffeeMakerLight:5025616,lamp:16766287},Ma={floor:14142664,carpet:6323595,carpetBorder:4545124,sofa:5533306,sofaCushion:6323595,sofaArm:4545124,tv:2171169,tvScreen:2503224,tvStand:4342338,sideTable:7951688,magazine:15684432,magazineAlt:4367861},ec=480,Za=360,id=400,Gi=60,Qa=120,mb=120,mE=160,gE=120,yE=160,Y4=64,V4=80,X4=fl+32,K4=iu+48,xE=2,KC=10,Wo=80;function My(e,t,n){const i=Math.max(0,Math.min(1,n));return e+(t-e)*i}function $4(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}const W4=["nw","ne","sw","se"],Q4={nw:"right",ne:"left",sw:"top",se:"top"};function T0(e){const t=KC,n=Math.max(1,e),i={nw:0,ne:0,sw:0,se:0},r=[];for(let W=0;W<n;W++){const B=W4[W%4];r.push({quadrant:B,slot:i[B]}),i[B]++}const s=Math.max(1,i.nw),l=Math.max(1,i.ne),c=Math.max(1,i.sw),f=Math.max(1,i.se),p=Math.max(id,Qa),m=s*(Za+t),g=l*(Za+t),x=Math.max(m+p,g+Qa),v=c*(Za+t),S=f*(Za+t),A=Math.max(mE,yE),T=Math.max(v+A+t,S+A+t),C=Math.max(ec,Qa+t+id),N=Math.max(ec,Qa),R=Math.max(ec,mb),O=Math.max(ec,gE),H=Math.max(C,R),D=Math.max(N,O),F=t+H+t+Gi+t+D+t,Z=t+x+t+Gi+t+T+t,V={x:t+H+t,y:t,width:Gi,height:Z-2*t},Y={x:t,y:t+x+t,width:F-2*t,height:Gi},P={x:V.x+V.width/2,y:Y.y+Y.height/2},q={x:V.x-t-id,y:Y.y-t-id,width:id,height:id},ne={x:q.x-t-Qa,y:Y.y-t-Qa,width:Qa,height:Qa},I={x:V.x+Gi+t,y:Y.y-t-Qa,width:Qa,height:Qa},$={x:V.x-t-mb,y:Y.y+Gi+t+c*(Za+t),width:mb,height:mE},z={x:V.x+Gi+t,y:Y.y+Gi+t+f*(Za+t),width:gE,height:yE},G=[],Q={};for(let W=0;W<n;W++){const{quadrant:B,slot:K}=r[W],J=Q4[B];let X;B==="nw"?X={x:V.x-t-ec,y:q.y-t-(K+1)*Za-K*t}:B==="ne"?X={x:V.x+Gi+t,y:I.y-t-(K+1)*Za-K*t}:B==="sw"?X={x:V.x-t-ec,y:Y.y+Gi+t+K*(Za+t)}:X={x:V.x+Gi+t,y:Y.y+Gi+t+K*(Za+t)},G.push({origin:X,width:ec,height:Za,quadrant:B,doorSide:J}),J==="right"||J==="left"?Q[`squad-${W}`]={x:V.x+Gi/2,y:X.y+Za/2}:Q[`squad-${W}`]={x:X.x+ec/2,y:Y.y+Gi/2}}return Q.ceo={x:V.x+Gi/2,y:q.y+id/2},Q["bathroom-male"]={x:ne.x+Qa/2,y:Y.y+Gi/2},Q["bathroom-female"]={x:I.x+Qa/2,y:Y.y+Gi/2},Q.kitchen={x:V.x+Gi/2,y:$.y+$.height/2},Q["rest-area"]={x:V.x+Gi/2,y:z.y+z.height/2},{totalWidth:F,totalHeight:Z,squadOrigins:G,ceoOffice:q,corridorH:Y,corridorV:V,bathroomMale:ne,bathroomFemale:I,kitchen:$,restArea:z,doorPoints:Q,corridorHub:P}}function th(e,t,n,i){const r=e%xE,s=Math.floor(e/xE);return{x:t.x+Y4+r*X4,y:t.y+V4+s*K4}}function bm(e,t,n){return{x:e.x+t-80,y:e.y+n-80}}function $C(e,t,n){return{x:e.x+t-160,y:e.y+Math.floor(n/2)}}function Z4(e,t){const n=t==="male"?e.bathroomMale:e.bathroomFemale;return{x:n.x+n.width/2,y:n.y+n.height/2}}function J4(e){return{x:e.kitchen.x+e.kitchen.width/2,y:e.kitchen.y+e.kitchen.height/2}}function eD(e){return{x:e.restArea.x+e.restArea.width/2,y:e.restArea.y+e.restArea.height/2}}function tD(e){const t=e.corridorV;if(t.height>0&&Math.random()<.5)return{x:t.x+10+Math.random()*Math.max(0,t.width-20),y:t.y+10+Math.random()*Math.max(0,t.height-20)};const n=e.corridorH;return{x:n.x+20+Math.random()*Math.max(0,n.width-40),y:n.y+10+Math.random()*Math.max(0,n.height-20)}}function bE(e,t){const n=t.corridorH;return e.x>=n.x&&e.x<=n.x+n.width&&e.y>=n.y&&e.y<=n.y+n.height}function vE(e,t){const n=t.corridorV;return e.x>=n.x&&e.x<=n.x+n.width&&e.y>=n.y&&e.y<=n.y+n.height}function nD(e,t){if(e==="ceo"){const i=t.ceoOffice;return{x:i.x+i.width/2,y:i.y+i.height/2}}if(e==="bathroom-male"){const i=t.bathroomMale;return{x:i.x+i.width/2,y:i.y+i.height/2}}if(e==="bathroom-female"){const i=t.bathroomFemale;return{x:i.x+i.width/2,y:i.y+i.height/2}}if(e==="kitchen"){const i=t.kitchen;return{x:i.x+i.width/2,y:i.y+i.height/2}}if(e==="rest-area"){const i=t.restArea;return{x:i.x+i.width/2,y:i.y+i.height/2}}const n=e.match(/^squad-(\d+)$/);if(n){const i=parseInt(n[1],10),r=t.squadOrigins[i];if(r)return{x:r.origin.x+r.width/2,y:r.origin.y+r.height/2}}return t.corridorHub}function vm(e,t,n,i){const r=i.doorPoints[t],s=i.doorPoints[n];if(!r||!s)return[e];const l=i.corridorHub,c=nD(n,i),f=bE(r,i)&&bE(s,i),p=vE(r,i)&&vE(s,i);return f||p?[e,r,s,c]:[e,r,l,s,c]}function Ry(e,t){const n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)}const _E=500,SE=50;let EE=0;function wE(e){return{idle:"idle",working:"working",delivering:"walking",done:"idle",checkpoint:"checkpoint"}[e]??"idle"}const ai=fu(e=>({rooms:[],activeRoom:null,bubbles:{},activityLog:{},checkpoints:{},agentVisuals:{},appendBubble:(t,n,i)=>{const r=`${t}:${n}`;e(s=>{var f;let c=(((f=s.bubbles[r])==null?void 0:f.text)??"")+i;return c.length>_E&&(c=c.slice(c.length-_E)),{bubbles:{...s.bubbles,[r]:{text:c,updatedAt:Date.now()}}}})},clearBubble:(t,n)=>{const i=`${t}:${n}`;e(r=>{const{[i]:s,...l}=r.bubbles;return{bubbles:l}})},clearAllBubbles:()=>e({bubbles:{}}),addActivity:(t,n,i)=>{const s={id:++EE,agentName:n,action:i,timestamp:Date.now()};e(l=>{var m;const f=[...((m=l.activityLog[t])==null?void 0:m.entries)??[],s],p=f.length>SE?f.slice(f.length-SE):f;return{activityLog:{...l.activityLog,[t]:{entries:p}}}})},setCheckpoint:(t,n,i,r)=>e(s=>({checkpoints:{...s.checkpoints,[t]:{agentId:n,agentName:i,question:r}}})),clearCheckpoint:t=>e(n=>{const{[t]:i,...r}=n.checkpoints;return{checkpoints:r}}),setActiveRoom:t=>e({activeRoom:t}),syncRooms:t=>e(n=>{const i=t;let r;return i.length===0?r=null:n.activeRoom===null||!i.includes(n.activeRoom)?r=i[0]:r=n.activeRoom,{rooms:i,activeRoom:r}}),setAgents:(t,n)=>e(i=>{const r=i.agentVisuals[t]??[],s=new Map(r.map(v=>[v.id,v])),l={x:0,y:0},c=T0(i.rooms.length),f=i.rooms.indexOf(t),p=c.squadOrigins[f],m=(p==null?void 0:p.width)??480,g=(p==null?void 0:p.height)??360,x=n.map((v,S)=>{const A=s.get(v.id);if(A){const N=v.status?wE(v.status):A.status,R=N!==A.status;let O=A.targetPosition;return R&&(N==="working"||N==="checkpoint"?O=th(S,l):O=bm(l,m,g)),{...A,name:v.name,avatar:v.avatar,deskIndex:S,status:N,targetPosition:O}}const T=v.status?wE(v.status):"idle",C=T==="working"||T==="checkpoint"?th(S,l):bm(l,m,g);return{id:v.id,name:v.name,avatar:v.avatar,colorIndex:S%6,status:T,deskIndex:S,position:C,targetPosition:null}});return{agentVisuals:{...i.agentVisuals,[t]:x}}}),setAgentStatus:(t,n,i)=>e(r=>{const s=r.agentVisuals[t];if(!s)return r;const l={x:0,y:0},c=T0(r.rooms.length),f=r.rooms.indexOf(t),p=c.squadOrigins[f],m=(p==null?void 0:p.width)??480,g=(p==null?void 0:p.height)??360,x=s.map(v=>{if(v.id!==n)return v;let S;return i==="working"||i==="checkpoint"?S=th(v.deskIndex,l):S=bm(l,m,g),{...v,status:i,targetPosition:S}});return{agentVisuals:{...r.agentVisuals,[t]:x}}}),reset:()=>{EE=0,e({rooms:[],activeRoom:null,bubbles:{},activityLog:{},checkpoints:{},agentVisuals:{}})}})),aQ={background:"#0a0a0f",grid:"rgba(0, 200, 255, 0.06)",orbStandby:"#1a3a5c",orbListening:"#00c8ff",orbProcessing:"#ff8c00",orbSpeaking:"#00ff88",panelBg:"rgba(0, 200, 255, 0.08)",panelBorder:"rgba(0, 200, 255, 0.25)",textPrimary:"#e0e8f0",textAccent:"#00c8ff",textJarvis:"#00ff88",particleStart:"#00c8ff"},iD={orbRadius:60,orbRingWidth:3,gridSpacing:40,particleCount:65,particleMinRadius:1,particleMaxRadius:3,waveformBars:32,waveformMaxHeight:40,panelWidth:180,panelPadding:12,transcriptLineHeight:20,standbyTimeoutMs:15e3,ttsSplitLength:300};let WC=0;function rD(){return`jarvis-${Date.now()}-${++WC}`}let lo=null;const gb=fu((e,t)=>({mode:"STANDBY",messages:[],streamingText:"",selectedSquad:null,userName:"",setMode:n=>e({mode:n}),addMessage:(n,i)=>{const r={id:rD(),role:n,content:i,createdAt:new Date().toISOString()};e(s=>({messages:[...s.messages,r]}))},appendChunk:n=>{e(i=>({streamingText:i.streamingText+n}))},finalizeMessage:n=>{const{streamingText:i}=t(),r={id:n,role:"assistant",content:i,createdAt:new Date().toISOString()};e(s=>({messages:[...s.messages,r],streamingText:""}))},selectSquad:n=>e({selectedSquad:n}),setUserName:n=>e({userName:n}),startStandbyTimer:()=>{lo&&clearTimeout(lo),lo=setTimeout(()=>{e({mode:"STANDBY"}),lo=null},iD.standbyTimeoutMs)},resetStandbyTimer:()=>{t().startStandbyTimer()},clearStandbyTimer:()=>{lo&&(clearTimeout(lo),lo=null)},reset:()=>{lo&&(clearTimeout(lo),lo=null),WC=0,e({mode:"STANDBY",messages:[],streamingText:"",selectedSquad:null,userName:""})}})),ua=fu((e,t)=>({jobs:[],loading:!1,history:{},historyLoading:{},fetchJobs:async()=>{e({loading:!0});try{const n=await fetch("/api/scheduler",{credentials:"include"});if(n.ok){const i=await n.json();e({jobs:i.data,loading:!1})}else e({loading:!1})}catch{e({loading:!1})}},createJob:async n=>(await fetch("/api/scheduler",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).ok?(t().fetchJobs(),!0):!1,deleteJob:async n=>{await fetch(`/api/scheduler/${n}`,{method:"DELETE",credentials:"include"}),t().fetchJobs()},pauseJob:async n=>{await fetch(`/api/scheduler/${n}/pause`,{method:"POST",credentials:"include"}),t().fetchJobs()},resumeJob:async n=>{await fetch(`/api/scheduler/${n}/resume`,{method:"POST",credentials:"include"}),t().fetchJobs()},triggerJob:async n=>{await fetch(`/api/scheduler/${n}/trigger`,{method:"POST",credentials:"include"})},updateJobStatus:(n,i)=>{e(r=>({jobs:r.jobs.map(s=>s.squad_name===n?{...s,status:i}:s)}))},fetchHistory:async n=>{e(i=>({historyLoading:{...i.historyLoading,[n]:!0}}));try{const i=await fetch(`/api/scheduler/${n}/history?limit=50`,{credentials:"include"});if(i.ok){const r=await i.json();e(s=>({history:{...s.history,[n]:r.data},historyLoading:{...s.historyLoading,[n]:!1}}))}else e(r=>({historyLoading:{...r.historyLoading,[n]:!1}}))}catch{e(i=>({historyLoading:{...i.historyLoading,[n]:!1}}))}}})),aD=600*1e3;function sD(){const[e,t]=j.useState(null),[n,i]=j.useState(!1),[r,s]=j.useState(!1),l=j.useCallback(async()=>{try{const f=await fetch("/api/system/version",{credentials:"include"});if(f.ok){const p=await f.json();t(p)}}catch{}},[]);j.useEffect(()=>{l();const f=setInterval(l,aD);return()=>clearInterval(f)},[l]);const c=async()=>{i(!0);try{await fetch("/api/system/update",{method:"POST",credentials:"include"})}catch{i(!1)}};return!(e!=null&&e.updateAvailable)||r?null:_.jsx("div",{"data-testid":"update-banner",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"var(--sp-3)",padding:"8px var(--sp-4)",background:"var(--surface-2)",borderBottom:"1px solid var(--accent)",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)",animation:"fadeIn 0.3s var(--ease-out) both"},children:n?_.jsxs("span",{style:{color:"var(--accent)"},children:["Updating to v",e.latest,"... Server will restart automatically."]}):_.jsxs(_.Fragment,{children:[_.jsxs("span",{children:["New version available: ",_.jsxs("strong",{style:{color:"var(--accent)"},children:["v",e.latest]}),_.jsxs("span",{style:{color:"var(--text-muted)",marginLeft:6},children:["(current: v",e.current,")"]})]}),_.jsx("button",{"data-testid":"btn-update",onClick:c,style:{padding:"3px 12px",borderRadius:"var(--radius-xs)",fontFamily:"var(--font-mono)",fontSize:"0.68rem",fontWeight:600,cursor:"pointer",border:"none",background:"var(--accent)",color:"var(--text-inverse)",transition:"opacity 0.15s ease"},children:"Update"}),_.jsx("button",{"data-testid":"btn-dismiss-update",onClick:()=>s(!0),style:{padding:"2px 6px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.68rem"},children:"✕"})]})})}function lD(){if(typeof window>"u")return"dark";const e=localStorage.getItem("expx-theme");return e==="light"||e==="dark"?e:"dark"}function TE(e){document.documentElement.setAttribute("data-theme",e),localStorage.setItem("expx-theme",e)}const C0=fu((e,t)=>({theme:lD(),toggle:()=>{const n=t().theme==="dark"?"light":"dark";TE(n),e({theme:n})},setTheme:n=>{TE(n),e({theme:n})}})),oD=j.lazy(()=>ou(()=>import("./ThreeBackground-WzYXg5Xd.js"),__vite__mapDeps([0,1])).then(e=>({default:e.ThreeBackground}))),cD=[{to:"/office",label:"Office",icon:"⬡"},{to:"/chat",label:"Chat",icon:"◈"},{to:"/kanban",label:"Kanban",icon:"▦"},{to:"/dashboard",label:"Dashboard",icon:"▣"},{to:"/scheduler",label:"Scheduler",icon:"⏣"},{to:"/email",label:"Email",icon:"✉"},{to:"/orgchart",label:"Org Chart",icon:"◎"},{to:"/graph",label:"Graph",icon:"◇"},{to:"/files",label:"Files",icon:"▤"},{to:"/settings",label:"Settings",icon:"⚙"}];function uD(){const e=gl(ie=>ie.user),t=gl(ie=>ie.isAuthenticated),n=gl(ie=>ie.loading),i=gl(ie=>ie.logout),r=gl(ie=>ie.checkAuth),s=Z0(),l=wl();l.pathname==="/office"||l.pathname;const c=l.pathname==="/jarvis",f=C0(ie=>ie.theme),p=C0(ie=>ie.toggle),m=vr(ie=>ie.squads),g=vr(ie=>ie.selectedSquad),x=vr(ie=>g?ie.activeStates[g]:null),v=vr(ie=>ie.fetchSquads),S=vr(ie=>ie.setSquadState),A=vr(ie=>ie.clearSquadState),T=j.useCallback((ie,de)=>{S(ie,de);const ye=ai.getState();ye.rooms.includes(ie)||ye.syncRooms([...ye.rooms,ie]),de.status!=="checkpoint"&&ye.clearCheckpoint(ie),de.agents&&ye.setAgents(ie,de.agents.map(me=>({id:me.id,name:me.name,status:me.status})))},[S]),C=j.useCallback(ie=>{A(ie);const de=ai.getState(),ye=de.agentVisuals[ie];if(ye)for(const me of ye)de.setAgentStatus(ie,me.id,"idle")},[A]),N=j.useCallback((ie,de)=>{rr.setState(ye=>({conversationId:de,messages:[],conversations:[{id:de,createdAt:new Date().toISOString(),preview:""},...ye.conversations.filter(me=>me.id!==de)]}))},[]),R=j.useCallback((ie,de,ye)=>{if(ie==="_jarvis"){gb.getState().appendChunk(ye);return}const me=rr.getState();me.streaming||me.startStreaming(),me.appendChunk(ye)},[]),O=j.useCallback((ie,de,ye)=>{if(ie==="_jarvis"){gb.getState().finalizeMessage(ye);return}rr.getState().finishStreaming(ye)},[]),H=j.useCallback((ie,de)=>{if(ie==="_jarvis"){gb.getState().setMode("LISTENING");return}rr.getState().setError(de)},[]),D=j.useCallback((ie,de,ye)=>{ie!=="_jarvis"&&rr.getState().setActivity(`${de}${ye?" "+ye:""}`)},[]),F=j.useCallback((ie,de,ye,me,le)=>{rr.getState().addAgentDm({agentId:ye,agentName:me,content:le})},[]),Z=j.useCallback((ie,de,ye,me)=>{ai.getState().appendBubble(ie,de,me)},[]),V=j.useCallback((ie,de,ye,me,le)=>{ai.getState().addActivity(ie,ye,`started "${le}"`),ai.getState().setAgentStatus(ie,de,"working")},[]),Y=j.useCallback((ie,de,ye,me,le)=>{ai.getState().addActivity(ie,ye,`completed "${le}"`),ai.getState().setAgentStatus(ie,de,"idle")},[]),P=j.useCallback((ie,de,ye,me)=>{ai.getState().setCheckpoint(ie,de,ye,me),ai.getState().setAgentStatus(ie,de,"checkpoint")},[]),q=j.useCallback(()=>{ai.getState().clearAllBubbles()},[]),ne=j.useCallback((ie,de,ye)=>{ua.getState().fetchJobs()},[]),I=j.useCallback((ie,de,ye,me)=>{ua.getState().fetchJobs()},[]),$=j.useCallback((ie,de,ye,me,le)=>{ua.getState().fetchJobs()},[]),z=j.useCallback((ie,de)=>{ua.getState().updateJobStatus(ie,de)},[]),G=j.useCallback(ie=>{window.dispatchEvent(new CustomEvent("kanban:task_updated",{detail:ie}))},[]),Q=j.useCallback((ie,de)=>{vr.getState().setUiComponents(ie,de)},[]),{subscribe:W,unsubscribe:B,sendChat:K,newConversation:J,sendCheckpointResponse:X}=L4({onSquadState:T,onSquadInactive:C,onChatConversationCreated:N,onChatChunk:R,onChatActivity:D,onChatDone:O,onChatError:H,onChatAgentDm:F,onAgentOutputChunk:Z,onAgentStepStart:V,onAgentStepComplete:Y,onSquadCheckpoint:P,onReconnect:q,onScheduleStarted:ne,onScheduleDone:I,onScheduleError:$,onScheduleStatusChanged:z,onKanbanTaskUpdated:G,onA2uiUpdate:Q});j.useEffect(()=>{U4(K)},[K]),j.useEffect(()=>{H4(J)},[J]),j.useEffect(()=>{F4(X)},[X]),j.useEffect(()=>{v().then(()=>{const{squads:ie}=vr.getState();if(ie.length>0){const de=ai.getState(),ye=ie.map(Re=>Re.code),me=de.rooms,le=[...new Set([...me,...ye])];de.syncRooms(le);for(const Re of ie)!de.agentVisuals[Re.code]&&Re.agents&&Re.agents.length>0&&de.setAgents(Re.code,Re.agents.map(Le=>({id:Le.id,name:Le.name,avatar:Le.avatar,status:"idle"})))}})},[v]);const ce=ai(ie=>ie.rooms);return j.useEffect(()=>{for(const ie of ce)W(ie);return()=>{for(const ie of ce)B(ie)}},[ce,W,B]),j.useEffect(()=>(W("_expxagents"),()=>B("_expxagents")),[W,B]),j.useEffect(()=>{if(c)return W("_jarvis"),()=>B("_jarvis")},[c,W,B]),j.useEffect(()=>{t||r()},[]),j.useEffect(()=>{!n&&!t&&s("/login",{state:{from:l.pathname}})},[n,t,s,l.pathname]),c?_.jsx(uE,{}):_.jsxs("div",{className:"noise-bg",style:{display:"flex",flexDirection:"column",height:"100vh",background:"var(--surface-0)",color:"var(--text-primary)"},children:[_.jsxs("header",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",height:"var(--header-height)",padding:"0 var(--sp-4)",background:"var(--surface-1)",borderBottom:"1px solid var(--border-subtle)",position:"relative",zIndex:10},children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[_.jsx("div",{style:{width:28,height:28,borderRadius:"var(--radius-sm)",background:"linear-gradient(135deg, var(--accent), var(--accent-dim))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.8rem",fontWeight:700,color:"var(--text-inverse)",boxShadow:"0 0 12px var(--accent-glow-strong)"},children:"EX"}),_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",letterSpacing:"-0.02em"},children:"ExpxAgents"}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",background:"var(--surface-3)",padding:"2px 6px",borderRadius:"var(--radius-xs)",letterSpacing:"0.05em"},children:"MISSION CONTROL"})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-4)"},children:[_.jsx("button",{"data-testid":"btn-restart-server",onClick:async()=>{if(confirm("Restart the server? It will be briefly unavailable."))try{await fetch("/api/system/restart",{method:"POST",credentials:"include"})}catch{}},title:"Restart server",style:{background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.7rem",padding:"3px 8px",borderRadius:"var(--radius-xs)",transition:"all var(--duration-fast) var(--ease-out)",display:"flex",alignItems:"center",gap:4},onMouseEnter:ie=>{ie.currentTarget.style.color="var(--accent)",ie.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:ie=>{ie.currentTarget.style.color="var(--text-muted)",ie.currentTarget.style.borderColor="var(--border-subtle)"},children:"↻ Restart"}),_.jsx("button",{"data-testid":"btn-toggle-theme",onClick:p,title:`Switch to ${f==="dark"?"light":"dark"} mode`,style:{background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.85rem",padding:"3px 8px",borderRadius:"var(--radius-xs)",transition:"all var(--duration-fast) var(--ease-out)",display:"flex",alignItems:"center",gap:4,lineHeight:1},onMouseEnter:ie=>{ie.currentTarget.style.color="var(--accent)",ie.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:ie=>{ie.currentTarget.style.color="var(--text-muted)",ie.currentTarget.style.borderColor="var(--border-subtle)"},children:f==="dark"?"☀":"☽"}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-2)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)"},children:[_.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:"var(--status-active)",boxShadow:"0 0 8px var(--status-active-glow)",animation:"statusPulse 2s ease-in-out infinite"}}),_.jsx("span",{children:e==null?void 0:e.username})]}),_.jsx("button",{onClick:i,className:"btn-ghost",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-display)",fontSize:"0.75rem",padding:"4px 8px",borderRadius:"var(--radius-xs)",transition:"color var(--duration-fast) var(--ease-out)"},onMouseEnter:ie=>ie.currentTarget.style.color="var(--status-error)",onMouseLeave:ie=>ie.currentTarget.style.color="var(--text-muted)",children:"Logout"})]})]}),_.jsx(sD,{}),_.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[_.jsxs("aside",{style:{width:"var(--sidebar-width)",background:"var(--surface-1)",borderRight:"1px solid var(--border-subtle)",display:"flex",flexDirection:"column",overflowY:"auto"},children:[_.jsxs("nav",{style:{padding:"var(--sp-3)",display:"flex",flexDirection:"column",gap:"var(--sp-1)",flex:1},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.1em",padding:"0 var(--sp-2)",marginBottom:"var(--sp-1)"},children:"Navigation"}),cD.map(ie=>_.jsxs(YC,{to:ie.to,style:({isActive:de})=>({display:"flex",alignItems:"center",gap:"var(--sp-2)",padding:"8px 10px",borderRadius:"var(--radius-sm)",textDecoration:"none",fontSize:"0.82rem",fontWeight:de?600:400,color:de?"var(--accent)":"var(--text-secondary)",background:de?"var(--accent-glow)":"transparent",border:de?"1px solid var(--accent-glow)":"1px solid transparent",transition:"all var(--duration-fast) var(--ease-out)"}),children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.85rem",width:20,textAlign:"center",opacity:.7},children:ie.icon}),ie.label]},ie.to)),_.jsx("div",{style:{height:1,margin:"var(--sp-2) var(--sp-2)",background:"var(--border-subtle)"}}),_.jsxs("a",{href:"/jarvis",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"var(--sp-2)",padding:"8px 10px",borderRadius:"var(--radius-sm)",textDecoration:"none",fontSize:"0.82rem",fontWeight:500,color:"var(--status-active)",background:"var(--status-active-glow)",border:"1px solid var(--status-active-glow)",transition:"all var(--duration-fast) var(--ease-out)"},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.85rem",width:20,textAlign:"center",opacity:.7},children:"◉"}),"Jarvis",_.jsx("span",{style:{marginLeft:"auto",fontFamily:"var(--font-mono)",fontSize:"0.55rem",opacity:.6},children:"↗"})]})]}),_.jsxs("div",{style:{padding:"var(--sp-3)",borderTop:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",display:"flex",justifyContent:"space-between"},children:[_.jsxs("span",{children:[m.length," squad",m.length!==1?"s":""]}),_.jsx("span",{children:"v0.1.0"})]})]}),_.jsxs("main",{className:"grid-bg",style:{flex:1,overflow:"hidden",position:"relative"},children:[_.jsx(j.Suspense,{fallback:null,children:_.jsx(oD,{opacity:.4})}),_.jsx("div",{style:{position:"relative",zIndex:1,height:"100%",overflow:"auto"},children:_.jsx(uE,{})})]})]}),_.jsx(I4,{state:x})]})}const dD=j.lazy(()=>ou(()=>import("./ThreeBackground-WzYXg5Xd.js"),__vite__mapDeps([0,1])).then(e=>({default:e.ThreeBackground})));function fD(){var S;const[e,t]=j.useState(""),[n,i]=j.useState(""),r=gl(A=>A.login),s=gl(A=>A.loading),l=gl(A=>A.error),c=gl(A=>A.isAuthenticated),f=Z0(),m=((S=wl().state)==null?void 0:S.from)||"/";j.useEffect(()=>{c&&f(m,{replace:!0})},[c,f,m]);const g=A=>{A.preventDefault(),r(e,n)},x=C0(A=>A.theme),v=C0(A=>A.toggle);return _.jsxs("div",{className:"noise-bg",style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"100vh",background:"var(--surface-0)",position:"relative",overflow:"hidden"},children:[_.jsx(j.Suspense,{fallback:null,children:_.jsx(dD,{opacity:.6})}),_.jsx("button",{onClick:v,title:`Switch to ${x==="dark"?"light":"dark"} mode`,style:{position:"absolute",top:16,right:16,zIndex:10,background:"var(--surface-2)",border:"1px solid var(--border-default)",color:"var(--text-secondary)",cursor:"pointer",fontSize:"1rem",padding:"6px 10px",borderRadius:"var(--radius-sm)",transition:"all var(--duration-fast) var(--ease-out)",lineHeight:1},children:x==="dark"?"☀":"☽"}),_.jsxs("div",{style:{animation:"fadeInUp 0.6s var(--ease-out) both",width:360,position:"relative",zIndex:1},children:[_.jsxs("div",{style:{textAlign:"center",marginBottom:"var(--sp-8)"},children:[_.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:48,height:48,borderRadius:"var(--radius-md)",background:"linear-gradient(135deg, var(--accent), var(--accent-dim))",fontSize:"1.1rem",fontWeight:800,color:"var(--text-inverse)",boxShadow:"var(--shadow-glow-strong)",marginBottom:"var(--sp-4)"},children:"EX"}),_.jsx("h1",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1.4rem",color:"var(--text-primary)",letterSpacing:"-0.02em",marginBottom:"var(--sp-1)"},children:"ExpxAgents"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.15em"},children:"Mission Control"})]}),_.jsxs("form",{onSubmit:g,className:"glass",style:{padding:"var(--sp-6)",borderRadius:"var(--radius-lg)",boxShadow:"var(--shadow-lg)"},children:[l&&_.jsx("div",{style:{padding:"var(--sp-2) var(--sp-3)",marginBottom:"var(--sp-4)",borderRadius:"var(--radius-sm)",background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.2)",color:"var(--status-error)",fontSize:"0.8rem",fontFamily:"var(--font-mono)"},children:l}),_.jsxs("div",{style:{marginBottom:"var(--sp-3)"},children:[_.jsx("label",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:"var(--sp-1)"},children:"Username"}),_.jsx("input",{type:"text",className:"input",placeholder:"Enter username",value:e,onChange:A=>t(A.target.value),autoFocus:!0})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("label",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:"var(--sp-1)"},children:"Password"}),_.jsx("input",{type:"password",className:"input",placeholder:"Enter password",value:n,onChange:A=>i(A.target.value)})]}),_.jsx("button",{type:"submit",disabled:s,className:"btn btn-accent",style:{width:"100%",padding:"var(--sp-3)",fontSize:"0.85rem",cursor:s?"wait":"pointer",opacity:s?.7:1},children:s?"Authenticating...":"Access Mission Control"})]}),_.jsx("p",{style:{textAlign:"center",marginTop:"var(--sp-4)",fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)"},children:"AI Squad Orchestration Platform"})]})]})}function QC(e,t,n){if(!e)return;if(n(e)===!0)return e;let i=e.child;for(;i;){const r=QC(i,t,n);if(r)return r;i=i.sibling}}function ZC(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}const Z1=ZC(j.createContext(null));let JC=class extends j.Component{render(){return j.createElement(Z1.Provider,{value:this._reactInternals},this.props.children)}};function hD(){const e=j.useContext(Z1);if(e===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const t=j.useId();return j.useMemo(()=>{for(const n of[e,e==null?void 0:e.alternate]){if(!n)continue;const i=QC(n,!1,r=>{let s=r.memoizedState;for(;s;){if(s.memoizedState===t)return!0;s=s.next}});if(i)return i}},[e,t])}const pD=Symbol.for("react.context"),mD=e=>e!==null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===pD;function gD(){const e=hD(),[t]=j.useState(()=>new Map);t.clear();let n=e;for(;n;){const i=n.type;mD(i)&&i!==Z1&&!t.has(i)&&t.set(i,j.use(ZC(i))),n=n.return}return t}function yD(){const e=gD();return j.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>i=>j.createElement(t,null,j.createElement(n.Provider,{...i,value:e.get(n)})),t=>j.createElement(JC,{...t})),[e])}var kt=(e=>(e.Application="application",e.WebGLPipes="webgl-pipes",e.WebGLPipesAdaptor="webgl-pipes-adaptor",e.WebGLSystem="webgl-system",e.WebGPUPipes="webgpu-pipes",e.WebGPUPipesAdaptor="webgpu-pipes-adaptor",e.WebGPUSystem="webgpu-system",e.CanvasSystem="canvas-system",e.CanvasPipesAdaptor="canvas-pipes-adaptor",e.CanvasPipes="canvas-pipes",e.Asset="asset",e.LoadParser="load-parser",e.ResolveParser="resolve-parser",e.CacheParser="cache-parser",e.DetectionParser="detection-parser",e.MaskEffect="mask-effect",e.BlendMode="blend-mode",e.TextureSource="texture-source",e.Environment="environment",e.ShapeBuilder="shape-builder",e.Batcher="batcher",e))(kt||{});const Vv=e=>{if(typeof e=="function"||typeof e=="object"&&e.extension){if(!e.extension)throw new Error("Extension class must have an extension object");e={...typeof e.extension!="object"?{type:e.extension}:e.extension,ref:e}}if(typeof e=="object")e={...e};else throw new Error("Invalid extension type");return typeof e.type=="string"&&(e.type=[e.type]),e},ky=(e,t)=>Vv(e).priority??t,li={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...e){return e.map(Vv).forEach(t=>{t.type.forEach(n=>{var i,r;return(r=(i=this._removeHandlers)[n])==null?void 0:r.call(i,t)})}),this},add(...e){return e.map(Vv).forEach(t=>{t.type.forEach(n=>{var s,l;const i=this._addHandlers,r=this._queue;i[n]?(l=i[n])==null||l.call(i,t):(r[n]=r[n]||[],(s=r[n])==null||s.push(t))})}),this},handle(e,t,n){var l;const i=this._addHandlers,r=this._removeHandlers;if(i[e]||r[e])throw new Error(`Extension type ${e} already has a handler`);i[e]=t,r[e]=n;const s=this._queue;return s[e]&&((l=s[e])==null||l.forEach(c=>t(c)),delete s[e]),this},handleByMap(e,t){return this.handle(e,n=>{n.name&&(t[n.name]=n.ref)},n=>{n.name&&delete t[n.name]})},handleByNamedList(e,t,n=-1){return this.handle(e,i=>{t.findIndex(s=>s.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((s,l)=>ky(l.value,n)-ky(s.value,n)))},i=>{const r=t.findIndex(s=>s.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(e,t,n=-1){return this.handle(e,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,s)=>ky(s,n)-ky(r,n)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})},mixin(e,...t){for(const n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}},xD={extension:{type:kt.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await ou(()=>import("./browserAll-BrawnolA.js"),__vite__mapDeps([2,3]))}},bD={extension:{type:kt.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await ou(()=>import("./webworkerAll-BcgX8OcC.js"),[])}};class br{constructor(t,n,i){this._x=n||0,this._y=i||0,this._observer=t}clone(t){return new br(t??this._observer,this._x,this._y)}set(t=0,n=t){return(this._x!==t||this._y!==n)&&(this._x=t,this._y=n,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}var yb={exports:{}},CE;function vD(){return CE||(CE=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(n=!1));function r(f,p,m){this.fn=f,this.context=p,this.once=m||!1}function s(f,p,m,g,x){if(typeof m!="function")throw new TypeError("The listener must be a function");var v=new r(m,g||f,x),S=n?n+p:p;return f._events[S]?f._events[S].fn?f._events[S]=[f._events[S],v]:f._events[S].push(v):(f._events[S]=v,f._eventsCount++),f}function l(f,p){--f._eventsCount===0?f._events=new i:delete f._events[p]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var p=[],m,g;if(this._eventsCount===0)return p;for(g in m=this._events)t.call(m,g)&&p.push(n?g.slice(1):g);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(m)):p},c.prototype.listeners=function(p){var m=n?n+p:p,g=this._events[m];if(!g)return[];if(g.fn)return[g.fn];for(var x=0,v=g.length,S=new Array(v);x<v;x++)S[x]=g[x].fn;return S},c.prototype.listenerCount=function(p){var m=n?n+p:p,g=this._events[m];return g?g.fn?1:g.length:0},c.prototype.emit=function(p,m,g,x,v,S){var A=n?n+p:p;if(!this._events[A])return!1;var T=this._events[A],C=arguments.length,N,R;if(T.fn){switch(T.once&&this.removeListener(p,T.fn,void 0,!0),C){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,m),!0;case 3:return T.fn.call(T.context,m,g),!0;case 4:return T.fn.call(T.context,m,g,x),!0;case 5:return T.fn.call(T.context,m,g,x,v),!0;case 6:return T.fn.call(T.context,m,g,x,v,S),!0}for(R=1,N=new Array(C-1);R<C;R++)N[R-1]=arguments[R];T.fn.apply(T.context,N)}else{var O=T.length,H;for(R=0;R<O;R++)switch(T[R].once&&this.removeListener(p,T[R].fn,void 0,!0),C){case 1:T[R].fn.call(T[R].context);break;case 2:T[R].fn.call(T[R].context,m);break;case 3:T[R].fn.call(T[R].context,m,g);break;case 4:T[R].fn.call(T[R].context,m,g,x);break;default:if(!N)for(H=1,N=new Array(C-1);H<C;H++)N[H-1]=arguments[H];T[R].fn.apply(T[R].context,N)}}return!0},c.prototype.on=function(p,m,g){return s(this,p,m,g,!1)},c.prototype.once=function(p,m,g){return s(this,p,m,g,!0)},c.prototype.removeListener=function(p,m,g,x){var v=n?n+p:p;if(!this._events[v])return this;if(!m)return l(this,v),this;var S=this._events[v];if(S.fn)S.fn===m&&(!x||S.once)&&(!g||S.context===g)&&l(this,v);else{for(var A=0,T=[],C=S.length;A<C;A++)(S[A].fn!==m||x&&!S[A].once||g&&S[A].context!==g)&&T.push(S[A]);T.length?this._events[v]=T.length===1?T[0]:T:l(this,v)}return this},c.prototype.removeAllListeners=function(p){var m;return p?(m=n?n+p:p,this._events[m]&&l(this,m)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c})(yb)),yb.exports}var _D=vD();const yo=du(_D),SD=Math.PI*2,ED=180/Math.PI,wD=Math.PI/180;class Lr{constructor(t=0,n=0){this.x=0,this.y=0,this.x=t,this.y=n}clone(){return new Lr(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,n=t){return this.x=t,this.y=n,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return xb.x=0,xb.y=0,xb}}const xb=new Lr;class Ht{constructor(t=1,n=0,i=0,r=1,s=0,l=0){this.array=null,this.a=t,this.b=n,this.c=i,this.d=r,this.tx=s,this.ty=l}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,n,i,r,s,l){return this.a=t,this.b=n,this.c=i,this.d=r,this.tx=s,this.ty=l,this}toArray(t,n){this.array||(this.array=new Float32Array(9));const i=n||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,n){n=n||new Lr;const i=t.x,r=t.y;return n.x=this.a*i+this.c*r+this.tx,n.y=this.b*i+this.d*r+this.ty,n}applyInverse(t,n){n=n||new Lr;const i=this.a,r=this.b,s=this.c,l=this.d,c=this.tx,f=this.ty,p=1/(i*l+s*-r),m=t.x,g=t.y;return n.x=l*p*m+-s*p*g+(f*s-c*l)*p,n.y=i*p*g+-r*p*m+(-f*i+c*r)*p,n}translate(t,n){return this.tx+=t,this.ty+=n,this}scale(t,n){return this.a*=t,this.d*=n,this.c*=t,this.b*=n,this.tx*=t,this.ty*=n,this}rotate(t){const n=Math.cos(t),i=Math.sin(t),r=this.a,s=this.c,l=this.tx;return this.a=r*n-this.b*i,this.b=r*i+this.b*n,this.c=s*n-this.d*i,this.d=s*i+this.d*n,this.tx=l*n-this.ty*i,this.ty=l*i+this.ty*n,this}append(t){const n=this.a,i=this.b,r=this.c,s=this.d;return this.a=t.a*n+t.b*r,this.b=t.a*i+t.b*s,this.c=t.c*n+t.d*r,this.d=t.c*i+t.d*s,this.tx=t.tx*n+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}appendFrom(t,n){const i=t.a,r=t.b,s=t.c,l=t.d,c=t.tx,f=t.ty,p=n.a,m=n.b,g=n.c,x=n.d;return this.a=i*p+r*g,this.b=i*m+r*x,this.c=s*p+l*g,this.d=s*m+l*x,this.tx=c*p+f*g+n.tx,this.ty=c*m+f*x+n.ty,this}setTransform(t,n,i,r,s,l,c,f,p){return this.a=Math.cos(c+p)*s,this.b=Math.sin(c+p)*s,this.c=-Math.sin(c-f)*l,this.d=Math.cos(c-f)*l,this.tx=t-(i*this.a+r*this.c),this.ty=n-(i*this.b+r*this.d),this}prepend(t){const n=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=n*t.a+this.ty*t.c+t.tx,this.ty=n*t.b+this.ty*t.d+t.ty,this}decompose(t){const n=this.a,i=this.b,r=this.c,s=this.d,l=t.pivot,c=-Math.atan2(-r,s),f=Math.atan2(i,n),p=Math.abs(c+f);return p<1e-5||Math.abs(SD-p)<1e-5?(t.rotation=f,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=c,t.skew.y=f),t.scale.x=Math.sqrt(n*n+i*i),t.scale.y=Math.sqrt(r*r+s*s),t.position.x=this.tx+(l.x*n+l.y*r),t.position.y=this.ty+(l.x*i+l.y*s),t}invert(){const t=this.a,n=this.b,i=this.c,r=this.d,s=this.tx,l=t*r-n*i;return this.a=r/l,this.b=-n/l,this.c=-i/l,this.d=t/l,this.tx=(i*this.ty-r*s)/l,this.ty=-(t*this.ty-n*s)/l,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new Ht;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return CD.identity()}static get shared(){return TD.identity()}}const TD=new Ht,CD=new Ht,od=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],cd=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ud=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],dd=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Xv=[],eA=[],Ny=Math.sign;function AD(){for(let e=0;e<16;e++){const t=[];Xv.push(t);for(let n=0;n<16;n++){const i=Ny(od[e]*od[n]+ud[e]*cd[n]),r=Ny(cd[e]*od[n]+dd[e]*cd[n]),s=Ny(od[e]*ud[n]+ud[e]*dd[n]),l=Ny(cd[e]*ud[n]+dd[e]*dd[n]);for(let c=0;c<16;c++)if(od[c]===i&&cd[c]===r&&ud[c]===s&&dd[c]===l){t.push(c);break}}}for(let e=0;e<16;e++){const t=new Ht;t.set(od[e],cd[e],ud[e],dd[e],0,0),eA.push(t)}}AD();const Bn={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:e=>od[e],uY:e=>cd[e],vX:e=>ud[e],vY:e=>dd[e],inv:e=>e&8?e&15:-e&7,add:(e,t)=>Xv[e][t],sub:(e,t)=>Xv[e][Bn.inv(t)],rotate180:e=>e^4,isVertical:e=>(e&3)===2,byDirection:(e,t)=>Math.abs(e)*2<=Math.abs(t)?t>=0?Bn.S:Bn.N:Math.abs(t)*2<=Math.abs(e)?e>0?Bn.E:Bn.W:t>0?e>0?Bn.SE:Bn.SW:e>0?Bn.NE:Bn.NW,matrixAppendRotationInv:(e,t,n=0,i=0,r=0,s=0)=>{const l=eA[Bn.inv(t)],c=l.a,f=l.b,p=l.c,m=l.d,g=n-Math.min(0,c*r,p*s,c*r+p*s),x=i-Math.min(0,f*r,m*s,f*r+m*s),v=e.a,S=e.b,A=e.c,T=e.d;e.a=c*v+f*A,e.b=c*S+f*T,e.c=p*v+m*A,e.d=p*S+m*T,e.tx=g*v+x*A+e.tx,e.ty=g*S+x*T+e.ty},transformRectCoords:(e,t,n,i)=>{const{x:r,y:s,width:l,height:c}=e,{x:f,y:p,width:m,height:g}=t;return n===Bn.E?(i.set(r+f,s+p,l,c),i):n===Bn.S?i.set(m-s-c+f,r+p,c,l):n===Bn.W?i.set(m-r-l+f,g-s-c+p,l,c):n===Bn.N?i.set(s+f,g-r-l+p,c,l):i.set(r+f,s+p,l,c)}},Oy=[new Lr,new Lr,new Lr,new Lr];class Ti{constructor(t=0,n=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(n),this.width=Number(i),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new Ti(0,0,0,0)}clone(){return new Ti(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,n){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&n>=this.y&&n<this.y+this.height}strokeContains(t,n,i,r=.5){const{width:s,height:l}=this;if(s<=0||l<=0)return!1;const c=this.x,f=this.y,p=i*(1-r),m=i-p,g=c-p,x=c+s+p,v=f-p,S=f+l+p,A=c+m,T=c+s-m,C=f+m,N=f+l-m;return t>=g&&t<=x&&n>=v&&n<=S&&!(t>A&&t<T&&n>C&&n<N)}intersects(t,n){if(!n){const Z=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=Z)return!1;const Y=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>Y}const i=this.left,r=this.right,s=this.top,l=this.bottom;if(r<=i||l<=s)return!1;const c=Oy[0].set(t.left,t.top),f=Oy[1].set(t.left,t.bottom),p=Oy[2].set(t.right,t.top),m=Oy[3].set(t.right,t.bottom);if(p.x<=c.x||f.y<=c.y)return!1;const g=Math.sign(n.a*n.d-n.b*n.c);if(g===0||(n.apply(c,c),n.apply(f,f),n.apply(p,p),n.apply(m,m),Math.max(c.x,f.x,p.x,m.x)<=i||Math.min(c.x,f.x,p.x,m.x)>=r||Math.max(c.y,f.y,p.y,m.y)<=s||Math.min(c.y,f.y,p.y,m.y)>=l))return!1;const x=g*(f.y-c.y),v=g*(c.x-f.x),S=x*i+v*s,A=x*r+v*s,T=x*i+v*l,C=x*r+v*l;if(Math.max(S,A,T,C)<=x*c.x+v*c.y||Math.min(S,A,T,C)>=x*m.x+v*m.y)return!1;const N=g*(c.y-p.y),R=g*(p.x-c.x),O=N*i+R*s,H=N*r+R*s,D=N*i+R*l,F=N*r+R*l;return!(Math.max(O,H,D,F)<=N*c.x+R*c.y||Math.min(O,H,D,F)>=N*m.x+R*m.y)}pad(t=0,n=t){return this.x-=t,this.y-=n,this.width+=t*2,this.height+=n*2,this}fit(t){const n=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=n,this.width=Math.max(i-n,0),this.y=r,this.height=Math.max(s-r,0),this}ceil(t=1,n=.001){const i=Math.ceil((this.x+this.width-n)*t)/t,r=Math.ceil((this.y+this.height-n)*t)/t;return this.x=Math.floor((this.x+n)*t)/t,this.y=Math.floor((this.y+n)*t)/t,this.width=i-this.x,this.height=r-this.y,this}scale(t,n=t){return this.x*=t,this.y*=n,this.width*=t,this.height*=n,this}enlarge(t){const n=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=n,this.width=i-n,this.y=r,this.height=s-r,this}getBounds(t){return t||(t=new Ti),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const n=t.x,i=t.y,r=t.x+t.width,s=t.y+t.height;return n>=this.x&&n<this.x+this.width&&i>=this.y&&i<this.y+this.height&&r>=this.x&&r<this.x+this.width&&s>=this.y&&s<this.y+this.height}set(t,n,i,r){return this.x=t,this.y=n,this.width=i,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const bb={default:-1};function bi(e="default"){return bb[e]===void 0&&(bb[e]=-1),++bb[e]}const AE=new Set,xi="8.0.0",MD="8.3.4",$f={quiet:!1,noColor:!1},en=((e,t,n=3)=>{if($f.quiet||AE.has(t))return;let i=new Error().stack;const r=`${t}
|
|
61
|
+
Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let m=wl(),g;if(t){let C=typeof t=="string"?_h(t):t;Wn(f==="/"||((T=C.pathname)==null?void 0:T.startsWith(f)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${f}" but pathname "${C.pathname}" was given in the \`location\` prop.`),g=C}else g=m;let x=g.pathname||"/",v=x;if(f!=="/"){let C=f.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(C.length).join("/")}let S=MC(e,{pathname:v});_l(p||S!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),_l(S==null||S[S.length-1].route.element!==void 0||S[S.length-1].route.Component!==void 0||S[S.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let A=FO(S&&S.map(C=>Object.assign({},C,{params:Object.assign({},l,C.params),pathname:po([f,i.encodeLocation?i.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?f:po([f,i.encodeLocation?i.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),r,n);return t&&A?j.createElement($m.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...g},navigationType:"POP"}},A):A}function IO(){let e=XO(),t=EO(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:i},s={padding:"2px 4px",backgroundColor:i},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=j.createElement(j.Fragment,null,j.createElement("p",null,"💿 Hey developer 👋"),j.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",j.createElement("code",{style:s},"ErrorBoundary")," or"," ",j.createElement("code",{style:s},"errorElement")," prop on your route.")),j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:r},n):null,l)}var UO=j.createElement(IO,null),UC=class extends j.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=OO(e.digest);n&&(e=n)}let t=e!==void 0?j.createElement(El.Provider,{value:this.props.routeContext},j.createElement(X1.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?j.createElement(HO,{error:e},t):t}};UC.contextType=CO;var hb=new WeakMap;function HO({children:e,error:t}){let{basename:n}=j.useContext(ss);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let i=NO(t.digest);if(i){let r=hb.get(t);if(r)throw r;let s=OC(i.location,n);if(NC&&!hb.get(t))if(s.isExternal||i.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:i.replace}));throw hb.set(t,l),l}return j.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return e}function PO({routeContext:e,match:t,children:n}){let i=j.useContext(Sh);return i&&i.static&&i.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=t.route.id),j.createElement(El.Provider,{value:e},n)}function FO(e,t=[],n){let i=n==null?void 0:n.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(t.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let r=e,s=i==null?void 0:i.errors;if(s!=null){let m=r.findIndex(g=>g.route.id&&(s==null?void 0:s[g.route.id])!==void 0);Wn(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),r=r.slice(0,Math.min(r.length,m+1))}let l=!1,c=-1;if(n&&i){l=i.renderFallback;for(let m=0;m<r.length;m++){let g=r[m];if((g.route.HydrateFallback||g.route.hydrateFallbackElement)&&(c=m),g.route.id){let{loaderData:x,errors:v}=i,S=g.route.loader&&!x.hasOwnProperty(g.route.id)&&(!v||v[g.route.id]===void 0);if(g.route.lazy||S){n.isStatic&&(l=!0),c>=0?r=r.slice(0,c+1):r=[r[0]];break}}}}let f=n==null?void 0:n.onError,p=i&&f?(m,g)=>{var x,v;f(m,{location:i.location,params:((v=(x=i.matches)==null?void 0:x[0])==null?void 0:v.params)??{},unstable_pattern:wO(i.matches),errorInfo:g})}:void 0;return r.reduceRight((m,g,x)=>{let v,S=!1,A=null,T=null;i&&(v=s&&g.route.id?s[g.route.id]:void 0,A=g.route.errorElement||UO,l&&(c<0&&x===0?(HC("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),S=!0,T=null):c===x&&(S=!0,T=g.route.hydrateFallbackElement||null)));let C=t.concat(r.slice(0,x+1)),N=()=>{let R;return v?R=A:S?R=T:g.route.Component?R=j.createElement(g.route.Component,null):g.route.element?R=g.route.element:R=m,j.createElement(PO,{match:g,routeContext:{outlet:m,matches:C,isDataRoute:i!=null},children:R})};return i&&(g.route.ErrorBoundary||g.route.errorElement||x===0)?j.createElement(UC,{location:i.location,revalidation:i.revalidation,component:A,error:v,children:N(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:p}):N()},null)}function K1(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function GO(e){let t=j.useContext(Sh);return Wn(t,K1(e)),t}function qO(e){let t=j.useContext(Q0);return Wn(t,K1(e)),t}function YO(e){let t=j.useContext(El);return Wn(t,K1(e)),t}function $1(e){let t=YO(e),n=t.matches[t.matches.length-1];return Wn(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function VO(){return $1("useRouteId")}function XO(){var i;let e=j.useContext(X1),t=qO("useRouteError"),n=$1("useRouteError");return e!==void 0?e:(i=t.errors)==null?void 0:i[n]}function KO(){let{router:e}=GO("useNavigate"),t=$1("useNavigate"),n=j.useRef(!1);return jC(()=>{n.current=!0}),j.useCallback(async(r,s={})=>{_l(n.current,LC),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...s}))},[e,t])}var cE={};function HC(e,t,n){!t&&!cE[e]&&(cE[e]=!0,_l(!1,n))}j.memo($O);function $O({routes:e,future:t,state:n,isStatic:i,onError:r}){return IC(e,void 0,{state:n,isStatic:i,onError:r})}function WO({to:e,replace:t,state:n,relative:i}){Wn(Eh(),"<Navigate> may be used only in the context of a <Router> component.");let{static:r}=j.useContext(ss);_l(!r,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=j.useContext(El),{pathname:l}=wl(),c=Z0(),f=W0(e,V1(s),l,i==="path"),p=JSON.stringify(f);return j.useEffect(()=>{c(JSON.parse(p),{replace:t,state:n,relative:i})},[c,p,i,t,n]),null}function uE(e){return LO(e.context)}function ca(e){Wn(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function QO({basename:e="/",children:t=null,location:n,navigationType:i="POP",navigator:r,static:s=!1,unstable_useTransitions:l}){Wn(!Eh(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),f=j.useMemo(()=>({basename:c,navigator:r,static:s,unstable_useTransitions:l,future:{}}),[c,r,s,l]);typeof n=="string"&&(n=_h(n));let{pathname:p="/",search:m="",hash:g="",state:x=null,key:v="default",unstable_mask:S}=n,A=j.useMemo(()=>{let T=sc(p,c);return T==null?null:{location:{pathname:T,search:m,hash:g,state:x,key:v,unstable_mask:S},navigationType:i}},[c,p,m,g,x,v,i,S]);return _l(A!=null,`<Router basename="${c}"> is not able to match the URL "${p}${m}${g}" because it does not start with the basename, so the <Router> won't render anything.`),A==null?null:j.createElement(ss.Provider,{value:f},j.createElement($m.Provider,{children:t,value:A}))}function ZO({children:e,location:t}){return jO(Pv(e),t)}function Pv(e,t=[]){let n=[];return j.Children.forEach(e,(i,r)=>{if(!j.isValidElement(i))return;let s=[...t,r];if(i.type===j.Fragment){n.push.apply(n,Pv(i.props.children,s));return}Wn(i.type===ca,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Wn(!i.props.index||!i.props.children,"An index route cannot have child routes.");let l={id:i.props.id||s.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(l.children=Pv(i.props.children,s)),n.push(l)}),n}var h0="get",p0="application/x-www-form-urlencoded";function J0(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function JO(e){return J0(e)&&e.tagName.toLowerCase()==="button"}function e4(e){return J0(e)&&e.tagName.toLowerCase()==="form"}function t4(e){return J0(e)&&e.tagName.toLowerCase()==="input"}function n4(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function i4(e,t){return e.button===0&&(!t||t==="_self")&&!n4(e)}var Ay=null;function r4(){if(Ay===null)try{new FormData(document.createElement("form"),0),Ay=!1}catch{Ay=!0}return Ay}var a4=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function pb(e){return e!=null&&!a4.has(e)?(_l(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${p0}"`),null):e}function s4(e,t){let n,i,r,s,l;if(e4(e)){let c=e.getAttribute("action");i=c?sc(c,t):null,n=e.getAttribute("method")||h0,r=pb(e.getAttribute("enctype"))||p0,s=new FormData(e)}else if(JO(e)||t4(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let f=e.getAttribute("formaction")||c.getAttribute("action");if(i=f?sc(f,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||h0,r=pb(e.getAttribute("formenctype"))||pb(c.getAttribute("enctype"))||p0,s=new FormData(c,e),!r4()){let{name:p,type:m,value:g}=e;if(m==="image"){let x=p?`${p}.`:"";s.append(`${x}x`,"0"),s.append(`${x}y`,"0")}else p&&s.append(p,g)}}else{if(J0(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=h0,i=null,r=p0,l=e}return s&&r==="text/plain"&&(l=s,s=void 0),{action:i,method:n.toLowerCase(),encType:r,formData:s,body:l}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function W1(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function l4(e,t,n,i){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?r.pathname.endsWith("/")?r.pathname=`${r.pathname}_.${i}`:r.pathname=`${r.pathname}.${i}`:r.pathname==="/"?r.pathname=`_root.${i}`:t&&sc(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${i}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${i}`,r}async function o4(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function c4(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function u4(e,t,n){let i=await Promise.all(e.map(async r=>{let s=t.routes[r.route.id];if(s){let l=await o4(s,n);return l.links?l.links():[]}return[]}));return p4(i.flat(1).filter(c4).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function dE(e,t,n,i,r,s){let l=(f,p)=>n[p]?f.route.id!==n[p].route.id:!0,c=(f,p)=>{var m;return n[p].pathname!==f.pathname||((m=n[p].route.path)==null?void 0:m.endsWith("*"))&&n[p].params["*"]!==f.params["*"]};return s==="assets"?t.filter((f,p)=>l(f,p)||c(f,p)):s==="data"?t.filter((f,p)=>{var g;let m=i.routes[f.route.id];if(!m||!m.hasLoader)return!1;if(l(f,p)||c(f,p))return!0;if(f.route.shouldRevalidate){let x=f.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:((g=n[0])==null?void 0:g.params)||{},nextUrl:new URL(e,window.origin),nextParams:f.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function d4(e,t,{includeHydrateFallback:n}={}){return f4(e.map(i=>{let r=t.routes[i.route.id];if(!r)return[];let s=[r.module];return r.clientActionModule&&(s=s.concat(r.clientActionModule)),r.clientLoaderModule&&(s=s.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(s=s.concat(r.hydrateFallbackModule)),r.imports&&(s=s.concat(r.imports)),s}).flat(1))}function f4(e){return[...new Set(e)]}function h4(e){let t={},n=Object.keys(e).sort();for(let i of n)t[i]=e[i];return t}function p4(e,t){let n=new Set;return new Set(t),e.reduce((i,r)=>{let s=JSON.stringify(h4(r));return n.has(s)||(n.add(s),i.push({key:s,link:r})),i},[])}function PC(){let e=j.useContext(Sh);return W1(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function m4(){let e=j.useContext(Q0);return W1(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Q1=j.createContext(void 0);Q1.displayName="FrameworkContext";function FC(){let e=j.useContext(Q1);return W1(e,"You must render this element inside a <HydratedRouter> element"),e}function g4(e,t){let n=j.useContext(Q1),[i,r]=j.useState(!1),[s,l]=j.useState(!1),{onFocus:c,onBlur:f,onMouseEnter:p,onMouseLeave:m,onTouchStart:g}=t,x=j.useRef(null);j.useEffect(()=>{if(e==="render"&&l(!0),e==="viewport"){let A=C=>{C.forEach(N=>{l(N.isIntersecting)})},T=new IntersectionObserver(A,{threshold:.5});return x.current&&T.observe(x.current),()=>{T.disconnect()}}},[e]),j.useEffect(()=>{if(i){let A=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(A)}}},[i]);let v=()=>{r(!0)},S=()=>{r(!1),l(!1)};return n?e!=="intent"?[s,x,{}]:[s,x,{onFocus:$p(c,v),onBlur:$p(f,S),onMouseEnter:$p(p,v),onMouseLeave:$p(m,S),onTouchStart:$p(g,v)}]:[!1,x,{}]}function $p(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function y4({page:e,...t}){let{router:n}=PC(),i=j.useMemo(()=>MC(n.routes,e,n.basename),[n.routes,e,n.basename]);return i?j.createElement(b4,{page:e,matches:i,...t}):null}function x4(e){let{manifest:t,routeModules:n}=FC(),[i,r]=j.useState([]);return j.useEffect(()=>{let s=!1;return u4(e,t,n).then(l=>{s||r(l)}),()=>{s=!0}},[e,t,n]),i}function b4({page:e,matches:t,...n}){let i=wl(),{future:r,manifest:s,routeModules:l}=FC(),{basename:c}=PC(),{loaderData:f,matches:p}=m4(),m=j.useMemo(()=>dE(e,t,p,s,i,"data"),[e,t,p,s,i]),g=j.useMemo(()=>dE(e,t,p,s,i,"assets"),[e,t,p,s,i]),x=j.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let A=new Set,T=!1;if(t.forEach(N=>{var O;let R=s.routes[N.route.id];!R||!R.hasLoader||(!m.some(H=>H.route.id===N.route.id)&&N.route.id in f&&((O=l[N.route.id])!=null&&O.shouldRevalidate)||R.hasClientLoader?T=!0:A.add(N.route.id))}),A.size===0)return[];let C=l4(e,c,r.unstable_trailingSlashAwareDataRequests,"data");return T&&A.size>0&&C.searchParams.set("_routes",t.filter(N=>A.has(N.route.id)).map(N=>N.route.id).join(",")),[C.pathname+C.search]},[c,r.unstable_trailingSlashAwareDataRequests,f,i,s,m,t,e,l]),v=j.useMemo(()=>d4(g,s),[g,s]),S=x4(g);return j.createElement(j.Fragment,null,x.map(A=>j.createElement("link",{key:A,rel:"prefetch",as:"fetch",href:A,...n})),v.map(A=>j.createElement("link",{key:A,rel:"modulepreload",href:A,...n})),S.map(({key:A,link:T})=>j.createElement("link",{key:A,nonce:n.nonce,...T,crossOrigin:T.crossOrigin??n.crossOrigin})))}function v4(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var _4=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{_4&&(window.__reactRouterVersion="7.13.1")}catch{}function S4({basename:e,children:t,unstable_useTransitions:n,window:i}){let r=j.useRef();r.current==null&&(r.current=J3({window:i,v5Compat:!0}));let s=r.current,[l,c]=j.useState({action:s.action,location:s.location}),f=j.useCallback(p=>{n===!1?c(p):j.startTransition(()=>c(p))},[n]);return j.useLayoutEffect(()=>s.listen(f),[s,f]),j.createElement(QO,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:s,unstable_useTransitions:n})}var GC=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qC=j.forwardRef(function({onClick:t,discover:n="render",prefetch:i="none",relative:r,reloadDocument:s,replace:l,unstable_mask:c,state:f,target:p,to:m,preventScrollReset:g,viewTransition:x,unstable_defaultShouldRevalidate:v,...S},A){let{basename:T,navigator:C,unstable_useTransitions:N}=j.useContext(ss),R=typeof m=="string"&&GC.test(m),O=OC(m,T);m=O.to;let H=DO(m,{relative:r}),D=wl(),F=null;if(c){let $=W0(c,[],D.unstable_mask?D.unstable_mask.pathname:"/",!0);T!=="/"&&($.pathname=$.pathname==="/"?T:po([T,$.pathname])),F=C.createHref($)}let[Z,V,Y]=g4(i,S),P=T4(m,{replace:l,unstable_mask:c,state:f,target:p,preventScrollReset:g,relative:r,viewTransition:x,unstable_defaultShouldRevalidate:v,unstable_useTransitions:N});function q($){t&&t($),$.defaultPrevented||P($)}let ne=!(O.isExternal||s),I=j.createElement("a",{...S,...Y,href:(ne?F:void 0)||O.absoluteURL||H,onClick:ne?q:t,ref:v4(A,V),target:p,"data-discover":!R&&n==="render"?"true":void 0});return Z&&!R?j.createElement(j.Fragment,null,I,j.createElement(y4,{page:H})):I});qC.displayName="Link";var YC=j.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:i="",end:r=!1,style:s,to:l,viewTransition:c,children:f,...p},m){let g=Wm(l,{relative:p.relative}),x=wl(),v=j.useContext(Q0),{navigator:S,basename:A}=j.useContext(ss),T=v!=null&&k4(g)&&c===!0,C=S.encodeLocation?S.encodeLocation(g).pathname:g.pathname,N=x.pathname,R=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;n||(N=N.toLowerCase(),R=R?R.toLowerCase():null,C=C.toLowerCase()),R&&A&&(R=sc(R,A)||R);const O=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let H=N===C||!r&&N.startsWith(C)&&N.charAt(O)==="/",D=R!=null&&(R===C||!r&&R.startsWith(C)&&R.charAt(C.length)==="/"),F={isActive:H,isPending:D,isTransitioning:T},Z=H?t:void 0,V;typeof i=="function"?V=i(F):V=[i,H?"active":null,D?"pending":null,T?"transitioning":null].filter(Boolean).join(" ");let Y=typeof s=="function"?s(F):s;return j.createElement(qC,{...p,"aria-current":Z,className:V,ref:m,style:Y,to:l,viewTransition:c},typeof f=="function"?f(F):f)});YC.displayName="NavLink";var E4=j.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:i,replace:r,state:s,method:l=h0,action:c,onSubmit:f,relative:p,preventScrollReset:m,viewTransition:g,unstable_defaultShouldRevalidate:x,...v},S)=>{let{unstable_useTransitions:A}=j.useContext(ss),T=M4(),C=R4(c,{relative:p}),N=l.toLowerCase()==="get"?"get":"post",R=typeof c=="string"&&GC.test(c),O=H=>{if(f&&f(H),H.defaultPrevented)return;H.preventDefault();let D=H.nativeEvent.submitter,F=(D==null?void 0:D.getAttribute("formmethod"))||l,Z=()=>T(D||H.currentTarget,{fetcherKey:t,method:F,navigate:n,replace:r,state:s,relative:p,preventScrollReset:m,viewTransition:g,unstable_defaultShouldRevalidate:x});A&&n!==!1?j.startTransition(()=>Z()):Z()};return j.createElement("form",{ref:S,method:N,action:C,onSubmit:i?f:O,...v,"data-discover":!R&&e==="render"?"true":void 0})});E4.displayName="Form";function w4(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function VC(e){let t=j.useContext(Sh);return Wn(t,w4(e)),t}function T4(e,{target:t,replace:n,unstable_mask:i,state:r,preventScrollReset:s,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:f,unstable_useTransitions:p}={}){let m=Z0(),g=wl(),x=Wm(e,{relative:l});return j.useCallback(v=>{if(i4(v,t)){v.preventDefault();let S=n!==void 0?n:km(g)===km(x),A=()=>m(e,{replace:S,unstable_mask:i,state:r,preventScrollReset:s,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:f});p?j.startTransition(()=>A()):A()}},[g,m,x,n,i,r,t,e,s,l,c,f,p])}var C4=0,A4=()=>`__${String(++C4)}__`;function M4(){let{router:e}=VC("useSubmit"),{basename:t}=j.useContext(ss),n=VO(),i=e.fetch,r=e.navigate;return j.useCallback(async(s,l={})=>{let{action:c,method:f,encType:p,formData:m,body:g}=s4(s,t);if(l.navigate===!1){let x=l.fetcherKey||A4();await i(x,n,l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:g,formMethod:l.method||f,formEncType:l.encType||p,flushSync:l.flushSync})}else await r(l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:g,formMethod:l.method||f,formEncType:l.encType||p,replace:l.replace,state:l.state,fromRouteId:n,flushSync:l.flushSync,viewTransition:l.viewTransition})},[i,r,t,n])}function R4(e,{relative:t}={}){let{basename:n}=j.useContext(ss),i=j.useContext(El);Wn(i,"useFormAction must be used inside a RouteContext");let[r]=i.matches.slice(-1),s={...Wm(e||".",{relative:t})},l=wl();if(e==null){s.search=l.search;let c=new URLSearchParams(s.search),f=c.getAll("index");if(f.some(m=>m==="")){c.delete("index"),f.filter(g=>g).forEach(g=>c.append("index",g));let m=c.toString();s.search=m?`?${m}`:""}}return(!e||e===".")&&r.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:po([n,s.pathname])),km(s)}function k4(e,{relative:t}={}){let n=j.useContext(zC);Wn(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=VC("useViewTransitionState"),r=Wm(e,{relative:t});if(!n.isTransitioning)return!1;let s=sc(n.currentLocation.pathname,i)||n.currentLocation.pathname,l=sc(n.nextLocation.pathname,i)||n.nextLocation.pathname;return w0(r.pathname,l)!=null||w0(r.pathname,s)!=null}AC();const fE=e=>{let t;const n=new Set,i=(p,m)=>{const g=typeof p=="function"?p(t):p;if(!Object.is(g,t)){const x=t;t=m??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(v=>v(t,x))}},r=()=>t,c={setState:i,getState:r,getInitialState:()=>f,subscribe:p=>(n.add(p),()=>n.delete(p))},f=t=e(i,r,c);return c},N4=(e=>e?fE(e):fE),O4=e=>e;function D4(e,t=O4){const n=fm.useSyncExternalStore(e.subscribe,fm.useCallback(()=>t(e.getState()),[e,t]),fm.useCallback(()=>t(e.getInitialState()),[e,t]));return fm.useDebugValue(n),n}const hE=e=>{const t=N4(e),n=i=>D4(t,i);return Object.assign(n,t),n},fu=(e=>e?hE(e):hE),gl=fu(e=>({user:null,isAuthenticated:!1,loading:!1,error:null,login:async(t,n)=>{e({loading:!0,error:null});try{const i=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:n}),credentials:"include"}),r=await i.json();if(!i.ok){e({loading:!1,error:r.error||"Login failed"});return}e({user:r.user,isAuthenticated:!0,loading:!1,error:null})}catch{e({loading:!1,error:"Network error"})}},logout:async()=>{try{await fetch("/api/auth/logout",{method:"POST",credentials:"include"})}catch{}e({user:null,isAuthenticated:!1,error:null})},checkAuth:async()=>{e({loading:!0});try{const t=await fetch("/api/auth/me",{credentials:"include"});if(t.ok){const n=await t.json();e({user:n.user,isAuthenticated:!0,loading:!1})}else e({user:null,isAuthenticated:!1,loading:!1})}catch{e({user:null,isAuthenticated:!1,loading:!1})}},reset:()=>e({user:null,isAuthenticated:!1,loading:!1,error:null})})),vr=fu((e,t)=>({squads:[],selectedSquad:null,activeStates:{},uiComponents:{},fetchSquads:async()=>{try{const n=await fetch("/api/squads",{credentials:"include"});if(n.ok){const i=await n.json();e({squads:i.squads})}}catch{}},selectSquad:n=>e({selectedSquad:n}),setSquadState:(n,i)=>e(r=>({activeStates:{...r.activeStates,[n]:i}})),clearSquadState:n=>e(i=>{const{[n]:r,...s}=i.activeStates;return{activeStates:s}}),setUiComponents:(n,i)=>e(r=>({uiComponents:{...r.uiComponents,[n]:i}})),reset:()=>e({squads:[],selectedSquad:null,activeStates:{},uiComponents:{}})}));let z4=0;function pE(){return`local-${Date.now()}-${++z4}`}const rr=fu((e,t)=>({conversations:[],messages:[],conversationId:null,streaming:!1,streamingText:"",activity:null,error:null,addUserMessage:n=>{const i={id:pE(),role:"user",content:n,createdAt:new Date().toISOString()};e(r=>{const s=r.conversationId,l=s&&!r.messages.some(c=>c.role==="user")?r.conversations.map(c=>c.id===s?{...c,preview:n.slice(0,80)}:c):r.conversations;return{messages:[...r.messages,i],error:null,conversations:l}})},setConversationId:n=>{e({conversationId:n})},startStreaming:()=>{e({streaming:!0,streamingText:"",activity:null,error:null})},appendChunk:n=>{e(i=>({streamingText:i.streamingText+n,activity:null}))},setActivity:n=>{e({activity:n})},finishStreaming:n=>{const{streamingText:i}=t(),r={id:n,role:"assistant",content:i,createdAt:new Date().toISOString()};e(s=>({messages:[...s.messages,r],streaming:!1,streamingText:"",activity:null}))},addAgentDm:n=>{const i={id:pE(),role:"agent_dm",content:n.content,agentId:n.agentId,agentName:n.agentName,createdAt:new Date().toISOString()};e(r=>({messages:[...r.messages,i]}))},setError:n=>{e({error:n,streaming:!1,streamingText:"",activity:null})},loadConversations:async n=>{try{const i=await fetch(`/api/squads/${n}/conversations`,{credentials:"include"});if(!i.ok)return;const s=((await i.json()).data||[]).map(l=>({id:l.id,createdAt:l.created_at,preview:""}));for(const l of s)try{const c=await fetch(`/api/conversations/${l.id}/messages?limit=1`,{credentials:"include"});if(c.ok){const p=((await c.json()).data||[])[0];p&&(l.preview=p.content.slice(0,80))}}catch{}e({conversations:s})}catch{}},selectConversation:async n=>{e({conversationId:n,messages:[],streaming:!1,streamingText:"",activity:null,error:null});try{const i=await fetch(`/api/conversations/${n}/messages`,{credentials:"include"});if(!i.ok)return;const s=((await i.json()).data||[]).map(l=>({id:l.id,role:l.role,content:l.content,agentId:l.agent_id??void 0,agentName:l.agent_name??void 0,createdAt:l.created_at}));e({messages:s})}catch{}},deleteConversation:async(n,i)=>{try{if(!(await fetch(`/api/conversations/${n}`,{method:"DELETE",credentials:"include"})).ok)return;const{conversationId:s}=t();e(l=>({conversations:l.conversations.filter(c=>c.id!==n)})),s===n&&e({conversationId:null,messages:[]})}catch{}},loadHistory:async n=>{try{const i=await fetch(`/api/squads/${n}/conversations`,{credentials:"include"});if(!i.ok)return;const r=await i.json();if(!r.data||r.data.length===0){e({conversationId:null,messages:[],conversations:[]});return}const s=(r.data||[]).map(g=>({id:g.id,createdAt:g.created_at,preview:""})),l=r.data[0];e({conversationId:l.id,conversations:s});const c=await fetch(`/api/conversations/${l.id}/messages`,{credentials:"include"});if(!c.ok)return;const p=((await c.json()).data||[]).map(g=>({id:g.id,role:g.role,content:g.content,agentId:g.agent_id??void 0,agentName:g.agent_name??void 0,createdAt:g.created_at})),m=p.find(g=>g.role==="user");if(m){const g=s.findIndex(x=>x.id===l.id);g>=0&&(s[g].preview=m.content.slice(0,80))}e({messages:p,conversations:s});for(const g of s)if(g.id!==l.id)try{const x=await fetch(`/api/conversations/${g.id}/messages?limit=1`,{credentials:"include"});if(x.ok){const S=((await x.json()).data||[])[0];S&&(g.preview=S.content.slice(0,80))}}catch{}e({conversations:[...s]})}catch{}},reset:()=>e({conversations:[],messages:[],conversationId:null,streaming:!1,streamingText:"",error:null})}));function B4(e){const n=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`,i=new WebSocket(n),r=[];let s=!0;function l(c){i.readyState===WebSocket.OPEN?i.send(JSON.stringify(c)):i.readyState===WebSocket.CONNECTING&&r.push(c)}return i.onopen=()=>{var c,f;s||(f=(c=e.current).onReconnect)==null||f.call(c),s=!1;for(const p of r)i.send(JSON.stringify(p));r.length=0},i.onmessage=c=>{var f,p,m,g,x,v,S,A,T,C,N,R,O,H,D,F,Z,V,Y;try{const P=JSON.parse(c.data),q=e.current;switch(P.type){case"squad:state":(f=q.onSquadState)==null||f.call(q,P.squadName,P.state);break;case"squad:inactive":(p=q.onSquadInactive)==null||p.call(q,P.squadName,P.reason);break;case"chat:chunk":(m=q.onChatChunk)==null||m.call(q,P.squadName,P.conversationId,P.delta);break;case"chat:activity":(g=q.onChatActivity)==null||g.call(q,P.squadName,P.tool,P.summary);break;case"chat:done":(x=q.onChatDone)==null||x.call(q,P.squadName,P.conversationId,P.messageId);break;case"chat:error":(v=q.onChatError)==null||v.call(q,P.squadName,P.error);break;case"chat:agent_dm":(S=q.onChatAgentDm)==null||S.call(q,P.squadName,P.conversationId,P.agentId,P.agentName,P.message);break;case"chat:conversation_created":(A=q.onChatConversationCreated)==null||A.call(q,P.squadName,P.conversationId);break;case"agent:output_chunk":(T=q.onAgentOutputChunk)==null||T.call(q,P.squadName,P.agentId,P.agentName,P.delta);break;case"agent:step_start":(C=q.onAgentStepStart)==null||C.call(q,P.squadName,P.agentId,P.agentName,P.stepIndex,P.stepLabel);break;case"agent:step_complete":(N=q.onAgentStepComplete)==null||N.call(q,P.squadName,P.agentId,P.agentName,P.stepIndex,P.stepLabel);break;case"squad:checkpoint":(R=q.onSquadCheckpoint)==null||R.call(q,P.squadName,P.agentId,P.agentName,P.question);break;case"schedule:started":(O=q.onScheduleStarted)==null||O.call(q,P.squadName,P.jobId,P.attempt);break;case"schedule:chunk":(H=q.onScheduleChunk)==null||H.call(q,P.squadName,P.jobId,P.delta);break;case"schedule:done":(D=q.onScheduleDone)==null||D.call(q,P.squadName,P.jobId,P.summary,P.attempt);break;case"schedule:error":(F=q.onScheduleError)==null||F.call(q,P.squadName,P.jobId,P.error,P.attempt,P.willRetry);break;case"schedule:status_changed":(Z=q.onScheduleStatusChanged)==null||Z.call(q,P.squadName,P.status);break;case"kanban:task_updated":(V=q.onKanbanTaskUpdated)==null||V.call(q,P);break;case"a2ui:update":(Y=q.onA2uiUpdate)==null||Y.call(q,P.squadName,P.components);break}}catch{}},{subscribe:c=>{l({type:"squad:subscribe",squadName:c})},unsubscribe:c=>{l({type:"squad:unsubscribe",squadName:c})},sendChat:(c,f,p)=>{const m={type:"chat:send",squadName:c,message:f};p&&p.length>0&&(m.files=p),l(m)},newConversation:c=>{l({type:"chat:new_conversation",squadName:c})},sendCheckpointResponse:(c,f)=>{l({type:"squad:checkpoint_response",squadName:c,answer:f})},disconnect:()=>{i.close()}}}function L4(e={}){const t=j.useRef(null),n=j.useRef(e),i=j.useRef(new Set);n.current=e,j.useEffect(()=>{const p=B4(n);t.current=p;for(const m of i.current)p.subscribe(m);return()=>{p.disconnect()}},[]);const r=j.useCallback(p=>{var m;i.current.add(p),(m=t.current)==null||m.subscribe(p)},[]),s=j.useCallback(p=>{var m;i.current.delete(p),(m=t.current)==null||m.unsubscribe(p)},[]),l=j.useCallback((p,m,g)=>{var x;(x=t.current)==null||x.sendChat(p,m,g)},[]),c=j.useCallback(p=>{var m;(m=t.current)==null||m.newConversation(p)},[]),f=j.useCallback((p,m)=>{var g;(g=t.current)==null||g.sendCheckpointResponse(p,m)},[]);return{subscribe:r,unsubscribe:s,sendChat:l,newConversation:c,sendCheckpointResponse:f}}function j4(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),i=e%60,r=s=>s.toString().padStart(2,"0");return t>0?`${t}h ${r(n)}m ${r(i)}s`:`${n}m ${r(i)}s`}function I4({state:e}){const[t,n]=j.useState(0);return j.useEffect(()=>{if(!(e!=null&&e.startedAt)||e.status!=="running"){n(0);return}const i=new Date(e.startedAt).getTime(),r=()=>n(Math.floor((Date.now()-i)/1e3));r();const s=setInterval(r,1e3);return()=>clearInterval(s)},[e==null?void 0:e.startedAt,e==null?void 0:e.status]),_.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",height:"var(--statusbar-height)",padding:"0 var(--sp-4)",background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:e?_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[_.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:e.status==="running"?"var(--status-active)":e.status==="checkpoint"?"var(--status-warning)":"var(--status-idle)",boxShadow:e.status==="running"?"0 0 8px var(--status-active-glow)":"none",animation:e.status==="running"?"statusPulse 2s ease-in-out infinite":"none"}}),_.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Step ",e.step.current,"/",e.step.total]}),_.jsx("span",{style:{color:"var(--border-strong)"},children:"│"}),_.jsx("span",{children:e.step.label})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[e.handoff&&_.jsxs("span",{style:{color:"var(--accent)"},children:[e.handoff.from," → ",e.handoff.to]}),e.status==="running"&&_.jsx("span",{style:{color:"var(--text-secondary)"},children:j4(t)})]})]}):_.jsxs(_.Fragment,{children:[_.jsx("span",{children:"Ready"}),_.jsx("span",{children:"ExpxAgents Mission Control"})]})})}let Fv=null;function U4(e){Fv=e}function XC(e,t,n){Fv&&Fv(e,t,n)}let Gv=null;function H4(e){Gv=e}function P4(e){Gv&&Gv(e)}let qv=null;function F4(e){qv=e}function G4(e,t){qv&&qv(e,t)}const m0=32,fl=96,iu=64,pt={floor:13158600,floorHighlight:14211288,floorGrout:12105912,wall:15261904,wallTrim:11577496,baseboard:7035464,desk:15263976,deskTop:16119285,deskShadow:13684944,deskLeg:1710618,deskEdge:14737632,monitor:2236976,monitorScreen:1981020,monitorScreenGlow:2773120,monitorStand:3355456,keyboard:3355456,keyboardKey:4473941,chairSeat:2899536,chairBack:3426654,chairBase:4473924,chairWheel:3355443,plant:5025616,plantDark:3706428,plantLight:6732650,pot:9133628,potRim:10515018,soil:4863264,bookshelf:8020808,bookshelfEdge:9139029,bookColors:[15022389,2001125,4431943,16750592,9315498,35195,16635957],rug:6044974,rugPattern:8016448,rugBorder:4861472},Yv=[5227511,5025616,16750592,15022389,9315498,16771899],q4={idle:8947848,working:5025616,delivering:5227511,done:5025616,checkpoint:16750592},Br={counter:4073251,counterTop:6111287,machine:3622735,machineTop:4545124,machineLight:5025616,cup:14142664,cupShadow:12364452,saucer:14735052,sink:7901340,faucet:11583173,menu:5125166},Wa={table:6111287,tableTop:7162945,tableEdge:5125166,tableLeg:4073251,chair:3622735,chairSeat:4545124,chairBack:5533306,carpet:2503224,carpetPattern:3030340,whiteboard:15527921,whiteboardFrame:7901340},md={background:1713022,backgroundGlow:2635155,statusRunning:5025616,statusIdle:8947848,statusCheckpoint:16750592,statusCompleted:5025616},au={floor:11579568,tile:11053224,grout:10066329,stripe:12632256},la={floor:14477552,tile:12966120,tileGrout:11453652,wall:14740208,stall:11583173,stallDoor:9479342,sink:15527921,sinkBowl:16777215,mirror:11789820,mirrorFrame:7901340,toilet:16448250,toiletSeat:15658734,pipe:9479342},Aa={floor:6111287,carpet:5125166,carpetBorder:4073251,desk:4073251,deskTop:6111287,deskEdge:2890510,chair:1713022,chairSeat:2635155,window:8508666,windowFrame:5533306,windowSill:7901340,bookshelf:7162945,globe:4367861,nameplate:16766720},ah={wall:7901340,wallHighlight:10795204,doorFrame:6111287},ir={floor:16115411,tile:15259072,tileGrout:13942952,counter:6111287,counterTop:7951688,fridge:15527921,fridgeDoor:14737632,fridgeHandle:10395294,table:9268835,tableTop:10586239,chair:7162945,coffeeMaker:3622735,coffeeMakerLight:5025616,lamp:16766287},Ma={floor:14142664,carpet:6323595,carpetBorder:4545124,sofa:5533306,sofaCushion:6323595,sofaArm:4545124,tv:2171169,tvScreen:2503224,tvStand:4342338,sideTable:7951688,magazine:15684432,magazineAlt:4367861},ec=480,Za=360,id=400,Gi=60,Qa=120,mb=120,mE=160,gE=120,yE=160,Y4=64,V4=80,X4=fl+32,K4=iu+48,xE=2,KC=10,Wo=80;function My(e,t,n){const i=Math.max(0,Math.min(1,n));return e+(t-e)*i}function $4(e){return e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2}const W4=["nw","ne","sw","se"],Q4={nw:"right",ne:"left",sw:"top",se:"top"};function T0(e){const t=KC,n=Math.max(1,e),i={nw:0,ne:0,sw:0,se:0},r=[];for(let W=0;W<n;W++){const B=W4[W%4];r.push({quadrant:B,slot:i[B]}),i[B]++}const s=Math.max(1,i.nw),l=Math.max(1,i.ne),c=Math.max(1,i.sw),f=Math.max(1,i.se),p=Math.max(id,Qa),m=s*(Za+t),g=l*(Za+t),x=Math.max(m+p,g+Qa),v=c*(Za+t),S=f*(Za+t),A=Math.max(mE,yE),T=Math.max(v+A+t,S+A+t),C=Math.max(ec,Qa+t+id),N=Math.max(ec,Qa),R=Math.max(ec,mb),O=Math.max(ec,gE),H=Math.max(C,R),D=Math.max(N,O),F=t+H+t+Gi+t+D+t,Z=t+x+t+Gi+t+T+t,V={x:t+H+t,y:t,width:Gi,height:Z-2*t},Y={x:t,y:t+x+t,width:F-2*t,height:Gi},P={x:V.x+V.width/2,y:Y.y+Y.height/2},q={x:V.x-t-id,y:Y.y-t-id,width:id,height:id},ne={x:q.x-t-Qa,y:Y.y-t-Qa,width:Qa,height:Qa},I={x:V.x+Gi+t,y:Y.y-t-Qa,width:Qa,height:Qa},$={x:V.x-t-mb,y:Y.y+Gi+t+c*(Za+t),width:mb,height:mE},z={x:V.x+Gi+t,y:Y.y+Gi+t+f*(Za+t),width:gE,height:yE},G=[],Q={};for(let W=0;W<n;W++){const{quadrant:B,slot:K}=r[W],J=Q4[B];let X;B==="nw"?X={x:V.x-t-ec,y:q.y-t-(K+1)*Za-K*t}:B==="ne"?X={x:V.x+Gi+t,y:I.y-t-(K+1)*Za-K*t}:B==="sw"?X={x:V.x-t-ec,y:Y.y+Gi+t+K*(Za+t)}:X={x:V.x+Gi+t,y:Y.y+Gi+t+K*(Za+t)},G.push({origin:X,width:ec,height:Za,quadrant:B,doorSide:J}),J==="right"||J==="left"?Q[`squad-${W}`]={x:V.x+Gi/2,y:X.y+Za/2}:Q[`squad-${W}`]={x:X.x+ec/2,y:Y.y+Gi/2}}return Q.ceo={x:V.x+Gi/2,y:q.y+id/2},Q["bathroom-male"]={x:ne.x+Qa/2,y:Y.y+Gi/2},Q["bathroom-female"]={x:I.x+Qa/2,y:Y.y+Gi/2},Q.kitchen={x:V.x+Gi/2,y:$.y+$.height/2},Q["rest-area"]={x:V.x+Gi/2,y:z.y+z.height/2},{totalWidth:F,totalHeight:Z,squadOrigins:G,ceoOffice:q,corridorH:Y,corridorV:V,bathroomMale:ne,bathroomFemale:I,kitchen:$,restArea:z,doorPoints:Q,corridorHub:P}}function th(e,t,n,i){const r=e%xE,s=Math.floor(e/xE);return{x:t.x+Y4+r*X4,y:t.y+V4+s*K4}}function bm(e,t,n){return{x:e.x+t-80,y:e.y+n-80}}function $C(e,t,n){return{x:e.x+t-160,y:e.y+Math.floor(n/2)}}function Z4(e,t){const n=t==="male"?e.bathroomMale:e.bathroomFemale;return{x:n.x+n.width/2,y:n.y+n.height/2}}function J4(e){return{x:e.kitchen.x+e.kitchen.width/2,y:e.kitchen.y+e.kitchen.height/2}}function eD(e){return{x:e.restArea.x+e.restArea.width/2,y:e.restArea.y+e.restArea.height/2}}function tD(e){const t=e.corridorV;if(t.height>0&&Math.random()<.5)return{x:t.x+10+Math.random()*Math.max(0,t.width-20),y:t.y+10+Math.random()*Math.max(0,t.height-20)};const n=e.corridorH;return{x:n.x+20+Math.random()*Math.max(0,n.width-40),y:n.y+10+Math.random()*Math.max(0,n.height-20)}}function bE(e,t){const n=t.corridorH;return e.x>=n.x&&e.x<=n.x+n.width&&e.y>=n.y&&e.y<=n.y+n.height}function vE(e,t){const n=t.corridorV;return e.x>=n.x&&e.x<=n.x+n.width&&e.y>=n.y&&e.y<=n.y+n.height}function nD(e,t){if(e==="ceo"){const i=t.ceoOffice;return{x:i.x+i.width/2,y:i.y+i.height/2}}if(e==="bathroom-male"){const i=t.bathroomMale;return{x:i.x+i.width/2,y:i.y+i.height/2}}if(e==="bathroom-female"){const i=t.bathroomFemale;return{x:i.x+i.width/2,y:i.y+i.height/2}}if(e==="kitchen"){const i=t.kitchen;return{x:i.x+i.width/2,y:i.y+i.height/2}}if(e==="rest-area"){const i=t.restArea;return{x:i.x+i.width/2,y:i.y+i.height/2}}const n=e.match(/^squad-(\d+)$/);if(n){const i=parseInt(n[1],10),r=t.squadOrigins[i];if(r)return{x:r.origin.x+r.width/2,y:r.origin.y+r.height/2}}return t.corridorHub}function vm(e,t,n,i){const r=i.doorPoints[t],s=i.doorPoints[n];if(!r||!s)return[e];const l=i.corridorHub,c=nD(n,i),f=bE(r,i)&&bE(s,i),p=vE(r,i)&&vE(s,i);return f||p?[e,r,s,c]:[e,r,l,s,c]}function Ry(e,t){const n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)}const _E=500,SE=50;let EE=0;function wE(e){return{idle:"idle",working:"working",delivering:"walking",done:"idle",checkpoint:"checkpoint"}[e]??"idle"}const ai=fu(e=>({rooms:[],activeRoom:null,bubbles:{},activityLog:{},checkpoints:{},agentVisuals:{},appendBubble:(t,n,i)=>{const r=`${t}:${n}`;e(s=>{var f;let c=(((f=s.bubbles[r])==null?void 0:f.text)??"")+i;return c.length>_E&&(c=c.slice(c.length-_E)),{bubbles:{...s.bubbles,[r]:{text:c,updatedAt:Date.now()}}}})},clearBubble:(t,n)=>{const i=`${t}:${n}`;e(r=>{const{[i]:s,...l}=r.bubbles;return{bubbles:l}})},clearAllBubbles:()=>e({bubbles:{}}),addActivity:(t,n,i)=>{const s={id:++EE,agentName:n,action:i,timestamp:Date.now()};e(l=>{var m;const f=[...((m=l.activityLog[t])==null?void 0:m.entries)??[],s],p=f.length>SE?f.slice(f.length-SE):f;return{activityLog:{...l.activityLog,[t]:{entries:p}}}})},setCheckpoint:(t,n,i,r)=>e(s=>({checkpoints:{...s.checkpoints,[t]:{agentId:n,agentName:i,question:r}}})),clearCheckpoint:t=>e(n=>{const{[t]:i,...r}=n.checkpoints;return{checkpoints:r}}),setActiveRoom:t=>e({activeRoom:t}),syncRooms:t=>e(n=>{const i=t;let r;return i.length===0?r=null:n.activeRoom===null||!i.includes(n.activeRoom)?r=i[0]:r=n.activeRoom,{rooms:i,activeRoom:r}}),setAgents:(t,n)=>e(i=>{const r=i.agentVisuals[t]??[],s=new Map(r.map(v=>[v.id,v])),l={x:0,y:0},c=T0(i.rooms.length),f=i.rooms.indexOf(t),p=c.squadOrigins[f],m=(p==null?void 0:p.width)??480,g=(p==null?void 0:p.height)??360,x=n.map((v,S)=>{const A=s.get(v.id);if(A){const N=v.status?wE(v.status):A.status,R=N!==A.status;let O=A.targetPosition;return R&&(N==="working"||N==="checkpoint"?O=th(S,l):O=bm(l,m,g)),{...A,name:v.name,avatar:v.avatar,deskIndex:S,status:N,targetPosition:O}}const T=v.status?wE(v.status):"idle",C=T==="working"||T==="checkpoint"?th(S,l):bm(l,m,g);return{id:v.id,name:v.name,avatar:v.avatar,colorIndex:S%6,status:T,deskIndex:S,position:C,targetPosition:null}});return{agentVisuals:{...i.agentVisuals,[t]:x}}}),setAgentStatus:(t,n,i)=>e(r=>{const s=r.agentVisuals[t];if(!s)return r;const l={x:0,y:0},c=T0(r.rooms.length),f=r.rooms.indexOf(t),p=c.squadOrigins[f],m=(p==null?void 0:p.width)??480,g=(p==null?void 0:p.height)??360,x=s.map(v=>{if(v.id!==n)return v;let S;return i==="working"||i==="checkpoint"?S=th(v.deskIndex,l):S=bm(l,m,g),{...v,status:i,targetPosition:S}});return{agentVisuals:{...r.agentVisuals,[t]:x}}}),reset:()=>{EE=0,e({rooms:[],activeRoom:null,bubbles:{},activityLog:{},checkpoints:{},agentVisuals:{}})}})),aQ={background:"#0a0a0f",grid:"rgba(0, 200, 255, 0.06)",orbStandby:"#1a3a5c",orbListening:"#00c8ff",orbProcessing:"#ff8c00",orbSpeaking:"#00ff88",panelBg:"rgba(0, 200, 255, 0.08)",panelBorder:"rgba(0, 200, 255, 0.25)",textPrimary:"#e0e8f0",textAccent:"#00c8ff",textJarvis:"#00ff88",particleStart:"#00c8ff"},iD={orbRadius:60,orbRingWidth:3,gridSpacing:40,particleCount:65,particleMinRadius:1,particleMaxRadius:3,waveformBars:32,waveformMaxHeight:40,panelWidth:180,panelPadding:12,transcriptLineHeight:20,standbyTimeoutMs:15e3,ttsSplitLength:300};let WC=0;function rD(){return`jarvis-${Date.now()}-${++WC}`}let lo=null;const gb=fu((e,t)=>({mode:"STANDBY",messages:[],streamingText:"",selectedSquad:null,userName:"",setMode:n=>e({mode:n}),addMessage:(n,i)=>{const r={id:rD(),role:n,content:i,createdAt:new Date().toISOString()};e(s=>({messages:[...s.messages,r]}))},appendChunk:n=>{e(i=>({streamingText:i.streamingText+n}))},finalizeMessage:n=>{const{streamingText:i}=t(),r={id:n,role:"assistant",content:i,createdAt:new Date().toISOString()};e(s=>({messages:[...s.messages,r],streamingText:""}))},selectSquad:n=>e({selectedSquad:n}),setUserName:n=>e({userName:n}),startStandbyTimer:()=>{lo&&clearTimeout(lo),lo=setTimeout(()=>{e({mode:"STANDBY"}),lo=null},iD.standbyTimeoutMs)},resetStandbyTimer:()=>{t().startStandbyTimer()},clearStandbyTimer:()=>{lo&&(clearTimeout(lo),lo=null)},reset:()=>{lo&&(clearTimeout(lo),lo=null),WC=0,e({mode:"STANDBY",messages:[],streamingText:"",selectedSquad:null,userName:""})}})),ua=fu((e,t)=>({jobs:[],loading:!1,history:{},historyLoading:{},fetchJobs:async()=>{e({loading:!0});try{const n=await fetch("/api/scheduler",{credentials:"include"});if(n.ok){const i=await n.json();e({jobs:i.data,loading:!1})}else e({loading:!1})}catch{e({loading:!1})}},createJob:async n=>(await fetch("/api/scheduler",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).ok?(t().fetchJobs(),!0):!1,deleteJob:async n=>{await fetch(`/api/scheduler/${n}`,{method:"DELETE",credentials:"include"}),t().fetchJobs()},pauseJob:async n=>{await fetch(`/api/scheduler/${n}/pause`,{method:"POST",credentials:"include"}),t().fetchJobs()},resumeJob:async n=>{await fetch(`/api/scheduler/${n}/resume`,{method:"POST",credentials:"include"}),t().fetchJobs()},triggerJob:async n=>{await fetch(`/api/scheduler/${n}/trigger`,{method:"POST",credentials:"include"})},updateJobStatus:(n,i)=>{e(r=>({jobs:r.jobs.map(s=>s.squad_name===n?{...s,status:i}:s)}))},fetchHistory:async n=>{e(i=>({historyLoading:{...i.historyLoading,[n]:!0}}));try{const i=await fetch(`/api/scheduler/${n}/history?limit=50`,{credentials:"include"});if(i.ok){const r=await i.json();e(s=>({history:{...s.history,[n]:r.data},historyLoading:{...s.historyLoading,[n]:!1}}))}else e(r=>({historyLoading:{...r.historyLoading,[n]:!1}}))}catch{e(i=>({historyLoading:{...i.historyLoading,[n]:!1}}))}}})),aD=600*1e3;function sD(){const[e,t]=j.useState(null),[n,i]=j.useState(!1),[r,s]=j.useState(!1),l=j.useCallback(async()=>{try{const f=await fetch("/api/system/version",{credentials:"include"});if(f.ok){const p=await f.json();t(p)}}catch{}},[]);j.useEffect(()=>{l();const f=setInterval(l,aD);return()=>clearInterval(f)},[l]);const c=async()=>{i(!0);try{await fetch("/api/system/update",{method:"POST",credentials:"include"})}catch{i(!1)}};return!(e!=null&&e.updateAvailable)||r?null:_.jsx("div",{"data-testid":"update-banner",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"var(--sp-3)",padding:"8px var(--sp-4)",background:"var(--surface-2)",borderBottom:"1px solid var(--accent)",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)",animation:"fadeIn 0.3s var(--ease-out) both"},children:n?_.jsxs("span",{style:{color:"var(--accent)"},children:["Updating to v",e.latest,"... Server will restart automatically."]}):_.jsxs(_.Fragment,{children:[_.jsxs("span",{children:["New version available: ",_.jsxs("strong",{style:{color:"var(--accent)"},children:["v",e.latest]}),_.jsxs("span",{style:{color:"var(--text-muted)",marginLeft:6},children:["(current: v",e.current,")"]})]}),_.jsx("button",{"data-testid":"btn-update",onClick:c,style:{padding:"3px 12px",borderRadius:"var(--radius-xs)",fontFamily:"var(--font-mono)",fontSize:"0.68rem",fontWeight:600,cursor:"pointer",border:"none",background:"var(--accent)",color:"var(--text-inverse)",transition:"opacity 0.15s ease"},children:"Update"}),_.jsx("button",{"data-testid":"btn-dismiss-update",onClick:()=>s(!0),style:{padding:"2px 6px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.68rem"},children:"✕"})]})})}function lD(){if(typeof window>"u")return"dark";const e=localStorage.getItem("expx-theme");return e==="light"||e==="dark"?e:"dark"}function TE(e){document.documentElement.setAttribute("data-theme",e),localStorage.setItem("expx-theme",e)}const C0=fu((e,t)=>({theme:lD(),toggle:()=>{const n=t().theme==="dark"?"light":"dark";TE(n),e({theme:n})},setTheme:n=>{TE(n),e({theme:n})}})),oD=j.lazy(()=>ou(()=>import("./ThreeBackground-CjnKNeeJ.js"),__vite__mapDeps([0,1])).then(e=>({default:e.ThreeBackground}))),cD=[{to:"/office",label:"Office",icon:"⬡"},{to:"/chat",label:"Chat",icon:"◈"},{to:"/kanban",label:"Kanban",icon:"▦"},{to:"/dashboard",label:"Dashboard",icon:"▣"},{to:"/scheduler",label:"Scheduler",icon:"⏣"},{to:"/email",label:"Email",icon:"✉"},{to:"/orgchart",label:"Org Chart",icon:"◎"},{to:"/graph",label:"Graph",icon:"◇"},{to:"/files",label:"Files",icon:"▤"},{to:"/settings",label:"Settings",icon:"⚙"}];function uD(){const e=gl(ie=>ie.user),t=gl(ie=>ie.isAuthenticated),n=gl(ie=>ie.loading),i=gl(ie=>ie.logout),r=gl(ie=>ie.checkAuth),s=Z0(),l=wl();l.pathname==="/office"||l.pathname;const c=l.pathname==="/jarvis",f=C0(ie=>ie.theme),p=C0(ie=>ie.toggle),m=vr(ie=>ie.squads),g=vr(ie=>ie.selectedSquad),x=vr(ie=>g?ie.activeStates[g]:null),v=vr(ie=>ie.fetchSquads),S=vr(ie=>ie.setSquadState),A=vr(ie=>ie.clearSquadState),T=j.useCallback((ie,de)=>{S(ie,de);const ye=ai.getState();ye.rooms.includes(ie)||ye.syncRooms([...ye.rooms,ie]),de.status!=="checkpoint"&&ye.clearCheckpoint(ie),de.agents&&ye.setAgents(ie,de.agents.map(me=>({id:me.id,name:me.name,status:me.status})))},[S]),C=j.useCallback(ie=>{A(ie);const de=ai.getState(),ye=de.agentVisuals[ie];if(ye)for(const me of ye)de.setAgentStatus(ie,me.id,"idle")},[A]),N=j.useCallback((ie,de)=>{rr.setState(ye=>({conversationId:de,messages:[],conversations:[{id:de,createdAt:new Date().toISOString(),preview:""},...ye.conversations.filter(me=>me.id!==de)]}))},[]),R=j.useCallback((ie,de,ye)=>{if(ie==="_jarvis"){gb.getState().appendChunk(ye);return}const me=rr.getState();me.streaming||me.startStreaming(),me.appendChunk(ye)},[]),O=j.useCallback((ie,de,ye)=>{if(ie==="_jarvis"){gb.getState().finalizeMessage(ye);return}rr.getState().finishStreaming(ye)},[]),H=j.useCallback((ie,de)=>{if(ie==="_jarvis"){gb.getState().setMode("LISTENING");return}rr.getState().setError(de)},[]),D=j.useCallback((ie,de,ye)=>{ie!=="_jarvis"&&rr.getState().setActivity(`${de}${ye?" "+ye:""}`)},[]),F=j.useCallback((ie,de,ye,me,le)=>{rr.getState().addAgentDm({agentId:ye,agentName:me,content:le})},[]),Z=j.useCallback((ie,de,ye,me)=>{ai.getState().appendBubble(ie,de,me)},[]),V=j.useCallback((ie,de,ye,me,le)=>{ai.getState().addActivity(ie,ye,`started "${le}"`),ai.getState().setAgentStatus(ie,de,"working")},[]),Y=j.useCallback((ie,de,ye,me,le)=>{ai.getState().addActivity(ie,ye,`completed "${le}"`),ai.getState().setAgentStatus(ie,de,"idle")},[]),P=j.useCallback((ie,de,ye,me)=>{ai.getState().setCheckpoint(ie,de,ye,me),ai.getState().setAgentStatus(ie,de,"checkpoint")},[]),q=j.useCallback(()=>{ai.getState().clearAllBubbles()},[]),ne=j.useCallback((ie,de,ye)=>{ua.getState().fetchJobs()},[]),I=j.useCallback((ie,de,ye,me)=>{ua.getState().fetchJobs()},[]),$=j.useCallback((ie,de,ye,me,le)=>{ua.getState().fetchJobs()},[]),z=j.useCallback((ie,de)=>{ua.getState().updateJobStatus(ie,de)},[]),G=j.useCallback(ie=>{window.dispatchEvent(new CustomEvent("kanban:task_updated",{detail:ie}))},[]),Q=j.useCallback((ie,de)=>{vr.getState().setUiComponents(ie,de)},[]),{subscribe:W,unsubscribe:B,sendChat:K,newConversation:J,sendCheckpointResponse:X}=L4({onSquadState:T,onSquadInactive:C,onChatConversationCreated:N,onChatChunk:R,onChatActivity:D,onChatDone:O,onChatError:H,onChatAgentDm:F,onAgentOutputChunk:Z,onAgentStepStart:V,onAgentStepComplete:Y,onSquadCheckpoint:P,onReconnect:q,onScheduleStarted:ne,onScheduleDone:I,onScheduleError:$,onScheduleStatusChanged:z,onKanbanTaskUpdated:G,onA2uiUpdate:Q});j.useEffect(()=>{U4(K)},[K]),j.useEffect(()=>{H4(J)},[J]),j.useEffect(()=>{F4(X)},[X]),j.useEffect(()=>{v().then(()=>{const{squads:ie}=vr.getState();if(ie.length>0){const de=ai.getState(),ye=ie.map(Re=>Re.code),me=de.rooms,le=[...new Set([...me,...ye])];de.syncRooms(le);for(const Re of ie)!de.agentVisuals[Re.code]&&Re.agents&&Re.agents.length>0&&de.setAgents(Re.code,Re.agents.map(Le=>({id:Le.id,name:Le.name,avatar:Le.avatar,status:"idle"})))}})},[v]);const ce=ai(ie=>ie.rooms);return j.useEffect(()=>{for(const ie of ce)W(ie);return()=>{for(const ie of ce)B(ie)}},[ce,W,B]),j.useEffect(()=>(W("_expxagents"),()=>B("_expxagents")),[W,B]),j.useEffect(()=>{if(c)return W("_jarvis"),()=>B("_jarvis")},[c,W,B]),j.useEffect(()=>{t||r()},[]),j.useEffect(()=>{!n&&!t&&s("/login",{state:{from:l.pathname}})},[n,t,s,l.pathname]),c?_.jsx(uE,{}):_.jsxs("div",{className:"noise-bg",style:{display:"flex",flexDirection:"column",height:"100vh",background:"var(--surface-0)",color:"var(--text-primary)"},children:[_.jsxs("header",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",height:"var(--header-height)",padding:"0 var(--sp-4)",background:"var(--surface-1)",borderBottom:"1px solid var(--border-subtle)",position:"relative",zIndex:10},children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[_.jsx("div",{style:{width:28,height:28,borderRadius:"var(--radius-sm)",background:"linear-gradient(135deg, var(--accent), var(--accent-dim))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.8rem",fontWeight:700,color:"var(--text-inverse)",boxShadow:"0 0 12px var(--accent-glow-strong)"},children:"EX"}),_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",letterSpacing:"-0.02em"},children:"ExpxAgents"}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",background:"var(--surface-3)",padding:"2px 6px",borderRadius:"var(--radius-xs)",letterSpacing:"0.05em"},children:"MISSION CONTROL"})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-4)"},children:[_.jsx("button",{"data-testid":"btn-restart-server",onClick:async()=>{if(confirm("Restart the server? It will be briefly unavailable."))try{await fetch("/api/system/restart",{method:"POST",credentials:"include"})}catch{}},title:"Restart server",style:{background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.7rem",padding:"3px 8px",borderRadius:"var(--radius-xs)",transition:"all var(--duration-fast) var(--ease-out)",display:"flex",alignItems:"center",gap:4},onMouseEnter:ie=>{ie.currentTarget.style.color="var(--accent)",ie.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:ie=>{ie.currentTarget.style.color="var(--text-muted)",ie.currentTarget.style.borderColor="var(--border-subtle)"},children:"↻ Restart"}),_.jsx("button",{"data-testid":"btn-toggle-theme",onClick:p,title:`Switch to ${f==="dark"?"light":"dark"} mode`,style:{background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.85rem",padding:"3px 8px",borderRadius:"var(--radius-xs)",transition:"all var(--duration-fast) var(--ease-out)",display:"flex",alignItems:"center",gap:4,lineHeight:1},onMouseEnter:ie=>{ie.currentTarget.style.color="var(--accent)",ie.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:ie=>{ie.currentTarget.style.color="var(--text-muted)",ie.currentTarget.style.borderColor="var(--border-subtle)"},children:f==="dark"?"☀":"☽"}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-2)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)"},children:[_.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:"var(--status-active)",boxShadow:"0 0 8px var(--status-active-glow)",animation:"statusPulse 2s ease-in-out infinite"}}),_.jsx("span",{children:e==null?void 0:e.username})]}),_.jsx("button",{onClick:i,className:"btn-ghost",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-display)",fontSize:"0.75rem",padding:"4px 8px",borderRadius:"var(--radius-xs)",transition:"color var(--duration-fast) var(--ease-out)"},onMouseEnter:ie=>ie.currentTarget.style.color="var(--status-error)",onMouseLeave:ie=>ie.currentTarget.style.color="var(--text-muted)",children:"Logout"})]})]}),_.jsx(sD,{}),_.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[_.jsxs("aside",{style:{width:"var(--sidebar-width)",background:"var(--surface-1)",borderRight:"1px solid var(--border-subtle)",display:"flex",flexDirection:"column",overflowY:"auto"},children:[_.jsxs("nav",{style:{padding:"var(--sp-3)",display:"flex",flexDirection:"column",gap:"var(--sp-1)",flex:1},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.1em",padding:"0 var(--sp-2)",marginBottom:"var(--sp-1)"},children:"Navigation"}),cD.map(ie=>_.jsxs(YC,{to:ie.to,style:({isActive:de})=>({display:"flex",alignItems:"center",gap:"var(--sp-2)",padding:"8px 10px",borderRadius:"var(--radius-sm)",textDecoration:"none",fontSize:"0.82rem",fontWeight:de?600:400,color:de?"var(--accent)":"var(--text-secondary)",background:de?"var(--accent-glow)":"transparent",border:de?"1px solid var(--accent-glow)":"1px solid transparent",transition:"all var(--duration-fast) var(--ease-out)"}),children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.85rem",width:20,textAlign:"center",opacity:.7},children:ie.icon}),ie.label]},ie.to)),_.jsx("div",{style:{height:1,margin:"var(--sp-2) var(--sp-2)",background:"var(--border-subtle)"}}),_.jsxs("a",{href:"/jarvis",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"var(--sp-2)",padding:"8px 10px",borderRadius:"var(--radius-sm)",textDecoration:"none",fontSize:"0.82rem",fontWeight:500,color:"var(--status-active)",background:"var(--status-active-glow)",border:"1px solid var(--status-active-glow)",transition:"all var(--duration-fast) var(--ease-out)"},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.85rem",width:20,textAlign:"center",opacity:.7},children:"◉"}),"Jarvis",_.jsx("span",{style:{marginLeft:"auto",fontFamily:"var(--font-mono)",fontSize:"0.55rem",opacity:.6},children:"↗"})]})]}),_.jsxs("div",{style:{padding:"var(--sp-3)",borderTop:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",display:"flex",justifyContent:"space-between"},children:[_.jsxs("span",{children:[m.length," squad",m.length!==1?"s":""]}),_.jsx("span",{children:"v0.1.0"})]})]}),_.jsxs("main",{className:"grid-bg",style:{flex:1,overflow:"hidden",position:"relative"},children:[_.jsx(j.Suspense,{fallback:null,children:_.jsx(oD,{opacity:.4})}),_.jsx("div",{style:{position:"relative",zIndex:1,height:"100%",overflow:"auto"},children:_.jsx(uE,{})})]})]}),_.jsx(I4,{state:x})]})}const dD=j.lazy(()=>ou(()=>import("./ThreeBackground-CjnKNeeJ.js"),__vite__mapDeps([0,1])).then(e=>({default:e.ThreeBackground})));function fD(){var S;const[e,t]=j.useState(""),[n,i]=j.useState(""),r=gl(A=>A.login),s=gl(A=>A.loading),l=gl(A=>A.error),c=gl(A=>A.isAuthenticated),f=Z0(),m=((S=wl().state)==null?void 0:S.from)||"/";j.useEffect(()=>{c&&f(m,{replace:!0})},[c,f,m]);const g=A=>{A.preventDefault(),r(e,n)},x=C0(A=>A.theme),v=C0(A=>A.toggle);return _.jsxs("div",{className:"noise-bg",style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"100vh",background:"var(--surface-0)",position:"relative",overflow:"hidden"},children:[_.jsx(j.Suspense,{fallback:null,children:_.jsx(dD,{opacity:.6})}),_.jsx("button",{onClick:v,title:`Switch to ${x==="dark"?"light":"dark"} mode`,style:{position:"absolute",top:16,right:16,zIndex:10,background:"var(--surface-2)",border:"1px solid var(--border-default)",color:"var(--text-secondary)",cursor:"pointer",fontSize:"1rem",padding:"6px 10px",borderRadius:"var(--radius-sm)",transition:"all var(--duration-fast) var(--ease-out)",lineHeight:1},children:x==="dark"?"☀":"☽"}),_.jsxs("div",{style:{animation:"fadeInUp 0.6s var(--ease-out) both",width:360,position:"relative",zIndex:1},children:[_.jsxs("div",{style:{textAlign:"center",marginBottom:"var(--sp-8)"},children:[_.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:48,height:48,borderRadius:"var(--radius-md)",background:"linear-gradient(135deg, var(--accent), var(--accent-dim))",fontSize:"1.1rem",fontWeight:800,color:"var(--text-inverse)",boxShadow:"var(--shadow-glow-strong)",marginBottom:"var(--sp-4)"},children:"EX"}),_.jsx("h1",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1.4rem",color:"var(--text-primary)",letterSpacing:"-0.02em",marginBottom:"var(--sp-1)"},children:"ExpxAgents"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.15em"},children:"Mission Control"})]}),_.jsxs("form",{onSubmit:g,className:"glass",style:{padding:"var(--sp-6)",borderRadius:"var(--radius-lg)",boxShadow:"var(--shadow-lg)"},children:[l&&_.jsx("div",{style:{padding:"var(--sp-2) var(--sp-3)",marginBottom:"var(--sp-4)",borderRadius:"var(--radius-sm)",background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.2)",color:"var(--status-error)",fontSize:"0.8rem",fontFamily:"var(--font-mono)"},children:l}),_.jsxs("div",{style:{marginBottom:"var(--sp-3)"},children:[_.jsx("label",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:"var(--sp-1)"},children:"Username"}),_.jsx("input",{type:"text",className:"input",placeholder:"Enter username",value:e,onChange:A=>t(A.target.value),autoFocus:!0})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("label",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:"var(--sp-1)"},children:"Password"}),_.jsx("input",{type:"password",className:"input",placeholder:"Enter password",value:n,onChange:A=>i(A.target.value)})]}),_.jsx("button",{type:"submit",disabled:s,className:"btn btn-accent",style:{width:"100%",padding:"var(--sp-3)",fontSize:"0.85rem",cursor:s?"wait":"pointer",opacity:s?.7:1},children:s?"Authenticating...":"Access Mission Control"})]}),_.jsx("p",{style:{textAlign:"center",marginTop:"var(--sp-4)",fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)"},children:"AI Squad Orchestration Platform"})]})]})}function QC(e,t,n){if(!e)return;if(n(e)===!0)return e;let i=e.child;for(;i;){const r=QC(i,t,n);if(r)return r;i=i.sibling}}function ZC(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}const Z1=ZC(j.createContext(null));let JC=class extends j.Component{render(){return j.createElement(Z1.Provider,{value:this._reactInternals},this.props.children)}};function hD(){const e=j.useContext(Z1);if(e===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const t=j.useId();return j.useMemo(()=>{for(const n of[e,e==null?void 0:e.alternate]){if(!n)continue;const i=QC(n,!1,r=>{let s=r.memoizedState;for(;s;){if(s.memoizedState===t)return!0;s=s.next}});if(i)return i}},[e,t])}const pD=Symbol.for("react.context"),mD=e=>e!==null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===pD;function gD(){const e=hD(),[t]=j.useState(()=>new Map);t.clear();let n=e;for(;n;){const i=n.type;mD(i)&&i!==Z1&&!t.has(i)&&t.set(i,j.use(ZC(i))),n=n.return}return t}function yD(){const e=gD();return j.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>i=>j.createElement(t,null,j.createElement(n.Provider,{...i,value:e.get(n)})),t=>j.createElement(JC,{...t})),[e])}var kt=(e=>(e.Application="application",e.WebGLPipes="webgl-pipes",e.WebGLPipesAdaptor="webgl-pipes-adaptor",e.WebGLSystem="webgl-system",e.WebGPUPipes="webgpu-pipes",e.WebGPUPipesAdaptor="webgpu-pipes-adaptor",e.WebGPUSystem="webgpu-system",e.CanvasSystem="canvas-system",e.CanvasPipesAdaptor="canvas-pipes-adaptor",e.CanvasPipes="canvas-pipes",e.Asset="asset",e.LoadParser="load-parser",e.ResolveParser="resolve-parser",e.CacheParser="cache-parser",e.DetectionParser="detection-parser",e.MaskEffect="mask-effect",e.BlendMode="blend-mode",e.TextureSource="texture-source",e.Environment="environment",e.ShapeBuilder="shape-builder",e.Batcher="batcher",e))(kt||{});const Vv=e=>{if(typeof e=="function"||typeof e=="object"&&e.extension){if(!e.extension)throw new Error("Extension class must have an extension object");e={...typeof e.extension!="object"?{type:e.extension}:e.extension,ref:e}}if(typeof e=="object")e={...e};else throw new Error("Invalid extension type");return typeof e.type=="string"&&(e.type=[e.type]),e},ky=(e,t)=>Vv(e).priority??t,li={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...e){return e.map(Vv).forEach(t=>{t.type.forEach(n=>{var i,r;return(r=(i=this._removeHandlers)[n])==null?void 0:r.call(i,t)})}),this},add(...e){return e.map(Vv).forEach(t=>{t.type.forEach(n=>{var s,l;const i=this._addHandlers,r=this._queue;i[n]?(l=i[n])==null||l.call(i,t):(r[n]=r[n]||[],(s=r[n])==null||s.push(t))})}),this},handle(e,t,n){var l;const i=this._addHandlers,r=this._removeHandlers;if(i[e]||r[e])throw new Error(`Extension type ${e} already has a handler`);i[e]=t,r[e]=n;const s=this._queue;return s[e]&&((l=s[e])==null||l.forEach(c=>t(c)),delete s[e]),this},handleByMap(e,t){return this.handle(e,n=>{n.name&&(t[n.name]=n.ref)},n=>{n.name&&delete t[n.name]})},handleByNamedList(e,t,n=-1){return this.handle(e,i=>{t.findIndex(s=>s.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((s,l)=>ky(l.value,n)-ky(s.value,n)))},i=>{const r=t.findIndex(s=>s.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(e,t,n=-1){return this.handle(e,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,s)=>ky(s,n)-ky(r,n)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})},mixin(e,...t){for(const n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}},xD={extension:{type:kt.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await ou(()=>import("./browserAll-Bld8lsfV.js"),__vite__mapDeps([2,3]))}},bD={extension:{type:kt.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await ou(()=>import("./webworkerAll-CcL19ShU.js"),[])}};class br{constructor(t,n,i){this._x=n||0,this._y=i||0,this._observer=t}clone(t){return new br(t??this._observer,this._x,this._y)}set(t=0,n=t){return(this._x!==t||this._y!==n)&&(this._x=t,this._y=n,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}var yb={exports:{}},CE;function vD(){return CE||(CE=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(n=!1));function r(f,p,m){this.fn=f,this.context=p,this.once=m||!1}function s(f,p,m,g,x){if(typeof m!="function")throw new TypeError("The listener must be a function");var v=new r(m,g||f,x),S=n?n+p:p;return f._events[S]?f._events[S].fn?f._events[S]=[f._events[S],v]:f._events[S].push(v):(f._events[S]=v,f._eventsCount++),f}function l(f,p){--f._eventsCount===0?f._events=new i:delete f._events[p]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var p=[],m,g;if(this._eventsCount===0)return p;for(g in m=this._events)t.call(m,g)&&p.push(n?g.slice(1):g);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(m)):p},c.prototype.listeners=function(p){var m=n?n+p:p,g=this._events[m];if(!g)return[];if(g.fn)return[g.fn];for(var x=0,v=g.length,S=new Array(v);x<v;x++)S[x]=g[x].fn;return S},c.prototype.listenerCount=function(p){var m=n?n+p:p,g=this._events[m];return g?g.fn?1:g.length:0},c.prototype.emit=function(p,m,g,x,v,S){var A=n?n+p:p;if(!this._events[A])return!1;var T=this._events[A],C=arguments.length,N,R;if(T.fn){switch(T.once&&this.removeListener(p,T.fn,void 0,!0),C){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,m),!0;case 3:return T.fn.call(T.context,m,g),!0;case 4:return T.fn.call(T.context,m,g,x),!0;case 5:return T.fn.call(T.context,m,g,x,v),!0;case 6:return T.fn.call(T.context,m,g,x,v,S),!0}for(R=1,N=new Array(C-1);R<C;R++)N[R-1]=arguments[R];T.fn.apply(T.context,N)}else{var O=T.length,H;for(R=0;R<O;R++)switch(T[R].once&&this.removeListener(p,T[R].fn,void 0,!0),C){case 1:T[R].fn.call(T[R].context);break;case 2:T[R].fn.call(T[R].context,m);break;case 3:T[R].fn.call(T[R].context,m,g);break;case 4:T[R].fn.call(T[R].context,m,g,x);break;default:if(!N)for(H=1,N=new Array(C-1);H<C;H++)N[H-1]=arguments[H];T[R].fn.apply(T[R].context,N)}}return!0},c.prototype.on=function(p,m,g){return s(this,p,m,g,!1)},c.prototype.once=function(p,m,g){return s(this,p,m,g,!0)},c.prototype.removeListener=function(p,m,g,x){var v=n?n+p:p;if(!this._events[v])return this;if(!m)return l(this,v),this;var S=this._events[v];if(S.fn)S.fn===m&&(!x||S.once)&&(!g||S.context===g)&&l(this,v);else{for(var A=0,T=[],C=S.length;A<C;A++)(S[A].fn!==m||x&&!S[A].once||g&&S[A].context!==g)&&T.push(S[A]);T.length?this._events[v]=T.length===1?T[0]:T:l(this,v)}return this},c.prototype.removeAllListeners=function(p){var m;return p?(m=n?n+p:p,this._events[m]&&l(this,m)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c})(yb)),yb.exports}var _D=vD();const yo=du(_D),SD=Math.PI*2,ED=180/Math.PI,wD=Math.PI/180;class Lr{constructor(t=0,n=0){this.x=0,this.y=0,this.x=t,this.y=n}clone(){return new Lr(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,n=t){return this.x=t,this.y=n,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return xb.x=0,xb.y=0,xb}}const xb=new Lr;class Ht{constructor(t=1,n=0,i=0,r=1,s=0,l=0){this.array=null,this.a=t,this.b=n,this.c=i,this.d=r,this.tx=s,this.ty=l}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,n,i,r,s,l){return this.a=t,this.b=n,this.c=i,this.d=r,this.tx=s,this.ty=l,this}toArray(t,n){this.array||(this.array=new Float32Array(9));const i=n||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,n){n=n||new Lr;const i=t.x,r=t.y;return n.x=this.a*i+this.c*r+this.tx,n.y=this.b*i+this.d*r+this.ty,n}applyInverse(t,n){n=n||new Lr;const i=this.a,r=this.b,s=this.c,l=this.d,c=this.tx,f=this.ty,p=1/(i*l+s*-r),m=t.x,g=t.y;return n.x=l*p*m+-s*p*g+(f*s-c*l)*p,n.y=i*p*g+-r*p*m+(-f*i+c*r)*p,n}translate(t,n){return this.tx+=t,this.ty+=n,this}scale(t,n){return this.a*=t,this.d*=n,this.c*=t,this.b*=n,this.tx*=t,this.ty*=n,this}rotate(t){const n=Math.cos(t),i=Math.sin(t),r=this.a,s=this.c,l=this.tx;return this.a=r*n-this.b*i,this.b=r*i+this.b*n,this.c=s*n-this.d*i,this.d=s*i+this.d*n,this.tx=l*n-this.ty*i,this.ty=l*i+this.ty*n,this}append(t){const n=this.a,i=this.b,r=this.c,s=this.d;return this.a=t.a*n+t.b*r,this.b=t.a*i+t.b*s,this.c=t.c*n+t.d*r,this.d=t.c*i+t.d*s,this.tx=t.tx*n+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}appendFrom(t,n){const i=t.a,r=t.b,s=t.c,l=t.d,c=t.tx,f=t.ty,p=n.a,m=n.b,g=n.c,x=n.d;return this.a=i*p+r*g,this.b=i*m+r*x,this.c=s*p+l*g,this.d=s*m+l*x,this.tx=c*p+f*g+n.tx,this.ty=c*m+f*x+n.ty,this}setTransform(t,n,i,r,s,l,c,f,p){return this.a=Math.cos(c+p)*s,this.b=Math.sin(c+p)*s,this.c=-Math.sin(c-f)*l,this.d=Math.cos(c-f)*l,this.tx=t-(i*this.a+r*this.c),this.ty=n-(i*this.b+r*this.d),this}prepend(t){const n=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=n*t.a+this.ty*t.c+t.tx,this.ty=n*t.b+this.ty*t.d+t.ty,this}decompose(t){const n=this.a,i=this.b,r=this.c,s=this.d,l=t.pivot,c=-Math.atan2(-r,s),f=Math.atan2(i,n),p=Math.abs(c+f);return p<1e-5||Math.abs(SD-p)<1e-5?(t.rotation=f,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=c,t.skew.y=f),t.scale.x=Math.sqrt(n*n+i*i),t.scale.y=Math.sqrt(r*r+s*s),t.position.x=this.tx+(l.x*n+l.y*r),t.position.y=this.ty+(l.x*i+l.y*s),t}invert(){const t=this.a,n=this.b,i=this.c,r=this.d,s=this.tx,l=t*r-n*i;return this.a=r/l,this.b=-n/l,this.c=-i/l,this.d=t/l,this.tx=(i*this.ty-r*s)/l,this.ty=-(t*this.ty-n*s)/l,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new Ht;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return CD.identity()}static get shared(){return TD.identity()}}const TD=new Ht,CD=new Ht,od=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],cd=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ud=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],dd=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Xv=[],eA=[],Ny=Math.sign;function AD(){for(let e=0;e<16;e++){const t=[];Xv.push(t);for(let n=0;n<16;n++){const i=Ny(od[e]*od[n]+ud[e]*cd[n]),r=Ny(cd[e]*od[n]+dd[e]*cd[n]),s=Ny(od[e]*ud[n]+ud[e]*dd[n]),l=Ny(cd[e]*ud[n]+dd[e]*dd[n]);for(let c=0;c<16;c++)if(od[c]===i&&cd[c]===r&&ud[c]===s&&dd[c]===l){t.push(c);break}}}for(let e=0;e<16;e++){const t=new Ht;t.set(od[e],cd[e],ud[e],dd[e],0,0),eA.push(t)}}AD();const Bn={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:e=>od[e],uY:e=>cd[e],vX:e=>ud[e],vY:e=>dd[e],inv:e=>e&8?e&15:-e&7,add:(e,t)=>Xv[e][t],sub:(e,t)=>Xv[e][Bn.inv(t)],rotate180:e=>e^4,isVertical:e=>(e&3)===2,byDirection:(e,t)=>Math.abs(e)*2<=Math.abs(t)?t>=0?Bn.S:Bn.N:Math.abs(t)*2<=Math.abs(e)?e>0?Bn.E:Bn.W:t>0?e>0?Bn.SE:Bn.SW:e>0?Bn.NE:Bn.NW,matrixAppendRotationInv:(e,t,n=0,i=0,r=0,s=0)=>{const l=eA[Bn.inv(t)],c=l.a,f=l.b,p=l.c,m=l.d,g=n-Math.min(0,c*r,p*s,c*r+p*s),x=i-Math.min(0,f*r,m*s,f*r+m*s),v=e.a,S=e.b,A=e.c,T=e.d;e.a=c*v+f*A,e.b=c*S+f*T,e.c=p*v+m*A,e.d=p*S+m*T,e.tx=g*v+x*A+e.tx,e.ty=g*S+x*T+e.ty},transformRectCoords:(e,t,n,i)=>{const{x:r,y:s,width:l,height:c}=e,{x:f,y:p,width:m,height:g}=t;return n===Bn.E?(i.set(r+f,s+p,l,c),i):n===Bn.S?i.set(m-s-c+f,r+p,c,l):n===Bn.W?i.set(m-r-l+f,g-s-c+p,l,c):n===Bn.N?i.set(s+f,g-r-l+p,c,l):i.set(r+f,s+p,l,c)}},Oy=[new Lr,new Lr,new Lr,new Lr];class Ti{constructor(t=0,n=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(n),this.width=Number(i),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new Ti(0,0,0,0)}clone(){return new Ti(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,n){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&n>=this.y&&n<this.y+this.height}strokeContains(t,n,i,r=.5){const{width:s,height:l}=this;if(s<=0||l<=0)return!1;const c=this.x,f=this.y,p=i*(1-r),m=i-p,g=c-p,x=c+s+p,v=f-p,S=f+l+p,A=c+m,T=c+s-m,C=f+m,N=f+l-m;return t>=g&&t<=x&&n>=v&&n<=S&&!(t>A&&t<T&&n>C&&n<N)}intersects(t,n){if(!n){const Z=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=Z)return!1;const Y=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>Y}const i=this.left,r=this.right,s=this.top,l=this.bottom;if(r<=i||l<=s)return!1;const c=Oy[0].set(t.left,t.top),f=Oy[1].set(t.left,t.bottom),p=Oy[2].set(t.right,t.top),m=Oy[3].set(t.right,t.bottom);if(p.x<=c.x||f.y<=c.y)return!1;const g=Math.sign(n.a*n.d-n.b*n.c);if(g===0||(n.apply(c,c),n.apply(f,f),n.apply(p,p),n.apply(m,m),Math.max(c.x,f.x,p.x,m.x)<=i||Math.min(c.x,f.x,p.x,m.x)>=r||Math.max(c.y,f.y,p.y,m.y)<=s||Math.min(c.y,f.y,p.y,m.y)>=l))return!1;const x=g*(f.y-c.y),v=g*(c.x-f.x),S=x*i+v*s,A=x*r+v*s,T=x*i+v*l,C=x*r+v*l;if(Math.max(S,A,T,C)<=x*c.x+v*c.y||Math.min(S,A,T,C)>=x*m.x+v*m.y)return!1;const N=g*(c.y-p.y),R=g*(p.x-c.x),O=N*i+R*s,H=N*r+R*s,D=N*i+R*l,F=N*r+R*l;return!(Math.max(O,H,D,F)<=N*c.x+R*c.y||Math.min(O,H,D,F)>=N*m.x+R*m.y)}pad(t=0,n=t){return this.x-=t,this.y-=n,this.width+=t*2,this.height+=n*2,this}fit(t){const n=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=n,this.width=Math.max(i-n,0),this.y=r,this.height=Math.max(s-r,0),this}ceil(t=1,n=.001){const i=Math.ceil((this.x+this.width-n)*t)/t,r=Math.ceil((this.y+this.height-n)*t)/t;return this.x=Math.floor((this.x+n)*t)/t,this.y=Math.floor((this.y+n)*t)/t,this.width=i-this.x,this.height=r-this.y,this}scale(t,n=t){return this.x*=t,this.y*=n,this.width*=t,this.height*=n,this}enlarge(t){const n=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=n,this.width=i-n,this.y=r,this.height=s-r,this}getBounds(t){return t||(t=new Ti),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const n=t.x,i=t.y,r=t.x+t.width,s=t.y+t.height;return n>=this.x&&n<this.x+this.width&&i>=this.y&&i<this.y+this.height&&r>=this.x&&r<this.x+this.width&&s>=this.y&&s<this.y+this.height}set(t,n,i,r){return this.x=t,this.y=n,this.width=i,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const bb={default:-1};function bi(e="default"){return bb[e]===void 0&&(bb[e]=-1),++bb[e]}const AE=new Set,xi="8.0.0",MD="8.3.4",$f={quiet:!1,noColor:!1},en=((e,t,n=3)=>{if($f.quiet||AE.has(t))return;let i=new Error().stack;const r=`${t}
|
|
62
62
|
Deprecated since v${e}`,s=typeof console.groupCollapsed=="function"&&!$f.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",r):(i=i.split(`
|
|
63
63
|
`).splice(n).join(`
|
|
64
64
|
`),s?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",r),console.warn(i))),AE.add(t)});Object.defineProperties(en,{quiet:{get:()=>$f.quiet,set:e=>{$f.quiet=e},enumerable:!0,configurable:!1},noColor:{get:()=>$f.noColor,set:e=>{$f.noColor=e},enumerable:!0,configurable:!1}});const tA=()=>{};function sh(e){return e+=e===0?1:0,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function ME(e){return!(e&e-1)&&!!e}function nA(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}const RE=Object.create(null);function RD(e){const t=RE[e];return t===void 0&&(RE[e]=bi("resource")),t}const iA=class rA extends yo{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...rA.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){en(xi,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=RD(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};iA.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let lh=iA;const aA=class sA extends yo{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=bi("textureSource"),this._resourceType="textureSource",this._resourceId=bi("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...sA.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new lh(nA(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var n,i;this.style!==t&&((n=this._style)==null||n.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,n;this._resourceId=bi("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(n=(t=this._gpuData[i])==null?void 0:t.destroy)==null||n.call(t);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,n,i){i||(i=this._resolution),t||(t=this.width),n||(n=this.height);const r=Math.round(t*i),s=Math.round(n*i);return this.width=r/i,this.height=s/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===s?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=s,this.emit("resize",this),this._resourceId=bi("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=ME(this.pixelWidth)&&ME(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};aA.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Is=aA;class J1 extends Is{constructor(t){const n=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(n instanceof Float32Array?i="rgba32float":n instanceof Int32Array||n instanceof Uint32Array?i="rgba32uint":n instanceof Int16Array||n instanceof Uint16Array?i="rgba16uint":(n instanceof Int8Array,i="bgra8unorm")),super({...t,resource:n,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}J1.extension=kt.TextureSource;const kE=new Ht;class kD{constructor(t,n){this.mapCoord=new Ht,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof n>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=n,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var n;this.texture!==t&&((n=this._texture)==null||n.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,n){n===void 0&&(n=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const s=t[r],l=t[r+1];n[r]=s*i.a+l*i.c+i.tx,n[r+1]=s*i.b+l*i.d+i.ty}return n}update(){const t=this._texture;this._updateID++;const n=t.uvs;this.mapCoord.set(n.x1-n.x0,n.y1-n.y0,n.x3-n.x0,n.y3-n.y0,n.x0,n.y0);const i=t.orig,r=t.trim;r&&(kE.set(i.width/r.width,0,0,i.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(kE));const s=t.source,l=this.uClampFrame,c=this.clampMargin/s._resolution,f=this.clampOffset/s._resolution;return l[0]=(t.frame.x+c+f)/s.width,l[1]=(t.frame.y+c+f)/s.height,l[2]=(t.frame.x+t.frame.width-c+f)/s.width,l[3]=(t.frame.y+t.frame.height-c+f)/s.height,this.uClampOffset[0]=this.clampOffset/s.pixelWidth,this.uClampOffset[1]=this.clampOffset/s.pixelHeight,this.isSimple=t.frame.width===s.width&&t.frame.height===s.height&&t.rotate===0,!0}}class Mn extends yo{constructor({source:t,label:n,frame:i,orig:r,trim:s,defaultAnchor:l,defaultBorders:c,rotate:f,dynamic:p}={}){if(super(),this.uid=bi("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Ti,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=n,this.source=(t==null?void 0:t.source)??new Is,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:m,height:g}=this._source;this.frame.width=m,this.frame.height=g}this.orig=r||this.frame,this.trim=s,this.rotate=f??0,this.defaultAnchor=l,this.defaultBorders=c,this.destroyed=!1,this.dynamic=p||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new kD(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:n}=this,{width:i,height:r}=this._source,s=n.x/i,l=n.y/r,c=n.width/i,f=n.height/r;let p=this.rotate;if(p){const m=c/2,g=f/2,x=s+m,v=l+g;p=Bn.add(p,Bn.NW),t.x0=x+m*Bn.uX(p),t.y0=v+g*Bn.uY(p),p=Bn.add(p,2),t.x1=x+m*Bn.uX(p),t.y1=v+g*Bn.uY(p),p=Bn.add(p,2),t.x2=x+m*Bn.uX(p),t.y2=v+g*Bn.uY(p),p=Bn.add(p,2),t.x3=x+m*Bn.uX(p),t.y3=v+g*Bn.uY(p)}else t.x0=s,t.y0=l,t.x1=s+c,t.y1=l,t.x2=s+c,t.y2=l+f,t.x3=s,t.y3=l+f}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return en(xi,"Texture.baseTexture is now Texture.source"),this._source}}Mn.EMPTY=new Mn({label:"EMPTY",source:new Is({label:"EMPTY"})});Mn.EMPTY.destroy=tA;Mn.WHITE=new Mn({source:new J1({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});Mn.WHITE.destroy=tA;function lA(e,t,n){const{width:i,height:r}=n.orig,s=n.trim;if(s){const l=s.width,c=s.height;e.minX=s.x-t._x*i,e.maxX=e.minX+l,e.minY=s.y-t._y*r,e.maxY=e.minY+c}else e.minX=-t._x*i,e.maxX=e.minX+i,e.minY=-t._y*r,e.maxY=e.minY+r}const NE=new Ht;class js{constructor(t=1/0,n=1/0,i=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=NE,this.minX=t,this.minY=n,this.maxX=i,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Ti);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=NE,this}set(t,n,i,r){this.minX=t,this.minY=n,this.maxX=i,this.maxY=r}addFrame(t,n,i,r,s){s||(s=this.matrix);const l=s.a,c=s.b,f=s.c,p=s.d,m=s.tx,g=s.ty;let x=this.minX,v=this.minY,S=this.maxX,A=this.maxY,T=l*t+f*n+m,C=c*t+p*n+g;T<x&&(x=T),C<v&&(v=C),T>S&&(S=T),C>A&&(A=C),T=l*i+f*n+m,C=c*i+p*n+g,T<x&&(x=T),C<v&&(v=C),T>S&&(S=T),C>A&&(A=C),T=l*t+f*r+m,C=c*t+p*r+g,T<x&&(x=T),C<v&&(v=C),T>S&&(S=T),C>A&&(A=C),T=l*i+f*r+m,C=c*i+p*r+g,T<x&&(x=T),C<v&&(v=C),T>S&&(S=T),C>A&&(A=C),this.minX=x,this.minY=v,this.maxX=S,this.maxY=A}addRect(t,n){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,n)}addBounds(t,n){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,n)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const n=this.minX,i=this.minY,r=this.maxX,s=this.maxY,{a:l,b:c,c:f,d:p,tx:m,ty:g}=t;let x=l*n+f*i+m,v=c*n+p*i+g;this.minX=x,this.minY=v,this.maxX=x,this.maxY=v,x=l*r+f*i+m,v=c*r+p*i+g,this.minX=x<this.minX?x:this.minX,this.minY=v<this.minY?v:this.minY,this.maxX=x>this.maxX?x:this.maxX,this.maxY=v>this.maxY?v:this.maxY,x=l*n+f*s+m,v=c*n+p*s+g,this.minX=x<this.minX?x:this.minX,this.minY=v<this.minY?v:this.minY,this.maxX=x>this.maxX?x:this.maxX,this.maxY=v>this.maxY?v:this.maxY,x=l*r+f*s+m,v=c*r+p*s+g,this.minX=x<this.minX?x:this.minX,this.minY=v<this.minY?v:this.minY,this.maxX=x>this.maxX?x:this.maxX,this.maxY=v>this.maxY?v:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,n,i,r){return this.minX<t&&(this.minX=t),this.maxX>n&&(this.maxX=n),this.minY<i&&(this.minY=i),this.maxY>r&&(this.maxY=r),this}pad(t,n=t){return this.minX-=t,this.maxX+=t,this.minY-=n,this.maxY+=n,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new js(this.minX,this.minY,this.maxX,this.maxY)}scale(t,n=t){return this.minX*=t,this.minY*=n,this.maxX*=t,this.maxY*=n,this}get x(){return this.minX}set x(t){const n=this.maxX-this.minX;this.minX=t,this.maxX=t+n}get y(){return this.minY}set y(t){const n=this.maxY-this.minY;this.minY=t,this.maxY=t+n}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,n,i,r){let s=this.minX,l=this.minY,c=this.maxX,f=this.maxY;r||(r=this.matrix);const p=r.a,m=r.b,g=r.c,x=r.d,v=r.tx,S=r.ty;for(let A=n;A<i;A+=2){const T=t[A],C=t[A+1],N=p*T+g*C+v,R=m*T+x*C+S;s=N<s?N:s,l=R<l?R:l,c=N>c?N:c,f=R>f?R:f}this.minX=s,this.minY=l,this.maxX=c,this.maxY=f}containsPoint(t,n){return this.minX<=t&&this.minY<=n&&this.maxX>=t&&this.maxY>=n}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var ND={grad:.9,turn:360,rad:360/(2*Math.PI)},Qo=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},ar=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},Bs=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},oA=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},OE=function(e){return{r:Bs(e.r,0,255),g:Bs(e.g,0,255),b:Bs(e.b,0,255),a:Bs(e.a)}},vb=function(e){return{r:ar(e.r),g:ar(e.g),b:ar(e.b),a:ar(e.a,3)}},OD=/^#([0-9a-f]{3,8})$/i,Dy=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},cA=function(e){var t=e.r,n=e.g,i=e.b,r=e.a,s=Math.max(t,n,i),l=s-Math.min(t,n,i),c=l?s===t?(n-i)/l:s===n?2+(i-t)/l:4+(t-n)/l:0;return{h:60*(c<0?c+6:c),s:s?l/s*100:0,v:s/255*100,a:r}},uA=function(e){var t=e.h,n=e.s,i=e.v,r=e.a;t=t/360*6,n/=100,i/=100;var s=Math.floor(t),l=i*(1-n),c=i*(1-(t-s)*n),f=i*(1-(1-t+s)*n),p=s%6;return{r:255*[i,c,l,l,f,i][p],g:255*[f,i,i,c,l,l][p],b:255*[l,l,f,i,i,c][p],a:r}},DE=function(e){return{h:oA(e.h),s:Bs(e.s,0,100),l:Bs(e.l,0,100),a:Bs(e.a)}},zE=function(e){return{h:ar(e.h),s:ar(e.s),l:ar(e.l),a:ar(e.a,3)}},BE=function(e){return uA((n=(t=e).s,{h:t.h,s:(n*=((i=t.l)<50?i:100-i)/100)>0?2*n/(i+n)*100:0,v:i+n,a:t.a}));var t,n,i},_m=function(e){return{h:(t=cA(e)).h,s:(r=(200-(n=t.s))*(i=t.v)/100)>0&&r<200?n*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,n,i,r},DD=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,zD=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,BD=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,LD=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Kv={string:[[function(e){var t=OD.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?ar(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?ar(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=BD.exec(e)||LD.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:OE({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=DD.exec(e)||zD.exec(e);if(!t)return null;var n,i,r=DE({h:(n=t[1],i=t[2],i===void 0&&(i="deg"),Number(n)*(ND[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return BE(r)},"hsl"]],object:[[function(e){var t=e.r,n=e.g,i=e.b,r=e.a,s=r===void 0?1:r;return Qo(t)&&Qo(n)&&Qo(i)?OE({r:Number(t),g:Number(n),b:Number(i),a:Number(s)}):null},"rgb"],[function(e){var t=e.h,n=e.s,i=e.l,r=e.a,s=r===void 0?1:r;if(!Qo(t)||!Qo(n)||!Qo(i))return null;var l=DE({h:Number(t),s:Number(n),l:Number(i),a:Number(s)});return BE(l)},"hsl"],[function(e){var t=e.h,n=e.s,i=e.v,r=e.a,s=r===void 0?1:r;if(!Qo(t)||!Qo(n)||!Qo(i))return null;var l=(function(c){return{h:oA(c.h),s:Bs(c.s,0,100),v:Bs(c.v,0,100),a:Bs(c.a)}})({h:Number(t),s:Number(n),v:Number(i),a:Number(s)});return uA(l)},"hsv"]]},LE=function(e,t){for(var n=0;n<t.length;n++){var i=t[n][0](e);if(i)return[i,t[n][1]]}return[null,void 0]},jD=function(e){return typeof e=="string"?LE(e.trim(),Kv.string):typeof e=="object"&&e!==null?LE(e,Kv.object):[null,void 0]},_b=function(e,t){var n=_m(e);return{h:n.h,s:Bs(n.s+100*t,0,100),l:n.l,a:n.a}},Sb=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},jE=function(e,t){var n=_m(e);return{h:n.h,s:n.s,l:Bs(n.l+100*t,0,100),a:n.a}},$v=(function(){function e(t){this.parsed=jD(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return ar(Sb(this.rgba),2)},e.prototype.isDark=function(){return Sb(this.rgba)<.5},e.prototype.isLight=function(){return Sb(this.rgba)>=.5},e.prototype.toHex=function(){return t=vb(this.rgba),n=t.r,i=t.g,r=t.b,l=(s=t.a)<1?Dy(ar(255*s)):"","#"+Dy(n)+Dy(i)+Dy(r)+l;var t,n,i,r,s,l},e.prototype.toRgb=function(){return vb(this.rgba)},e.prototype.toRgbString=function(){return t=vb(this.rgba),n=t.r,i=t.g,r=t.b,(s=t.a)<1?"rgba("+n+", "+i+", "+r+", "+s+")":"rgb("+n+", "+i+", "+r+")";var t,n,i,r,s},e.prototype.toHsl=function(){return zE(_m(this.rgba))},e.prototype.toHslString=function(){return t=zE(_m(this.rgba)),n=t.h,i=t.s,r=t.l,(s=t.a)<1?"hsla("+n+", "+i+"%, "+r+"%, "+s+")":"hsl("+n+", "+i+"%, "+r+"%)";var t,n,i,r,s},e.prototype.toHsv=function(){return t=cA(this.rgba),{h:ar(t.h),s:ar(t.s),v:ar(t.v),a:ar(t.a,3)};var t},e.prototype.invert=function(){return oo({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),oo(_b(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),oo(_b(this.rgba,-t))},e.prototype.grayscale=function(){return oo(_b(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),oo(jE(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),oo(jE(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?oo({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):ar(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=_m(this.rgba);return typeof t=="number"?oo({h:t,s:n.s,l:n.l,a:n.a}):ar(n.h)},e.prototype.isEqual=function(t){return this.toHex()===oo(t).toHex()},e})(),oo=function(e){return e instanceof $v?e:new $v(e)},IE=[],ID=function(e){e.forEach(function(t){IE.indexOf(t)<0&&(t($v,Kv),IE.push(t))})};function UD(e,t){var n={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in n)i[n[r]]=r;var s={};e.prototype.toName=function(l){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var c,f,p=i[this.toHex()];if(p)return p;if(l!=null&&l.closest){var m=this.toRgb(),g=1/0,x="black";if(!s.length)for(var v in n)s[v]=new e(n[v]).toRgb();for(var S in n){var A=(c=m,f=s[S],Math.pow(c.r-f.r,2)+Math.pow(c.g-f.g,2)+Math.pow(c.b-f.b,2));A<g&&(g=A,x=S)}return x}},t.string.push([function(l){var c=l.toLowerCase(),f=c==="transparent"?"#0000":n[c];return f?new e(f).toRgb():null},"name"])}ID([UD]);const oh=class hm{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof hm)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,n){const i=typeof t;if(i!==typeof n)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===n;if(Array.isArray(t)&&Array.isArray(n)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(n))return t.length!==n.length?!1:t.every((s,l)=>s===n[l]);if(t!==null&&n!==null){const s=Object.keys(t),l=Object.keys(n);return s.length!==l.length?!1:s.every(c=>t[c]===n[c])}return t===n}toRgba(){const[t,n,i,r]=this._components;return{r:t,g:n,b:i,a:r}}toRgb(){const[t,n,i]=this._components;return{r:t,g:n,b:i}}toRgbaString(){const[t,n,i]=this.toUint8RgbArray();return`rgba(${t},${n},${i},${this.alpha})`}toUint8RgbArray(t){const[n,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(n*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[n,i,r,s]=this._components;return t[0]=n,t[1]=i,t[2]=r,t[3]=s,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[n,i,r]=this._components;return t[0]=n,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,n,i]=this.toUint8RgbArray();return(i<<16)+(n<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[n,i,r,s]=hm._temp.setValue(t)._components;return this._components[0]*=n,this._components[1]*=i,this._components[2]*=r,this._components[3]*=s,this._refreshInt(),this._value=null,this}premultiply(t,n=!0){return n&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,n=!0){if(t===1)return(255<<24)+this._int;if(t===0)return n?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,s=this._int&255;return n&&(i=i*t+.5|0,r=r*t+.5|0,s=s*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+s}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const n=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-n.length)+n}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let n,i,r,s;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const l=t;n=(l>>16&255)/255,i=(l>>8&255)/255,r=(l&255)/255,s=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[n,i,r,s=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[n,i,r,s=255]=t,n/=255,i/=255,r/=255,s/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const c=hm.HEX_PATTERN.exec(t);c&&(t=`#${c[2]}`)}const l=oo(t);l.isValid()&&({r:n,g:i,b:r,a:s}=l.rgba,n/=255,i/=255,r/=255)}if(n!==void 0)this._components[0]=n,this._components[1]=i,this._components[2]=r,this._components[3]=s,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,n,i]=this._components;this._int=(t*255<<16)+(n*255<<8)+(i*255|0)}_clamp(t,n=0,i=1){return typeof t=="number"?Math.min(Math.max(t,n),i):(t.forEach((r,s)=>{t[s]=Math.min(Math.max(r,n),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof hm||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};oh.shared=new oh;oh._temp=new oh;oh.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let qi=oh;const HD={cullArea:null,cullable:!1,cullableChildren:!0};let Eb=0;const UE=500;function ma(...e){Eb!==UE&&(Eb++,Eb===UE?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...e))}const Qm={_registeredResources:new Set,register(e){this._registeredResources.add(e)},unregister(e){this._registeredResources.delete(e)},release(){this._registeredResources.forEach(e=>e.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(e){return this._registeredResources.has(e)},reset(){this._registeredResources.clear()}};class PD{constructor(t,n){this._pool=[],this._count=0,this._index=0,this._classType=t,n&&this.prepopulate(n)}prepopulate(t){for(let n=0;n<t;n++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var i;let n;return this._index>0?n=this._pool[--this._index]:(n=new this._classType,this._count++),(i=n.init)==null||i.call(n,t),n}return(t){var n;(n=t.reset)==null||n.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class FD{constructor(){this._poolsByClass=new Map}prepopulate(t,n){this.getPool(t).prepopulate(n)}get(t,n){return this.getPool(t).get(n)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new PD(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(n=>{const i=t[n._classType.name]?n._classType.name+n._classType.ID:n._classType.name;t[i]={free:n.totalFree,used:n.totalUsed,size:n.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const Da=new FD;Qm.register(Da);const GD={get isCachedAsTexture(){var e;return!!((e=this.renderGroup)!=null&&e.isCachedAsTexture)},cacheAsTexture(e){typeof e=="boolean"&&e===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(e===!0?{}:e))},updateCacheTexture(){var e;(e=this.renderGroup)==null||e.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(e){en("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(e)}};function qD(e,t,n){const i=e.length;let r;if(t>=i||n===0)return;n=t+n>i?i-t:n;const s=i-n;for(r=t;r<s;++r)e[r]=e[r+n];e.length=s}const YD={allowChildren:!0,removeChildren(e=0,t){var s;const n=t??this.children.length,i=n-e,r=[];if(i>0&&i<=n){for(let c=n-1;c>=e;c--){const f=this.children[c];f&&(r.push(f),f.parent=null)}qD(this.children,e,n);const l=this.renderGroup||this.parentRenderGroup;l&&l.removeChildren(r);for(let c=0;c<r.length;++c){const f=r[c];(s=f.parentRenderLayer)==null||s.detach(f),this.emit("childRemoved",f,this,c),r[c].emit("removed",this)}return r.length>0&&this._didViewChangeTick++,r}else if(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(e){const t=this.getChildAt(e);return this.removeChild(t)},getChildAt(e){if(e<0||e>=this.children.length)throw new Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]},setChildIndex(e,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(e),this.addChildAt(e,t)},getChildIndex(e){const t=this.children.indexOf(e);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(e,t){this.allowChildren||en(xi,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:n}=this;if(t<0||t>n.length)throw new Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${n.length}`);const i=e.parent===this;if(e.parent){const s=e.parent.children.indexOf(e);if(i){if(s===t)return e;e.parent.children.splice(s,1)}else e.removeFromParent()}t===n.length?n.push(e):n.splice(t,0,e),e.parent=this,e.didChange=!0,e._updateFlags=15;const r=this.renderGroup||this.parentRenderGroup;return r&&r.addChild(e),this.sortableChildren&&(this.sortDirty=!0),i||(this.emit("childAdded",e,this,t),e.emit("added",this)),e},swapChildren(e,t){if(e===t)return;const n=this.getChildIndex(e),i=this.getChildIndex(t);this.children[n]=t,this.children[i]=e;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var e;(e=this.parent)==null||e.removeChild(this)},reparentChild(...e){return e.length===1?this.reparentChildAt(e[0],this.children.length):(e.forEach(t=>this.reparentChildAt(t,this.children.length)),e[0])},reparentChildAt(e,t){if(e.parent===this)return this.setChildIndex(e,t),e;const n=e.worldTransform.clone();e.removeFromParent(),this.addChildAt(e,t);const i=this.worldTransform.clone();return i.invert(),n.prepend(i),e.setFromMatrix(n),e},replaceChild(e,t){e.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(e)),t.setFromMatrix(e.localTransform),t.updateLocalTransform(),this.removeChild(e)}},VD={collectRenderables(e,t,n){this.parentRenderLayer&&this.parentRenderLayer!==n||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(e,t,n):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,e):this.collectRenderablesWithEffects(e,t,n))},collectRenderablesSimple(e,t,n){const i=this.children,r=i.length;for(let s=0;s<r;s++)i[s].collectRenderables(e,t,n)},collectRenderablesWithEffects(e,t,n){const{renderPipes:i}=t;for(let r=0;r<this.effects.length;r++){const s=this.effects[r];i[s.pipe].push(s,this,e)}this.collectRenderablesSimple(e,t,n);for(let r=this.effects.length-1;r>=0;r--){const s=this.effects[r];i[s.pipe].pop(s,this,e)}}};class HE{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class XD{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let n=0;n<this._tests.length;n++){const i=this._tests[n];if(i.test(t))return Da.get(i.maskClass,t)}return t}returnMaskEffect(t){Da.return(t)}}const Wv=new XD;li.handleByList(kt.MaskEffect,Wv._effectClasses);const KD={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0)},addEffect(e){this.effects.indexOf(e)===-1&&(this.effects.push(e),this.effects.sort((n,i)=>n.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(e){const t=this.effects.indexOf(e);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(e){const t=this._maskEffect;(t==null?void 0:t.mask)!==e&&(t&&(this.removeEffect(t),Wv.returnMaskEffect(t),this._maskEffect=null),e!=null&&(this._maskEffect=Wv.getMaskEffect(e),this.addEffect(this._maskEffect)))},get mask(){var e;return(e=this._maskEffect)==null?void 0:e.mask},setMask(e){this._maskOptions={...this._maskOptions,...e},e.mask&&(this.mask=e.mask),this._markStructureAsChanged()},set filters(e){var s;!Array.isArray(e)&&e&&(e=[e]);const t=this._filterEffect||(this._filterEffect=new HE);e=e;const n=(e==null?void 0:e.length)>0,i=((s=t.filters)==null?void 0:s.length)>0,r=n!==i;e=Array.isArray(e)?e.slice(0):e,t.filters=Object.freeze(e),r&&(n?this.addEffect(t):(this.removeEffect(t),t.filters=e??null))},get filters(){var e;return(e=this._filterEffect)==null?void 0:e.filters},set filterArea(e){this._filterEffect||(this._filterEffect=new HE),this._filterEffect.filterArea=e},get filterArea(){var e;return(e=this._filterEffect)==null?void 0:e.filterArea}},$D={label:null,get name(){return en(xi,"Container.name property has been removed, use Container.label instead"),this.label},set name(e){en(xi,"Container.name property has been removed, use Container.label instead"),this.label=e},getChildByName(e,t=!1){return this.getChildByLabel(e,t)},getChildByLabel(e,t=!1){const n=this.children;for(let i=0;i<n.length;i++){const r=n[i];if(r.label===e||e instanceof RegExp&&e.test(r.label))return r}if(t)for(let i=0;i<n.length;i++){const s=n[i].getChildByLabel(e,!0);if(s)return s}return null},getChildrenByLabel(e,t=!1,n=[]){const i=this.children;for(let r=0;r<i.length;r++){const s=i[r];(s.label===e||e instanceof RegExp&&e.test(s.label))&&n.push(s)}if(t)for(let r=0;r<i.length;r++)i[r].getChildrenByLabel(e,!0,n);return n}},pa=Da.getPool(Ht),rc=Da.getPool(js),WD=new Ht,QD={getFastGlobalBounds(e,t){t||(t=new js),t.clear(),this._getGlobalBoundsRecursive(!!e,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const n=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(n.worldTransform),t},_getGlobalBoundsRecursive(e,t,n){let i=t;if(e&&this.parentRenderLayer&&this.parentRenderLayer!==n||this.localDisplayStatus!==7||!this.measurable)return;const r=!!this.effects.length;if((this.renderGroup||r)&&(i=rc.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const l=this.bounds;i.addFrame(l.minX,l.minY,l.maxX,l.maxY,this.groupTransform)}const s=this.children;for(let l=0;l<s.length;l++)s[l]._getGlobalBoundsRecursive(e,i,n)}if(r){let s=!1;const l=this.renderGroup||this.parentRenderGroup;for(let c=0;c<this.effects.length;c++)this.effects[c].addBounds&&(s||(s=!0,i.applyMatrix(l.worldTransform)),this.effects[c].addBounds(i,!0));s&&i.applyMatrix(l.worldTransform.copyTo(WD).invert()),t.addBounds(i),rc.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),rc.return(i))}};function dA(e,t,n){n.clear();let i,r;return e.parent?t?i=e.parent.worldTransform:(r=pa.get().identity(),i=e_(e,r)):i=Ht.IDENTITY,fA(e,n,i,t),r&&pa.return(r),n.isValid||n.set(0,0,0,0),n}function fA(e,t,n,i){var c,f;if(!e.visible||!e.measurable)return;let r;i?r=e.worldTransform:(e.updateLocalTransform(),r=pa.get(),r.appendFrom(e.localTransform,n));const s=t,l=!!e.effects.length;if(l&&(t=rc.get().clear()),e.boundsArea)t.addRect(e.boundsArea,r);else{const p=e.bounds;p&&!p.isEmpty()&&(t.matrix=r,t.addBounds(p));for(let m=0;m<e.children.length;m++)fA(e.children[m],t,r,i)}if(l){for(let p=0;p<e.effects.length;p++)(f=(c=e.effects[p]).addBounds)==null||f.call(c,t);s.addBounds(t,Ht.IDENTITY),rc.return(t)}i||pa.return(r)}function e_(e,t){const n=e.parent;return n&&(e_(n,t),n.updateLocalTransform(),t.append(n.localTransform)),t}function hA(e,t){if(e===16777215||!t)return t;if(t===16777215||!e)return e;const n=e>>16&255,i=e>>8&255,r=e&255,s=t>>16&255,l=t>>8&255,c=t&255,f=n*s/255|0,p=i*l/255|0,m=r*c/255|0;return(f<<16)+(p<<8)+m}const PE=16777215;function FE(e,t){return e===PE?t:t===PE?e:hA(e,t)}function g0(e){return((e&255)<<16)+(e&65280)+(e>>16&255)}const ZD={getGlobalAlpha(e){if(e)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,n=this.parent;for(;n;)t*=n.alpha,n=n.parent;return t},getGlobalTransform(e=new Ht,t){if(t)return e.copyFrom(this.worldTransform);this.updateLocalTransform();const n=e_(this,pa.get().identity());return e.appendFrom(this.localTransform,n),pa.return(n),e},getGlobalTint(e){if(e)return this.renderGroup?g0(this.renderGroup.worldColor):this.parentRenderGroup?g0(FE(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,n=this.parent;for(;n;)t=FE(t,n.localColor),n=n.parent;return g0(t)}};function pA(e,t,n){return t.clear(),n||(n=Ht.IDENTITY),mA(e,t,n,e,!0),t.isValid||t.set(0,0,0,0),t}function mA(e,t,n,i,r){var f,p;let s;if(r)s=pa.get(),s=n.copyTo(s);else{if(!e.visible||!e.measurable)return;e.updateLocalTransform();const m=e.localTransform;s=pa.get(),s.appendFrom(m,n)}const l=t,c=!!e.effects.length;if(c&&(t=rc.get().clear()),e.boundsArea)t.addRect(e.boundsArea,s);else{e.renderPipeId&&(t.matrix=s,t.addBounds(e.bounds));const m=e.children;for(let g=0;g<m.length;g++)mA(m[g],t,s,i,!1)}if(c){for(let m=0;m<e.effects.length;m++)(p=(f=e.effects[m]).addLocalBounds)==null||p.call(f,t,i);l.addBounds(t,Ht.IDENTITY),rc.return(t)}pa.return(s)}function gA(e,t){const n=e.children;for(let i=0;i<n.length;i++){const r=n[i],s=r.uid,l=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,c=t.index;(t.data[c]!==s||t.data[c+1]!==l)&&(t.data[t.index]=s,t.data[t.index+1]=l,t.didChange=!0),t.index=c+2,r.children.length&&gA(r,t)}return t.didChange}const JD=new Ht,ez={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(e,t){const n=Math.sign(this.scale.x)||1;t!==0?this.scale.x=e/t*n:this.scale.x=n},_setHeight(e,t){const n=Math.sign(this.scale.y)||1;t!==0?this.scale.y=e/t*n:this.scale.y=n},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new js});const e=this._localBoundsCacheData;return e.index=1,e.didChange=!1,e.data[0]!==this._didViewChangeTick&&(e.didChange=!0,e.data[0]=this._didViewChangeTick),gA(this,e),e.didChange&&pA(this,e.localBounds,JD),e.localBounds},getBounds(e,t){return dA(this,e,t||new js)}},tz={_onRender:null,set onRender(e){const t=this.renderGroup||this.parentRenderGroup;if(!e){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=e},get onRender(){return this._onRender}},nz={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(e){this._zIndex!==e&&(this._zIndex=e,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(iz))}};function iz(e,t){return e._zIndex-t._zIndex}const rz={getGlobalPosition(e=new Lr,t=!1){return this.parent?this.parent.toGlobal(this._position,e,t):(e.x=this._position.x,e.y=this._position.y),e},toGlobal(e,t,n=!1){const i=this.getGlobalTransform(pa.get(),n);return t=i.apply(e,t),pa.return(i),t},toLocal(e,t,n,i){t&&(e=t.toGlobal(e,n,i));const r=this.getGlobalTransform(pa.get(),i);return n=r.applyInverse(e,n),pa.return(r),n}};class t_{constructor(){this.uid=bi("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let az=0;class sz{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new lh(this.textureOptions)}createTexture(t,n,i,r){const s=new Is({...this.textureOptions,width:t,height:n,resolution:1,antialias:i,autoGarbageCollect:!1,autoGenerateMipmaps:r});return new Mn({source:s,label:`texturePool_${az++}`})}getOptimalTexture(t,n,i=1,r,s=!1){let l=Math.ceil(t*i-1e-6),c=Math.ceil(n*i-1e-6);l=sh(l),c=sh(c);const f=r?1:0,p=s?1:0,m=(l<<17)+(c<<2)+(p<<1)+f;this._texturePool[m]||(this._texturePool[m]=[]);let g=this._texturePool[m].pop();return g||(g=this.createTexture(l,c,r,s)),g.source._resolution=i,g.source.width=l/i,g.source.height=c/i,g.source.pixelWidth=l,g.source.pixelHeight=c,g.frame.x=0,g.frame.y=0,g.frame.width=t,g.frame.height=n,g.updateUvs(),this._poolKeyHash[g.uid]=m,g}getSameSizeTexture(t,n=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,n)}returnTexture(t,n=!1){const i=this._poolKeyHash[t.uid];n&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=t!==!1,t)for(const n in this._texturePool){const i=this._texturePool[n];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this._texturePool={}}}const ex=new sz;Qm.register(ex);class lz{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new Ht,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new t_,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const n=t.children;for(let i=0;i<n.length;i++){const r=n[i];r._updateFlags=15,this.addChild(r)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(ex.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const n=this.childrenToUpdate[t];n.list.fill(null),n.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const n=this.renderGroupChildren.indexOf(t);n>-1&&this.renderGroupChildren.splice(n,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const n=t.children;for(let i=0;i<n.length;i++)this.addChild(n[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const n=t.children;for(let i=0;i<n.length;i++)this.removeChild(n[i])}removeChildren(t){for(let n=0;n<t.length;n++)this.removeChild(t[n])}onChildUpdate(t){let n=this.childrenToUpdate[t.relativeRenderGroupDepth];n||(n=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),n.list[n.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let n=0;n<this._onRenderContainers.length;n++)this._onRenderContainers[n]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const n=this.root.children;for(let i=0;i<n.length;i++)this._getChildren(n[i],t);return t}_getChildren(t,n=[]){if(n.push(t),t.renderGroup)return n;const i=t.children;for(let r=0;r<i.length;r++)this._getChildren(i[r],n);return n}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new Ht),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new Ht),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new Ht),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function oz(e,t,n={}){for(const i in t)!n[i]&&t[i]!==void 0&&(e[i]=t[i])}const wb=new br(null),zy=new br(null),Tb=new br(null,1,1),By=new br(null),GE=1,cz=2,Cb=4;class _r extends yo{constructor(t={}){var n,i;super(),this.uid=bi("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new Ht,this.relativeGroupTransform=new Ht,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new br(this,0,0),this._scale=Tb,this._pivot=zy,this._origin=By,this._skew=wb,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],oz(this,t,{children:!0,parent:!0,effects:!0}),(n=t.children)==null||n.forEach(r=>this.addChild(r)),(i=t.parent)==null||i.addChild(this)}static mixin(t){en("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),li.mixin(_r,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||en(xi,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r<t.length;r++)this.addChild(t[r]);return t[0]}const n=t[0],i=this.renderGroup||this.parentRenderGroup;return n.parent===this?(this.children.splice(this.children.indexOf(n),1),this.children.push(n),i&&(i.structureDidChange=!0),n):(n.parent&&n.parent.removeChild(n),this.children.push(n),this.sortableChildren&&(this.sortDirty=!0),n.parent=this,n.didChange=!0,n._updateFlags=15,i&&i.addChild(n),this.emit("childAdded",n,this,this.children.length-1),n.emit("added",this),this._didViewChangeTick++,n._zIndex!==0&&n.depthOfChildModified(),n)}removeChild(...t){if(t.length>1){for(let r=0;r<t.length;r++)this.removeChild(t[r]);return t[0]}const n=t[0],i=this.children.indexOf(n);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(n):this.parentRenderGroup&&this.parentRenderGroup.removeChild(n),n.parentRenderLayer&&n.parentRenderLayer.detach(n),n.parent=null,this.emit("childRemoved",n,this,i),n.emit("removed",this)),n}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=Da.get(lz,this),this.groupTransform=Ht.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Da.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new Ht),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*ED}set angle(t){this.rotation=t*wD}get pivot(){return this._pivot===zy&&(this._pivot=new br(this,0,0)),this._pivot}set pivot(t){this._pivot===zy&&(this._pivot=new br(this,0,0),this._origin!==By&&ma("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===wb&&(this._skew=new br(this,0,0)),this._skew}set skew(t){this._skew===wb&&(this._skew=new br(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Tb&&(this._scale=new br(this,1,1)),this._scale}set scale(t){this._scale===Tb&&(this._scale=new br(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===By&&(this._origin=new br(this,0,0)),this._origin}set origin(t){this._origin===By&&(this._origin=new br(this,0,0),this._pivot!==zy&&ma("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const n=this.getLocalBounds().width;this._setWidth(t,n)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const n=this.getLocalBounds().height;this._setHeight(t,n)}getSize(t){t||(t={});const n=this.getLocalBounds();return t.width=Math.abs(this.scale.x*n.width),t.height=Math.abs(this.scale.y*n.height),t}setSize(t,n){const i=this.getLocalBounds();typeof t=="object"?(n=t.height??t.width,t=t.width):n??(n=t),t!==void 0&&this._setWidth(t,i.width),n!==void 0&&this._setHeight(n,i.height)}_updateSkew(){const t=this._rotation,n=this._skew;this._cx=Math.cos(t+n._y),this._sx=Math.sin(t+n._y),this._cy=-Math.sin(t-n._x),this._sy=Math.cos(t-n._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const n=this.localTransform,i=this._scale,r=this._pivot,s=this._origin,l=this._position,c=i._x,f=i._y,p=r._x,m=r._y,g=-s._x,x=-s._y;n.a=this._cx*c,n.b=this._sx*c,n.c=this._cy*f,n.d=this._sy*f,n.tx=l._x-(p*n.a+m*n.c)+(g*n.a+x*n.c)-g,n.ty=l._y-(p*n.b+m*n.d)+(g*n.b+x*n.d)-x}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=GE,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=qi.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=GE,this._onUpdate())}get tint(){return g0(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=cz,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const n=t?2:0;(this.localDisplayStatus&2)!==n&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Cb,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const n=t?0:4;(this.localDisplayStatus&4)!==n&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Cb,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const n=t?1:0;(this.localDisplayStatus&1)!==n&&(this._updateFlags|=Cb,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var r;if(this.destroyed)return;this.destroyed=!0;let n;if(this.children.length&&(n=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&n)for(let s=0;s<n.length;++s)n[s].destroy(t);(r=this.renderGroup)==null||r.destroy(),this.renderGroup=null}}li.mixin(_r,YD,QD,rz,tz,ez,KD,$D,nz,HD,GD,ZD,VD);class n_ extends _r{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new js(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=t.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const n=this.bounds,{x:i,y:r}=t;return i>=n.minX&&i<=n.maxX&&r>=n.minY&&r<=n.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){var t;this.emit("unload",this);for(const n in this._gpuData)(t=this._gpuData[n])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,n,i){const{renderPipes:r}=n;r.blendMode.pushBlendMode(this,this.groupBlendMode,t);const l=r[this.renderPipeId];l!=null&&l.addRenderable&&l.addRenderable(this,t),this.didViewUpdate=!1;const c=this.children,f=c.length;for(let p=0;p<f;p++)c[p].collectRenderables(t,n,i);r.blendMode.popBlendMode(t)}}class ch extends n_{constructor(t=Mn.EMPTY){t instanceof Mn&&(t={texture:t});const{texture:n=Mn.EMPTY,anchor:i,roundPixels:r,width:s,height:l,...c}=t;super({label:"Sprite",...c}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new br({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:n.defaultAnchor&&(this.anchor=n.defaultAnchor),this.texture=n,this.allowChildren=!1,this.roundPixels=r??!1,s!==void 0&&(this.width=s),l!==void 0&&(this.height=l)}static from(t,n=!1){return t instanceof Mn?new ch(t):new ch(Mn.from(t,n))}set texture(t){t||(t=Mn.EMPTY);const n=this._texture;n!==t&&(n&&n.dynamic&&n.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return lA(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return en("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,n=this._texture,i=this._bounds,{width:r,height:s}=n.orig;i.minX=-t._x*r,i.maxX=i.minX+r,i.minY=-t._y*s,i.maxY=i.minY+s}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,n){typeof t=="object"?(n=t.height??t.width,t=t.width):n??(n=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),n!==void 0&&this._setHeight(n,this._texture.orig.height)}}const uz=new js;function yA(e,t,n){const i=uz;e.measurable=!0,dA(e,n,i),t.addBoundsMask(i),e.measurable=!1}function xA(e,t,n){const i=rc.get();e.measurable=!0;const r=pa.get().identity(),s=bA(e,n,r);pA(e,i,s),e.measurable=!1,t.addBoundsMask(i),pa.return(r),rc.return(i)}function bA(e,t,n){return e?(e!==t&&(bA(e.parent,t,n),e.updateLocalTransform(),n.append(e.localTransform)),n):(ma("Mask bounds, renderable is not inside the root container"),n)}class vA{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof ch),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,n){this.inverse||yA(this.mask,t,n)}addLocalBounds(t,n){xA(this.mask,t,n)}containsPoint(t,n){const i=this.mask;return n(i,t)}destroy(){this.reset()}static test(t){return t instanceof ch}}vA.extension=kt.MaskEffect;class _A{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}_A.extension=kt.MaskEffect;class SA{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,n){yA(this.mask,t,n)}addLocalBounds(t,n){xA(this.mask,t,n)}containsPoint(t,n){const i=this.mask;return n(i,t)}destroy(){this.reset()}static test(t){return t instanceof _r}}SA.extension=kt.MaskEffect;const dz={createCanvas:(e,t)=>{const n=document.createElement("canvas");return n.width=e,n.height=t,n},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(e,t)=>fetch(e,t),parseXML:e=>new DOMParser().parseFromString(e,"text/xml")};let qE=dz;const is={get(){return qE},set(e){qE=e}};class EA extends Is{constructor(t){t.resource||(t.resource=is.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,n=this.height,i=this._resolution){const r=super.resize(t,n,i);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}EA.extension=kt.TextureSource;class A0 extends Is{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}A0.extension=kt.TextureSource;var M0=(e=>(e[e.INTERACTION=50]="INTERACTION",e[e.HIGH=25]="HIGH",e[e.NORMAL=0]="NORMAL",e[e.LOW=-25]="LOW",e[e.UTILITY=-50]="UTILITY",e))(M0||{});class Ab{constructor(t,n=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=n,this.priority=i,this._once=r}match(t,n=null){return this._fn===t&&this._context===n}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const n=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),n}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const n=this.next;return this.next=t?null:n,this.previous=null,n}}const wA=class Ja{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Ab(null,null,1/0),this.deltaMS=1/Ja.targetFPMS,this.elapsedMS=1/Ja.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,n,i=M0.NORMAL){return this._addListener(new Ab(t,n,i))}addOnce(t,n,i=M0.NORMAL){return this._addListener(new Ab(t,n,i,!0))}_addListener(t){let n=this._head.next,i=this._head;if(!n)t.connect(i);else{for(;n;){if(t.priority>n.priority){t.connect(i);break}i=n,n=n.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,n){let i=this._head.next;for(;i;)i.match(t,n)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,n=this._head;for(;n=n.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let n;if(t>this.lastTime){if(n=this.elapsedMS=t-this.lastTime,n>this._maxElapsedMS&&(n=this._maxElapsedMS),n*=this.speed,this._minElapsedMS){const s=t-this._lastFrame|0;if(s<this._minElapsedMS)return;this._lastFrame=t-s%this._minElapsedMS}this.deltaMS=n,this.deltaTime=this.deltaMS*Ja.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const n=Math.min(Math.max(0,t)/1e3,Ja.targetFPMS);this._maxElapsedMS=1/n,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t<this.minFPS&&(this.minFPS=t),this._minElapsedMS=1/(t/1e3))}static get shared(){if(!Ja._shared){const t=Ja._shared=new Ja;t.autoStart=!0,t._protected=!0}return Ja._shared}static get system(){if(!Ja._system){const t=Ja._system=new Ja;t.autoStart=!0,t._protected=!0}return Ja._system}};wA.targetFPMS=.06;let Wf=wA,Mb;async function fz(){return Mb??(Mb=(async()=>{var l;const t=is.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const n=await new Promise(c=>{const f=document.createElement("video");f.onloadeddata=()=>c(f),f.onerror=()=>c(null),f.autoplay=!1,f.crossOrigin="anonymous",f.preload="auto",f.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",f.load()});if(!n)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n);const s=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,s),t.deleteFramebuffer(r),t.deleteTexture(i),(l=t.getExtension("WEBGL_lose_context"))==null||l.loseContext(),s[0]<=s[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Mb}const tx=class TA extends Is{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...TA.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Wf.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,n=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(n.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await fz(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,n.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${n.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Wf.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Wf.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Wf.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};tx.extension=kt.TextureSource;tx.defaultOptions={...Is.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};tx.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let hz=tx;const Gf=(e,t,n=!1)=>(Array.isArray(e)||(e=[e]),t?e.map(i=>typeof i=="string"||n?t(i):i):e);class pz{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const n=this._cache.get(t);return n||ma(`[Assets] Asset id ${t} was not found in the Cache`),n}set(t,n){const i=Gf(t);let r;for(let f=0;f<this.parsers.length;f++){const p=this.parsers[f];if(p.test(n)){r=p.getCacheableAssets(i,n);break}}const s=new Map(Object.entries(r||{}));r||i.forEach(f=>{s.set(f,n)});const l=[...s.keys()],c={cacheKeys:l,keys:i};i.forEach(f=>{this._cacheMap.set(f,c)}),l.forEach(f=>{const p=r?r[f]:n;this._cache.has(f)&&this._cache.get(f)!==p&&ma("[Cache] already has key:",f),this._cache.set(f,s.get(f))})}remove(t){if(!this._cacheMap.has(t)){ma(`[Assets] Asset id ${t} was not found in the Cache`);return}const n=this._cacheMap.get(t);n.cacheKeys.forEach(r=>{this._cache.delete(r)}),n.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const qf=new pz,Qv=[];li.handleByList(kt.TextureSource,Qv);function CA(e={}){const t=e&&e.resource,n=t?e.resource:e,i=t?e:{resource:e};for(let r=0;r<Qv.length;r++){const s=Qv[r];if(s.test(n))return new s(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function mz(e={},t=!1){const n=e&&e.resource,i=n?e.resource:e,r=n?e:{resource:e};if(!t&&qf.has(i))return qf.get(i);const s=new Mn({source:CA(r)});return s.on("destroy",()=>{qf.has(i)&&qf.remove(i)}),t||qf.set(i,s),s}function gz(e,t=!1){return typeof e=="string"?qf.get(e):e instanceof Is?new Mn({source:e}):mz(e,t)}Mn.from=gz;Is.from=CA;li.add(vA,_A,SA,hz,A0,EA,J1);var AA=(e=>(e[e.Low=0]="Low",e[e.Normal=1]="Normal",e[e.High=2]="High",e))(AA||{});function dl(e){if(typeof e!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(e)}`)}function Wp(e){return e.split("?")[0].split("#")[0]}function yz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xz(e,t,n){return e.replace(new RegExp(yz(t),"g"),n)}function bz(e,t){let n="",i=0,r=-1,s=0,l=-1;for(let c=0;c<=e.length;++c){if(c<e.length)l=e.charCodeAt(c);else{if(l===47)break;l=47}if(l===47){if(!(r===c-1||s===1))if(r!==c-1&&s===2){if(n.length<2||i!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){const f=n.lastIndexOf("/");if(f!==n.length-1){f===-1?(n="",i=0):(n=n.slice(0,f),i=n.length-1-n.lastIndexOf("/")),r=c,s=0;continue}}else if(n.length===2||n.length===1){n="",i=0,r=c,s=0;continue}}}else n.length>0?n+=`/${e.slice(r+1,c)}`:n=e.slice(r+1,c),i=c-r-1;r=c,s=0}else l===46&&s!==-1?++s:s=-1}return n}const Nm={toPosix(e){return xz(e,"\\","/")},isUrl(e){return/^https?:/.test(this.toPosix(e))},isDataUrl(e){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(e)},isBlobUrl(e){return e.startsWith("blob:")},hasProtocol(e){return/^[^/:]+:/.test(this.toPosix(e))},getProtocol(e){dl(e),e=this.toPosix(e);const t=/^file:\/\/\//.exec(e);if(t)return t[0];const n=/^[^/:]+:\/{0,2}/.exec(e);return n?n[0]:""},toAbsolute(e,t,n){if(dl(e),this.isDataUrl(e)||this.isBlobUrl(e))return e;const i=Wp(this.toPosix(t??is.get().getBaseUrl())),r=Wp(this.toPosix(n??this.rootname(i)));return e=this.toPosix(e),e.startsWith("/")?Nm.join(r,e.slice(1)):this.isAbsolute(e)?e:this.join(i,e)},normalize(e){if(dl(e),e.length===0)return".";if(this.isDataUrl(e)||this.isBlobUrl(e))return e;e=this.toPosix(e);let t="";const n=e.startsWith("/");this.hasProtocol(e)&&(t=this.rootname(e),e=e.slice(t.length));const i=e.endsWith("/");return e=bz(e),e.length>0&&i&&(e+="/"),n?`/${e}`:t+e},isAbsolute(e){return dl(e),e=this.toPosix(e),this.hasProtocol(e)?!0:e.startsWith("/")},join(...e){if(e.length===0)return".";let t;for(let n=0;n<e.length;++n){const i=e[n];if(dl(i),i.length>0)if(t===void 0)t=i;else{const r=e[n-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(e){if(dl(e),e.length===0)return".";e=this.toPosix(e);let t=e.charCodeAt(0);const n=t===47;let i=-1,r=!0;const s=this.getProtocol(e),l=e;e=e.slice(s.length);for(let c=e.length-1;c>=1;--c)if(t=e.charCodeAt(c),t===47){if(!r){i=c;break}}else r=!1;return i===-1?n?"/":this.isUrl(l)?s+e:s:n&&i===1?"//":s+e.slice(0,i)},rootname(e){dl(e),e=this.toPosix(e);let t="";if(e.startsWith("/")?t="/":t=this.getProtocol(e),this.isUrl(e)){const n=e.indexOf("/",t.length);n!==-1?t=e.slice(0,n):t=e,t.endsWith("/")||(t+="/")}return t},basename(e,t){dl(e),t&&dl(t),e=Wp(this.toPosix(e));let n=0,i=-1,r=!0,s;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let l=t.length-1,c=-1;for(s=e.length-1;s>=0;--s){const f=e.charCodeAt(s);if(f===47){if(!r){n=s+1;break}}else c===-1&&(r=!1,c=s+1),l>=0&&(f===t.charCodeAt(l)?--l===-1&&(i=s):(l=-1,i=c))}return n===i?i=c:i===-1&&(i=e.length),e.slice(n,i)}for(s=e.length-1;s>=0;--s)if(e.charCodeAt(s)===47){if(!r){n=s+1;break}}else i===-1&&(r=!1,i=s+1);return i===-1?"":e.slice(n,i)},extname(e){dl(e),e=Wp(this.toPosix(e));let t=-1,n=0,i=-1,r=!0,s=0;for(let l=e.length-1;l>=0;--l){const c=e.charCodeAt(l);if(c===47){if(!r){n=l+1;break}continue}i===-1&&(r=!1,i=l+1),c===46?t===-1?t=l:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||i===-1||s===0||s===1&&t===i-1&&t===n+1?"":e.slice(t,i)},parse(e){dl(e);const t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;e=Wp(this.toPosix(e));let n=e.charCodeAt(0);const i=this.isAbsolute(e);let r;t.root=this.rootname(e),i||this.hasProtocol(e)?r=1:r=0;let s=-1,l=0,c=-1,f=!0,p=e.length-1,m=0;for(;p>=r;--p){if(n=e.charCodeAt(p),n===47){if(!f){l=p+1;break}continue}c===-1&&(f=!1,c=p+1),n===46?s===-1?s=p:m!==1&&(m=1):s!==-1&&(m=-1)}return s===-1||c===-1||m===0||m===1&&s===c-1&&s===l+1?c!==-1&&(l===0&&i?t.base=t.name=e.slice(1,c):t.base=t.name=e.slice(l,c)):(l===0&&i?(t.name=e.slice(1,s),t.base=e.slice(1,c)):(t.name=e.slice(l,s),t.base=e.slice(l,c)),t.ext=e.slice(s,c)),t.dir=this.dirname(e),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function MA(e,t,n,i,r){const s=t[n];for(let l=0;l<s.length;l++){const c=s[l];n<t.length-1?MA(e.replace(i[n],c),t,n+1,i,r):r.push(e.replace(i[n],c))}}function vz(e){const t=/\{(.*?)\}/g,n=e.match(t),i=[];if(n){const r=[];n.forEach(s=>{const l=s.substring(1,s.length-1).split(",");r.push(l)}),MA(e,r,0,n,i)}else i.push(e);return i}const YE=e=>!Array.isArray(e);class RA{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,n)=>`${t}${this._bundleIdConnector}${n}`,extractAssetIdFromBundle:(t,n)=>n.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(n=>{this._preferredOrder.push(n),n.priority||(n.priority=Object.keys(n.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const n=t;this._defaultSearchParams=Object.keys(n).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(n[i])}`).join("&")}}getAlias(t){const{alias:n,src:i}=t;return Gf(n||i,s=>typeof s=="string"?s:Array.isArray(s)?s.map(l=>(l==null?void 0:l.src)??l):s!=null&&s.src?s.src:s,!0)}removeAlias(t,n){this._assetMap[t]&&(n&&n!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest&&ma("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(n=>{this.addBundle(n.name,n.assets)})}addBundle(t,n){const i=[];let r=n;Array.isArray(n)||(r=Object.entries(n).map(([s,l])=>typeof l=="string"||Array.isArray(l)?{alias:s,src:l}:{alias:s,...l})),r.forEach(s=>{const l=s.src,c=s.alias;let f;if(typeof c=="string"){const p=this._createBundleAssetId(t,c);i.push(p),f=[c,p]}else{const p=c.map(m=>this._createBundleAssetId(t,m));i.push(...p),f=[...c,...p]}this.add({...s,alias:f,src:l})}),this._bundles[t]=i}add(t){const n=[];Array.isArray(t)?n.push(...t):n.push(t);let i;i=s=>{this.hasKey(s)&&ma(`[Resolver] already has key: ${s} overwriting`)},Gf(n).forEach(s=>{const{src:l}=s;let{data:c,format:f,loadParser:p,parser:m}=s;const g=Gf(l).map(A=>typeof A=="string"?vz(A):Array.isArray(A)?A:[A]),x=this.getAlias(s);Array.isArray(x)?x.forEach(i):i(x);const v=[],S=A=>{const T=this._parsers.find(C=>C.test(A));return{src:A,...T==null?void 0:T.parse(A)}};g.forEach(A=>{A.forEach(T=>{let C={};if(typeof T!="object"?C=S(T):(c=T.data??c,f=T.format??f,(T.loadParser||T.parser)&&(p=T.loadParser??p,m=T.parser??m),C={...S(T.src),...T}),!x)throw new Error(`[Resolver] alias is undefined for this asset: ${C.src}`);C=this._buildResolvedAsset(C,{aliases:x,data:c,format:f,loadParser:p,parser:m,progressSize:s.progressSize}),v.push(C)})}),x.forEach(A=>{this._assetMap[A]=v})})}resolveBundle(t){const n=YE(t);t=Gf(t);const i={};return t.forEach(r=>{const s=this._bundles[r];if(s){const l=this.resolve(s),c={};for(const f in l){const p=l[f];c[this._extractAssetIdFromBundle(r,f)]=p}i[r]=c}}),n?i[t[0]]:i}resolveUrl(t){const n=this.resolve(t);if(typeof t!="string"){const i={};for(const r in n)i[r]=n[r].src;return i}return n.src}resolve(t){const n=YE(t);t=Gf(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let s=this._assetMap[r];const l=this._getPreferredOrder(s);l==null||l.priority.forEach(c=>{l.params[c].forEach(f=>{const p=s.filter(m=>m[c]?m[c]===f:!1);p.length&&(s=p)})}),this._resolverHash[r]=s[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),n?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let n=0;n<t.length;n++){const i=t[n],r=this._preferredOrder.find(s=>s.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const n=/\?/.test(t)?"&":"?";return`${t}${n}${this._defaultSearchParams}`}_buildResolvedAsset(t,n){const{aliases:i,data:r,loadParser:s,parser:l,format:c,progressSize:f}=n;return(this._basePath||this._rootPath)&&(t.src=Nm.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=s??t.loadParser,t.parser=l??t.parser,t.format=c??t.format??_z(t.src),f!==void 0&&(t.progressSize=f),t}}RA.RETINA_PREFIX=/@([0-9\.]+)x/;function _z(e){return e.split(".").pop().split("?").shift().split("#").shift()}const VE=(e,t)=>{const n=t.split("?")[1];return n&&(e+=`?${n}`),e},kA=class pm{constructor(t,n){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof Is&&(i={texture:t,data:n});const{texture:r,data:s,cachePrefix:l=""}=i;this.cachePrefix=l,this._texture=r instanceof Mn?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=s;const c=parseFloat(s.meta.scale);c?(this.resolution=c,r.source.resolution=this.resolution):this.resolution=r.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=pm.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,n=!1){let i=t;const r=n?1/0:pm.BATCH_SIZE;for(;i-t<r&&i<this._frameKeys.length;){const s=this._frameKeys[i],l=this._frames[s],c=l.frame;if(c){let f=null,p=null;const m=l.trimmed!==!1&&l.sourceSize?l.sourceSize:l.frame,g=new Ti(0,0,Math.floor(m.w)/this.resolution,Math.floor(m.h)/this.resolution);l.rotated?f=new Ti(Math.floor(c.x)/this.resolution,Math.floor(c.y)/this.resolution,Math.floor(c.h)/this.resolution,Math.floor(c.w)/this.resolution):f=new Ti(Math.floor(c.x)/this.resolution,Math.floor(c.y)/this.resolution,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution),l.trimmed!==!1&&l.spriteSourceSize&&(p=new Ti(Math.floor(l.spriteSourceSize.x)/this.resolution,Math.floor(l.spriteSourceSize.y)/this.resolution,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution)),this.textures[s]=new Mn({source:this.textureSource,frame:f,orig:g,trim:p,rotate:l.rotated?2:0,defaultAnchor:l.anchor,defaultBorders:l.borders,label:s.toString()})}i++}}_processAnimations(){const t=this.data.animations||{};for(const n in t){this.animations[n]=[];for(let i=0;i<t[n].length;i++){const r=t[n][i];this.animations[n].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*pm.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*pm.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var n;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((n=this._texture)==null||n.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};kA.BATCH_SIZE=1e3;let XE=kA;const Sz=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function NA(e,t,n){const i={};if(e.forEach(r=>{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[`${t.cachePrefix}${r}`]=t.textures[r]}),!n){const r=Nm.dirname(e[0]);t.linkedSheets.forEach((s,l)=>{const c=NA([`${r}/${t.data.meta.related_multi_packs[l]}`],s,!0);Object.assign(i,c)})}return i}const Ez={extension:kt.Asset,cache:{test:e=>e instanceof XE,getCacheableAssets:(e,t)=>NA(e,t,!1)},resolver:{extension:{type:kt.ResolveParser,name:"resolveSpritesheet"},test:e=>{const n=e.split("?")[0].split("."),i=n.pop(),r=n.pop();return i==="json"&&Sz.includes(r)},parse:e=>{var n;const t=e.split(".");return{resolution:parseFloat(((n=RA.RETINA_PREFIX.exec(e))==null?void 0:n[1])??"1"),format:t[t.length-2],src:e}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:kt.LoadParser,priority:AA.Normal,name:"spritesheetLoader"},async testParse(e,t){return Nm.extname(t.src).toLowerCase()===".json"&&!!e.frames},async parse(e,t,n){var g,x;const{texture:i,imageFilename:r,textureOptions:s,cachePrefix:l}=(t==null?void 0:t.data)??{};let c=Nm.dirname(t.src);c&&c.lastIndexOf("/")!==c.length-1&&(c+="/");let f;if(i instanceof Mn)f=i;else{const v=VE(c+(r??e.meta.image),t.src);f=(await n.load([{src:v,data:s}]))[v]}const p=new XE({texture:f.source,data:e,cachePrefix:l});await p.parse();const m=(g=e==null?void 0:e.meta)==null?void 0:g.related_multi_packs;if(Array.isArray(m)){const v=[];for(const A of m){if(typeof A!="string")continue;let T=c+A;(x=t.data)!=null&&x.ignoreMultiPack||(T=VE(T,t.src),v.push(n.load({src:T,data:{textureOptions:s,ignoreMultiPack:!0}})))}const S=await Promise.all(v);p.linkedSheets=S,S.forEach(A=>{A.linkedSheets=[p].concat(p.linkedSheets.filter(T=>T!==A))})}return p},async unload(e,t,n){await n.unload(e.textureSource._sourceOrigin),e.destroy(!1)}}};li.add(Ez);const Rb=Object.create(null),KE=Object.create(null);function i_(e,t){let n=KE[e];return n===void 0&&(Rb[t]===void 0&&(Rb[t]=1),KE[e]=n=Rb[t]++),n}let zf;function OA(){return(!zf||zf!=null&&zf.isContextLost())&&(zf=is.get().createCanvas().getContext("webgl",{})),zf}let Ly;function wz(){if(!Ly){Ly="mediump";const e=OA();e&&e.getShaderPrecisionFormat&&(Ly=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision?"highp":"mediump")}return Ly}function Tz(e,t,n){return t?e:n?(e=e.replace("out vec4 finalColor;",""),`
|
|
@@ -79,7 +79,7 @@ Deprecated since v${e}`,s=typeof console.groupCollapsed=="function"&&!$f.noColor
|
|
|
79
79
|
`}function Cz(e,t,n){const i=n?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(e.substring(0,9)!=="precision"){let r=n?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float;
|
|
80
80
|
${e}`}else if(i!=="highp"&&e.substring(0,15)==="precision highp")return e.replace("precision highp","precision mediump");return e}function Az(e,t){return t?`#version 300 es
|
|
81
81
|
${e}`:e}const Mz={},Rz={};function kz(e,{name:t="pixi-program"},n=!0){t=t.replace(/\s+/g,"-"),t+=n?"-fragment":"-vertex";const i=n?Mz:Rz;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,e.indexOf("#define SHADER_NAME")!==-1?e:`${`#define SHADER_NAME ${t}`}
|
|
82
|
-
${e}`}function Nz(e,t){return t?e.replace("#version 300 es",""):e}const kb={stripVersion:Nz,ensurePrecision:Cz,addProgramDefines:Tz,setProgramName:kz,insertVersion:Az},Qp=Object.create(null),DA=class Zv{constructor(t){t={...Zv.defaultOptions,...t};const n=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:n,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:wz()},setProgramName:{name:t.name},addProgramDefines:n,insertVersion:n};let r=t.fragment,s=t.vertex;Object.keys(kb).forEach(l=>{const c=i[l];r=kb[l](r,c,!0),s=kb[l](s,c,!1)}),this.fragment=r,this.vertex=s,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=i_(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,Qp[this._cacheKey]=null}static from(t){const n=`${t.vertex}:${t.fragment}`;return Qp[n]||(Qp[n]=new Zv(t),Qp[n]._cacheKey=n),Qp[n]}};DA.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let r_=DA;const $E={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Oz(e){return $E[e]??$E.float32}const Dz={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},WE=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function QE(e,t){let n;for(;(n=WE.exec(e))!==null;){const i=Dz[n[3]]??"float32";t[n[2]]={location:parseInt(n[1],10),format:i,stride:Oz(i).stride,offset:0,instance:!1,start:0}}WE.lastIndex=0}function zz(e){return e.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Bz({source:e,entryPoint:t}){const n={},i=zz(e),r=i.indexOf(`fn ${t}(`);if(r===-1)return n;const s=i.indexOf("->",r);if(s===-1)return n;const l=i.substring(r,s);if(QE(l,n),Object.keys(n).length===0){const c=l.match(/\(\s*\w+\s*:\s*(\w+)/);if(c){const f=c[1],p=new RegExp(`struct\\s+${f}\\s*\\{([^}]+)\\}`,"s"),m=i.match(p);m&&QE(m[1],n)}}return n}function Nb(e){var g,x;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,s=/:\s*([\w<>]+)/,l=/struct\s+(\w+)\s*{([^}]+)}/g,c=/(\w+)\s*:\s*([\w\<\>]+)/g,f=/struct\s+(\w+)/,p=(g=e.match(t))==null?void 0:g.map(v=>({group:parseInt(v.match(n)[1],10),binding:parseInt(v.match(i)[1],10),name:v.match(r)[2],isUniform:v.match(r)[1]==="<uniform>",type:v.match(s)[1]}));if(!p)return{groups:[],structs:[]};const m=((x=e.match(l))==null?void 0:x.map(v=>{const S=v.match(f)[1],A=v.match(c).reduce((T,C)=>{const[N,R]=C.split(":");return T[N.trim()]=R.trim(),T},{});return A?{name:S,members:A}:null}).filter(({name:v})=>p.some(S=>S.type===v||S.type.includes(`<${v}>`))))??[];return{groups:p,structs:m}}var fd=(e=>(e[e.VERTEX=1]="VERTEX",e[e.FRAGMENT=2]="FRAGMENT",e[e.COMPUTE=4]="COMPUTE",e))(fd||{});function Lz({groups:e}){const t=[];for(let n=0;n<e.length;n++){const i=e[n];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:fd.VERTEX|fd.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:fd.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"||i.type.startsWith("texture_2d<")?t[i.group].push({binding:i.binding,visibility:fd.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):i.type==="texture_2d_array"||i.type.startsWith("texture_2d_array<")?t[i.group].push({binding:i.binding,visibility:fd.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(i.type==="texture_cube"||i.type.startsWith("texture_cube<"))&&t[i.group].push({binding:i.binding,visibility:fd.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let n=0;n<t.length;n++)t[n]||(t[n]=[]);return t}function jz({groups:e}){const t=[];for(let n=0;n<e.length;n++){const i=e[n];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Iz(e,t){const n=new Set,i=new Set,r=[...e.structs,...t.structs].filter(l=>n.has(l.name)?!1:(n.add(l.name),!0)),s=[...e.groups,...t.groups].filter(l=>{const c=`${l.name}-${l.binding}`;return i.has(c)?!1:(i.add(c),!0)});return{structs:r,groups:s}}const Zp=Object.create(null);class Zm{constructor(t){var c,f;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:n,vertex:i,layout:r,gpuLayout:s,name:l}=t;if(this.name=l,this.fragment=n,this.vertex=i,n.source===i.source){const p=Nb(n.source);this.structsAndGroups=p}else{const p=Nb(i.source),m=Nb(n.source);this.structsAndGroups=Iz(p,m)}this.layout=r??jz(this.structsAndGroups),this.gpuLayout=s??Lz(this.structsAndGroups),this.autoAssignGlobalUniforms=((c=this.layout[0])==null?void 0:c.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((f=this.layout[1])==null?void 0:f.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:n}=this,i=t.source+n.source+t.entryPoint+n.entryPoint;this._layoutKey=i_(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Bz(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Zp[this._cacheKey]=null}static from(t){const n=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Zp[n]||(Zp[n]=new Zm(t),Zp[n]._cacheKey=n),Zp[n]}}const zA=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],Uz=zA.reduce((e,t)=>(e[t]=!0,e),{});function Hz(e,t){switch(e){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const BA=class LA{constructor(t,n){this._touched=0,this.uid=bi("uniform"),this._resourceType="uniformGroup",this._resourceId=bi("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,n={...LA.defaultOptions,...n},this.uniformStructures=t;const i={};for(const r in t){const s=t[r];if(s.name=r,s.size=s.size??1,!Uz[s.type]){const l=s.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,c,f]=l;throw new Error(`Uniform type ${s.type} is not supported. Use type: '${c}', size: ${f} instead.`)}throw new Error(`Uniform type ${s.type} is not supported. Supported uniform types are: ${zA.join(", ")}`)}s.value??(s.value=Hz(s.type,s.size)),i[r]=s.value}this.uniforms=i,this._dirtyId=1,this.ubo=n.ubo,this.isStatic=n.isStatic,this._signature=i_(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};BA.defaultOptions={ubo:!1,isStatic:!1};let jA=BA;class y0{constructor(t){this.resources=Object.create(null),this._dirty=!0;let n=0;for(const i in t){const r=t[i];this.setResource(r,n++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let n=0;for(const i in this.resources)t[n++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,n){var r,s;const i=this.resources[n];t!==i&&((r=i==null?void 0:i.off)==null||r.call(i,"change",this.onResourceChange,this),(s=t.on)==null||s.call(t,"change",this.onResourceChange,this),this.resources[n]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,n){const i=this.resources;for(const r in i)i[r]._gcLastUsed=t,i[r]._touched=n}destroy(){var n;const t=this.resources;for(const i in t){const r=t[i];(n=r==null?void 0:r.off)==null||n.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var Jv=(e=>(e[e.WEBGL=1]="WEBGL",e[e.WEBGPU=2]="WEBGPU",e[e.CANVAS=4]="CANVAS",e[e.BOTH=3]="BOTH",e))(Jv||{});class nx extends yo{constructor(t){super(),this.uid=bi("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:n,glProgram:i,groups:r,resources:s,compatibleRenderers:l,groupMap:c}=t;this.gpuProgram=n,this.glProgram=i,l===void 0&&(l=0,n&&(l|=Jv.WEBGPU),i&&(l|=Jv.WEBGL)),this.compatibleRenderers=l;const f={};if(!s&&!r&&(s={}),s&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!n&&r&&!c)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!n&&r&&c)for(const p in c)for(const m in c[p]){const g=c[p][m];f[g]={group:p,binding:m,name:g}}else if(n&&r&&!c){const p=n.structsAndGroups.groups;c={},p.forEach(m=>{c[m.group]=c[m.group]||{},c[m.group][m.binding]=m.name,f[m.name]=m})}else if(s){r={},c={},n&&n.structsAndGroups.groups.forEach(g=>{c[g.group]=c[g.group]||{},c[g.group][g.binding]=g.name,f[g.name]=g});let p=0;for(const m in s)f[m]||(r[99]||(r[99]=new y0,this._ownedBindGroups.push(r[99])),f[m]={group:99,binding:p,name:m},c[99]=c[99]||{},c[99][p]=m,p++);for(const m in s){const g=m;let x=s[m];!x.source&&!x._resourceType&&(x=new jA(x));const v=f[g];v&&(r[v.group]||(r[v.group]=new y0,this._ownedBindGroups.push(r[v.group])),r[v.group].setResource(x,v.binding))}}this.groups=r,this._uniformBindMap=c,this.resources=this._buildResourceAccessor(r,f)}addResource(t,n,i){var r,s;(r=this._uniformBindMap)[n]||(r[n]={}),(s=this._uniformBindMap[n])[i]||(s[i]=t),this.groups[n]||(this.groups[n]=new y0,this._ownedBindGroups.push(this.groups[n]))}_buildResourceAccessor(t,n){const i={};for(const r in n){const s=n[r];Object.defineProperty(i,s.name,{get(){return t[s.group].getResource(s.binding)},set(l){t[s.group].setResource(l,s.binding)}})}return i}destroy(t=!1){var n,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((n=this.gpuProgram)==null||n.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:n,gl:i,...r}=t;let s,l;return n&&(s=Zm.from(n)),i&&(l=r_.from(i)),new nx({gpuProgram:s,glProgram:l,...r})}}const Pz={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},Ob=0,Db=1,zb=2,Bb=3,Lb=4,jb=5,e1=class IA{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Ob)}set blend(t){!!(this.data&1<<Ob)!==t&&(this.data^=1<<Ob)}get offsets(){return!!(this.data&1<<Db)}set offsets(t){!!(this.data&1<<Db)!==t&&(this.data^=1<<Db)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<zb)}set culling(t){!!(this.data&1<<zb)!==t&&(this.data^=1<<zb)}get depthTest(){return!!(this.data&1<<Bb)}set depthTest(t){!!(this.data&1<<Bb)!==t&&(this.data^=1<<Bb)}get depthMask(){return!!(this.data&1<<jb)}set depthMask(t){!!(this.data&1<<jb)!==t&&(this.data^=1<<jb)}get clockwiseFrontFace(){return!!(this.data&1<<Lb)}set clockwiseFrontFace(t){!!(this.data&1<<Lb)!==t&&(this.data^=1<<Lb)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=Pz[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new IA;return t.depthTest=!1,t.blend=!0,t}};e1.default2d=e1.for2d();let a_=e1;const UA=class t1 extends nx{constructor(t){t={...t1.defaultOptions,...t},super(t),this.enabled=!0,this._state=a_.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,n,i,r){t.applyFilter(this,n,i,r)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:n,gl:i,...r}=t;let s,l;return n&&(s=Zm.from(n)),i&&(l=r_.from(i)),new t1({gpuProgram:s,glProgram:l,...r})}};UA.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Ad=UA;const n1=[];li.handleByNamedList(kt.Environment,n1);async function Fz(e){if(!e)for(let t=0;t<n1.length;t++){const n=n1[t];if(n.value.test()){await n.value.load();return}}}let Jp;function Gz(){if(typeof Jp=="boolean")return Jp;try{Jp=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Jp=!1}return Jp}function ZE(e,t,n=2){const i=t&&t.length,r=i?t[0]*n:e.length;let s=HA(e,0,r,n,!0);const l=[];if(!s||s.next===s.prev)return l;let c,f,p;if(i&&(s=Kz(e,t,s,n)),e.length>80*n){c=e[0],f=e[1];let m=c,g=f;for(let x=n;x<r;x+=n){const v=e[x],S=e[x+1];v<c&&(c=v),S<f&&(f=S),v>m&&(m=v),S>g&&(g=S)}p=Math.max(m-c,g-f),p=p!==0?32767/p:0}return Om(s,l,n,c,f,p,0),l}function HA(e,t,n,i,r){let s;if(r===a5(e,t,n,i)>0)for(let l=t;l<n;l+=i)s=JE(l/i|0,e[l],e[l+1],s);else for(let l=n-i;l>=t;l-=i)s=JE(l/i|0,e[l],e[l+1],s);return s&&uh(s,s.next)&&(zm(s),s=s.next),s}function vd(e,t){if(!e)return e;t||(t=e);let n=e,i;do if(i=!1,!n.steiner&&(uh(n,n.next)||si(n.prev,n,n.next)===0)){if(zm(n),n=t=n.prev,n===n.next)break;i=!0}else n=n.next;while(i||n!==t);return t}function Om(e,t,n,i,r,s,l){if(!e)return;!l&&s&&Jz(e,i,r,s);let c=e;for(;e.prev!==e.next;){const f=e.prev,p=e.next;if(s?Yz(e,i,r,s):qz(e)){t.push(f.i,e.i,p.i),zm(e),e=p.next,c=p.next;continue}if(e=p,e===c){l?l===1?(e=Vz(vd(e),t),Om(e,t,n,i,r,s,2)):l===2&&Xz(e,t,n,i,r,s):Om(vd(e),t,n,i,r,s,1);break}}}function qz(e){const t=e.prev,n=e,i=e.next;if(si(t,n,i)>=0)return!1;const r=t.x,s=n.x,l=i.x,c=t.y,f=n.y,p=i.y,m=Math.min(r,s,l),g=Math.min(c,f,p),x=Math.max(r,s,l),v=Math.max(c,f,p);let S=i.next;for(;S!==t;){if(S.x>=m&&S.x<=x&&S.y>=g&&S.y<=v&&mm(r,c,s,f,l,p,S.x,S.y)&&si(S.prev,S,S.next)>=0)return!1;S=S.next}return!0}function Yz(e,t,n,i){const r=e.prev,s=e,l=e.next;if(si(r,s,l)>=0)return!1;const c=r.x,f=s.x,p=l.x,m=r.y,g=s.y,x=l.y,v=Math.min(c,f,p),S=Math.min(m,g,x),A=Math.max(c,f,p),T=Math.max(m,g,x),C=i1(v,S,t,n,i),N=i1(A,T,t,n,i);let R=e.prevZ,O=e.nextZ;for(;R&&R.z>=C&&O&&O.z<=N;){if(R.x>=v&&R.x<=A&&R.y>=S&&R.y<=T&&R!==r&&R!==l&&mm(c,m,f,g,p,x,R.x,R.y)&&si(R.prev,R,R.next)>=0||(R=R.prevZ,O.x>=v&&O.x<=A&&O.y>=S&&O.y<=T&&O!==r&&O!==l&&mm(c,m,f,g,p,x,O.x,O.y)&&si(O.prev,O,O.next)>=0))return!1;O=O.nextZ}for(;R&&R.z>=C;){if(R.x>=v&&R.x<=A&&R.y>=S&&R.y<=T&&R!==r&&R!==l&&mm(c,m,f,g,p,x,R.x,R.y)&&si(R.prev,R,R.next)>=0)return!1;R=R.prevZ}for(;O&&O.z<=N;){if(O.x>=v&&O.x<=A&&O.y>=S&&O.y<=T&&O!==r&&O!==l&&mm(c,m,f,g,p,x,O.x,O.y)&&si(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function Vz(e,t){let n=e;do{const i=n.prev,r=n.next.next;!uh(i,r)&&FA(i,n,n.next,r)&&Dm(i,r)&&Dm(r,i)&&(t.push(i.i,n.i,r.i),zm(n),zm(n.next),n=e=r),n=n.next}while(n!==e);return vd(n)}function Xz(e,t,n,i,r,s){let l=e;do{let c=l.next.next;for(;c!==l.prev;){if(l.i!==c.i&&n5(l,c)){let f=GA(l,c);l=vd(l,l.next),f=vd(f,f.next),Om(l,t,n,i,r,s,0),Om(f,t,n,i,r,s,0);return}c=c.next}l=l.next}while(l!==e)}function Kz(e,t,n,i){const r=[];for(let s=0,l=t.length;s<l;s++){const c=t[s]*i,f=s<l-1?t[s+1]*i:e.length,p=HA(e,c,f,i,!1);p===p.next&&(p.steiner=!0),r.push(t5(p))}r.sort($z);for(let s=0;s<r.length;s++)n=Wz(r[s],n);return n}function $z(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){const i=(e.next.y-e.y)/(e.next.x-e.x),r=(t.next.y-t.y)/(t.next.x-t.x);n=i-r}return n}function Wz(e,t){const n=Qz(e,t);if(!n)return t;const i=GA(n,e);return vd(i,i.next),vd(n,n.next)}function Qz(e,t){let n=t;const i=e.x,r=e.y;let s=-1/0,l;if(uh(e,n))return n;do{if(uh(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const g=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(g<=i&&g>s&&(s=g,l=n.x<n.next.x?n:n.next,g===i))return l}n=n.next}while(n!==t);if(!l)return null;const c=l,f=l.x,p=l.y;let m=1/0;n=l;do{if(i>=n.x&&n.x>=f&&i!==n.x&&PA(r<p?i:s,r,f,p,r<p?s:i,r,n.x,n.y)){const g=Math.abs(r-n.y)/(i-n.x);Dm(n,e)&&(g<m||g===m&&(n.x>l.x||n.x===l.x&&Zz(l,n)))&&(l=n,m=g)}n=n.next}while(n!==c);return l}function Zz(e,t){return si(e.prev,e,t.prev)<0&&si(t.next,e,e.next)<0}function Jz(e,t,n,i){let r=e;do r.z===0&&(r.z=i1(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,e5(r)}function e5(e){let t,n=1;do{let i=e,r;e=null;let s=null;for(t=0;i;){t++;let l=i,c=0;for(let p=0;p<n&&(c++,l=l.nextZ,!!l);p++);let f=n;for(;c>0||f>0&&l;)c!==0&&(f===0||!l||i.z<=l.z)?(r=i,i=i.nextZ,c--):(r=l,l=l.nextZ,f--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;i=l}s.nextZ=null,n*=2}while(t>1);return e}function i1(e,t,n,i,r){return e=(e-n)*r|0,t=(t-i)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function t5(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function PA(e,t,n,i,r,s,l,c){return(r-l)*(t-c)>=(e-l)*(s-c)&&(e-l)*(i-c)>=(n-l)*(t-c)&&(n-l)*(s-c)>=(r-l)*(i-c)}function mm(e,t,n,i,r,s,l,c){return!(e===l&&t===c)&&PA(e,t,n,i,r,s,l,c)}function n5(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!i5(e,t)&&(Dm(e,t)&&Dm(t,e)&&r5(e,t)&&(si(e.prev,e,t.prev)||si(e,t.prev,t))||uh(e,t)&&si(e.prev,e,e.next)>0&&si(t.prev,t,t.next)>0)}function si(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function uh(e,t){return e.x===t.x&&e.y===t.y}function FA(e,t,n,i){const r=Iy(si(e,t,n)),s=Iy(si(e,t,i)),l=Iy(si(n,i,e)),c=Iy(si(n,i,t));return!!(r!==s&&l!==c||r===0&&jy(e,n,t)||s===0&&jy(e,i,t)||l===0&&jy(n,e,i)||c===0&&jy(n,t,i))}function jy(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Iy(e){return e>0?1:e<0?-1:0}function i5(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&FA(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Dm(e,t){return si(e.prev,e,e.next)<0?si(e,t,e.next)>=0&&si(e,e.prev,t)>=0:si(e,t,e.prev)<0||si(e,e.next,t)<0}function r5(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next;while(n!==e);return i}function GA(e,t){const n=r1(e.i,e.x,e.y),i=r1(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function JE(e,t,n,i){const r=r1(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function zm(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function r1(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function a5(e,t,n,i){let r=0;for(let s=t,l=n-i;s<n;s+=i)r+=(e[l]-e[s])*(e[s+1]+e[l+1]),l=s;return r}const s5=ZE.default||ZE;var qA=(e=>(e[e.NONE=0]="NONE",e[e.COLOR=16384]="COLOR",e[e.STENCIL=1024]="STENCIL",e[e.DEPTH=256]="DEPTH",e[e.COLOR_DEPTH=16640]="COLOR_DEPTH",e[e.COLOR_STENCIL=17408]="COLOR_STENCIL",e[e.DEPTH_STENCIL=1280]="DEPTH_STENCIL",e[e.ALL=17664]="ALL",e))(qA||{});class l5{constructor(t){this.items=[],this._name=t}emit(t,n,i,r,s,l,c,f){const{name:p,items:m}=this;for(let g=0,x=m.length;g<x;g++)m[g][p](t,n,i,r,s,l,c,f);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const n=this.items.indexOf(t);return n!==-1&&this.items.splice(n,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const o5=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],YA=class VA extends yo{constructor(t){super(),this.tick=0,this.uid=bi("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const n=[...o5,...this.config.runners??[]];this._addRunners(...n),this._unsafeEvalCheck()}async init(t={}){const n=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Fz(n),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)t={...this._systemsHash[i].constructor.defaultOptions,...t};t={...VA.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,n){this.tick++;let i=t;if(i instanceof _r&&(i={container:i},n&&(en(xi,"passing a second argument is deprecated, please use render options instead"),i.target=n.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const r=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=r?i.clearColor:qi.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i))}resize(t,n,i){const r=this.view.resolution;this.view.resize(t,n,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==r&&this.runners.resolutionChange.emit(i)}clear(t={}){const n=this;t.target||(t.target=n.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=qA.ALL);const{clear:i,clearColor:r,target:s,mipLevel:l,layer:c}=t;qi.shared.setValue(r??this.background.colorRgba),n.renderTarget.clear(s,i,qi.shared.toArray(),l??0,c??0)}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(n=>{this.runners[n]=new l5(n)})}_addSystems(t){let n;for(n in t){const i=t[n];this._addSystem(i.value,i.name)}}_addSystem(t,n){const i=new t(this);if(this[n])throw new Error(`Whoops! The name "${n}" is already in use`);this[n]=i,this._systemsHash[n]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,n){const i=n.reduce((r,s)=>(r[s.name]=s.value,r),{});t.forEach(r=>{const s=r.value,l=r.name,c=i[l];this.renderPipes[l]=new s(this,c?new c:null),this.runners.destroy.add(this.renderPipes[l])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&Qm.release(),Object.values(this.runners).forEach(n=>{n.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Gz())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};YA.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let XA=YA,Uy;function c5(e){return Uy!==void 0||(Uy=(()=>{var n;const t={stencil:!0,failIfMajorPerformanceCaveat:e??XA.defaultOptions.failIfMajorPerformanceCaveat};try{if(!is.get().getWebGLRenderingContext())return!1;let r=is.get().createCanvas().getContext("webgl",t);const s=!!((n=r==null?void 0:r.getContextAttributes())!=null&&n.stencil);if(r){const l=r.getExtension("WEBGL_lose_context");l&&l.loseContext()}return r=null,s}catch{return!1}})()),Uy}let Hy;async function u5(e={}){return Hy!==void 0||(Hy=await(async()=>{const t=is.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(e)).requestDevice(),!0}catch{return!1}})()),Hy}const ew=["webgl","webgpu","canvas"];async function d5(e){let t=[];e.preference?(t.push(e.preference),ew.forEach(s=>{s!==e.preference&&t.push(s)})):t=ew.slice();let n,i={};for(let s=0;s<t.length;s++){const l=t[s];if(l==="webgpu"&&await u5()){const{WebGPURenderer:c}=await ou(async()=>{const{WebGPURenderer:f}=await import("./WebGPURenderer-DLRzrHD6.js");return{WebGPURenderer:f}},__vite__mapDeps([4,5,6]));n=c,i={...e,...e.webgpu};break}else if(l==="webgl"&&c5(e.failIfMajorPerformanceCaveat??XA.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:c}=await ou(async()=>{const{WebGLRenderer:f}=await import("./WebGLRenderer-C9oCtm3q.js");return{WebGLRenderer:f}},__vite__mapDeps([7,5,6]));n=c,i={...e,...e.webgl};break}else if(l==="canvas"){const{CanvasRenderer:c}=await ou(async()=>{const{CanvasRenderer:f}=await import("./CanvasRenderer-Bvvt4cGi.js");return{CanvasRenderer:f}},__vite__mapDeps([8,6]));n=c,i={...e,...e.canvasOptions};break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!n)throw new Error("No available renderer for the current environment");const r=new n;return await r.init(i),r}const KA="8.17.0";class $A{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,KA)}static destroy(){}}$A.extension=kt.Application;class f5{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,KA)}destroy(){this._renderer=null}}f5.extension={type:[kt.WebGLSystem,kt.WebGPUSystem],name:"initHook",priority:-10};class WA{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(n){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=n,n&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let n,i;if(this._resizeTo===globalThis.window)n=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:s}=this._resizeTo;n=r,i=s}this.renderer.resize(n,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}WA.extension=kt.Application;class QA{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(n){this._ticker&&this._ticker.remove(this.render,this),this._ticker=n,n&&n.add(this.render,this,M0.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Wf.shared:new Wf,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}QA.extension=kt.Application;li.add(WA);li.add(QA);const ZA=class a1{constructor(...t){this.stage=new _r,t[0]!==void 0&&en(xi,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new _r),this.renderer=await d5(t),a1._plugins.forEach(n=>{n.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return en(xi,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,n=!1){const i=a1._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(n),this.stage=null,this.renderer.destroy(t),this.renderer=null}};ZA._plugins=[];let s_=ZA;li.handleByList(kt.Application,s_._plugins);li.add($A);var Ib,tw;function h5(){if(tw)return Ib;tw=1,Ib=n;var e={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function n(s){var l=[];return s.replace(t,function(c,f,p){var m=f.toLowerCase();for(p=r(p),m=="m"&&p.length>2&&(l.push([f].concat(p.splice(0,2))),m="l",f=f=="m"?"l":"L");;){if(p.length==e[m])return p.unshift(f),l.push(p);if(p.length<e[m])throw new Error("malformed path data");l.push([f].concat(p.splice(0,e[m])))}}),l}var i=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function r(s){var l=s.match(i);return l?l.map(Number):[]}return Ib}var p5=h5();const m5=du(p5);function g5(e,t){const n=m5(e),i=[];let r=null,s=0,l=0;for(let c=0;c<n.length;c++){const f=n[c],p=f[0],m=f;switch(p){case"M":s=m[1],l=m[2],t.moveTo(s,l);break;case"m":s+=m[1],l+=m[2],t.moveTo(s,l);break;case"H":s=m[1],t.lineTo(s,l);break;case"h":s+=m[1],t.lineTo(s,l);break;case"V":l=m[1],t.lineTo(s,l);break;case"v":l+=m[1],t.lineTo(s,l);break;case"L":s=m[1],l=m[2],t.lineTo(s,l);break;case"l":s+=m[1],l+=m[2],t.lineTo(s,l);break;case"C":s=m[5],l=m[6],t.bezierCurveTo(m[1],m[2],m[3],m[4],s,l);break;case"c":t.bezierCurveTo(s+m[1],l+m[2],s+m[3],l+m[4],s+m[5],l+m[6]),s+=m[5],l+=m[6];break;case"S":s=m[3],l=m[4],t.bezierCurveToShort(m[1],m[2],s,l);break;case"s":t.bezierCurveToShort(s+m[1],l+m[2],s+m[3],l+m[4]),s+=m[3],l+=m[4];break;case"Q":s=m[3],l=m[4],t.quadraticCurveTo(m[1],m[2],s,l);break;case"q":t.quadraticCurveTo(s+m[1],l+m[2],s+m[3],l+m[4]),s+=m[3],l+=m[4];break;case"T":s=m[1],l=m[2],t.quadraticCurveToShort(s,l);break;case"t":s+=m[1],l+=m[2],t.quadraticCurveToShort(s,l);break;case"A":s=m[6],l=m[7],t.arcToSvg(m[1],m[2],m[3],m[4],m[5],s,l);break;case"a":s+=m[6],l+=m[7],t.arcToSvg(m[1],m[2],m[3],m[4],m[5],s,l);break;case"Z":case"z":t.closePath(),i.length>0&&(r=i.pop(),r?(s=r.startX,l=r.startY):(s=0,l=0)),r=null;break;default:ma(`Unknown SVG path command: ${p}`)}p!=="Z"&&p!=="z"&&r===null&&(r={startX:s,startY:l},i.push(r))}return t}class l_{constructor(t=0,n=0,i=0){this.type="circle",this.x=t,this.y=n,this.radius=i}clone(){return new l_(this.x,this.y,this.radius)}contains(t,n){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,s=this.y-n;return r*=r,s*=s,r+s<=i}strokeContains(t,n,i,r=.5){if(this.radius===0)return!1;const s=this.x-t,l=this.y-n,c=this.radius,f=(1-r)*i,p=Math.sqrt(s*s+l*l);return p<=c+f&&p>c-(i-f)}getBounds(t){return t||(t=new Ti),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class o_{constructor(t=0,n=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=n,this.halfWidth=i,this.halfHeight=r}clone(){return new o_(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,n){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(n-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,n,i,r=.5){const{halfWidth:s,halfHeight:l}=this;if(s<=0||l<=0)return!1;const c=i*(1-r),f=i-c,p=s-f,m=l-f,g=s+c,x=l+c,v=t-this.x,S=n-this.y,A=v*v/(p*p)+S*S/(m*m),T=v*v/(g*g)+S*S/(x*x);return A>1&&T<=1}getBounds(t){return t||(t=new Ti),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function y5(e,t,n,i,r,s){const l=e-n,c=t-i,f=r-n,p=s-i,m=l*f+c*p,g=f*f+p*p;let x=-1;g!==0&&(x=m/g);let v,S;x<0?(v=n,S=i):x>1?(v=r,S=s):(v=n+x*f,S=i+x*p);const A=e-v,T=t-S;return A*A+T*T}let x5,b5;class Sm{constructor(...t){this.type="polygon";let n=Array.isArray(t[0])?t[0]:t;if(typeof n[0]!="number"){const i=[];for(let r=0,s=n.length;r<s;r++)i.push(n[r].x,n[r].y);n=i}this.points=n,this.closePath=!0}isClockwise(){let t=0;const n=this.points,i=n.length;for(let r=0;r<i;r+=2){const s=n[r],l=n[r+1],c=n[(r+2)%i],f=n[(r+3)%i];t+=(c-s)*(f+l)}return t<0}containsPolygon(t){const n=this.getBounds(x5),i=t.getBounds(b5);if(!n.containsRect(i))return!1;const r=t.points;for(let s=0;s<r.length;s+=2){const l=r[s],c=r[s+1];if(!this.contains(l,c))return!1}return!0}clone(){const t=this.points.slice(),n=new Sm(t);return n.closePath=this.closePath,n}contains(t,n){let i=!1;const r=this.points.length/2;for(let s=0,l=r-1;s<r;l=s++){const c=this.points[s*2],f=this.points[s*2+1],p=this.points[l*2],m=this.points[l*2+1];f>n!=m>n&&t<(p-c)*((n-f)/(m-f))+c&&(i=!i)}return i}strokeContains(t,n,i,r=.5){const s=i*i,l=s*(1-r),c=s-l,{points:f}=this,p=f.length-(this.closePath?0:2);for(let m=0;m<p;m+=2){const g=f[m],x=f[m+1],v=f[(m+2)%f.length],S=f[(m+3)%f.length],A=y5(t,n,g,x,v,S),T=Math.sign((v-g)*(n-x)-(S-x)*(t-g));if(A<=(T<0?c:l))return!0}return!1}getBounds(t){t||(t=new Ti);const n=this.points;let i=1/0,r=-1/0,s=1/0,l=-1/0;for(let c=0,f=n.length;c<f;c+=2){const p=n[c],m=n[c+1];i=p<i?p:i,r=p>r?p:r,s=m<s?m:s,l=m>l?m:l}return t.x=i,t.width=r-i,t.y=s,t.height=l-s,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,n)=>`${t}, ${n}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return en("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return en("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Py=(e,t,n,i,r,s,l)=>{const c=e-n,f=t-i,p=Math.sqrt(c*c+f*f);return p>=r-s&&p<=r+l};class c_{constructor(t=0,n=0,i=0,r=0,s=20){this.type="roundedRectangle",this.x=t,this.y=n,this.width=i,this.height=r,this.radius=s}getBounds(t){return t||(t=new Ti),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new c_(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,n){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&n>=this.y&&n<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(n>=this.y+i&&n<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),s=n-(this.y+i);const l=i*i;if(r*r+s*s<=l||(r=t-(this.x+this.width-i),r*r+s*s<=l)||(s=n-(this.y+this.height-i),r*r+s*s<=l)||(r=t-(this.x+i),r*r+s*s<=l))return!0}return!1}strokeContains(t,n,i,r=.5){const{x:s,y:l,width:c,height:f,radius:p}=this,m=i*(1-r),g=i-m,x=s+p,v=l+p,S=c-p*2,A=f-p*2,T=s+c,C=l+f;return(t>=s-m&&t<=s+g||t>=T-g&&t<=T+m)&&n>=v&&n<=v+A||(n>=l-m&&n<=l+g||n>=C-g&&n<=C+m)&&t>=x&&t<=x+S?!0:t<x&&n<v&&Py(t,n,x,v,p,g,m)||t>T-p&&n<v&&Py(t,n,T-p,v,p,g,m)||t>T-p&&n>C-p&&Py(t,n,T-p,C-p,p,g,m)||t<x&&n>C-p&&Py(t,n,x,C-p,p,g,m)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const JA={};function v5(e,t,n){let i=2166136261;for(let r=0;r<t;r++)i^=e[r].uid,i=Math.imul(i,16777619),i>>>=0;return JA[i]||_5(e,t,i,n)}function _5(e,t,n,i){const r={};let s=0;for(let c=0;c<i;c++){const f=c<t?e[c]:Mn.EMPTY.source;r[s++]=f.source,r[s++]=f.style}const l=new y0(r);return JA[n]=l,l}class nw{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function iw(e,t,n,i){if(n??(n=0),i??(i=Math.min(e.byteLength-n,t.byteLength)),!(n&7)&&!(i&7)){const r=i/8;new Float64Array(t,0,r).set(new Float64Array(e,n,r))}else if(!(n&3)&&!(i&3)){const r=i/4;new Float32Array(t,0,r).set(new Float32Array(e,n,r))}else new Uint8Array(t).set(new Uint8Array(e,n,i))}const S5={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var E5=(e=>(e[e.DISABLED=0]="DISABLED",e[e.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",e[e.MASK_ACTIVE=2]="MASK_ACTIVE",e[e.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",e[e.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",e[e.NONE=5]="NONE",e))(E5||{});function rw(e,t){return t.alphaMode==="no-premultiply-alpha"&&S5[e]||e}const w5=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
82
|
+
${e}`}function Nz(e,t){return t?e.replace("#version 300 es",""):e}const kb={stripVersion:Nz,ensurePrecision:Cz,addProgramDefines:Tz,setProgramName:kz,insertVersion:Az},Qp=Object.create(null),DA=class Zv{constructor(t){t={...Zv.defaultOptions,...t};const n=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:n,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:wz()},setProgramName:{name:t.name},addProgramDefines:n,insertVersion:n};let r=t.fragment,s=t.vertex;Object.keys(kb).forEach(l=>{const c=i[l];r=kb[l](r,c,!0),s=kb[l](s,c,!1)}),this.fragment=r,this.vertex=s,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=i_(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,Qp[this._cacheKey]=null}static from(t){const n=`${t.vertex}:${t.fragment}`;return Qp[n]||(Qp[n]=new Zv(t),Qp[n]._cacheKey=n),Qp[n]}};DA.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let r_=DA;const $E={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Oz(e){return $E[e]??$E.float32}const Dz={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},WE=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function QE(e,t){let n;for(;(n=WE.exec(e))!==null;){const i=Dz[n[3]]??"float32";t[n[2]]={location:parseInt(n[1],10),format:i,stride:Oz(i).stride,offset:0,instance:!1,start:0}}WE.lastIndex=0}function zz(e){return e.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Bz({source:e,entryPoint:t}){const n={},i=zz(e),r=i.indexOf(`fn ${t}(`);if(r===-1)return n;const s=i.indexOf("->",r);if(s===-1)return n;const l=i.substring(r,s);if(QE(l,n),Object.keys(n).length===0){const c=l.match(/\(\s*\w+\s*:\s*(\w+)/);if(c){const f=c[1],p=new RegExp(`struct\\s+${f}\\s*\\{([^}]+)\\}`,"s"),m=i.match(p);m&&QE(m[1],n)}}return n}function Nb(e){var g,x;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,s=/:\s*([\w<>]+)/,l=/struct\s+(\w+)\s*{([^}]+)}/g,c=/(\w+)\s*:\s*([\w\<\>]+)/g,f=/struct\s+(\w+)/,p=(g=e.match(t))==null?void 0:g.map(v=>({group:parseInt(v.match(n)[1],10),binding:parseInt(v.match(i)[1],10),name:v.match(r)[2],isUniform:v.match(r)[1]==="<uniform>",type:v.match(s)[1]}));if(!p)return{groups:[],structs:[]};const m=((x=e.match(l))==null?void 0:x.map(v=>{const S=v.match(f)[1],A=v.match(c).reduce((T,C)=>{const[N,R]=C.split(":");return T[N.trim()]=R.trim(),T},{});return A?{name:S,members:A}:null}).filter(({name:v})=>p.some(S=>S.type===v||S.type.includes(`<${v}>`))))??[];return{groups:p,structs:m}}var fd=(e=>(e[e.VERTEX=1]="VERTEX",e[e.FRAGMENT=2]="FRAGMENT",e[e.COMPUTE=4]="COMPUTE",e))(fd||{});function Lz({groups:e}){const t=[];for(let n=0;n<e.length;n++){const i=e[n];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:fd.VERTEX|fd.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:fd.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"||i.type.startsWith("texture_2d<")?t[i.group].push({binding:i.binding,visibility:fd.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):i.type==="texture_2d_array"||i.type.startsWith("texture_2d_array<")?t[i.group].push({binding:i.binding,visibility:fd.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(i.type==="texture_cube"||i.type.startsWith("texture_cube<"))&&t[i.group].push({binding:i.binding,visibility:fd.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let n=0;n<t.length;n++)t[n]||(t[n]=[]);return t}function jz({groups:e}){const t=[];for(let n=0;n<e.length;n++){const i=e[n];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Iz(e,t){const n=new Set,i=new Set,r=[...e.structs,...t.structs].filter(l=>n.has(l.name)?!1:(n.add(l.name),!0)),s=[...e.groups,...t.groups].filter(l=>{const c=`${l.name}-${l.binding}`;return i.has(c)?!1:(i.add(c),!0)});return{structs:r,groups:s}}const Zp=Object.create(null);class Zm{constructor(t){var c,f;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:n,vertex:i,layout:r,gpuLayout:s,name:l}=t;if(this.name=l,this.fragment=n,this.vertex=i,n.source===i.source){const p=Nb(n.source);this.structsAndGroups=p}else{const p=Nb(i.source),m=Nb(n.source);this.structsAndGroups=Iz(p,m)}this.layout=r??jz(this.structsAndGroups),this.gpuLayout=s??Lz(this.structsAndGroups),this.autoAssignGlobalUniforms=((c=this.layout[0])==null?void 0:c.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((f=this.layout[1])==null?void 0:f.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:n}=this,i=t.source+n.source+t.entryPoint+n.entryPoint;this._layoutKey=i_(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Bz(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Zp[this._cacheKey]=null}static from(t){const n=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Zp[n]||(Zp[n]=new Zm(t),Zp[n]._cacheKey=n),Zp[n]}}const zA=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],Uz=zA.reduce((e,t)=>(e[t]=!0,e),{});function Hz(e,t){switch(e){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const BA=class LA{constructor(t,n){this._touched=0,this.uid=bi("uniform"),this._resourceType="uniformGroup",this._resourceId=bi("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,n={...LA.defaultOptions,...n},this.uniformStructures=t;const i={};for(const r in t){const s=t[r];if(s.name=r,s.size=s.size??1,!Uz[s.type]){const l=s.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,c,f]=l;throw new Error(`Uniform type ${s.type} is not supported. Use type: '${c}', size: ${f} instead.`)}throw new Error(`Uniform type ${s.type} is not supported. Supported uniform types are: ${zA.join(", ")}`)}s.value??(s.value=Hz(s.type,s.size)),i[r]=s.value}this.uniforms=i,this._dirtyId=1,this.ubo=n.ubo,this.isStatic=n.isStatic,this._signature=i_(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};BA.defaultOptions={ubo:!1,isStatic:!1};let jA=BA;class y0{constructor(t){this.resources=Object.create(null),this._dirty=!0;let n=0;for(const i in t){const r=t[i];this.setResource(r,n++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let n=0;for(const i in this.resources)t[n++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,n){var r,s;const i=this.resources[n];t!==i&&((r=i==null?void 0:i.off)==null||r.call(i,"change",this.onResourceChange,this),(s=t.on)==null||s.call(t,"change",this.onResourceChange,this),this.resources[n]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,n){const i=this.resources;for(const r in i)i[r]._gcLastUsed=t,i[r]._touched=n}destroy(){var n;const t=this.resources;for(const i in t){const r=t[i];(n=r==null?void 0:r.off)==null||n.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var Jv=(e=>(e[e.WEBGL=1]="WEBGL",e[e.WEBGPU=2]="WEBGPU",e[e.CANVAS=4]="CANVAS",e[e.BOTH=3]="BOTH",e))(Jv||{});class nx extends yo{constructor(t){super(),this.uid=bi("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:n,glProgram:i,groups:r,resources:s,compatibleRenderers:l,groupMap:c}=t;this.gpuProgram=n,this.glProgram=i,l===void 0&&(l=0,n&&(l|=Jv.WEBGPU),i&&(l|=Jv.WEBGL)),this.compatibleRenderers=l;const f={};if(!s&&!r&&(s={}),s&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!n&&r&&!c)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!n&&r&&c)for(const p in c)for(const m in c[p]){const g=c[p][m];f[g]={group:p,binding:m,name:g}}else if(n&&r&&!c){const p=n.structsAndGroups.groups;c={},p.forEach(m=>{c[m.group]=c[m.group]||{},c[m.group][m.binding]=m.name,f[m.name]=m})}else if(s){r={},c={},n&&n.structsAndGroups.groups.forEach(g=>{c[g.group]=c[g.group]||{},c[g.group][g.binding]=g.name,f[g.name]=g});let p=0;for(const m in s)f[m]||(r[99]||(r[99]=new y0,this._ownedBindGroups.push(r[99])),f[m]={group:99,binding:p,name:m},c[99]=c[99]||{},c[99][p]=m,p++);for(const m in s){const g=m;let x=s[m];!x.source&&!x._resourceType&&(x=new jA(x));const v=f[g];v&&(r[v.group]||(r[v.group]=new y0,this._ownedBindGroups.push(r[v.group])),r[v.group].setResource(x,v.binding))}}this.groups=r,this._uniformBindMap=c,this.resources=this._buildResourceAccessor(r,f)}addResource(t,n,i){var r,s;(r=this._uniformBindMap)[n]||(r[n]={}),(s=this._uniformBindMap[n])[i]||(s[i]=t),this.groups[n]||(this.groups[n]=new y0,this._ownedBindGroups.push(this.groups[n]))}_buildResourceAccessor(t,n){const i={};for(const r in n){const s=n[r];Object.defineProperty(i,s.name,{get(){return t[s.group].getResource(s.binding)},set(l){t[s.group].setResource(l,s.binding)}})}return i}destroy(t=!1){var n,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((n=this.gpuProgram)==null||n.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:n,gl:i,...r}=t;let s,l;return n&&(s=Zm.from(n)),i&&(l=r_.from(i)),new nx({gpuProgram:s,glProgram:l,...r})}}const Pz={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},Ob=0,Db=1,zb=2,Bb=3,Lb=4,jb=5,e1=class IA{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Ob)}set blend(t){!!(this.data&1<<Ob)!==t&&(this.data^=1<<Ob)}get offsets(){return!!(this.data&1<<Db)}set offsets(t){!!(this.data&1<<Db)!==t&&(this.data^=1<<Db)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<zb)}set culling(t){!!(this.data&1<<zb)!==t&&(this.data^=1<<zb)}get depthTest(){return!!(this.data&1<<Bb)}set depthTest(t){!!(this.data&1<<Bb)!==t&&(this.data^=1<<Bb)}get depthMask(){return!!(this.data&1<<jb)}set depthMask(t){!!(this.data&1<<jb)!==t&&(this.data^=1<<jb)}get clockwiseFrontFace(){return!!(this.data&1<<Lb)}set clockwiseFrontFace(t){!!(this.data&1<<Lb)!==t&&(this.data^=1<<Lb)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=Pz[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new IA;return t.depthTest=!1,t.blend=!0,t}};e1.default2d=e1.for2d();let a_=e1;const UA=class t1 extends nx{constructor(t){t={...t1.defaultOptions,...t},super(t),this.enabled=!0,this._state=a_.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,n,i,r){t.applyFilter(this,n,i,r)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:n,gl:i,...r}=t;let s,l;return n&&(s=Zm.from(n)),i&&(l=r_.from(i)),new t1({gpuProgram:s,glProgram:l,...r})}};UA.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Ad=UA;const n1=[];li.handleByNamedList(kt.Environment,n1);async function Fz(e){if(!e)for(let t=0;t<n1.length;t++){const n=n1[t];if(n.value.test()){await n.value.load();return}}}let Jp;function Gz(){if(typeof Jp=="boolean")return Jp;try{Jp=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Jp=!1}return Jp}function ZE(e,t,n=2){const i=t&&t.length,r=i?t[0]*n:e.length;let s=HA(e,0,r,n,!0);const l=[];if(!s||s.next===s.prev)return l;let c,f,p;if(i&&(s=Kz(e,t,s,n)),e.length>80*n){c=e[0],f=e[1];let m=c,g=f;for(let x=n;x<r;x+=n){const v=e[x],S=e[x+1];v<c&&(c=v),S<f&&(f=S),v>m&&(m=v),S>g&&(g=S)}p=Math.max(m-c,g-f),p=p!==0?32767/p:0}return Om(s,l,n,c,f,p,0),l}function HA(e,t,n,i,r){let s;if(r===a5(e,t,n,i)>0)for(let l=t;l<n;l+=i)s=JE(l/i|0,e[l],e[l+1],s);else for(let l=n-i;l>=t;l-=i)s=JE(l/i|0,e[l],e[l+1],s);return s&&uh(s,s.next)&&(zm(s),s=s.next),s}function vd(e,t){if(!e)return e;t||(t=e);let n=e,i;do if(i=!1,!n.steiner&&(uh(n,n.next)||si(n.prev,n,n.next)===0)){if(zm(n),n=t=n.prev,n===n.next)break;i=!0}else n=n.next;while(i||n!==t);return t}function Om(e,t,n,i,r,s,l){if(!e)return;!l&&s&&Jz(e,i,r,s);let c=e;for(;e.prev!==e.next;){const f=e.prev,p=e.next;if(s?Yz(e,i,r,s):qz(e)){t.push(f.i,e.i,p.i),zm(e),e=p.next,c=p.next;continue}if(e=p,e===c){l?l===1?(e=Vz(vd(e),t),Om(e,t,n,i,r,s,2)):l===2&&Xz(e,t,n,i,r,s):Om(vd(e),t,n,i,r,s,1);break}}}function qz(e){const t=e.prev,n=e,i=e.next;if(si(t,n,i)>=0)return!1;const r=t.x,s=n.x,l=i.x,c=t.y,f=n.y,p=i.y,m=Math.min(r,s,l),g=Math.min(c,f,p),x=Math.max(r,s,l),v=Math.max(c,f,p);let S=i.next;for(;S!==t;){if(S.x>=m&&S.x<=x&&S.y>=g&&S.y<=v&&mm(r,c,s,f,l,p,S.x,S.y)&&si(S.prev,S,S.next)>=0)return!1;S=S.next}return!0}function Yz(e,t,n,i){const r=e.prev,s=e,l=e.next;if(si(r,s,l)>=0)return!1;const c=r.x,f=s.x,p=l.x,m=r.y,g=s.y,x=l.y,v=Math.min(c,f,p),S=Math.min(m,g,x),A=Math.max(c,f,p),T=Math.max(m,g,x),C=i1(v,S,t,n,i),N=i1(A,T,t,n,i);let R=e.prevZ,O=e.nextZ;for(;R&&R.z>=C&&O&&O.z<=N;){if(R.x>=v&&R.x<=A&&R.y>=S&&R.y<=T&&R!==r&&R!==l&&mm(c,m,f,g,p,x,R.x,R.y)&&si(R.prev,R,R.next)>=0||(R=R.prevZ,O.x>=v&&O.x<=A&&O.y>=S&&O.y<=T&&O!==r&&O!==l&&mm(c,m,f,g,p,x,O.x,O.y)&&si(O.prev,O,O.next)>=0))return!1;O=O.nextZ}for(;R&&R.z>=C;){if(R.x>=v&&R.x<=A&&R.y>=S&&R.y<=T&&R!==r&&R!==l&&mm(c,m,f,g,p,x,R.x,R.y)&&si(R.prev,R,R.next)>=0)return!1;R=R.prevZ}for(;O&&O.z<=N;){if(O.x>=v&&O.x<=A&&O.y>=S&&O.y<=T&&O!==r&&O!==l&&mm(c,m,f,g,p,x,O.x,O.y)&&si(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function Vz(e,t){let n=e;do{const i=n.prev,r=n.next.next;!uh(i,r)&&FA(i,n,n.next,r)&&Dm(i,r)&&Dm(r,i)&&(t.push(i.i,n.i,r.i),zm(n),zm(n.next),n=e=r),n=n.next}while(n!==e);return vd(n)}function Xz(e,t,n,i,r,s){let l=e;do{let c=l.next.next;for(;c!==l.prev;){if(l.i!==c.i&&n5(l,c)){let f=GA(l,c);l=vd(l,l.next),f=vd(f,f.next),Om(l,t,n,i,r,s,0),Om(f,t,n,i,r,s,0);return}c=c.next}l=l.next}while(l!==e)}function Kz(e,t,n,i){const r=[];for(let s=0,l=t.length;s<l;s++){const c=t[s]*i,f=s<l-1?t[s+1]*i:e.length,p=HA(e,c,f,i,!1);p===p.next&&(p.steiner=!0),r.push(t5(p))}r.sort($z);for(let s=0;s<r.length;s++)n=Wz(r[s],n);return n}function $z(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){const i=(e.next.y-e.y)/(e.next.x-e.x),r=(t.next.y-t.y)/(t.next.x-t.x);n=i-r}return n}function Wz(e,t){const n=Qz(e,t);if(!n)return t;const i=GA(n,e);return vd(i,i.next),vd(n,n.next)}function Qz(e,t){let n=t;const i=e.x,r=e.y;let s=-1/0,l;if(uh(e,n))return n;do{if(uh(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const g=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(g<=i&&g>s&&(s=g,l=n.x<n.next.x?n:n.next,g===i))return l}n=n.next}while(n!==t);if(!l)return null;const c=l,f=l.x,p=l.y;let m=1/0;n=l;do{if(i>=n.x&&n.x>=f&&i!==n.x&&PA(r<p?i:s,r,f,p,r<p?s:i,r,n.x,n.y)){const g=Math.abs(r-n.y)/(i-n.x);Dm(n,e)&&(g<m||g===m&&(n.x>l.x||n.x===l.x&&Zz(l,n)))&&(l=n,m=g)}n=n.next}while(n!==c);return l}function Zz(e,t){return si(e.prev,e,t.prev)<0&&si(t.next,e,e.next)<0}function Jz(e,t,n,i){let r=e;do r.z===0&&(r.z=i1(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,e5(r)}function e5(e){let t,n=1;do{let i=e,r;e=null;let s=null;for(t=0;i;){t++;let l=i,c=0;for(let p=0;p<n&&(c++,l=l.nextZ,!!l);p++);let f=n;for(;c>0||f>0&&l;)c!==0&&(f===0||!l||i.z<=l.z)?(r=i,i=i.nextZ,c--):(r=l,l=l.nextZ,f--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;i=l}s.nextZ=null,n*=2}while(t>1);return e}function i1(e,t,n,i,r){return e=(e-n)*r|0,t=(t-i)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function t5(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function PA(e,t,n,i,r,s,l,c){return(r-l)*(t-c)>=(e-l)*(s-c)&&(e-l)*(i-c)>=(n-l)*(t-c)&&(n-l)*(s-c)>=(r-l)*(i-c)}function mm(e,t,n,i,r,s,l,c){return!(e===l&&t===c)&&PA(e,t,n,i,r,s,l,c)}function n5(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!i5(e,t)&&(Dm(e,t)&&Dm(t,e)&&r5(e,t)&&(si(e.prev,e,t.prev)||si(e,t.prev,t))||uh(e,t)&&si(e.prev,e,e.next)>0&&si(t.prev,t,t.next)>0)}function si(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function uh(e,t){return e.x===t.x&&e.y===t.y}function FA(e,t,n,i){const r=Iy(si(e,t,n)),s=Iy(si(e,t,i)),l=Iy(si(n,i,e)),c=Iy(si(n,i,t));return!!(r!==s&&l!==c||r===0&&jy(e,n,t)||s===0&&jy(e,i,t)||l===0&&jy(n,e,i)||c===0&&jy(n,t,i))}function jy(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Iy(e){return e>0?1:e<0?-1:0}function i5(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&FA(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Dm(e,t){return si(e.prev,e,e.next)<0?si(e,t,e.next)>=0&&si(e,e.prev,t)>=0:si(e,t,e.prev)<0||si(e,e.next,t)<0}function r5(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next;while(n!==e);return i}function GA(e,t){const n=r1(e.i,e.x,e.y),i=r1(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function JE(e,t,n,i){const r=r1(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function zm(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function r1(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function a5(e,t,n,i){let r=0;for(let s=t,l=n-i;s<n;s+=i)r+=(e[l]-e[s])*(e[s+1]+e[l+1]),l=s;return r}const s5=ZE.default||ZE;var qA=(e=>(e[e.NONE=0]="NONE",e[e.COLOR=16384]="COLOR",e[e.STENCIL=1024]="STENCIL",e[e.DEPTH=256]="DEPTH",e[e.COLOR_DEPTH=16640]="COLOR_DEPTH",e[e.COLOR_STENCIL=17408]="COLOR_STENCIL",e[e.DEPTH_STENCIL=1280]="DEPTH_STENCIL",e[e.ALL=17664]="ALL",e))(qA||{});class l5{constructor(t){this.items=[],this._name=t}emit(t,n,i,r,s,l,c,f){const{name:p,items:m}=this;for(let g=0,x=m.length;g<x;g++)m[g][p](t,n,i,r,s,l,c,f);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const n=this.items.indexOf(t);return n!==-1&&this.items.splice(n,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const o5=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],YA=class VA extends yo{constructor(t){super(),this.tick=0,this.uid=bi("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const n=[...o5,...this.config.runners??[]];this._addRunners(...n),this._unsafeEvalCheck()}async init(t={}){const n=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Fz(n),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)t={...this._systemsHash[i].constructor.defaultOptions,...t};t={...VA.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,n){this.tick++;let i=t;if(i instanceof _r&&(i={container:i},n&&(en(xi,"passing a second argument is deprecated, please use render options instead"),i.target=n.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const r=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=r?i.clearColor:qi.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i))}resize(t,n,i){const r=this.view.resolution;this.view.resize(t,n,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==r&&this.runners.resolutionChange.emit(i)}clear(t={}){const n=this;t.target||(t.target=n.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=qA.ALL);const{clear:i,clearColor:r,target:s,mipLevel:l,layer:c}=t;qi.shared.setValue(r??this.background.colorRgba),n.renderTarget.clear(s,i,qi.shared.toArray(),l??0,c??0)}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(n=>{this.runners[n]=new l5(n)})}_addSystems(t){let n;for(n in t){const i=t[n];this._addSystem(i.value,i.name)}}_addSystem(t,n){const i=new t(this);if(this[n])throw new Error(`Whoops! The name "${n}" is already in use`);this[n]=i,this._systemsHash[n]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,n){const i=n.reduce((r,s)=>(r[s.name]=s.value,r),{});t.forEach(r=>{const s=r.value,l=r.name,c=i[l];this.renderPipes[l]=new s(this,c?new c:null),this.runners.destroy.add(this.renderPipes[l])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&Qm.release(),Object.values(this.runners).forEach(n=>{n.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Gz())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};YA.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let XA=YA,Uy;function c5(e){return Uy!==void 0||(Uy=(()=>{var n;const t={stencil:!0,failIfMajorPerformanceCaveat:e??XA.defaultOptions.failIfMajorPerformanceCaveat};try{if(!is.get().getWebGLRenderingContext())return!1;let r=is.get().createCanvas().getContext("webgl",t);const s=!!((n=r==null?void 0:r.getContextAttributes())!=null&&n.stencil);if(r){const l=r.getExtension("WEBGL_lose_context");l&&l.loseContext()}return r=null,s}catch{return!1}})()),Uy}let Hy;async function u5(e={}){return Hy!==void 0||(Hy=await(async()=>{const t=is.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(e)).requestDevice(),!0}catch{return!1}})()),Hy}const ew=["webgl","webgpu","canvas"];async function d5(e){let t=[];e.preference?(t.push(e.preference),ew.forEach(s=>{s!==e.preference&&t.push(s)})):t=ew.slice();let n,i={};for(let s=0;s<t.length;s++){const l=t[s];if(l==="webgpu"&&await u5()){const{WebGPURenderer:c}=await ou(async()=>{const{WebGPURenderer:f}=await import("./WebGPURenderer-Bg-RJB1D.js");return{WebGPURenderer:f}},__vite__mapDeps([4,5,6]));n=c,i={...e,...e.webgpu};break}else if(l==="webgl"&&c5(e.failIfMajorPerformanceCaveat??XA.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:c}=await ou(async()=>{const{WebGLRenderer:f}=await import("./WebGLRenderer-DnjjNW5h.js");return{WebGLRenderer:f}},__vite__mapDeps([7,5,6]));n=c,i={...e,...e.webgl};break}else if(l==="canvas"){const{CanvasRenderer:c}=await ou(async()=>{const{CanvasRenderer:f}=await import("./CanvasRenderer-hkP-z9TW.js");return{CanvasRenderer:f}},__vite__mapDeps([8,6]));n=c,i={...e,...e.canvasOptions};break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!n)throw new Error("No available renderer for the current environment");const r=new n;return await r.init(i),r}const KA="8.17.0";class $A{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,KA)}static destroy(){}}$A.extension=kt.Application;class f5{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,KA)}destroy(){this._renderer=null}}f5.extension={type:[kt.WebGLSystem,kt.WebGPUSystem],name:"initHook",priority:-10};class WA{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(n){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=n,n&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let n,i;if(this._resizeTo===globalThis.window)n=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:s}=this._resizeTo;n=r,i=s}this.renderer.resize(n,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}WA.extension=kt.Application;class QA{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(n){this._ticker&&this._ticker.remove(this.render,this),this._ticker=n,n&&n.add(this.render,this,M0.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Wf.shared:new Wf,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}QA.extension=kt.Application;li.add(WA);li.add(QA);const ZA=class a1{constructor(...t){this.stage=new _r,t[0]!==void 0&&en(xi,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new _r),this.renderer=await d5(t),a1._plugins.forEach(n=>{n.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return en(xi,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,n=!1){const i=a1._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(n),this.stage=null,this.renderer.destroy(t),this.renderer=null}};ZA._plugins=[];let s_=ZA;li.handleByList(kt.Application,s_._plugins);li.add($A);var Ib,tw;function h5(){if(tw)return Ib;tw=1,Ib=n;var e={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function n(s){var l=[];return s.replace(t,function(c,f,p){var m=f.toLowerCase();for(p=r(p),m=="m"&&p.length>2&&(l.push([f].concat(p.splice(0,2))),m="l",f=f=="m"?"l":"L");;){if(p.length==e[m])return p.unshift(f),l.push(p);if(p.length<e[m])throw new Error("malformed path data");l.push([f].concat(p.splice(0,e[m])))}}),l}var i=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function r(s){var l=s.match(i);return l?l.map(Number):[]}return Ib}var p5=h5();const m5=du(p5);function g5(e,t){const n=m5(e),i=[];let r=null,s=0,l=0;for(let c=0;c<n.length;c++){const f=n[c],p=f[0],m=f;switch(p){case"M":s=m[1],l=m[2],t.moveTo(s,l);break;case"m":s+=m[1],l+=m[2],t.moveTo(s,l);break;case"H":s=m[1],t.lineTo(s,l);break;case"h":s+=m[1],t.lineTo(s,l);break;case"V":l=m[1],t.lineTo(s,l);break;case"v":l+=m[1],t.lineTo(s,l);break;case"L":s=m[1],l=m[2],t.lineTo(s,l);break;case"l":s+=m[1],l+=m[2],t.lineTo(s,l);break;case"C":s=m[5],l=m[6],t.bezierCurveTo(m[1],m[2],m[3],m[4],s,l);break;case"c":t.bezierCurveTo(s+m[1],l+m[2],s+m[3],l+m[4],s+m[5],l+m[6]),s+=m[5],l+=m[6];break;case"S":s=m[3],l=m[4],t.bezierCurveToShort(m[1],m[2],s,l);break;case"s":t.bezierCurveToShort(s+m[1],l+m[2],s+m[3],l+m[4]),s+=m[3],l+=m[4];break;case"Q":s=m[3],l=m[4],t.quadraticCurveTo(m[1],m[2],s,l);break;case"q":t.quadraticCurveTo(s+m[1],l+m[2],s+m[3],l+m[4]),s+=m[3],l+=m[4];break;case"T":s=m[1],l=m[2],t.quadraticCurveToShort(s,l);break;case"t":s+=m[1],l+=m[2],t.quadraticCurveToShort(s,l);break;case"A":s=m[6],l=m[7],t.arcToSvg(m[1],m[2],m[3],m[4],m[5],s,l);break;case"a":s+=m[6],l+=m[7],t.arcToSvg(m[1],m[2],m[3],m[4],m[5],s,l);break;case"Z":case"z":t.closePath(),i.length>0&&(r=i.pop(),r?(s=r.startX,l=r.startY):(s=0,l=0)),r=null;break;default:ma(`Unknown SVG path command: ${p}`)}p!=="Z"&&p!=="z"&&r===null&&(r={startX:s,startY:l},i.push(r))}return t}class l_{constructor(t=0,n=0,i=0){this.type="circle",this.x=t,this.y=n,this.radius=i}clone(){return new l_(this.x,this.y,this.radius)}contains(t,n){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,s=this.y-n;return r*=r,s*=s,r+s<=i}strokeContains(t,n,i,r=.5){if(this.radius===0)return!1;const s=this.x-t,l=this.y-n,c=this.radius,f=(1-r)*i,p=Math.sqrt(s*s+l*l);return p<=c+f&&p>c-(i-f)}getBounds(t){return t||(t=new Ti),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class o_{constructor(t=0,n=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=n,this.halfWidth=i,this.halfHeight=r}clone(){return new o_(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,n){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(n-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,n,i,r=.5){const{halfWidth:s,halfHeight:l}=this;if(s<=0||l<=0)return!1;const c=i*(1-r),f=i-c,p=s-f,m=l-f,g=s+c,x=l+c,v=t-this.x,S=n-this.y,A=v*v/(p*p)+S*S/(m*m),T=v*v/(g*g)+S*S/(x*x);return A>1&&T<=1}getBounds(t){return t||(t=new Ti),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function y5(e,t,n,i,r,s){const l=e-n,c=t-i,f=r-n,p=s-i,m=l*f+c*p,g=f*f+p*p;let x=-1;g!==0&&(x=m/g);let v,S;x<0?(v=n,S=i):x>1?(v=r,S=s):(v=n+x*f,S=i+x*p);const A=e-v,T=t-S;return A*A+T*T}let x5,b5;class Sm{constructor(...t){this.type="polygon";let n=Array.isArray(t[0])?t[0]:t;if(typeof n[0]!="number"){const i=[];for(let r=0,s=n.length;r<s;r++)i.push(n[r].x,n[r].y);n=i}this.points=n,this.closePath=!0}isClockwise(){let t=0;const n=this.points,i=n.length;for(let r=0;r<i;r+=2){const s=n[r],l=n[r+1],c=n[(r+2)%i],f=n[(r+3)%i];t+=(c-s)*(f+l)}return t<0}containsPolygon(t){const n=this.getBounds(x5),i=t.getBounds(b5);if(!n.containsRect(i))return!1;const r=t.points;for(let s=0;s<r.length;s+=2){const l=r[s],c=r[s+1];if(!this.contains(l,c))return!1}return!0}clone(){const t=this.points.slice(),n=new Sm(t);return n.closePath=this.closePath,n}contains(t,n){let i=!1;const r=this.points.length/2;for(let s=0,l=r-1;s<r;l=s++){const c=this.points[s*2],f=this.points[s*2+1],p=this.points[l*2],m=this.points[l*2+1];f>n!=m>n&&t<(p-c)*((n-f)/(m-f))+c&&(i=!i)}return i}strokeContains(t,n,i,r=.5){const s=i*i,l=s*(1-r),c=s-l,{points:f}=this,p=f.length-(this.closePath?0:2);for(let m=0;m<p;m+=2){const g=f[m],x=f[m+1],v=f[(m+2)%f.length],S=f[(m+3)%f.length],A=y5(t,n,g,x,v,S),T=Math.sign((v-g)*(n-x)-(S-x)*(t-g));if(A<=(T<0?c:l))return!0}return!1}getBounds(t){t||(t=new Ti);const n=this.points;let i=1/0,r=-1/0,s=1/0,l=-1/0;for(let c=0,f=n.length;c<f;c+=2){const p=n[c],m=n[c+1];i=p<i?p:i,r=p>r?p:r,s=m<s?m:s,l=m>l?m:l}return t.x=i,t.width=r-i,t.y=s,t.height=l-s,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,n)=>`${t}, ${n}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return en("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return en("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Py=(e,t,n,i,r,s,l)=>{const c=e-n,f=t-i,p=Math.sqrt(c*c+f*f);return p>=r-s&&p<=r+l};class c_{constructor(t=0,n=0,i=0,r=0,s=20){this.type="roundedRectangle",this.x=t,this.y=n,this.width=i,this.height=r,this.radius=s}getBounds(t){return t||(t=new Ti),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new c_(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,n){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&n>=this.y&&n<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(n>=this.y+i&&n<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),s=n-(this.y+i);const l=i*i;if(r*r+s*s<=l||(r=t-(this.x+this.width-i),r*r+s*s<=l)||(s=n-(this.y+this.height-i),r*r+s*s<=l)||(r=t-(this.x+i),r*r+s*s<=l))return!0}return!1}strokeContains(t,n,i,r=.5){const{x:s,y:l,width:c,height:f,radius:p}=this,m=i*(1-r),g=i-m,x=s+p,v=l+p,S=c-p*2,A=f-p*2,T=s+c,C=l+f;return(t>=s-m&&t<=s+g||t>=T-g&&t<=T+m)&&n>=v&&n<=v+A||(n>=l-m&&n<=l+g||n>=C-g&&n<=C+m)&&t>=x&&t<=x+S?!0:t<x&&n<v&&Py(t,n,x,v,p,g,m)||t>T-p&&n<v&&Py(t,n,T-p,v,p,g,m)||t>T-p&&n>C-p&&Py(t,n,T-p,C-p,p,g,m)||t<x&&n>C-p&&Py(t,n,x,C-p,p,g,m)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const JA={};function v5(e,t,n){let i=2166136261;for(let r=0;r<t;r++)i^=e[r].uid,i=Math.imul(i,16777619),i>>>=0;return JA[i]||_5(e,t,i,n)}function _5(e,t,n,i){const r={};let s=0;for(let c=0;c<i;c++){const f=c<t?e[c]:Mn.EMPTY.source;r[s++]=f.source,r[s++]=f.style}const l=new y0(r);return JA[n]=l,l}class nw{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function iw(e,t,n,i){if(n??(n=0),i??(i=Math.min(e.byteLength-n,t.byteLength)),!(n&7)&&!(i&7)){const r=i/8;new Float64Array(t,0,r).set(new Float64Array(e,n,r))}else if(!(n&3)&&!(i&3)){const r=i/4;new Float32Array(t,0,r).set(new Float32Array(e,n,r))}else new Uint8Array(t).set(new Uint8Array(e,n,i))}const S5={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var E5=(e=>(e[e.DISABLED=0]="DISABLED",e[e.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",e[e.MASK_ACTIVE=2]="MASK_ACTIVE",e[e.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",e[e.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",e[e.NONE=5]="NONE",e))(E5||{});function rw(e,t){return t.alphaMode==="no-premultiply-alpha"&&S5[e]||e}const w5=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
83
83
|
`);function T5(e){let t="";for(let n=0;n<e;++n)n>0&&(t+=`
|
|
84
84
|
else `),n<e-1&&(t+=`if(test == ${n}.0){}`);return t}function C5(e,t){if(e===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const n=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=w5.replace(/%forloop%/gi,T5(e));if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))e=e/2|0;else break}}finally{t.deleteShader(n)}return e}let Bf=null;function A5(){var t;if(Bf)return Bf;const e=OA();return Bf=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),Bf=C5(Bf,e),(t=e.getExtension("WEBGL_lose_context"))==null||t.loseContext(),Bf}class M5{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const n=this.textures[t];this.textures[t]=null,this.ids[n.uid]=null}this.count=0}}class R5{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new M5,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const Em=[];let R0=0;Qm.register({clear:()=>{if(Em.length>0)for(const e of Em)e&&e.destroy();Em.length=0,R0=0}});function aw(){return R0>0?Em[--R0]:new R5}function sw(e){e.elements=null,Em[R0++]=e}let em=0;const eM=class tM{constructor(t){this.uid=bi("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...tM.defaultOptions,...t},t.maxTextures||(en("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=A5());const{maxTextures:n,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new nw(i*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=n}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)sw(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,n){const i=t._batch.textures.ids[n._source.uid];return!i&&i!==0?!1:(t._textureId=i,t.texture=n,!0)}updateElement(t){this.dirty=!0;const n=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,n.float32View,n.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,n.float32View,n.uint32View,t._attributeStart,t._textureId)}break(t){const n=this._elements;if(!n[this.elementStart])return;let i=aw(),r=i.textures;r.clear();const s=n[this.elementStart];let l=rw(s.blendMode,s.texture._source),c=s.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const f=this.attributeBuffer.float32View,p=this.attributeBuffer.uint32View,m=this.indexBuffer;let g=this._batchIndexSize,x=this._batchIndexStart,v="startBatch",S=[];const A=this.maxTextures;for(let T=this.elementStart;T<this.elementSize;++T){const C=n[T];n[T]=null;const R=C.texture._source,O=rw(C.blendMode,R),H=l!==O||c!==C.topology;if(R._batchTick===em&&!H){C._textureId=R._textureBindLocation,g+=C.indexSize,C.packAsQuad?(this.packQuadAttributes(C,f,p,C._attributeStart,C._textureId),this.packQuadIndex(m,C._indexStart,C._attributeStart/this.vertexSize)):(this.packAttributes(C,f,p,C._attributeStart,C._textureId),this.packIndex(C,m,C._indexStart,C._attributeStart/this.vertexSize)),C._batch=i,S.push(C);continue}R._batchTick=em,(r.count>=A||H)&&(this._finishBatch(i,x,g-x,r,l,c,t,v,S),v="renderBatch",x=g,l=O,c=C.topology,i=aw(),r=i.textures,r.clear(),S=[],++em),C._textureId=R._textureBindLocation=r.count,r.ids[R.uid]=r.count,r.textures[r.count++]=R,C._batch=i,S.push(C),g+=C.indexSize,C.packAsQuad?(this.packQuadAttributes(C,f,p,C._attributeStart,C._textureId),this.packQuadIndex(m,C._indexStart,C._attributeStart/this.vertexSize)):(this.packAttributes(C,f,p,C._attributeStart,C._textureId),this.packIndex(C,m,C._indexStart,C._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,x,g-x,r,l,c,t,v,S),x=g,++em),this.elementStart=this.elementSize,this._batchIndexStart=x,this._batchIndexSize=g}_finishBatch(t,n,i,r,s,l,c,f,p){t.gpuBindGroup=null,t.bindGroup=null,t.action=f,t.batcher=this,t.textures=r,t.blendMode=s,t.topology=l,t.start=n,t.size=i,t.elements=p,++em,this.batches[this.batchIndex++]=t,c.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const n=Math.max(t,this.attributeBuffer.size*2),i=new nw(n);iw(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const n=this.indexBuffer;let i=Math.max(t,n.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==n.BYTES_PER_ELEMENT)for(let s=0;s<n.length;s++)r[s]=n[s];else iw(n.buffer,r.buffer);this.indexBuffer=r}packQuadIndex(t,n,i){t[n]=i+0,t[n+1]=i+1,t[n+2]=i+2,t[n+3]=i+0,t[n+4]=i+2,t[n+5]=i+3}packIndex(t,n,i,r){const s=t.indices,l=t.indexSize,c=t.indexOffset,f=t.attributeOffset;for(let p=0;p<l;p++)n[i++]=r+s[p+c]-f}destroy(t={}){var n;if(this.batches!==null){for(let i=0;i<this.batchIndex;i++)sw(this.batches[i]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((n=this.shader)==null||n.destroy(),this.shader=null);for(let i=0;i<this._elements.length;i++)this._elements[i]&&(this._elements[i]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};eM.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let k5=eM;var ka=(e=>(e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE",e[e.STATIC=1024]="STATIC",e))(ka||{});class Bm extends yo{constructor(t){let{data:n,size:i}=t;const{usage:r,label:s,shrinkToFit:l}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=bi("buffer"),this._resourceType="buffer",this._resourceId=bi("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,n instanceof Array&&(n=new Float32Array(n)),this._data=n,i??(i=n==null?void 0:n.byteLength);const c=!!n;this.descriptor={size:i,usage:r,mappedAtCreation:c,label:s},this.shrinkToFit=l??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&ka.STATIC)}set static(t){t?this.descriptor.usage|=ka.STATIC:this.descriptor.usage&=~ka.STATIC}setDataWithSize(t,n,i){if(this._updateID++,this._updateSize=n*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,this._dataInt32=null,!r||r.length!==t.length){!this.shrinkToFit&&r&&t.byteLength<r.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=bi("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}unload(){var t;this.emit("unload",this);for(const n in this._gpuData)(t=this._gpuData[n])==null||t.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function nM(e,t){if(!(e instanceof Bm)){let n=t?ka.INDEX:ka.VERTEX;e instanceof Array&&(t?(e=new Uint32Array(e),n=ka.INDEX|ka.COPY_DST):(e=new Float32Array(e),n=ka.VERTEX|ka.COPY_DST)),e=new Bm({data:e,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:n})}return e}function N5(e,t,n){const i=e.getAttribute(t);if(!i)return n.minX=0,n.minY=0,n.maxX=0,n.maxY=0,n;const r=i.buffer.data;let s=1/0,l=1/0,c=-1/0,f=-1/0;const p=r.BYTES_PER_ELEMENT,m=(i.offset||0)/p,g=(i.stride||8)/p;for(let x=m;x<r.length;x+=g){const v=r[x],S=r[x+1];v>c&&(c=v),S>f&&(f=S),v<s&&(s=v),S<l&&(l=S)}return n.minX=s,n.minY=l,n.maxX=c,n.maxY=f,n}function O5(e){return(e instanceof Bm||Array.isArray(e)||e.BYTES_PER_ELEMENT)&&(e={buffer:e}),e.buffer=nM(e.buffer,!1),e}class D5 extends yo{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=bi("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new js,this._boundsDirty=!0;const{attributes:n,indexBuffer:i,topology:r}=t;if(this.buffers=[],this.attributes={},n)for(const s in n)this.addAttribute(s,n[s]);this.instanceCount=t.instanceCount??1,i&&this.addIndex(i),this.topology=r||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const n=this.attributes[t];return n.buffer.data.length/(n.stride/4||n.size)}return 0}addAttribute(t,n){const i=O5(n);this.buffers.indexOf(i.buffer)===-1&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=nM(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,N5(this,"aPosition",this._bounds)):this._bounds}unload(){var t;this.emit("unload",this);for(const n in this._gpuData)(t=this._gpuData[n])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){var n;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(i=>i.destroy()),this.unload(),(n=this.indexBuffer)==null||n.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const z5=new Float32Array(1),B5=new Uint32Array(1);class L5 extends D5{constructor(){const n=new Bm({data:z5,label:"attribute-batch-buffer",usage:ka.VERTEX|ka.COPY_DST,shrinkToFit:!1}),i=new Bm({data:B5,label:"index-batch-buffer",usage:ka.INDEX|ka.COPY_DST,shrinkToFit:!1}),r=24;super({attributes:{aPosition:{buffer:n,format:"float32x2",stride:r,offset:0},aUV:{buffer:n,format:"float32x2",stride:r,offset:8},aColor:{buffer:n,format:"unorm8x4",stride:r,offset:16},aTextureIdAndRound:{buffer:n,format:"uint16x2",stride:r,offset:20}},indexBuffer:i})}}function lw(e,t,n){if(e)for(const i in e){const r=i.toLocaleLowerCase(),s=t[r];if(s){let l=e[i];i==="header"&&(l=l.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),n&&s.push(`//----${n}----//`),s.push(l)}else ma(`${i} placement hook does not exist in shader`)}}const j5=/\{\{(.*?)\}\}/g;function ow(e){var i;const t={};return(((i=e.match(j5))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function cw(e,t){let n;const i=/@in\s+([^;]+);/g;for(;(n=i.exec(e))!==null;)t.push(n[1])}function uw(e,t,n=!1){const i=[];cw(t,i),e.forEach(c=>{c.header&&cw(c.header,i)});const r=i;n&&r.sort();const s=r.map((c,f)=>` @location(${f}) ${c},`).join(`
|
|
85
85
|
`);let l=t.replace(/@in\s+[^;]+;\s*/g,"");return l=l.replace("{{in}}",`
|
|
@@ -375,7 +375,7 @@ No matching component was found for:
|
|
|
375
375
|
`},p]}}const WP=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),QP=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],ZP=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],JP=[...QP,...ZP],eF=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),WR=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),QR=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),tF=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),nF=WR.concat(QR).sort().reverse();function iF(e){const t=WP(e),n=nF,i="and or not only",r="[\\w-]+",s="("+r+"|@\\{"+r+"\\})",l=[],c=[],f=function(R){return{className:"string",begin:"~?"+R+".*?"+R}},p=function(R,O,H){return{className:R,begin:O,relevance:H}},m={$pattern:/[a-z-]+/,keyword:i,attribute:eF.join(" ")},g={begin:"\\(",end:"\\)",contains:c,keywords:m,relevance:0};c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,f("'"),f('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,g,p("variable","@@?"+r,10),p("variable","@\\{"+r+"\\}"),p("built_in","~?`[^`]*?`"),{className:"attribute",begin:r+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const x=c.concat({begin:/\{/,end:/\}/,contains:l}),v={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(c)},S={begin:s+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+tF.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:c}}]},A={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:m,returnEnd:!0,contains:c,relevance:0}},T={className:"variable",variants:[{begin:"@"+r+"\\s*:",relevance:15},{begin:"@"+r}],starts:{end:"[;}]",returnEnd:!0,contains:x}},C={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:s,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,v,p("keyword","all\\b"),p("variable","@\\{"+r+"\\}"),{begin:"\\b("+JP.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,p("selector-tag",s,0),p("selector-id","#"+s),p("selector-class","\\."+s,0),p("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+WR.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+QR.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:x},{begin:"!important"},t.FUNCTION_DISPATCH]},N={begin:r+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[C]};return l.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,A,T,N,S,C,v,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:l}}function rF(e){const t="\\[=*\\[",n="\\]=*\\]",i={begin:t,end:n,contains:["self"]},r=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[i],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:r.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:r}].concat(r)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[i],relevance:5}])}}function aF(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},i={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},r={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},s={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},l={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,i,r,s,l]}}function sF(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},i={begin:"^[-\\*]{3,}",end:"$"},r={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,f={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},p={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},m={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(p,{contains:[]}),x=e.inherit(m,{contains:[]});p.contains.push(x),m.contains.push(g);let v=[n,f];return[p,m,g,x].forEach(C=>{C.contains=C.contains.concat(v)}),v=v.concat(p,m),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:v},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:v}]}]},n,s,p,m,{className:"quote",begin:"^>\\s+",contains:v,end:"$"},r,i,f,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function lF(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,c={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},f={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:c,illegal:"</",contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+f.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:f,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function oF(e){const t=e.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],i=/[dualxmsipngr]{0,12}/,r={$pattern:/[\w.]+/,keyword:n.join(" ")},s={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:r},l={begin:/->\{/,end:/\}/},c={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},f={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[c]},p={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},m=[e.BACKSLASH_ESCAPE,s,f],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],x=(A,T,C="\\1")=>{const N=C==="\\1"?C:t.concat(C,T);return t.concat(t.concat("(?:",A,")"),T,/(?:\\.|[^\\\/])*?/,N,/(?:\\.|[^\\\/])*?/,C,i)},v=(A,T,C)=>t.concat(t.concat("(?:",A,")"),T,/(?:\\.|[^\\\/])*?/,C,i),S=[f,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),l,{className:"string",contains:m,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},p,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:x("s|tr|y",t.either(...g,{capture:!0}))},{begin:x("s|tr|y","\\(","\\)")},{begin:x("s|tr|y","\\[","\\]")},{begin:x("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:v("(?:m|qr)?",/\//,/\//)},{begin:v("m|qr",t.either(...g,{capture:!0}),/\1/)},{begin:v("m|qr",/\(/,/\)/)},{begin:v("m|qr",/\[/,/\]/)},{begin:v("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,c]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,c,p]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return s.contains=S,l.contains=S,{name:"Perl",aliases:["pl","pm"],keywords:r,contains:S}}function cF(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,i=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),r=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),s=t.concat(/[A-Z]+/,n),l={scope:"variable",match:"\\$+"+i},c={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},f={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},p=e.inherit(e.APOS_STRING_MODE,{illegal:null}),m=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(f)}),g={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(f),"on:begin":(I,$)=>{$.data._beginMatch=I[1]||I[2]},"on:end":(I,$)=>{$.data._beginMatch!==I[1]&&$.ignoreMatch()}},x=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),v=`[
|
|
376
376
|
]`,S={scope:"string",variants:[m,p,g,x]},A={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},T=["false","null","true"],C=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],N=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],O={keyword:C,literal:(I=>{const $=[];return I.forEach(z=>{$.push(z),z.toLowerCase()===z?$.push(z.toUpperCase()):$.push(z.toLowerCase())}),$})(T),built_in:N},H=I=>I.map($=>$.replace(/\|\d+$/,"")),D={variants:[{match:[/new/,t.concat(v,"+"),t.concat("(?!",H(N).join("\\b|"),"\\b)"),r],scope:{1:"keyword",4:"title.class"}}]},F=t.concat(i,"\\b(?!\\()"),Z={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),F],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[r,t.concat(/::/,t.lookahead(/(?!class\b)/)),F],scope:{1:"title.class",3:"variable.constant"}},{match:[r,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[r,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},V={scope:"attr",match:t.concat(i,t.lookahead(":"),t.lookahead(/(?!::)/))},Y={relevance:0,begin:/\(/,end:/\)/,keywords:O,contains:[V,l,Z,e.C_BLOCK_COMMENT_MODE,S,A,D]},P={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",H(C).join("\\b|"),"|",H(N).join("\\b|"),"\\b)"),i,t.concat(v,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[Y]};Y.contains.push(P);const q=[V,Z,e.C_BLOCK_COMMENT_MODE,S,A,D],ne={begin:t.concat(/#\[\s*\\?/,t.either(r,s)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:T,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:T,keyword:["new","array"]},contains:["self",...q]},...q,{scope:"meta",variants:[{match:r},{match:s}]}]};return{case_insensitive:!1,keywords:O,contains:[ne,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},c,{scope:"variable.language",match:/\$this\b/},l,P,Z,{match:[/const/,/\s/,i],scope:{1:"keyword",3:"variable.constant"}},D,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:O,contains:["self",ne,l,Z,e.C_BLOCK_COMMENT_MODE,S,A]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},S,A]}}function uF(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function dF(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function fF(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),i=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:i,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},f={className:"meta",begin:/^(>>>|\.\.\.) /},p={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},m={begin:/\{\{/,relevance:0},g={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,f],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,f],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,f,m,p]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,f,m,p]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,m,p]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,m,p]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},x="[0-9](_?[0-9])*",v=`(\\b(${x}))?\\.(${x})|\\b(${x})\\.`,S=`\\b|${i.join("|")}`,A={className:"number",relevance:0,variants:[{begin:`(\\b(${x})|(${v}))[eE][+-]?(${x})[jJ]?(?=${S})`},{begin:`(${v})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${S})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${S})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${S})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${S})`},{begin:`\\b(${x})[jJ](?=${S})`}]},T={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},C={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",f,A,g,e.HASH_COMMENT_MODE]}]};return p.contains=[g,A,f],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[f,A,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,T,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[C]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[A,C,g]}]}}function hF(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function pF(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,i=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),r=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[r,i]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,i]},{scope:{1:"punctuation",2:"number"},match:[s,i]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,i]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:r},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function mF(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",i=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),r=t.concat(i,/(::\w+)*/),l={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},c={className:"doctag",begin:"@[A-Za-z]+"},f={begin:"#<",end:">"},p=[e.COMMENT("#","$",{contains:[c]}),e.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],m={className:"subst",begin:/#\{/,end:/\}/,keywords:l},g={className:"string",contains:[e.BACKSLASH_ESCAPE,m],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,m]})]}]},x="[1-9](_?[0-9])*|0",v="[0-9](_?[0-9])*",S={className:"number",relevance:0,variants:[{begin:`\\b(${x})(\\.(${v}))?([eE][+-]?(${v})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},A={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:l}]},D=[g,{variants:[{match:[/class\s+/,r,/\s+<\s+/,r]},{match:[/\b(class|module)\s+/,r]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:l},{match:[/(include|extend)\s+/,r],scope:{2:"title.class"},keywords:l},{relevance:0,match:[r,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:i,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[A]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[g,{begin:n}],relevance:0},S,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:l},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,m],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(f,p),relevance:0}].concat(f,p);m.contains=D,A.contains=D;const Y=[{begin:/^\s*=>/,starts:{end:"$",contains:D}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:l,contains:D}}];return p.unshift(f),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:l,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(Y).concat(p).concat(D)}}function gF(e){const t=e.regex,n=/(r#)?/,i=t.concat(n,e.UNDERSCORE_IDENT_RE),r=t.concat(n,e.IDENT_RE),s={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,r,t.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(32|64))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],f=["true","false","Some","None","Ok","Err"],p=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],m=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:m,keyword:c,literal:f,built_in:p},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/fn/,/\s+/,i],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,i],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,i,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,i],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,i],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:p,type:m}},{className:"punctuation",begin:"->"},s]}}const yF=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),xF=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],bF=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],vF=[...xF,...bF],_F=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),SF=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),EF=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),wF=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function TF(e){const t=yF(e),n=EF,i=SF,r="@[a-z-]+",s="and or not only",c={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+vF.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+i.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},c,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+wF.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,c,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:r,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:_F.join(" ")},contains:[{begin:r,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},c,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function CF(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function AF(e){const t=e.regex,n=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},r={begin:/"/,end:/"/,contains:[{match:/""/}]},s=["true","false","unknown"],l=["double precision","large object","with timezone","without timezone"],c=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],f=["add","asc","collation","desc","final","first","last","view"],p=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],m=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],g=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],x=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],v=m,S=[...p,...f].filter(H=>!m.includes(H)),A={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},T={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},C={match:t.concat(/\b/,t.either(...v),/\s*\(/),relevance:0,keywords:{built_in:v}};function N(H){return t.concat(/\b/,t.either(...H.map(D=>D.replace(/\s+/,"\\s+"))),/\b/)}const R={scope:"keyword",match:N(x),relevance:0};function O(H,{exceptions:D,when:F}={}){const Z=F;return D=D||[],H.map(V=>V.match(/\|\d+$/)||D.includes(V)?V:Z(V)?`${V}|0`:V)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:O(S,{when:H=>H.length<3}),literal:s,type:c,built_in:g},contains:[{scope:"type",match:N(l)},R,C,A,i,r,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,T]}}function ZR(e){return e?typeof e=="string"?e:e.source:null}function cm(e){return An("(?=",e,")")}function An(...e){return e.map(n=>ZR(n)).join("")}function MF(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function da(...e){return"("+(MF(e).capture?"":"?:")+e.map(i=>ZR(i)).join("|")+")"}const j_=e=>An(/\b/,e,/\w$/.test(e)?/\b/:/\B/),RF=["Protocol","Type"].map(j_),aT=["init","self"].map(j_),kF=["Any","Self"],gv=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],sT=["false","nil","true"],NF=["assignment","associativity","higherThan","left","lowerThan","none","right"],OF=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],lT=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],JR=da(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),ek=da(JR,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),yv=An(JR,ek,"*"),tk=da(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),I0=da(tk,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),uo=An(tk,I0,"*"),n0=An(/[A-Z]/,I0,"*"),DF=["attached","autoclosure",An(/convention\(/,da("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",An(/objc\(/,uo,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],zF=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function BF(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),i=[e.C_LINE_COMMENT_MODE,n],r={match:[/\./,da(...RF,...aT)],className:{2:"keyword"}},s={match:An(/\./,da(...gv)),relevance:0},l=gv.filter(Ue=>typeof Ue=="string").concat(["_|0"]),c=gv.filter(Ue=>typeof Ue!="string").concat(kF).map(j_),f={variants:[{className:"keyword",match:da(...c,...aT)}]},p={$pattern:da(/\b\w+/,/#\w+/),keyword:l.concat(OF),literal:sT},m=[r,s,f],g={match:An(/\./,da(...lT)),relevance:0},x={className:"built_in",match:An(/\b/,da(...lT),/(?=\()/)},v=[g,x],S={match:/->/,relevance:0},A={className:"operator",relevance:0,variants:[{match:yv},{match:`\\.(\\.|${ek})+`}]},T=[S,A],C="([0-9]_*)+",N="([0-9a-fA-F]_*)+",R={className:"number",relevance:0,variants:[{match:`\\b(${C})(\\.(${C}))?([eE][+-]?(${C}))?\\b`},{match:`\\b0x(${N})(\\.(${N}))?([pP][+-]?(${C}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},O=(Ue="")=>({className:"subst",variants:[{match:An(/\\/,Ue,/[0\\tnr"']/)},{match:An(/\\/,Ue,/u\{[0-9a-fA-F]{1,8}\}/)}]}),H=(Ue="")=>({className:"subst",match:An(/\\/,Ue,/[\t ]*(?:[\r\n]|\r\n)/)}),D=(Ue="")=>({className:"subst",label:"interpol",begin:An(/\\/,Ue,/\(/),end:/\)/}),F=(Ue="")=>({begin:An(Ue,/"""/),end:An(/"""/,Ue),contains:[O(Ue),H(Ue),D(Ue)]}),Z=(Ue="")=>({begin:An(Ue,/"/),end:An(/"/,Ue),contains:[O(Ue),D(Ue)]}),V={className:"string",variants:[F(),F("#"),F("##"),F("###"),Z(),Z("#"),Z("##"),Z("###")]},Y=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],P={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:Y},q=Ue=>{const wt=An(Ue,/\//),_n=An(/\//,Ue);return{begin:wt,end:_n,contains:[...Y,{scope:"comment",begin:`#(?!.*${_n})`,end:/$/}]}},ne={scope:"regexp",variants:[q("###"),q("##"),q("#"),P]},I={match:An(/`/,uo,/`/)},$={className:"variable",match:/\$\d+/},z={className:"variable",match:`\\$${I0}+`},G=[I,$,z],Q={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:zF,contains:[...T,R,V]}]}},W={scope:"keyword",match:An(/@/,da(...DF),cm(da(/\(/,/\s+/)))},B={scope:"meta",match:An(/@/,uo)},K=[Q,W,B],J={match:cm(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:An(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,I0,"+")},{className:"type",match:n0,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:An(/\s+&\s+/,cm(n0)),relevance:0}]},X={begin:/</,end:/>/,keywords:p,contains:[...i,...m,...K,S,J]};J.contains.push(X);const ce={match:An(uo,/\s*:/),keywords:"_|0",relevance:0},ie={begin:/\(/,end:/\)/,relevance:0,keywords:p,contains:["self",ce,...i,ne,...m,...v,...T,R,V,...G,...K,J]},de={begin:/</,end:/>/,keywords:"repeat each",contains:[...i,J]},ye={begin:da(cm(An(uo,/\s*:/)),cm(An(uo,/\s+/,uo,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:uo}]},me={begin:/\(/,end:/\)/,keywords:p,contains:[ye,...i,...m,...T,R,V,...K,J,ie],endsParent:!0,illegal:/["']/},le={match:[/(func|macro)/,/\s+/,da(I.match,uo,yv)],className:{1:"keyword",3:"title.function"},contains:[de,me,t],illegal:[/\[/,/%/]},Re={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[de,me,t],illegal:/\[|%/},Le={match:[/operator/,/\s+/,yv],className:{1:"keyword",3:"title"}},je={begin:[/precedencegroup/,/\s+/,n0],className:{1:"keyword",3:"title"},contains:[J],keywords:[...NF,...sT],end:/}/},He={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Qe={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},ot={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,uo,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:p,contains:[de,...m,{begin:/:/,end:/\{/,keywords:p,contains:[{scope:"title.class.inherited",match:n0},...m],relevance:0}]};for(const Ue of V.variants){const wt=Ue.contains.find(Sn=>Sn.label==="interpol");wt.keywords=p;const _n=[...m,...v,...T,R,V,...G];wt.contains=[..._n,{begin:/\(/,end:/\)/,contains:["self",..._n]}]}return{name:"Swift",keywords:p,contains:[...i,le,Re,He,Qe,ot,Le,je,{beginKeywords:"import",end:/$/,contains:[...i],relevance:0},ne,...m,...v,...T,R,V,...G,...K,J,ie]}}const U0="[A-Za-z$_][0-9A-Za-z$_]*",nk=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],ik=["true","false","null","undefined","NaN","Infinity"],rk=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],ak=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],sk=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],lk=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],ok=[].concat(sk,rk,ak);function LF(e){const t=e.regex,n=(Q,{after:W})=>{const B="</"+Q[0].slice(1);return Q.input.indexOf(B,W)!==-1},i=U0,r={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Q,W)=>{const B=Q[0].length+Q.index,K=Q.input[B];if(K==="<"||K===","){W.ignoreMatch();return}K===">"&&(n(Q,{after:B})||W.ignoreMatch());let J;const X=Q.input.substring(B);if(J=X.match(/^\s*=/)){W.ignoreMatch();return}if((J=X.match(/^\s+extends\s+/))&&J.index===0){W.ignoreMatch();return}}},c={$pattern:U0,keyword:nk,literal:ik,built_in:ok,"variable.language":lk},f="[0-9](_?[0-9])*",p=`\\.(${f})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${m})((${p})|\\.)?|(${p}))[eE][+-]?(${f})\\b`},{begin:`\\b(${m})\\b((${p})\\b|\\.)?|(${p})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},x={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"xml"}},S={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"css"}},A={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"graphql"}},T={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,x]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},R=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,S,A,T,{match:/\$\d+/},g];x.contains=R.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(R)});const O=[].concat(N,x.contains),H=O.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(O)}]),D={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:H},F={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},Z={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...rk,...ak]}},V={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Y={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[D],illegal:/%/},P={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(Q){return t.concat("(?!",Q.join("|"),")")}const ne={match:t.concat(/\b/,q([...sk,"super","import"].map(Q=>`${Q}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},$={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},D]},z="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",G={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(z)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[D]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:H,CLASS_REFERENCE:Z},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),V,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,S,A,T,N,{match:/\$\d+/},g,Z,{scope:"attr",match:i+t.lookahead(":"),relevance:0},G,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:z,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:H}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:s},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},Y,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[D,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[D]},ne,P,F,$,{match:/\$[(.]/}]}}function jF(e){const t=e.regex,n=LF(e),i=U0,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},f=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],p={$pattern:U0,keyword:nk.concat(f),literal:ik,built_in:ok.concat(r),"variable.language":lk},m={className:"meta",begin:"@"+i},g=(A,T,C)=>{const N=A.contains.findIndex(R=>R.label===T);if(N===-1)throw new Error("can not find mode to replace");A.contains.splice(N,1,C)};Object.assign(n.keywords,p),n.exports.PARAMS_CONTAINS.push(m);const x=n.contains.find(A=>A.scope==="attr"),v=Object.assign({},x,{match:t.concat(i,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,x,v]),n.contains=n.contains.concat([m,s,l,v]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",c);const S=n.contains.find(A=>A.label==="func.def");return S.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function IF(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},i={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},r=/\d{1,2}\/\d{1,2}\/\d{4}/,s=/\d{4}-\d{1,2}-\d{1,2}/,l=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,c=/\d{1,2}(:\d{1,2}){1,2}/,f={className:"literal",variants:[{begin:t.concat(/# */,t.either(s,r),/ *#/)},{begin:t.concat(/# */,c,/ *#/)},{begin:t.concat(/# */,l,/ *#/)},{begin:t.concat(/# */,t.either(s,r),/ +/,t.either(l,c),/ *#/)}]},p={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},m={className:"label",begin:/^\w+:/},g=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),x=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,i,f,p,m,g,x,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[x]}]}}function UF(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),i=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],r={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},s={className:"variable",begin:/\$[\w_]+/},l={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},c={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},f={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},p={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:i},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},s,l,r,e.QUOTE_STRING_MODE,f,p,c]}}function HF(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),i=/[\p{L}0-9._:-]+/u,r={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=e.inherit(s,{begin:/\(/,end:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{className:"string"}),f=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),p={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:i,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[r]},{begin:/'/,end:/'/,contains:[r]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[s,f,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[s,l,f,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},r,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[f]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[p],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[p],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:p}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function PF(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",i={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},r={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,r]},c=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),x={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},v={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},S={begin:/\{/,end:/\}/,contains:[v],illegal:"\\n",relevance:0},A={begin:"\\[",end:"\\]",contains:[v],illegal:"\\n",relevance:0},T=[i,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},x,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},S,A,s,l],C=[...T];return C.pop(),C.push(c),v.contains=C,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:T}}const FF={arduino:EP,bash:wP,c:TP,cpp:CP,csharp:AP,css:LP,diff:jP,go:IP,graphql:UP,ini:HP,java:PP,javascript:VP,json:XP,kotlin:$P,less:iF,lua:rF,makefile:aF,markdown:sF,objectivec:lF,perl:oF,php:cF,"php-template":uF,plaintext:dF,python:fF,"python-repl":hF,r:pF,ruby:mF,rust:gF,scss:TF,shell:CF,sql:AF,swift:BF,typescript:jF,vbnet:IF,wasm:UF,xml:HF,yaml:PF};var xv,oT;function GF(){if(oT)return xv;oT=1;function e(se){return se instanceof Map?se.clear=se.delete=se.set=function(){throw new Error("map is read-only")}:se instanceof Set&&(se.add=se.clear=se.delete=function(){throw new Error("set is read-only")}),Object.freeze(se),Object.getOwnPropertyNames(se).forEach(Te=>{const Ie=se[Te],tt=typeof Ie;(tt==="object"||tt==="function")&&!Object.isFrozen(Ie)&&e(Ie)}),se}class t{constructor(Te){Te.data===void 0&&(Te.data={}),this.data=Te.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(se){return se.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function i(se,...Te){const Ie=Object.create(null);for(const tt in se)Ie[tt]=se[tt];return Te.forEach(function(tt){for(const nn in tt)Ie[nn]=tt[nn]}),Ie}const r="</span>",s=se=>!!se.scope,l=(se,{prefix:Te})=>{if(se.startsWith("language:"))return se.replace("language:","language-");if(se.includes(".")){const Ie=se.split(".");return[`${Te}${Ie.shift()}`,...Ie.map((tt,nn)=>`${tt}${"_".repeat(nn+1)}`)].join(" ")}return`${Te}${se}`};class c{constructor(Te,Ie){this.buffer="",this.classPrefix=Ie.classPrefix,Te.walk(this)}addText(Te){this.buffer+=n(Te)}openNode(Te){if(!s(Te))return;const Ie=l(Te.scope,{prefix:this.classPrefix});this.span(Ie)}closeNode(Te){s(Te)&&(this.buffer+=r)}value(){return this.buffer}span(Te){this.buffer+=`<span class="${Te}">`}}const f=(se={})=>{const Te={children:[]};return Object.assign(Te,se),Te};class p{constructor(){this.rootNode=f(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(Te){this.top.children.push(Te)}openNode(Te){const Ie=f({scope:Te});this.add(Ie),this.stack.push(Ie)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(Te){return this.constructor._walk(Te,this.rootNode)}static _walk(Te,Ie){return typeof Ie=="string"?Te.addText(Ie):Ie.children&&(Te.openNode(Ie),Ie.children.forEach(tt=>this._walk(Te,tt)),Te.closeNode(Ie)),Te}static _collapse(Te){typeof Te!="string"&&Te.children&&(Te.children.every(Ie=>typeof Ie=="string")?Te.children=[Te.children.join("")]:Te.children.forEach(Ie=>{p._collapse(Ie)}))}}class m extends p{constructor(Te){super(),this.options=Te}addText(Te){Te!==""&&this.add(Te)}startScope(Te){this.openNode(Te)}endScope(){this.closeNode()}__addSublanguage(Te,Ie){const tt=Te.root;Ie&&(tt.scope=`language:${Ie}`),this.add(tt)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(se){return se?typeof se=="string"?se:se.source:null}function x(se){return A("(?=",se,")")}function v(se){return A("(?:",se,")*")}function S(se){return A("(?:",se,")?")}function A(...se){return se.map(Ie=>g(Ie)).join("")}function T(se){const Te=se[se.length-1];return typeof Te=="object"&&Te.constructor===Object?(se.splice(se.length-1,1),Te):{}}function C(...se){return"("+(T(se).capture?"":"?:")+se.map(tt=>g(tt)).join("|")+")"}function N(se){return new RegExp(se.toString()+"|").exec("").length-1}function R(se,Te){const Ie=se&&se.exec(Te);return Ie&&Ie.index===0}const O=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function H(se,{joinWith:Te}){let Ie=0;return se.map(tt=>{Ie+=1;const nn=Ie;let rn=g(tt),Ye="";for(;rn.length>0;){const Ge=O.exec(rn);if(!Ge){Ye+=rn;break}Ye+=rn.substring(0,Ge.index),rn=rn.substring(Ge.index+Ge[0].length),Ge[0][0]==="\\"&&Ge[1]?Ye+="\\"+String(Number(Ge[1])+nn):(Ye+=Ge[0],Ge[0]==="("&&Ie++)}return Ye}).map(tt=>`(${tt})`).join(Te)}const D=/\b\B/,F="[a-zA-Z]\\w*",Z="[a-zA-Z_]\\w*",V="\\b\\d+(\\.\\d+)?",Y="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",P="\\b(0b[01]+)",q="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ne=(se={})=>{const Te=/^#![ ]*\//;return se.binary&&(se.begin=A(Te,/.*\b/,se.binary,/\b.*/)),i({scope:"meta",begin:Te,end:/$/,relevance:0,"on:begin":(Ie,tt)=>{Ie.index!==0&&tt.ignoreMatch()}},se)},I={begin:"\\\\[\\s\\S]",relevance:0},$={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[I]},z={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[I]},G={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Q=function(se,Te,Ie={}){const tt=i({scope:"comment",begin:se,end:Te,contains:[]},Ie);tt.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const nn=C("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return tt.contains.push({begin:A(/[ ]+/,"(",nn,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),tt},W=Q("//","$"),B=Q("/\\*","\\*/"),K=Q("#","$"),J={scope:"number",begin:V,relevance:0},X={scope:"number",begin:Y,relevance:0},ce={scope:"number",begin:P,relevance:0},ie={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[I,{begin:/\[/,end:/\]/,relevance:0,contains:[I]}]},de={scope:"title",begin:F,relevance:0},ye={scope:"title",begin:Z,relevance:0},me={begin:"\\.\\s*"+Z,relevance:0};var Re=Object.freeze({__proto__:null,APOS_STRING_MODE:$,BACKSLASH_ESCAPE:I,BINARY_NUMBER_MODE:ce,BINARY_NUMBER_RE:P,COMMENT:Q,C_BLOCK_COMMENT_MODE:B,C_LINE_COMMENT_MODE:W,C_NUMBER_MODE:X,C_NUMBER_RE:Y,END_SAME_AS_BEGIN:function(se){return Object.assign(se,{"on:begin":(Te,Ie)=>{Ie.data._beginMatch=Te[1]},"on:end":(Te,Ie)=>{Ie.data._beginMatch!==Te[1]&&Ie.ignoreMatch()}})},HASH_COMMENT_MODE:K,IDENT_RE:F,MATCH_NOTHING_RE:D,METHOD_GUARD:me,NUMBER_MODE:J,NUMBER_RE:V,PHRASAL_WORDS_MODE:G,QUOTE_STRING_MODE:z,REGEXP_MODE:ie,RE_STARTERS_RE:q,SHEBANG:ne,TITLE_MODE:de,UNDERSCORE_IDENT_RE:Z,UNDERSCORE_TITLE_MODE:ye});function Le(se,Te){se.input[se.index-1]==="."&&Te.ignoreMatch()}function je(se,Te){se.className!==void 0&&(se.scope=se.className,delete se.className)}function He(se,Te){Te&&se.beginKeywords&&(se.begin="\\b("+se.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",se.__beforeBegin=Le,se.keywords=se.keywords||se.beginKeywords,delete se.beginKeywords,se.relevance===void 0&&(se.relevance=0))}function Qe(se,Te){Array.isArray(se.illegal)&&(se.illegal=C(...se.illegal))}function ot(se,Te){if(se.match){if(se.begin||se.end)throw new Error("begin & end are not supported with match");se.begin=se.match,delete se.match}}function Ue(se,Te){se.relevance===void 0&&(se.relevance=1)}const wt=(se,Te)=>{if(!se.beforeMatch)return;if(se.starts)throw new Error("beforeMatch cannot be used with starts");const Ie=Object.assign({},se);Object.keys(se).forEach(tt=>{delete se[tt]}),se.keywords=Ie.keywords,se.begin=A(Ie.beforeMatch,x(Ie.begin)),se.starts={relevance:0,contains:[Object.assign(Ie,{endsParent:!0})]},se.relevance=0,delete Ie.beforeMatch},_n=["of","and","for","in","not","or","if","then","parent","list","value"],Sn="keyword";function hn(se,Te,Ie=Sn){const tt=Object.create(null);return typeof se=="string"?nn(Ie,se.split(" ")):Array.isArray(se)?nn(Ie,se):Object.keys(se).forEach(function(rn){Object.assign(tt,hn(se[rn],Te,rn))}),tt;function nn(rn,Ye){Te&&(Ye=Ye.map(Ge=>Ge.toLowerCase())),Ye.forEach(function(Ge){const nt=Ge.split("|");tt[nt[0]]=[rn,oi(nt[0],nt[1])]})}}function oi(se,Te){return Te?Number(Te):Ur(se)?0:1}function Ur(se){return _n.includes(se.toLowerCase())}const Ci={},Wt=se=>{console.error(se)},sr=(se,...Te)=>{console.log(`WARN: ${se}`,...Te)},Ee=(se,Te)=>{Ci[`${se}/${Te}`]||(console.log(`Deprecated as of ${se}. ${Te}`),Ci[`${se}/${Te}`]=!0)},ke=new Error;function oe(se,Te,{key:Ie}){let tt=0;const nn=se[Ie],rn={},Ye={};for(let Ge=1;Ge<=Te.length;Ge++)Ye[Ge+tt]=nn[Ge],rn[Ge+tt]=!0,tt+=N(Te[Ge-1]);se[Ie]=Ye,se[Ie]._emit=rn,se[Ie]._multi=!0}function Pe(se){if(Array.isArray(se.begin)){if(se.skip||se.excludeBegin||se.returnBegin)throw Wt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ke;if(typeof se.beginScope!="object"||se.beginScope===null)throw Wt("beginScope must be object"),ke;oe(se,se.begin,{key:"beginScope"}),se.begin=H(se.begin,{joinWith:""})}}function ct(se){if(Array.isArray(se.end)){if(se.skip||se.excludeEnd||se.returnEnd)throw Wt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ke;if(typeof se.endScope!="object"||se.endScope===null)throw Wt("endScope must be object"),ke;oe(se,se.end,{key:"endScope"}),se.end=H(se.end,{joinWith:""})}}function tn(se){se.scope&&typeof se.scope=="object"&&se.scope!==null&&(se.beginScope=se.scope,delete se.scope)}function ci(se){tn(se),typeof se.beginScope=="string"&&(se.beginScope={_wrap:se.beginScope}),typeof se.endScope=="string"&&(se.endScope={_wrap:se.endScope}),Pe(se),ct(se)}function Qt(se){function Te(Ye,Ge){return new RegExp(g(Ye),"m"+(se.case_insensitive?"i":"")+(se.unicodeRegex?"u":"")+(Ge?"g":""))}class Ie{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Ge,nt){nt.position=this.position++,this.matchIndexes[this.matchAt]=nt,this.regexes.push([nt,Ge]),this.matchAt+=N(Ge)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Ge=this.regexes.map(nt=>nt[1]);this.matcherRe=Te(H(Ge,{joinWith:"|"}),!0),this.lastIndex=0}exec(Ge){this.matcherRe.lastIndex=this.lastIndex;const nt=this.matcherRe.exec(Ge);if(!nt)return null;const Rn=nt.findIndex((ga,lr)=>lr>0&&ga!==void 0),Ft=this.matchIndexes[Rn];return nt.splice(0,Rn),Object.assign(nt,Ft)}}class tt{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Ge){if(this.multiRegexes[Ge])return this.multiRegexes[Ge];const nt=new Ie;return this.rules.slice(Ge).forEach(([Rn,Ft])=>nt.addRule(Rn,Ft)),nt.compile(),this.multiRegexes[Ge]=nt,nt}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Ge,nt){this.rules.push([Ge,nt]),nt.type==="begin"&&this.count++}exec(Ge){const nt=this.getMatcher(this.regexIndex);nt.lastIndex=this.lastIndex;let Rn=nt.exec(Ge);if(this.resumingScanAtSamePosition()&&!(Rn&&Rn.index===this.lastIndex)){const Ft=this.getMatcher(0);Ft.lastIndex=this.lastIndex+1,Rn=Ft.exec(Ge)}return Rn&&(this.regexIndex+=Rn.position+1,this.regexIndex===this.count&&this.considerAll()),Rn}}function nn(Ye){const Ge=new tt;return Ye.contains.forEach(nt=>Ge.addRule(nt.begin,{rule:nt,type:"begin"})),Ye.terminatorEnd&&Ge.addRule(Ye.terminatorEnd,{type:"end"}),Ye.illegal&&Ge.addRule(Ye.illegal,{type:"illegal"}),Ge}function rn(Ye,Ge){const nt=Ye;if(Ye.isCompiled)return nt;[je,ot,ci,wt].forEach(Ft=>Ft(Ye,Ge)),se.compilerExtensions.forEach(Ft=>Ft(Ye,Ge)),Ye.__beforeBegin=null,[He,Qe,Ue].forEach(Ft=>Ft(Ye,Ge)),Ye.isCompiled=!0;let Rn=null;return typeof Ye.keywords=="object"&&Ye.keywords.$pattern&&(Ye.keywords=Object.assign({},Ye.keywords),Rn=Ye.keywords.$pattern,delete Ye.keywords.$pattern),Rn=Rn||/\w+/,Ye.keywords&&(Ye.keywords=hn(Ye.keywords,se.case_insensitive)),nt.keywordPatternRe=Te(Rn,!0),Ge&&(Ye.begin||(Ye.begin=/\B|\b/),nt.beginRe=Te(nt.begin),!Ye.end&&!Ye.endsWithParent&&(Ye.end=/\B|\b/),Ye.end&&(nt.endRe=Te(nt.end)),nt.terminatorEnd=g(nt.end)||"",Ye.endsWithParent&&Ge.terminatorEnd&&(nt.terminatorEnd+=(Ye.end?"|":"")+Ge.terminatorEnd)),Ye.illegal&&(nt.illegalRe=Te(Ye.illegal)),Ye.contains||(Ye.contains=[]),Ye.contains=[].concat(...Ye.contains.map(function(Ft){return Gn(Ft==="self"?Ye:Ft)})),Ye.contains.forEach(function(Ft){rn(Ft,nt)}),Ye.starts&&rn(Ye.starts,Ge),nt.matcher=nn(nt),nt}if(se.compilerExtensions||(se.compilerExtensions=[]),se.contains&&se.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return se.classNameAliases=i(se.classNameAliases||{}),rn(se)}function Zt(se){return se?se.endsWithParent||Zt(se.starts):!1}function Gn(se){return se.variants&&!se.cachedVariants&&(se.cachedVariants=se.variants.map(function(Te){return i(se,{variants:null},Te)})),se.cachedVariants?se.cachedVariants:Zt(se)?i(se,{starts:se.starts?i(se.starts):null}):Object.isFrozen(se)?i(se):se}var Pt="11.11.1";class Yi extends Error{constructor(Te,Ie){super(Te),this.name="HTMLInjectionError",this.html=Ie}}const Jn=n,vo=i,ls=Symbol("nomatch"),Ba=7,os=function(se){const Te=Object.create(null),Ie=Object.create(null),tt=[];let nn=!0;const rn="Could not find the language '{}', did you forget to load/include a language module?",Ye={disableAutodetect:!0,name:"Plain text",contains:[]};let Ge={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:m};function nt(Ne){return Ge.noHighlightRe.test(Ne)}function Rn(Ne){let Ke=Ne.className+" ";Ke+=Ne.parentNode?Ne.parentNode.className:"";const vt=Ge.languageDetectRe.exec(Ke);if(vt){const Xt=an(vt[1]);return Xt||(sr(rn.replace("{}",vt[1])),sr("Falling back to no-highlight mode for this block.",Ne)),Xt?vt[1]:"no-highlight"}return Ke.split(/\s+/).find(Xt=>nt(Xt)||an(Xt))}function Ft(Ne,Ke,vt){let Xt="",In="";typeof Ke=="object"?(Xt=Ne,vt=Ke.ignoreIllegals,In=Ke.language):(Ee("10.7.0","highlight(lang, code, ...args) has been deprecated."),Ee("10.7.0",`Please use highlight(code, options) instead.
|
|
377
377
|
https://github.com/highlightjs/highlight.js/issues/2277`),In=Ne,Xt=Ke),vt===void 0&&(vt=!0);const _i={code:Xt,language:In};ya("before:highlight",_i);const Xi=_i.result?_i.result:ga(_i.language,_i.code,vt);return Xi.code=_i.code,ya("after:highlight",Xi),Xi}function ga(Ne,Ke,vt,Xt){const In=Object.create(null);function _i(Be,Ve){return Be.keywords[Ve]}function Xi(){if(!rt.keywords){Hn.addText(ln);return}let Be=0;rt.keywordPatternRe.lastIndex=0;let Ve=rt.keywordPatternRe.exec(ln),yt="";for(;Ve;){yt+=ln.substring(Be,Ve.index);const Nt=di.case_insensitive?Ve[0].toLowerCase():Ve[0],kn=_i(rt,Nt);if(kn){const[Gr,pc]=kn;if(Hn.addText(yt),yt="",In[Nt]=(In[Nt]||0)+1,In[Nt]<=Ba&&(ds+=pc),Gr.startsWith("_"))yt+=Ve[0];else{const mu=di.classNameAliases[Gr]||Gr;ur(Ve[0],mu)}}else yt+=Ve[0];Be=rt.keywordPatternRe.lastIndex,Ve=rt.keywordPatternRe.exec(ln)}yt+=ln.substring(Be),Hn.addText(yt)}function Ai(){if(ln==="")return;let Be=null;if(typeof rt.subLanguage=="string"){if(!Te[rt.subLanguage]){Hn.addText(ln);return}Be=ga(rt.subLanguage,ln,!0,So[rt.subLanguage]),So[rt.subLanguage]=Be._top}else Be=Vi(ln,rt.subLanguage.length?rt.subLanguage:null);rt.relevance>0&&(ds+=Be.relevance),Hn.__addSublanguage(Be._emitter,Be.language)}function pn(){rt.subLanguage!=null?Ai():Xi(),ln=""}function ur(Be,Ve){Be!==""&&(Hn.startScope(Ve),Hn.addText(Be),Hn.endScope())}function _o(Be,Ve){let yt=1;const Nt=Ve.length-1;for(;yt<=Nt;){if(!Be._emit[yt]){yt++;continue}const kn=di.classNameAliases[Be[yt]]||Be[yt],Gr=Ve[yt];kn?ur(Gr,kn):(ln=Gr,Xi(),ln=""),yt++}}function xa(Be,Ve){return Be.scope&&typeof Be.scope=="string"&&Hn.openNode(di.classNameAliases[Be.scope]||Be.scope),Be.beginScope&&(Be.beginScope._wrap?(ur(ln,di.classNameAliases[Be.beginScope._wrap]||Be.beginScope._wrap),ln=""):Be.beginScope._multi&&(_o(Be.beginScope,Ve),ln="")),rt=Object.create(Be,{parent:{value:rt}}),rt}function Rl(Be,Ve,yt){let Nt=R(Be.endRe,yt);if(Nt){if(Be["on:end"]){const kn=new t(Be);Be["on:end"](Ve,kn),kn.isMatchIgnored&&(Nt=!1)}if(Nt){for(;Be.endsParent&&Be.parent;)Be=Be.parent;return Be}}if(Be.endsWithParent)return Rl(Be.parent,Ve,yt)}function ja(Be){return rt.matcher.regexIndex===0?(ln+=Be[0],1):(Fs=!0,0)}function fc(Be){const Ve=Be[0],yt=Be.rule,Nt=new t(yt),kn=[yt.__beforeBegin,yt["on:begin"]];for(const Gr of kn)if(Gr&&(Gr(Be,Nt),Nt.isMatchIgnored))return ja(Ve);return yt.skip?ln+=Ve:(yt.excludeBegin&&(ln+=Ve),pn(),!yt.returnBegin&&!yt.excludeBegin&&(ln=Ve)),xa(yt,Be),yt.returnBegin?0:Ve.length}function Bi(Be){const Ve=Be[0],yt=Ke.substring(Be.index),Nt=Rl(rt,Be,yt);if(!Nt)return ls;const kn=rt;rt.endScope&&rt.endScope._wrap?(pn(),ur(Ve,rt.endScope._wrap)):rt.endScope&&rt.endScope._multi?(pn(),_o(rt.endScope,Be)):kn.skip?ln+=Ve:(kn.returnEnd||kn.excludeEnd||(ln+=Ve),pn(),kn.excludeEnd&&(ln=Ve));do rt.scope&&Hn.closeNode(),!rt.skip&&!rt.subLanguage&&(ds+=rt.relevance),rt=rt.parent;while(rt!==Nt.parent);return Nt.starts&&xa(Nt.starts,Be),kn.returnEnd?0:Ve.length}function cs(){const Be=[];for(let Ve=rt;Ve!==di;Ve=Ve.parent)Ve.scope&&Be.unshift(Ve.scope);Be.forEach(Ve=>Hn.openNode(Ve))}let us={};function Ps(Be,Ve){const yt=Ve&&Ve[0];if(ln+=Be,yt==null)return pn(),0;if(us.type==="begin"&&Ve.type==="end"&&us.index===Ve.index&&yt===""){if(ln+=Ke.slice(Ve.index,Ve.index+1),!nn){const Nt=new Error(`0 width match regex (${Ne})`);throw Nt.languageName=Ne,Nt.badRule=us.rule,Nt}return 1}if(us=Ve,Ve.type==="begin")return fc(Ve);if(Ve.type==="illegal"&&!vt){const Nt=new Error('Illegal lexeme "'+yt+'" for mode "'+(rt.scope||"<unnamed>")+'"');throw Nt.mode=rt,Nt}else if(Ve.type==="end"){const Nt=Bi(Ve);if(Nt!==ls)return Nt}if(Ve.type==="illegal"&&yt==="")return ln+=`
|
|
378
|
-
`,1;if(hc>1e5&&hc>Ve.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ln+=yt,yt.length}const di=an(Ne);if(!di)throw Wt(rn.replace("{}",Ne)),new Error('Unknown language: "'+Ne+'"');const pu=Qt(di);let Ia="",rt=Xt||pu;const So={},Hn=new Ge.__emitter(Ge);cs();let ln="",ds=0,fs=0,hc=0,Fs=!1;try{if(di.__emitTokens)di.__emitTokens(Ke,Hn);else{for(rt.matcher.considerAll();;){hc++,Fs?Fs=!1:rt.matcher.considerAll(),rt.matcher.lastIndex=fs;const Be=rt.matcher.exec(Ke);if(!Be)break;const Ve=Ke.substring(fs,Be.index),yt=Ps(Ve,Be);fs=Be.index+yt}Ps(Ke.substring(fs))}return Hn.finalize(),Ia=Hn.toHTML(),{language:Ne,value:Ia,relevance:ds,illegal:!1,_emitter:Hn,_top:rt}}catch(Be){if(Be.message&&Be.message.includes("Illegal"))return{language:Ne,value:Jn(Ke),illegal:!0,relevance:0,_illegalBy:{message:Be.message,index:fs,context:Ke.slice(fs-100,fs+100),mode:Be.mode,resultSoFar:Ia},_emitter:Hn};if(nn)return{language:Ne,value:Jn(Ke),illegal:!1,relevance:0,errorRaised:Be,_emitter:Hn,_top:rt};throw Be}}function lr(Ne){const Ke={value:Jn(Ne),illegal:!1,relevance:0,_top:Ye,_emitter:new Ge.__emitter(Ge)};return Ke._emitter.addText(Ne),Ke}function Vi(Ne,Ke){Ke=Ke||Ge.languages||Object.keys(Te);const vt=lr(Ne),Xt=Ke.filter(an).filter(cr).map(pn=>ga(pn,Ne,!1));Xt.unshift(vt);const In=Xt.sort((pn,ur)=>{if(pn.relevance!==ur.relevance)return ur.relevance-pn.relevance;if(pn.language&&ur.language){if(an(pn.language).supersetOf===ur.language)return 1;if(an(ur.language).supersetOf===pn.language)return-1}return 0}),[_i,Xi]=In,Ai=_i;return Ai.secondBest=Xi,Ai}function or(Ne,Ke,vt){const Xt=Ke&&Ie[Ke]||vt;Ne.classList.add("hljs"),Ne.classList.add(`language-${Xt}`)}function bt(Ne){let Ke=null;const vt=Rn(Ne);if(nt(vt))return;if(ya("before:highlightElement",{el:Ne,language:vt}),Ne.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ne);return}if(Ne.children.length>0&&(Ge.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Ne)),Ge.throwUnescapedHTML))throw new Yi("One of your code blocks includes unescaped HTML.",Ne.innerHTML);Ke=Ne;const Xt=Ke.textContent,In=vt?Ft(Xt,{language:vt,ignoreIllegals:!0}):Vi(Xt);Ne.innerHTML=In.value,Ne.dataset.highlighted="yes",or(Ne,vt,In.language),Ne.result={language:In.language,re:In.relevance,relevance:In.relevance},In.secondBest&&(Ne.secondBest={language:In.secondBest.language,relevance:In.secondBest.relevance}),ya("after:highlightElement",{el:Ne,result:In,text:Xt})}function ui(Ne){Ge=vo(Ge,Ne)}const Hr=()=>{Al(),Ee("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Us(){Al(),Ee("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Cl=!1;function Al(){function Ne(){Al()}if(document.readyState==="loading"){Cl||window.addEventListener("DOMContentLoaded",Ne,!1),Cl=!0;return}document.querySelectorAll(Ge.cssSelector).forEach(bt)}function Ml(Ne,Ke){let vt=null;try{vt=Ke(se)}catch(Xt){if(Wt("Language definition for '{}' could not be registered.".replace("{}",Ne)),nn)Wt(Xt);else throw Xt;vt=Ye}vt.name||(vt.name=Ne),Te[Ne]=vt,vt.rawDefinition=Ke.bind(null,se),vt.aliases&&sn(vt.aliases,{languageName:Ne})}function La(Ne){delete Te[Ne];for(const Ke of Object.keys(Ie))Ie[Ke]===Ne&&delete Ie[Ke]}function Hs(){return Object.keys(Te)}function an(Ne){return Ne=(Ne||"").toLowerCase(),Te[Ne]||Te[Ie[Ne]]}function sn(Ne,{languageName:Ke}){typeof Ne=="string"&&(Ne=[Ne]),Ne.forEach(vt=>{Ie[vt.toLowerCase()]=Ke})}function cr(Ne){const Ke=an(Ne);return Ke&&!Ke.disableAutodetect}function Pr(Ne){Ne["before:highlightBlock"]&&!Ne["before:highlightElement"]&&(Ne["before:highlightElement"]=Ke=>{Ne["before:highlightBlock"](Object.assign({block:Ke.el},Ke))}),Ne["after:highlightBlock"]&&!Ne["after:highlightElement"]&&(Ne["after:highlightElement"]=Ke=>{Ne["after:highlightBlock"](Object.assign({block:Ke.el},Ke))})}function jn(Ne){Pr(Ne),tt.push(Ne)}function Sr(Ne){const Ke=tt.indexOf(Ne);Ke!==-1&&tt.splice(Ke,1)}function ya(Ne,Ke){const vt=Ne;tt.forEach(function(Xt){Xt[vt]&&Xt[vt](Ke)})}function Fr(Ne){return Ee("10.7.0","highlightBlock will be removed entirely in v12.0"),Ee("10.7.0","Please use highlightElement now."),bt(Ne)}Object.assign(se,{highlight:Ft,highlightAuto:Vi,highlightAll:Al,highlightElement:bt,highlightBlock:Fr,configure:ui,initHighlighting:Hr,initHighlightingOnLoad:Us,registerLanguage:Ml,unregisterLanguage:La,listLanguages:Hs,getLanguage:an,registerAliases:sn,autoDetection:cr,inherit:vo,addPlugin:jn,removePlugin:Sr}),se.debugMode=function(){nn=!1},se.safeMode=function(){nn=!0},se.versionString=Pt,se.regex={concat:A,lookahead:x,either:C,optional:S,anyNumberOfTimes:v};for(const Ne in Re)typeof Re[Ne]=="object"&&e(Re[Ne]);return Object.assign(se,Re),se},vi=os({});return vi.newInstance=()=>os({}),xv=vi,vi.HighlightJS=vi,vi.default=vi,xv}var qF=GF();const YF=du(qF),cT={},VF="hljs-";function XF(e){const t=YF.newInstance();return e&&s(e),{highlight:n,highlightAuto:i,listLanguages:r,register:s,registerAlias:l,registered:c};function n(f,p,m){const g=m||cT,x=typeof g.prefix=="string"?g.prefix:VF;if(!t.getLanguage(f))throw new Error("Unknown language: `"+f+"` is not registered");t.configure({__emitter:KF,classPrefix:x});const v=t.highlight(p,{ignoreIllegals:!0,language:f});if(v.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:v.errorRaised});const S=v._emitter.root,A=S.data;return A.language=v.language,A.relevance=v.relevance,S}function i(f,p){const g=(p||cT).subset||r();let x=-1,v=0,S;for(;++x<g.length;){const A=g[x];if(!t.getLanguage(A))continue;const T=n(A,f,p);T.data&&T.data.relevance!==void 0&&T.data.relevance>v&&(v=T.data.relevance,S=T)}return S||{type:"root",children:[],data:{language:void 0,relevance:v}}}function r(){return t.listLanguages()}function s(f,p){if(typeof f=="string")t.registerLanguage(f,p);else{let m;for(m in f)Object.hasOwn(f,m)&&t.registerLanguage(m,f[m])}}function l(f,p){if(typeof f=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:f});else{let m;for(m in f)if(Object.hasOwn(f,m)){const g=f[m];t.registerAliases(typeof g=="string"?g:[...g],{languageName:m})}}}function c(f){return!!t.getLanguage(f)}}class KF{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],i=n.children[n.children.length-1];i&&i.type==="text"?i.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const i=this.stack[this.stack.length-1],r=t.root.children;n?i.children.push({type:"element",tagName:"span",properties:{className:[n]},children:r}):i.children.push(...r)}openNode(t){const n=this,i=t.split(".").map(function(l,c){return c?l+"_".repeat(c):n.options.classPrefix+l}),r=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:i},children:[]};r.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const $F={};function WF(e){const t=e||$F,n=t.aliases,i=t.detect||!1,r=t.languages||FF,s=t.plainText,l=t.prefix,c=t.subset;let f="hljs";const p=XF(r);if(n&&p.registerAlias(n),l){const m=l.indexOf("-");f=m===-1?l:l.slice(0,m)}return function(m,g){dx(m,"element",function(x,v,S){if(x.tagName!=="code"||!S||S.type!=="element"||S.tagName!=="pre")return;const A=QF(x);if(A===!1||!A&&!i||A&&s&&s.includes(A))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(f)||x.properties.className.unshift(f);const T=mP(x,{whitespace:"pre"});let C;try{C=A?p.highlight(A,T,{prefix:l}):p.highlightAuto(T,{prefix:l,subset:c})}catch(N){const R=N;if(A&&/Unknown language/.test(R.message)){g.message("Cannot highlight as `"+A+"`, it’s not registered",{ancestors:[S,x],cause:R,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw R}!A&&C.data&&C.data.language&&x.properties.className.push("language-"+C.data.language),C.children.length>0&&(x.children=C.children)})}}function QF(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let i;for(;++n<t.length;){const r=String(t[n]);if(r==="no-highlight"||r==="nohighlight")return!1;!i&&r.slice(0,5)==="lang-"&&(i=r.slice(5)),!i&&r.slice(0,9)==="language-"&&(i=r.slice(9))}return i}function ZF({text:e}){const[t,n]=j.useState(!1),i=()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})};return _.jsx("button",{onClick:i,style:{position:"absolute",top:6,right:6,background:"var(--surface-4)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-xs)",color:t?"var(--status-active)":"var(--text-muted)",fontSize:"0.65rem",fontFamily:"var(--font-mono)",padding:"2px 8px",cursor:"pointer",transition:"color var(--duration-fast) var(--ease-out)"},children:t?"Copied!":"Copy"})}function M1({content:e}){return _.jsx("div",{className:"markdown-message",children:_.jsx($H,{remarkPlugins:[oP],rehypePlugins:[WF],components:{pre({children:t,...n}){const i=Array.isArray(t)?t.find(s=>{var l,c;return(s==null?void 0:s.type)==="code"||((c=(l=s==null?void 0:s.props)==null?void 0:l.node)==null?void 0:c.tagName)==="code"}):t,r=typeof i=="object"&&i!==null&&"props"in i?R1(i.props.children):"";return _.jsxs("div",{style:{position:"relative"},children:[_.jsx(ZF,{text:r}),_.jsx("pre",{...n,style:{background:"var(--surface-0)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",padding:"12px 14px",paddingTop:28,margin:"8px 0",overflowX:"auto",fontSize:"0.78rem",lineHeight:1.6,fontFamily:"var(--font-mono)"},children:t})]})},code({className:t,children:n,...i}){return t?_.jsx("code",{className:t,...i,children:n}):_.jsx("code",{...i,style:{background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",padding:"1px 5px",fontSize:"0.82em",fontFamily:"var(--font-mono)",color:"var(--accent)"},children:n})},a({href:t,children:n,...i}){return _.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"none"},...i,children:n})},table({children:t,...n}){return _.jsx("div",{style:{overflowX:"auto",margin:"8px 0"},children:_.jsx("table",{...n,style:{borderCollapse:"collapse",width:"100%",fontSize:"0.82rem"},children:t})})},th({children:t,...n}){return _.jsx("th",{...n,style:{borderBottom:"2px solid var(--border-default)",padding:"6px 10px",textAlign:"left",fontWeight:600,color:"var(--text-primary)"},children:t})},td({children:t,...n}){return _.jsx("td",{...n,style:{borderBottom:"1px solid var(--border-subtle)",padding:"5px 10px",color:"var(--text-secondary)"},children:t})},blockquote({children:t,...n}){return _.jsx("blockquote",{...n,style:{borderLeft:"3px solid var(--accent-dim)",margin:"8px 0",padding:"4px 12px",color:"var(--text-secondary)",background:"rgba(0, 200, 255, 0.04)",borderRadius:"0 var(--radius-xs) var(--radius-xs) 0"},children:t})},hr(){return _.jsx("hr",{style:{border:"none",borderTop:"1px solid var(--border-default)",margin:"12px 0"}})},ul({children:t,...n}){return _.jsx("ul",{...n,style:{paddingLeft:20,margin:"4px 0"},children:t})},ol({children:t,...n}){return _.jsx("ol",{...n,style:{paddingLeft:20,margin:"4px 0"},children:t})},li({children:t,...n}){return _.jsx("li",{...n,style:{marginBottom:2},children:t})},h1({children:t,...n}){return _.jsx("h1",{...n,style:{fontSize:"1.3em",fontWeight:700,margin:"12px 0 6px"},children:t})},h2({children:t,...n}){return _.jsx("h2",{...n,style:{fontSize:"1.15em",fontWeight:600,margin:"10px 0 4px"},children:t})},h3({children:t,...n}){return _.jsx("h3",{...n,style:{fontSize:"1.05em",fontWeight:600,margin:"8px 0 4px"},children:t})},p({children:t,...n}){return _.jsx("p",{...n,style:{margin:"4px 0",lineHeight:1.6},children:t})}},children:e})})}function R1(e){var t;return typeof e=="string"?e:Array.isArray(e)?e.map(R1).join(""):(t=e==null?void 0:e.props)!=null&&t.children?R1(e.props.children):""}function JF({commands:e,filter:t,selectedIndex:n,onSelect:i,visible:r}){const s=j.useRef(null),l=j.useRef(null),c=e.filter(f=>f.command.toLowerCase().includes(t.toLowerCase())||f.description.toLowerCase().includes(t.toLowerCase()));return j.useEffect(()=>{var f;(f=l.current)==null||f.scrollIntoView({block:"nearest"})},[n]),!r||c.length===0?null:_.jsxs("div",{ref:s,style:{position:"absolute",bottom:"100%",left:0,right:0,marginBottom:4,background:"var(--surface-2)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-lg)",maxHeight:280,overflowY:"auto",zIndex:100,animation:"fadeInUp 0.15s var(--ease-out) both"},children:[_.jsx("div",{style:{padding:"8px 12px 4px",fontSize:"0.65rem",fontFamily:"var(--font-mono)",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Commands"}),c.map((f,p)=>{const m=p===n;return _.jsxs("div",{ref:m?l:void 0,onClick:()=>i(f),style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",cursor:"pointer",background:m?"var(--accent-glow)":"transparent",borderLeft:m?"2px solid var(--accent)":"2px solid transparent",transition:"background var(--duration-fast) var(--ease-out)"},onMouseEnter:g=>{m||(g.currentTarget.style.background="var(--surface-3)")},onMouseLeave:g=>{m||(g.currentTarget.style.background="transparent")},children:[_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.8rem",fontWeight:600,color:m?"var(--accent)":"var(--text-primary)",whiteSpace:"nowrap"},children:["/",f.command,f.args&&_.jsxs("span",{style:{color:"var(--text-muted)",fontWeight:400},children:[" ",f.args]})]}),_.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.description})]},f.command)})]})}const uT=[{command:"expxagents",description:"Show main menu"},{command:"expxagents create",args:"[description]",description:"Design a new squad"},{command:"expxagents run",args:"<name>",description:"Execute a squad pipeline"},{command:"expxagents list",description:"List all squads"},{command:"expxagents edit",args:"<name>",description:"Modify a squad"},{command:"expxagents delete",args:"<name>",description:"Delete a squad"},{command:"expxagents skills",description:"Browse skills"},{command:"expxagents install",args:"<name>",description:"Install a skill"},{command:"expxagents uninstall",args:"<name>",description:"Remove a skill"},{command:"expxagents dashboard",description:"Open virtual office"},{command:"expxagents virtual-office",description:"Open virtual office in browser"},{command:"expxagents jarvis",description:"Open Jarvis voice assistant"},{command:"expxagents help",description:"Show help text"}];function eG({c:e}){return _.jsxs("div",{style:{padding:"12px",background:"#1e1e2e",borderRadius:"8px",minWidth:"120px"},children:[_.jsxs("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#cdd6f4"},children:[e.value,e.unit?` ${e.unit}`:""]}),_.jsx("div",{style:{fontSize:"12px",color:"#a6adc8",marginTop:"4px"},children:e.label})]})}function tG({c:e}){const t=Math.round(e.value*100);return _.jsxs("div",{style:{width:"100%"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[_.jsx("span",{style:{fontSize:"12px",color:"#a6adc8"},children:e.label}),_.jsxs("span",{style:{fontSize:"12px",color:"#cdd6f4"},children:[t,"%"]})]}),_.jsx("div",{style:{height:"6px",background:"#313244",borderRadius:"3px"},children:_.jsx("div",{style:{height:"100%",width:`${t}%`,background:"#89b4fa",borderRadius:"3px",transition:"width 0.3s"}})})]})}function nG({c:e}){return _.jsxs("div",{children:[e.title&&_.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#cdd6f4",marginBottom:"8px"},children:e.title}),_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[_.jsx("thead",{children:_.jsx("tr",{children:e.columns.map((t,n)=>_.jsx("th",{style:{textAlign:"left",padding:"4px 8px",color:"#a6adc8",borderBottom:"1px solid #313244"},children:t},n))})}),_.jsx("tbody",{children:e.rows.map((t,n)=>_.jsx("tr",{children:t.map((i,r)=>_.jsx("td",{style:{padding:"4px 8px",color:"#cdd6f4",borderBottom:"1px solid #1e1e2e"},children:i},r))},n))})]})]})}function iG({c:e}){return _.jsxs("div",{style:{padding:"12px",background:"#1e1e2e",borderRadius:"8px"},children:[_.jsx("div",{style:{fontWeight:600,color:"#cdd6f4",marginBottom:"6px"},children:e.title}),_.jsx("div",{style:{fontSize:"13px",color:"#a6adc8"},children:e.body})]})}const rG={green:"#a6e3a1",yellow:"#f9e2af",red:"#f38ba8",blue:"#89b4fa"};function aG({c:e}){return _.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:"12px",fontSize:"11px",fontWeight:600,color:"#1e1e2e",background:rG[e.color]??"#a6adc8"},children:e.label})}function sG({components:e}){return e.length===0?null:_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"12px"},children:e.map((t,n)=>{switch(t.type){case"metric":return _.jsx(eG,{c:t},n);case"progress":return _.jsx(tG,{c:t},n);case"table":return _.jsx(nG,{c:t},n);case"card":return _.jsx(iG,{c:t},n);case"badge":return _.jsx(aG,{c:t},n)}})})}const i0="_expxagents",eu=[.72,.78,.85,.95,1.08,1.2],lG=2;function oG({file:e,onRemove:t}){return _.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,background:"var(--surface-3)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-xs)",padding:"2px 8px",fontSize:"0.72rem",fontFamily:"var(--font-mono)",color:"var(--accent)",maxWidth:180},children:[_.jsx("span",{style:{opacity:.6},children:"📎"}),_.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),_.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",padding:0,fontSize:"0.8rem",lineHeight:1},"aria-label":`Remove ${e.name}`,children:"×"})]})}function cG({message:e,fontSize:t}){if(e.role==="agent_dm")return _.jsxs("div",{"data-role":"agent_dm",style:{alignSelf:"flex-start",background:"var(--surface-3)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",padding:"10px 14px",maxWidth:"85%",marginBottom:"var(--sp-2)",animation:"fadeInUp 0.3s var(--ease-out) both"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--accent)",fontWeight:600,marginBottom:4,letterSpacing:"0.02em"},children:e.agentName}),_.jsx("div",{style:{color:"var(--text-primary)",fontSize:`${t}rem`,lineHeight:1.55},children:_.jsx(M1,{content:e.content})})]});const n=e.role==="user";return _.jsx("div",{"data-role":e.role,style:{alignSelf:n?"flex-end":"flex-start",background:n?"var(--user-bubble)":"var(--agent-bubble)",border:n?"1px solid rgba(100, 160, 255, 0.15)":"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"10px 14px",maxWidth:n?"75%":"85%",marginBottom:"var(--sp-2)",animation:"fadeInUp 0.3s var(--ease-out) both"},children:_.jsx("div",{style:{color:"var(--text-primary)",fontSize:`${t}rem`,lineHeight:1.55},children:n?_.jsx("span",{style:{whiteSpace:"pre-wrap"},children:e.content}):_.jsx(M1,{content:e.content})})})}function uG({conv:e,isActive:t,onSelect:n,onDelete:i}){const[r,s]=j.useState(!1),l=new Date(e.createdAt),c=l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),f=l.toLocaleDateString([],{day:"2-digit",month:"2-digit"});return _.jsxs("div",{onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{padding:"8px 10px",borderRadius:"var(--radius-sm)",cursor:"pointer",background:t?"var(--accent-glow)":r?"var(--surface-3)":"transparent",border:t?"1px solid rgba(0, 200, 255, 0.12)":"1px solid transparent",transition:"all var(--duration-fast) var(--ease-out)",display:"flex",alignItems:"center",gap:8},children:[_.jsxs("div",{style:{flex:1,minWidth:0},children:[_.jsx("div",{style:{fontSize:"0.72rem",fontFamily:"var(--font-mono)",color:t?"var(--accent)":"var(--text-secondary)",fontWeight:t?600:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.preview||"New conversation"}),_.jsxs("div",{style:{fontSize:"0.6rem",fontFamily:"var(--font-mono)",color:"var(--text-muted)",marginTop:2},children:[f," ",c]})]}),r&&_.jsx("button",{onClick:p=>{p.stopPropagation(),i()},title:"Delete conversation","aria-label":"Delete conversation",style:{background:"none",border:"none",color:"var(--status-error)",cursor:"pointer",padding:"2px 4px",fontSize:"0.75rem",lineHeight:1,opacity:.7,flexShrink:0},children:"×"})]})}function dG(){const[e,t]=j.useState(""),[n,i]=j.useState([]),[r,s]=j.useState(lG),[l,c]=j.useState(!1),[f,p]=j.useState(""),[m,g]=j.useState(0),x=j.useRef(null),v=j.useRef(null),S=j.useRef(null),A=j.useRef(null),T=vr(le=>le.selectedSquad),C=vr(le=>le.uiComponents[T??""]),N=rr(le=>le.conversations),R=rr(le=>le.conversationId),O=rr(le=>le.messages),H=rr(le=>le.streaming),D=rr(le=>le.streamingText),F=rr(le=>le.activity),Z=rr(le=>le.error),V=rr(le=>le.addUserMessage),Y=rr(le=>le.startStreaming),P=rr(le=>le.loadHistory),q=rr(le=>le.selectConversation),ne=rr(le=>le.deleteConversation);j.useEffect(()=>{P(i0)},[P]),j.useEffect(()=>{var le,Re;(Re=(le=x.current)==null?void 0:le.scrollIntoView)==null||Re.call(le,{behavior:"smooth"})},[O,D]);const I=j.useCallback(()=>{const le=v.current;le&&(le.style.height="auto",le.style.height=Math.min(le.scrollHeight,200)+"px")},[]);j.useEffect(()=>{I()},[e,I]);const $=j.useCallback(le=>{if(le.startsWith("/")){const Re=le.slice(1);p(Re),c(!0),g(0)}else c(!1)},[]),z=j.useCallback(()=>uT.filter(le=>le.command.toLowerCase().includes(f.toLowerCase())||le.description.toLowerCase().includes(f.toLowerCase())),[f]),G=j.useCallback(le=>{var Re;t("/"+le.command+(le.args?" ":"")),c(!1),(Re=v.current)==null||Re.focus()},[]),Q=j.useCallback(()=>{H||P4(i0)},[H]),W=j.useCallback(le=>{H||ne(le,i0)},[H,ne]),B=j.useCallback(le=>{H||le===R||q(le)},[H,R,q]),K=j.useCallback(()=>{const le=e.trim();!le||H||(V(le),Y(),XC(i0,le,n.length>0?n:void 0),t(""),i([]),c(!1),v.current&&(v.current.style.height="auto"))},[e,H,n,V,Y]),J=j.useCallback(le=>{if(l){const Re=z();if(le.key==="ArrowDown"){le.preventDefault(),g(Le=>Math.min(Le+1,Re.length-1));return}if(le.key==="ArrowUp"){le.preventDefault(),g(Le=>Math.max(Le-1,0));return}if(le.key==="Enter"&&!le.shiftKey){le.preventDefault(),Re[m]&&G(Re[m]);return}if(le.key==="Escape"){le.preventDefault(),c(!1);return}if(le.key==="Tab"){le.preventDefault(),Re[m]&&G(Re[m]);return}}le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),K())},[l,z,m,G,K]),X=j.useCallback(le=>{const Re=le.target.value;t(Re),$(Re)},[$]),ce=j.useCallback(async le=>{var Le;if(!le)return;const Re=[];for(const je of Array.from(le))if(!(je.size>512e3))try{const He=await je.text();Re.push({name:je.name,content:He})}catch{}i(je=>[...je,...Re]),(Le=v.current)==null||Le.focus()},[]),ie=j.useCallback(le=>{le.preventDefault(),le.stopPropagation(),ce(le.dataTransfer.files)},[ce]),de=j.useCallback(le=>{le.preventDefault(),le.stopPropagation()},[]),ye=j.useCallback(le=>{i(Re=>Re.filter((Le,je)=>je!==le))},[]),me=e.trim()&&!H;return _.jsxs("div",{style:{display:"flex",height:"100%"},onDrop:ie,onDragOver:de,children:[_.jsxs("div",{style:{width:220,borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)",display:"flex",flexDirection:"column",flexShrink:0},children:[_.jsx("div",{style:{padding:"var(--sp-2)"},children:_.jsx("button",{onClick:Q,disabled:H,"aria-label":"New conversation",style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 10px",background:"var(--accent-glow)",border:"1px solid rgba(0, 200, 255, 0.15)",borderRadius:"var(--radius-sm)",color:"var(--accent)",cursor:H?"not-allowed":"pointer",fontFamily:"var(--font-mono)",fontSize:"0.72rem",fontWeight:600,letterSpacing:"0.02em",opacity:H?.5:1,transition:"all var(--duration-fast) var(--ease-out)"},children:"+ New Chat"})}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"0 var(--sp-2) var(--sp-2)",display:"flex",flexDirection:"column",gap:2},children:[N.length===0&&_.jsx("div",{style:{padding:"var(--sp-4) var(--sp-2)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)"},children:"No conversations yet"}),N.map(le=>_.jsx(uG,{conv:le,isActive:le.id===R,onSelect:()=>B(le.id),onDelete:()=>W(le.id)},le.id))]})]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",padding:"4px var(--sp-4)",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",gap:2},children:[_.jsx("button",{onClick:()=>s(le=>Math.max(le-1,0)),disabled:r===0,title:"Decrease font size","aria-label":"Decrease font size",style:{background:"none",border:"1px solid var(--border-default)",borderRadius:"var(--radius-xs)",color:r===0?"var(--text-muted)":"var(--text-secondary)",cursor:r===0?"not-allowed":"pointer",padding:"2px 7px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:700,lineHeight:1.4,opacity:r===0?.35:.7},children:"A-"}),_.jsx("button",{onClick:()=>s(le=>Math.min(le+1,eu.length-1)),disabled:r===eu.length-1,title:"Increase font size","aria-label":"Increase font size",style:{background:"none",border:"1px solid var(--border-default)",borderRadius:"var(--radius-xs)",color:r===eu.length-1?"var(--text-muted)":"var(--text-secondary)",cursor:r===eu.length-1?"not-allowed":"pointer",padding:"2px 7px",fontFamily:"var(--font-mono)",fontSize:"0.8rem",fontWeight:700,lineHeight:1.4,opacity:r===eu.length-1?.35:.7},children:"A+"})]}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"var(--sp-4)",display:"flex",flexDirection:"column"},children:[O.length===0&&!H&&_.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,gap:"var(--sp-3)",opacity:.6},children:[_.jsx("div",{style:{width:48,height:48,borderRadius:"var(--radius-md)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.2rem",color:"var(--accent)"},children:"EX"}),_.jsx("span",{style:{color:"var(--text-muted)",fontSize:"0.82rem",fontFamily:"var(--font-display)"},children:"ExpxAgents Terminal"}),_.jsx("span",{style:{color:"var(--text-muted)",fontSize:"0.7rem",fontFamily:"var(--font-mono)"},children:"Type / to see available commands"})]}),O.map(le=>_.jsx(cG,{message:le,fontSize:eu[r]},le.id)),H&&D&&_.jsx("div",{"data-role":"assistant",style:{alignSelf:"flex-start",background:"var(--agent-bubble)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"10px 14px",maxWidth:"85%",marginBottom:"var(--sp-2)"},children:_.jsxs("div",{style:{color:"var(--text-primary)",fontSize:`${eu[r]}rem`,lineHeight:1.55},children:[_.jsx(M1,{content:D}),_.jsx("span",{style:{display:"inline-block",width:6,height:14,background:"var(--accent)",marginLeft:2,animation:"pulse 1s ease-in-out infinite",borderRadius:1,verticalAlign:"text-bottom"}})]})}),H&&!D&&_.jsx("div",{style:{alignSelf:"flex-start",display:"flex",flexDirection:"column",gap:4,padding:"10px 14px",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[_.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:"var(--accent)",animation:"pulse 1s ease-in-out infinite"}}),F||"Thinking..."]})}),Z&&_.jsx("div",{style:{alignSelf:"center",background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.25)",borderRadius:"var(--radius-sm)",padding:"8px 14px",color:"var(--status-error)",fontFamily:"var(--font-mono)",fontSize:"0.78rem",marginBottom:"var(--sp-2)"},children:Z}),_.jsx("div",{ref:x}),C&&C.length>0&&_.jsx("div",{style:{borderTop:"1px solid #313244",marginTop:"8px"},children:_.jsx(sG,{components:C})})]}),_.jsxs("div",{ref:A,style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)",position:"relative"},children:[_.jsx("div",{style:{position:"relative",padding:"0 var(--sp-4)"},children:_.jsx(JF,{commands:uT,filter:f,selectedIndex:m,onSelect:G,visible:l})}),n.length>0&&_.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,padding:"var(--sp-2) var(--sp-4) 0"},children:n.map((le,Re)=>_.jsx(oG,{file:le,onRemove:()=>ye(Re)},`${le.name}-${Re}`))}),_.jsxs("div",{style:{display:"flex",padding:"var(--sp-3) var(--sp-4)",gap:"var(--sp-2)",alignItems:"flex-end"},children:[_.jsx("button",{onClick:()=>{var le;return(le=S.current)==null?void 0:le.click()},disabled:H,title:"Attach files (text only, max 500KB)",style:{background:"none",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",color:"var(--text-muted)",cursor:H?"not-allowed":"pointer",padding:"6px 8px",fontSize:"1rem",lineHeight:1,opacity:H?.4:.7,transition:"opacity var(--duration-fast) var(--ease-out)",flexShrink:0},"aria-label":"Attach file",children:"📎"}),_.jsx("input",{ref:S,type:"file",multiple:!0,style:{display:"none"},onChange:le=>ce(le.target.files)}),_.jsx("textarea",{ref:v,className:"input",value:e,onChange:X,onKeyDown:J,placeholder:"Type a message... (/ for commands)",disabled:H,rows:1,style:{flex:1,resize:"none",overflow:"hidden",minHeight:36,maxHeight:200,lineHeight:1.5,fontFamily:"var(--font-mono)",fontSize:`${eu[r]}rem`}}),_.jsx("button",{onClick:K,disabled:!me,"aria-label":"Send",className:me?"btn btn-accent":"btn",style:{padding:"0 var(--sp-5)",cursor:me?"pointer":"not-allowed",opacity:me?1:.4,flexShrink:0,height:36},children:"Send"})]})]})]})]})}const fG={planned:"var(--status-idle)",executing:"var(--accent)",done:"var(--status-active)",failed:"var(--status-error)"},hG={planned:"planejado",executing:"executando",done:"finalizado",failed:"falhou"};function pG({task:e,selected:t,onClick:n,onDelete:i}){const r=fG[e.status],s=e.status==="executing",l=f=>{f.dataTransfer.setData("text/plain",`task:${e.id}`),f.dataTransfer.effectAllowed="move",f.currentTarget.style.opacity="0.5"},c=f=>{f.currentTarget.style.opacity="1"};return _.jsxs("div",{draggable:!e.activity_id,onDragStart:l,onDragEnd:c,onClick:()=>n==null?void 0:n(e),"data-testid":`task-card-${e.id}`,style:{background:t?"var(--surface-4)":"var(--surface-3)",borderRadius:"var(--radius-sm)",padding:"12px 14px",marginBottom:"var(--sp-2)",border:"1px solid",borderColor:t?"var(--accent)":s?r:"var(--border-subtle)",transition:"border-color var(--duration-fast) var(--ease-out), opacity 0.15s ease",cursor:"pointer"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",fontWeight:600,color:r,padding:"2px 8px",borderRadius:"var(--radius-full)",border:`1px solid ${r}`,letterSpacing:"0.02em"},children:hG[e.status]}),i&&_.jsx("button",{onClick:f=>{f.stopPropagation(),i(e.id)},style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:"0.7rem",padding:"0 2px",lineHeight:1,opacity:.5,transition:"opacity 0.15s, color 0.15s"},onMouseEnter:f=>{f.currentTarget.style.opacity="1",f.currentTarget.style.color="var(--status-error)"},onMouseLeave:f=>{f.currentTarget.style.opacity="0.5",f.currentTarget.style.color="var(--text-muted)"},title:"Delete task",children:"✕"})]}),_.jsx("div",{style:{fontWeight:600,fontSize:"0.82rem",color:"var(--text-primary)",marginBottom:e.description?6:0,lineHeight:1.4},children:e.title}),e.description&&_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-secondary)",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.description}),e.agent_name&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"var(--text-muted)",marginTop:2,display:"flex",alignItems:"center",gap:4},children:[_.jsx("span",{children:"🤖"}),e.agent_name]}),e.step_id&&!e.agent_name&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"var(--accent-dim)",marginTop:2},children:["◆"," checkpoint"]}),e.triggered_by&&e.triggered_by!=="dashboard"&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",marginTop:4,opacity:.7},children:[e.triggered_by==="chat"?"💬":e.triggered_by==="schedule"?"⏰":e.triggered_by==="chain"?"🔗":""," ",e.triggered_by]}),e.activity_id&&_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--accent-dim)",marginTop:4,padding:"1px 6px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-full)",display:"inline-block"},children:e.squad_code}),e.result&&_.jsxs("div",{style:{marginTop:6,fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--status-active)",display:"flex",alignItems:"center",gap:4},children:[_.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--status-active)",display:"inline-block"}}),"has output"]})]})}const ck=[{key:"planned",label:"Planejado",color:"var(--status-idle)",glow:"none"},{key:"executing",label:"Executando",color:"var(--accent)",glow:"var(--accent-glow)"},{key:"done",label:"Finalizado",color:"var(--status-active)",glow:"var(--status-active-glow)"},{key:"failed",label:"Falhou",color:"var(--status-error)",glow:"none"}];function bv(e){if(!e)return"—";const t=new Date(e);return t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function vv(e,t){if(!e||!t)return null;const n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;if(n<1e3)return`${n}ms`;const i=Math.floor(n/1e3);if(i<60)return`${i}s`;const r=Math.floor(i/60),s=i%60;if(r<60)return`${r}m ${s}s`;const l=Math.floor(r/60),c=r%60;return`${l}h ${c}m`}function mG(){const e=vr(I=>I.squads),t=vr(I=>I.activeStates),[n,i]=j.useState(null),[r,s]=j.useState(""),[l,c]=j.useState([]),[f,p]=j.useState(null),[m,g]=j.useState(""),[x,v]=j.useState(""),[S,A]=j.useState(null),[T,C]=j.useState(null),[N,R]=j.useState(!1),O=n;j.useEffect(()=>{if(!O){c([]),C(null);return}const I=O==="__all__"?"/api/kanban/tasks":`/api/kanban/${O}/tasks`;fetch(I,{credentials:"include"}).then($=>$.json()).then($=>c(Array.isArray($)?$:[])).catch(()=>c([]))},[O]),j.useEffect(()=>{const I=$=>{const z=$.detail;if(!(z!=null&&z.activityId)||!O)return;const G=O==="__all__"?"/api/kanban/tasks":`/api/kanban/${O}/tasks`;fetch(G,{credentials:"include"}).then(Q=>Q.json()).then(Q=>{const W=Array.isArray(Q)?Q:[];c(W),C(B=>B?W.find(J=>J.id===B.id)??null:null)}).catch(()=>{})};return window.addEventListener("kanban:task_updated",I),()=>window.removeEventListener("kanban:task_updated",I)},[O]);const H=j.useMemo(()=>ck.map(I=>({...I,tasks:l.filter($=>$.status===I.key).sort(($,z)=>$.position-z.position)})),[l]),D=e.filter(I=>{if(!r)return!0;const $=r.toLowerCase();return I.name.toLowerCase().includes($)||I.code.toLowerCase().includes($)}),F=j.useCallback(async I=>{if(!O||!m.trim())return;const $=await fetch(`/api/kanban/${O}/tasks`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:m.trim(),description:x.trim()||void 0,status:I})});if($.ok){const z=await $.json();c(G=>[...G,z]),g(""),v(""),p(null)}},[O,m,x]),Z=j.useCallback(async I=>{if(!O)return;(await fetch(`/api/kanban/${O}/tasks/${I}`,{method:"DELETE",credentials:"include"})).ok&&(c(z=>z.filter(G=>G.id!==I)),(T==null?void 0:T.id)===I&&C(null))},[O,T]),V=j.useCallback(async(I,$)=>{if(!O)return;const z=l.find(Q=>Q.id===I);if(!z||z.status===$)return;c(Q=>Q.map(W=>W.id===I?{...W,status:$}:W));const G=await fetch(`/api/kanban/${O}/tasks/${I}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:$})});if(G.ok){const Q=await G.json();c(W=>W.map(B=>B.id===I?Q:B)),(T==null?void 0:T.id)===I&&C(Q),$==="executing"&&XC(O,`Execute a seguinte tarefa do kanban: ${z.title}${z.description?" — "+z.description:""}`)}else c(Q=>Q.map(W=>W.id===I?z:W))},[O,l,T]),Y=j.useCallback(async(I,$)=>{if(!O)return;const z=await fetch(`/api/kanban/${O}/tasks/${I}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({result:$})});if(z.ok){const G=await z.json();c(Q=>Q.map(W=>W.id===I?G:W)),C(G)}},[O]),P=j.useCallback((I,$)=>{I.preventDefault(),I.dataTransfer.dropEffect="move",A($)},[]),q=j.useCallback(()=>{A(null)},[]),ne=j.useCallback((I,$)=>{I.preventDefault(),A(null);const z=I.dataTransfer.getData("text/plain");if(!z.startsWith("task:"))return;const G=z.replace("task:","");V(G,$)},[V]);return _.jsxs("div",{style:{display:"flex",overflow:"hidden",...N?{position:"fixed",inset:0,zIndex:200,background:"var(--surface-0)"}:{height:"100%"}},children:[_.jsxs("div",{style:{width:240,minWidth:240,borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[_.jsxs("div",{style:{padding:"8px 14px",borderBottom:"1px solid var(--border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Squads"}),_.jsx("button",{onClick:()=>R(I=>!I),title:N?"Voltar ao modo normal":"Modo foco — tela cheia",style:{background:N?"rgba(0,200,255,0.1)":"transparent",border:`1px solid ${N?"var(--accent)":"var(--border-subtle)"}`,color:N?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.58rem",padding:"2px 7px",borderRadius:3},children:N?"← Normal":"⛶ Foco"})]}),_.jsx("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border-subtle)"},children:_.jsx("input",{type:"text",placeholder:"Search squads...",value:r,onChange:I=>s(I.target.value),style:{width:"100%",padding:"5px 8px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",outline:"none"}})}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"6px 8px"},children:[D.map(I=>{var G;const $=I.code===O,z=!!t[I.code];return _.jsxs("button",{onClick:()=>{i(I.code),C(null)},style:{width:"100%",background:$?"var(--accent-glow)":"none",border:$?"1px solid rgba(0, 200, 255, 0.12)":"1px solid transparent",borderRadius:"var(--radius-sm)",padding:"8px 10px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",textAlign:"left",marginBottom:2},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:z?"var(--status-active)":"var(--status-idle)",flexShrink:0}}),_.jsxs("div",{style:{overflow:"hidden"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",fontWeight:$?600:400,color:$?"var(--accent)":"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:I.name}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)"},children:[((G=I.agents)==null?void 0:G.length)||0," agents"]})]})]},I.code)}),D.length===0&&_.jsx("div",{style:{padding:"16px 10px",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)",textAlign:"center"},children:"No squads found"})]})]}),_.jsx("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:O?_.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[_.jsx("div",{style:{display:"flex",gap:"var(--sp-4)",padding:"var(--sp-5)",flex:1,overflow:"auto"},children:H.map((I,$)=>{const z=S===I.key;return _.jsxs("div",{"data-testid":`column-${I.key}`,onDragOver:G=>P(G,I.key),onDragLeave:q,onDrop:G=>ne(G,I.key),style:{flex:1,background:z?"rgba(0, 200, 255, 0.04)":"var(--surface-2)",border:z?"1px dashed var(--accent)":"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-4)",display:"flex",flexDirection:"column",minWidth:220,animation:`fadeInUp 0.4s var(--ease-out) ${$*80}ms both`,transition:"background 0.15s ease, border-color 0.15s ease"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--sp-4)",paddingBottom:"var(--sp-3)",borderBottom:`2px solid ${I.color}`},children:[_.jsx("span",{style:{fontWeight:600,fontSize:"0.82rem",color:"var(--text-primary)"},children:I.label}),_.jsx("span",{"data-testid":`count-${I.key}`,style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:700,color:I.color,background:I.glow,width:22,height:22,borderRadius:"var(--radius-full)",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${I.color}`},children:I.tasks.length})]}),_.jsx("div",{style:{flex:1,overflowY:"auto"},children:I.tasks.map(G=>_.jsx(pG,{task:G,selected:(T==null?void 0:T.id)===G.id,onClick:C,onDelete:G.activity_id?void 0:Z},G.id))}),f===I.key?_.jsxs("div",{style:{marginTop:"var(--sp-3)",background:"var(--surface-3)",borderRadius:"var(--radius-sm)",padding:"10px 12px",border:"1px solid var(--border-default)"},children:[_.jsx("input",{type:"text",placeholder:"Title",value:m,onChange:G=>g(G.target.value),autoFocus:!0,onKeyDown:G=>{G.key==="Enter"&&m.trim()&&F(I.key),G.key==="Escape"&&(p(null),g(""),v(""))},style:{width:"100%",padding:"5px 8px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-display)",fontSize:"0.82rem",fontWeight:600,outline:"none",marginBottom:6}}),_.jsx("textarea",{placeholder:"Description (optional)",value:x,onChange:G=>v(G.target.value),onKeyDown:G=>{G.key==="Escape"&&(p(null),g(""),v(""))},rows:2,style:{width:"100%",padding:"5px 8px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-secondary)",fontFamily:"var(--font-mono)",fontSize:"0.7rem",outline:"none",resize:"none",marginBottom:8}}),_.jsxs("div",{style:{display:"flex",gap:6},children:[_.jsx("button",{onClick:()=>F(I.key),disabled:!m.trim(),style:{background:m.trim()?"var(--accent)":"var(--surface-4)",border:"none",borderRadius:"var(--radius-xs)",padding:"4px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:m.trim()?"var(--text-inverse)":"var(--text-muted)",cursor:m.trim()?"pointer":"default"},children:"Add"}),_.jsx("button",{onClick:()=>{p(null),g(""),v("")},style:{background:"none",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",padding:"4px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-secondary)",cursor:"pointer"},children:"Cancel"})]})]}):_.jsx("button",{"data-testid":`add-task-${I.key}`,onClick:()=>{p(I.key),g(""),v("")},style:{marginTop:"var(--sp-3)",width:"100%",background:"none",border:"1px dashed var(--border-default)",borderRadius:"var(--radius-sm)",padding:"8px",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-muted)",cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:G=>{G.currentTarget.style.borderColor="var(--accent-dim)",G.currentTarget.style.color="var(--accent)"},onMouseLeave:G=>{G.currentTarget.style.borderColor="var(--border-default)",G.currentTarget.style.color="var(--text-muted)"},children:"+ New Task"})]},I.key)})}),T&&_.jsx(gG,{task:T,onClose:()=>C(null),onMove:V,onUpdateResult:Y})]}):_.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"var(--sp-3)",animation:"fadeIn 0.5s var(--ease-out) both"},children:[_.jsx("span",{style:{fontSize:"1.5rem",color:"var(--text-muted)",opacity:.4},children:"▦"}),_.jsx("span",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Select a squad to view the kanban"})]})})]})}function gG({task:e,onClose:t,onMove:n,onUpdateResult:i}){const[r,s]=j.useState(!1),[l,c]=j.useState(e.result||"");j.useEffect(()=>{c(e.result||""),s(!1)},[e.id,e.result]);const f=()=>{i(e.id,l),s(!1)},p=e.status==="planned"?"var(--status-idle)":e.status==="executing"?"var(--accent)":e.status==="failed"?"var(--status-error)":"var(--status-active)";return _.jsxs("div",{"data-testid":"task-detail-panel",style:{width:360,minWidth:360,borderLeft:"1px solid var(--border-subtle)",background:"var(--surface-1)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideInRight 0.2s var(--ease-out) both"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:600,color:p,padding:"2px 10px",borderRadius:"var(--radius-full)",border:`1px solid ${p}`,textTransform:"uppercase"},children:e.status==="planned"?"planejado":e.status==="executing"?"executando":e.status==="failed"?"falhou":"finalizado"}),_.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:"1rem",padding:"0 4px"},children:"✕"})]}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px"},children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontSize:"1rem",fontWeight:700,color:"var(--text-primary)",marginBottom:8,lineHeight:1.3},children:e.title}),e.description&&_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.78rem",color:"var(--text-secondary)",lineHeight:1.5,marginBottom:16},children:e.description}),_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,marginBottom:20,padding:"12px",background:"var(--surface-2)",borderRadius:"var(--radius-sm)"},children:[_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",marginBottom:2},children:"Created"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)"},children:bv(e.created_at)})]}),_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",marginBottom:2},children:"Started"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)"},children:bv(e.started_at)})]}),_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",marginBottom:2},children:"Finished"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)"},children:bv(e.finished_at)})]}),_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",marginBottom:2},children:"Duration"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:vv(e.started_at,e.finished_at)?"var(--accent)":"var(--text-secondary)",fontWeight:vv(e.started_at,e.finished_at)?600:400},children:vv(e.started_at,e.finished_at)??"—"})]})]}),_.jsxs("div",{style:{marginBottom:20},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"Move to"}),_.jsx("div",{style:{display:"flex",gap:6},children:ck.filter(m=>m.key!==e.status).map(m=>_.jsx("button",{"data-testid":`move-to-${m.key}`,onClick:()=>n(e.id,m.key),style:{flex:1,background:"var(--surface-3)",border:`1px solid ${m.color}`,borderRadius:"var(--radius-xs)",padding:"6px 10px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:m.color,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:g=>{g.currentTarget.style.background=m.glow!=="none"?m.glow:"var(--surface-4)"},onMouseLeave:g=>{g.currentTarget.style.background="var(--surface-3)"},children:m.label},m.key))})]}),_.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Output / Result"}),!r&&_.jsx("button",{onClick:()=>{s(!0),c(e.result||"")},style:{background:"none",border:"none",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--accent-dim)",cursor:"pointer"},children:e.result?"edit":"+ add"})]}),r?_.jsxs("div",{children:[_.jsx("textarea",{value:l,onChange:m=>c(m.target.value),autoFocus:!0,rows:8,style:{width:"100%",padding:"10px 12px",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",lineHeight:1.6,outline:"none",resize:"vertical",marginBottom:8}}),_.jsxs("div",{style:{display:"flex",gap:6},children:[_.jsx("button",{onClick:f,style:{background:"var(--accent)",border:"none",borderRadius:"var(--radius-xs)",padding:"4px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:"var(--text-inverse)",cursor:"pointer"},children:"Save"}),_.jsx("button",{onClick:()=>s(!1),style:{background:"none",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",padding:"4px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-secondary)",cursor:"pointer"},children:"Cancel"})]})]}):e.result?_.jsx("div",{style:{padding:"12px",background:"var(--surface-2)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-primary)",lineHeight:1.6,whiteSpace:"pre-wrap",maxHeight:300,overflowY:"auto"},children:e.result}):_.jsx("div",{style:{padding:"20px",background:"var(--surface-2)",borderRadius:"var(--radius-sm)",border:"1px dashed var(--border-default)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-muted)"},children:"No output yet"})]})]})]})}function yG(){const e=gl(R=>R.user),[t,n]=j.useState([]),[i,r]=j.useState(!0),[s,l]=j.useState(""),[c,f]=j.useState(""),[p,m]=j.useState("viewer"),[g,x]=j.useState(null),[v,S]=j.useState(null),A=j.useCallback(async()=>{try{const R=await fetch("/api/users",{credentials:"include"});if(R.ok){const O=await R.json();n(O.users)}}catch{x("Failed to load users")}finally{r(!1)}},[]);j.useEffect(()=>{A()},[A]);const T=async()=>{if(!(!s.trim()||!c.trim())){x(null);try{const R=await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:s,password:c,role:p}),credentials:"include"});if(!R.ok){const O=await R.json();x(O.error||"Failed to create user");return}l(""),f(""),m("viewer"),await A()}catch{x("Network error")}}},C=async(R,O)=>{try{(await fetch(`/api/users/${R}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({role:O}),credentials:"include"})).ok&&await A()}catch{x("Failed to update role")}},N=async R=>{try{(await fetch(`/api/users/${R}`,{method:"DELETE",credentials:"include"})).ok&&(S(null),await A())}catch{x("Failed to delete user")}};return i?_.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading users..."}):_.jsxs("div",{children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",marginBottom:"var(--sp-4)"},children:"User Management"}),g&&_.jsx("div",{style:{background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.2)",color:"var(--status-error)",padding:"var(--sp-2) var(--sp-3)",borderRadius:"var(--radius-sm)",marginBottom:"var(--sp-3)",fontFamily:"var(--font-mono)",fontSize:"0.78rem"},children:g}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)",marginBottom:"var(--sp-5)",flexWrap:"wrap",alignItems:"center"},children:[_.jsx("input",{className:"input",placeholder:"Username",value:s,onChange:R=>l(R.target.value),style:{flex:1,minWidth:120}}),_.jsx("input",{className:"input",placeholder:"Password",type:"password",value:c,onChange:R=>f(R.target.value),style:{flex:1,minWidth:120}}),_.jsxs("select",{className:"input",value:p,onChange:R=>m(R.target.value),style:{minWidth:100},children:[_.jsx("option",{value:"viewer",children:"viewer"}),_.jsx("option",{value:"operator",children:"operator"}),_.jsx("option",{value:"admin",children:"admin"})]}),_.jsx("button",{onClick:T,className:"btn btn-accent",children:"Create User"})]}),_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{borderBottom:"1px solid var(--border-default)"},children:["Username","Email","Role","Last Login","Actions"].map((R,O)=>_.jsx("th",{style:{textAlign:O===4?"right":"left",padding:"8px 12px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em"},children:R},R))})}),_.jsx("tbody",{children:t.map(R=>_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-primary)",fontSize:"0.82rem"},children:R.username}),_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-secondary)",fontSize:"0.82rem"},children:R.email||"—"}),_.jsx("td",{style:{padding:"10px 12px"},children:R.id===(e==null?void 0:e.id)?_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)"},children:R.role}):_.jsxs("select",{className:"input",value:R.role,onChange:O=>C(R.id,O.target.value),style:{padding:"4px 8px",fontSize:"0.75rem"},children:[_.jsx("option",{value:"viewer",children:"viewer"}),_.jsx("option",{value:"operator",children:"operator"}),_.jsx("option",{value:"admin",children:"admin"})]})}),_.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:R.last_login?new Date(R.last_login).toLocaleDateString():"—"}),_.jsx("td",{style:{padding:"10px 12px",textAlign:"right"},children:R.id!==(e==null?void 0:e.id)&&(v===R.id?_.jsxs("span",{style:{display:"inline-flex",gap:"var(--sp-2)",alignItems:"center"},children:[_.jsx("span",{style:{color:"var(--status-error)",fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:"Confirm?"}),_.jsx("button",{onClick:()=>N(R.id),className:"btn btn-sm btn-danger",children:"Yes"}),_.jsx("button",{onClick:()=>S(null),className:"btn btn-sm",children:"No"})]}):_.jsx("button",{onClick:()=>S(R.id),className:"btn btn-sm btn-danger",children:"Delete"}))})]},R.id))})]})]})}function xG(){const e=vr(f=>f.selectedSquad),t=vr(f=>f.activeStates),[n,i]=j.useState(null),[r,s]=j.useState(!1),l=e?t[e]:null;if(j.useEffect(()=>{if(!e){i(null);return}s(!0),fetch(`/api/squads/${e}`,{credentials:"include"}).then(f=>f.ok?f.json():null).then(f=>{f&&i(f.data)}).finally(()=>s(!1))},[e]),!e)return _.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontSize:"0.85rem"},children:"Select a squad to view details"});if(r)return _.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading squad details..."});const c={fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",fontWeight:600,marginBottom:"var(--sp-2)",textTransform:"uppercase",letterSpacing:"0.08em"};return _.jsxs("div",{children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",marginBottom:"var(--sp-4)"},children:"Squad Info"}),n&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Name"}),_.jsx("div",{style:{color:"var(--text-primary)",fontSize:"0.9rem",fontWeight:600},children:n.name})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Description"}),_.jsx("div",{style:{color:"var(--text-primary)",fontSize:"0.85rem",lineHeight:1.5},children:n.description})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Agents"}),_.jsx("div",{style:{display:"flex",gap:"var(--sp-2)",flexWrap:"wrap"},children:n.agents.map(f=>_.jsx("span",{style:{background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",padding:"4px 10px",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-primary)"},children:f.name},f.id))})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Pipeline Steps"}),_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-2)"},children:n.pipeline.steps.map((f,p)=>_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-3)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",padding:"8px 12px",fontSize:"0.82rem"},children:[_.jsx("span",{style:{background:"var(--accent)",color:"var(--text-inverse)",width:22,height:22,borderRadius:"var(--radius-full)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:700,flexShrink:0},children:p+1}),_.jsx("span",{style:{color:"var(--text-primary)"},children:f.label}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text-muted)",fontSize:"0.68rem",marginLeft:"auto"},children:f.agent})]},f.id))})]})]}),l&&_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Current State"}),_.jsx("pre",{"data-testid":"state-json",style:{background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",padding:"var(--sp-4)",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--accent)",overflow:"auto",maxHeight:400,lineHeight:1.5},children:JSON.stringify(l,null,2)})]})]})}function bG(){const[e,t]=j.useState(null),[n,i]=j.useState(null),[r,s]=j.useState(!0),[l,c]=j.useState(null),f=j.useCallback(async()=>{s(!0);try{const g=await fetch("/api/health",{credentials:"include"});if(g.ok){const x=await g.json();t(x),i(x.status==="ok")}else i(!1)}catch{i(!1)}finally{s(!1),c(new Date().toLocaleTimeString())}},[]);j.useEffect(()=>{f()},[f]);const p={fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",fontWeight:600,marginBottom:"var(--sp-2)",textTransform:"uppercase",letterSpacing:"0.08em"},m={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",marginBottom:"var(--sp-2)",fontSize:"0.82rem"};return _.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--sp-4)"},children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)"},children:"Server Info"}),_.jsx("button",{onClick:f,className:"btn btn-sm",children:"Refresh"})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:p,children:"Health Status"}),_.jsxs("div",{style:m,children:[_.jsx("span",{style:{color:"var(--text-primary)"},children:"API Server"}),r?_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)",animation:"pulse 1.5s ease-in-out infinite"},children:"Checking..."}):_.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"var(--sp-1)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",fontWeight:600,color:n?"var(--status-active)":"var(--status-error)"},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:n?"var(--status-active)":"var(--status-error)",display:"inline-block",boxShadow:n?"0 0 8px var(--status-active-glow)":"0 0 8px var(--status-error-glow)"}}),n?"Healthy":"Unhealthy"]})]})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:p,children:"Environment"}),_.jsxs("div",{style:m,children:[_.jsx("span",{style:{color:"var(--text-primary)"},children:"API Port"}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)"},children:"3001"})]}),_.jsxs("div",{style:m,children:[_.jsx("span",{style:{color:"var(--text-primary)"},children:"Dashboard Port (dev)"}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)"},children:"5173"})]})]}),l&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textAlign:"right"},children:["Last checked: ",l]})]})}const vG=[{key:"AWS_ACCESS_KEY_ID",label:"AWS Access Key ID",type:"password",hint:"Your AWS IAM access key"},{key:"AWS_SECRET_ACCESS_KEY",label:"AWS Secret Access Key",type:"password",hint:"Your AWS IAM secret key"},{key:"AWS_REGION",label:"AWS Region",type:"text",hint:"e.g. us-east-1, eu-west-1"},{key:"SES_FROM_EMAIL",label:"SES From Email",type:"text",hint:"Verified sender email in SES"},{key:"SES_RATE_LIMIT",label:"SES Rate Limit",type:"text",hint:"Max emails per second (default: 14)"},{key:"SERVER_URL",label:"Server URL",type:"text",hint:"Public URL for unsubscribe links"},{key:"PORT",label:"Port",type:"text",hint:"Server port (requires restart)"},{key:"CORS_ORIGIN",label:"CORS Origin",type:"text",hint:"Allowed origin for CORS"},{key:"NODE_ENV",label:"Node Environment",type:"text",hint:"development or production"}];function _G(){const[e,t]=j.useState({}),[n,i]=j.useState(!0),[r,s]=j.useState(!1),[l,c]=j.useState(null),[f,p]=j.useState(new Set);j.useEffect(()=>{fetch("/api/settings/env").then(x=>x.json()).then(x=>{t(x.settings||{}),i(!1)}).catch(()=>i(!1))},[]);const m=(x,v)=>{t(S=>({...S,[x]:v})),p(S=>new Set(S).add(x)),c(null)},g=async()=>{if(f.size===0)return;s(!0),c(null);const x={};for(const v of f)x[v]=e[v]||"";try{const v=await fetch("/api/settings/env",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(v.ok){const S=await v.json();t(S.settings),p(new Set),c({type:"success",text:"Settings saved successfully"})}else{const S=await v.json();c({type:"error",text:S.error||"Failed to save"})}}catch{c({type:"error",text:"Network error"})}finally{s(!1)}};return n?_.jsx("div",{style:{textAlign:"center",padding:"var(--sp-6)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:"Loading..."}):_.jsxs("div",{style:{maxWidth:640},children:[_.jsx("div",{style:{marginBottom:"var(--sp-4)"},children:_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)",lineHeight:1.6},children:"Server environment variables. Secret values are masked. Changes to PORT or NODE_ENV require a server restart."})}),_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-3)"},children:vG.map(x=>_.jsxs("div",{children:[_.jsx("label",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.04em",marginBottom:4},children:x.label}),_.jsx("input",{type:x.type,value:e[x.key]||"",onChange:v=>m(x.key,v.target.value),placeholder:x.hint,style:{width:"100%",padding:"8px 12px",background:"var(--surface-2)",border:f.has(x.key)?"1px solid var(--accent)":"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.78rem",boxSizing:"border-box"}}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)"},children:x.hint})]},x.key))}),_.jsxs("div",{style:{marginTop:"var(--sp-4)",display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[_.jsx("button",{onClick:g,disabled:f.size===0||r,style:{padding:"8px 24px",background:f.size>0?"var(--accent)":"var(--surface-3)",border:"none",borderRadius:"var(--radius-sm)",color:f.size>0?"var(--text-inverse)":"var(--text-muted)",cursor:f.size>0?"pointer":"default",fontFamily:"var(--font-display)",fontSize:"0.82rem",fontWeight:600,opacity:r?.6:1},children:r?"Saving...":`Save ${f.size>0?`(${f.size})`:""}`}),l&&_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:l.type==="success"?"var(--status-active)":"var(--status-error)"},children:l.text})]})]})}function SG(){const[e,t]=j.useState([]),[n,i]=j.useState(!0),[r,s]=j.useState(null),[l,c]=j.useState(null),[f,p]=j.useState(""),[m,g]=j.useState(""),[x,v]=j.useState(""),[S,A]=j.useState(""),[T,C]=j.useState(null),[N,R]=j.useState(""),[O,H]=j.useState(""),[D,F]=j.useState(""),[Z,V]=j.useState(""),Y=j.useCallback(async()=>{try{const z=await fetch("/api/team",{credentials:"include"});if(z.ok){const G=await z.json();t(G.members)}}catch{s("Failed to load team members")}finally{i(!1)}},[]);j.useEffect(()=>{Y()},[Y]);const P=async()=>{if(!(!f.trim()||!m.trim())){s(null);try{const z=await fetch("/api/team",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:f.trim(),role:m.trim(),email:x.trim()||void 0,phone:S.trim()||void 0}),credentials:"include"});if(!z.ok){const G=await z.json();s(G.error||"Failed to create team member");return}p(""),g(""),v(""),A(""),await Y()}catch{s("Network error")}}},q=z=>{C(z.id),R(z.name),H(z.role),F(z.email||""),V(z.phone||"")},ne=()=>{C(null)},I=async()=>{if(!(!T||!N.trim()||!O.trim())){s(null);try{(await fetch(`/api/team/${T}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N.trim(),role:O.trim(),email:D.trim()||void 0,phone:Z.trim()||void 0}),credentials:"include"})).ok&&(C(null),await Y())}catch{s("Failed to update member")}}},$=async z=>{try{(await fetch(`/api/team/${z}`,{method:"DELETE",credentials:"include"})).ok&&(c(null),await Y())}catch{s("Failed to delete member")}};return n?_.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading team..."}):_.jsxs("div",{children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",marginBottom:"var(--sp-4)"},children:"Team Members"}),r&&_.jsx("div",{style:{background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.2)",color:"var(--status-error)",padding:"var(--sp-2) var(--sp-3)",borderRadius:"var(--radius-sm)",marginBottom:"var(--sp-3)",fontFamily:"var(--font-mono)",fontSize:"0.78rem"},children:r}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)",marginBottom:"var(--sp-5)",flexWrap:"wrap",alignItems:"center"},children:[_.jsx("input",{className:"input",placeholder:"Name *",value:f,onChange:z=>p(z.target.value),style:{flex:1,minWidth:120}}),_.jsx("input",{className:"input",placeholder:"Role *",value:m,onChange:z=>g(z.target.value),style:{flex:1,minWidth:120}}),_.jsx("input",{className:"input",placeholder:"Email",type:"email",value:x,onChange:z=>v(z.target.value),style:{flex:1,minWidth:150}}),_.jsx("input",{className:"input",placeholder:"Phone",type:"tel",value:S,onChange:z=>A(z.target.value),style:{flex:1,minWidth:130}}),_.jsx("button",{onClick:P,className:"btn btn-accent",children:"Add Member"})]}),_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{borderBottom:"1px solid var(--border-default)"},children:["Name","Role","Email","Phone","Actions"].map((z,G)=>_.jsx("th",{style:{textAlign:G===4?"right":"left",padding:"8px 12px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em"},children:z},z))})}),_.jsxs("tbody",{children:[e.length===0&&_.jsx("tr",{children:_.jsx("td",{colSpan:5,style:{padding:"var(--sp-5)",textAlign:"center",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.78rem"},children:"No team members yet"})}),e.map(z=>T===z.id?_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-3)"},children:[_.jsx("td",{style:{padding:"6px 12px"},children:_.jsx("input",{className:"input",value:N,onChange:G=>R(G.target.value),style:{width:"100%",fontSize:"0.82rem"}})}),_.jsx("td",{style:{padding:"6px 12px"},children:_.jsx("input",{className:"input",value:O,onChange:G=>H(G.target.value),style:{width:"100%",fontSize:"0.82rem"}})}),_.jsx("td",{style:{padding:"6px 12px"},children:_.jsx("input",{className:"input",value:D,onChange:G=>F(G.target.value),style:{width:"100%",fontSize:"0.82rem"}})}),_.jsx("td",{style:{padding:"6px 12px"},children:_.jsx("input",{className:"input",value:Z,onChange:G=>V(G.target.value),style:{width:"100%",fontSize:"0.82rem"}})}),_.jsx("td",{style:{padding:"6px 12px",textAlign:"right"},children:_.jsxs("span",{style:{display:"inline-flex",gap:"var(--sp-2)"},children:[_.jsx("button",{onClick:I,className:"btn btn-sm btn-accent",children:"Save"}),_.jsx("button",{onClick:ne,className:"btn btn-sm",children:"Cancel"})]})})]},z.id):_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-primary)",fontSize:"0.82rem"},children:z.name}),_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-secondary)",fontSize:"0.82rem"},children:z.role}),_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-secondary)",fontSize:"0.82rem"},children:z.email||"—"}),_.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)"},children:z.phone||"—"}),_.jsx("td",{style:{padding:"10px 12px",textAlign:"right"},children:l===z.id?_.jsxs("span",{style:{display:"inline-flex",gap:"var(--sp-2)",alignItems:"center"},children:[_.jsx("span",{style:{color:"var(--status-error)",fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:"Confirm?"}),_.jsx("button",{onClick:()=>$(z.id),className:"btn btn-sm btn-danger",children:"Yes"}),_.jsx("button",{onClick:()=>c(null),className:"btn btn-sm",children:"No"})]}):_.jsxs("span",{style:{display:"inline-flex",gap:"var(--sp-2)"},children:[_.jsx("button",{onClick:()=>q(z),className:"btn btn-sm",children:"Edit"}),_.jsx("button",{onClick:()=>c(z.id),className:"btn btn-sm btn-danger",children:"Delete"})]})})]},z.id))]})]})]})}const EG={dev:"Development",messaging:"Messaging",ads:"Advertising",crm:"CRM",support:"Support",email:"Email Marketing",sales:"Sales & Payments",pm:"Project Management",monitoring:"Monitoring",cloud:"Cloud & Deploy",design:"Design"},wG={dev:"⌨",messaging:"💬",ads:"📢",crm:"📊",support:"🎧",email:"✉",sales:"💰",pm:"📋",monitoring:"🔍",cloud:"☁",design:"🎨"};function TG(){const[e,t]=j.useState([]),[n,i]=j.useState([]),[r,s]=j.useState(!0),[l,c]=j.useState(null),[f,p]=j.useState(null),[m,g]=j.useState(!1),[x,v]=j.useState({}),[S,A]=j.useState(!1),[T,C]=j.useState(null),[N,R]=j.useState(""),O=j.useCallback(async()=>{try{const[q,ne]=await Promise.all([fetch("/api/integrations/catalog",{credentials:"include"}),fetch("/api/integrations",{credentials:"include"})]);if(q.ok){const I=await q.json();t(I.providers)}if(ne.ok){const I=await ne.json();i(I.integrations)}}catch{c("Failed to load integrations")}finally{s(!1)}},[]);j.useEffect(()=>{O()},[O]);const H=q=>n.find(ne=>ne.provider===q),D=q=>{const ne=H(q.key),I={};for(const $ of q.fields)I[$.key]=(ne==null?void 0:ne.config[$.key])||"";v(I),A((ne==null?void 0:ne.enabled)??!1),p(q.key),c(null)},F=async()=>{if(f){g(!0),c(null);try{const q=await fetch(`/api/integrations/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:S,config:x}),credentials:"include"});if(!q.ok){const ne=await q.json();c(ne.error||"Failed to save");return}await O(),p(null)}catch{c("Network error")}finally{g(!1)}}},Z=async q=>{try{(await fetch(`/api/integrations/${q}`,{method:"DELETE",credentials:"include"})).ok&&(await O(),f===q&&p(null))}catch{c("Failed to disconnect")}},V=Array.from(new Set(e.map(q=>q.category))),Y=N.toLowerCase(),P=e.filter(q=>!(T&&q.category!==T||N&&!q.name.toLowerCase().includes(Y)&&!q.description.toLowerCase().includes(Y)));return r?_.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading integrations..."}):_.jsxs("div",{children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",marginBottom:"var(--sp-2)"},children:"Integrations"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-muted)",marginBottom:"var(--sp-4)"},children:"Configure third-party services for your squads and agents"}),_.jsx("input",{className:"input",type:"text",placeholder:"Search integrations...",value:N,onChange:q=>R(q.target.value),style:{width:"100%",fontSize:"0.8rem",marginBottom:"var(--sp-3)"}}),l&&_.jsx("div",{style:{background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.2)",color:"var(--status-error)",padding:"var(--sp-2) var(--sp-3)",borderRadius:"var(--radius-sm)",marginBottom:"var(--sp-3)",fontFamily:"var(--font-mono)",fontSize:"0.78rem"},children:l}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)",marginBottom:"var(--sp-4)",flexWrap:"wrap"},children:[_.jsx("button",{onClick:()=>C(null),style:{padding:"4px 12px",border:"1px solid",borderColor:T?"var(--border-subtle)":"var(--accent)",borderRadius:"var(--radius-sm)",background:T?"transparent":"var(--accent)",color:T?"var(--text-secondary)":"#fff",fontFamily:"var(--font-mono)",fontSize:"0.7rem",cursor:"pointer"},children:"All"}),V.map(q=>_.jsxs("button",{onClick:()=>C(q),style:{padding:"4px 12px",border:"1px solid",borderColor:T===q?"var(--accent)":"var(--border-subtle)",borderRadius:"var(--radius-sm)",background:T===q?"var(--accent)":"transparent",color:T===q?"#fff":"var(--text-secondary)",fontFamily:"var(--font-mono)",fontSize:"0.7rem",cursor:"pointer"},children:[wG[q]||""," ",EG[q]||q]},q))]}),_.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"var(--sp-3)"},children:P.map(q=>{const ne=H(q.key),I=f===q.key;return _.jsxs("div",{style:{background:"var(--surface-3)",border:"1px solid",borderColor:ne!=null&&ne.enabled?"var(--status-running)":"var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-3)",transition:"all var(--duration-fast) var(--ease-out)",gridColumn:I?"1 / -1":void 0},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:I?"var(--sp-3)":0},children:[_.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-2)"},children:[_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:600,fontSize:"0.85rem",color:"var(--text-primary)"},children:q.name}),(ne==null?void 0:ne.enabled)&&_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--status-running)",boxShadow:"0 0 4px var(--status-running)",display:"inline-block"}})]}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.68rem",color:"var(--text-muted)"},children:q.description})]}),_.jsx("button",{onClick:()=>I?p(null):D(q),className:"btn btn-sm",style:{flexShrink:0},children:I?"Close":ne?"Edit":"Configure"})]}),I&&_.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"var(--sp-3)"},children:[_.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"var(--sp-2)",marginBottom:"var(--sp-3)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)",cursor:"pointer"},children:[_.jsx("input",{type:"checkbox",checked:S,onChange:$=>A($.target.checked)}),"Enabled"]}),_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-2)"},children:q.fields.map($=>_.jsxs("div",{children:[_.jsxs("label",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:2,display:"block"},children:[$.label," ",$.required&&"*"]}),_.jsx("input",{className:"input",type:$.type==="password"?"password":"text",placeholder:$.placeholder||"",value:x[$.key]||"",onChange:z=>v(G=>({...G,[$.key]:z.target.value})),style:{width:"100%",fontSize:"0.8rem"}})]},$.key))}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)",marginTop:"var(--sp-3)",justifyContent:"flex-end"},children:[ne&&_.jsx("button",{onClick:()=>Z(q.key),className:"btn btn-sm btn-danger",children:"Disconnect"}),_.jsx("button",{onClick:()=>p(null),className:"btn btn-sm",children:"Cancel"}),_.jsx("button",{onClick:F,className:"btn btn-sm btn-accent",disabled:m,children:m?"Saving...":"Save"})]})]})]},q.key)})})]})}function CG(){const e=gl(l=>l.user),t=(e==null?void 0:e.role)==="admin",[n,i]=j.useState(t?"users":"squad"),s=[{key:"users",label:"Users",icon:"◉",adminOnly:!0},{key:"team",label:"Team",icon:"◎"},{key:"integrations",label:"Integrations",icon:"⬡"},{key:"squad",label:"Squad",icon:"⬢"},{key:"server",label:"Server",icon:"⚙"},{key:"env",label:"Environment",icon:"◆",adminOnly:!0}].filter(l=>!l.adminOnly||t);return _.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",padding:"var(--sp-5)",animation:"fadeIn 0.4s var(--ease-out) both"},children:[_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("h2",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1.1rem",color:"var(--text-primary)",marginBottom:"var(--sp-1)"},children:"Settings"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"Configuration and management"})]}),_.jsx("div",{style:{display:"flex",gap:"var(--sp-1)",marginBottom:"var(--sp-5)",borderBottom:"1px solid var(--border-subtle)"},children:s.map(l=>_.jsxs("button",{onClick:()=>i(l.key),style:{display:"flex",alignItems:"center",gap:"var(--sp-2)",padding:"10px 16px",border:"none",borderBottom:n===l.key?"2px solid var(--accent)":"2px solid transparent",background:"transparent",color:n===l.key?"var(--text-primary)":"var(--text-muted)",fontFamily:"var(--font-display)",fontWeight:n===l.key?600:400,fontSize:"0.82rem",cursor:"pointer",transition:"all var(--duration-fast) var(--ease-out)"},children:[_.jsx("span",{style:{fontSize:"0.75rem",opacity:.7},children:l.icon}),l.label]},l.key))}),_.jsxs("div",{style:{flex:1,overflow:"auto"},children:[n==="users"&&t&&_.jsx(yG,{}),n==="team"&&_.jsx(SG,{}),n==="integrations"&&_.jsx(TG,{}),n==="squad"&&_.jsx(xG,{}),n==="server"&&_.jsx(bG,{}),n==="env"&&t&&_.jsx(_G,{})]})]})}const uk=[{value:"0",label:"Domingo"},{value:"1",label:"Segunda"},{value:"2",label:"Terça"},{value:"3",label:"Quarta"},{value:"4",label:"Quinta"},{value:"5",label:"Sexta"},{value:"6",label:"Sábado"}];function AG(e,t){switch(e){case"every_n_minutes":return`*/${t.everyNMinutes||"30"} * * * *`;case"every_n_hours":return`${t.minute||"0"} */${t.everyNHours||"2"} * * *`;case"hourly":return`${t.minute||"0"} * * * *`;case"daily":return`${t.minute||"0"} ${t.hour||"9"} * * *`;case"weekly":return`${t.minute||"0"} ${t.hour||"9"} * * ${t.dayOfWeek||"1"}`;case"monthly":return`${t.minute||"0"} ${t.hour||"9"} ${t.dayOfMonth||"1"} * *`;case"custom":return"";default:return"0 9 * * *"}}function _v(e){var l;if(!e)return"";const t=e.split(" ");if(t.length!==5)return e;const[n,i,r,,s]=t;return n.startsWith("*/")?`A cada ${n.replace("*/","")} minutos`:i.startsWith("*/")?`A cada ${i.replace("*/","")} horas no minuto ${n}`:i==="*"&&r==="*"?`A cada hora no minuto ${n}`:r==="*"&&s==="*"?`Diariamente às ${i.padStart(2,"0")}:${n.padStart(2,"0")}`:r==="*"&&s!=="*"?`Semanalmente, ${((l=uk.find(f=>f.value===s))==null?void 0:l.label)||`dia ${s}`} às ${i.padStart(2,"0")}:${n.padStart(2,"0")}`:s==="*"&&r!=="*"?`Mensalmente, dia ${r} às ${i.padStart(2,"0")}:${n.padStart(2,"0")}`:e}function MG(e){if(e===null)return"—";if(e<1e3)return`${e}ms`;const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;if(n<60)return`${n}m ${i}s`;const r=Math.floor(n/60),s=n%60;return`${r}h ${s}m`}function dT(e){return e?new Date(e).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"—"}function RG(e){switch(e){case"completed":return{label:"Sucesso",color:"var(--status-active)"};case"failed":return{label:"Falhou",color:"var(--status-error)"};case"running":return{label:"Executando",color:"var(--status-warning)"};default:return{label:e,color:"var(--text-muted)"}}}const Kf={width:"100%",padding:"6px 10px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.78rem",outline:"none"},Ds={...Kf,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center",paddingRight:"28px"},oa={fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:4,display:"block"},ts={padding:"6px 16px",borderRadius:"var(--radius-xs)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",fontWeight:600,cursor:"pointer",border:"none",transition:"all 0.15s ease"};function fT({children:e,onClose:t,title:n,wide:i}){return _.jsx("div",{"data-testid":"modal-overlay",onClick:r=>{r.target===r.currentTarget&&t()},style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"var(--sp-4)",animation:"fadeIn 0.15s var(--ease-out) both"},children:_.jsxs("div",{"data-testid":"modal-content",style:{background:"var(--surface-1)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",width:"100%",maxWidth:i?900:560,maxHeight:"90vh",display:"flex",flexDirection:"column",animation:"fadeInUp 0.2s var(--ease-out) both"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--border-subtle)",flexShrink:0},children:[_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.9rem",color:"var(--text-primary)"},children:n}),_.jsx("button",{onClick:t,style:{...ts,padding:"4px 8px",fontSize:"0.7rem",background:"none",border:"none",color:"var(--text-muted)"},children:"✕"})]}),_.jsx("div",{style:{overflow:"auto",flex:1},children:e})]})})}function kG(){var sr,Ee,ke;const e=ua(oe=>oe.jobs),t=ua(oe=>oe.loading),n=ua(oe=>oe.fetchJobs),i=ua(oe=>oe.createJob),r=ua(oe=>oe.deleteJob),s=ua(oe=>oe.pauseJob),l=ua(oe=>oe.resumeJob),c=ua(oe=>oe.triggerJob),f=ua(oe=>oe.history),p=ua(oe=>oe.historyLoading),m=ua(oe=>oe.fetchHistory),g=vr(oe=>oe.squads),[x,v]=j.useState(!1),[S,A]=j.useState(null),[T,C]=j.useState(null),[N,R]=j.useState(null),[O,H]=j.useState(""),[D,F]=j.useState(""),[Z,V]=j.useState("daily"),[Y,P]=j.useState("0"),[q,ne]=j.useState("9"),[I,$]=j.useState("1"),[z,G]=j.useState("1"),[Q,W]=j.useState("30"),[B,K]=j.useState("2"),[J,X]=j.useState(""),[ce,ie]=j.useState(""),[de,ye]=j.useState("America/Sao_Paulo"),[me,le]=j.useState("30"),[Re,Le]=j.useState("0");j.useEffect(()=>{n()},[n]);const je=j.useCallback(()=>{F(""),V("daily"),P("0"),ne("9"),$("1"),G("1"),W("30"),K("2"),X(""),ie(""),ye("America/Sao_Paulo"),le("30"),Le("0"),A(null)},[]),He=()=>{v(!1),je()},Qe=()=>{je(),v(!0)},ot=oe=>{F(oe.squad_name),ie(oe.prompt||""),ye(oe.timezone||"America/Sao_Paulo"),le(String(oe.timeout_minutes||30)),Le(String(oe.retry_on_failure||0)),A(oe.squad_name);const Pe=oe.cron_expression.split(" ");if(Pe.length===5){const[ct,tn,ci,,Qt]=Pe;ct.startsWith("*/")?(V("every_n_minutes"),W(ct.replace("*/",""))):tn.startsWith("*/")?(V("every_n_hours"),K(tn.replace("*/","")),P(ct)):tn==="*"?(V("hourly"),P(ct)):ci==="*"&&Qt==="*"?(V("daily"),P(ct),ne(tn)):ci==="*"&&Qt!=="*"?(V("weekly"),P(ct),ne(tn),$(Qt)):Qt==="*"&&ci!=="*"?(V("monthly"),P(ct),ne(tn),G(ci)):(V("custom"),X(oe.cron_expression))}else V("custom"),X(oe.cron_expression);v(!0)},Ue=Z==="custom"?J:AG(Z,{minute:Y,hour:q,dayOfMonth:z,dayOfWeek:I,everyNMinutes:Q,everyNHours:B}),wt=async()=>{if(!D||!Ue||!ce.trim())return;const oe={squad_name:D,cron_expression:Ue,prompt:ce.trim(),timezone:de||void 0,timeout_minutes:parseInt(me)||30,retry_on_failure:parseInt(Re)||0};await i(oe)&&He()},_n=oe=>{C(oe),R(null),m(oe)},Sn=()=>{C(null),R(null)},hn=oe=>oe==="active"?"var(--status-active)":oe==="paused"?"var(--status-warning)":"var(--status-error)",oi=oe=>oe==="active"?"var(--status-active-glow)":oe==="paused"?"var(--status-warning-glow)":"var(--status-error-glow)",Ur=g.filter(oe=>!e.some(Pe=>Pe.squad_name===oe.code)),Ci=O.toLowerCase(),Wt=O?e.filter(oe=>{var Pe;return oe.squad_name.toLowerCase().includes(Ci)||((Pe=oe.prompt)==null?void 0:Pe.toLowerCase().includes(Ci))||oe.status.toLowerCase().includes(Ci)||_v(oe.cron_expression).toLowerCase().includes(Ci)}):e;return _.jsxs("div",{style:{padding:"var(--sp-6)",animation:"fadeIn 0.4s var(--ease-out) both",width:"100%",boxSizing:"border-box"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"var(--sp-4)"},children:[_.jsxs("div",{children:[_.jsx("h2",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1.1rem",color:"var(--text-primary)",marginBottom:"var(--sp-1)"},children:"Scheduler"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"Autonomous job execution and monitoring"})]}),_.jsx("button",{"data-testid":"btn-new-schedule",onClick:Qe,style:{...ts,background:"var(--accent)",color:"var(--text-inverse)"},children:"+ New Schedule"})]}),e.length>0&&_.jsx("div",{style:{marginBottom:"var(--sp-4)"},children:_.jsx("input",{"data-testid":"search-jobs",type:"text",placeholder:"Search by name, prompt, status...",value:O,onChange:oe=>H(oe.target.value),style:{...Kf,maxWidth:400,paddingLeft:32,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"10px center"}})}),t&&_.jsx("p",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading jobs..."}),!t&&e.length===0&&!x&&_.jsxs("div",{style:{padding:"var(--sp-8)",textAlign:"center",color:"var(--text-muted)"},children:[_.jsx("div",{style:{fontSize:"1.5rem",marginBottom:"var(--sp-3)"},children:"⏣"}),_.jsx("p",{style:{fontSize:"0.85rem",marginBottom:"var(--sp-2)"},children:"No scheduled jobs"}),_.jsxs("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:["Click ",_.jsx("strong",{children:"+ New Schedule"})," to create your first automated job."]})]}),_.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"var(--sp-3)",width:"100%"},children:Wt.map((oe,Pe)=>_.jsxs("div",{"data-testid":`job-${oe.squad_name}`,style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-3)",transition:"all var(--duration-fast) var(--ease-out)",animation:`fadeInUp 0.4s var(--ease-out) ${Pe*40}ms both`,display:"flex",flexDirection:"column",gap:"var(--sp-2)"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[_.jsx("span",{style:{fontWeight:600,fontSize:"0.82rem",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:oe.squad_name}),_.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:hn(oe.status),flexShrink:0,marginLeft:"var(--sp-2)"},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:hn(oe.status),boxShadow:`0 0 8px ${oi(oe.status)}`,display:"inline-block",animation:oe.status==="active"?"statusPulse 2s ease-in-out infinite":"none"}}),oe.status]})]}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-secondary)",display:"flex",alignItems:"center",gap:"var(--sp-2)"},children:[_.jsx("code",{style:{background:"var(--surface-3)",padding:"1px 5px",borderRadius:"var(--radius-xs)",fontSize:"0.6rem",flexShrink:0},children:oe.cron_expression}),_.jsx("span",{style:{color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_v(oe.cron_expression)})]}),oe.prompt&&_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.63rem",color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"4px 8px",background:"var(--surface-3)",borderRadius:"var(--radius-xs)"},children:oe.prompt}),oe.last_run_at&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)"},children:["Last: ",new Date(oe.last_run_at).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"}),oe.last_result&&_.jsxs("span",{children:[" — ",oe.last_result]})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-1)",flexWrap:"wrap",marginTop:"auto"},children:[_.jsx("button",{onClick:()=>ot(oe),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:"Edit"}),oe.status==="active"?_.jsx("button",{onClick:()=>s(oe.squad_name),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",color:"var(--status-warning)"},children:"Pause"}):_.jsx("button",{onClick:()=>l(oe.squad_name),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",color:"var(--status-active)"},children:"Resume"}),_.jsx("button",{onClick:()=>c(oe.squad_name),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"var(--accent)",color:"var(--text-inverse)"},children:"Trigger"}),_.jsx("button",{"data-testid":`btn-history-${oe.squad_name}`,onClick:()=>_n(oe.squad_name),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-muted)"},children:"Log"}),_.jsx("button",{onClick:()=>{confirm(`Delete schedule for ${oe.squad_name}?`)&&r(oe.squad_name)},style:{...ts,padding:"3px 6px",fontSize:"0.62rem",background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",marginLeft:"auto"},title:"Delete schedule",children:"✕"})]})]},oe.squad_name))}),!t&&O&&Wt.length===0&&e.length>0&&_.jsxs("div",{style:{padding:"var(--sp-6)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)"},children:['No jobs matching "',O,'"']}),x&&_.jsx(fT,{title:S?"Edit Schedule":"New Schedule",onClose:He,children:_.jsxs("div",{"data-testid":"schedule-form",style:{padding:"var(--sp-4)"},children:[_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("label",{style:oa,children:"Squad"}),S?_.jsx("div",{style:{...Kf,background:"var(--surface-3)",color:"var(--text-secondary)"},children:S}):_.jsxs("select",{"data-testid":"select-squad",value:D,onChange:oe=>F(oe.target.value),style:Ds,children:[_.jsx("option",{value:"",children:"Select a squad..."}),Ur.map(oe=>_.jsxs("option",{value:oe.code,children:[oe.name," (",oe.code,")"]},oe.code)),e.length===0&&g.length===0&&_.jsx("option",{disabled:!0,children:"No squads available"})]})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("label",{style:oa,children:"Frequency"}),_.jsxs("select",{"data-testid":"select-frequency",value:Z,onChange:oe=>V(oe.target.value),style:Ds,children:[_.jsx("option",{value:"every_n_minutes",children:"Every N minutes"}),_.jsx("option",{value:"every_n_hours",children:"Every N hours"}),_.jsx("option",{value:"hourly",children:"Hourly"}),_.jsx("option",{value:"daily",children:"Daily"}),_.jsx("option",{value:"weekly",children:"Weekly"}),_.jsx("option",{value:"monthly",children:"Monthly"}),_.jsx("option",{value:"custom",children:"Custom cron"})]})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-3)",marginBottom:"var(--sp-4)",flexWrap:"wrap"},children:[Z==="every_n_minutes"&&_.jsxs("div",{style:{flex:1,minWidth:120},children:[_.jsx("label",{style:oa,children:"Every (minutes)"}),_.jsx("select",{value:Q,onChange:oe=>W(oe.target.value),style:Ds,children:[1,2,5,10,15,20,30].map(oe=>_.jsx("option",{value:String(oe),children:oe},oe))})]}),Z==="every_n_hours"&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{flex:1,minWidth:120},children:[_.jsx("label",{style:oa,children:"Every (hours)"}),_.jsx("select",{value:B,onChange:oe=>K(oe.target.value),style:Ds,children:[2,3,4,6,8,12].map(oe=>_.jsx("option",{value:String(oe),children:oe},oe))})]}),_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"At minute"}),_.jsx("select",{value:Y,onChange:oe=>P(oe.target.value),style:Ds,children:Array.from({length:60},(oe,Pe)=>_.jsx("option",{value:String(Pe),children:String(Pe).padStart(2,"0")},Pe))})]})]}),Z==="hourly"&&_.jsxs("div",{style:{flex:1,minWidth:120},children:[_.jsx("label",{style:oa,children:"At minute"}),_.jsx("select",{value:Y,onChange:oe=>P(oe.target.value),style:Ds,children:Array.from({length:60},(oe,Pe)=>_.jsx("option",{value:String(Pe),children:String(Pe).padStart(2,"0")},Pe))})]}),(Z==="daily"||Z==="weekly"||Z==="monthly")&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"Hour"}),_.jsx("select",{value:q,onChange:oe=>ne(oe.target.value),style:Ds,children:Array.from({length:24},(oe,Pe)=>_.jsx("option",{value:String(Pe),children:String(Pe).padStart(2,"0")},Pe))})]}),_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"Minute"}),_.jsx("select",{value:Y,onChange:oe=>P(oe.target.value),style:Ds,children:Array.from({length:60},(oe,Pe)=>_.jsx("option",{value:String(Pe),children:String(Pe).padStart(2,"0")},Pe))})]})]}),Z==="weekly"&&_.jsxs("div",{style:{flex:1,minWidth:140},children:[_.jsx("label",{style:oa,children:"Day of week"}),_.jsx("select",{value:I,onChange:oe=>$(oe.target.value),style:Ds,children:uk.map(oe=>_.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),Z==="monthly"&&_.jsxs("div",{style:{flex:1,minWidth:120},children:[_.jsx("label",{style:oa,children:"Day of month"}),_.jsx("select",{value:z,onChange:oe=>G(oe.target.value),style:Ds,children:Array.from({length:31},(oe,Pe)=>_.jsx("option",{value:String(Pe+1),children:Pe+1},Pe+1))})]}),Z==="custom"&&_.jsxs("div",{style:{flex:1,minWidth:200},children:[_.jsx("label",{style:oa,children:"Cron expression"}),_.jsx("input",{type:"text",placeholder:"* * * * *",value:J,onChange:oe=>X(oe.target.value),style:Kf})]})]}),Ue&&_.jsxs("div",{style:{marginBottom:"var(--sp-4)",padding:"8px 12px",background:"var(--surface-3)",borderRadius:"var(--radius-xs)",border:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono)",fontSize:"0.72rem",display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[_.jsx("code",{style:{color:"var(--accent)",fontWeight:600},children:Ue}),_.jsx("span",{style:{color:"var(--text-muted)"},children:"—"}),_.jsx("span",{"data-testid":"cron-preview",style:{color:"var(--text-secondary)"},children:_v(Ue)})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("label",{style:oa,children:"Instruction for the agent"}),_.jsx("textarea",{"data-testid":"input-prompt",placeholder:"What should the squad do on each execution?",value:ce,onChange:oe=>ie(oe.target.value),rows:3,style:{...Kf,resize:"vertical",lineHeight:1.5}})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-3)",marginBottom:"var(--sp-4)",flexWrap:"wrap"},children:[_.jsxs("div",{style:{flex:2,minWidth:180},children:[_.jsx("label",{style:oa,children:"Timezone"}),_.jsxs("select",{value:de,onChange:oe=>ye(oe.target.value),style:Ds,children:[_.jsx("option",{value:"America/Sao_Paulo",children:"America/Sao_Paulo"}),_.jsx("option",{value:"America/New_York",children:"America/New_York"}),_.jsx("option",{value:"America/Chicago",children:"America/Chicago"}),_.jsx("option",{value:"America/Los_Angeles",children:"America/Los_Angeles"}),_.jsx("option",{value:"Europe/London",children:"Europe/London"}),_.jsx("option",{value:"Europe/Berlin",children:"Europe/Berlin"}),_.jsx("option",{value:"Asia/Tokyo",children:"Asia/Tokyo"}),_.jsx("option",{value:"UTC",children:"UTC"})]})]}),_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"Timeout (min)"}),_.jsx("input",{type:"number",min:1,max:480,value:me,onChange:oe=>le(oe.target.value),style:Kf})]}),_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"Retries"}),_.jsx("select",{value:Re,onChange:oe=>Le(oe.target.value),style:Ds,children:[0,1,2,3,4,5].map(oe=>_.jsx("option",{value:String(oe),children:oe},oe))})]})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)"},children:[_.jsx("button",{"data-testid":"btn-save-schedule",onClick:wt,disabled:!D||!Ue||!ce.trim(),style:{...ts,background:D&&Ue&&ce.trim()?"var(--accent)":"var(--surface-4)",color:D&&Ue&&ce.trim()?"var(--text-inverse)":"var(--text-muted)"},children:S?"Update":"Create"}),_.jsx("button",{onClick:He,style:{...ts,background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:"Cancel"})]})]})}),T&&_.jsx(fT,{title:`Execution Log — ${T}`,onClose:Sn,wide:!0,children:_.jsxs("div",{"data-testid":`history-${T}`,children:[_.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"6px 12px",borderBottom:"1px solid var(--border-subtle)"},children:_.jsxs("button",{"data-testid":`btn-refresh-${T}`,onClick:()=>m(T),disabled:p[T],style:{...ts,padding:"3px 10px",fontSize:"0.62rem",background:"none",border:"1px solid var(--border-subtle)",color:p[T]?"var(--text-muted)":"var(--text-secondary)",display:"inline-flex",alignItems:"center",gap:4},children:[_.jsx("span",{style:{display:"inline-block",animation:p[T]?"spin 1s linear infinite":"none"},children:"↻"}),"Refresh"]})}),p[T]&&_.jsx("div",{style:{padding:"var(--sp-3)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"Loading..."}),!p[T]&&(!f[T]||f[T].length===0)&&_.jsx("div",{style:{padding:"var(--sp-6)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"No executions recorded yet."}),!p[T]&&((sr=f[T])==null?void 0:sr.length)>0&&_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontFamily:"var(--font-mono)",fontSize:"0.68rem"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{background:"var(--surface-3)"},children:["Status","Started","Finished","Duration","Attempt","Output"].map(oe=>_.jsx("th",{style:{padding:"6px 8px",textAlign:"left",fontWeight:600,fontSize:"0.6rem",textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",borderBottom:"1px solid var(--border-subtle)"},children:oe},oe))})}),_.jsx("tbody",{children:f[T].map(oe=>{const Pe=RG(oe.status),ct=N===oe.id;return _.jsxs("tr",{"data-testid":`activity-${oe.id}`,style:{borderBottom:"1px solid var(--border-subtle)",transition:"background 0.1s"},onMouseEnter:tn=>{tn.currentTarget.style.background="var(--surface-3)"},onMouseLeave:tn=>{tn.currentTarget.style.background="transparent"},children:[_.jsx("td",{style:{padding:"6px 8px"},children:_.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:Pe.color,fontWeight:600},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:Pe.color,display:"inline-block",animation:oe.status==="running"?"statusPulse 2s ease-in-out infinite":"none"}}),Pe.label]})}),_.jsx("td",{style:{padding:"6px 8px",color:"var(--text-secondary)"},children:dT(oe.started_at)}),_.jsx("td",{style:{padding:"6px 8px",color:"var(--text-secondary)"},children:dT(oe.finished_at)}),_.jsx("td",{style:{padding:"6px 8px",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:MG(oe.duration_ms)}),_.jsx("td",{style:{padding:"6px 8px",color:"var(--text-muted)",textAlign:"center"},children:oe.attempt??1}),_.jsx("td",{style:{padding:"6px 8px"},children:oe.result_summary?_.jsx("button",{"data-testid":`btn-output-${oe.id}`,onClick:()=>R(ct?null:oe.id),style:{...ts,padding:"2px 8px",fontSize:"0.62rem",background:ct?"var(--accent)":"var(--surface-4)",color:ct?"var(--text-inverse)":"var(--text-secondary)",border:"none"},children:ct?"Hide":"View"}):_.jsx("span",{style:{color:"var(--text-muted)"},children:"—"})})]},oe.id)})})]}),N&&((Ee=f[T])==null?void 0:Ee.find(oe=>oe.id===N))&&_.jsxs("div",{"data-testid":`output-panel-${N}`,style:{padding:"var(--sp-3)",background:"var(--surface-0)",borderTop:"1px solid var(--border-subtle)"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--sp-2)"},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)"},children:"Output"}),_.jsx("button",{onClick:()=>R(null),style:{...ts,padding:"2px 6px",fontSize:"0.6rem",background:"none",border:"none",color:"var(--text-muted)"},children:"✕"})]}),_.jsx("pre",{style:{fontFamily:"var(--font-mono)",fontSize:"0.68rem",color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0,lineHeight:1.6,padding:"var(--sp-3)",background:"var(--surface-2)",borderRadius:"var(--radius-xs)",border:"1px solid var(--border-subtle)"},children:(ke=f[T].find(oe=>oe.id===N))==null?void 0:ke.result_summary})]})]})})]})}const hl=fu(e=>({leads:[],campaigns:[],lists:[],tags:[],total:0,loading:!1,fetchLeads:async(t={})=>{e({loading:!0});try{const n=new URLSearchParams(t),i=await fetch(`/api/email/leads?${n}`);if(i.ok){const r=await i.json();e({leads:r.data,total:r.total})}}finally{e({loading:!1})}},fetchCampaigns:async(t={})=>{e({loading:!0});try{const n=new URLSearchParams(t),i=await fetch(`/api/email/campaigns?${n}`);if(i.ok){const r=await i.json();e({campaigns:r.data})}}finally{e({loading:!1})}},fetchLists:async()=>{const t=await fetch("/api/email/leads/lists");if(t.ok){const n=await t.json();e({lists:n.lists})}},fetchTags:async()=>{const t=await fetch("/api/email/leads/tags");if(t.ok){const n=await t.json();e({tags:n.tags})}}}));function NG(){const e=hl(g=>g.leads),t=hl(g=>g.total),n=hl(g=>g.lists),i=hl(g=>g.tags),r=hl(g=>g.loading),s=hl(g=>g.fetchLeads),l=hl(g=>g.fetchLists),c=hl(g=>g.fetchTags),[f,p]=j.useState("");j.useEffect(()=>{s(),l(),c()},[s,l,c]);const m=()=>{s(f?{search:f}:{})};return _.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-4)"},children:[_.jsxs("div",{style:{display:"flex",gap:"var(--sp-3)"},children:[_.jsx(Sv,{label:"Total Leads",value:t}),_.jsx(Sv,{label:"Lists",value:n.length}),_.jsx(Sv,{label:"Tags",value:i.length})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)"},children:[_.jsx("input",{type:"text",placeholder:"Search leads...",value:f,onChange:g=>p(g.target.value),onKeyDown:g=>g.key==="Enter"&&m(),style:{flex:1,padding:"8px 12px",background:"var(--surface-2)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",color:"var(--text-primary)",fontFamily:"var(--font-body)",fontSize:"0.82rem"}}),_.jsx("button",{onClick:m,className:"btn-ghost",style:{padding:"8px 16px",background:"var(--accent-glow)",border:"1px solid rgba(0, 200, 255, 0.2)",borderRadius:"var(--radius-sm)",color:"var(--accent)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:"Search"})]}),r?_.jsx("div",{style:{textAlign:"center",padding:"var(--sp-6)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:"Loading..."}):_.jsx("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["Email","Name","Company","Status","Source","Created"].map(g=>_.jsx("th",{style:{textAlign:"left",padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",fontWeight:600},children:g},g))})}),_.jsxs("tbody",{children:[e.map(g=>_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("td",{style:fa,children:g.email}),_.jsx("td",{style:fa,children:g.name||"—"}),_.jsx("td",{style:fa,children:g.company||"—"}),_.jsx("td",{style:fa,children:_.jsx(dk,{status:g.status})}),_.jsx("td",{style:fa,children:g.source||"—"}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:new Date(g.created_at).toLocaleDateString()})]},g.id)),e.length===0&&_.jsx("tr",{children:_.jsx("td",{colSpan:6,style:{...fa,textAlign:"center",color:"var(--text-muted)"},children:"No leads found"})})]})]})})]})}function OG(){const e=hl(i=>i.campaigns),t=hl(i=>i.loading),n=hl(i=>i.fetchCampaigns);return j.useEffect(()=>{n()},[n]),_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-4)"},children:t?_.jsx("div",{style:{textAlign:"center",padding:"var(--sp-6)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:"Loading..."}):_.jsx("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["Name","Subject","Status","Recipients","Sent","Bounced","Created"].map(i=>_.jsx("th",{style:{textAlign:"left",padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",fontWeight:600},children:i},i))})}),_.jsxs("tbody",{children:[e.map(i=>_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("td",{style:fa,children:i.name}),_.jsx("td",{style:fa,children:i.subject}),_.jsx("td",{style:fa,children:_.jsx(dk,{status:i.status})}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)"},children:i.total_recipients}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)"},children:i.sent_count}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)"},children:i.bounce_count}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:new Date(i.created_at).toLocaleDateString()})]},i.id)),e.length===0&&_.jsx("tr",{children:_.jsx("td",{colSpan:7,style:{...fa,textAlign:"center",color:"var(--text-muted)"},children:"No campaigns yet"})})]})]})})})}function DG(){return _.jsxs("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-4)"},children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontSize:"0.9rem",color:"var(--text-primary)",marginBottom:"var(--sp-3)"},children:"Amazon SES Configuration"}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)",lineHeight:1.8},children:[_.jsx("p",{children:"Configure these environment variables on the server:"}),_.jsxs("div",{style:{background:"var(--surface-2)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",padding:"var(--sp-3)",marginTop:"var(--sp-2)"},children:[_.jsx("code",{children:"AWS_ACCESS_KEY_ID=..."}),_.jsx("br",{}),_.jsx("code",{children:"AWS_SECRET_ACCESS_KEY=..."}),_.jsx("br",{}),_.jsx("code",{children:"AWS_REGION=us-east-1"}),_.jsx("br",{}),_.jsx("code",{children:"SES_FROM_EMAIL=noreply@yourdomain.com"}),_.jsx("br",{}),_.jsx("code",{children:"SES_RATE_LIMIT=14"}),_.jsx("br",{}),_.jsx("code",{children:"SERVER_URL=https://yourdomain.com"})]})]})]})}function Sv({label:e,value:t}){return _.jsxs("div",{style:{flex:1,background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-3)"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:"var(--sp-1)"},children:e}),_.jsx("div",{style:{fontFamily:"var(--font-display)",fontSize:"1.4rem",fontWeight:700,color:"var(--accent)"},children:t})]})}function dk({status:e}){const n={active:{bg:"rgba(0, 230, 138, 0.1)",text:"var(--status-active)"},unsubscribed:{bg:"rgba(255, 100, 100, 0.1)",text:"var(--status-error)"},draft:{bg:"rgba(150, 150, 150, 0.1)",text:"var(--text-muted)"},queued:{bg:"rgba(0, 200, 255, 0.1)",text:"var(--accent)"},sending:{bg:"rgba(255, 180, 0, 0.1)",text:"var(--status-warning)"},sent:{bg:"rgba(0, 230, 138, 0.1)",text:"var(--status-active)"},paused:{bg:"rgba(255, 180, 0, 0.1)",text:"var(--status-warning)"},cancelled:{bg:"rgba(255, 100, 100, 0.1)",text:"var(--status-error)"}}[e]||{bg:"rgba(150, 150, 150, 0.1)",text:"var(--text-muted)"};return _.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:"var(--radius-xs)",background:n.bg,color:n.text,fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:e})}const fa={padding:"10px 14px",fontSize:"0.82rem",color:"var(--text-secondary)"};function zG(){const[e,t]=j.useState("leads"),n=[{key:"leads",label:"Leads"},{key:"campaigns",label:"Campaigns"},{key:"settings",label:"Settings"}];return _.jsxs("div",{style:{padding:"var(--sp-4)",maxWidth:1100,margin:"0 auto"},children:[_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:"1.1rem",fontWeight:700,color:"var(--text-primary)",marginBottom:"var(--sp-1)"},children:"Email Engine"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"Lead management, campaigns, and Amazon SES integration"})]}),_.jsx("div",{style:{display:"flex",gap:"var(--sp-1)",marginBottom:"var(--sp-4)",borderBottom:"1px solid var(--border-subtle)",paddingBottom:"var(--sp-1)"},children:n.map(i=>_.jsx("button",{onClick:()=>t(i.key),style:{padding:"8px 16px",background:e===i.key?"var(--accent-glow)":"transparent",border:e===i.key?"1px solid rgba(0, 200, 255, 0.15)":"1px solid transparent",borderRadius:"var(--radius-sm)",color:e===i.key?"var(--accent)":"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-display)",fontSize:"0.82rem",fontWeight:e===i.key?600:400,transition:"all var(--duration-fast) var(--ease-out)"},children:i.label},i.key))}),e==="leads"&&_.jsx(NG,{}),e==="campaigns"&&_.jsx(OG,{}),e==="settings"&&_.jsx(DG,{})]})}function zi(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n<e.length;n++)(i=zi(e[n]))!==""&&(t+=(t&&" ")+i);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var BG={value:()=>{}};function fx(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new b0(n)}function b0(e){this._=e}function LG(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}b0.prototype=fx.prototype={constructor:b0,on:function(e,t){var n=this._,i=LG(e+"",n),r,s=-1,l=i.length;if(arguments.length<2){for(;++s<l;)if((r=(e=i[s]).type)&&(r=jG(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<l;)if(r=(e=i[s]).type)n[r]=hT(n[r],e.name,t);else if(t==null)for(r in n)n[r]=hT(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new b0(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,s;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],i=0,r=s.length;i<r;++i)s[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)}};function jG(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function hT(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=BG,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var k1="http://www.w3.org/1999/xhtml";const pT={svg:"http://www.w3.org/2000/svg",xhtml:k1,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function hx(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),pT.hasOwnProperty(t)?{space:pT[t],local:e}:e}function IG(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===k1&&t.documentElement.namespaceURI===k1?t.createElement(e):t.createElementNS(n,e)}}function UG(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function fk(e){var t=hx(e);return(t.local?UG:IG)(t)}function HG(){}function I_(e){return e==null?HG:function(){return this.querySelector(e)}}function PG(e){typeof e!="function"&&(e=I_(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],l=s.length,c=i[r]=new Array(l),f,p,m=0;m<l;++m)(f=s[m])&&(p=e.call(f,f.__data__,m,s))&&("__data__"in f&&(p.__data__=f.__data__),c[m]=p);return new as(i,this._parents)}function FG(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function GG(){return[]}function hk(e){return e==null?GG:function(){return this.querySelectorAll(e)}}function qG(e){return function(){return FG(e.apply(this,arguments))}}function YG(e){typeof e=="function"?e=qG(e):e=hk(e);for(var t=this._groups,n=t.length,i=[],r=[],s=0;s<n;++s)for(var l=t[s],c=l.length,f,p=0;p<c;++p)(f=l[p])&&(i.push(e.call(f,f.__data__,p,l)),r.push(f));return new as(i,r)}function pk(e){return function(){return this.matches(e)}}function mk(e){return function(t){return t.matches(e)}}var VG=Array.prototype.find;function XG(e){return function(){return VG.call(this.children,e)}}function KG(){return this.firstElementChild}function $G(e){return this.select(e==null?KG:XG(typeof e=="function"?e:mk(e)))}var WG=Array.prototype.filter;function QG(){return Array.from(this.children)}function ZG(e){return function(){return WG.call(this.children,e)}}function JG(e){return this.selectAll(e==null?QG:ZG(typeof e=="function"?e:mk(e)))}function eq(e){typeof e!="function"&&(e=pk(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],l=s.length,c=i[r]=[],f,p=0;p<l;++p)(f=s[p])&&e.call(f,f.__data__,p,s)&&c.push(f);return new as(i,this._parents)}function gk(e){return new Array(e.length)}function tq(){return new as(this._enter||this._groups.map(gk),this._parents)}function H0(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}H0.prototype={constructor:H0,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function nq(e){return function(){return e}}function iq(e,t,n,i,r,s){for(var l=0,c,f=t.length,p=s.length;l<p;++l)(c=t[l])?(c.__data__=s[l],i[l]=c):n[l]=new H0(e,s[l]);for(;l<f;++l)(c=t[l])&&(r[l]=c)}function rq(e,t,n,i,r,s,l){var c,f,p=new Map,m=t.length,g=s.length,x=new Array(m),v;for(c=0;c<m;++c)(f=t[c])&&(x[c]=v=l.call(f,f.__data__,c,t)+"",p.has(v)?r[c]=f:p.set(v,f));for(c=0;c<g;++c)v=l.call(e,s[c],c,s)+"",(f=p.get(v))?(i[c]=f,f.__data__=s[c],p.delete(v)):n[c]=new H0(e,s[c]);for(c=0;c<m;++c)(f=t[c])&&p.get(x[c])===f&&(r[c]=f)}function aq(e){return e.__data__}function sq(e,t){if(!arguments.length)return Array.from(this,aq);var n=t?rq:iq,i=this._parents,r=this._groups;typeof e!="function"&&(e=nq(e));for(var s=r.length,l=new Array(s),c=new Array(s),f=new Array(s),p=0;p<s;++p){var m=i[p],g=r[p],x=g.length,v=lq(e.call(m,m&&m.__data__,p,i)),S=v.length,A=c[p]=new Array(S),T=l[p]=new Array(S),C=f[p]=new Array(x);n(m,g,A,T,C,v,t);for(var N=0,R=0,O,H;N<S;++N)if(O=A[N]){for(N>=R&&(R=N+1);!(H=T[R])&&++R<S;);O._next=H||null}}return l=new as(l,i),l._enter=c,l._exit=f,l}function lq(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function oq(){return new as(this._exit||this._groups.map(gk),this._parents)}function cq(e,t,n){var i=this.enter(),r=this,s=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),i&&r?i.merge(r).order():r}function uq(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,s=i.length,l=Math.min(r,s),c=new Array(r),f=0;f<l;++f)for(var p=n[f],m=i[f],g=p.length,x=c[f]=new Array(g),v,S=0;S<g;++S)(v=p[S]||m[S])&&(x[S]=v);for(;f<r;++f)c[f]=n[f];return new as(c,this._parents)}function dq(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,s=i[r],l;--r>=0;)(l=i[r])&&(s&&l.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(l,s),s=l);return this}function fq(e){e||(e=hq);function t(g,x){return g&&x?e(g.__data__,x.__data__):!g-!x}for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var l=n[s],c=l.length,f=r[s]=new Array(c),p,m=0;m<c;++m)(p=l[m])&&(f[m]=p);f.sort(t)}return new as(r,this._parents).order()}function hq(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function pq(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function mq(){return Array.from(this)}function gq(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length;r<s;++r){var l=i[r];if(l)return l}return null}function yq(){let e=0;for(const t of this)++e;return e}function xq(){return!this.node()}function bq(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],s=0,l=r.length,c;s<l;++s)(c=r[s])&&e.call(c,c.__data__,s,r);return this}function vq(e){return function(){this.removeAttribute(e)}}function _q(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Sq(e,t){return function(){this.setAttribute(e,t)}}function Eq(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function wq(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Tq(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Cq(e,t){var n=hx(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?_q:vq:typeof t=="function"?n.local?Tq:wq:n.local?Eq:Sq)(n,t))}function yk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Aq(e){return function(){this.style.removeProperty(e)}}function Mq(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Rq(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function kq(e,t,n){return arguments.length>1?this.each((t==null?Aq:typeof t=="function"?Rq:Mq)(e,t,n??"")):hh(this.node(),e)}function hh(e,t){return e.style.getPropertyValue(t)||yk(e).getComputedStyle(e,null).getPropertyValue(t)}function Nq(e){return function(){delete this[e]}}function Oq(e,t){return function(){this[e]=t}}function Dq(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function zq(e,t){return arguments.length>1?this.each((t==null?Nq:typeof t=="function"?Dq:Oq)(e,t)):this.node()[e]}function xk(e){return e.trim().split(/^|\s+/)}function U_(e){return e.classList||new bk(e)}function bk(e){this._node=e,this._names=xk(e.getAttribute("class")||"")}bk.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function vk(e,t){for(var n=U_(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function _k(e,t){for(var n=U_(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function Bq(e){return function(){vk(this,e)}}function Lq(e){return function(){_k(this,e)}}function jq(e,t){return function(){(t.apply(this,arguments)?vk:_k)(this,e)}}function Iq(e,t){var n=xk(e+"");if(arguments.length<2){for(var i=U_(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?jq:t?Bq:Lq)(n,t))}function Uq(){this.textContent=""}function Hq(e){return function(){this.textContent=e}}function Pq(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Fq(e){return arguments.length?this.each(e==null?Uq:(typeof e=="function"?Pq:Hq)(e)):this.node().textContent}function Gq(){this.innerHTML=""}function qq(e){return function(){this.innerHTML=e}}function Yq(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Vq(e){return arguments.length?this.each(e==null?Gq:(typeof e=="function"?Yq:qq)(e)):this.node().innerHTML}function Xq(){this.nextSibling&&this.parentNode.appendChild(this)}function Kq(){return this.each(Xq)}function $q(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Wq(){return this.each($q)}function Qq(e){var t=typeof e=="function"?e:fk(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Zq(){return null}function Jq(e,t){var n=typeof e=="function"?e:fk(e),i=t==null?Zq:typeof t=="function"?t:I_(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function eY(){var e=this.parentNode;e&&e.removeChild(this)}function tY(){return this.each(eY)}function nY(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function iY(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function rY(e){return this.select(e?iY:nY)}function aY(e){return arguments.length?this.property("__data__",e):this.node().__data__}function sY(e){return function(t){e.call(this,t,this.__data__)}}function lY(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function oY(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++i]=s;++i?t.length=i:delete this.__on}}}function cY(e,t,n){return function(){var i=this.__on,r,s=sY(t);if(i){for(var l=0,c=i.length;l<c;++l)if((r=i[l]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},i?i.push(r):this.__on=[r]}}function uY(e,t,n){var i=lY(e+""),r,s=i.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var f=0,p=c.length,m;f<p;++f)for(r=0,m=c[f];r<s;++r)if((l=i[r]).type===m.type&&l.name===m.name)return m.value}return}for(c=t?cY:oY,r=0;r<s;++r)this.each(c(i[r],t,n));return this}function Sk(e,t,n){var i=yk(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function dY(e,t){return function(){return Sk(this,e,t)}}function fY(e,t){return function(){return Sk(this,e,t.apply(this,arguments))}}function hY(e,t){return this.each((typeof t=="function"?fY:dY)(e,t))}function*pY(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length,l;r<s;++r)(l=i[r])&&(yield l)}var Ek=[null];function as(e,t){this._groups=e,this._parents=t}function rg(){return new as([[document.documentElement]],Ek)}function mY(){return this}as.prototype=rg.prototype={constructor:as,select:PG,selectAll:YG,selectChild:$G,selectChildren:JG,filter:eq,data:sq,enter:tq,exit:oq,join:cq,merge:uq,selection:mY,order:dq,sort:fq,call:pq,nodes:mq,node:gq,size:yq,empty:xq,each:bq,attr:Cq,style:kq,property:zq,classed:Iq,text:Fq,html:Vq,raise:Kq,lower:Wq,append:Qq,insert:Jq,remove:tY,clone:rY,datum:aY,on:uY,dispatch:hY,[Symbol.iterator]:pY};function ns(e){return typeof e=="string"?new as([[document.querySelector(e)]],[document.documentElement]):new as([[e]],Ek)}function gY(e){let t;for(;t=e.sourceEvent;)e=t;return e}function pl(e,t){if(e=gY(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const yY={passive:!1},Um={capture:!0,passive:!1};function Ev(e){e.stopImmediatePropagation()}function ih(e){e.preventDefault(),e.stopImmediatePropagation()}function wk(e){var t=e.document.documentElement,n=ns(e).on("dragstart.drag",ih,Um);"onselectstart"in t?n.on("selectstart.drag",ih,Um):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Tk(e,t){var n=e.document.documentElement,i=ns(e).on("dragstart.drag",null);t&&(i.on("click.drag",ih,Um),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const r0=e=>()=>e;function N1(e,{sourceEvent:t,subject:n,target:i,identifier:r,active:s,x:l,y:c,dx:f,dy:p,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:m}})}N1.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function xY(e){return!e.ctrlKey&&!e.button}function bY(){return this.parentNode}function vY(e,t){return t??{x:e.x,y:e.y}}function _Y(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ck(){var e=xY,t=bY,n=vY,i=_Y,r={},s=fx("start","drag","end"),l=0,c,f,p,m,g=0;function x(O){O.on("mousedown.drag",v).filter(i).on("touchstart.drag",T).on("touchmove.drag",C,yY).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(O,H){if(!(m||!e.call(this,O,H))){var D=R(this,t.call(this,O,H),O,H,"mouse");D&&(ns(O.view).on("mousemove.drag",S,Um).on("mouseup.drag",A,Um),wk(O.view),Ev(O),p=!1,c=O.clientX,f=O.clientY,D("start",O))}}function S(O){if(ih(O),!p){var H=O.clientX-c,D=O.clientY-f;p=H*H+D*D>g}r.mouse("drag",O)}function A(O){ns(O.view).on("mousemove.drag mouseup.drag",null),Tk(O.view,p),ih(O),r.mouse("end",O)}function T(O,H){if(e.call(this,O,H)){var D=O.changedTouches,F=t.call(this,O,H),Z=D.length,V,Y;for(V=0;V<Z;++V)(Y=R(this,F,O,H,D[V].identifier,D[V]))&&(Ev(O),Y("start",O,D[V]))}}function C(O){var H=O.changedTouches,D=H.length,F,Z;for(F=0;F<D;++F)(Z=r[H[F].identifier])&&(ih(O),Z("drag",O,H[F]))}function N(O){var H=O.changedTouches,D=H.length,F,Z;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),F=0;F<D;++F)(Z=r[H[F].identifier])&&(Ev(O),Z("end",O,H[F]))}function R(O,H,D,F,Z,V){var Y=s.copy(),P=pl(V||D,H),q,ne,I;if((I=n.call(O,new N1("beforestart",{sourceEvent:D,target:x,identifier:Z,active:l,x:P[0],y:P[1],dx:0,dy:0,dispatch:Y}),F))!=null)return q=I.x-P[0]||0,ne=I.y-P[1]||0,function $(z,G,Q){var W=P,B;switch(z){case"start":r[Z]=$,B=l++;break;case"end":delete r[Z],--l;case"drag":P=pl(Q||G,H),B=l;break}Y.call(z,O,new N1(z,{sourceEvent:G,subject:I,target:x,identifier:Z,active:B,x:P[0]+q,y:P[1]+ne,dx:P[0]-W[0],dy:P[1]-W[1],dispatch:Y}),F)}}return x.filter=function(O){return arguments.length?(e=typeof O=="function"?O:r0(!!O),x):e},x.container=function(O){return arguments.length?(t=typeof O=="function"?O:r0(O),x):t},x.subject=function(O){return arguments.length?(n=typeof O=="function"?O:r0(O),x):n},x.touchable=function(O){return arguments.length?(i=typeof O=="function"?O:r0(!!O),x):i},x.on=function(){var O=s.on.apply(s,arguments);return O===s?x:O},x.clickDistance=function(O){return arguments.length?(g=(O=+O)*O,x):Math.sqrt(g)},x}function H_(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ak(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function ag(){}var Hm=.7,P0=1/Hm,rh="\\s*([+-]?\\d+)\\s*",Pm="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",mo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",SY=/^#([0-9a-f]{3,8})$/,EY=new RegExp(`^rgb\\(${rh},${rh},${rh}\\)$`),wY=new RegExp(`^rgb\\(${mo},${mo},${mo}\\)$`),TY=new RegExp(`^rgba\\(${rh},${rh},${rh},${Pm}\\)$`),CY=new RegExp(`^rgba\\(${mo},${mo},${mo},${Pm}\\)$`),AY=new RegExp(`^hsl\\(${Pm},${mo},${mo}\\)$`),MY=new RegExp(`^hsla\\(${Pm},${mo},${mo},${Pm}\\)$`),mT={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};H_(ag,Ed,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:gT,formatHex:gT,formatHex8:RY,formatHsl:kY,formatRgb:yT,toString:yT});function gT(){return this.rgb().formatHex()}function RY(){return this.rgb().formatHex8()}function kY(){return Mk(this).formatHsl()}function yT(){return this.rgb().formatRgb()}function Ed(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=SY.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?xT(t):n===3?new Oa(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?a0(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?a0(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=EY.exec(e))?new Oa(t[1],t[2],t[3],1):(t=wY.exec(e))?new Oa(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=TY.exec(e))?a0(t[1],t[2],t[3],t[4]):(t=CY.exec(e))?a0(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=AY.exec(e))?_T(t[1],t[2]/100,t[3]/100,1):(t=MY.exec(e))?_T(t[1],t[2]/100,t[3]/100,t[4]):mT.hasOwnProperty(e)?xT(mT[e]):e==="transparent"?new Oa(NaN,NaN,NaN,0):null}function xT(e){return new Oa(e>>16&255,e>>8&255,e&255,1)}function a0(e,t,n,i){return i<=0&&(e=t=n=NaN),new Oa(e,t,n,i)}function NY(e){return e instanceof ag||(e=Ed(e)),e?(e=e.rgb(),new Oa(e.r,e.g,e.b,e.opacity)):new Oa}function O1(e,t,n,i){return arguments.length===1?NY(e):new Oa(e,t,n,i??1)}function Oa(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}H_(Oa,O1,Ak(ag,{brighter(e){return e=e==null?P0:Math.pow(P0,e),new Oa(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Hm:Math.pow(Hm,e),new Oa(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Oa(xd(this.r),xd(this.g),xd(this.b),F0(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:bT,formatHex:bT,formatHex8:OY,formatRgb:vT,toString:vT}));function bT(){return`#${yd(this.r)}${yd(this.g)}${yd(this.b)}`}function OY(){return`#${yd(this.r)}${yd(this.g)}${yd(this.b)}${yd((isNaN(this.opacity)?1:this.opacity)*255)}`}function vT(){const e=F0(this.opacity);return`${e===1?"rgb(":"rgba("}${xd(this.r)}, ${xd(this.g)}, ${xd(this.b)}${e===1?")":`, ${e})`}`}function F0(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function xd(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function yd(e){return e=xd(e),(e<16?"0":"")+e.toString(16)}function _T(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new yl(e,t,n,i)}function Mk(e){if(e instanceof yl)return new yl(e.h,e.s,e.l,e.opacity);if(e instanceof ag||(e=Ed(e)),!e)return new yl;if(e instanceof yl)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),s=Math.max(t,n,i),l=NaN,c=s-r,f=(s+r)/2;return c?(t===s?l=(n-i)/c+(n<i)*6:n===s?l=(i-t)/c+2:l=(t-n)/c+4,c/=f<.5?s+r:2-s-r,l*=60):c=f>0&&f<1?0:l,new yl(l,c,f,e.opacity)}function DY(e,t,n,i){return arguments.length===1?Mk(e):new yl(e,t,n,i??1)}function yl(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}H_(yl,DY,Ak(ag,{brighter(e){return e=e==null?P0:Math.pow(P0,e),new yl(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Hm:Math.pow(Hm,e),new yl(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new Oa(wv(e>=240?e-240:e+120,r,i),wv(e,r,i),wv(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new yl(ST(this.h),s0(this.s),s0(this.l),F0(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=F0(this.opacity);return`${e===1?"hsl(":"hsla("}${ST(this.h)}, ${s0(this.s)*100}%, ${s0(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ST(e){return e=(e||0)%360,e<0?e+360:e}function s0(e){return Math.max(0,Math.min(1,e||0))}function wv(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const P_=e=>()=>e;function zY(e,t){return function(n){return e+n*t}}function BY(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function LY(e){return(e=+e)==1?Rk:function(t,n){return n-t?BY(t,n,e):P_(isNaN(t)?n:t)}}function Rk(e,t){var n=t-e;return n?zY(e,n):P_(isNaN(e)?t:e)}const G0=(function e(t){var n=LY(t);function i(r,s){var l=n((r=O1(r)).r,(s=O1(s)).r),c=n(r.g,s.g),f=n(r.b,s.b),p=Rk(r.opacity,s.opacity);return function(m){return r.r=l(m),r.g=c(m),r.b=f(m),r.opacity=p(m),r+""}}return i.gamma=e,i})(1);function jY(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(s){for(r=0;r<n;++r)i[r]=e[r]*(1-s)+t[r]*s;return i}}function IY(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function UY(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,r=new Array(i),s=new Array(n),l;for(l=0;l<i;++l)r[l]=Mm(e[l],t[l]);for(;l<n;++l)s[l]=t[l];return function(c){for(l=0;l<i;++l)s[l]=r[l](c);return s}}function HY(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function ho(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function PY(e,t){var n={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=Mm(e[r],t[r]):i[r]=t[r];return function(s){for(r in n)i[r]=n[r](s);return i}}var D1=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Tv=new RegExp(D1.source,"g");function FY(e){return function(){return e}}function GY(e){return function(t){return e(t)+""}}function kk(e,t){var n=D1.lastIndex=Tv.lastIndex=0,i,r,s,l=-1,c=[],f=[];for(e=e+"",t=t+"";(i=D1.exec(e))&&(r=Tv.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),c[l]?c[l]+=s:c[++l]=s),(i=i[0])===(r=r[0])?c[l]?c[l]+=r:c[++l]=r:(c[++l]=null,f.push({i:l,x:ho(i,r)})),n=Tv.lastIndex;return n<t.length&&(s=t.slice(n),c[l]?c[l]+=s:c[++l]=s),c.length<2?f[0]?GY(f[0].x):FY(t):(t=f.length,function(p){for(var m=0,g;m<t;++m)c[(g=f[m]).i]=g.x(p);return c.join("")})}function Mm(e,t){var n=typeof t,i;return t==null||n==="boolean"?P_(t):(n==="number"?ho:n==="string"?(i=Ed(t))?(t=i,G0):kk:t instanceof Ed?G0:t instanceof Date?HY:IY(t)?jY:Array.isArray(t)?UY:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?PY:ho)(e,t)}var ET=180/Math.PI,z1={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Nk(e,t,n,i,r,s){var l,c,f;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(f=e*n+t*i)&&(n-=e*f,i-=t*f),(c=Math.sqrt(n*n+i*i))&&(n/=c,i/=c,f/=c),e*i<t*n&&(e=-e,t=-t,f=-f,l=-l),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*ET,skewX:Math.atan(f)*ET,scaleX:l,scaleY:c}}var l0;function qY(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?z1:Nk(t.a,t.b,t.c,t.d,t.e,t.f)}function YY(e){return e==null||(l0||(l0=document.createElementNS("http://www.w3.org/2000/svg","g")),l0.setAttribute("transform",e),!(e=l0.transform.baseVal.consolidate()))?z1:(e=e.matrix,Nk(e.a,e.b,e.c,e.d,e.e,e.f))}function Ok(e,t,n,i){function r(p){return p.length?p.pop()+" ":""}function s(p,m,g,x,v,S){if(p!==g||m!==x){var A=v.push("translate(",null,t,null,n);S.push({i:A-4,x:ho(p,g)},{i:A-2,x:ho(m,x)})}else(g||x)&&v.push("translate("+g+t+x+n)}function l(p,m,g,x){p!==m?(p-m>180?m+=360:m-p>180&&(p+=360),x.push({i:g.push(r(g)+"rotate(",null,i)-2,x:ho(p,m)})):m&&g.push(r(g)+"rotate("+m+i)}function c(p,m,g,x){p!==m?x.push({i:g.push(r(g)+"skewX(",null,i)-2,x:ho(p,m)}):m&&g.push(r(g)+"skewX("+m+i)}function f(p,m,g,x,v,S){if(p!==g||m!==x){var A=v.push(r(v)+"scale(",null,",",null,")");S.push({i:A-4,x:ho(p,g)},{i:A-2,x:ho(m,x)})}else(g!==1||x!==1)&&v.push(r(v)+"scale("+g+","+x+")")}return function(p,m){var g=[],x=[];return p=e(p),m=e(m),s(p.translateX,p.translateY,m.translateX,m.translateY,g,x),l(p.rotate,m.rotate,g,x),c(p.skewX,m.skewX,g,x),f(p.scaleX,p.scaleY,m.scaleX,m.scaleY,g,x),p=m=null,function(v){for(var S=-1,A=x.length,T;++S<A;)g[(T=x[S]).i]=T.x(v);return g.join("")}}}var VY=Ok(qY,"px, ","px)","deg)"),XY=Ok(YY,", ",")",")"),KY=1e-12;function wT(e){return((e=Math.exp(e))+1/e)/2}function $Y(e){return((e=Math.exp(e))-1/e)/2}function WY(e){return((e=Math.exp(2*e))-1)/(e+1)}const v0=(function e(t,n,i){function r(s,l){var c=s[0],f=s[1],p=s[2],m=l[0],g=l[1],x=l[2],v=m-c,S=g-f,A=v*v+S*S,T,C;if(A<KY)C=Math.log(x/p)/t,T=function(F){return[c+F*v,f+F*S,p*Math.exp(t*F*C)]};else{var N=Math.sqrt(A),R=(x*x-p*p+i*A)/(2*p*n*N),O=(x*x-p*p-i*A)/(2*x*n*N),H=Math.log(Math.sqrt(R*R+1)-R),D=Math.log(Math.sqrt(O*O+1)-O);C=(D-H)/t,T=function(F){var Z=F*C,V=wT(H),Y=p/(n*N)*(V*WY(t*Z+H)-$Y(H));return[c+Y*v,f+Y*S,p*V/wT(t*Z+H)]}}return T.duration=C*1e3*t/Math.SQRT2,T}return r.rho=function(s){var l=Math.max(.001,+s),c=l*l,f=c*c;return e(l,c,f)},r})(Math.SQRT2,2,4);var ph=0,gm=0,um=0,Dk=1e3,q0,ym,Y0=0,wd=0,px=0,Fm=typeof performance=="object"&&performance.now?performance:Date,zk=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function F_(){return wd||(zk(QY),wd=Fm.now()+px)}function QY(){wd=0}function V0(){this._call=this._time=this._next=null}V0.prototype=Bk.prototype={constructor:V0,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?F_():+n)+(t==null?0:+t),!this._next&&ym!==this&&(ym?ym._next=this:q0=this,ym=this),this._call=e,this._time=n,B1()},stop:function(){this._call&&(this._call=null,this._time=1/0,B1())}};function Bk(e,t,n){var i=new V0;return i.restart(e,t,n),i}function ZY(){F_(),++ph;for(var e=q0,t;e;)(t=wd-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ph}function TT(){wd=(Y0=Fm.now())+px,ph=gm=0;try{ZY()}finally{ph=0,eV(),wd=0}}function JY(){var e=Fm.now(),t=e-Y0;t>Dk&&(px-=t,Y0=e)}function eV(){for(var e,t=q0,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:q0=n);ym=e,B1(i)}function B1(e){if(!ph){gm&&(gm=clearTimeout(gm));var t=e-wd;t>24?(e<1/0&&(gm=setTimeout(TT,e-Fm.now()-px)),um&&(um=clearInterval(um))):(um||(Y0=Fm.now(),um=setInterval(JY,Dk)),ph=1,zk(TT))}}function CT(e,t,n){var i=new V0;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var tV=fx("start","end","cancel","interrupt"),nV=[],Lk=0,AT=1,L1=2,_0=3,MT=4,j1=5,S0=6;function mx(e,t,n,i,r,s){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;iV(e,n,{name:t,index:i,group:r,on:tV,tween:nV,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Lk})}function G_(e,t){var n=Tl(e,t);if(n.state>Lk)throw new Error("too late; already scheduled");return n}function bo(e,t){var n=Tl(e,t);if(n.state>_0)throw new Error("too late; already running");return n}function Tl(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function iV(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=Bk(s,0,n.time);function s(p){n.state=AT,n.timer.restart(l,n.delay,n.time),n.delay<=p&&l(p-n.delay)}function l(p){var m,g,x,v;if(n.state!==AT)return f();for(m in i)if(v=i[m],v.name===n.name){if(v.state===_0)return CT(l);v.state===MT?(v.state=S0,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete i[m]):+m<t&&(v.state=S0,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete i[m])}if(CT(function(){n.state===_0&&(n.state=MT,n.timer.restart(c,n.delay,n.time),c(p))}),n.state=L1,n.on.call("start",e,e.__data__,n.index,n.group),n.state===L1){for(n.state=_0,r=new Array(x=n.tween.length),m=0,g=-1;m<x;++m)(v=n.tween[m].value.call(e,e.__data__,n.index,n.group))&&(r[++g]=v);r.length=g+1}}function c(p){for(var m=p<n.duration?n.ease.call(null,p/n.duration):(n.timer.restart(f),n.state=j1,1),g=-1,x=r.length;++g<x;)r[g].call(e,m);n.state===j1&&(n.on.call("end",e,e.__data__,n.index,n.group),f())}function f(){n.state=S0,n.timer.stop(),delete i[t];for(var p in i)return;delete e.__transition}}function E0(e,t){var n=e.__transition,i,r,s=!0,l;if(n){t=t==null?null:t+"";for(l in n){if((i=n[l]).name!==t){s=!1;continue}r=i.state>L1&&i.state<j1,i.state=S0,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[l]}s&&delete e.__transition}}function rV(e){return this.each(function(){E0(this,e)})}function aV(e,t){var n,i;return function(){var r=bo(this,e),s=r.tween;if(s!==n){i=n=s;for(var l=0,c=i.length;l<c;++l)if(i[l].name===t){i=i.slice(),i.splice(l,1);break}}r.tween=i}}function sV(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=bo(this,e),l=s.tween;if(l!==i){r=(i=l).slice();for(var c={name:t,value:n},f=0,p=r.length;f<p;++f)if(r[f].name===t){r[f]=c;break}f===p&&r.push(c)}s.tween=r}}function lV(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=Tl(this.node(),n).tween,r=0,s=i.length,l;r<s;++r)if((l=i[r]).name===e)return l.value;return null}return this.each((t==null?aV:sV)(n,e,t))}function q_(e,t,n){var i=e._id;return e.each(function(){var r=bo(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Tl(r,i).value[t]}}function jk(e,t){var n;return(typeof t=="number"?ho:t instanceof Ed?G0:(n=Ed(t))?(t=n,G0):kk)(e,t)}function oV(e){return function(){this.removeAttribute(e)}}function cV(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uV(e,t,n){var i,r=n+"",s;return function(){var l=this.getAttribute(e);return l===r?null:l===i?s:s=t(i=l,n)}}function dV(e,t,n){var i,r=n+"",s;return function(){var l=this.getAttributeNS(e.space,e.local);return l===r?null:l===i?s:s=t(i=l,n)}}function fV(e,t,n){var i,r,s;return function(){var l,c=n(this),f;return c==null?void this.removeAttribute(e):(l=this.getAttribute(e),f=c+"",l===f?null:l===i&&f===r?s:(r=f,s=t(i=l,c)))}}function hV(e,t,n){var i,r,s;return function(){var l,c=n(this),f;return c==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),f=c+"",l===f?null:l===i&&f===r?s:(r=f,s=t(i=l,c)))}}function pV(e,t){var n=hx(e),i=n==="transform"?XY:jk;return this.attrTween(e,typeof t=="function"?(n.local?hV:fV)(n,i,q_(this,"attr."+e,t)):t==null?(n.local?cV:oV)(n):(n.local?dV:uV)(n,i,t))}function mV(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function gV(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function yV(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&gV(e,s)),n}return r._value=t,r}function xV(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&mV(e,s)),n}return r._value=t,r}function bV(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=hx(e);return this.tween(n,(i.local?yV:xV)(i,t))}function vV(e,t){return function(){G_(this,e).delay=+t.apply(this,arguments)}}function _V(e,t){return t=+t,function(){G_(this,e).delay=t}}function SV(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vV:_V)(t,e)):Tl(this.node(),t).delay}function EV(e,t){return function(){bo(this,e).duration=+t.apply(this,arguments)}}function wV(e,t){return t=+t,function(){bo(this,e).duration=t}}function TV(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?EV:wV)(t,e)):Tl(this.node(),t).duration}function CV(e,t){if(typeof t!="function")throw new Error;return function(){bo(this,e).ease=t}}function AV(e){var t=this._id;return arguments.length?this.each(CV(t,e)):Tl(this.node(),t).ease}function MV(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;bo(this,e).ease=n}}function RV(e){if(typeof e!="function")throw new Error;return this.each(MV(this._id,e))}function kV(e){typeof e!="function"&&(e=pk(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],l=s.length,c=i[r]=[],f,p=0;p<l;++p)(f=s[p])&&e.call(f,f.__data__,p,s)&&c.push(f);return new oc(i,this._parents,this._name,this._id)}function NV(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,s=Math.min(i,r),l=new Array(i),c=0;c<s;++c)for(var f=t[c],p=n[c],m=f.length,g=l[c]=new Array(m),x,v=0;v<m;++v)(x=f[v]||p[v])&&(g[v]=x);for(;c<i;++c)l[c]=t[c];return new oc(l,this._parents,this._name,this._id)}function OV(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function DV(e,t,n){var i,r,s=OV(t)?G_:bo;return function(){var l=s(this,e),c=l.on;c!==i&&(r=(i=c).copy()).on(t,n),l.on=r}}function zV(e,t){var n=this._id;return arguments.length<2?Tl(this.node(),n).on.on(e):this.each(DV(n,e,t))}function BV(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function LV(){return this.on("end.remove",BV(this._id))}function jV(e){var t=this._name,n=this._id;typeof e!="function"&&(e=I_(e));for(var i=this._groups,r=i.length,s=new Array(r),l=0;l<r;++l)for(var c=i[l],f=c.length,p=s[l]=new Array(f),m,g,x=0;x<f;++x)(m=c[x])&&(g=e.call(m,m.__data__,x,c))&&("__data__"in m&&(g.__data__=m.__data__),p[x]=g,mx(p[x],t,n,x,p,Tl(m,n)));return new oc(s,this._parents,t,n)}function IV(e){var t=this._name,n=this._id;typeof e!="function"&&(e=hk(e));for(var i=this._groups,r=i.length,s=[],l=[],c=0;c<r;++c)for(var f=i[c],p=f.length,m,g=0;g<p;++g)if(m=f[g]){for(var x=e.call(m,m.__data__,g,f),v,S=Tl(m,n),A=0,T=x.length;A<T;++A)(v=x[A])&&mx(v,t,n,A,x,S);s.push(x),l.push(m)}return new oc(s,l,t,n)}var UV=rg.prototype.constructor;function HV(){return new UV(this._groups,this._parents)}function PV(e,t){var n,i,r;return function(){var s=hh(this,e),l=(this.style.removeProperty(e),hh(this,e));return s===l?null:s===n&&l===i?r:r=t(n=s,i=l)}}function Ik(e){return function(){this.style.removeProperty(e)}}function FV(e,t,n){var i,r=n+"",s;return function(){var l=hh(this,e);return l===r?null:l===i?s:s=t(i=l,n)}}function GV(e,t,n){var i,r,s;return function(){var l=hh(this,e),c=n(this),f=c+"";return c==null&&(f=c=(this.style.removeProperty(e),hh(this,e))),l===f?null:l===i&&f===r?s:(r=f,s=t(i=l,c))}}function qV(e,t){var n,i,r,s="style."+t,l="end."+s,c;return function(){var f=bo(this,e),p=f.on,m=f.value[s]==null?c||(c=Ik(t)):void 0;(p!==n||r!==m)&&(i=(n=p).copy()).on(l,r=m),f.on=i}}function YV(e,t,n){var i=(e+="")=="transform"?VY:jk;return t==null?this.styleTween(e,PV(e,i)).on("end.style."+e,Ik(e)):typeof t=="function"?this.styleTween(e,GV(e,i,q_(this,"style."+e,t))).each(qV(this._id,e)):this.styleTween(e,FV(e,i,t),n).on("end.style."+e,null)}function VV(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function XV(e,t,n){var i,r;function s(){var l=t.apply(this,arguments);return l!==r&&(i=(r=l)&&VV(e,l,n)),i}return s._value=t,s}function KV(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,XV(e,t,n??""))}function $V(e){return function(){this.textContent=e}}function WV(e){return function(){var t=e(this);this.textContent=t??""}}function QV(e){return this.tween("text",typeof e=="function"?WV(q_(this,"text",e)):$V(e==null?"":e+""))}function ZV(e){return function(t){this.textContent=e.call(this,t)}}function JV(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ZV(r)),t}return i._value=e,i}function eX(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,JV(e))}function tX(){for(var e=this._name,t=this._id,n=Uk(),i=this._groups,r=i.length,s=0;s<r;++s)for(var l=i[s],c=l.length,f,p=0;p<c;++p)if(f=l[p]){var m=Tl(f,t);mx(f,e,n,p,l,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new oc(i,this._parents,e,n)}function nX(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(s,l){var c={value:l},f={value:function(){--r===0&&s()}};n.each(function(){var p=bo(this,i),m=p.on;m!==e&&(t=(e=m).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(f)),p.on=t}),r===0&&s()})}var iX=0;function oc(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function Uk(){return++iX}var Jo=rg.prototype;oc.prototype={constructor:oc,select:jV,selectAll:IV,selectChild:Jo.selectChild,selectChildren:Jo.selectChildren,filter:kV,merge:NV,selection:HV,transition:tX,call:Jo.call,nodes:Jo.nodes,node:Jo.node,size:Jo.size,empty:Jo.empty,each:Jo.each,on:zV,attr:pV,attrTween:bV,style:YV,styleTween:KV,text:QV,textTween:eX,remove:LV,tween:lV,delay:SV,duration:TV,ease:AV,easeVarying:RV,end:nX,[Symbol.iterator]:Jo[Symbol.iterator]};function rX(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var aX={time:null,delay:0,duration:250,ease:rX};function sX(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function lX(e){var t,n;e instanceof oc?(t=e._id,e=e._name):(t=Uk(),(n=aX).time=F_(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var l=i[s],c=l.length,f,p=0;p<c;++p)(f=l[p])&&mx(f,e,t,p,l,n||sX(f,t));return new oc(i,this._parents,e,t)}rg.prototype.interrupt=rV;rg.prototype.transition=lX;const o0=e=>()=>e;function oX(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function ic(e,t,n){this.k=e,this.x=t,this.y=n}ic.prototype={constructor:ic,scale:function(e){return e===1?this:new ic(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ic(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var gx=new ic(1,0,0);Hk.prototype=ic.prototype;function Hk(e){for(;!e.__zoom;)if(!(e=e.parentNode))return gx;return e.__zoom}function Cv(e){e.stopImmediatePropagation()}function dm(e){e.preventDefault(),e.stopImmediatePropagation()}function cX(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function uX(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function RT(){return this.__zoom||gx}function dX(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function fX(){return navigator.maxTouchPoints||"ontouchstart"in this}function hX(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],l=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),l>s?(s+l)/2:Math.min(0,s)||Math.max(0,l))}function Pk(){var e=cX,t=uX,n=hX,i=dX,r=fX,s=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,f=v0,p=fx("start","zoom","end"),m,g,x,v=500,S=150,A=0,T=10;function C(I){I.property("__zoom",RT).on("wheel.zoom",Z,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",Y).filter(r).on("touchstart.zoom",P).on("touchmove.zoom",q).on("touchend.zoom touchcancel.zoom",ne).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}C.transform=function(I,$,z,G){var Q=I.selection?I.selection():I;Q.property("__zoom",RT),I!==Q?H(I,$,z,G):Q.interrupt().each(function(){D(this,arguments).event(G).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},C.scaleBy=function(I,$,z,G){C.scaleTo(I,function(){var Q=this.__zoom.k,W=typeof $=="function"?$.apply(this,arguments):$;return Q*W},z,G)},C.scaleTo=function(I,$,z,G){C.transform(I,function(){var Q=t.apply(this,arguments),W=this.__zoom,B=z==null?O(Q):typeof z=="function"?z.apply(this,arguments):z,K=W.invert(B),J=typeof $=="function"?$.apply(this,arguments):$;return n(R(N(W,J),B,K),Q,l)},z,G)},C.translateBy=function(I,$,z,G){C.transform(I,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),l)},null,G)},C.translateTo=function(I,$,z,G,Q){C.transform(I,function(){var W=t.apply(this,arguments),B=this.__zoom,K=G==null?O(W):typeof G=="function"?G.apply(this,arguments):G;return n(gx.translate(K[0],K[1]).scale(B.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof z=="function"?-z.apply(this,arguments):-z),W,l)},G,Q)};function N(I,$){return $=Math.max(s[0],Math.min(s[1],$)),$===I.k?I:new ic($,I.x,I.y)}function R(I,$,z){var G=$[0]-z[0]*I.k,Q=$[1]-z[1]*I.k;return G===I.x&&Q===I.y?I:new ic(I.k,G,Q)}function O(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function H(I,$,z,G){I.on("start.zoom",function(){D(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,W=arguments,B=D(Q,W).event(G),K=t.apply(Q,W),J=z==null?O(K):typeof z=="function"?z.apply(Q,W):z,X=Math.max(K[1][0]-K[0][0],K[1][1]-K[0][1]),ce=Q.__zoom,ie=typeof $=="function"?$.apply(Q,W):$,de=f(ce.invert(J).concat(X/ce.k),ie.invert(J).concat(X/ie.k));return function(ye){if(ye===1)ye=ie;else{var me=de(ye),le=X/me[2];ye=new ic(le,J[0]-me[0]*le,J[1]-me[1]*le)}B.zoom(null,ye)}})}function D(I,$,z){return!z&&I.__zooming||new F(I,$)}function F(I,$){this.that=I,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,$),this.taps=0}F.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,$){return this.mouse&&I!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var $=ns(this.that).datum();p.call(I,this.that,new oX(I,{sourceEvent:this.sourceEvent,target:C,transform:this.that.__zoom,dispatch:p}),$)}};function Z(I,...$){if(!e.apply(this,arguments))return;var z=D(this,$).event(I),G=this.__zoom,Q=Math.max(s[0],Math.min(s[1],G.k*Math.pow(2,i.apply(this,arguments)))),W=pl(I);if(z.wheel)(z.mouse[0][0]!==W[0]||z.mouse[0][1]!==W[1])&&(z.mouse[1]=G.invert(z.mouse[0]=W)),clearTimeout(z.wheel);else{if(G.k===Q)return;z.mouse=[W,G.invert(W)],E0(this),z.start()}dm(I),z.wheel=setTimeout(B,S),z.zoom("mouse",n(R(N(G,Q),z.mouse[0],z.mouse[1]),z.extent,l));function B(){z.wheel=null,z.end()}}function V(I,...$){if(x||!e.apply(this,arguments))return;var z=I.currentTarget,G=D(this,$,!0).event(I),Q=ns(I.view).on("mousemove.zoom",J,!0).on("mouseup.zoom",X,!0),W=pl(I,z),B=I.clientX,K=I.clientY;wk(I.view),Cv(I),G.mouse=[W,this.__zoom.invert(W)],E0(this),G.start();function J(ce){if(dm(ce),!G.moved){var ie=ce.clientX-B,de=ce.clientY-K;G.moved=ie*ie+de*de>A}G.event(ce).zoom("mouse",n(R(G.that.__zoom,G.mouse[0]=pl(ce,z),G.mouse[1]),G.extent,l))}function X(ce){Q.on("mousemove.zoom mouseup.zoom",null),Tk(ce.view,G.moved),dm(ce),G.event(ce).end()}}function Y(I,...$){if(e.apply(this,arguments)){var z=this.__zoom,G=pl(I.changedTouches?I.changedTouches[0]:I,this),Q=z.invert(G),W=z.k*(I.shiftKey?.5:2),B=n(R(N(z,W),G,Q),t.apply(this,$),l);dm(I),c>0?ns(this).transition().duration(c).call(H,B,G,I):ns(this).call(C.transform,B,G,I)}}function P(I,...$){if(e.apply(this,arguments)){var z=I.touches,G=z.length,Q=D(this,$,I.changedTouches.length===G).event(I),W,B,K,J;for(Cv(I),B=0;B<G;++B)K=z[B],J=pl(K,this),J=[J,this.__zoom.invert(J),K.identifier],Q.touch0?!Q.touch1&&Q.touch0[2]!==J[2]&&(Q.touch1=J,Q.taps=0):(Q.touch0=J,W=!0,Q.taps=1+!!m);m&&(m=clearTimeout(m)),W&&(Q.taps<2&&(g=J[0],m=setTimeout(function(){m=null},v)),E0(this),Q.start())}}function q(I,...$){if(this.__zooming){var z=D(this,$).event(I),G=I.changedTouches,Q=G.length,W,B,K,J;for(dm(I),W=0;W<Q;++W)B=G[W],K=pl(B,this),z.touch0&&z.touch0[2]===B.identifier?z.touch0[0]=K:z.touch1&&z.touch1[2]===B.identifier&&(z.touch1[0]=K);if(B=z.that.__zoom,z.touch1){var X=z.touch0[0],ce=z.touch0[1],ie=z.touch1[0],de=z.touch1[1],ye=(ye=ie[0]-X[0])*ye+(ye=ie[1]-X[1])*ye,me=(me=de[0]-ce[0])*me+(me=de[1]-ce[1])*me;B=N(B,Math.sqrt(ye/me)),K=[(X[0]+ie[0])/2,(X[1]+ie[1])/2],J=[(ce[0]+de[0])/2,(ce[1]+de[1])/2]}else if(z.touch0)K=z.touch0[0],J=z.touch0[1];else return;z.zoom("touch",n(R(B,K,J),z.extent,l))}}function ne(I,...$){if(this.__zooming){var z=D(this,$).event(I),G=I.changedTouches,Q=G.length,W,B;for(Cv(I),x&&clearTimeout(x),x=setTimeout(function(){x=null},v),W=0;W<Q;++W)B=G[W],z.touch0&&z.touch0[2]===B.identifier?delete z.touch0:z.touch1&&z.touch1[2]===B.identifier&&delete z.touch1;if(z.touch1&&!z.touch0&&(z.touch0=z.touch1,delete z.touch1),z.touch0)z.touch0[1]=this.__zoom.invert(z.touch0[0]);else if(z.end(),z.taps===2&&(B=pl(B,this),Math.hypot(g[0]-B[0],g[1]-B[1])<T)){var K=ns(this).on("dblclick.zoom");K&&K.apply(this,arguments)}}}return C.wheelDelta=function(I){return arguments.length?(i=typeof I=="function"?I:o0(+I),C):i},C.filter=function(I){return arguments.length?(e=typeof I=="function"?I:o0(!!I),C):e},C.touchable=function(I){return arguments.length?(r=typeof I=="function"?I:o0(!!I),C):r},C.extent=function(I){return arguments.length?(t=typeof I=="function"?I:o0([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),C):t},C.scaleExtent=function(I){return arguments.length?(s[0]=+I[0],s[1]=+I[1],C):[s[0],s[1]]},C.translateExtent=function(I){return arguments.length?(l[0][0]=+I[0][0],l[1][0]=+I[1][0],l[0][1]=+I[0][1],l[1][1]=+I[1][1],C):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},C.constrain=function(I){return arguments.length?(n=I,C):n},C.duration=function(I){return arguments.length?(c=+I,C):c},C.interpolate=function(I){return arguments.length?(f=I,C):f},C.on=function(){var I=p.on.apply(p,arguments);return I===p?C:I},C.clickDistance=function(I){return arguments.length?(A=(I=+I)*I,C):Math.sqrt(A)},C.tapDistance=function(I){return arguments.length?(T=+I,C):T},C}const go={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Gm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Fk=["Enter"," ","Escape"],Gk={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var mh;(function(e){e.Strict="strict",e.Loose="loose"})(mh||(mh={}));var bd;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(bd||(bd={}));var qm;(function(e){e.Partial="partial",e.Full="full"})(qm||(qm={}));const qk={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var su;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(su||(su={}));var Ym;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ym||(Ym={}));var We;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(We||(We={}));const kT={[We.Left]:We.Right,[We.Right]:We.Left,[We.Top]:We.Bottom,[We.Bottom]:We.Top};function Yk(e){return e===null?null:e?"valid":"invalid"}const Vk=e=>"id"in e&&"source"in e&&"target"in e,pX=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Y_=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),sg=(e,t=[0,0])=>{const{width:n,height:i}=dc(e),r=e.origin??t,s=n*r[0],l=i*r[1];return{x:e.position.x-s,y:e.position.y-l}},mX=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,r)=>{const s=typeof r=="string";let l=!t.nodeLookup&&!s?r:void 0;t.nodeLookup&&(l=s?t.nodeLookup.get(r):Y_(r)?r:t.nodeLookup.get(r.id));const c=l?X0(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return yx(i,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return xx(n)},lg=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=yx(n,X0(r)),i=!0)}),i?xx(n):{x:0,y:0,width:0,height:0}},V_=(e,t,[n,i,r]=[0,0,1],s=!1,l=!1)=>{const c={...cg(t,[n,i,r]),width:t.width/r,height:t.height/r},f=[];for(const p of e.values()){const{measured:m,selectable:g=!0,hidden:x=!1}=p;if(l&&!g||x)continue;const v=m.width??p.width??p.initialWidth??null,S=m.height??p.height??p.initialHeight??null,A=Vm(c,yh(p)),T=(v??0)*(S??0),C=s&&A>0;(!p.internals.handleBounds||C||A>=T||p.dragging)&&f.push(p)}return f},gX=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function yX(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function xX({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:s},l){if(e.size===0)return Promise.resolve(!0);const c=yX(e,l),f=lg(c),p=X_(f,t,n,(l==null?void 0:l.minZoom)??r,(l==null?void 0:l.maxZoom)??s,(l==null?void 0:l.padding)??.1);return await i.setViewport(p,{duration:l==null?void 0:l.duration,ease:l==null?void 0:l.ease,interpolate:l==null?void 0:l.interpolate}),Promise.resolve(!0)}function Xk({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:s}){const l=n.get(e),c=l.parentId?n.get(l.parentId):void 0,{x:f,y:p}=c?c.internals.positionAbsolute:{x:0,y:0},m=l.origin??i;let g=l.extent||r;if(l.extent==="parent"&&!l.expandParent)if(!c)s==null||s("005",go.error005());else{const v=c.measured.width,S=c.measured.height;v&&S&&(g=[[f,p],[f+v,p+S]])}else c&&xh(l.extent)&&(g=[[l.extent[0][0]+f,l.extent[0][1]+p],[l.extent[1][0]+f,l.extent[1][1]+p]]);const x=xh(g)?Td(t,g,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&(s==null||s("015",go.error015())),{position:{x:x.x-f+(l.measured.width??0)*m[0],y:x.y-p+(l.measured.height??0)*m[1]},positionAbsolute:x}}async function bX({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const s=new Set(e.map(x=>x.id)),l=[];for(const x of n){if(x.deletable===!1)continue;const v=s.has(x.id),S=!v&&x.parentId&&l.find(A=>A.id===x.parentId);(v||S)&&l.push(x)}const c=new Set(t.map(x=>x.id)),f=i.filter(x=>x.deletable!==!1),m=gX(l,f);for(const x of f)c.has(x.id)&&!m.find(S=>S.id===x.id)&&m.push(x);if(!r)return{edges:m,nodes:l};const g=await r({nodes:l,edges:m});return typeof g=="boolean"?g?{edges:m,nodes:l}:{edges:[],nodes:[]}:g}const gh=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Td=(e={x:0,y:0},t,n)=>({x:gh(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:gh(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Kk(e,t,n){const{width:i,height:r}=dc(n),{x:s,y:l}=n.internals.positionAbsolute;return Td(e,[[s,l],[s+i,l+r]],t)}const NT=(e,t,n)=>e<t?gh(Math.abs(e-t),1,t)/t:e>n?-gh(Math.abs(e-n),1,t)/t:0,$k=(e,t,n=15,i=40)=>{const r=NT(e.x,i,t.width-i)*n,s=NT(e.y,i,t.height-i)*n;return[r,s]},yx=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),I1=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),xx=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),yh=(e,t=[0,0])=>{var r,s;const{x:n,y:i}=Y_(e)?e.internals.positionAbsolute:sg(e,t);return{x:n,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}},X0=(e,t=[0,0])=>{var r,s;const{x:n,y:i}=Y_(e)?e.internals.positionAbsolute:sg(e,t);return{x:n,y:i,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0)}},Wk=(e,t)=>xx(yx(I1(e),I1(t))),Vm=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},OT=e=>xl(e.width)&&xl(e.height)&&xl(e.x)&&xl(e.y),xl=e=>!isNaN(e)&&isFinite(e),vX=(e,t)=>{},og=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),cg=({x:e,y:t},[n,i,r],s=!1,l=[1,1])=>{const c={x:(e-n)/r,y:(t-i)/r};return s?og(c,l):c},K0=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function Pf(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function _X(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=Pf(e,n),r=Pf(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=Pf(e.top??e.y??0,n),r=Pf(e.bottom??e.y??0,n),s=Pf(e.left??e.x??0,t),l=Pf(e.right??e.x??0,t);return{top:i,right:l,bottom:r,left:s,x:s+l,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function SX(e,t,n,i,r,s){const{x:l,y:c}=K0(e,[t,n,i]),{x:f,y:p}=K0({x:e.x+e.width,y:e.y+e.height},[t,n,i]),m=r-f,g=s-p;return{left:Math.floor(l),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(g)}}const X_=(e,t,n,i,r,s)=>{const l=_X(s,t,n),c=(t-l.x)/e.width,f=(n-l.y)/e.height,p=Math.min(c,f),m=gh(p,i,r),g=e.x+e.width/2,x=e.y+e.height/2,v=t/2-g*m,S=n/2-x*m,A=SX(e,v,S,m,t,n),T={left:Math.min(A.left-l.left,0),top:Math.min(A.top-l.top,0),right:Math.min(A.right-l.right,0),bottom:Math.min(A.bottom-l.bottom,0)};return{x:v-T.left+T.right,y:S-T.top+T.bottom,zoom:m}},Xm=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xh(e){return e!=null&&e!=="parent"}function dc(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Qk(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Zk(e,t={width:0,height:0},n,i,r){const s={...e},l=i.get(n);if(l){const c=l.origin||r;s.x+=l.internals.positionAbsolute.x-(t.width??0)*c[0],s.y+=l.internals.positionAbsolute.y-(t.height??0)*c[1]}return s}function DT(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function EX(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function wX(e){return{...Gk,...e||{}}}function Rm(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:s,y:l}=bl(e),c=cg({x:s-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},i),{x:f,y:p}=n?og(c,t):c;return{xSnapped:f,ySnapped:p,...c}}const K_=e=>({width:e.offsetWidth,height:e.offsetHeight}),Jk=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},TX=["INPUT","SELECT","TEXTAREA"];function eN(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:TX.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const tN=e=>"clientX"in e,bl=(e,t)=>{var s,l;const n=tN(e),i=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,r=n?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},zT=(e,t,n,i,r)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(l=>{const c=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:r,position:l.getAttribute("data-handlepos"),x:(c.left-n.left)/i,y:(c.top-n.top)/i,...K_(l)}})};function nN({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:s,targetControlX:l,targetControlY:c}){const f=e*.125+r*.375+l*.375+n*.125,p=t*.125+s*.375+c*.375+i*.125,m=Math.abs(f-e),g=Math.abs(p-t);return[f,p,m,g]}function c0(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function BT({pos:e,x1:t,y1:n,x2:i,y2:r,c:s}){switch(e){case We.Left:return[t-c0(t-i,s),n];case We.Right:return[t+c0(i-t,s),n];case We.Top:return[t,n-c0(n-r,s)];case We.Bottom:return[t,n+c0(r-n,s)]}}function iN({sourceX:e,sourceY:t,sourcePosition:n=We.Bottom,targetX:i,targetY:r,targetPosition:s=We.Top,curvature:l=.25}){const[c,f]=BT({pos:n,x1:e,y1:t,x2:i,y2:r,c:l}),[p,m]=BT({pos:s,x1:i,y1:r,x2:e,y2:t,c:l}),[g,x,v,S]=nN({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:c,sourceControlY:f,targetControlX:p,targetControlY:m});return[`M${e},${t} C${c},${f} ${p},${m} ${i},${r}`,g,x,v,S]}function rN({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,s=n<e?n+r:n-r,l=Math.abs(i-t)/2,c=i<t?i+l:i-l;return[s,c,r,l]}function CX({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:r=!1,zIndexMode:s="basic"}){if(s==="manual")return i;const l=r&&n?i+1e3:i,c=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return l+c}function AX({sourceNode:e,targetNode:t,width:n,height:i,transform:r}){const s=yx(X0(e),X0(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const l={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:i/r[2]};return Vm(l,xx(s))>0}const MX=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,RX=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),kX=(e,t,n={})=>{if(!e.source||!e.target)return t;const i=n.getEdgeId||MX;let r;return Vk(e)?r={...e}:r={...e,id:i(e)},RX(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function aN({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,s,l,c]=rN({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,s,l,c]}const LT={[We.Left]:{x:-1,y:0},[We.Right]:{x:1,y:0},[We.Top]:{x:0,y:-1},[We.Bottom]:{x:0,y:1}},NX=({source:e,sourcePosition:t=We.Bottom,target:n})=>t===We.Left||t===We.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},jT=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function OX({source:e,sourcePosition:t=We.Bottom,target:n,targetPosition:i=We.Top,center:r,offset:s,stepPosition:l}){const c=LT[t],f=LT[i],p={x:e.x+c.x*s,y:e.y+c.y*s},m={x:n.x+f.x*s,y:n.y+f.y*s},g=NX({source:p,sourcePosition:t,target:m}),x=g.x!==0?"x":"y",v=g[x];let S=[],A,T;const C={x:0,y:0},N={x:0,y:0},[,,R,O]=rN({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[x]*f[x]===-1){x==="x"?(A=r.x??p.x+(m.x-p.x)*l,T=r.y??(p.y+m.y)/2):(A=r.x??(p.x+m.x)/2,T=r.y??p.y+(m.y-p.y)*l);const D=[{x:A,y:p.y},{x:A,y:m.y}],F=[{x:p.x,y:T},{x:m.x,y:T}];c[x]===v?S=x==="x"?D:F:S=x==="x"?F:D}else{const D=[{x:p.x,y:m.y}],F=[{x:m.x,y:p.y}];if(x==="x"?S=c.x===v?F:D:S=c.y===v?D:F,t===i){const q=Math.abs(e[x]-n[x]);if(q<=s){const ne=Math.min(s-1,s-q);c[x]===v?C[x]=(p[x]>e[x]?-1:1)*ne:N[x]=(m[x]>n[x]?-1:1)*ne}}if(t!==i){const q=x==="x"?"y":"x",ne=c[x]===f[q],I=p[q]>m[q],$=p[q]<m[q];(c[x]===1&&(!ne&&I||ne&&$)||c[x]!==1&&(!ne&&$||ne&&I))&&(S=x==="x"?D:F)}const Z={x:p.x+C.x,y:p.y+C.y},V={x:m.x+N.x,y:m.y+N.y},Y=Math.max(Math.abs(Z.x-S[0].x),Math.abs(V.x-S[0].x)),P=Math.max(Math.abs(Z.y-S[0].y),Math.abs(V.y-S[0].y));Y>=P?(A=(Z.x+V.x)/2,T=S[0].y):(A=S[0].x,T=(Z.y+V.y)/2)}return[[e,{x:p.x+C.x,y:p.y+C.y},...S,{x:m.x+N.x,y:m.y+N.y},n],A,T,R,O]}function DX(e,t,n,i){const r=Math.min(jT(e,t)/2,jT(t,n)/2,i),{x:s,y:l}=t;if(e.x===s&&s===n.x||e.y===l&&l===n.y)return`L${s} ${l}`;if(e.y===l){const p=e.x<n.x?-1:1,m=e.y<n.y?1:-1;return`L ${s+r*p},${l}Q ${s},${l} ${s},${l+r*m}`}const c=e.x<n.x?1:-1,f=e.y<n.y?-1:1;return`L ${s},${l+r*f}Q ${s},${l} ${s+r*c},${l}`}function U1({sourceX:e,sourceY:t,sourcePosition:n=We.Bottom,targetX:i,targetY:r,targetPosition:s=We.Top,borderRadius:l=5,centerX:c,centerY:f,offset:p=20,stepPosition:m=.5}){const[g,x,v,S,A]=OX({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:r},targetPosition:s,center:{x:c,y:f},offset:p,stepPosition:m});return[g.reduce((C,N,R)=>{let O="";return R>0&&R<g.length-1?O=DX(g[R-1],N,g[R+1],l):O=`${R===0?"M":"L"}${N.x} ${N.y}`,C+=O,C},""),x,v,S,A]}function IT(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function zX(e){var g;const{sourceNode:t,targetNode:n}=e;if(!IT(t)||!IT(n))return null;const i=t.internals.handleBounds||UT(t.handles),r=n.internals.handleBounds||UT(n.handles),s=HT((i==null?void 0:i.source)??[],e.sourceHandle),l=HT(e.connectionMode===mh.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!s||!l)return(g=e.onError)==null||g.call(e,"008",go.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(s==null?void 0:s.position)||We.Bottom,f=(l==null?void 0:l.position)||We.Top,p=Cd(t,s,c),m=Cd(n,l,f);return{sourceX:p.x,sourceY:p.y,targetX:m.x,targetY:m.y,sourcePosition:c,targetPosition:f}}function UT(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function Cd(e,t,n=We.Left,i=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,s=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:l,height:c}=t??dc(e);if(i)return{x:r+l/2,y:s+c/2};switch((t==null?void 0:t.position)??n){case We.Top:return{x:r+l/2,y:s};case We.Right:return{x:r+l,y:s+c/2};case We.Bottom:return{x:r+l/2,y:s+c};case We.Left:return{x:r,y:s+c/2}}}function HT(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function H1(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function BX(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const s=new Set;return e.reduce((l,c)=>([c.markerStart||i,c.markerEnd||r].forEach(f=>{if(f&&typeof f=="object"){const p=H1(f,t);s.has(p)||(l.push({id:p,color:f.color||n,...f}),s.add(p))}}),l),[]).sort((l,c)=>l.id.localeCompare(c.id))}const sN=1e3,LX=10,$_={nodeOrigin:[0,0],nodeExtent:Gm,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},jX={...$_,checkEquality:!0};function W_(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function IX(e,t,n){const i=W_($_,n);for(const r of e.values())if(r.parentId)Z_(r,e,t,i);else{const s=sg(r,i.nodeOrigin),l=xh(r.extent)?r.extent:i.nodeExtent,c=Td(s,l,dc(r));r.internals.positionAbsolute=c}}function UX(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const r of e.handles){const s={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(s):r.type==="target"&&i.push(s)}return{source:n,target:i}}function Q_(e){return e==="manual"}function P1(e,t,n,i={}){var p,m;const r=W_(jX,i),s={i:0},l=new Map(t),c=r!=null&&r.elevateNodesOnSelect&&!Q_(r.zIndexMode)?sN:0;let f=e.length>0;t.clear(),n.clear();for(const g of e){let x=l.get(g.id);if(r.checkEquality&&g===(x==null?void 0:x.internals.userNode))t.set(g.id,x);else{const v=sg(g,r.nodeOrigin),S=xh(g.extent)?g.extent:r.nodeExtent,A=Td(v,S,dc(g));x={...r.defaults,...g,measured:{width:(p=g.measured)==null?void 0:p.width,height:(m=g.measured)==null?void 0:m.height},internals:{positionAbsolute:A,handleBounds:UX(g,x),z:lN(g,c,r.zIndexMode),userNode:g}},t.set(g.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(f=!1),g.parentId&&Z_(x,t,n,i,s)}return f}function HX(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Z_(e,t,n,i,r){const{elevateNodesOnSelect:s,nodeOrigin:l,nodeExtent:c,zIndexMode:f}=W_($_,i),p=e.parentId,m=t.get(p);if(!m){console.warn(`Parent node ${p} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}HX(e,n),r&&!m.parentId&&m.internals.rootParentIndex===void 0&&f==="auto"&&(m.internals.rootParentIndex=++r.i,m.internals.z=m.internals.z+r.i*LX),r&&m.internals.rootParentIndex!==void 0&&(r.i=m.internals.rootParentIndex);const g=s&&!Q_(f)?sN:0,{x,y:v,z:S}=PX(e,m,l,c,g,f),{positionAbsolute:A}=e.internals,T=x!==A.x||v!==A.y;(T||S!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:T?{x,y:v}:A,z:S}})}function lN(e,t,n){const i=xl(e.zIndex)?e.zIndex:0;return Q_(n)?i:i+(e.selected?t:0)}function PX(e,t,n,i,r,s){const{x:l,y:c}=t.internals.positionAbsolute,f=dc(e),p=sg(e,n),m=xh(e.extent)?Td(p,e.extent,f):p;let g=Td({x:l+m.x,y:c+m.y},i,f);e.extent==="parent"&&(g=Kk(g,f,t));const x=lN(e,r,s),v=t.internals.z??0;return{x:g.x,y:g.y,z:v>=x?v+1:x}}function J_(e,t,n,i=[0,0]){var l;const r=[],s=new Map;for(const c of e){const f=t.get(c.parentId);if(!f)continue;const p=((l=s.get(c.parentId))==null?void 0:l.expandedRect)??yh(f),m=Wk(p,c.rect);s.set(c.parentId,{expandedRect:m,parent:f})}return s.size>0&&s.forEach(({expandedRect:c,parent:f},p)=>{var R;const m=f.internals.positionAbsolute,g=dc(f),x=f.origin??i,v=c.x<m.x?Math.round(Math.abs(m.x-c.x)):0,S=c.y<m.y?Math.round(Math.abs(m.y-c.y)):0,A=Math.max(g.width,Math.round(c.width)),T=Math.max(g.height,Math.round(c.height)),C=(A-g.width)*x[0],N=(T-g.height)*x[1];(v>0||S>0||C||N)&&(r.push({id:p,type:"position",position:{x:f.position.x-v+C,y:f.position.y-S+N}}),(R=n.get(p))==null||R.forEach(O=>{e.some(H=>H.id===O.id)||r.push({id:O.id,type:"position",position:{x:O.position.x+v,y:O.position.y+S}})})),(g.width<c.width||g.height<c.height||v||S)&&r.push({id:p,type:"dimensions",setAttributes:!0,dimensions:{width:A+(v?x[0]*v-C:0),height:T+(S?x[1]*S-N:0)}})}),r}function FX(e,t,n,i,r,s,l){const c=i==null?void 0:i.querySelector(".xyflow__viewport");let f=!1;if(!c)return{changes:[],updatedInternals:f};const p=[],m=window.getComputedStyle(c),{m22:g}=new window.DOMMatrixReadOnly(m.transform),x=[];for(const v of e.values()){const S=t.get(v.id);if(!S)continue;if(S.hidden){t.set(S.id,{...S,internals:{...S.internals,handleBounds:void 0}}),f=!0;continue}const A=K_(v.nodeElement),T=S.measured.width!==A.width||S.measured.height!==A.height;if(!!(A.width&&A.height&&(T||!S.internals.handleBounds||v.force))){const N=v.nodeElement.getBoundingClientRect(),R=xh(S.extent)?S.extent:s;let{positionAbsolute:O}=S.internals;S.parentId&&S.extent==="parent"?O=Kk(O,A,t.get(S.parentId)):R&&(O=Td(O,R,A));const H={...S,measured:A,internals:{...S.internals,positionAbsolute:O,handleBounds:{source:zT("source",v.nodeElement,N,g,S.id),target:zT("target",v.nodeElement,N,g,S.id)}}};t.set(S.id,H),S.parentId&&Z_(H,t,n,{nodeOrigin:r,zIndexMode:l}),f=!0,T&&(p.push({id:S.id,type:"dimensions",dimensions:A}),S.expandParent&&S.parentId&&x.push({id:S.id,parentId:S.parentId,rect:yh(H,r)}))}}if(x.length>0){const v=J_(x,t,n,r);p.push(...v)}return{changes:p,updatedInternals:f}}async function GX({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,height:s}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const l=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,s]],i),c=!!l&&(l.x!==n[0]||l.y!==n[1]||l.k!==n[2]);return Promise.resolve(c)}function PT(e,t,n,i,r,s){let l=r;const c=i.get(l)||new Map;i.set(l,c.set(n,t)),l=`${r}-${e}`;const f=i.get(l)||new Map;if(i.set(l,f.set(n,t)),s){l=`${r}-${e}-${s}`;const p=i.get(l)||new Map;i.set(l,p.set(n,t))}}function oN(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:s,sourceHandle:l=null,targetHandle:c=null}=i,f={edgeId:i.id,source:r,target:s,sourceHandle:l,targetHandle:c},p=`${r}-${l}--${s}-${c}`,m=`${s}-${c}--${r}-${l}`;PT("source",f,m,e,r,l),PT("target",f,p,e,s,c),t.set(i.id,i)}}function cN(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:cN(n,t):!1}function FT(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function qX(e,t,n,i){const r=new Map;for(const[s,l]of e)if((l.selected||l.id===i)&&(!l.parentId||!cN(l,e))&&(l.draggable||t&&typeof l.draggable>"u")){const c=e.get(s);c&&r.set(s,{id:s,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function Av({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var l,c,f;const r=[];for(const[p,m]of t){const g=(l=n.get(p))==null?void 0:l.internals.userNode;g&&r.push({...g,position:m.position,dragging:i})}if(!e)return[r[0],r];const s=(c=n.get(e))==null?void 0:c.internals.userNode;return[s?{...s,position:((f=t.get(e))==null?void 0:f.position)||s.position,dragging:i}:r[0],r]}function YX({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const s={x:n-r.distance.x,y:i-r.distance.y},l=og(s,t);return{x:l.x-s.x,y:l.y-s.y}}function VX({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let s={x:null,y:null},l=0,c=new Map,f=!1,p={x:0,y:0},m=null,g=!1,x=null,v=!1,S=!1,A=null;function T({noDragClassName:N,handleSelector:R,domNode:O,isSelectable:H,nodeId:D,nodeClickDistance:F=0}){x=ns(O);function Z({x:q,y:ne}){const{nodeLookup:I,nodeExtent:$,snapGrid:z,snapToGrid:G,nodeOrigin:Q,onNodeDrag:W,onSelectionDrag:B,onError:K,updateNodePositions:J}=t();s={x:q,y:ne};let X=!1;const ce=c.size>1,ie=ce&&$?I1(lg(c)):null,de=ce&&G?YX({dragItems:c,snapGrid:z,x:q,y:ne}):null;for(const[ye,me]of c){if(!I.has(ye))continue;let le={x:q-me.distance.x,y:ne-me.distance.y};G&&(le=de?{x:Math.round(le.x+de.x),y:Math.round(le.y+de.y)}:og(le,z));let Re=null;if(ce&&$&&!me.extent&&ie){const{positionAbsolute:He}=me.internals,Qe=He.x-ie.x+$[0][0],ot=He.x+me.measured.width-ie.x2+$[1][0],Ue=He.y-ie.y+$[0][1],wt=He.y+me.measured.height-ie.y2+$[1][1];Re=[[Qe,Ue],[ot,wt]]}const{position:Le,positionAbsolute:je}=Xk({nodeId:ye,nextPosition:le,nodeLookup:I,nodeExtent:Re||$,nodeOrigin:Q,onError:K});X=X||me.position.x!==Le.x||me.position.y!==Le.y,me.position=Le,me.internals.positionAbsolute=je}if(S=S||X,!!X&&(J(c,!0),A&&(i||W||!D&&B))){const[ye,me]=Av({nodeId:D,dragItems:c,nodeLookup:I});i==null||i(A,c,ye,me),W==null||W(A,ye,me),D||B==null||B(A,me)}}async function V(){if(!m)return;const{transform:q,panBy:ne,autoPanSpeed:I,autoPanOnNodeDrag:$}=t();if(!$){f=!1,cancelAnimationFrame(l);return}const[z,G]=$k(p,m,I);(z!==0||G!==0)&&(s.x=(s.x??0)-z/q[2],s.y=(s.y??0)-G/q[2],await ne({x:z,y:G})&&Z(s)),l=requestAnimationFrame(V)}function Y(q){var ce;const{nodeLookup:ne,multiSelectionActive:I,nodesDraggable:$,transform:z,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:W,onNodeDragStart:B,onSelectionDragStart:K,unselectNodesAndEdges:J}=t();g=!0,(!W||!H)&&!I&&D&&((ce=ne.get(D))!=null&&ce.selected||J()),H&&W&&D&&(e==null||e(D));const X=Rm(q.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Q,containerBounds:m});if(s=X,c=qX(ne,$,X,D),c.size>0&&(n||B||!D&&K)){const[ie,de]=Av({nodeId:D,dragItems:c,nodeLookup:ne});n==null||n(q.sourceEvent,c,ie,de),B==null||B(q.sourceEvent,ie,de),D||K==null||K(q.sourceEvent,de)}}const P=Ck().clickDistance(F).on("start",q=>{const{domNode:ne,nodeDragThreshold:I,transform:$,snapGrid:z,snapToGrid:G}=t();m=(ne==null?void 0:ne.getBoundingClientRect())||null,v=!1,S=!1,A=q.sourceEvent,I===0&&Y(q),s=Rm(q.sourceEvent,{transform:$,snapGrid:z,snapToGrid:G,containerBounds:m}),p=bl(q.sourceEvent,m)}).on("drag",q=>{const{autoPanOnNodeDrag:ne,transform:I,snapGrid:$,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Q}=t(),W=Rm(q.sourceEvent,{transform:I,snapGrid:$,snapToGrid:z,containerBounds:m});if(A=q.sourceEvent,(q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1||D&&!Q.has(D))&&(v=!0),!v){if(!f&&ne&&g&&(f=!0,V()),!g){const B=bl(q.sourceEvent,m),K=B.x-p.x,J=B.y-p.y;Math.sqrt(K*K+J*J)>G&&Y(q)}(s.x!==W.xSnapped||s.y!==W.ySnapped)&&c&&g&&(p=bl(q.sourceEvent,m),Z(W))}}).on("end",q=>{if(!(!g||v)&&(f=!1,g=!1,cancelAnimationFrame(l),c.size>0)){const{nodeLookup:ne,updateNodePositions:I,onNodeDragStop:$,onSelectionDragStop:z}=t();if(S&&(I(c,!1),S=!1),r||$||!D&&z){const[G,Q]=Av({nodeId:D,dragItems:c,nodeLookup:ne,dragging:!1});r==null||r(q.sourceEvent,c,G,Q),$==null||$(q.sourceEvent,G,Q),D||z==null||z(q.sourceEvent,Q)}}}).filter(q=>{const ne=q.target;return!q.button&&(!N||!FT(ne,`.${N}`,O))&&(!R||FT(ne,R,O))});x.call(P)}function C(){x==null||x.on(".drag",null)}return{update:T,destroy:C}}function XX(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())Vm(r,yh(s))>0&&i.push(s);return i}const KX=250;function $X(e,t,n,i){var c,f;let r=[],s=1/0;const l=XX(e,n,t+KX);for(const p of l){const m=[...((c=p.internals.handleBounds)==null?void 0:c.source)??[],...((f=p.internals.handleBounds)==null?void 0:f.target)??[]];for(const g of m){if(i.nodeId===g.nodeId&&i.type===g.type&&i.id===g.id)continue;const{x,y:v}=Cd(p,g,g.position,!0),S=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(v-e.y,2));S>t||(S<s?(r=[{...g,x,y:v}],s=S):S===s&&r.push({...g,x,y:v}))}}if(!r.length)return null;if(r.length>1){const p=i.type==="source"?"target":"source";return r.find(m=>m.type===p)??r[0]}return r[0]}function uN(e,t,n,i,r,s=!1){var p,m,g;const l=i.get(e);if(!l)return null;const c=r==="strict"?(p=l.internals.handleBounds)==null?void 0:p[t]:[...((m=l.internals.handleBounds)==null?void 0:m.source)??[],...((g=l.internals.handleBounds)==null?void 0:g.target)??[]],f=(n?c==null?void 0:c.find(x=>x.id===n):c==null?void 0:c[0])??null;return f&&s?{...f,...Cd(l,f,f.position,!0)}:f}function dN(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function WX(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const fN=()=>!0;function QX(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:s,isTarget:l,domNode:c,nodeLookup:f,lib:p,autoPanOnConnect:m,flowId:g,panBy:x,cancelConnection:v,onConnectStart:S,onConnect:A,onConnectEnd:T,isValidConnection:C=fN,onReconnectEnd:N,updateConnection:R,getTransform:O,getFromHandle:H,autoPanSpeed:D,dragThreshold:F=1,handleDomNode:Z}){const V=Jk(e.target);let Y=0,P;const{x:q,y:ne}=bl(e),I=dN(s,Z),$=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!$||!I)return;const G=uN(r,I,i,f,t);if(!G)return;let Q=bl(e,$),W=!1,B=null,K=!1,J=null;function X(){if(!m||!$)return;const[Le,je]=$k(Q,$,D);x({x:Le,y:je}),Y=requestAnimationFrame(X)}const ce={...G,nodeId:r,type:I,position:G.position},ie=f.get(r);let ye={inProgress:!0,isValid:null,from:Cd(ie,ce,We.Left,!0),fromHandle:ce,fromPosition:ce.position,fromNode:ie,to:Q,toHandle:null,toPosition:kT[ce.position],toNode:null,pointer:Q};function me(){z=!0,R(ye),S==null||S(e,{nodeId:r,handleId:i,handleType:I})}F===0&&me();function le(Le){if(!z){const{x:wt,y:_n}=bl(Le),Sn=wt-q,hn=_n-ne;if(!(Sn*Sn+hn*hn>F*F))return;me()}if(!H()||!ce){Re(Le);return}const je=O();Q=bl(Le,$),P=$X(cg(Q,je,!1,[1,1]),n,f,ce),W||(X(),W=!0);const He=hN(Le,{handle:P,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:l?"target":"source",isValidConnection:C,doc:V,lib:p,flowId:g,nodeLookup:f});J=He.handleDomNode,B=He.connection,K=WX(!!P,He.isValid);const Qe=f.get(r),ot=Qe?Cd(Qe,ce,We.Left,!0):ye.from,Ue={...ye,from:ot,isValid:K,to:He.toHandle&&K?K0({x:He.toHandle.x,y:He.toHandle.y},je):Q,toHandle:He.toHandle,toPosition:K&&He.toHandle?He.toHandle.position:kT[ce.position],toNode:He.toHandle?f.get(He.toHandle.nodeId):null,pointer:Q};R(Ue),ye=Ue}function Re(Le){if(!("touches"in Le&&Le.touches.length>0)){if(z){(P||J)&&B&&K&&(A==null||A(B));const{inProgress:je,...He}=ye,Qe={...He,toPosition:ye.toHandle?ye.toPosition:null};T==null||T(Le,Qe),s&&(N==null||N(Le,Qe))}v(),cancelAnimationFrame(Y),W=!1,K=!1,B=null,J=null,V.removeEventListener("mousemove",le),V.removeEventListener("mouseup",Re),V.removeEventListener("touchmove",le),V.removeEventListener("touchend",Re)}}V.addEventListener("mousemove",le),V.addEventListener("mouseup",Re),V.addEventListener("touchmove",le),V.addEventListener("touchend",Re)}function hN(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:s,doc:l,lib:c,flowId:f,isValidConnection:p=fN,nodeLookup:m}){const g=s==="target",x=t?l.querySelector(`.${c}-flow__handle[data-id="${f}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:v,y:S}=bl(e),A=l.elementFromPoint(v,S),T=A!=null&&A.classList.contains(`${c}-flow__handle`)?A:x,C={handleDomNode:T,isValid:!1,connection:null,toHandle:null};if(T){const N=dN(void 0,T),R=T.getAttribute("data-nodeid"),O=T.getAttribute("data-handleid"),H=T.classList.contains("connectable"),D=T.classList.contains("connectableend");if(!R||!N)return C;const F={source:g?R:i,sourceHandle:g?O:r,target:g?i:R,targetHandle:g?r:O};C.connection=F;const V=H&&D&&(n===mh.Strict?g&&N==="source"||!g&&N==="target":R!==i||O!==r);C.isValid=V&&p(F),C.toHandle=uN(R,N,O,m,n,!0)}return C}const F1={onPointerDown:QX,isValid:hN};function ZX({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=ns(e);function s({translateExtent:c,width:f,height:p,zoomStep:m=1,pannable:g=!0,zoomable:x=!0,inversePan:v=!1}){const S=R=>{if(R.sourceEvent.type!=="wheel"||!t)return;const O=n(),H=R.sourceEvent.ctrlKey&&Xm()?10:1,D=-R.sourceEvent.deltaY*(R.sourceEvent.deltaMode===1?.05:R.sourceEvent.deltaMode?1:.002)*m,F=O[2]*Math.pow(2,D*H);t.scaleTo(F)};let A=[0,0];const T=R=>{(R.sourceEvent.type==="mousedown"||R.sourceEvent.type==="touchstart")&&(A=[R.sourceEvent.clientX??R.sourceEvent.touches[0].clientX,R.sourceEvent.clientY??R.sourceEvent.touches[0].clientY])},C=R=>{const O=n();if(R.sourceEvent.type!=="mousemove"&&R.sourceEvent.type!=="touchmove"||!t)return;const H=[R.sourceEvent.clientX??R.sourceEvent.touches[0].clientX,R.sourceEvent.clientY??R.sourceEvent.touches[0].clientY],D=[H[0]-A[0],H[1]-A[1]];A=H;const F=i()*Math.max(O[2],Math.log(O[2]))*(v?-1:1),Z={x:O[0]-D[0]*F,y:O[1]-D[1]*F},V=[[0,0],[f,p]];t.setViewportConstrained({x:Z.x,y:Z.y,zoom:O[2]},V,c)},N=Pk().on("start",T).on("zoom",g?C:null).on("zoom.wheel",x?S:null);r.call(N,{})}function l(){r.on("zoom",null)}return{update:s,destroy:l,pointer:pl}}const bx=e=>({x:e.x,y:e.y,zoom:e.k}),Mv=({x:e,y:t,zoom:n})=>gx.translate(e,t).scale(n),Jf=(e,t)=>e.target.closest(`.${t}`),pN=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),JX=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Rv=(e,t=0,n=JX,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},mN=e=>{const t=e.ctrlKey&&Xm()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function eK({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:s,zoomOnPinch:l,onPanZoomStart:c,onPanZoom:f,onPanZoomEnd:p}){return m=>{if(Jf(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const g=n.property("__zoom").k||1;if(m.ctrlKey&&l){const T=pl(m),C=mN(m),N=g*Math.pow(2,C);i.scaleTo(n,N,T,m);return}const x=m.deltaMode===1?20:1;let v=r===bd.Vertical?0:m.deltaX*x,S=r===bd.Horizontal?0:m.deltaY*x;!Xm()&&m.shiftKey&&r!==bd.Vertical&&(v=m.deltaY*x,S=0),i.translateBy(n,-(v/g)*s,-(S/g)*s,{internal:!0});const A=bx(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(f==null||f(m,A),e.panScrollTimeout=setTimeout(()=>{p==null||p(m,A),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,A))}}function tK({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const s=i.type==="wheel",l=!t&&s&&!i.ctrlKey,c=Jf(i,e);if(i.ctrlKey&&s&&c&&i.preventDefault(),l||c)return null;i.preventDefault(),n.call(this,i,r)}}function nK({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var s,l,c;if((s=i.sourceEvent)!=null&&s.internal)return;const r=bx(i.transform);e.mouseButton=((l=i.sourceEvent)==null?void 0:l.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((c=i.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function iK({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return s=>{var l,c;e.usedRightMouseButton=!!(n&&pN(t,e.mouseButton??0)),(l=s.sourceEvent)!=null&&l.sync||i([s.transform.x,s.transform.y,s.transform.k]),r&&!((c=s.sourceEvent)!=null&&c.internal)&&(r==null||r(s.sourceEvent,bx(s.transform)))}}function rK({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:s}){return l=>{var c;if(!((c=l.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,s&&pN(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&s(l.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const f=bx(l.transform);e.prevViewport=f,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,f)},n?150:0)}}}function aK({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:r,zoomOnDoubleClick:s,userSelectionActive:l,noWheelClassName:c,noPanClassName:f,lib:p,connectionInProgress:m}){return g=>{var T;const x=e||t,v=n&&g.ctrlKey,S=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(Jf(g,`${p}-flow__node`)||Jf(g,`${p}-flow__edge`)))return!0;if(!i&&!x&&!r&&!s&&!n||l||m&&!S||Jf(g,c)&&S||Jf(g,f)&&(!S||r&&S&&!e)||!n&&g.ctrlKey&&S)return!1;if(!n&&g.type==="touchstart"&&((T=g.touches)==null?void 0:T.length)>1)return g.preventDefault(),!1;if(!x&&!r&&!v&&S||!i&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(i)&&!i.includes(g.button)&&g.type==="mousedown")return!1;const A=Array.isArray(i)&&i.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||S)&&A}}function sK({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:s,onPanZoomStart:l,onPanZoomEnd:c,onDraggingChange:f}){const p={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),g=Pk().scaleExtent([t,n]).translateExtent(i),x=ns(e).call(g);N({x:r.x,y:r.y,zoom:gh(r.zoom,t,n)},[[0,0],[m.width,m.height]],i);const v=x.on("wheel.zoom"),S=x.on("dblclick.zoom");g.wheelDelta(mN);function A(P,q){return x?new Promise(ne=>{g==null||g.interpolate((q==null?void 0:q.interpolate)==="linear"?Mm:v0).transform(Rv(x,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>ne(!0)),P)}):Promise.resolve(!1)}function T({noWheelClassName:P,noPanClassName:q,onPaneContextMenu:ne,userSelectionActive:I,panOnScroll:$,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:W,zoomOnPinch:B,zoomOnScroll:K,zoomOnDoubleClick:J,zoomActivationKeyPressed:X,lib:ce,onTransformChange:ie,connectionInProgress:de,paneClickDistance:ye,selectionOnDrag:me}){I&&!p.isZoomingOrPanning&&C();const le=$&&!X&&!I;g.clickDistance(me?1/0:!xl(ye)||ye<0?0:ye);const Re=le?eK({zoomPanValues:p,noWheelClassName:P,d3Selection:x,d3Zoom:g,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:B,onPanZoomStart:l,onPanZoom:s,onPanZoomEnd:c}):tK({noWheelClassName:P,preventScrolling:W,d3ZoomHandler:v});if(x.on("wheel.zoom",Re,{passive:!1}),!I){const je=nK({zoomPanValues:p,onDraggingChange:f,onPanZoomStart:l});g.on("start",je);const He=iK({zoomPanValues:p,panOnDrag:z,onPaneContextMenu:!!ne,onPanZoom:s,onTransformChange:ie});g.on("zoom",He);const Qe=rK({zoomPanValues:p,panOnDrag:z,panOnScroll:$,onPaneContextMenu:ne,onPanZoomEnd:c,onDraggingChange:f});g.on("end",Qe)}const Le=aK({zoomActivationKeyPressed:X,panOnDrag:z,zoomOnScroll:K,panOnScroll:$,zoomOnDoubleClick:J,zoomOnPinch:B,userSelectionActive:I,noPanClassName:q,noWheelClassName:P,lib:ce,connectionInProgress:de});g.filter(Le),J?x.on("dblclick.zoom",S):x.on("dblclick.zoom",null)}function C(){g.on("zoom",null)}async function N(P,q,ne){const I=Mv(P),$=g==null?void 0:g.constrain()(I,q,ne);return $&&await A($),new Promise(z=>z($))}async function R(P,q){const ne=Mv(P);return await A(ne,q),new Promise(I=>I(ne))}function O(P){if(x){const q=Mv(P),ne=x.property("__zoom");(ne.k!==P.zoom||ne.x!==P.x||ne.y!==P.y)&&(g==null||g.transform(x,q,null,{sync:!0}))}}function H(){const P=x?Hk(x.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}function D(P,q){return x?new Promise(ne=>{g==null||g.interpolate((q==null?void 0:q.interpolate)==="linear"?Mm:v0).scaleTo(Rv(x,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>ne(!0)),P)}):Promise.resolve(!1)}function F(P,q){return x?new Promise(ne=>{g==null||g.interpolate((q==null?void 0:q.interpolate)==="linear"?Mm:v0).scaleBy(Rv(x,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>ne(!0)),P)}):Promise.resolve(!1)}function Z(P){g==null||g.scaleExtent(P)}function V(P){g==null||g.translateExtent(P)}function Y(P){const q=!xl(P)||P<0?0:P;g==null||g.clickDistance(q)}return{update:T,destroy:C,setViewport:R,setViewportConstrained:N,getViewport:H,scaleTo:D,scaleBy:F,setScaleExtent:Z,setTranslateExtent:V,syncViewport:O,setClickDistance:Y}}var bh;(function(e){e.Line="line",e.Handle="handle"})(bh||(bh={}));function lK({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:s}){const l=e-t,c=n-i,f=[l>0?1:l<0?-1:0,c>0?1:c<0?-1:0];return l&&r&&(f[0]=f[0]*-1),c&&s&&(f[1]=f[1]*-1),f}function GT(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function tu(e,t){return Math.max(0,t-e)}function nu(e,t){return Math.max(0,e-t)}function u0(e,t,n){return Math.max(0,t-e,e-n)}function qT(e,t){return e?!t:t}function oK(e,t,n,i,r,s,l,c){let{affectsX:f,affectsY:p}=t;const{isHorizontal:m,isVertical:g}=t,x=m&&g,{xSnapped:v,ySnapped:S}=n,{minWidth:A,maxWidth:T,minHeight:C,maxHeight:N}=i,{x:R,y:O,width:H,height:D,aspectRatio:F}=e;let Z=Math.floor(m?v-e.pointerX:0),V=Math.floor(g?S-e.pointerY:0);const Y=H+(f?-Z:Z),P=D+(p?-V:V),q=-s[0]*H,ne=-s[1]*D;let I=u0(Y,A,T),$=u0(P,C,N);if(l){let Q=0,W=0;f&&Z<0?Q=tu(R+Z+q,l[0][0]):!f&&Z>0&&(Q=nu(R+Y+q,l[1][0])),p&&V<0?W=tu(O+V+ne,l[0][1]):!p&&V>0&&(W=nu(O+P+ne,l[1][1])),I=Math.max(I,Q),$=Math.max($,W)}if(c){let Q=0,W=0;f&&Z>0?Q=nu(R+Z,c[0][0]):!f&&Z<0&&(Q=tu(R+Y,c[1][0])),p&&V>0?W=nu(O+V,c[0][1]):!p&&V<0&&(W=tu(O+P,c[1][1])),I=Math.max(I,Q),$=Math.max($,W)}if(r){if(m){const Q=u0(Y/F,C,N)*F;if(I=Math.max(I,Q),l){let W=0;!f&&!p||f&&!p&&x?W=nu(O+ne+Y/F,l[1][1])*F:W=tu(O+ne+(f?Z:-Z)/F,l[0][1])*F,I=Math.max(I,W)}if(c){let W=0;!f&&!p||f&&!p&&x?W=tu(O+Y/F,c[1][1])*F:W=nu(O+(f?Z:-Z)/F,c[0][1])*F,I=Math.max(I,W)}}if(g){const Q=u0(P*F,A,T)/F;if($=Math.max($,Q),l){let W=0;!f&&!p||p&&!f&&x?W=nu(R+P*F+q,l[1][0])/F:W=tu(R+(p?V:-V)*F+q,l[0][0])/F,$=Math.max($,W)}if(c){let W=0;!f&&!p||p&&!f&&x?W=tu(R+P*F,c[1][0])/F:W=nu(R+(p?V:-V)*F,c[0][0])/F,$=Math.max($,W)}}}V=V+(V<0?$:-$),Z=Z+(Z<0?I:-I),r&&(x?Y>P*F?V=(qT(f,p)?-Z:Z)/F:Z=(qT(f,p)?-V:V)*F:m?(V=Z/F,p=f):(Z=V*F,f=p));const z=f?R+Z:R,G=p?O+V:O;return{width:H+(f?-Z:Z),height:D+(p?-V:V),x:s[0]*Z*(f?-1:1)+z,y:s[1]*V*(p?-1:1)+G}}const gN={width:0,height:0,x:0,y:0},cK={...gN,pointerX:0,pointerY:0,aspectRatio:1};function uK(e){return[[0,0],[e.measured.width,e.measured.height]]}function dK(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,s=e.measured.width??0,l=e.measured.height??0,c=n[0]*s,f=n[1]*l;return[[i-c,r-f],[i+s-c,r+l-f]]}function fK({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const s=ns(e);let l={controlDirection:GT("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:p,boundaries:m,keepAspectRatio:g,resizeDirection:x,onResizeStart:v,onResize:S,onResizeEnd:A,shouldResize:T}){let C={...gN},N={...cK};l={boundaries:m,resizeDirection:x,keepAspectRatio:g,controlDirection:GT(p)};let R,O=null,H=[],D,F,Z,V=!1;const Y=Ck().on("start",P=>{const{nodeLookup:q,transform:ne,snapGrid:I,snapToGrid:$,nodeOrigin:z,paneDomNode:G}=n();if(R=q.get(t),!R)return;O=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:W}=Rm(P.sourceEvent,{transform:ne,snapGrid:I,snapToGrid:$,containerBounds:O});C={width:R.measured.width??0,height:R.measured.height??0,x:R.position.x??0,y:R.position.y??0},N={...C,pointerX:Q,pointerY:W,aspectRatio:C.width/C.height},D=void 0,R.parentId&&(R.extent==="parent"||R.expandParent)&&(D=q.get(R.parentId),F=D&&R.extent==="parent"?uK(D):void 0),H=[],Z=void 0;for(const[B,K]of q)if(K.parentId===t&&(H.push({id:B,position:{...K.position},extent:K.extent}),K.extent==="parent"||K.expandParent)){const J=dK(K,R,K.origin??z);Z?Z=[[Math.min(J[0][0],Z[0][0]),Math.min(J[0][1],Z[0][1])],[Math.max(J[1][0],Z[1][0]),Math.max(J[1][1],Z[1][1])]]:Z=J}v==null||v(P,{...C})}).on("drag",P=>{const{transform:q,snapGrid:ne,snapToGrid:I,nodeOrigin:$}=n(),z=Rm(P.sourceEvent,{transform:q,snapGrid:ne,snapToGrid:I,containerBounds:O}),G=[];if(!R)return;const{x:Q,y:W,width:B,height:K}=C,J={},X=R.origin??$,{width:ce,height:ie,x:de,y:ye}=oK(N,l.controlDirection,z,l.boundaries,l.keepAspectRatio,X,F,Z),me=ce!==B,le=ie!==K,Re=de!==Q&&me,Le=ye!==W&≤if(!Re&&!Le&&!me&&!le)return;if((Re||Le||X[0]===1||X[1]===1)&&(J.x=Re?de:C.x,J.y=Le?ye:C.y,C.x=J.x,C.y=J.y,H.length>0)){const ot=de-Q,Ue=ye-W;for(const wt of H)wt.position={x:wt.position.x-ot+X[0]*(ce-B),y:wt.position.y-Ue+X[1]*(ie-K)},G.push(wt)}if((me||le)&&(J.width=me&&(!l.resizeDirection||l.resizeDirection==="horizontal")?ce:C.width,J.height=le&&(!l.resizeDirection||l.resizeDirection==="vertical")?ie:C.height,C.width=J.width,C.height=J.height),D&&R.expandParent){const ot=X[0]*(J.width??0);J.x&&J.x<ot&&(C.x=ot,N.x=N.x-(J.x-ot));const Ue=X[1]*(J.height??0);J.y&&J.y<Ue&&(C.y=Ue,N.y=N.y-(J.y-Ue))}const je=lK({width:C.width,prevWidth:B,height:C.height,prevHeight:K,affectsX:l.controlDirection.affectsX,affectsY:l.controlDirection.affectsY}),He={...C,direction:je};(T==null?void 0:T(P,He))!==!1&&(V=!0,S==null||S(P,He),i(J,G))}).on("end",P=>{V&&(A==null||A(P,{...C}),r==null||r({...C}),V=!1)});s.call(Y)}function f(){s.on(".drag",null)}return{update:c,destroy:f}}var kv={exports:{}},Nv={},Ov={exports:{}},Dv={};/**
|
|
378
|
+
`,1;if(hc>1e5&&hc>Ve.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ln+=yt,yt.length}const di=an(Ne);if(!di)throw Wt(rn.replace("{}",Ne)),new Error('Unknown language: "'+Ne+'"');const pu=Qt(di);let Ia="",rt=Xt||pu;const So={},Hn=new Ge.__emitter(Ge);cs();let ln="",ds=0,fs=0,hc=0,Fs=!1;try{if(di.__emitTokens)di.__emitTokens(Ke,Hn);else{for(rt.matcher.considerAll();;){hc++,Fs?Fs=!1:rt.matcher.considerAll(),rt.matcher.lastIndex=fs;const Be=rt.matcher.exec(Ke);if(!Be)break;const Ve=Ke.substring(fs,Be.index),yt=Ps(Ve,Be);fs=Be.index+yt}Ps(Ke.substring(fs))}return Hn.finalize(),Ia=Hn.toHTML(),{language:Ne,value:Ia,relevance:ds,illegal:!1,_emitter:Hn,_top:rt}}catch(Be){if(Be.message&&Be.message.includes("Illegal"))return{language:Ne,value:Jn(Ke),illegal:!0,relevance:0,_illegalBy:{message:Be.message,index:fs,context:Ke.slice(fs-100,fs+100),mode:Be.mode,resultSoFar:Ia},_emitter:Hn};if(nn)return{language:Ne,value:Jn(Ke),illegal:!1,relevance:0,errorRaised:Be,_emitter:Hn,_top:rt};throw Be}}function lr(Ne){const Ke={value:Jn(Ne),illegal:!1,relevance:0,_top:Ye,_emitter:new Ge.__emitter(Ge)};return Ke._emitter.addText(Ne),Ke}function Vi(Ne,Ke){Ke=Ke||Ge.languages||Object.keys(Te);const vt=lr(Ne),Xt=Ke.filter(an).filter(cr).map(pn=>ga(pn,Ne,!1));Xt.unshift(vt);const In=Xt.sort((pn,ur)=>{if(pn.relevance!==ur.relevance)return ur.relevance-pn.relevance;if(pn.language&&ur.language){if(an(pn.language).supersetOf===ur.language)return 1;if(an(ur.language).supersetOf===pn.language)return-1}return 0}),[_i,Xi]=In,Ai=_i;return Ai.secondBest=Xi,Ai}function or(Ne,Ke,vt){const Xt=Ke&&Ie[Ke]||vt;Ne.classList.add("hljs"),Ne.classList.add(`language-${Xt}`)}function bt(Ne){let Ke=null;const vt=Rn(Ne);if(nt(vt))return;if(ya("before:highlightElement",{el:Ne,language:vt}),Ne.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ne);return}if(Ne.children.length>0&&(Ge.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Ne)),Ge.throwUnescapedHTML))throw new Yi("One of your code blocks includes unescaped HTML.",Ne.innerHTML);Ke=Ne;const Xt=Ke.textContent,In=vt?Ft(Xt,{language:vt,ignoreIllegals:!0}):Vi(Xt);Ne.innerHTML=In.value,Ne.dataset.highlighted="yes",or(Ne,vt,In.language),Ne.result={language:In.language,re:In.relevance,relevance:In.relevance},In.secondBest&&(Ne.secondBest={language:In.secondBest.language,relevance:In.secondBest.relevance}),ya("after:highlightElement",{el:Ne,result:In,text:Xt})}function ui(Ne){Ge=vo(Ge,Ne)}const Hr=()=>{Al(),Ee("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Us(){Al(),Ee("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Cl=!1;function Al(){function Ne(){Al()}if(document.readyState==="loading"){Cl||window.addEventListener("DOMContentLoaded",Ne,!1),Cl=!0;return}document.querySelectorAll(Ge.cssSelector).forEach(bt)}function Ml(Ne,Ke){let vt=null;try{vt=Ke(se)}catch(Xt){if(Wt("Language definition for '{}' could not be registered.".replace("{}",Ne)),nn)Wt(Xt);else throw Xt;vt=Ye}vt.name||(vt.name=Ne),Te[Ne]=vt,vt.rawDefinition=Ke.bind(null,se),vt.aliases&&sn(vt.aliases,{languageName:Ne})}function La(Ne){delete Te[Ne];for(const Ke of Object.keys(Ie))Ie[Ke]===Ne&&delete Ie[Ke]}function Hs(){return Object.keys(Te)}function an(Ne){return Ne=(Ne||"").toLowerCase(),Te[Ne]||Te[Ie[Ne]]}function sn(Ne,{languageName:Ke}){typeof Ne=="string"&&(Ne=[Ne]),Ne.forEach(vt=>{Ie[vt.toLowerCase()]=Ke})}function cr(Ne){const Ke=an(Ne);return Ke&&!Ke.disableAutodetect}function Pr(Ne){Ne["before:highlightBlock"]&&!Ne["before:highlightElement"]&&(Ne["before:highlightElement"]=Ke=>{Ne["before:highlightBlock"](Object.assign({block:Ke.el},Ke))}),Ne["after:highlightBlock"]&&!Ne["after:highlightElement"]&&(Ne["after:highlightElement"]=Ke=>{Ne["after:highlightBlock"](Object.assign({block:Ke.el},Ke))})}function jn(Ne){Pr(Ne),tt.push(Ne)}function Sr(Ne){const Ke=tt.indexOf(Ne);Ke!==-1&&tt.splice(Ke,1)}function ya(Ne,Ke){const vt=Ne;tt.forEach(function(Xt){Xt[vt]&&Xt[vt](Ke)})}function Fr(Ne){return Ee("10.7.0","highlightBlock will be removed entirely in v12.0"),Ee("10.7.0","Please use highlightElement now."),bt(Ne)}Object.assign(se,{highlight:Ft,highlightAuto:Vi,highlightAll:Al,highlightElement:bt,highlightBlock:Fr,configure:ui,initHighlighting:Hr,initHighlightingOnLoad:Us,registerLanguage:Ml,unregisterLanguage:La,listLanguages:Hs,getLanguage:an,registerAliases:sn,autoDetection:cr,inherit:vo,addPlugin:jn,removePlugin:Sr}),se.debugMode=function(){nn=!1},se.safeMode=function(){nn=!0},se.versionString=Pt,se.regex={concat:A,lookahead:x,either:C,optional:S,anyNumberOfTimes:v};for(const Ne in Re)typeof Re[Ne]=="object"&&e(Re[Ne]);return Object.assign(se,Re),se},vi=os({});return vi.newInstance=()=>os({}),xv=vi,vi.HighlightJS=vi,vi.default=vi,xv}var qF=GF();const YF=du(qF),cT={},VF="hljs-";function XF(e){const t=YF.newInstance();return e&&s(e),{highlight:n,highlightAuto:i,listLanguages:r,register:s,registerAlias:l,registered:c};function n(f,p,m){const g=m||cT,x=typeof g.prefix=="string"?g.prefix:VF;if(!t.getLanguage(f))throw new Error("Unknown language: `"+f+"` is not registered");t.configure({__emitter:KF,classPrefix:x});const v=t.highlight(p,{ignoreIllegals:!0,language:f});if(v.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:v.errorRaised});const S=v._emitter.root,A=S.data;return A.language=v.language,A.relevance=v.relevance,S}function i(f,p){const g=(p||cT).subset||r();let x=-1,v=0,S;for(;++x<g.length;){const A=g[x];if(!t.getLanguage(A))continue;const T=n(A,f,p);T.data&&T.data.relevance!==void 0&&T.data.relevance>v&&(v=T.data.relevance,S=T)}return S||{type:"root",children:[],data:{language:void 0,relevance:v}}}function r(){return t.listLanguages()}function s(f,p){if(typeof f=="string")t.registerLanguage(f,p);else{let m;for(m in f)Object.hasOwn(f,m)&&t.registerLanguage(m,f[m])}}function l(f,p){if(typeof f=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:f});else{let m;for(m in f)if(Object.hasOwn(f,m)){const g=f[m];t.registerAliases(typeof g=="string"?g:[...g],{languageName:m})}}}function c(f){return!!t.getLanguage(f)}}class KF{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],i=n.children[n.children.length-1];i&&i.type==="text"?i.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const i=this.stack[this.stack.length-1],r=t.root.children;n?i.children.push({type:"element",tagName:"span",properties:{className:[n]},children:r}):i.children.push(...r)}openNode(t){const n=this,i=t.split(".").map(function(l,c){return c?l+"_".repeat(c):n.options.classPrefix+l}),r=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:i},children:[]};r.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const $F={};function WF(e){const t=e||$F,n=t.aliases,i=t.detect||!1,r=t.languages||FF,s=t.plainText,l=t.prefix,c=t.subset;let f="hljs";const p=XF(r);if(n&&p.registerAlias(n),l){const m=l.indexOf("-");f=m===-1?l:l.slice(0,m)}return function(m,g){dx(m,"element",function(x,v,S){if(x.tagName!=="code"||!S||S.type!=="element"||S.tagName!=="pre")return;const A=QF(x);if(A===!1||!A&&!i||A&&s&&s.includes(A))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(f)||x.properties.className.unshift(f);const T=mP(x,{whitespace:"pre"});let C;try{C=A?p.highlight(A,T,{prefix:l}):p.highlightAuto(T,{prefix:l,subset:c})}catch(N){const R=N;if(A&&/Unknown language/.test(R.message)){g.message("Cannot highlight as `"+A+"`, it’s not registered",{ancestors:[S,x],cause:R,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw R}!A&&C.data&&C.data.language&&x.properties.className.push("language-"+C.data.language),C.children.length>0&&(x.children=C.children)})}}function QF(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let i;for(;++n<t.length;){const r=String(t[n]);if(r==="no-highlight"||r==="nohighlight")return!1;!i&&r.slice(0,5)==="lang-"&&(i=r.slice(5)),!i&&r.slice(0,9)==="language-"&&(i=r.slice(9))}return i}function ZF({text:e}){const[t,n]=j.useState(!1),i=()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})};return _.jsx("button",{onClick:i,style:{position:"absolute",top:6,right:6,background:"var(--surface-4)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-xs)",color:t?"var(--status-active)":"var(--text-muted)",fontSize:"0.65rem",fontFamily:"var(--font-mono)",padding:"2px 8px",cursor:"pointer",transition:"color var(--duration-fast) var(--ease-out)"},children:t?"Copied!":"Copy"})}function M1({content:e}){return _.jsx("div",{className:"markdown-message",children:_.jsx($H,{remarkPlugins:[oP],rehypePlugins:[WF],components:{pre({children:t,...n}){const i=Array.isArray(t)?t.find(s=>{var l,c;return(s==null?void 0:s.type)==="code"||((c=(l=s==null?void 0:s.props)==null?void 0:l.node)==null?void 0:c.tagName)==="code"}):t,r=typeof i=="object"&&i!==null&&"props"in i?R1(i.props.children):"";return _.jsxs("div",{style:{position:"relative"},children:[_.jsx(ZF,{text:r}),_.jsx("pre",{...n,style:{background:"var(--surface-0)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",padding:"12px 14px",paddingTop:28,margin:"8px 0",overflowX:"auto",fontSize:"0.78rem",lineHeight:1.6,fontFamily:"var(--font-mono)"},children:t})]})},code({className:t,children:n,...i}){return t?_.jsx("code",{className:t,...i,children:n}):_.jsx("code",{...i,style:{background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",padding:"1px 5px",fontSize:"0.82em",fontFamily:"var(--font-mono)",color:"var(--accent)"},children:n})},a({href:t,children:n,...i}){return _.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"none"},...i,children:n})},table({children:t,...n}){return _.jsx("div",{style:{overflowX:"auto",margin:"8px 0"},children:_.jsx("table",{...n,style:{borderCollapse:"collapse",width:"100%",fontSize:"0.82rem"},children:t})})},th({children:t,...n}){return _.jsx("th",{...n,style:{borderBottom:"2px solid var(--border-default)",padding:"6px 10px",textAlign:"left",fontWeight:600,color:"var(--text-primary)"},children:t})},td({children:t,...n}){return _.jsx("td",{...n,style:{borderBottom:"1px solid var(--border-subtle)",padding:"5px 10px",color:"var(--text-secondary)"},children:t})},blockquote({children:t,...n}){return _.jsx("blockquote",{...n,style:{borderLeft:"3px solid var(--accent-dim)",margin:"8px 0",padding:"4px 12px",color:"var(--text-secondary)",background:"rgba(0, 200, 255, 0.04)",borderRadius:"0 var(--radius-xs) var(--radius-xs) 0"},children:t})},hr(){return _.jsx("hr",{style:{border:"none",borderTop:"1px solid var(--border-default)",margin:"12px 0"}})},ul({children:t,...n}){return _.jsx("ul",{...n,style:{paddingLeft:20,margin:"4px 0"},children:t})},ol({children:t,...n}){return _.jsx("ol",{...n,style:{paddingLeft:20,margin:"4px 0"},children:t})},li({children:t,...n}){return _.jsx("li",{...n,style:{marginBottom:2},children:t})},h1({children:t,...n}){return _.jsx("h1",{...n,style:{fontSize:"1.3em",fontWeight:700,margin:"12px 0 6px"},children:t})},h2({children:t,...n}){return _.jsx("h2",{...n,style:{fontSize:"1.15em",fontWeight:600,margin:"10px 0 4px"},children:t})},h3({children:t,...n}){return _.jsx("h3",{...n,style:{fontSize:"1.05em",fontWeight:600,margin:"8px 0 4px"},children:t})},p({children:t,...n}){return _.jsx("p",{...n,style:{margin:"4px 0",lineHeight:1.6},children:t})}},children:e})})}function R1(e){var t;return typeof e=="string"?e:Array.isArray(e)?e.map(R1).join(""):(t=e==null?void 0:e.props)!=null&&t.children?R1(e.props.children):""}function JF({commands:e,filter:t,selectedIndex:n,onSelect:i,visible:r}){const s=j.useRef(null),l=j.useRef(null),c=e.filter(f=>f.command.toLowerCase().includes(t.toLowerCase())||f.description.toLowerCase().includes(t.toLowerCase()));return j.useEffect(()=>{var f;(f=l.current)==null||f.scrollIntoView({block:"nearest"})},[n]),!r||c.length===0?null:_.jsxs("div",{ref:s,style:{position:"absolute",bottom:"100%",left:0,right:0,marginBottom:4,background:"var(--surface-2)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-lg)",maxHeight:280,overflowY:"auto",zIndex:100,animation:"fadeInUp 0.15s var(--ease-out) both"},children:[_.jsx("div",{style:{padding:"8px 12px 4px",fontSize:"0.65rem",fontFamily:"var(--font-mono)",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Commands"}),c.map((f,p)=>{const m=p===n;return _.jsxs("div",{ref:m?l:void 0,onClick:()=>i(f),style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",cursor:"pointer",background:m?"var(--accent-glow)":"transparent",borderLeft:m?"2px solid var(--accent)":"2px solid transparent",transition:"background var(--duration-fast) var(--ease-out)"},onMouseEnter:g=>{m||(g.currentTarget.style.background="var(--surface-3)")},onMouseLeave:g=>{m||(g.currentTarget.style.background="transparent")},children:[_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.8rem",fontWeight:600,color:m?"var(--accent)":"var(--text-primary)",whiteSpace:"nowrap"},children:["/",f.command,f.args&&_.jsxs("span",{style:{color:"var(--text-muted)",fontWeight:400},children:[" ",f.args]})]}),_.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.description})]},f.command)})]})}const uT=[{command:"expxagents",description:"Show main menu"},{command:"expxagents create",args:"[description]",description:"Design a new squad"},{command:"expxagents run",args:"<name>",description:"Execute a squad pipeline"},{command:"expxagents list",description:"List all squads"},{command:"expxagents edit",args:"<name>",description:"Modify a squad"},{command:"expxagents delete",args:"<name>",description:"Delete a squad"},{command:"expxagents skills",description:"Browse skills"},{command:"expxagents install",args:"<name>",description:"Install a skill"},{command:"expxagents uninstall",args:"<name>",description:"Remove a skill"},{command:"expxagents dashboard",description:"Open virtual office"},{command:"expxagents virtual-office",description:"Open virtual office in browser"},{command:"expxagents jarvis",description:"Open Jarvis voice assistant"},{command:"expxagents help",description:"Show help text"}];function eG({c:e}){return _.jsxs("div",{style:{padding:"12px",background:"#1e1e2e",borderRadius:"8px",minWidth:"120px"},children:[_.jsxs("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#cdd6f4"},children:[e.value,e.unit?` ${e.unit}`:""]}),_.jsx("div",{style:{fontSize:"12px",color:"#a6adc8",marginTop:"4px"},children:e.label})]})}function tG({c:e}){const t=Math.round(e.value*100);return _.jsxs("div",{style:{width:"100%"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[_.jsx("span",{style:{fontSize:"12px",color:"#a6adc8"},children:e.label}),_.jsxs("span",{style:{fontSize:"12px",color:"#cdd6f4"},children:[t,"%"]})]}),_.jsx("div",{style:{height:"6px",background:"#313244",borderRadius:"3px"},children:_.jsx("div",{style:{height:"100%",width:`${t}%`,background:"#89b4fa",borderRadius:"3px",transition:"width 0.3s"}})})]})}function nG({c:e}){return _.jsxs("div",{children:[e.title&&_.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#cdd6f4",marginBottom:"8px"},children:e.title}),_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[_.jsx("thead",{children:_.jsx("tr",{children:e.columns.map((t,n)=>_.jsx("th",{style:{textAlign:"left",padding:"4px 8px",color:"#a6adc8",borderBottom:"1px solid #313244"},children:t},n))})}),_.jsx("tbody",{children:e.rows.map((t,n)=>_.jsx("tr",{children:t.map((i,r)=>_.jsx("td",{style:{padding:"4px 8px",color:"#cdd6f4",borderBottom:"1px solid #1e1e2e"},children:i},r))},n))})]})]})}function iG({c:e}){return _.jsxs("div",{style:{padding:"12px",background:"#1e1e2e",borderRadius:"8px"},children:[_.jsx("div",{style:{fontWeight:600,color:"#cdd6f4",marginBottom:"6px"},children:e.title}),_.jsx("div",{style:{fontSize:"13px",color:"#a6adc8"},children:e.body})]})}const rG={green:"#a6e3a1",yellow:"#f9e2af",red:"#f38ba8",blue:"#89b4fa"};function aG({c:e}){return _.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:"12px",fontSize:"11px",fontWeight:600,color:"#1e1e2e",background:rG[e.color]??"#a6adc8"},children:e.label})}function sG({components:e}){return e.length===0?null:_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"12px"},children:e.map((t,n)=>{switch(t.type){case"metric":return _.jsx(eG,{c:t},n);case"progress":return _.jsx(tG,{c:t},n);case"table":return _.jsx(nG,{c:t},n);case"card":return _.jsx(iG,{c:t},n);case"badge":return _.jsx(aG,{c:t},n)}})})}const i0="_expxagents",eu=[.72,.78,.85,.95,1.08,1.2],lG=2;function oG({file:e,onRemove:t}){return _.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,background:"var(--surface-3)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-xs)",padding:"2px 8px",fontSize:"0.72rem",fontFamily:"var(--font-mono)",color:"var(--accent)",maxWidth:180},children:[_.jsx("span",{style:{opacity:.6},children:"📎"}),_.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),_.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",padding:0,fontSize:"0.8rem",lineHeight:1},"aria-label":`Remove ${e.name}`,children:"×"})]})}function cG({message:e,fontSize:t}){if(e.role==="agent_dm")return _.jsxs("div",{"data-role":"agent_dm",style:{alignSelf:"flex-start",background:"var(--surface-3)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",padding:"10px 14px",maxWidth:"85%",marginBottom:"var(--sp-2)",animation:"fadeInUp 0.3s var(--ease-out) both"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--accent)",fontWeight:600,marginBottom:4,letterSpacing:"0.02em"},children:e.agentName}),_.jsx("div",{style:{color:"var(--text-primary)",fontSize:`${t}rem`,lineHeight:1.55},children:_.jsx(M1,{content:e.content})})]});const n=e.role==="user";return _.jsx("div",{"data-role":e.role,style:{alignSelf:n?"flex-end":"flex-start",background:n?"var(--user-bubble)":"var(--agent-bubble)",border:n?"1px solid rgba(100, 160, 255, 0.15)":"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"10px 14px",maxWidth:n?"75%":"85%",marginBottom:"var(--sp-2)",animation:"fadeInUp 0.3s var(--ease-out) both"},children:_.jsx("div",{style:{color:"var(--text-primary)",fontSize:`${t}rem`,lineHeight:1.55},children:n?_.jsx("span",{style:{whiteSpace:"pre-wrap"},children:e.content}):_.jsx(M1,{content:e.content})})})}function uG({conv:e,isActive:t,onSelect:n,onDelete:i}){const[r,s]=j.useState(!1),l=new Date(e.createdAt),c=l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),f=l.toLocaleDateString([],{day:"2-digit",month:"2-digit"});return _.jsxs("div",{onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{padding:"8px 10px",borderRadius:"var(--radius-sm)",cursor:"pointer",background:t?"var(--accent-glow)":r?"var(--surface-3)":"transparent",border:t?"1px solid rgba(0, 200, 255, 0.12)":"1px solid transparent",transition:"all var(--duration-fast) var(--ease-out)",display:"flex",alignItems:"center",gap:8},children:[_.jsxs("div",{style:{flex:1,minWidth:0},children:[_.jsx("div",{style:{fontSize:"0.72rem",fontFamily:"var(--font-mono)",color:t?"var(--accent)":"var(--text-secondary)",fontWeight:t?600:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.preview||"New conversation"}),_.jsxs("div",{style:{fontSize:"0.6rem",fontFamily:"var(--font-mono)",color:"var(--text-muted)",marginTop:2},children:[f," ",c]})]}),r&&_.jsx("button",{onClick:p=>{p.stopPropagation(),i()},title:"Delete conversation","aria-label":"Delete conversation",style:{background:"none",border:"none",color:"var(--status-error)",cursor:"pointer",padding:"2px 4px",fontSize:"0.75rem",lineHeight:1,opacity:.7,flexShrink:0},children:"×"})]})}function dG(){const[e,t]=j.useState(""),[n,i]=j.useState([]),[r,s]=j.useState(lG),[l,c]=j.useState(!1),[f,p]=j.useState(""),[m,g]=j.useState(0),x=j.useRef(null),v=j.useRef(null),S=j.useRef(null),A=j.useRef(null),T=vr(le=>le.selectedSquad),C=vr(le=>le.uiComponents[T??""]),N=rr(le=>le.conversations),R=rr(le=>le.conversationId),O=rr(le=>le.messages),H=rr(le=>le.streaming),D=rr(le=>le.streamingText),F=rr(le=>le.activity),Z=rr(le=>le.error),V=rr(le=>le.addUserMessage),Y=rr(le=>le.startStreaming),P=rr(le=>le.loadHistory),q=rr(le=>le.selectConversation),ne=rr(le=>le.deleteConversation);j.useEffect(()=>{P(i0)},[P]),j.useEffect(()=>{var le,Re;(Re=(le=x.current)==null?void 0:le.scrollIntoView)==null||Re.call(le,{behavior:"smooth"})},[O,D]);const I=j.useCallback(()=>{const le=v.current;le&&(le.style.height="auto",le.style.height=Math.min(le.scrollHeight,200)+"px")},[]);j.useEffect(()=>{I()},[e,I]);const $=j.useCallback(le=>{if(le.startsWith("/")){const Re=le.slice(1);p(Re),c(!0),g(0)}else c(!1)},[]),z=j.useCallback(()=>uT.filter(le=>le.command.toLowerCase().includes(f.toLowerCase())||le.description.toLowerCase().includes(f.toLowerCase())),[f]),G=j.useCallback(le=>{var Re;t("/"+le.command+(le.args?" ":"")),c(!1),(Re=v.current)==null||Re.focus()},[]),Q=j.useCallback(()=>{H||P4(i0)},[H]),W=j.useCallback(le=>{H||ne(le,i0)},[H,ne]),B=j.useCallback(le=>{H||le===R||q(le)},[H,R,q]),K=j.useCallback(()=>{const le=e.trim();!le||H||(V(le),Y(),XC(i0,le,n.length>0?n:void 0),t(""),i([]),c(!1),v.current&&(v.current.style.height="auto"))},[e,H,n,V,Y]),J=j.useCallback(le=>{if(l){const Re=z();if(le.key==="ArrowDown"){le.preventDefault(),g(Le=>Math.min(Le+1,Re.length-1));return}if(le.key==="ArrowUp"){le.preventDefault(),g(Le=>Math.max(Le-1,0));return}if(le.key==="Enter"&&!le.shiftKey){le.preventDefault(),Re[m]&&G(Re[m]);return}if(le.key==="Escape"){le.preventDefault(),c(!1);return}if(le.key==="Tab"){le.preventDefault(),Re[m]&&G(Re[m]);return}}le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),K())},[l,z,m,G,K]),X=j.useCallback(le=>{const Re=le.target.value;t(Re),$(Re)},[$]),ce=j.useCallback(async le=>{var Le;if(!le)return;const Re=[];for(const je of Array.from(le))if(!(je.size>512e3))try{const He=await je.text();Re.push({name:je.name,content:He})}catch{}i(je=>[...je,...Re]),(Le=v.current)==null||Le.focus()},[]),ie=j.useCallback(le=>{le.preventDefault(),le.stopPropagation(),ce(le.dataTransfer.files)},[ce]),de=j.useCallback(le=>{le.preventDefault(),le.stopPropagation()},[]),ye=j.useCallback(le=>{i(Re=>Re.filter((Le,je)=>je!==le))},[]),me=e.trim()&&!H;return _.jsxs("div",{style:{display:"flex",height:"100%"},onDrop:ie,onDragOver:de,children:[_.jsxs("div",{style:{width:220,borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)",display:"flex",flexDirection:"column",flexShrink:0},children:[_.jsx("div",{style:{padding:"var(--sp-2)"},children:_.jsx("button",{onClick:Q,disabled:H,"aria-label":"New conversation",style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 10px",background:"var(--accent-glow)",border:"1px solid rgba(0, 200, 255, 0.15)",borderRadius:"var(--radius-sm)",color:"var(--accent)",cursor:H?"not-allowed":"pointer",fontFamily:"var(--font-mono)",fontSize:"0.72rem",fontWeight:600,letterSpacing:"0.02em",opacity:H?.5:1,transition:"all var(--duration-fast) var(--ease-out)"},children:"+ New Chat"})}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"0 var(--sp-2) var(--sp-2)",display:"flex",flexDirection:"column",gap:2},children:[N.length===0&&_.jsx("div",{style:{padding:"var(--sp-4) var(--sp-2)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)"},children:"No conversations yet"}),N.map(le=>_.jsx(uG,{conv:le,isActive:le.id===R,onSelect:()=>B(le.id),onDelete:()=>W(le.id)},le.id))]})]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",padding:"4px var(--sp-4)",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",gap:2},children:[_.jsx("button",{onClick:()=>s(le=>Math.max(le-1,0)),disabled:r===0,title:"Decrease font size","aria-label":"Decrease font size",style:{background:"none",border:"1px solid var(--border-default)",borderRadius:"var(--radius-xs)",color:r===0?"var(--text-muted)":"var(--text-secondary)",cursor:r===0?"not-allowed":"pointer",padding:"2px 7px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:700,lineHeight:1.4,opacity:r===0?.35:.7},children:"A-"}),_.jsx("button",{onClick:()=>s(le=>Math.min(le+1,eu.length-1)),disabled:r===eu.length-1,title:"Increase font size","aria-label":"Increase font size",style:{background:"none",border:"1px solid var(--border-default)",borderRadius:"var(--radius-xs)",color:r===eu.length-1?"var(--text-muted)":"var(--text-secondary)",cursor:r===eu.length-1?"not-allowed":"pointer",padding:"2px 7px",fontFamily:"var(--font-mono)",fontSize:"0.8rem",fontWeight:700,lineHeight:1.4,opacity:r===eu.length-1?.35:.7},children:"A+"})]}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"var(--sp-4)",display:"flex",flexDirection:"column"},children:[O.length===0&&!H&&_.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,gap:"var(--sp-3)",opacity:.6},children:[_.jsx("div",{style:{width:48,height:48,borderRadius:"var(--radius-md)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.2rem",color:"var(--accent)"},children:"EX"}),_.jsx("span",{style:{color:"var(--text-muted)",fontSize:"0.82rem",fontFamily:"var(--font-display)"},children:"ExpxAgents Terminal"}),_.jsx("span",{style:{color:"var(--text-muted)",fontSize:"0.7rem",fontFamily:"var(--font-mono)"},children:"Type / to see available commands"})]}),O.map(le=>_.jsx(cG,{message:le,fontSize:eu[r]},le.id)),H&&D&&_.jsx("div",{"data-role":"assistant",style:{alignSelf:"flex-start",background:"var(--agent-bubble)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"10px 14px",maxWidth:"85%",marginBottom:"var(--sp-2)"},children:_.jsxs("div",{style:{color:"var(--text-primary)",fontSize:`${eu[r]}rem`,lineHeight:1.55},children:[_.jsx(M1,{content:D}),_.jsx("span",{style:{display:"inline-block",width:6,height:14,background:"var(--accent)",marginLeft:2,animation:"pulse 1s ease-in-out infinite",borderRadius:1,verticalAlign:"text-bottom"}})]})}),H&&!D&&_.jsx("div",{style:{alignSelf:"flex-start",display:"flex",flexDirection:"column",gap:4,padding:"10px 14px",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[_.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:"var(--accent)",animation:"pulse 1s ease-in-out infinite"}}),F||"Thinking..."]})}),Z&&_.jsx("div",{style:{alignSelf:"center",background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.25)",borderRadius:"var(--radius-sm)",padding:"8px 14px",color:"var(--status-error)",fontFamily:"var(--font-mono)",fontSize:"0.78rem",marginBottom:"var(--sp-2)"},children:Z}),_.jsx("div",{ref:x}),C&&C.length>0&&_.jsx("div",{style:{borderTop:"1px solid #313244",marginTop:"8px"},children:_.jsx(sG,{components:C})})]}),_.jsxs("div",{ref:A,style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)",position:"relative"},children:[_.jsx("div",{style:{position:"relative",padding:"0 var(--sp-4)"},children:_.jsx(JF,{commands:uT,filter:f,selectedIndex:m,onSelect:G,visible:l})}),n.length>0&&_.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,padding:"var(--sp-2) var(--sp-4) 0"},children:n.map((le,Re)=>_.jsx(oG,{file:le,onRemove:()=>ye(Re)},`${le.name}-${Re}`))}),_.jsxs("div",{style:{display:"flex",padding:"var(--sp-3) var(--sp-4)",gap:"var(--sp-2)",alignItems:"flex-end"},children:[_.jsx("button",{onClick:()=>{var le;return(le=S.current)==null?void 0:le.click()},disabled:H,title:"Attach files (text only, max 500KB)",style:{background:"none",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",color:"var(--text-muted)",cursor:H?"not-allowed":"pointer",padding:"6px 8px",fontSize:"1rem",lineHeight:1,opacity:H?.4:.7,transition:"opacity var(--duration-fast) var(--ease-out)",flexShrink:0},"aria-label":"Attach file",children:"📎"}),_.jsx("input",{ref:S,type:"file",multiple:!0,style:{display:"none"},onChange:le=>ce(le.target.files)}),_.jsx("textarea",{ref:v,className:"input",value:e,onChange:X,onKeyDown:J,placeholder:"Type a message... (/ for commands)",disabled:H,rows:1,style:{flex:1,resize:"none",overflow:"hidden",minHeight:36,maxHeight:200,lineHeight:1.5,fontFamily:"var(--font-mono)",fontSize:`${eu[r]}rem`}}),_.jsx("button",{onClick:K,disabled:!me,"aria-label":"Send",className:me?"btn btn-accent":"btn",style:{padding:"0 var(--sp-5)",cursor:me?"pointer":"not-allowed",opacity:me?1:.4,flexShrink:0,height:36},children:"Send"})]})]})]})]})}const fG={planned:"var(--status-idle)",executing:"var(--accent)",done:"var(--status-active)",failed:"var(--status-error)"},hG={planned:"planejado",executing:"executando",done:"finalizado",failed:"falhou"};function pG({task:e,selected:t,onClick:n,onDelete:i}){const r=fG[e.status],s=e.status==="executing",l=f=>{f.dataTransfer.setData("text/plain",`task:${e.id}`),f.dataTransfer.effectAllowed="move",f.currentTarget.style.opacity="0.5"},c=f=>{f.currentTarget.style.opacity="1"};return _.jsxs("div",{draggable:!e.activity_id,onDragStart:l,onDragEnd:c,onClick:()=>n==null?void 0:n(e),"data-testid":`task-card-${e.id}`,style:{background:t?"var(--surface-4)":"var(--surface-3)",borderRadius:"var(--radius-sm)",padding:"12px 14px",marginBottom:"var(--sp-2)",border:"1px solid",borderColor:t?"var(--accent)":s?r:"var(--border-subtle)",transition:"border-color var(--duration-fast) var(--ease-out), opacity 0.15s ease",cursor:"pointer"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",fontWeight:600,color:r,padding:"2px 8px",borderRadius:"var(--radius-full)",border:`1px solid ${r}`,letterSpacing:"0.02em"},children:hG[e.status]}),i&&_.jsx("button",{onClick:f=>{f.stopPropagation(),i(e.id)},style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:"0.7rem",padding:"0 2px",lineHeight:1,opacity:.5,transition:"opacity 0.15s, color 0.15s"},onMouseEnter:f=>{f.currentTarget.style.opacity="1",f.currentTarget.style.color="var(--status-error)"},onMouseLeave:f=>{f.currentTarget.style.opacity="0.5",f.currentTarget.style.color="var(--text-muted)"},title:"Delete task",children:"✕"})]}),_.jsx("div",{style:{fontWeight:600,fontSize:"0.82rem",color:"var(--text-primary)",marginBottom:e.description?6:0,lineHeight:1.4},children:e.title}),e.description&&_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-secondary)",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.description}),e.agent_name&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"var(--text-muted)",marginTop:2,display:"flex",alignItems:"center",gap:4},children:[_.jsx("span",{children:"🤖"}),e.agent_name]}),e.step_id&&!e.agent_name&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"var(--accent-dim)",marginTop:2},children:["◆"," checkpoint"]}),e.triggered_by&&e.triggered_by!=="dashboard"&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",marginTop:4,opacity:.7},children:[e.triggered_by==="chat"?"💬":e.triggered_by==="schedule"?"⏰":e.triggered_by==="chain"?"🔗":""," ",e.triggered_by]}),e.activity_id&&_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--accent-dim)",marginTop:4,padding:"1px 6px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-full)",display:"inline-block"},children:e.squad_code}),e.result&&_.jsxs("div",{style:{marginTop:6,fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--status-active)",display:"flex",alignItems:"center",gap:4},children:[_.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--status-active)",display:"inline-block"}}),"has output"]})]})}const ck=[{key:"planned",label:"Planejado",color:"var(--status-idle)",glow:"none"},{key:"executing",label:"Executando",color:"var(--accent)",glow:"var(--accent-glow)"},{key:"done",label:"Finalizado",color:"var(--status-active)",glow:"var(--status-active-glow)"},{key:"failed",label:"Falhou",color:"var(--status-error)",glow:"none"}];function bv(e){if(!e)return"—";const t=new Date(e);return t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function vv(e,t){if(!e||!t)return null;const n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;if(n<1e3)return`${n}ms`;const i=Math.floor(n/1e3);if(i<60)return`${i}s`;const r=Math.floor(i/60),s=i%60;if(r<60)return`${r}m ${s}s`;const l=Math.floor(r/60),c=r%60;return`${l}h ${c}m`}function mG(){const e=vr(I=>I.squads),t=vr(I=>I.activeStates),[n,i]=j.useState(null),[r,s]=j.useState(""),[l,c]=j.useState([]),[f,p]=j.useState(null),[m,g]=j.useState(""),[x,v]=j.useState(""),[S,A]=j.useState(null),[T,C]=j.useState(null),[N,R]=j.useState(!1),O=n;j.useEffect(()=>{if(!O){c([]),C(null);return}const I=O==="__all__"?"/api/kanban/tasks":`/api/kanban/${O}/tasks`;fetch(I,{credentials:"include"}).then($=>$.json()).then($=>c(Array.isArray($)?$:[])).catch(()=>c([]))},[O]),j.useEffect(()=>{const I=$=>{const z=$.detail;if(!(z!=null&&z.activityId)||!O)return;const G=O==="__all__"?"/api/kanban/tasks":`/api/kanban/${O}/tasks`;fetch(G,{credentials:"include"}).then(Q=>Q.json()).then(Q=>{const W=Array.isArray(Q)?Q:[];c(W),C(B=>B?W.find(J=>J.id===B.id)??null:null)}).catch(()=>{})};return window.addEventListener("kanban:task_updated",I),()=>window.removeEventListener("kanban:task_updated",I)},[O]);const H=j.useMemo(()=>ck.map(I=>({...I,tasks:l.filter($=>$.status===I.key).sort(($,z)=>$.position-z.position)})),[l]),D=e.filter(I=>{if(!r)return!0;const $=r.toLowerCase();return I.name.toLowerCase().includes($)||I.code.toLowerCase().includes($)}),F=j.useCallback(async I=>{if(!O||!m.trim())return;const $=await fetch(`/api/kanban/${O}/tasks`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:m.trim(),description:x.trim()||void 0,status:I})});if($.ok){const z=await $.json();c(G=>[...G,z]),g(""),v(""),p(null)}},[O,m,x]),Z=j.useCallback(async I=>{if(!O)return;(await fetch(`/api/kanban/${O}/tasks/${I}`,{method:"DELETE",credentials:"include"})).ok&&(c(z=>z.filter(G=>G.id!==I)),(T==null?void 0:T.id)===I&&C(null))},[O,T]),V=j.useCallback(async(I,$)=>{if(!O)return;const z=l.find(Q=>Q.id===I);if(!z||z.status===$)return;c(Q=>Q.map(W=>W.id===I?{...W,status:$}:W));const G=await fetch(`/api/kanban/${O}/tasks/${I}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:$})});if(G.ok){const Q=await G.json();c(W=>W.map(B=>B.id===I?Q:B)),(T==null?void 0:T.id)===I&&C(Q),$==="executing"&&XC(O,`Execute a seguinte tarefa do kanban: ${z.title}${z.description?" — "+z.description:""}`)}else c(Q=>Q.map(W=>W.id===I?z:W))},[O,l,T]),Y=j.useCallback(async(I,$)=>{if(!O)return;const z=await fetch(`/api/kanban/${O}/tasks/${I}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({result:$})});if(z.ok){const G=await z.json();c(Q=>Q.map(W=>W.id===I?G:W)),C(G)}},[O]),P=j.useCallback((I,$)=>{I.preventDefault(),I.dataTransfer.dropEffect="move",A($)},[]),q=j.useCallback(()=>{A(null)},[]),ne=j.useCallback((I,$)=>{I.preventDefault(),A(null);const z=I.dataTransfer.getData("text/plain");if(!z.startsWith("task:"))return;const G=z.replace("task:","");V(G,$)},[V]);return _.jsxs("div",{style:{display:"flex",overflow:"hidden",...N?{position:"fixed",inset:0,zIndex:200,background:"var(--surface-0)"}:{height:"100%"}},children:[_.jsxs("div",{style:{width:240,minWidth:240,borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[_.jsxs("div",{style:{padding:"8px 14px",borderBottom:"1px solid var(--border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Squads"}),_.jsx("button",{onClick:()=>R(I=>!I),title:N?"Voltar ao modo normal":"Modo foco — tela cheia",style:{background:N?"rgba(0,200,255,0.1)":"transparent",border:`1px solid ${N?"var(--accent)":"var(--border-subtle)"}`,color:N?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.58rem",padding:"2px 7px",borderRadius:3},children:N?"← Normal":"⛶ Foco"})]}),_.jsx("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border-subtle)"},children:_.jsx("input",{type:"text",placeholder:"Search squads...",value:r,onChange:I=>s(I.target.value),style:{width:"100%",padding:"5px 8px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",outline:"none"}})}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"6px 8px"},children:[_.jsxs("button",{onClick:()=>{i("__all__"),C(null)},style:{width:"100%",background:O==="__all__"?"var(--accent-glow)":"none",border:O==="__all__"?"1px solid rgba(0, 200, 255, 0.12)":"1px solid transparent",borderRadius:"var(--radius-sm)",padding:"8px 10px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",textAlign:"left",marginBottom:6},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--accent)",flexShrink:0}}),_.jsxs("div",{style:{overflow:"hidden"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",fontWeight:O==="__all__"?600:400,color:O==="__all__"?"var(--accent)":"var(--text-primary)"},children:"Todos"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)"},children:"all squads"})]})]}),_.jsx("div",{style:{borderBottom:"1px solid var(--border-subtle)",margin:"4px 0 6px"}}),D.map(I=>{var G;const $=I.code===O,z=!!t[I.code];return _.jsxs("button",{onClick:()=>{i(I.code),C(null)},style:{width:"100%",background:$?"var(--accent-glow)":"none",border:$?"1px solid rgba(0, 200, 255, 0.12)":"1px solid transparent",borderRadius:"var(--radius-sm)",padding:"8px 10px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",textAlign:"left",marginBottom:2},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:z?"var(--status-active)":"var(--status-idle)",flexShrink:0}}),_.jsxs("div",{style:{overflow:"hidden"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",fontWeight:$?600:400,color:$?"var(--accent)":"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:I.name}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)"},children:[((G=I.agents)==null?void 0:G.length)||0," agents"]})]})]},I.code)}),D.length===0&&_.jsx("div",{style:{padding:"16px 10px",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)",textAlign:"center"},children:"No squads found"})]})]}),_.jsx("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:O?_.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[_.jsx("div",{style:{display:"flex",gap:"var(--sp-4)",padding:"var(--sp-5)",flex:1,overflow:"auto"},children:H.map((I,$)=>{const z=S===I.key;return _.jsxs("div",{"data-testid":`column-${I.key}`,onDragOver:G=>P(G,I.key),onDragLeave:q,onDrop:G=>ne(G,I.key),style:{flex:1,background:z?"rgba(0, 200, 255, 0.04)":"var(--surface-2)",border:z?"1px dashed var(--accent)":"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-4)",display:"flex",flexDirection:"column",minWidth:220,animation:`fadeInUp 0.4s var(--ease-out) ${$*80}ms both`,transition:"background 0.15s ease, border-color 0.15s ease"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--sp-4)",paddingBottom:"var(--sp-3)",borderBottom:`2px solid ${I.color}`},children:[_.jsx("span",{style:{fontWeight:600,fontSize:"0.82rem",color:"var(--text-primary)"},children:I.label}),_.jsx("span",{"data-testid":`count-${I.key}`,style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:700,color:I.color,background:I.glow,width:22,height:22,borderRadius:"var(--radius-full)",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${I.color}`},children:I.tasks.length})]}),_.jsx("div",{style:{flex:1,overflowY:"auto"},children:I.tasks.map(G=>_.jsx(pG,{task:G,selected:(T==null?void 0:T.id)===G.id,onClick:C,onDelete:G.activity_id?void 0:Z},G.id))}),f===I.key?_.jsxs("div",{style:{marginTop:"var(--sp-3)",background:"var(--surface-3)",borderRadius:"var(--radius-sm)",padding:"10px 12px",border:"1px solid var(--border-default)"},children:[_.jsx("input",{type:"text",placeholder:"Title",value:m,onChange:G=>g(G.target.value),autoFocus:!0,onKeyDown:G=>{G.key==="Enter"&&m.trim()&&F(I.key),G.key==="Escape"&&(p(null),g(""),v(""))},style:{width:"100%",padding:"5px 8px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-display)",fontSize:"0.82rem",fontWeight:600,outline:"none",marginBottom:6}}),_.jsx("textarea",{placeholder:"Description (optional)",value:x,onChange:G=>v(G.target.value),onKeyDown:G=>{G.key==="Escape"&&(p(null),g(""),v(""))},rows:2,style:{width:"100%",padding:"5px 8px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-secondary)",fontFamily:"var(--font-mono)",fontSize:"0.7rem",outline:"none",resize:"none",marginBottom:8}}),_.jsxs("div",{style:{display:"flex",gap:6},children:[_.jsx("button",{onClick:()=>F(I.key),disabled:!m.trim(),style:{background:m.trim()?"var(--accent)":"var(--surface-4)",border:"none",borderRadius:"var(--radius-xs)",padding:"4px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:m.trim()?"var(--text-inverse)":"var(--text-muted)",cursor:m.trim()?"pointer":"default"},children:"Add"}),_.jsx("button",{onClick:()=>{p(null),g(""),v("")},style:{background:"none",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",padding:"4px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-secondary)",cursor:"pointer"},children:"Cancel"})]})]}):_.jsx("button",{"data-testid":`add-task-${I.key}`,onClick:()=>{p(I.key),g(""),v("")},style:{marginTop:"var(--sp-3)",width:"100%",background:"none",border:"1px dashed var(--border-default)",borderRadius:"var(--radius-sm)",padding:"8px",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-muted)",cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:G=>{G.currentTarget.style.borderColor="var(--accent-dim)",G.currentTarget.style.color="var(--accent)"},onMouseLeave:G=>{G.currentTarget.style.borderColor="var(--border-default)",G.currentTarget.style.color="var(--text-muted)"},children:"+ New Task"})]},I.key)})}),T&&_.jsx(gG,{task:T,onClose:()=>C(null),onMove:V,onUpdateResult:Y})]}):_.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"var(--sp-3)",animation:"fadeIn 0.5s var(--ease-out) both"},children:[_.jsx("span",{style:{fontSize:"1.5rem",color:"var(--text-muted)",opacity:.4},children:"▦"}),_.jsx("span",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Select a squad to view the kanban"})]})})]})}function gG({task:e,onClose:t,onMove:n,onUpdateResult:i}){const[r,s]=j.useState(!1),[l,c]=j.useState(e.result||"");j.useEffect(()=>{c(e.result||""),s(!1)},[e.id,e.result]);const f=()=>{i(e.id,l),s(!1)},p=e.status==="planned"?"var(--status-idle)":e.status==="executing"?"var(--accent)":e.status==="failed"?"var(--status-error)":"var(--status-active)";return _.jsxs("div",{"data-testid":"task-detail-panel",style:{width:360,minWidth:360,borderLeft:"1px solid var(--border-subtle)",background:"var(--surface-1)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideInRight 0.2s var(--ease-out) both"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:600,color:p,padding:"2px 10px",borderRadius:"var(--radius-full)",border:`1px solid ${p}`,textTransform:"uppercase"},children:e.status==="planned"?"planejado":e.status==="executing"?"executando":e.status==="failed"?"falhou":"finalizado"}),_.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:"1rem",padding:"0 4px"},children:"✕"})]}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px"},children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontSize:"1rem",fontWeight:700,color:"var(--text-primary)",marginBottom:8,lineHeight:1.3},children:e.title}),e.description&&_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.78rem",color:"var(--text-secondary)",lineHeight:1.5,marginBottom:16},children:e.description}),_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,marginBottom:20,padding:"12px",background:"var(--surface-2)",borderRadius:"var(--radius-sm)"},children:[_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",marginBottom:2},children:"Created"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)"},children:bv(e.created_at)})]}),_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",marginBottom:2},children:"Started"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)"},children:bv(e.started_at)})]}),_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",marginBottom:2},children:"Finished"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)"},children:bv(e.finished_at)})]}),_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",marginBottom:2},children:"Duration"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:vv(e.started_at,e.finished_at)?"var(--accent)":"var(--text-secondary)",fontWeight:vv(e.started_at,e.finished_at)?600:400},children:vv(e.started_at,e.finished_at)??"—"})]})]}),_.jsxs("div",{style:{marginBottom:20},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"Move to"}),_.jsx("div",{style:{display:"flex",gap:6},children:ck.filter(m=>m.key!==e.status).map(m=>_.jsx("button",{"data-testid":`move-to-${m.key}`,onClick:()=>n(e.id,m.key),style:{flex:1,background:"var(--surface-3)",border:`1px solid ${m.color}`,borderRadius:"var(--radius-xs)",padding:"6px 10px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:m.color,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:g=>{g.currentTarget.style.background=m.glow!=="none"?m.glow:"var(--surface-4)"},onMouseLeave:g=>{g.currentTarget.style.background="var(--surface-3)"},children:m.label},m.key))})]}),_.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Output / Result"}),!r&&_.jsx("button",{onClick:()=>{s(!0),c(e.result||"")},style:{background:"none",border:"none",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--accent-dim)",cursor:"pointer"},children:e.result?"edit":"+ add"})]}),r?_.jsxs("div",{children:[_.jsx("textarea",{value:l,onChange:m=>c(m.target.value),autoFocus:!0,rows:8,style:{width:"100%",padding:"10px 12px",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",lineHeight:1.6,outline:"none",resize:"vertical",marginBottom:8}}),_.jsxs("div",{style:{display:"flex",gap:6},children:[_.jsx("button",{onClick:f,style:{background:"var(--accent)",border:"none",borderRadius:"var(--radius-xs)",padding:"4px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:"var(--text-inverse)",cursor:"pointer"},children:"Save"}),_.jsx("button",{onClick:()=>s(!1),style:{background:"none",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",padding:"4px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-secondary)",cursor:"pointer"},children:"Cancel"})]})]}):e.result?_.jsx("div",{style:{padding:"12px",background:"var(--surface-2)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-primary)",lineHeight:1.6,whiteSpace:"pre-wrap",maxHeight:300,overflowY:"auto"},children:e.result}):_.jsx("div",{style:{padding:"20px",background:"var(--surface-2)",borderRadius:"var(--radius-sm)",border:"1px dashed var(--border-default)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-muted)"},children:"No output yet"})]})]})]})}function yG(){const e=gl(R=>R.user),[t,n]=j.useState([]),[i,r]=j.useState(!0),[s,l]=j.useState(""),[c,f]=j.useState(""),[p,m]=j.useState("viewer"),[g,x]=j.useState(null),[v,S]=j.useState(null),A=j.useCallback(async()=>{try{const R=await fetch("/api/users",{credentials:"include"});if(R.ok){const O=await R.json();n(O.users)}}catch{x("Failed to load users")}finally{r(!1)}},[]);j.useEffect(()=>{A()},[A]);const T=async()=>{if(!(!s.trim()||!c.trim())){x(null);try{const R=await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:s,password:c,role:p}),credentials:"include"});if(!R.ok){const O=await R.json();x(O.error||"Failed to create user");return}l(""),f(""),m("viewer"),await A()}catch{x("Network error")}}},C=async(R,O)=>{try{(await fetch(`/api/users/${R}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({role:O}),credentials:"include"})).ok&&await A()}catch{x("Failed to update role")}},N=async R=>{try{(await fetch(`/api/users/${R}`,{method:"DELETE",credentials:"include"})).ok&&(S(null),await A())}catch{x("Failed to delete user")}};return i?_.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading users..."}):_.jsxs("div",{children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",marginBottom:"var(--sp-4)"},children:"User Management"}),g&&_.jsx("div",{style:{background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.2)",color:"var(--status-error)",padding:"var(--sp-2) var(--sp-3)",borderRadius:"var(--radius-sm)",marginBottom:"var(--sp-3)",fontFamily:"var(--font-mono)",fontSize:"0.78rem"},children:g}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)",marginBottom:"var(--sp-5)",flexWrap:"wrap",alignItems:"center"},children:[_.jsx("input",{className:"input",placeholder:"Username",value:s,onChange:R=>l(R.target.value),style:{flex:1,minWidth:120}}),_.jsx("input",{className:"input",placeholder:"Password",type:"password",value:c,onChange:R=>f(R.target.value),style:{flex:1,minWidth:120}}),_.jsxs("select",{className:"input",value:p,onChange:R=>m(R.target.value),style:{minWidth:100},children:[_.jsx("option",{value:"viewer",children:"viewer"}),_.jsx("option",{value:"operator",children:"operator"}),_.jsx("option",{value:"admin",children:"admin"})]}),_.jsx("button",{onClick:T,className:"btn btn-accent",children:"Create User"})]}),_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{borderBottom:"1px solid var(--border-default)"},children:["Username","Email","Role","Last Login","Actions"].map((R,O)=>_.jsx("th",{style:{textAlign:O===4?"right":"left",padding:"8px 12px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em"},children:R},R))})}),_.jsx("tbody",{children:t.map(R=>_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-primary)",fontSize:"0.82rem"},children:R.username}),_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-secondary)",fontSize:"0.82rem"},children:R.email||"—"}),_.jsx("td",{style:{padding:"10px 12px"},children:R.id===(e==null?void 0:e.id)?_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-secondary)"},children:R.role}):_.jsxs("select",{className:"input",value:R.role,onChange:O=>C(R.id,O.target.value),style:{padding:"4px 8px",fontSize:"0.75rem"},children:[_.jsx("option",{value:"viewer",children:"viewer"}),_.jsx("option",{value:"operator",children:"operator"}),_.jsx("option",{value:"admin",children:"admin"})]})}),_.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:R.last_login?new Date(R.last_login).toLocaleDateString():"—"}),_.jsx("td",{style:{padding:"10px 12px",textAlign:"right"},children:R.id!==(e==null?void 0:e.id)&&(v===R.id?_.jsxs("span",{style:{display:"inline-flex",gap:"var(--sp-2)",alignItems:"center"},children:[_.jsx("span",{style:{color:"var(--status-error)",fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:"Confirm?"}),_.jsx("button",{onClick:()=>N(R.id),className:"btn btn-sm btn-danger",children:"Yes"}),_.jsx("button",{onClick:()=>S(null),className:"btn btn-sm",children:"No"})]}):_.jsx("button",{onClick:()=>S(R.id),className:"btn btn-sm btn-danger",children:"Delete"}))})]},R.id))})]})]})}function xG(){const e=vr(f=>f.selectedSquad),t=vr(f=>f.activeStates),[n,i]=j.useState(null),[r,s]=j.useState(!1),l=e?t[e]:null;if(j.useEffect(()=>{if(!e){i(null);return}s(!0),fetch(`/api/squads/${e}`,{credentials:"include"}).then(f=>f.ok?f.json():null).then(f=>{f&&i(f.data)}).finally(()=>s(!1))},[e]),!e)return _.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontSize:"0.85rem"},children:"Select a squad to view details"});if(r)return _.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading squad details..."});const c={fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",fontWeight:600,marginBottom:"var(--sp-2)",textTransform:"uppercase",letterSpacing:"0.08em"};return _.jsxs("div",{children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",marginBottom:"var(--sp-4)"},children:"Squad Info"}),n&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Name"}),_.jsx("div",{style:{color:"var(--text-primary)",fontSize:"0.9rem",fontWeight:600},children:n.name})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Description"}),_.jsx("div",{style:{color:"var(--text-primary)",fontSize:"0.85rem",lineHeight:1.5},children:n.description})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Agents"}),_.jsx("div",{style:{display:"flex",gap:"var(--sp-2)",flexWrap:"wrap"},children:n.agents.map(f=>_.jsx("span",{style:{background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",padding:"4px 10px",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-primary)"},children:f.name},f.id))})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Pipeline Steps"}),_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-2)"},children:n.pipeline.steps.map((f,p)=>_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-3)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",padding:"8px 12px",fontSize:"0.82rem"},children:[_.jsx("span",{style:{background:"var(--accent)",color:"var(--text-inverse)",width:22,height:22,borderRadius:"var(--radius-full)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:700,flexShrink:0},children:p+1}),_.jsx("span",{style:{color:"var(--text-primary)"},children:f.label}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text-muted)",fontSize:"0.68rem",marginLeft:"auto"},children:f.agent})]},f.id))})]})]}),l&&_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:c,children:"Current State"}),_.jsx("pre",{"data-testid":"state-json",style:{background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",padding:"var(--sp-4)",fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--accent)",overflow:"auto",maxHeight:400,lineHeight:1.5},children:JSON.stringify(l,null,2)})]})]})}function bG(){const[e,t]=j.useState(null),[n,i]=j.useState(null),[r,s]=j.useState(!0),[l,c]=j.useState(null),f=j.useCallback(async()=>{s(!0);try{const g=await fetch("/api/health",{credentials:"include"});if(g.ok){const x=await g.json();t(x),i(x.status==="ok")}else i(!1)}catch{i(!1)}finally{s(!1),c(new Date().toLocaleTimeString())}},[]);j.useEffect(()=>{f()},[f]);const p={fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",fontWeight:600,marginBottom:"var(--sp-2)",textTransform:"uppercase",letterSpacing:"0.08em"},m={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",marginBottom:"var(--sp-2)",fontSize:"0.82rem"};return _.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--sp-4)"},children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)"},children:"Server Info"}),_.jsx("button",{onClick:f,className:"btn btn-sm",children:"Refresh"})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:p,children:"Health Status"}),_.jsxs("div",{style:m,children:[_.jsx("span",{style:{color:"var(--text-primary)"},children:"API Server"}),r?_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)",animation:"pulse 1.5s ease-in-out infinite"},children:"Checking..."}):_.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"var(--sp-1)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",fontWeight:600,color:n?"var(--status-active)":"var(--status-error)"},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:n?"var(--status-active)":"var(--status-error)",display:"inline-block",boxShadow:n?"0 0 8px var(--status-active-glow)":"0 0 8px var(--status-error-glow)"}}),n?"Healthy":"Unhealthy"]})]})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-5)"},children:[_.jsx("div",{style:p,children:"Environment"}),_.jsxs("div",{style:m,children:[_.jsx("span",{style:{color:"var(--text-primary)"},children:"API Port"}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)"},children:"3001"})]}),_.jsxs("div",{style:m,children:[_.jsx("span",{style:{color:"var(--text-primary)"},children:"Dashboard Port (dev)"}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)"},children:"5173"})]})]}),l&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textAlign:"right"},children:["Last checked: ",l]})]})}const vG=[{key:"AWS_ACCESS_KEY_ID",label:"AWS Access Key ID",type:"password",hint:"Your AWS IAM access key"},{key:"AWS_SECRET_ACCESS_KEY",label:"AWS Secret Access Key",type:"password",hint:"Your AWS IAM secret key"},{key:"AWS_REGION",label:"AWS Region",type:"text",hint:"e.g. us-east-1, eu-west-1"},{key:"SES_FROM_EMAIL",label:"SES From Email",type:"text",hint:"Verified sender email in SES"},{key:"SES_RATE_LIMIT",label:"SES Rate Limit",type:"text",hint:"Max emails per second (default: 14)"},{key:"SERVER_URL",label:"Server URL",type:"text",hint:"Public URL for unsubscribe links"},{key:"PORT",label:"Port",type:"text",hint:"Server port (requires restart)"},{key:"CORS_ORIGIN",label:"CORS Origin",type:"text",hint:"Allowed origin for CORS"},{key:"NODE_ENV",label:"Node Environment",type:"text",hint:"development or production"}];function _G(){const[e,t]=j.useState({}),[n,i]=j.useState(!0),[r,s]=j.useState(!1),[l,c]=j.useState(null),[f,p]=j.useState(new Set);j.useEffect(()=>{fetch("/api/settings/env").then(x=>x.json()).then(x=>{t(x.settings||{}),i(!1)}).catch(()=>i(!1))},[]);const m=(x,v)=>{t(S=>({...S,[x]:v})),p(S=>new Set(S).add(x)),c(null)},g=async()=>{if(f.size===0)return;s(!0),c(null);const x={};for(const v of f)x[v]=e[v]||"";try{const v=await fetch("/api/settings/env",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(v.ok){const S=await v.json();t(S.settings),p(new Set),c({type:"success",text:"Settings saved successfully"})}else{const S=await v.json();c({type:"error",text:S.error||"Failed to save"})}}catch{c({type:"error",text:"Network error"})}finally{s(!1)}};return n?_.jsx("div",{style:{textAlign:"center",padding:"var(--sp-6)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:"Loading..."}):_.jsxs("div",{style:{maxWidth:640},children:[_.jsx("div",{style:{marginBottom:"var(--sp-4)"},children:_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)",lineHeight:1.6},children:"Server environment variables. Secret values are masked. Changes to PORT or NODE_ENV require a server restart."})}),_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-3)"},children:vG.map(x=>_.jsxs("div",{children:[_.jsx("label",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.04em",marginBottom:4},children:x.label}),_.jsx("input",{type:x.type,value:e[x.key]||"",onChange:v=>m(x.key,v.target.value),placeholder:x.hint,style:{width:"100%",padding:"8px 12px",background:"var(--surface-2)",border:f.has(x.key)?"1px solid var(--accent)":"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.78rem",boxSizing:"border-box"}}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)"},children:x.hint})]},x.key))}),_.jsxs("div",{style:{marginTop:"var(--sp-4)",display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[_.jsx("button",{onClick:g,disabled:f.size===0||r,style:{padding:"8px 24px",background:f.size>0?"var(--accent)":"var(--surface-3)",border:"none",borderRadius:"var(--radius-sm)",color:f.size>0?"var(--text-inverse)":"var(--text-muted)",cursor:f.size>0?"pointer":"default",fontFamily:"var(--font-display)",fontSize:"0.82rem",fontWeight:600,opacity:r?.6:1},children:r?"Saving...":`Save ${f.size>0?`(${f.size})`:""}`}),l&&_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:l.type==="success"?"var(--status-active)":"var(--status-error)"},children:l.text})]})]})}function SG(){const[e,t]=j.useState([]),[n,i]=j.useState(!0),[r,s]=j.useState(null),[l,c]=j.useState(null),[f,p]=j.useState(""),[m,g]=j.useState(""),[x,v]=j.useState(""),[S,A]=j.useState(""),[T,C]=j.useState(null),[N,R]=j.useState(""),[O,H]=j.useState(""),[D,F]=j.useState(""),[Z,V]=j.useState(""),Y=j.useCallback(async()=>{try{const z=await fetch("/api/team",{credentials:"include"});if(z.ok){const G=await z.json();t(G.members)}}catch{s("Failed to load team members")}finally{i(!1)}},[]);j.useEffect(()=>{Y()},[Y]);const P=async()=>{if(!(!f.trim()||!m.trim())){s(null);try{const z=await fetch("/api/team",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:f.trim(),role:m.trim(),email:x.trim()||void 0,phone:S.trim()||void 0}),credentials:"include"});if(!z.ok){const G=await z.json();s(G.error||"Failed to create team member");return}p(""),g(""),v(""),A(""),await Y()}catch{s("Network error")}}},q=z=>{C(z.id),R(z.name),H(z.role),F(z.email||""),V(z.phone||"")},ne=()=>{C(null)},I=async()=>{if(!(!T||!N.trim()||!O.trim())){s(null);try{(await fetch(`/api/team/${T}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N.trim(),role:O.trim(),email:D.trim()||void 0,phone:Z.trim()||void 0}),credentials:"include"})).ok&&(C(null),await Y())}catch{s("Failed to update member")}}},$=async z=>{try{(await fetch(`/api/team/${z}`,{method:"DELETE",credentials:"include"})).ok&&(c(null),await Y())}catch{s("Failed to delete member")}};return n?_.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading team..."}):_.jsxs("div",{children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",marginBottom:"var(--sp-4)"},children:"Team Members"}),r&&_.jsx("div",{style:{background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.2)",color:"var(--status-error)",padding:"var(--sp-2) var(--sp-3)",borderRadius:"var(--radius-sm)",marginBottom:"var(--sp-3)",fontFamily:"var(--font-mono)",fontSize:"0.78rem"},children:r}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)",marginBottom:"var(--sp-5)",flexWrap:"wrap",alignItems:"center"},children:[_.jsx("input",{className:"input",placeholder:"Name *",value:f,onChange:z=>p(z.target.value),style:{flex:1,minWidth:120}}),_.jsx("input",{className:"input",placeholder:"Role *",value:m,onChange:z=>g(z.target.value),style:{flex:1,minWidth:120}}),_.jsx("input",{className:"input",placeholder:"Email",type:"email",value:x,onChange:z=>v(z.target.value),style:{flex:1,minWidth:150}}),_.jsx("input",{className:"input",placeholder:"Phone",type:"tel",value:S,onChange:z=>A(z.target.value),style:{flex:1,minWidth:130}}),_.jsx("button",{onClick:P,className:"btn btn-accent",children:"Add Member"})]}),_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{borderBottom:"1px solid var(--border-default)"},children:["Name","Role","Email","Phone","Actions"].map((z,G)=>_.jsx("th",{style:{textAlign:G===4?"right":"left",padding:"8px 12px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em"},children:z},z))})}),_.jsxs("tbody",{children:[e.length===0&&_.jsx("tr",{children:_.jsx("td",{colSpan:5,style:{padding:"var(--sp-5)",textAlign:"center",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.78rem"},children:"No team members yet"})}),e.map(z=>T===z.id?_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-3)"},children:[_.jsx("td",{style:{padding:"6px 12px"},children:_.jsx("input",{className:"input",value:N,onChange:G=>R(G.target.value),style:{width:"100%",fontSize:"0.82rem"}})}),_.jsx("td",{style:{padding:"6px 12px"},children:_.jsx("input",{className:"input",value:O,onChange:G=>H(G.target.value),style:{width:"100%",fontSize:"0.82rem"}})}),_.jsx("td",{style:{padding:"6px 12px"},children:_.jsx("input",{className:"input",value:D,onChange:G=>F(G.target.value),style:{width:"100%",fontSize:"0.82rem"}})}),_.jsx("td",{style:{padding:"6px 12px"},children:_.jsx("input",{className:"input",value:Z,onChange:G=>V(G.target.value),style:{width:"100%",fontSize:"0.82rem"}})}),_.jsx("td",{style:{padding:"6px 12px",textAlign:"right"},children:_.jsxs("span",{style:{display:"inline-flex",gap:"var(--sp-2)"},children:[_.jsx("button",{onClick:I,className:"btn btn-sm btn-accent",children:"Save"}),_.jsx("button",{onClick:ne,className:"btn btn-sm",children:"Cancel"})]})})]},z.id):_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-primary)",fontSize:"0.82rem"},children:z.name}),_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-secondary)",fontSize:"0.82rem"},children:z.role}),_.jsx("td",{style:{padding:"10px 12px",color:"var(--text-secondary)",fontSize:"0.82rem"},children:z.email||"—"}),_.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)"},children:z.phone||"—"}),_.jsx("td",{style:{padding:"10px 12px",textAlign:"right"},children:l===z.id?_.jsxs("span",{style:{display:"inline-flex",gap:"var(--sp-2)",alignItems:"center"},children:[_.jsx("span",{style:{color:"var(--status-error)",fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:"Confirm?"}),_.jsx("button",{onClick:()=>$(z.id),className:"btn btn-sm btn-danger",children:"Yes"}),_.jsx("button",{onClick:()=>c(null),className:"btn btn-sm",children:"No"})]}):_.jsxs("span",{style:{display:"inline-flex",gap:"var(--sp-2)"},children:[_.jsx("button",{onClick:()=>q(z),className:"btn btn-sm",children:"Edit"}),_.jsx("button",{onClick:()=>c(z.id),className:"btn btn-sm btn-danger",children:"Delete"})]})})]},z.id))]})]})]})}const EG={dev:"Development",messaging:"Messaging",ads:"Advertising",crm:"CRM",support:"Support",email:"Email Marketing",sales:"Sales & Payments",pm:"Project Management",monitoring:"Monitoring",cloud:"Cloud & Deploy",design:"Design"},wG={dev:"⌨",messaging:"💬",ads:"📢",crm:"📊",support:"🎧",email:"✉",sales:"💰",pm:"📋",monitoring:"🔍",cloud:"☁",design:"🎨"};function TG(){const[e,t]=j.useState([]),[n,i]=j.useState([]),[r,s]=j.useState(!0),[l,c]=j.useState(null),[f,p]=j.useState(null),[m,g]=j.useState(!1),[x,v]=j.useState({}),[S,A]=j.useState(!1),[T,C]=j.useState(null),[N,R]=j.useState(""),O=j.useCallback(async()=>{try{const[q,ne]=await Promise.all([fetch("/api/integrations/catalog",{credentials:"include"}),fetch("/api/integrations",{credentials:"include"})]);if(q.ok){const I=await q.json();t(I.providers)}if(ne.ok){const I=await ne.json();i(I.integrations)}}catch{c("Failed to load integrations")}finally{s(!1)}},[]);j.useEffect(()=>{O()},[O]);const H=q=>n.find(ne=>ne.provider===q),D=q=>{const ne=H(q.key),I={};for(const $ of q.fields)I[$.key]=(ne==null?void 0:ne.config[$.key])||"";v(I),A((ne==null?void 0:ne.enabled)??!1),p(q.key),c(null)},F=async()=>{if(f){g(!0),c(null);try{const q=await fetch(`/api/integrations/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:S,config:x}),credentials:"include"});if(!q.ok){const ne=await q.json();c(ne.error||"Failed to save");return}await O(),p(null)}catch{c("Network error")}finally{g(!1)}}},Z=async q=>{try{(await fetch(`/api/integrations/${q}`,{method:"DELETE",credentials:"include"})).ok&&(await O(),f===q&&p(null))}catch{c("Failed to disconnect")}},V=Array.from(new Set(e.map(q=>q.category))),Y=N.toLowerCase(),P=e.filter(q=>!(T&&q.category!==T||N&&!q.name.toLowerCase().includes(Y)&&!q.description.toLowerCase().includes(Y)));return r?_.jsx("div",{style:{color:"var(--text-muted)",padding:"var(--sp-5)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading integrations..."}):_.jsxs("div",{children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.95rem",color:"var(--text-primary)",marginBottom:"var(--sp-2)"},children:"Integrations"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",color:"var(--text-muted)",marginBottom:"var(--sp-4)"},children:"Configure third-party services for your squads and agents"}),_.jsx("input",{className:"input",type:"text",placeholder:"Search integrations...",value:N,onChange:q=>R(q.target.value),style:{width:"100%",fontSize:"0.8rem",marginBottom:"var(--sp-3)"}}),l&&_.jsx("div",{style:{background:"var(--status-error-glow)",border:"1px solid rgba(255, 64, 112, 0.2)",color:"var(--status-error)",padding:"var(--sp-2) var(--sp-3)",borderRadius:"var(--radius-sm)",marginBottom:"var(--sp-3)",fontFamily:"var(--font-mono)",fontSize:"0.78rem"},children:l}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)",marginBottom:"var(--sp-4)",flexWrap:"wrap"},children:[_.jsx("button",{onClick:()=>C(null),style:{padding:"4px 12px",border:"1px solid",borderColor:T?"var(--border-subtle)":"var(--accent)",borderRadius:"var(--radius-sm)",background:T?"transparent":"var(--accent)",color:T?"var(--text-secondary)":"#fff",fontFamily:"var(--font-mono)",fontSize:"0.7rem",cursor:"pointer"},children:"All"}),V.map(q=>_.jsxs("button",{onClick:()=>C(q),style:{padding:"4px 12px",border:"1px solid",borderColor:T===q?"var(--accent)":"var(--border-subtle)",borderRadius:"var(--radius-sm)",background:T===q?"var(--accent)":"transparent",color:T===q?"#fff":"var(--text-secondary)",fontFamily:"var(--font-mono)",fontSize:"0.7rem",cursor:"pointer"},children:[wG[q]||""," ",EG[q]||q]},q))]}),_.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"var(--sp-3)"},children:P.map(q=>{const ne=H(q.key),I=f===q.key;return _.jsxs("div",{style:{background:"var(--surface-3)",border:"1px solid",borderColor:ne!=null&&ne.enabled?"var(--status-running)":"var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-3)",transition:"all var(--duration-fast) var(--ease-out)",gridColumn:I?"1 / -1":void 0},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:I?"var(--sp-3)":0},children:[_.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--sp-2)"},children:[_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:600,fontSize:"0.85rem",color:"var(--text-primary)"},children:q.name}),(ne==null?void 0:ne.enabled)&&_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--status-running)",boxShadow:"0 0 4px var(--status-running)",display:"inline-block"}})]}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.68rem",color:"var(--text-muted)"},children:q.description})]}),_.jsx("button",{onClick:()=>I?p(null):D(q),className:"btn btn-sm",style:{flexShrink:0},children:I?"Close":ne?"Edit":"Configure"})]}),I&&_.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"var(--sp-3)"},children:[_.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"var(--sp-2)",marginBottom:"var(--sp-3)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)",cursor:"pointer"},children:[_.jsx("input",{type:"checkbox",checked:S,onChange:$=>A($.target.checked)}),"Enabled"]}),_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-2)"},children:q.fields.map($=>_.jsxs("div",{children:[_.jsxs("label",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:2,display:"block"},children:[$.label," ",$.required&&"*"]}),_.jsx("input",{className:"input",type:$.type==="password"?"password":"text",placeholder:$.placeholder||"",value:x[$.key]||"",onChange:z=>v(G=>({...G,[$.key]:z.target.value})),style:{width:"100%",fontSize:"0.8rem"}})]},$.key))}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)",marginTop:"var(--sp-3)",justifyContent:"flex-end"},children:[ne&&_.jsx("button",{onClick:()=>Z(q.key),className:"btn btn-sm btn-danger",children:"Disconnect"}),_.jsx("button",{onClick:()=>p(null),className:"btn btn-sm",children:"Cancel"}),_.jsx("button",{onClick:F,className:"btn btn-sm btn-accent",disabled:m,children:m?"Saving...":"Save"})]})]})]},q.key)})})]})}function CG(){const e=gl(l=>l.user),t=(e==null?void 0:e.role)==="admin",[n,i]=j.useState(t?"users":"squad"),s=[{key:"users",label:"Users",icon:"◉",adminOnly:!0},{key:"team",label:"Team",icon:"◎"},{key:"integrations",label:"Integrations",icon:"⬡"},{key:"squad",label:"Squad",icon:"⬢"},{key:"server",label:"Server",icon:"⚙"},{key:"env",label:"Environment",icon:"◆",adminOnly:!0}].filter(l=>!l.adminOnly||t);return _.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",padding:"var(--sp-5)",animation:"fadeIn 0.4s var(--ease-out) both"},children:[_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("h2",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1.1rem",color:"var(--text-primary)",marginBottom:"var(--sp-1)"},children:"Settings"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"Configuration and management"})]}),_.jsx("div",{style:{display:"flex",gap:"var(--sp-1)",marginBottom:"var(--sp-5)",borderBottom:"1px solid var(--border-subtle)"},children:s.map(l=>_.jsxs("button",{onClick:()=>i(l.key),style:{display:"flex",alignItems:"center",gap:"var(--sp-2)",padding:"10px 16px",border:"none",borderBottom:n===l.key?"2px solid var(--accent)":"2px solid transparent",background:"transparent",color:n===l.key?"var(--text-primary)":"var(--text-muted)",fontFamily:"var(--font-display)",fontWeight:n===l.key?600:400,fontSize:"0.82rem",cursor:"pointer",transition:"all var(--duration-fast) var(--ease-out)"},children:[_.jsx("span",{style:{fontSize:"0.75rem",opacity:.7},children:l.icon}),l.label]},l.key))}),_.jsxs("div",{style:{flex:1,overflow:"auto"},children:[n==="users"&&t&&_.jsx(yG,{}),n==="team"&&_.jsx(SG,{}),n==="integrations"&&_.jsx(TG,{}),n==="squad"&&_.jsx(xG,{}),n==="server"&&_.jsx(bG,{}),n==="env"&&t&&_.jsx(_G,{})]})]})}const uk=[{value:"0",label:"Domingo"},{value:"1",label:"Segunda"},{value:"2",label:"Terça"},{value:"3",label:"Quarta"},{value:"4",label:"Quinta"},{value:"5",label:"Sexta"},{value:"6",label:"Sábado"}];function AG(e,t){switch(e){case"every_n_minutes":return`*/${t.everyNMinutes||"30"} * * * *`;case"every_n_hours":return`${t.minute||"0"} */${t.everyNHours||"2"} * * *`;case"hourly":return`${t.minute||"0"} * * * *`;case"daily":return`${t.minute||"0"} ${t.hour||"9"} * * *`;case"weekly":return`${t.minute||"0"} ${t.hour||"9"} * * ${t.dayOfWeek||"1"}`;case"monthly":return`${t.minute||"0"} ${t.hour||"9"} ${t.dayOfMonth||"1"} * *`;case"custom":return"";default:return"0 9 * * *"}}function _v(e){var l;if(!e)return"";const t=e.split(" ");if(t.length!==5)return e;const[n,i,r,,s]=t;return n.startsWith("*/")?`A cada ${n.replace("*/","")} minutos`:i.startsWith("*/")?`A cada ${i.replace("*/","")} horas no minuto ${n}`:i==="*"&&r==="*"?`A cada hora no minuto ${n}`:r==="*"&&s==="*"?`Diariamente às ${i.padStart(2,"0")}:${n.padStart(2,"0")}`:r==="*"&&s!=="*"?`Semanalmente, ${((l=uk.find(f=>f.value===s))==null?void 0:l.label)||`dia ${s}`} às ${i.padStart(2,"0")}:${n.padStart(2,"0")}`:s==="*"&&r!=="*"?`Mensalmente, dia ${r} às ${i.padStart(2,"0")}:${n.padStart(2,"0")}`:e}function MG(e){if(e===null)return"—";if(e<1e3)return`${e}ms`;const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),i=t%60;if(n<60)return`${n}m ${i}s`;const r=Math.floor(n/60),s=n%60;return`${r}h ${s}m`}function dT(e){return e?new Date(e).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"—"}function RG(e){switch(e){case"completed":return{label:"Sucesso",color:"var(--status-active)"};case"failed":return{label:"Falhou",color:"var(--status-error)"};case"running":return{label:"Executando",color:"var(--status-warning)"};default:return{label:e,color:"var(--text-muted)"}}}const Kf={width:"100%",padding:"6px 10px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.78rem",outline:"none"},Ds={...Kf,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center",paddingRight:"28px"},oa={fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:4,display:"block"},ts={padding:"6px 16px",borderRadius:"var(--radius-xs)",fontFamily:"var(--font-mono)",fontSize:"0.75rem",fontWeight:600,cursor:"pointer",border:"none",transition:"all 0.15s ease"};function fT({children:e,onClose:t,title:n,wide:i}){return _.jsx("div",{"data-testid":"modal-overlay",onClick:r=>{r.target===r.currentTarget&&t()},style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"var(--sp-4)",animation:"fadeIn 0.15s var(--ease-out) both"},children:_.jsxs("div",{"data-testid":"modal-content",style:{background:"var(--surface-1)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",width:"100%",maxWidth:i?900:560,maxHeight:"90vh",display:"flex",flexDirection:"column",animation:"fadeInUp 0.2s var(--ease-out) both"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--border-subtle)",flexShrink:0},children:[_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"0.9rem",color:"var(--text-primary)"},children:n}),_.jsx("button",{onClick:t,style:{...ts,padding:"4px 8px",fontSize:"0.7rem",background:"none",border:"none",color:"var(--text-muted)"},children:"✕"})]}),_.jsx("div",{style:{overflow:"auto",flex:1},children:e})]})})}function kG(){var sr,Ee,ke;const e=ua(oe=>oe.jobs),t=ua(oe=>oe.loading),n=ua(oe=>oe.fetchJobs),i=ua(oe=>oe.createJob),r=ua(oe=>oe.deleteJob),s=ua(oe=>oe.pauseJob),l=ua(oe=>oe.resumeJob),c=ua(oe=>oe.triggerJob),f=ua(oe=>oe.history),p=ua(oe=>oe.historyLoading),m=ua(oe=>oe.fetchHistory),g=vr(oe=>oe.squads),[x,v]=j.useState(!1),[S,A]=j.useState(null),[T,C]=j.useState(null),[N,R]=j.useState(null),[O,H]=j.useState(""),[D,F]=j.useState(""),[Z,V]=j.useState("daily"),[Y,P]=j.useState("0"),[q,ne]=j.useState("9"),[I,$]=j.useState("1"),[z,G]=j.useState("1"),[Q,W]=j.useState("30"),[B,K]=j.useState("2"),[J,X]=j.useState(""),[ce,ie]=j.useState(""),[de,ye]=j.useState("America/Sao_Paulo"),[me,le]=j.useState("30"),[Re,Le]=j.useState("0");j.useEffect(()=>{n()},[n]);const je=j.useCallback(()=>{F(""),V("daily"),P("0"),ne("9"),$("1"),G("1"),W("30"),K("2"),X(""),ie(""),ye("America/Sao_Paulo"),le("30"),Le("0"),A(null)},[]),He=()=>{v(!1),je()},Qe=()=>{je(),v(!0)},ot=oe=>{F(oe.squad_name),ie(oe.prompt||""),ye(oe.timezone||"America/Sao_Paulo"),le(String(oe.timeout_minutes||30)),Le(String(oe.retry_on_failure||0)),A(oe.squad_name);const Pe=oe.cron_expression.split(" ");if(Pe.length===5){const[ct,tn,ci,,Qt]=Pe;ct.startsWith("*/")?(V("every_n_minutes"),W(ct.replace("*/",""))):tn.startsWith("*/")?(V("every_n_hours"),K(tn.replace("*/","")),P(ct)):tn==="*"?(V("hourly"),P(ct)):ci==="*"&&Qt==="*"?(V("daily"),P(ct),ne(tn)):ci==="*"&&Qt!=="*"?(V("weekly"),P(ct),ne(tn),$(Qt)):Qt==="*"&&ci!=="*"?(V("monthly"),P(ct),ne(tn),G(ci)):(V("custom"),X(oe.cron_expression))}else V("custom"),X(oe.cron_expression);v(!0)},Ue=Z==="custom"?J:AG(Z,{minute:Y,hour:q,dayOfMonth:z,dayOfWeek:I,everyNMinutes:Q,everyNHours:B}),wt=async()=>{if(!D||!Ue||!ce.trim())return;const oe={squad_name:D,cron_expression:Ue,prompt:ce.trim(),timezone:de||void 0,timeout_minutes:parseInt(me)||30,retry_on_failure:parseInt(Re)||0};await i(oe)&&He()},_n=oe=>{C(oe),R(null),m(oe)},Sn=()=>{C(null),R(null)},hn=oe=>oe==="active"?"var(--status-active)":oe==="paused"?"var(--status-warning)":"var(--status-error)",oi=oe=>oe==="active"?"var(--status-active-glow)":oe==="paused"?"var(--status-warning-glow)":"var(--status-error-glow)",Ur=g.filter(oe=>!e.some(Pe=>Pe.squad_name===oe.code)),Ci=O.toLowerCase(),Wt=O?e.filter(oe=>{var Pe;return oe.squad_name.toLowerCase().includes(Ci)||((Pe=oe.prompt)==null?void 0:Pe.toLowerCase().includes(Ci))||oe.status.toLowerCase().includes(Ci)||_v(oe.cron_expression).toLowerCase().includes(Ci)}):e;return _.jsxs("div",{style:{padding:"var(--sp-6)",animation:"fadeIn 0.4s var(--ease-out) both",width:"100%",boxSizing:"border-box"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"var(--sp-4)"},children:[_.jsxs("div",{children:[_.jsx("h2",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1.1rem",color:"var(--text-primary)",marginBottom:"var(--sp-1)"},children:"Scheduler"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"Autonomous job execution and monitoring"})]}),_.jsx("button",{"data-testid":"btn-new-schedule",onClick:Qe,style:{...ts,background:"var(--accent)",color:"var(--text-inverse)"},children:"+ New Schedule"})]}),e.length>0&&_.jsx("div",{style:{marginBottom:"var(--sp-4)"},children:_.jsx("input",{"data-testid":"search-jobs",type:"text",placeholder:"Search by name, prompt, status...",value:O,onChange:oe=>H(oe.target.value),style:{...Kf,maxWidth:400,paddingLeft:32,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"10px center"}})}),t&&_.jsx("p",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.8rem",animation:"pulse 1.5s ease-in-out infinite"},children:"Loading jobs..."}),!t&&e.length===0&&!x&&_.jsxs("div",{style:{padding:"var(--sp-8)",textAlign:"center",color:"var(--text-muted)"},children:[_.jsx("div",{style:{fontSize:"1.5rem",marginBottom:"var(--sp-3)"},children:"⏣"}),_.jsx("p",{style:{fontSize:"0.85rem",marginBottom:"var(--sp-2)"},children:"No scheduled jobs"}),_.jsxs("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:["Click ",_.jsx("strong",{children:"+ New Schedule"})," to create your first automated job."]})]}),_.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"var(--sp-3)",width:"100%"},children:Wt.map((oe,Pe)=>_.jsxs("div",{"data-testid":`job-${oe.squad_name}`,style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-3)",transition:"all var(--duration-fast) var(--ease-out)",animation:`fadeInUp 0.4s var(--ease-out) ${Pe*40}ms both`,display:"flex",flexDirection:"column",gap:"var(--sp-2)"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[_.jsx("span",{style:{fontWeight:600,fontSize:"0.82rem",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:oe.squad_name}),_.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:hn(oe.status),flexShrink:0,marginLeft:"var(--sp-2)"},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:hn(oe.status),boxShadow:`0 0 8px ${oi(oe.status)}`,display:"inline-block",animation:oe.status==="active"?"statusPulse 2s ease-in-out infinite":"none"}}),oe.status]})]}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-secondary)",display:"flex",alignItems:"center",gap:"var(--sp-2)"},children:[_.jsx("code",{style:{background:"var(--surface-3)",padding:"1px 5px",borderRadius:"var(--radius-xs)",fontSize:"0.6rem",flexShrink:0},children:oe.cron_expression}),_.jsx("span",{style:{color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_v(oe.cron_expression)})]}),oe.prompt&&_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.63rem",color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"4px 8px",background:"var(--surface-3)",borderRadius:"var(--radius-xs)"},children:oe.prompt}),oe.last_run_at&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)"},children:["Last: ",new Date(oe.last_run_at).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"}),oe.last_result&&_.jsxs("span",{children:[" — ",oe.last_result]})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-1)",flexWrap:"wrap",marginTop:"auto"},children:[_.jsx("button",{onClick:()=>ot(oe),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:"Edit"}),oe.status==="active"?_.jsx("button",{onClick:()=>s(oe.squad_name),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",color:"var(--status-warning)"},children:"Pause"}):_.jsx("button",{onClick:()=>l(oe.squad_name),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",color:"var(--status-active)"},children:"Resume"}),_.jsx("button",{onClick:()=>c(oe.squad_name),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"var(--accent)",color:"var(--text-inverse)"},children:"Trigger"}),_.jsx("button",{"data-testid":`btn-history-${oe.squad_name}`,onClick:()=>_n(oe.squad_name),style:{...ts,padding:"3px 8px",fontSize:"0.62rem",background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-muted)"},children:"Log"}),_.jsx("button",{onClick:()=>{confirm(`Delete schedule for ${oe.squad_name}?`)&&r(oe.squad_name)},style:{...ts,padding:"3px 6px",fontSize:"0.62rem",background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",marginLeft:"auto"},title:"Delete schedule",children:"✕"})]})]},oe.squad_name))}),!t&&O&&Wt.length===0&&e.length>0&&_.jsxs("div",{style:{padding:"var(--sp-6)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)"},children:['No jobs matching "',O,'"']}),x&&_.jsx(fT,{title:S?"Edit Schedule":"New Schedule",onClose:He,children:_.jsxs("div",{"data-testid":"schedule-form",style:{padding:"var(--sp-4)"},children:[_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("label",{style:oa,children:"Squad"}),S?_.jsx("div",{style:{...Kf,background:"var(--surface-3)",color:"var(--text-secondary)"},children:S}):_.jsxs("select",{"data-testid":"select-squad",value:D,onChange:oe=>F(oe.target.value),style:Ds,children:[_.jsx("option",{value:"",children:"Select a squad..."}),Ur.map(oe=>_.jsxs("option",{value:oe.code,children:[oe.name," (",oe.code,")"]},oe.code)),e.length===0&&g.length===0&&_.jsx("option",{disabled:!0,children:"No squads available"})]})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("label",{style:oa,children:"Frequency"}),_.jsxs("select",{"data-testid":"select-frequency",value:Z,onChange:oe=>V(oe.target.value),style:Ds,children:[_.jsx("option",{value:"every_n_minutes",children:"Every N minutes"}),_.jsx("option",{value:"every_n_hours",children:"Every N hours"}),_.jsx("option",{value:"hourly",children:"Hourly"}),_.jsx("option",{value:"daily",children:"Daily"}),_.jsx("option",{value:"weekly",children:"Weekly"}),_.jsx("option",{value:"monthly",children:"Monthly"}),_.jsx("option",{value:"custom",children:"Custom cron"})]})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-3)",marginBottom:"var(--sp-4)",flexWrap:"wrap"},children:[Z==="every_n_minutes"&&_.jsxs("div",{style:{flex:1,minWidth:120},children:[_.jsx("label",{style:oa,children:"Every (minutes)"}),_.jsx("select",{value:Q,onChange:oe=>W(oe.target.value),style:Ds,children:[1,2,5,10,15,20,30].map(oe=>_.jsx("option",{value:String(oe),children:oe},oe))})]}),Z==="every_n_hours"&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{flex:1,minWidth:120},children:[_.jsx("label",{style:oa,children:"Every (hours)"}),_.jsx("select",{value:B,onChange:oe=>K(oe.target.value),style:Ds,children:[2,3,4,6,8,12].map(oe=>_.jsx("option",{value:String(oe),children:oe},oe))})]}),_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"At minute"}),_.jsx("select",{value:Y,onChange:oe=>P(oe.target.value),style:Ds,children:Array.from({length:60},(oe,Pe)=>_.jsx("option",{value:String(Pe),children:String(Pe).padStart(2,"0")},Pe))})]})]}),Z==="hourly"&&_.jsxs("div",{style:{flex:1,minWidth:120},children:[_.jsx("label",{style:oa,children:"At minute"}),_.jsx("select",{value:Y,onChange:oe=>P(oe.target.value),style:Ds,children:Array.from({length:60},(oe,Pe)=>_.jsx("option",{value:String(Pe),children:String(Pe).padStart(2,"0")},Pe))})]}),(Z==="daily"||Z==="weekly"||Z==="monthly")&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"Hour"}),_.jsx("select",{value:q,onChange:oe=>ne(oe.target.value),style:Ds,children:Array.from({length:24},(oe,Pe)=>_.jsx("option",{value:String(Pe),children:String(Pe).padStart(2,"0")},Pe))})]}),_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"Minute"}),_.jsx("select",{value:Y,onChange:oe=>P(oe.target.value),style:Ds,children:Array.from({length:60},(oe,Pe)=>_.jsx("option",{value:String(Pe),children:String(Pe).padStart(2,"0")},Pe))})]})]}),Z==="weekly"&&_.jsxs("div",{style:{flex:1,minWidth:140},children:[_.jsx("label",{style:oa,children:"Day of week"}),_.jsx("select",{value:I,onChange:oe=>$(oe.target.value),style:Ds,children:uk.map(oe=>_.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),Z==="monthly"&&_.jsxs("div",{style:{flex:1,minWidth:120},children:[_.jsx("label",{style:oa,children:"Day of month"}),_.jsx("select",{value:z,onChange:oe=>G(oe.target.value),style:Ds,children:Array.from({length:31},(oe,Pe)=>_.jsx("option",{value:String(Pe+1),children:Pe+1},Pe+1))})]}),Z==="custom"&&_.jsxs("div",{style:{flex:1,minWidth:200},children:[_.jsx("label",{style:oa,children:"Cron expression"}),_.jsx("input",{type:"text",placeholder:"* * * * *",value:J,onChange:oe=>X(oe.target.value),style:Kf})]})]}),Ue&&_.jsxs("div",{style:{marginBottom:"var(--sp-4)",padding:"8px 12px",background:"var(--surface-3)",borderRadius:"var(--radius-xs)",border:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono)",fontSize:"0.72rem",display:"flex",alignItems:"center",gap:"var(--sp-3)"},children:[_.jsx("code",{style:{color:"var(--accent)",fontWeight:600},children:Ue}),_.jsx("span",{style:{color:"var(--text-muted)"},children:"—"}),_.jsx("span",{"data-testid":"cron-preview",style:{color:"var(--text-secondary)"},children:_v(Ue)})]}),_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("label",{style:oa,children:"Instruction for the agent"}),_.jsx("textarea",{"data-testid":"input-prompt",placeholder:"What should the squad do on each execution?",value:ce,onChange:oe=>ie(oe.target.value),rows:3,style:{...Kf,resize:"vertical",lineHeight:1.5}})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-3)",marginBottom:"var(--sp-4)",flexWrap:"wrap"},children:[_.jsxs("div",{style:{flex:2,minWidth:180},children:[_.jsx("label",{style:oa,children:"Timezone"}),_.jsxs("select",{value:de,onChange:oe=>ye(oe.target.value),style:Ds,children:[_.jsx("option",{value:"America/Sao_Paulo",children:"America/Sao_Paulo"}),_.jsx("option",{value:"America/New_York",children:"America/New_York"}),_.jsx("option",{value:"America/Chicago",children:"America/Chicago"}),_.jsx("option",{value:"America/Los_Angeles",children:"America/Los_Angeles"}),_.jsx("option",{value:"Europe/London",children:"Europe/London"}),_.jsx("option",{value:"Europe/Berlin",children:"Europe/Berlin"}),_.jsx("option",{value:"Asia/Tokyo",children:"Asia/Tokyo"}),_.jsx("option",{value:"UTC",children:"UTC"})]})]}),_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"Timeout (min)"}),_.jsx("input",{type:"number",min:1,max:480,value:me,onChange:oe=>le(oe.target.value),style:Kf})]}),_.jsxs("div",{style:{flex:1,minWidth:100},children:[_.jsx("label",{style:oa,children:"Retries"}),_.jsx("select",{value:Re,onChange:oe=>Le(oe.target.value),style:Ds,children:[0,1,2,3,4,5].map(oe=>_.jsx("option",{value:String(oe),children:oe},oe))})]})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)"},children:[_.jsx("button",{"data-testid":"btn-save-schedule",onClick:wt,disabled:!D||!Ue||!ce.trim(),style:{...ts,background:D&&Ue&&ce.trim()?"var(--accent)":"var(--surface-4)",color:D&&Ue&&ce.trim()?"var(--text-inverse)":"var(--text-muted)"},children:S?"Update":"Create"}),_.jsx("button",{onClick:He,style:{...ts,background:"none",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:"Cancel"})]})]})}),T&&_.jsx(fT,{title:`Execution Log — ${T}`,onClose:Sn,wide:!0,children:_.jsxs("div",{"data-testid":`history-${T}`,children:[_.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"6px 12px",borderBottom:"1px solid var(--border-subtle)"},children:_.jsxs("button",{"data-testid":`btn-refresh-${T}`,onClick:()=>m(T),disabled:p[T],style:{...ts,padding:"3px 10px",fontSize:"0.62rem",background:"none",border:"1px solid var(--border-subtle)",color:p[T]?"var(--text-muted)":"var(--text-secondary)",display:"inline-flex",alignItems:"center",gap:4},children:[_.jsx("span",{style:{display:"inline-block",animation:p[T]?"spin 1s linear infinite":"none"},children:"↻"}),"Refresh"]})}),p[T]&&_.jsx("div",{style:{padding:"var(--sp-3)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"Loading..."}),!p[T]&&(!f[T]||f[T].length===0)&&_.jsx("div",{style:{padding:"var(--sp-6)",textAlign:"center",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"No executions recorded yet."}),!p[T]&&((sr=f[T])==null?void 0:sr.length)>0&&_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontFamily:"var(--font-mono)",fontSize:"0.68rem"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{background:"var(--surface-3)"},children:["Status","Started","Finished","Duration","Attempt","Output"].map(oe=>_.jsx("th",{style:{padding:"6px 8px",textAlign:"left",fontWeight:600,fontSize:"0.6rem",textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",borderBottom:"1px solid var(--border-subtle)"},children:oe},oe))})}),_.jsx("tbody",{children:f[T].map(oe=>{const Pe=RG(oe.status),ct=N===oe.id;return _.jsxs("tr",{"data-testid":`activity-${oe.id}`,style:{borderBottom:"1px solid var(--border-subtle)",transition:"background 0.1s"},onMouseEnter:tn=>{tn.currentTarget.style.background="var(--surface-3)"},onMouseLeave:tn=>{tn.currentTarget.style.background="transparent"},children:[_.jsx("td",{style:{padding:"6px 8px"},children:_.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:Pe.color,fontWeight:600},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:Pe.color,display:"inline-block",animation:oe.status==="running"?"statusPulse 2s ease-in-out infinite":"none"}}),Pe.label]})}),_.jsx("td",{style:{padding:"6px 8px",color:"var(--text-secondary)"},children:dT(oe.started_at)}),_.jsx("td",{style:{padding:"6px 8px",color:"var(--text-secondary)"},children:dT(oe.finished_at)}),_.jsx("td",{style:{padding:"6px 8px",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:MG(oe.duration_ms)}),_.jsx("td",{style:{padding:"6px 8px",color:"var(--text-muted)",textAlign:"center"},children:oe.attempt??1}),_.jsx("td",{style:{padding:"6px 8px"},children:oe.result_summary?_.jsx("button",{"data-testid":`btn-output-${oe.id}`,onClick:()=>R(ct?null:oe.id),style:{...ts,padding:"2px 8px",fontSize:"0.62rem",background:ct?"var(--accent)":"var(--surface-4)",color:ct?"var(--text-inverse)":"var(--text-secondary)",border:"none"},children:ct?"Hide":"View"}):_.jsx("span",{style:{color:"var(--text-muted)"},children:"—"})})]},oe.id)})})]}),N&&((Ee=f[T])==null?void 0:Ee.find(oe=>oe.id===N))&&_.jsxs("div",{"data-testid":`output-panel-${N}`,style:{padding:"var(--sp-3)",background:"var(--surface-0)",borderTop:"1px solid var(--border-subtle)"},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--sp-2)"},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)"},children:"Output"}),_.jsx("button",{onClick:()=>R(null),style:{...ts,padding:"2px 6px",fontSize:"0.6rem",background:"none",border:"none",color:"var(--text-muted)"},children:"✕"})]}),_.jsx("pre",{style:{fontFamily:"var(--font-mono)",fontSize:"0.68rem",color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0,lineHeight:1.6,padding:"var(--sp-3)",background:"var(--surface-2)",borderRadius:"var(--radius-xs)",border:"1px solid var(--border-subtle)"},children:(ke=f[T].find(oe=>oe.id===N))==null?void 0:ke.result_summary})]})]})})]})}const hl=fu(e=>({leads:[],campaigns:[],lists:[],tags:[],total:0,loading:!1,fetchLeads:async(t={})=>{e({loading:!0});try{const n=new URLSearchParams(t),i=await fetch(`/api/email/leads?${n}`);if(i.ok){const r=await i.json();e({leads:r.data,total:r.total})}}finally{e({loading:!1})}},fetchCampaigns:async(t={})=>{e({loading:!0});try{const n=new URLSearchParams(t),i=await fetch(`/api/email/campaigns?${n}`);if(i.ok){const r=await i.json();e({campaigns:r.data})}}finally{e({loading:!1})}},fetchLists:async()=>{const t=await fetch("/api/email/leads/lists");if(t.ok){const n=await t.json();e({lists:n.lists})}},fetchTags:async()=>{const t=await fetch("/api/email/leads/tags");if(t.ok){const n=await t.json();e({tags:n.tags})}}}));function NG(){const e=hl(g=>g.leads),t=hl(g=>g.total),n=hl(g=>g.lists),i=hl(g=>g.tags),r=hl(g=>g.loading),s=hl(g=>g.fetchLeads),l=hl(g=>g.fetchLists),c=hl(g=>g.fetchTags),[f,p]=j.useState("");j.useEffect(()=>{s(),l(),c()},[s,l,c]);const m=()=>{s(f?{search:f}:{})};return _.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-4)"},children:[_.jsxs("div",{style:{display:"flex",gap:"var(--sp-3)"},children:[_.jsx(Sv,{label:"Total Leads",value:t}),_.jsx(Sv,{label:"Lists",value:n.length}),_.jsx(Sv,{label:"Tags",value:i.length})]}),_.jsxs("div",{style:{display:"flex",gap:"var(--sp-2)"},children:[_.jsx("input",{type:"text",placeholder:"Search leads...",value:f,onChange:g=>p(g.target.value),onKeyDown:g=>g.key==="Enter"&&m(),style:{flex:1,padding:"8px 12px",background:"var(--surface-2)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",color:"var(--text-primary)",fontFamily:"var(--font-body)",fontSize:"0.82rem"}}),_.jsx("button",{onClick:m,className:"btn-ghost",style:{padding:"8px 16px",background:"var(--accent-glow)",border:"1px solid rgba(0, 200, 255, 0.2)",borderRadius:"var(--radius-sm)",color:"var(--accent)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:"Search"})]}),r?_.jsx("div",{style:{textAlign:"center",padding:"var(--sp-6)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:"Loading..."}):_.jsx("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["Email","Name","Company","Status","Source","Created"].map(g=>_.jsx("th",{style:{textAlign:"left",padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",fontWeight:600},children:g},g))})}),_.jsxs("tbody",{children:[e.map(g=>_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("td",{style:fa,children:g.email}),_.jsx("td",{style:fa,children:g.name||"—"}),_.jsx("td",{style:fa,children:g.company||"—"}),_.jsx("td",{style:fa,children:_.jsx(dk,{status:g.status})}),_.jsx("td",{style:fa,children:g.source||"—"}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:new Date(g.created_at).toLocaleDateString()})]},g.id)),e.length===0&&_.jsx("tr",{children:_.jsx("td",{colSpan:6,style:{...fa,textAlign:"center",color:"var(--text-muted)"},children:"No leads found"})})]})]})})]})}function OG(){const e=hl(i=>i.campaigns),t=hl(i=>i.loading),n=hl(i=>i.fetchCampaigns);return j.useEffect(()=>{n()},[n]),_.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--sp-4)"},children:t?_.jsx("div",{style:{textAlign:"center",padding:"var(--sp-6)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.75rem"},children:"Loading..."}):_.jsx("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:_.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[_.jsx("thead",{children:_.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["Name","Subject","Status","Recipients","Sent","Bounced","Created"].map(i=>_.jsx("th",{style:{textAlign:"left",padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",fontWeight:600},children:i},i))})}),_.jsxs("tbody",{children:[e.map(i=>_.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[_.jsx("td",{style:fa,children:i.name}),_.jsx("td",{style:fa,children:i.subject}),_.jsx("td",{style:fa,children:_.jsx(dk,{status:i.status})}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)"},children:i.total_recipients}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)"},children:i.sent_count}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)"},children:i.bounce_count}),_.jsx("td",{style:{...fa,fontFamily:"var(--font-mono)",fontSize:"0.7rem"},children:new Date(i.created_at).toLocaleDateString()})]},i.id)),e.length===0&&_.jsx("tr",{children:_.jsx("td",{colSpan:7,style:{...fa,textAlign:"center",color:"var(--text-muted)"},children:"No campaigns yet"})})]})]})})})}function DG(){return _.jsxs("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-4)"},children:[_.jsx("h3",{style:{fontFamily:"var(--font-display)",fontSize:"0.9rem",color:"var(--text-primary)",marginBottom:"var(--sp-3)"},children:"Amazon SES Configuration"}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)",lineHeight:1.8},children:[_.jsx("p",{children:"Configure these environment variables on the server:"}),_.jsxs("div",{style:{background:"var(--surface-2)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",padding:"var(--sp-3)",marginTop:"var(--sp-2)"},children:[_.jsx("code",{children:"AWS_ACCESS_KEY_ID=..."}),_.jsx("br",{}),_.jsx("code",{children:"AWS_SECRET_ACCESS_KEY=..."}),_.jsx("br",{}),_.jsx("code",{children:"AWS_REGION=us-east-1"}),_.jsx("br",{}),_.jsx("code",{children:"SES_FROM_EMAIL=noreply@yourdomain.com"}),_.jsx("br",{}),_.jsx("code",{children:"SES_RATE_LIMIT=14"}),_.jsx("br",{}),_.jsx("code",{children:"SERVER_URL=https://yourdomain.com"})]})]})]})}function Sv({label:e,value:t}){return _.jsxs("div",{style:{flex:1,background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",padding:"var(--sp-3)"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:"var(--sp-1)"},children:e}),_.jsx("div",{style:{fontFamily:"var(--font-display)",fontSize:"1.4rem",fontWeight:700,color:"var(--accent)"},children:t})]})}function dk({status:e}){const n={active:{bg:"rgba(0, 230, 138, 0.1)",text:"var(--status-active)"},unsubscribed:{bg:"rgba(255, 100, 100, 0.1)",text:"var(--status-error)"},draft:{bg:"rgba(150, 150, 150, 0.1)",text:"var(--text-muted)"},queued:{bg:"rgba(0, 200, 255, 0.1)",text:"var(--accent)"},sending:{bg:"rgba(255, 180, 0, 0.1)",text:"var(--status-warning)"},sent:{bg:"rgba(0, 230, 138, 0.1)",text:"var(--status-active)"},paused:{bg:"rgba(255, 180, 0, 0.1)",text:"var(--status-warning)"},cancelled:{bg:"rgba(255, 100, 100, 0.1)",text:"var(--status-error)"}}[e]||{bg:"rgba(150, 150, 150, 0.1)",text:"var(--text-muted)"};return _.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:"var(--radius-xs)",background:n.bg,color:n.text,fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:e})}const fa={padding:"10px 14px",fontSize:"0.82rem",color:"var(--text-secondary)"};function zG(){const[e,t]=j.useState("leads"),n=[{key:"leads",label:"Leads"},{key:"campaigns",label:"Campaigns"},{key:"settings",label:"Settings"}];return _.jsxs("div",{style:{padding:"var(--sp-4)",maxWidth:1100,margin:"0 auto"},children:[_.jsxs("div",{style:{marginBottom:"var(--sp-4)"},children:[_.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:"1.1rem",fontWeight:700,color:"var(--text-primary)",marginBottom:"var(--sp-1)"},children:"Email Engine"}),_.jsx("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)"},children:"Lead management, campaigns, and Amazon SES integration"})]}),_.jsx("div",{style:{display:"flex",gap:"var(--sp-1)",marginBottom:"var(--sp-4)",borderBottom:"1px solid var(--border-subtle)",paddingBottom:"var(--sp-1)"},children:n.map(i=>_.jsx("button",{onClick:()=>t(i.key),style:{padding:"8px 16px",background:e===i.key?"var(--accent-glow)":"transparent",border:e===i.key?"1px solid rgba(0, 200, 255, 0.15)":"1px solid transparent",borderRadius:"var(--radius-sm)",color:e===i.key?"var(--accent)":"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-display)",fontSize:"0.82rem",fontWeight:e===i.key?600:400,transition:"all var(--duration-fast) var(--ease-out)"},children:i.label},i.key))}),e==="leads"&&_.jsx(NG,{}),e==="campaigns"&&_.jsx(OG,{}),e==="settings"&&_.jsx(DG,{})]})}function zi(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n<e.length;n++)(i=zi(e[n]))!==""&&(t+=(t&&" ")+i);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var BG={value:()=>{}};function fx(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new b0(n)}function b0(e){this._=e}function LG(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}b0.prototype=fx.prototype={constructor:b0,on:function(e,t){var n=this._,i=LG(e+"",n),r,s=-1,l=i.length;if(arguments.length<2){for(;++s<l;)if((r=(e=i[s]).type)&&(r=jG(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<l;)if(r=(e=i[s]).type)n[r]=hT(n[r],e.name,t);else if(t==null)for(r in n)n[r]=hT(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new b0(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,s;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],i=0,r=s.length;i<r;++i)s[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)}};function jG(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function hT(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=BG,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var k1="http://www.w3.org/1999/xhtml";const pT={svg:"http://www.w3.org/2000/svg",xhtml:k1,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function hx(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),pT.hasOwnProperty(t)?{space:pT[t],local:e}:e}function IG(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===k1&&t.documentElement.namespaceURI===k1?t.createElement(e):t.createElementNS(n,e)}}function UG(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function fk(e){var t=hx(e);return(t.local?UG:IG)(t)}function HG(){}function I_(e){return e==null?HG:function(){return this.querySelector(e)}}function PG(e){typeof e!="function"&&(e=I_(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],l=s.length,c=i[r]=new Array(l),f,p,m=0;m<l;++m)(f=s[m])&&(p=e.call(f,f.__data__,m,s))&&("__data__"in f&&(p.__data__=f.__data__),c[m]=p);return new as(i,this._parents)}function FG(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function GG(){return[]}function hk(e){return e==null?GG:function(){return this.querySelectorAll(e)}}function qG(e){return function(){return FG(e.apply(this,arguments))}}function YG(e){typeof e=="function"?e=qG(e):e=hk(e);for(var t=this._groups,n=t.length,i=[],r=[],s=0;s<n;++s)for(var l=t[s],c=l.length,f,p=0;p<c;++p)(f=l[p])&&(i.push(e.call(f,f.__data__,p,l)),r.push(f));return new as(i,r)}function pk(e){return function(){return this.matches(e)}}function mk(e){return function(t){return t.matches(e)}}var VG=Array.prototype.find;function XG(e){return function(){return VG.call(this.children,e)}}function KG(){return this.firstElementChild}function $G(e){return this.select(e==null?KG:XG(typeof e=="function"?e:mk(e)))}var WG=Array.prototype.filter;function QG(){return Array.from(this.children)}function ZG(e){return function(){return WG.call(this.children,e)}}function JG(e){return this.selectAll(e==null?QG:ZG(typeof e=="function"?e:mk(e)))}function eq(e){typeof e!="function"&&(e=pk(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],l=s.length,c=i[r]=[],f,p=0;p<l;++p)(f=s[p])&&e.call(f,f.__data__,p,s)&&c.push(f);return new as(i,this._parents)}function gk(e){return new Array(e.length)}function tq(){return new as(this._enter||this._groups.map(gk),this._parents)}function H0(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}H0.prototype={constructor:H0,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function nq(e){return function(){return e}}function iq(e,t,n,i,r,s){for(var l=0,c,f=t.length,p=s.length;l<p;++l)(c=t[l])?(c.__data__=s[l],i[l]=c):n[l]=new H0(e,s[l]);for(;l<f;++l)(c=t[l])&&(r[l]=c)}function rq(e,t,n,i,r,s,l){var c,f,p=new Map,m=t.length,g=s.length,x=new Array(m),v;for(c=0;c<m;++c)(f=t[c])&&(x[c]=v=l.call(f,f.__data__,c,t)+"",p.has(v)?r[c]=f:p.set(v,f));for(c=0;c<g;++c)v=l.call(e,s[c],c,s)+"",(f=p.get(v))?(i[c]=f,f.__data__=s[c],p.delete(v)):n[c]=new H0(e,s[c]);for(c=0;c<m;++c)(f=t[c])&&p.get(x[c])===f&&(r[c]=f)}function aq(e){return e.__data__}function sq(e,t){if(!arguments.length)return Array.from(this,aq);var n=t?rq:iq,i=this._parents,r=this._groups;typeof e!="function"&&(e=nq(e));for(var s=r.length,l=new Array(s),c=new Array(s),f=new Array(s),p=0;p<s;++p){var m=i[p],g=r[p],x=g.length,v=lq(e.call(m,m&&m.__data__,p,i)),S=v.length,A=c[p]=new Array(S),T=l[p]=new Array(S),C=f[p]=new Array(x);n(m,g,A,T,C,v,t);for(var N=0,R=0,O,H;N<S;++N)if(O=A[N]){for(N>=R&&(R=N+1);!(H=T[R])&&++R<S;);O._next=H||null}}return l=new as(l,i),l._enter=c,l._exit=f,l}function lq(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function oq(){return new as(this._exit||this._groups.map(gk),this._parents)}function cq(e,t,n){var i=this.enter(),r=this,s=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),i&&r?i.merge(r).order():r}function uq(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,s=i.length,l=Math.min(r,s),c=new Array(r),f=0;f<l;++f)for(var p=n[f],m=i[f],g=p.length,x=c[f]=new Array(g),v,S=0;S<g;++S)(v=p[S]||m[S])&&(x[S]=v);for(;f<r;++f)c[f]=n[f];return new as(c,this._parents)}function dq(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,s=i[r],l;--r>=0;)(l=i[r])&&(s&&l.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(l,s),s=l);return this}function fq(e){e||(e=hq);function t(g,x){return g&&x?e(g.__data__,x.__data__):!g-!x}for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var l=n[s],c=l.length,f=r[s]=new Array(c),p,m=0;m<c;++m)(p=l[m])&&(f[m]=p);f.sort(t)}return new as(r,this._parents).order()}function hq(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function pq(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function mq(){return Array.from(this)}function gq(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length;r<s;++r){var l=i[r];if(l)return l}return null}function yq(){let e=0;for(const t of this)++e;return e}function xq(){return!this.node()}function bq(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],s=0,l=r.length,c;s<l;++s)(c=r[s])&&e.call(c,c.__data__,s,r);return this}function vq(e){return function(){this.removeAttribute(e)}}function _q(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Sq(e,t){return function(){this.setAttribute(e,t)}}function Eq(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function wq(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Tq(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Cq(e,t){var n=hx(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?_q:vq:typeof t=="function"?n.local?Tq:wq:n.local?Eq:Sq)(n,t))}function yk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Aq(e){return function(){this.style.removeProperty(e)}}function Mq(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Rq(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function kq(e,t,n){return arguments.length>1?this.each((t==null?Aq:typeof t=="function"?Rq:Mq)(e,t,n??"")):hh(this.node(),e)}function hh(e,t){return e.style.getPropertyValue(t)||yk(e).getComputedStyle(e,null).getPropertyValue(t)}function Nq(e){return function(){delete this[e]}}function Oq(e,t){return function(){this[e]=t}}function Dq(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function zq(e,t){return arguments.length>1?this.each((t==null?Nq:typeof t=="function"?Dq:Oq)(e,t)):this.node()[e]}function xk(e){return e.trim().split(/^|\s+/)}function U_(e){return e.classList||new bk(e)}function bk(e){this._node=e,this._names=xk(e.getAttribute("class")||"")}bk.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function vk(e,t){for(var n=U_(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function _k(e,t){for(var n=U_(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function Bq(e){return function(){vk(this,e)}}function Lq(e){return function(){_k(this,e)}}function jq(e,t){return function(){(t.apply(this,arguments)?vk:_k)(this,e)}}function Iq(e,t){var n=xk(e+"");if(arguments.length<2){for(var i=U_(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?jq:t?Bq:Lq)(n,t))}function Uq(){this.textContent=""}function Hq(e){return function(){this.textContent=e}}function Pq(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Fq(e){return arguments.length?this.each(e==null?Uq:(typeof e=="function"?Pq:Hq)(e)):this.node().textContent}function Gq(){this.innerHTML=""}function qq(e){return function(){this.innerHTML=e}}function Yq(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Vq(e){return arguments.length?this.each(e==null?Gq:(typeof e=="function"?Yq:qq)(e)):this.node().innerHTML}function Xq(){this.nextSibling&&this.parentNode.appendChild(this)}function Kq(){return this.each(Xq)}function $q(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Wq(){return this.each($q)}function Qq(e){var t=typeof e=="function"?e:fk(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Zq(){return null}function Jq(e,t){var n=typeof e=="function"?e:fk(e),i=t==null?Zq:typeof t=="function"?t:I_(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function eY(){var e=this.parentNode;e&&e.removeChild(this)}function tY(){return this.each(eY)}function nY(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function iY(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function rY(e){return this.select(e?iY:nY)}function aY(e){return arguments.length?this.property("__data__",e):this.node().__data__}function sY(e){return function(t){e.call(this,t,this.__data__)}}function lY(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function oY(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++i]=s;++i?t.length=i:delete this.__on}}}function cY(e,t,n){return function(){var i=this.__on,r,s=sY(t);if(i){for(var l=0,c=i.length;l<c;++l)if((r=i[l]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},i?i.push(r):this.__on=[r]}}function uY(e,t,n){var i=lY(e+""),r,s=i.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var f=0,p=c.length,m;f<p;++f)for(r=0,m=c[f];r<s;++r)if((l=i[r]).type===m.type&&l.name===m.name)return m.value}return}for(c=t?cY:oY,r=0;r<s;++r)this.each(c(i[r],t,n));return this}function Sk(e,t,n){var i=yk(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function dY(e,t){return function(){return Sk(this,e,t)}}function fY(e,t){return function(){return Sk(this,e,t.apply(this,arguments))}}function hY(e,t){return this.each((typeof t=="function"?fY:dY)(e,t))}function*pY(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length,l;r<s;++r)(l=i[r])&&(yield l)}var Ek=[null];function as(e,t){this._groups=e,this._parents=t}function rg(){return new as([[document.documentElement]],Ek)}function mY(){return this}as.prototype=rg.prototype={constructor:as,select:PG,selectAll:YG,selectChild:$G,selectChildren:JG,filter:eq,data:sq,enter:tq,exit:oq,join:cq,merge:uq,selection:mY,order:dq,sort:fq,call:pq,nodes:mq,node:gq,size:yq,empty:xq,each:bq,attr:Cq,style:kq,property:zq,classed:Iq,text:Fq,html:Vq,raise:Kq,lower:Wq,append:Qq,insert:Jq,remove:tY,clone:rY,datum:aY,on:uY,dispatch:hY,[Symbol.iterator]:pY};function ns(e){return typeof e=="string"?new as([[document.querySelector(e)]],[document.documentElement]):new as([[e]],Ek)}function gY(e){let t;for(;t=e.sourceEvent;)e=t;return e}function pl(e,t){if(e=gY(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const yY={passive:!1},Um={capture:!0,passive:!1};function Ev(e){e.stopImmediatePropagation()}function ih(e){e.preventDefault(),e.stopImmediatePropagation()}function wk(e){var t=e.document.documentElement,n=ns(e).on("dragstart.drag",ih,Um);"onselectstart"in t?n.on("selectstart.drag",ih,Um):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Tk(e,t){var n=e.document.documentElement,i=ns(e).on("dragstart.drag",null);t&&(i.on("click.drag",ih,Um),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const r0=e=>()=>e;function N1(e,{sourceEvent:t,subject:n,target:i,identifier:r,active:s,x:l,y:c,dx:f,dy:p,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:m}})}N1.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function xY(e){return!e.ctrlKey&&!e.button}function bY(){return this.parentNode}function vY(e,t){return t??{x:e.x,y:e.y}}function _Y(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ck(){var e=xY,t=bY,n=vY,i=_Y,r={},s=fx("start","drag","end"),l=0,c,f,p,m,g=0;function x(O){O.on("mousedown.drag",v).filter(i).on("touchstart.drag",T).on("touchmove.drag",C,yY).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(O,H){if(!(m||!e.call(this,O,H))){var D=R(this,t.call(this,O,H),O,H,"mouse");D&&(ns(O.view).on("mousemove.drag",S,Um).on("mouseup.drag",A,Um),wk(O.view),Ev(O),p=!1,c=O.clientX,f=O.clientY,D("start",O))}}function S(O){if(ih(O),!p){var H=O.clientX-c,D=O.clientY-f;p=H*H+D*D>g}r.mouse("drag",O)}function A(O){ns(O.view).on("mousemove.drag mouseup.drag",null),Tk(O.view,p),ih(O),r.mouse("end",O)}function T(O,H){if(e.call(this,O,H)){var D=O.changedTouches,F=t.call(this,O,H),Z=D.length,V,Y;for(V=0;V<Z;++V)(Y=R(this,F,O,H,D[V].identifier,D[V]))&&(Ev(O),Y("start",O,D[V]))}}function C(O){var H=O.changedTouches,D=H.length,F,Z;for(F=0;F<D;++F)(Z=r[H[F].identifier])&&(ih(O),Z("drag",O,H[F]))}function N(O){var H=O.changedTouches,D=H.length,F,Z;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),F=0;F<D;++F)(Z=r[H[F].identifier])&&(Ev(O),Z("end",O,H[F]))}function R(O,H,D,F,Z,V){var Y=s.copy(),P=pl(V||D,H),q,ne,I;if((I=n.call(O,new N1("beforestart",{sourceEvent:D,target:x,identifier:Z,active:l,x:P[0],y:P[1],dx:0,dy:0,dispatch:Y}),F))!=null)return q=I.x-P[0]||0,ne=I.y-P[1]||0,function $(z,G,Q){var W=P,B;switch(z){case"start":r[Z]=$,B=l++;break;case"end":delete r[Z],--l;case"drag":P=pl(Q||G,H),B=l;break}Y.call(z,O,new N1(z,{sourceEvent:G,subject:I,target:x,identifier:Z,active:B,x:P[0]+q,y:P[1]+ne,dx:P[0]-W[0],dy:P[1]-W[1],dispatch:Y}),F)}}return x.filter=function(O){return arguments.length?(e=typeof O=="function"?O:r0(!!O),x):e},x.container=function(O){return arguments.length?(t=typeof O=="function"?O:r0(O),x):t},x.subject=function(O){return arguments.length?(n=typeof O=="function"?O:r0(O),x):n},x.touchable=function(O){return arguments.length?(i=typeof O=="function"?O:r0(!!O),x):i},x.on=function(){var O=s.on.apply(s,arguments);return O===s?x:O},x.clickDistance=function(O){return arguments.length?(g=(O=+O)*O,x):Math.sqrt(g)},x}function H_(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ak(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function ag(){}var Hm=.7,P0=1/Hm,rh="\\s*([+-]?\\d+)\\s*",Pm="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",mo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",SY=/^#([0-9a-f]{3,8})$/,EY=new RegExp(`^rgb\\(${rh},${rh},${rh}\\)$`),wY=new RegExp(`^rgb\\(${mo},${mo},${mo}\\)$`),TY=new RegExp(`^rgba\\(${rh},${rh},${rh},${Pm}\\)$`),CY=new RegExp(`^rgba\\(${mo},${mo},${mo},${Pm}\\)$`),AY=new RegExp(`^hsl\\(${Pm},${mo},${mo}\\)$`),MY=new RegExp(`^hsla\\(${Pm},${mo},${mo},${Pm}\\)$`),mT={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};H_(ag,Ed,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:gT,formatHex:gT,formatHex8:RY,formatHsl:kY,formatRgb:yT,toString:yT});function gT(){return this.rgb().formatHex()}function RY(){return this.rgb().formatHex8()}function kY(){return Mk(this).formatHsl()}function yT(){return this.rgb().formatRgb()}function Ed(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=SY.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?xT(t):n===3?new Oa(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?a0(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?a0(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=EY.exec(e))?new Oa(t[1],t[2],t[3],1):(t=wY.exec(e))?new Oa(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=TY.exec(e))?a0(t[1],t[2],t[3],t[4]):(t=CY.exec(e))?a0(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=AY.exec(e))?_T(t[1],t[2]/100,t[3]/100,1):(t=MY.exec(e))?_T(t[1],t[2]/100,t[3]/100,t[4]):mT.hasOwnProperty(e)?xT(mT[e]):e==="transparent"?new Oa(NaN,NaN,NaN,0):null}function xT(e){return new Oa(e>>16&255,e>>8&255,e&255,1)}function a0(e,t,n,i){return i<=0&&(e=t=n=NaN),new Oa(e,t,n,i)}function NY(e){return e instanceof ag||(e=Ed(e)),e?(e=e.rgb(),new Oa(e.r,e.g,e.b,e.opacity)):new Oa}function O1(e,t,n,i){return arguments.length===1?NY(e):new Oa(e,t,n,i??1)}function Oa(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}H_(Oa,O1,Ak(ag,{brighter(e){return e=e==null?P0:Math.pow(P0,e),new Oa(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Hm:Math.pow(Hm,e),new Oa(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Oa(xd(this.r),xd(this.g),xd(this.b),F0(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:bT,formatHex:bT,formatHex8:OY,formatRgb:vT,toString:vT}));function bT(){return`#${yd(this.r)}${yd(this.g)}${yd(this.b)}`}function OY(){return`#${yd(this.r)}${yd(this.g)}${yd(this.b)}${yd((isNaN(this.opacity)?1:this.opacity)*255)}`}function vT(){const e=F0(this.opacity);return`${e===1?"rgb(":"rgba("}${xd(this.r)}, ${xd(this.g)}, ${xd(this.b)}${e===1?")":`, ${e})`}`}function F0(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function xd(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function yd(e){return e=xd(e),(e<16?"0":"")+e.toString(16)}function _T(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new yl(e,t,n,i)}function Mk(e){if(e instanceof yl)return new yl(e.h,e.s,e.l,e.opacity);if(e instanceof ag||(e=Ed(e)),!e)return new yl;if(e instanceof yl)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),s=Math.max(t,n,i),l=NaN,c=s-r,f=(s+r)/2;return c?(t===s?l=(n-i)/c+(n<i)*6:n===s?l=(i-t)/c+2:l=(t-n)/c+4,c/=f<.5?s+r:2-s-r,l*=60):c=f>0&&f<1?0:l,new yl(l,c,f,e.opacity)}function DY(e,t,n,i){return arguments.length===1?Mk(e):new yl(e,t,n,i??1)}function yl(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}H_(yl,DY,Ak(ag,{brighter(e){return e=e==null?P0:Math.pow(P0,e),new yl(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Hm:Math.pow(Hm,e),new yl(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new Oa(wv(e>=240?e-240:e+120,r,i),wv(e,r,i),wv(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new yl(ST(this.h),s0(this.s),s0(this.l),F0(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=F0(this.opacity);return`${e===1?"hsl(":"hsla("}${ST(this.h)}, ${s0(this.s)*100}%, ${s0(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ST(e){return e=(e||0)%360,e<0?e+360:e}function s0(e){return Math.max(0,Math.min(1,e||0))}function wv(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const P_=e=>()=>e;function zY(e,t){return function(n){return e+n*t}}function BY(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function LY(e){return(e=+e)==1?Rk:function(t,n){return n-t?BY(t,n,e):P_(isNaN(t)?n:t)}}function Rk(e,t){var n=t-e;return n?zY(e,n):P_(isNaN(e)?t:e)}const G0=(function e(t){var n=LY(t);function i(r,s){var l=n((r=O1(r)).r,(s=O1(s)).r),c=n(r.g,s.g),f=n(r.b,s.b),p=Rk(r.opacity,s.opacity);return function(m){return r.r=l(m),r.g=c(m),r.b=f(m),r.opacity=p(m),r+""}}return i.gamma=e,i})(1);function jY(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(s){for(r=0;r<n;++r)i[r]=e[r]*(1-s)+t[r]*s;return i}}function IY(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function UY(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,r=new Array(i),s=new Array(n),l;for(l=0;l<i;++l)r[l]=Mm(e[l],t[l]);for(;l<n;++l)s[l]=t[l];return function(c){for(l=0;l<i;++l)s[l]=r[l](c);return s}}function HY(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function ho(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function PY(e,t){var n={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=Mm(e[r],t[r]):i[r]=t[r];return function(s){for(r in n)i[r]=n[r](s);return i}}var D1=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Tv=new RegExp(D1.source,"g");function FY(e){return function(){return e}}function GY(e){return function(t){return e(t)+""}}function kk(e,t){var n=D1.lastIndex=Tv.lastIndex=0,i,r,s,l=-1,c=[],f=[];for(e=e+"",t=t+"";(i=D1.exec(e))&&(r=Tv.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),c[l]?c[l]+=s:c[++l]=s),(i=i[0])===(r=r[0])?c[l]?c[l]+=r:c[++l]=r:(c[++l]=null,f.push({i:l,x:ho(i,r)})),n=Tv.lastIndex;return n<t.length&&(s=t.slice(n),c[l]?c[l]+=s:c[++l]=s),c.length<2?f[0]?GY(f[0].x):FY(t):(t=f.length,function(p){for(var m=0,g;m<t;++m)c[(g=f[m]).i]=g.x(p);return c.join("")})}function Mm(e,t){var n=typeof t,i;return t==null||n==="boolean"?P_(t):(n==="number"?ho:n==="string"?(i=Ed(t))?(t=i,G0):kk:t instanceof Ed?G0:t instanceof Date?HY:IY(t)?jY:Array.isArray(t)?UY:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?PY:ho)(e,t)}var ET=180/Math.PI,z1={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Nk(e,t,n,i,r,s){var l,c,f;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(f=e*n+t*i)&&(n-=e*f,i-=t*f),(c=Math.sqrt(n*n+i*i))&&(n/=c,i/=c,f/=c),e*i<t*n&&(e=-e,t=-t,f=-f,l=-l),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*ET,skewX:Math.atan(f)*ET,scaleX:l,scaleY:c}}var l0;function qY(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?z1:Nk(t.a,t.b,t.c,t.d,t.e,t.f)}function YY(e){return e==null||(l0||(l0=document.createElementNS("http://www.w3.org/2000/svg","g")),l0.setAttribute("transform",e),!(e=l0.transform.baseVal.consolidate()))?z1:(e=e.matrix,Nk(e.a,e.b,e.c,e.d,e.e,e.f))}function Ok(e,t,n,i){function r(p){return p.length?p.pop()+" ":""}function s(p,m,g,x,v,S){if(p!==g||m!==x){var A=v.push("translate(",null,t,null,n);S.push({i:A-4,x:ho(p,g)},{i:A-2,x:ho(m,x)})}else(g||x)&&v.push("translate("+g+t+x+n)}function l(p,m,g,x){p!==m?(p-m>180?m+=360:m-p>180&&(p+=360),x.push({i:g.push(r(g)+"rotate(",null,i)-2,x:ho(p,m)})):m&&g.push(r(g)+"rotate("+m+i)}function c(p,m,g,x){p!==m?x.push({i:g.push(r(g)+"skewX(",null,i)-2,x:ho(p,m)}):m&&g.push(r(g)+"skewX("+m+i)}function f(p,m,g,x,v,S){if(p!==g||m!==x){var A=v.push(r(v)+"scale(",null,",",null,")");S.push({i:A-4,x:ho(p,g)},{i:A-2,x:ho(m,x)})}else(g!==1||x!==1)&&v.push(r(v)+"scale("+g+","+x+")")}return function(p,m){var g=[],x=[];return p=e(p),m=e(m),s(p.translateX,p.translateY,m.translateX,m.translateY,g,x),l(p.rotate,m.rotate,g,x),c(p.skewX,m.skewX,g,x),f(p.scaleX,p.scaleY,m.scaleX,m.scaleY,g,x),p=m=null,function(v){for(var S=-1,A=x.length,T;++S<A;)g[(T=x[S]).i]=T.x(v);return g.join("")}}}var VY=Ok(qY,"px, ","px)","deg)"),XY=Ok(YY,", ",")",")"),KY=1e-12;function wT(e){return((e=Math.exp(e))+1/e)/2}function $Y(e){return((e=Math.exp(e))-1/e)/2}function WY(e){return((e=Math.exp(2*e))-1)/(e+1)}const v0=(function e(t,n,i){function r(s,l){var c=s[0],f=s[1],p=s[2],m=l[0],g=l[1],x=l[2],v=m-c,S=g-f,A=v*v+S*S,T,C;if(A<KY)C=Math.log(x/p)/t,T=function(F){return[c+F*v,f+F*S,p*Math.exp(t*F*C)]};else{var N=Math.sqrt(A),R=(x*x-p*p+i*A)/(2*p*n*N),O=(x*x-p*p-i*A)/(2*x*n*N),H=Math.log(Math.sqrt(R*R+1)-R),D=Math.log(Math.sqrt(O*O+1)-O);C=(D-H)/t,T=function(F){var Z=F*C,V=wT(H),Y=p/(n*N)*(V*WY(t*Z+H)-$Y(H));return[c+Y*v,f+Y*S,p*V/wT(t*Z+H)]}}return T.duration=C*1e3*t/Math.SQRT2,T}return r.rho=function(s){var l=Math.max(.001,+s),c=l*l,f=c*c;return e(l,c,f)},r})(Math.SQRT2,2,4);var ph=0,gm=0,um=0,Dk=1e3,q0,ym,Y0=0,wd=0,px=0,Fm=typeof performance=="object"&&performance.now?performance:Date,zk=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function F_(){return wd||(zk(QY),wd=Fm.now()+px)}function QY(){wd=0}function V0(){this._call=this._time=this._next=null}V0.prototype=Bk.prototype={constructor:V0,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?F_():+n)+(t==null?0:+t),!this._next&&ym!==this&&(ym?ym._next=this:q0=this,ym=this),this._call=e,this._time=n,B1()},stop:function(){this._call&&(this._call=null,this._time=1/0,B1())}};function Bk(e,t,n){var i=new V0;return i.restart(e,t,n),i}function ZY(){F_(),++ph;for(var e=q0,t;e;)(t=wd-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ph}function TT(){wd=(Y0=Fm.now())+px,ph=gm=0;try{ZY()}finally{ph=0,eV(),wd=0}}function JY(){var e=Fm.now(),t=e-Y0;t>Dk&&(px-=t,Y0=e)}function eV(){for(var e,t=q0,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:q0=n);ym=e,B1(i)}function B1(e){if(!ph){gm&&(gm=clearTimeout(gm));var t=e-wd;t>24?(e<1/0&&(gm=setTimeout(TT,e-Fm.now()-px)),um&&(um=clearInterval(um))):(um||(Y0=Fm.now(),um=setInterval(JY,Dk)),ph=1,zk(TT))}}function CT(e,t,n){var i=new V0;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var tV=fx("start","end","cancel","interrupt"),nV=[],Lk=0,AT=1,L1=2,_0=3,MT=4,j1=5,S0=6;function mx(e,t,n,i,r,s){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;iV(e,n,{name:t,index:i,group:r,on:tV,tween:nV,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Lk})}function G_(e,t){var n=Tl(e,t);if(n.state>Lk)throw new Error("too late; already scheduled");return n}function bo(e,t){var n=Tl(e,t);if(n.state>_0)throw new Error("too late; already running");return n}function Tl(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function iV(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=Bk(s,0,n.time);function s(p){n.state=AT,n.timer.restart(l,n.delay,n.time),n.delay<=p&&l(p-n.delay)}function l(p){var m,g,x,v;if(n.state!==AT)return f();for(m in i)if(v=i[m],v.name===n.name){if(v.state===_0)return CT(l);v.state===MT?(v.state=S0,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete i[m]):+m<t&&(v.state=S0,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete i[m])}if(CT(function(){n.state===_0&&(n.state=MT,n.timer.restart(c,n.delay,n.time),c(p))}),n.state=L1,n.on.call("start",e,e.__data__,n.index,n.group),n.state===L1){for(n.state=_0,r=new Array(x=n.tween.length),m=0,g=-1;m<x;++m)(v=n.tween[m].value.call(e,e.__data__,n.index,n.group))&&(r[++g]=v);r.length=g+1}}function c(p){for(var m=p<n.duration?n.ease.call(null,p/n.duration):(n.timer.restart(f),n.state=j1,1),g=-1,x=r.length;++g<x;)r[g].call(e,m);n.state===j1&&(n.on.call("end",e,e.__data__,n.index,n.group),f())}function f(){n.state=S0,n.timer.stop(),delete i[t];for(var p in i)return;delete e.__transition}}function E0(e,t){var n=e.__transition,i,r,s=!0,l;if(n){t=t==null?null:t+"";for(l in n){if((i=n[l]).name!==t){s=!1;continue}r=i.state>L1&&i.state<j1,i.state=S0,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[l]}s&&delete e.__transition}}function rV(e){return this.each(function(){E0(this,e)})}function aV(e,t){var n,i;return function(){var r=bo(this,e),s=r.tween;if(s!==n){i=n=s;for(var l=0,c=i.length;l<c;++l)if(i[l].name===t){i=i.slice(),i.splice(l,1);break}}r.tween=i}}function sV(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=bo(this,e),l=s.tween;if(l!==i){r=(i=l).slice();for(var c={name:t,value:n},f=0,p=r.length;f<p;++f)if(r[f].name===t){r[f]=c;break}f===p&&r.push(c)}s.tween=r}}function lV(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=Tl(this.node(),n).tween,r=0,s=i.length,l;r<s;++r)if((l=i[r]).name===e)return l.value;return null}return this.each((t==null?aV:sV)(n,e,t))}function q_(e,t,n){var i=e._id;return e.each(function(){var r=bo(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Tl(r,i).value[t]}}function jk(e,t){var n;return(typeof t=="number"?ho:t instanceof Ed?G0:(n=Ed(t))?(t=n,G0):kk)(e,t)}function oV(e){return function(){this.removeAttribute(e)}}function cV(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uV(e,t,n){var i,r=n+"",s;return function(){var l=this.getAttribute(e);return l===r?null:l===i?s:s=t(i=l,n)}}function dV(e,t,n){var i,r=n+"",s;return function(){var l=this.getAttributeNS(e.space,e.local);return l===r?null:l===i?s:s=t(i=l,n)}}function fV(e,t,n){var i,r,s;return function(){var l,c=n(this),f;return c==null?void this.removeAttribute(e):(l=this.getAttribute(e),f=c+"",l===f?null:l===i&&f===r?s:(r=f,s=t(i=l,c)))}}function hV(e,t,n){var i,r,s;return function(){var l,c=n(this),f;return c==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),f=c+"",l===f?null:l===i&&f===r?s:(r=f,s=t(i=l,c)))}}function pV(e,t){var n=hx(e),i=n==="transform"?XY:jk;return this.attrTween(e,typeof t=="function"?(n.local?hV:fV)(n,i,q_(this,"attr."+e,t)):t==null?(n.local?cV:oV)(n):(n.local?dV:uV)(n,i,t))}function mV(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function gV(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function yV(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&gV(e,s)),n}return r._value=t,r}function xV(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&mV(e,s)),n}return r._value=t,r}function bV(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=hx(e);return this.tween(n,(i.local?yV:xV)(i,t))}function vV(e,t){return function(){G_(this,e).delay=+t.apply(this,arguments)}}function _V(e,t){return t=+t,function(){G_(this,e).delay=t}}function SV(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vV:_V)(t,e)):Tl(this.node(),t).delay}function EV(e,t){return function(){bo(this,e).duration=+t.apply(this,arguments)}}function wV(e,t){return t=+t,function(){bo(this,e).duration=t}}function TV(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?EV:wV)(t,e)):Tl(this.node(),t).duration}function CV(e,t){if(typeof t!="function")throw new Error;return function(){bo(this,e).ease=t}}function AV(e){var t=this._id;return arguments.length?this.each(CV(t,e)):Tl(this.node(),t).ease}function MV(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;bo(this,e).ease=n}}function RV(e){if(typeof e!="function")throw new Error;return this.each(MV(this._id,e))}function kV(e){typeof e!="function"&&(e=pk(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],l=s.length,c=i[r]=[],f,p=0;p<l;++p)(f=s[p])&&e.call(f,f.__data__,p,s)&&c.push(f);return new oc(i,this._parents,this._name,this._id)}function NV(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,s=Math.min(i,r),l=new Array(i),c=0;c<s;++c)for(var f=t[c],p=n[c],m=f.length,g=l[c]=new Array(m),x,v=0;v<m;++v)(x=f[v]||p[v])&&(g[v]=x);for(;c<i;++c)l[c]=t[c];return new oc(l,this._parents,this._name,this._id)}function OV(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function DV(e,t,n){var i,r,s=OV(t)?G_:bo;return function(){var l=s(this,e),c=l.on;c!==i&&(r=(i=c).copy()).on(t,n),l.on=r}}function zV(e,t){var n=this._id;return arguments.length<2?Tl(this.node(),n).on.on(e):this.each(DV(n,e,t))}function BV(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function LV(){return this.on("end.remove",BV(this._id))}function jV(e){var t=this._name,n=this._id;typeof e!="function"&&(e=I_(e));for(var i=this._groups,r=i.length,s=new Array(r),l=0;l<r;++l)for(var c=i[l],f=c.length,p=s[l]=new Array(f),m,g,x=0;x<f;++x)(m=c[x])&&(g=e.call(m,m.__data__,x,c))&&("__data__"in m&&(g.__data__=m.__data__),p[x]=g,mx(p[x],t,n,x,p,Tl(m,n)));return new oc(s,this._parents,t,n)}function IV(e){var t=this._name,n=this._id;typeof e!="function"&&(e=hk(e));for(var i=this._groups,r=i.length,s=[],l=[],c=0;c<r;++c)for(var f=i[c],p=f.length,m,g=0;g<p;++g)if(m=f[g]){for(var x=e.call(m,m.__data__,g,f),v,S=Tl(m,n),A=0,T=x.length;A<T;++A)(v=x[A])&&mx(v,t,n,A,x,S);s.push(x),l.push(m)}return new oc(s,l,t,n)}var UV=rg.prototype.constructor;function HV(){return new UV(this._groups,this._parents)}function PV(e,t){var n,i,r;return function(){var s=hh(this,e),l=(this.style.removeProperty(e),hh(this,e));return s===l?null:s===n&&l===i?r:r=t(n=s,i=l)}}function Ik(e){return function(){this.style.removeProperty(e)}}function FV(e,t,n){var i,r=n+"",s;return function(){var l=hh(this,e);return l===r?null:l===i?s:s=t(i=l,n)}}function GV(e,t,n){var i,r,s;return function(){var l=hh(this,e),c=n(this),f=c+"";return c==null&&(f=c=(this.style.removeProperty(e),hh(this,e))),l===f?null:l===i&&f===r?s:(r=f,s=t(i=l,c))}}function qV(e,t){var n,i,r,s="style."+t,l="end."+s,c;return function(){var f=bo(this,e),p=f.on,m=f.value[s]==null?c||(c=Ik(t)):void 0;(p!==n||r!==m)&&(i=(n=p).copy()).on(l,r=m),f.on=i}}function YV(e,t,n){var i=(e+="")=="transform"?VY:jk;return t==null?this.styleTween(e,PV(e,i)).on("end.style."+e,Ik(e)):typeof t=="function"?this.styleTween(e,GV(e,i,q_(this,"style."+e,t))).each(qV(this._id,e)):this.styleTween(e,FV(e,i,t),n).on("end.style."+e,null)}function VV(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function XV(e,t,n){var i,r;function s(){var l=t.apply(this,arguments);return l!==r&&(i=(r=l)&&VV(e,l,n)),i}return s._value=t,s}function KV(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,XV(e,t,n??""))}function $V(e){return function(){this.textContent=e}}function WV(e){return function(){var t=e(this);this.textContent=t??""}}function QV(e){return this.tween("text",typeof e=="function"?WV(q_(this,"text",e)):$V(e==null?"":e+""))}function ZV(e){return function(t){this.textContent=e.call(this,t)}}function JV(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ZV(r)),t}return i._value=e,i}function eX(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,JV(e))}function tX(){for(var e=this._name,t=this._id,n=Uk(),i=this._groups,r=i.length,s=0;s<r;++s)for(var l=i[s],c=l.length,f,p=0;p<c;++p)if(f=l[p]){var m=Tl(f,t);mx(f,e,n,p,l,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new oc(i,this._parents,e,n)}function nX(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(s,l){var c={value:l},f={value:function(){--r===0&&s()}};n.each(function(){var p=bo(this,i),m=p.on;m!==e&&(t=(e=m).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(f)),p.on=t}),r===0&&s()})}var iX=0;function oc(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function Uk(){return++iX}var Jo=rg.prototype;oc.prototype={constructor:oc,select:jV,selectAll:IV,selectChild:Jo.selectChild,selectChildren:Jo.selectChildren,filter:kV,merge:NV,selection:HV,transition:tX,call:Jo.call,nodes:Jo.nodes,node:Jo.node,size:Jo.size,empty:Jo.empty,each:Jo.each,on:zV,attr:pV,attrTween:bV,style:YV,styleTween:KV,text:QV,textTween:eX,remove:LV,tween:lV,delay:SV,duration:TV,ease:AV,easeVarying:RV,end:nX,[Symbol.iterator]:Jo[Symbol.iterator]};function rX(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var aX={time:null,delay:0,duration:250,ease:rX};function sX(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function lX(e){var t,n;e instanceof oc?(t=e._id,e=e._name):(t=Uk(),(n=aX).time=F_(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var l=i[s],c=l.length,f,p=0;p<c;++p)(f=l[p])&&mx(f,e,t,p,l,n||sX(f,t));return new oc(i,this._parents,e,t)}rg.prototype.interrupt=rV;rg.prototype.transition=lX;const o0=e=>()=>e;function oX(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function ic(e,t,n){this.k=e,this.x=t,this.y=n}ic.prototype={constructor:ic,scale:function(e){return e===1?this:new ic(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ic(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var gx=new ic(1,0,0);Hk.prototype=ic.prototype;function Hk(e){for(;!e.__zoom;)if(!(e=e.parentNode))return gx;return e.__zoom}function Cv(e){e.stopImmediatePropagation()}function dm(e){e.preventDefault(),e.stopImmediatePropagation()}function cX(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function uX(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function RT(){return this.__zoom||gx}function dX(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function fX(){return navigator.maxTouchPoints||"ontouchstart"in this}function hX(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],l=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),l>s?(s+l)/2:Math.min(0,s)||Math.max(0,l))}function Pk(){var e=cX,t=uX,n=hX,i=dX,r=fX,s=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,f=v0,p=fx("start","zoom","end"),m,g,x,v=500,S=150,A=0,T=10;function C(I){I.property("__zoom",RT).on("wheel.zoom",Z,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",Y).filter(r).on("touchstart.zoom",P).on("touchmove.zoom",q).on("touchend.zoom touchcancel.zoom",ne).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}C.transform=function(I,$,z,G){var Q=I.selection?I.selection():I;Q.property("__zoom",RT),I!==Q?H(I,$,z,G):Q.interrupt().each(function(){D(this,arguments).event(G).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},C.scaleBy=function(I,$,z,G){C.scaleTo(I,function(){var Q=this.__zoom.k,W=typeof $=="function"?$.apply(this,arguments):$;return Q*W},z,G)},C.scaleTo=function(I,$,z,G){C.transform(I,function(){var Q=t.apply(this,arguments),W=this.__zoom,B=z==null?O(Q):typeof z=="function"?z.apply(this,arguments):z,K=W.invert(B),J=typeof $=="function"?$.apply(this,arguments):$;return n(R(N(W,J),B,K),Q,l)},z,G)},C.translateBy=function(I,$,z,G){C.transform(I,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),l)},null,G)},C.translateTo=function(I,$,z,G,Q){C.transform(I,function(){var W=t.apply(this,arguments),B=this.__zoom,K=G==null?O(W):typeof G=="function"?G.apply(this,arguments):G;return n(gx.translate(K[0],K[1]).scale(B.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof z=="function"?-z.apply(this,arguments):-z),W,l)},G,Q)};function N(I,$){return $=Math.max(s[0],Math.min(s[1],$)),$===I.k?I:new ic($,I.x,I.y)}function R(I,$,z){var G=$[0]-z[0]*I.k,Q=$[1]-z[1]*I.k;return G===I.x&&Q===I.y?I:new ic(I.k,G,Q)}function O(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function H(I,$,z,G){I.on("start.zoom",function(){D(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,W=arguments,B=D(Q,W).event(G),K=t.apply(Q,W),J=z==null?O(K):typeof z=="function"?z.apply(Q,W):z,X=Math.max(K[1][0]-K[0][0],K[1][1]-K[0][1]),ce=Q.__zoom,ie=typeof $=="function"?$.apply(Q,W):$,de=f(ce.invert(J).concat(X/ce.k),ie.invert(J).concat(X/ie.k));return function(ye){if(ye===1)ye=ie;else{var me=de(ye),le=X/me[2];ye=new ic(le,J[0]-me[0]*le,J[1]-me[1]*le)}B.zoom(null,ye)}})}function D(I,$,z){return!z&&I.__zooming||new F(I,$)}function F(I,$){this.that=I,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,$),this.taps=0}F.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,$){return this.mouse&&I!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var $=ns(this.that).datum();p.call(I,this.that,new oX(I,{sourceEvent:this.sourceEvent,target:C,transform:this.that.__zoom,dispatch:p}),$)}};function Z(I,...$){if(!e.apply(this,arguments))return;var z=D(this,$).event(I),G=this.__zoom,Q=Math.max(s[0],Math.min(s[1],G.k*Math.pow(2,i.apply(this,arguments)))),W=pl(I);if(z.wheel)(z.mouse[0][0]!==W[0]||z.mouse[0][1]!==W[1])&&(z.mouse[1]=G.invert(z.mouse[0]=W)),clearTimeout(z.wheel);else{if(G.k===Q)return;z.mouse=[W,G.invert(W)],E0(this),z.start()}dm(I),z.wheel=setTimeout(B,S),z.zoom("mouse",n(R(N(G,Q),z.mouse[0],z.mouse[1]),z.extent,l));function B(){z.wheel=null,z.end()}}function V(I,...$){if(x||!e.apply(this,arguments))return;var z=I.currentTarget,G=D(this,$,!0).event(I),Q=ns(I.view).on("mousemove.zoom",J,!0).on("mouseup.zoom",X,!0),W=pl(I,z),B=I.clientX,K=I.clientY;wk(I.view),Cv(I),G.mouse=[W,this.__zoom.invert(W)],E0(this),G.start();function J(ce){if(dm(ce),!G.moved){var ie=ce.clientX-B,de=ce.clientY-K;G.moved=ie*ie+de*de>A}G.event(ce).zoom("mouse",n(R(G.that.__zoom,G.mouse[0]=pl(ce,z),G.mouse[1]),G.extent,l))}function X(ce){Q.on("mousemove.zoom mouseup.zoom",null),Tk(ce.view,G.moved),dm(ce),G.event(ce).end()}}function Y(I,...$){if(e.apply(this,arguments)){var z=this.__zoom,G=pl(I.changedTouches?I.changedTouches[0]:I,this),Q=z.invert(G),W=z.k*(I.shiftKey?.5:2),B=n(R(N(z,W),G,Q),t.apply(this,$),l);dm(I),c>0?ns(this).transition().duration(c).call(H,B,G,I):ns(this).call(C.transform,B,G,I)}}function P(I,...$){if(e.apply(this,arguments)){var z=I.touches,G=z.length,Q=D(this,$,I.changedTouches.length===G).event(I),W,B,K,J;for(Cv(I),B=0;B<G;++B)K=z[B],J=pl(K,this),J=[J,this.__zoom.invert(J),K.identifier],Q.touch0?!Q.touch1&&Q.touch0[2]!==J[2]&&(Q.touch1=J,Q.taps=0):(Q.touch0=J,W=!0,Q.taps=1+!!m);m&&(m=clearTimeout(m)),W&&(Q.taps<2&&(g=J[0],m=setTimeout(function(){m=null},v)),E0(this),Q.start())}}function q(I,...$){if(this.__zooming){var z=D(this,$).event(I),G=I.changedTouches,Q=G.length,W,B,K,J;for(dm(I),W=0;W<Q;++W)B=G[W],K=pl(B,this),z.touch0&&z.touch0[2]===B.identifier?z.touch0[0]=K:z.touch1&&z.touch1[2]===B.identifier&&(z.touch1[0]=K);if(B=z.that.__zoom,z.touch1){var X=z.touch0[0],ce=z.touch0[1],ie=z.touch1[0],de=z.touch1[1],ye=(ye=ie[0]-X[0])*ye+(ye=ie[1]-X[1])*ye,me=(me=de[0]-ce[0])*me+(me=de[1]-ce[1])*me;B=N(B,Math.sqrt(ye/me)),K=[(X[0]+ie[0])/2,(X[1]+ie[1])/2],J=[(ce[0]+de[0])/2,(ce[1]+de[1])/2]}else if(z.touch0)K=z.touch0[0],J=z.touch0[1];else return;z.zoom("touch",n(R(B,K,J),z.extent,l))}}function ne(I,...$){if(this.__zooming){var z=D(this,$).event(I),G=I.changedTouches,Q=G.length,W,B;for(Cv(I),x&&clearTimeout(x),x=setTimeout(function(){x=null},v),W=0;W<Q;++W)B=G[W],z.touch0&&z.touch0[2]===B.identifier?delete z.touch0:z.touch1&&z.touch1[2]===B.identifier&&delete z.touch1;if(z.touch1&&!z.touch0&&(z.touch0=z.touch1,delete z.touch1),z.touch0)z.touch0[1]=this.__zoom.invert(z.touch0[0]);else if(z.end(),z.taps===2&&(B=pl(B,this),Math.hypot(g[0]-B[0],g[1]-B[1])<T)){var K=ns(this).on("dblclick.zoom");K&&K.apply(this,arguments)}}}return C.wheelDelta=function(I){return arguments.length?(i=typeof I=="function"?I:o0(+I),C):i},C.filter=function(I){return arguments.length?(e=typeof I=="function"?I:o0(!!I),C):e},C.touchable=function(I){return arguments.length?(r=typeof I=="function"?I:o0(!!I),C):r},C.extent=function(I){return arguments.length?(t=typeof I=="function"?I:o0([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),C):t},C.scaleExtent=function(I){return arguments.length?(s[0]=+I[0],s[1]=+I[1],C):[s[0],s[1]]},C.translateExtent=function(I){return arguments.length?(l[0][0]=+I[0][0],l[1][0]=+I[1][0],l[0][1]=+I[0][1],l[1][1]=+I[1][1],C):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},C.constrain=function(I){return arguments.length?(n=I,C):n},C.duration=function(I){return arguments.length?(c=+I,C):c},C.interpolate=function(I){return arguments.length?(f=I,C):f},C.on=function(){var I=p.on.apply(p,arguments);return I===p?C:I},C.clickDistance=function(I){return arguments.length?(A=(I=+I)*I,C):Math.sqrt(A)},C.tapDistance=function(I){return arguments.length?(T=+I,C):T},C}const go={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Gm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Fk=["Enter"," ","Escape"],Gk={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var mh;(function(e){e.Strict="strict",e.Loose="loose"})(mh||(mh={}));var bd;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(bd||(bd={}));var qm;(function(e){e.Partial="partial",e.Full="full"})(qm||(qm={}));const qk={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var su;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(su||(su={}));var Ym;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ym||(Ym={}));var We;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(We||(We={}));const kT={[We.Left]:We.Right,[We.Right]:We.Left,[We.Top]:We.Bottom,[We.Bottom]:We.Top};function Yk(e){return e===null?null:e?"valid":"invalid"}const Vk=e=>"id"in e&&"source"in e&&"target"in e,pX=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Y_=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),sg=(e,t=[0,0])=>{const{width:n,height:i}=dc(e),r=e.origin??t,s=n*r[0],l=i*r[1];return{x:e.position.x-s,y:e.position.y-l}},mX=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,r)=>{const s=typeof r=="string";let l=!t.nodeLookup&&!s?r:void 0;t.nodeLookup&&(l=s?t.nodeLookup.get(r):Y_(r)?r:t.nodeLookup.get(r.id));const c=l?X0(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return yx(i,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return xx(n)},lg=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=yx(n,X0(r)),i=!0)}),i?xx(n):{x:0,y:0,width:0,height:0}},V_=(e,t,[n,i,r]=[0,0,1],s=!1,l=!1)=>{const c={...cg(t,[n,i,r]),width:t.width/r,height:t.height/r},f=[];for(const p of e.values()){const{measured:m,selectable:g=!0,hidden:x=!1}=p;if(l&&!g||x)continue;const v=m.width??p.width??p.initialWidth??null,S=m.height??p.height??p.initialHeight??null,A=Vm(c,yh(p)),T=(v??0)*(S??0),C=s&&A>0;(!p.internals.handleBounds||C||A>=T||p.dragging)&&f.push(p)}return f},gX=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function yX(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function xX({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:s},l){if(e.size===0)return Promise.resolve(!0);const c=yX(e,l),f=lg(c),p=X_(f,t,n,(l==null?void 0:l.minZoom)??r,(l==null?void 0:l.maxZoom)??s,(l==null?void 0:l.padding)??.1);return await i.setViewport(p,{duration:l==null?void 0:l.duration,ease:l==null?void 0:l.ease,interpolate:l==null?void 0:l.interpolate}),Promise.resolve(!0)}function Xk({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:s}){const l=n.get(e),c=l.parentId?n.get(l.parentId):void 0,{x:f,y:p}=c?c.internals.positionAbsolute:{x:0,y:0},m=l.origin??i;let g=l.extent||r;if(l.extent==="parent"&&!l.expandParent)if(!c)s==null||s("005",go.error005());else{const v=c.measured.width,S=c.measured.height;v&&S&&(g=[[f,p],[f+v,p+S]])}else c&&xh(l.extent)&&(g=[[l.extent[0][0]+f,l.extent[0][1]+p],[l.extent[1][0]+f,l.extent[1][1]+p]]);const x=xh(g)?Td(t,g,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&(s==null||s("015",go.error015())),{position:{x:x.x-f+(l.measured.width??0)*m[0],y:x.y-p+(l.measured.height??0)*m[1]},positionAbsolute:x}}async function bX({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const s=new Set(e.map(x=>x.id)),l=[];for(const x of n){if(x.deletable===!1)continue;const v=s.has(x.id),S=!v&&x.parentId&&l.find(A=>A.id===x.parentId);(v||S)&&l.push(x)}const c=new Set(t.map(x=>x.id)),f=i.filter(x=>x.deletable!==!1),m=gX(l,f);for(const x of f)c.has(x.id)&&!m.find(S=>S.id===x.id)&&m.push(x);if(!r)return{edges:m,nodes:l};const g=await r({nodes:l,edges:m});return typeof g=="boolean"?g?{edges:m,nodes:l}:{edges:[],nodes:[]}:g}const gh=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Td=(e={x:0,y:0},t,n)=>({x:gh(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:gh(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Kk(e,t,n){const{width:i,height:r}=dc(n),{x:s,y:l}=n.internals.positionAbsolute;return Td(e,[[s,l],[s+i,l+r]],t)}const NT=(e,t,n)=>e<t?gh(Math.abs(e-t),1,t)/t:e>n?-gh(Math.abs(e-n),1,t)/t:0,$k=(e,t,n=15,i=40)=>{const r=NT(e.x,i,t.width-i)*n,s=NT(e.y,i,t.height-i)*n;return[r,s]},yx=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),I1=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),xx=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),yh=(e,t=[0,0])=>{var r,s;const{x:n,y:i}=Y_(e)?e.internals.positionAbsolute:sg(e,t);return{x:n,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}},X0=(e,t=[0,0])=>{var r,s;const{x:n,y:i}=Y_(e)?e.internals.positionAbsolute:sg(e,t);return{x:n,y:i,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0)}},Wk=(e,t)=>xx(yx(I1(e),I1(t))),Vm=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},OT=e=>xl(e.width)&&xl(e.height)&&xl(e.x)&&xl(e.y),xl=e=>!isNaN(e)&&isFinite(e),vX=(e,t)=>{},og=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),cg=({x:e,y:t},[n,i,r],s=!1,l=[1,1])=>{const c={x:(e-n)/r,y:(t-i)/r};return s?og(c,l):c},K0=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function Pf(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function _X(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=Pf(e,n),r=Pf(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=Pf(e.top??e.y??0,n),r=Pf(e.bottom??e.y??0,n),s=Pf(e.left??e.x??0,t),l=Pf(e.right??e.x??0,t);return{top:i,right:l,bottom:r,left:s,x:s+l,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function SX(e,t,n,i,r,s){const{x:l,y:c}=K0(e,[t,n,i]),{x:f,y:p}=K0({x:e.x+e.width,y:e.y+e.height},[t,n,i]),m=r-f,g=s-p;return{left:Math.floor(l),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(g)}}const X_=(e,t,n,i,r,s)=>{const l=_X(s,t,n),c=(t-l.x)/e.width,f=(n-l.y)/e.height,p=Math.min(c,f),m=gh(p,i,r),g=e.x+e.width/2,x=e.y+e.height/2,v=t/2-g*m,S=n/2-x*m,A=SX(e,v,S,m,t,n),T={left:Math.min(A.left-l.left,0),top:Math.min(A.top-l.top,0),right:Math.min(A.right-l.right,0),bottom:Math.min(A.bottom-l.bottom,0)};return{x:v-T.left+T.right,y:S-T.top+T.bottom,zoom:m}},Xm=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xh(e){return e!=null&&e!=="parent"}function dc(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Qk(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Zk(e,t={width:0,height:0},n,i,r){const s={...e},l=i.get(n);if(l){const c=l.origin||r;s.x+=l.internals.positionAbsolute.x-(t.width??0)*c[0],s.y+=l.internals.positionAbsolute.y-(t.height??0)*c[1]}return s}function DT(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function EX(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function wX(e){return{...Gk,...e||{}}}function Rm(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:s,y:l}=bl(e),c=cg({x:s-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},i),{x:f,y:p}=n?og(c,t):c;return{xSnapped:f,ySnapped:p,...c}}const K_=e=>({width:e.offsetWidth,height:e.offsetHeight}),Jk=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},TX=["INPUT","SELECT","TEXTAREA"];function eN(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:TX.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const tN=e=>"clientX"in e,bl=(e,t)=>{var s,l;const n=tN(e),i=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,r=n?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},zT=(e,t,n,i,r)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(l=>{const c=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:r,position:l.getAttribute("data-handlepos"),x:(c.left-n.left)/i,y:(c.top-n.top)/i,...K_(l)}})};function nN({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:s,targetControlX:l,targetControlY:c}){const f=e*.125+r*.375+l*.375+n*.125,p=t*.125+s*.375+c*.375+i*.125,m=Math.abs(f-e),g=Math.abs(p-t);return[f,p,m,g]}function c0(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function BT({pos:e,x1:t,y1:n,x2:i,y2:r,c:s}){switch(e){case We.Left:return[t-c0(t-i,s),n];case We.Right:return[t+c0(i-t,s),n];case We.Top:return[t,n-c0(n-r,s)];case We.Bottom:return[t,n+c0(r-n,s)]}}function iN({sourceX:e,sourceY:t,sourcePosition:n=We.Bottom,targetX:i,targetY:r,targetPosition:s=We.Top,curvature:l=.25}){const[c,f]=BT({pos:n,x1:e,y1:t,x2:i,y2:r,c:l}),[p,m]=BT({pos:s,x1:i,y1:r,x2:e,y2:t,c:l}),[g,x,v,S]=nN({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:c,sourceControlY:f,targetControlX:p,targetControlY:m});return[`M${e},${t} C${c},${f} ${p},${m} ${i},${r}`,g,x,v,S]}function rN({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,s=n<e?n+r:n-r,l=Math.abs(i-t)/2,c=i<t?i+l:i-l;return[s,c,r,l]}function CX({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:r=!1,zIndexMode:s="basic"}){if(s==="manual")return i;const l=r&&n?i+1e3:i,c=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return l+c}function AX({sourceNode:e,targetNode:t,width:n,height:i,transform:r}){const s=yx(X0(e),X0(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const l={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:i/r[2]};return Vm(l,xx(s))>0}const MX=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,RX=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),kX=(e,t,n={})=>{if(!e.source||!e.target)return t;const i=n.getEdgeId||MX;let r;return Vk(e)?r={...e}:r={...e,id:i(e)},RX(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function aN({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,s,l,c]=rN({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,s,l,c]}const LT={[We.Left]:{x:-1,y:0},[We.Right]:{x:1,y:0},[We.Top]:{x:0,y:-1},[We.Bottom]:{x:0,y:1}},NX=({source:e,sourcePosition:t=We.Bottom,target:n})=>t===We.Left||t===We.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},jT=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function OX({source:e,sourcePosition:t=We.Bottom,target:n,targetPosition:i=We.Top,center:r,offset:s,stepPosition:l}){const c=LT[t],f=LT[i],p={x:e.x+c.x*s,y:e.y+c.y*s},m={x:n.x+f.x*s,y:n.y+f.y*s},g=NX({source:p,sourcePosition:t,target:m}),x=g.x!==0?"x":"y",v=g[x];let S=[],A,T;const C={x:0,y:0},N={x:0,y:0},[,,R,O]=rN({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[x]*f[x]===-1){x==="x"?(A=r.x??p.x+(m.x-p.x)*l,T=r.y??(p.y+m.y)/2):(A=r.x??(p.x+m.x)/2,T=r.y??p.y+(m.y-p.y)*l);const D=[{x:A,y:p.y},{x:A,y:m.y}],F=[{x:p.x,y:T},{x:m.x,y:T}];c[x]===v?S=x==="x"?D:F:S=x==="x"?F:D}else{const D=[{x:p.x,y:m.y}],F=[{x:m.x,y:p.y}];if(x==="x"?S=c.x===v?F:D:S=c.y===v?D:F,t===i){const q=Math.abs(e[x]-n[x]);if(q<=s){const ne=Math.min(s-1,s-q);c[x]===v?C[x]=(p[x]>e[x]?-1:1)*ne:N[x]=(m[x]>n[x]?-1:1)*ne}}if(t!==i){const q=x==="x"?"y":"x",ne=c[x]===f[q],I=p[q]>m[q],$=p[q]<m[q];(c[x]===1&&(!ne&&I||ne&&$)||c[x]!==1&&(!ne&&$||ne&&I))&&(S=x==="x"?D:F)}const Z={x:p.x+C.x,y:p.y+C.y},V={x:m.x+N.x,y:m.y+N.y},Y=Math.max(Math.abs(Z.x-S[0].x),Math.abs(V.x-S[0].x)),P=Math.max(Math.abs(Z.y-S[0].y),Math.abs(V.y-S[0].y));Y>=P?(A=(Z.x+V.x)/2,T=S[0].y):(A=S[0].x,T=(Z.y+V.y)/2)}return[[e,{x:p.x+C.x,y:p.y+C.y},...S,{x:m.x+N.x,y:m.y+N.y},n],A,T,R,O]}function DX(e,t,n,i){const r=Math.min(jT(e,t)/2,jT(t,n)/2,i),{x:s,y:l}=t;if(e.x===s&&s===n.x||e.y===l&&l===n.y)return`L${s} ${l}`;if(e.y===l){const p=e.x<n.x?-1:1,m=e.y<n.y?1:-1;return`L ${s+r*p},${l}Q ${s},${l} ${s},${l+r*m}`}const c=e.x<n.x?1:-1,f=e.y<n.y?-1:1;return`L ${s},${l+r*f}Q ${s},${l} ${s+r*c},${l}`}function U1({sourceX:e,sourceY:t,sourcePosition:n=We.Bottom,targetX:i,targetY:r,targetPosition:s=We.Top,borderRadius:l=5,centerX:c,centerY:f,offset:p=20,stepPosition:m=.5}){const[g,x,v,S,A]=OX({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:r},targetPosition:s,center:{x:c,y:f},offset:p,stepPosition:m});return[g.reduce((C,N,R)=>{let O="";return R>0&&R<g.length-1?O=DX(g[R-1],N,g[R+1],l):O=`${R===0?"M":"L"}${N.x} ${N.y}`,C+=O,C},""),x,v,S,A]}function IT(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function zX(e){var g;const{sourceNode:t,targetNode:n}=e;if(!IT(t)||!IT(n))return null;const i=t.internals.handleBounds||UT(t.handles),r=n.internals.handleBounds||UT(n.handles),s=HT((i==null?void 0:i.source)??[],e.sourceHandle),l=HT(e.connectionMode===mh.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!s||!l)return(g=e.onError)==null||g.call(e,"008",go.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(s==null?void 0:s.position)||We.Bottom,f=(l==null?void 0:l.position)||We.Top,p=Cd(t,s,c),m=Cd(n,l,f);return{sourceX:p.x,sourceY:p.y,targetX:m.x,targetY:m.y,sourcePosition:c,targetPosition:f}}function UT(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function Cd(e,t,n=We.Left,i=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,s=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:l,height:c}=t??dc(e);if(i)return{x:r+l/2,y:s+c/2};switch((t==null?void 0:t.position)??n){case We.Top:return{x:r+l/2,y:s};case We.Right:return{x:r+l,y:s+c/2};case We.Bottom:return{x:r+l/2,y:s+c};case We.Left:return{x:r,y:s+c/2}}}function HT(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function H1(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function BX(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const s=new Set;return e.reduce((l,c)=>([c.markerStart||i,c.markerEnd||r].forEach(f=>{if(f&&typeof f=="object"){const p=H1(f,t);s.has(p)||(l.push({id:p,color:f.color||n,...f}),s.add(p))}}),l),[]).sort((l,c)=>l.id.localeCompare(c.id))}const sN=1e3,LX=10,$_={nodeOrigin:[0,0],nodeExtent:Gm,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},jX={...$_,checkEquality:!0};function W_(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function IX(e,t,n){const i=W_($_,n);for(const r of e.values())if(r.parentId)Z_(r,e,t,i);else{const s=sg(r,i.nodeOrigin),l=xh(r.extent)?r.extent:i.nodeExtent,c=Td(s,l,dc(r));r.internals.positionAbsolute=c}}function UX(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const r of e.handles){const s={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(s):r.type==="target"&&i.push(s)}return{source:n,target:i}}function Q_(e){return e==="manual"}function P1(e,t,n,i={}){var p,m;const r=W_(jX,i),s={i:0},l=new Map(t),c=r!=null&&r.elevateNodesOnSelect&&!Q_(r.zIndexMode)?sN:0;let f=e.length>0;t.clear(),n.clear();for(const g of e){let x=l.get(g.id);if(r.checkEquality&&g===(x==null?void 0:x.internals.userNode))t.set(g.id,x);else{const v=sg(g,r.nodeOrigin),S=xh(g.extent)?g.extent:r.nodeExtent,A=Td(v,S,dc(g));x={...r.defaults,...g,measured:{width:(p=g.measured)==null?void 0:p.width,height:(m=g.measured)==null?void 0:m.height},internals:{positionAbsolute:A,handleBounds:UX(g,x),z:lN(g,c,r.zIndexMode),userNode:g}},t.set(g.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(f=!1),g.parentId&&Z_(x,t,n,i,s)}return f}function HX(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Z_(e,t,n,i,r){const{elevateNodesOnSelect:s,nodeOrigin:l,nodeExtent:c,zIndexMode:f}=W_($_,i),p=e.parentId,m=t.get(p);if(!m){console.warn(`Parent node ${p} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}HX(e,n),r&&!m.parentId&&m.internals.rootParentIndex===void 0&&f==="auto"&&(m.internals.rootParentIndex=++r.i,m.internals.z=m.internals.z+r.i*LX),r&&m.internals.rootParentIndex!==void 0&&(r.i=m.internals.rootParentIndex);const g=s&&!Q_(f)?sN:0,{x,y:v,z:S}=PX(e,m,l,c,g,f),{positionAbsolute:A}=e.internals,T=x!==A.x||v!==A.y;(T||S!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:T?{x,y:v}:A,z:S}})}function lN(e,t,n){const i=xl(e.zIndex)?e.zIndex:0;return Q_(n)?i:i+(e.selected?t:0)}function PX(e,t,n,i,r,s){const{x:l,y:c}=t.internals.positionAbsolute,f=dc(e),p=sg(e,n),m=xh(e.extent)?Td(p,e.extent,f):p;let g=Td({x:l+m.x,y:c+m.y},i,f);e.extent==="parent"&&(g=Kk(g,f,t));const x=lN(e,r,s),v=t.internals.z??0;return{x:g.x,y:g.y,z:v>=x?v+1:x}}function J_(e,t,n,i=[0,0]){var l;const r=[],s=new Map;for(const c of e){const f=t.get(c.parentId);if(!f)continue;const p=((l=s.get(c.parentId))==null?void 0:l.expandedRect)??yh(f),m=Wk(p,c.rect);s.set(c.parentId,{expandedRect:m,parent:f})}return s.size>0&&s.forEach(({expandedRect:c,parent:f},p)=>{var R;const m=f.internals.positionAbsolute,g=dc(f),x=f.origin??i,v=c.x<m.x?Math.round(Math.abs(m.x-c.x)):0,S=c.y<m.y?Math.round(Math.abs(m.y-c.y)):0,A=Math.max(g.width,Math.round(c.width)),T=Math.max(g.height,Math.round(c.height)),C=(A-g.width)*x[0],N=(T-g.height)*x[1];(v>0||S>0||C||N)&&(r.push({id:p,type:"position",position:{x:f.position.x-v+C,y:f.position.y-S+N}}),(R=n.get(p))==null||R.forEach(O=>{e.some(H=>H.id===O.id)||r.push({id:O.id,type:"position",position:{x:O.position.x+v,y:O.position.y+S}})})),(g.width<c.width||g.height<c.height||v||S)&&r.push({id:p,type:"dimensions",setAttributes:!0,dimensions:{width:A+(v?x[0]*v-C:0),height:T+(S?x[1]*S-N:0)}})}),r}function FX(e,t,n,i,r,s,l){const c=i==null?void 0:i.querySelector(".xyflow__viewport");let f=!1;if(!c)return{changes:[],updatedInternals:f};const p=[],m=window.getComputedStyle(c),{m22:g}=new window.DOMMatrixReadOnly(m.transform),x=[];for(const v of e.values()){const S=t.get(v.id);if(!S)continue;if(S.hidden){t.set(S.id,{...S,internals:{...S.internals,handleBounds:void 0}}),f=!0;continue}const A=K_(v.nodeElement),T=S.measured.width!==A.width||S.measured.height!==A.height;if(!!(A.width&&A.height&&(T||!S.internals.handleBounds||v.force))){const N=v.nodeElement.getBoundingClientRect(),R=xh(S.extent)?S.extent:s;let{positionAbsolute:O}=S.internals;S.parentId&&S.extent==="parent"?O=Kk(O,A,t.get(S.parentId)):R&&(O=Td(O,R,A));const H={...S,measured:A,internals:{...S.internals,positionAbsolute:O,handleBounds:{source:zT("source",v.nodeElement,N,g,S.id),target:zT("target",v.nodeElement,N,g,S.id)}}};t.set(S.id,H),S.parentId&&Z_(H,t,n,{nodeOrigin:r,zIndexMode:l}),f=!0,T&&(p.push({id:S.id,type:"dimensions",dimensions:A}),S.expandParent&&S.parentId&&x.push({id:S.id,parentId:S.parentId,rect:yh(H,r)}))}}if(x.length>0){const v=J_(x,t,n,r);p.push(...v)}return{changes:p,updatedInternals:f}}async function GX({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,height:s}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const l=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,s]],i),c=!!l&&(l.x!==n[0]||l.y!==n[1]||l.k!==n[2]);return Promise.resolve(c)}function PT(e,t,n,i,r,s){let l=r;const c=i.get(l)||new Map;i.set(l,c.set(n,t)),l=`${r}-${e}`;const f=i.get(l)||new Map;if(i.set(l,f.set(n,t)),s){l=`${r}-${e}-${s}`;const p=i.get(l)||new Map;i.set(l,p.set(n,t))}}function oN(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:s,sourceHandle:l=null,targetHandle:c=null}=i,f={edgeId:i.id,source:r,target:s,sourceHandle:l,targetHandle:c},p=`${r}-${l}--${s}-${c}`,m=`${s}-${c}--${r}-${l}`;PT("source",f,m,e,r,l),PT("target",f,p,e,s,c),t.set(i.id,i)}}function cN(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:cN(n,t):!1}function FT(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function qX(e,t,n,i){const r=new Map;for(const[s,l]of e)if((l.selected||l.id===i)&&(!l.parentId||!cN(l,e))&&(l.draggable||t&&typeof l.draggable>"u")){const c=e.get(s);c&&r.set(s,{id:s,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function Av({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var l,c,f;const r=[];for(const[p,m]of t){const g=(l=n.get(p))==null?void 0:l.internals.userNode;g&&r.push({...g,position:m.position,dragging:i})}if(!e)return[r[0],r];const s=(c=n.get(e))==null?void 0:c.internals.userNode;return[s?{...s,position:((f=t.get(e))==null?void 0:f.position)||s.position,dragging:i}:r[0],r]}function YX({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const s={x:n-r.distance.x,y:i-r.distance.y},l=og(s,t);return{x:l.x-s.x,y:l.y-s.y}}function VX({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let s={x:null,y:null},l=0,c=new Map,f=!1,p={x:0,y:0},m=null,g=!1,x=null,v=!1,S=!1,A=null;function T({noDragClassName:N,handleSelector:R,domNode:O,isSelectable:H,nodeId:D,nodeClickDistance:F=0}){x=ns(O);function Z({x:q,y:ne}){const{nodeLookup:I,nodeExtent:$,snapGrid:z,snapToGrid:G,nodeOrigin:Q,onNodeDrag:W,onSelectionDrag:B,onError:K,updateNodePositions:J}=t();s={x:q,y:ne};let X=!1;const ce=c.size>1,ie=ce&&$?I1(lg(c)):null,de=ce&&G?YX({dragItems:c,snapGrid:z,x:q,y:ne}):null;for(const[ye,me]of c){if(!I.has(ye))continue;let le={x:q-me.distance.x,y:ne-me.distance.y};G&&(le=de?{x:Math.round(le.x+de.x),y:Math.round(le.y+de.y)}:og(le,z));let Re=null;if(ce&&$&&!me.extent&&ie){const{positionAbsolute:He}=me.internals,Qe=He.x-ie.x+$[0][0],ot=He.x+me.measured.width-ie.x2+$[1][0],Ue=He.y-ie.y+$[0][1],wt=He.y+me.measured.height-ie.y2+$[1][1];Re=[[Qe,Ue],[ot,wt]]}const{position:Le,positionAbsolute:je}=Xk({nodeId:ye,nextPosition:le,nodeLookup:I,nodeExtent:Re||$,nodeOrigin:Q,onError:K});X=X||me.position.x!==Le.x||me.position.y!==Le.y,me.position=Le,me.internals.positionAbsolute=je}if(S=S||X,!!X&&(J(c,!0),A&&(i||W||!D&&B))){const[ye,me]=Av({nodeId:D,dragItems:c,nodeLookup:I});i==null||i(A,c,ye,me),W==null||W(A,ye,me),D||B==null||B(A,me)}}async function V(){if(!m)return;const{transform:q,panBy:ne,autoPanSpeed:I,autoPanOnNodeDrag:$}=t();if(!$){f=!1,cancelAnimationFrame(l);return}const[z,G]=$k(p,m,I);(z!==0||G!==0)&&(s.x=(s.x??0)-z/q[2],s.y=(s.y??0)-G/q[2],await ne({x:z,y:G})&&Z(s)),l=requestAnimationFrame(V)}function Y(q){var ce;const{nodeLookup:ne,multiSelectionActive:I,nodesDraggable:$,transform:z,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:W,onNodeDragStart:B,onSelectionDragStart:K,unselectNodesAndEdges:J}=t();g=!0,(!W||!H)&&!I&&D&&((ce=ne.get(D))!=null&&ce.selected||J()),H&&W&&D&&(e==null||e(D));const X=Rm(q.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Q,containerBounds:m});if(s=X,c=qX(ne,$,X,D),c.size>0&&(n||B||!D&&K)){const[ie,de]=Av({nodeId:D,dragItems:c,nodeLookup:ne});n==null||n(q.sourceEvent,c,ie,de),B==null||B(q.sourceEvent,ie,de),D||K==null||K(q.sourceEvent,de)}}const P=Ck().clickDistance(F).on("start",q=>{const{domNode:ne,nodeDragThreshold:I,transform:$,snapGrid:z,snapToGrid:G}=t();m=(ne==null?void 0:ne.getBoundingClientRect())||null,v=!1,S=!1,A=q.sourceEvent,I===0&&Y(q),s=Rm(q.sourceEvent,{transform:$,snapGrid:z,snapToGrid:G,containerBounds:m}),p=bl(q.sourceEvent,m)}).on("drag",q=>{const{autoPanOnNodeDrag:ne,transform:I,snapGrid:$,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Q}=t(),W=Rm(q.sourceEvent,{transform:I,snapGrid:$,snapToGrid:z,containerBounds:m});if(A=q.sourceEvent,(q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1||D&&!Q.has(D))&&(v=!0),!v){if(!f&&ne&&g&&(f=!0,V()),!g){const B=bl(q.sourceEvent,m),K=B.x-p.x,J=B.y-p.y;Math.sqrt(K*K+J*J)>G&&Y(q)}(s.x!==W.xSnapped||s.y!==W.ySnapped)&&c&&g&&(p=bl(q.sourceEvent,m),Z(W))}}).on("end",q=>{if(!(!g||v)&&(f=!1,g=!1,cancelAnimationFrame(l),c.size>0)){const{nodeLookup:ne,updateNodePositions:I,onNodeDragStop:$,onSelectionDragStop:z}=t();if(S&&(I(c,!1),S=!1),r||$||!D&&z){const[G,Q]=Av({nodeId:D,dragItems:c,nodeLookup:ne,dragging:!1});r==null||r(q.sourceEvent,c,G,Q),$==null||$(q.sourceEvent,G,Q),D||z==null||z(q.sourceEvent,Q)}}}).filter(q=>{const ne=q.target;return!q.button&&(!N||!FT(ne,`.${N}`,O))&&(!R||FT(ne,R,O))});x.call(P)}function C(){x==null||x.on(".drag",null)}return{update:T,destroy:C}}function XX(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())Vm(r,yh(s))>0&&i.push(s);return i}const KX=250;function $X(e,t,n,i){var c,f;let r=[],s=1/0;const l=XX(e,n,t+KX);for(const p of l){const m=[...((c=p.internals.handleBounds)==null?void 0:c.source)??[],...((f=p.internals.handleBounds)==null?void 0:f.target)??[]];for(const g of m){if(i.nodeId===g.nodeId&&i.type===g.type&&i.id===g.id)continue;const{x,y:v}=Cd(p,g,g.position,!0),S=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(v-e.y,2));S>t||(S<s?(r=[{...g,x,y:v}],s=S):S===s&&r.push({...g,x,y:v}))}}if(!r.length)return null;if(r.length>1){const p=i.type==="source"?"target":"source";return r.find(m=>m.type===p)??r[0]}return r[0]}function uN(e,t,n,i,r,s=!1){var p,m,g;const l=i.get(e);if(!l)return null;const c=r==="strict"?(p=l.internals.handleBounds)==null?void 0:p[t]:[...((m=l.internals.handleBounds)==null?void 0:m.source)??[],...((g=l.internals.handleBounds)==null?void 0:g.target)??[]],f=(n?c==null?void 0:c.find(x=>x.id===n):c==null?void 0:c[0])??null;return f&&s?{...f,...Cd(l,f,f.position,!0)}:f}function dN(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function WX(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const fN=()=>!0;function QX(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:s,isTarget:l,domNode:c,nodeLookup:f,lib:p,autoPanOnConnect:m,flowId:g,panBy:x,cancelConnection:v,onConnectStart:S,onConnect:A,onConnectEnd:T,isValidConnection:C=fN,onReconnectEnd:N,updateConnection:R,getTransform:O,getFromHandle:H,autoPanSpeed:D,dragThreshold:F=1,handleDomNode:Z}){const V=Jk(e.target);let Y=0,P;const{x:q,y:ne}=bl(e),I=dN(s,Z),$=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!$||!I)return;const G=uN(r,I,i,f,t);if(!G)return;let Q=bl(e,$),W=!1,B=null,K=!1,J=null;function X(){if(!m||!$)return;const[Le,je]=$k(Q,$,D);x({x:Le,y:je}),Y=requestAnimationFrame(X)}const ce={...G,nodeId:r,type:I,position:G.position},ie=f.get(r);let ye={inProgress:!0,isValid:null,from:Cd(ie,ce,We.Left,!0),fromHandle:ce,fromPosition:ce.position,fromNode:ie,to:Q,toHandle:null,toPosition:kT[ce.position],toNode:null,pointer:Q};function me(){z=!0,R(ye),S==null||S(e,{nodeId:r,handleId:i,handleType:I})}F===0&&me();function le(Le){if(!z){const{x:wt,y:_n}=bl(Le),Sn=wt-q,hn=_n-ne;if(!(Sn*Sn+hn*hn>F*F))return;me()}if(!H()||!ce){Re(Le);return}const je=O();Q=bl(Le,$),P=$X(cg(Q,je,!1,[1,1]),n,f,ce),W||(X(),W=!0);const He=hN(Le,{handle:P,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:l?"target":"source",isValidConnection:C,doc:V,lib:p,flowId:g,nodeLookup:f});J=He.handleDomNode,B=He.connection,K=WX(!!P,He.isValid);const Qe=f.get(r),ot=Qe?Cd(Qe,ce,We.Left,!0):ye.from,Ue={...ye,from:ot,isValid:K,to:He.toHandle&&K?K0({x:He.toHandle.x,y:He.toHandle.y},je):Q,toHandle:He.toHandle,toPosition:K&&He.toHandle?He.toHandle.position:kT[ce.position],toNode:He.toHandle?f.get(He.toHandle.nodeId):null,pointer:Q};R(Ue),ye=Ue}function Re(Le){if(!("touches"in Le&&Le.touches.length>0)){if(z){(P||J)&&B&&K&&(A==null||A(B));const{inProgress:je,...He}=ye,Qe={...He,toPosition:ye.toHandle?ye.toPosition:null};T==null||T(Le,Qe),s&&(N==null||N(Le,Qe))}v(),cancelAnimationFrame(Y),W=!1,K=!1,B=null,J=null,V.removeEventListener("mousemove",le),V.removeEventListener("mouseup",Re),V.removeEventListener("touchmove",le),V.removeEventListener("touchend",Re)}}V.addEventListener("mousemove",le),V.addEventListener("mouseup",Re),V.addEventListener("touchmove",le),V.addEventListener("touchend",Re)}function hN(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:s,doc:l,lib:c,flowId:f,isValidConnection:p=fN,nodeLookup:m}){const g=s==="target",x=t?l.querySelector(`.${c}-flow__handle[data-id="${f}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:v,y:S}=bl(e),A=l.elementFromPoint(v,S),T=A!=null&&A.classList.contains(`${c}-flow__handle`)?A:x,C={handleDomNode:T,isValid:!1,connection:null,toHandle:null};if(T){const N=dN(void 0,T),R=T.getAttribute("data-nodeid"),O=T.getAttribute("data-handleid"),H=T.classList.contains("connectable"),D=T.classList.contains("connectableend");if(!R||!N)return C;const F={source:g?R:i,sourceHandle:g?O:r,target:g?i:R,targetHandle:g?r:O};C.connection=F;const V=H&&D&&(n===mh.Strict?g&&N==="source"||!g&&N==="target":R!==i||O!==r);C.isValid=V&&p(F),C.toHandle=uN(R,N,O,m,n,!0)}return C}const F1={onPointerDown:QX,isValid:hN};function ZX({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=ns(e);function s({translateExtent:c,width:f,height:p,zoomStep:m=1,pannable:g=!0,zoomable:x=!0,inversePan:v=!1}){const S=R=>{if(R.sourceEvent.type!=="wheel"||!t)return;const O=n(),H=R.sourceEvent.ctrlKey&&Xm()?10:1,D=-R.sourceEvent.deltaY*(R.sourceEvent.deltaMode===1?.05:R.sourceEvent.deltaMode?1:.002)*m,F=O[2]*Math.pow(2,D*H);t.scaleTo(F)};let A=[0,0];const T=R=>{(R.sourceEvent.type==="mousedown"||R.sourceEvent.type==="touchstart")&&(A=[R.sourceEvent.clientX??R.sourceEvent.touches[0].clientX,R.sourceEvent.clientY??R.sourceEvent.touches[0].clientY])},C=R=>{const O=n();if(R.sourceEvent.type!=="mousemove"&&R.sourceEvent.type!=="touchmove"||!t)return;const H=[R.sourceEvent.clientX??R.sourceEvent.touches[0].clientX,R.sourceEvent.clientY??R.sourceEvent.touches[0].clientY],D=[H[0]-A[0],H[1]-A[1]];A=H;const F=i()*Math.max(O[2],Math.log(O[2]))*(v?-1:1),Z={x:O[0]-D[0]*F,y:O[1]-D[1]*F},V=[[0,0],[f,p]];t.setViewportConstrained({x:Z.x,y:Z.y,zoom:O[2]},V,c)},N=Pk().on("start",T).on("zoom",g?C:null).on("zoom.wheel",x?S:null);r.call(N,{})}function l(){r.on("zoom",null)}return{update:s,destroy:l,pointer:pl}}const bx=e=>({x:e.x,y:e.y,zoom:e.k}),Mv=({x:e,y:t,zoom:n})=>gx.translate(e,t).scale(n),Jf=(e,t)=>e.target.closest(`.${t}`),pN=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),JX=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Rv=(e,t=0,n=JX,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},mN=e=>{const t=e.ctrlKey&&Xm()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function eK({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:s,zoomOnPinch:l,onPanZoomStart:c,onPanZoom:f,onPanZoomEnd:p}){return m=>{if(Jf(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const g=n.property("__zoom").k||1;if(m.ctrlKey&&l){const T=pl(m),C=mN(m),N=g*Math.pow(2,C);i.scaleTo(n,N,T,m);return}const x=m.deltaMode===1?20:1;let v=r===bd.Vertical?0:m.deltaX*x,S=r===bd.Horizontal?0:m.deltaY*x;!Xm()&&m.shiftKey&&r!==bd.Vertical&&(v=m.deltaY*x,S=0),i.translateBy(n,-(v/g)*s,-(S/g)*s,{internal:!0});const A=bx(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(f==null||f(m,A),e.panScrollTimeout=setTimeout(()=>{p==null||p(m,A),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,A))}}function tK({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const s=i.type==="wheel",l=!t&&s&&!i.ctrlKey,c=Jf(i,e);if(i.ctrlKey&&s&&c&&i.preventDefault(),l||c)return null;i.preventDefault(),n.call(this,i,r)}}function nK({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var s,l,c;if((s=i.sourceEvent)!=null&&s.internal)return;const r=bx(i.transform);e.mouseButton=((l=i.sourceEvent)==null?void 0:l.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((c=i.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function iK({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return s=>{var l,c;e.usedRightMouseButton=!!(n&&pN(t,e.mouseButton??0)),(l=s.sourceEvent)!=null&&l.sync||i([s.transform.x,s.transform.y,s.transform.k]),r&&!((c=s.sourceEvent)!=null&&c.internal)&&(r==null||r(s.sourceEvent,bx(s.transform)))}}function rK({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:s}){return l=>{var c;if(!((c=l.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,s&&pN(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&s(l.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const f=bx(l.transform);e.prevViewport=f,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,f)},n?150:0)}}}function aK({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:r,zoomOnDoubleClick:s,userSelectionActive:l,noWheelClassName:c,noPanClassName:f,lib:p,connectionInProgress:m}){return g=>{var T;const x=e||t,v=n&&g.ctrlKey,S=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(Jf(g,`${p}-flow__node`)||Jf(g,`${p}-flow__edge`)))return!0;if(!i&&!x&&!r&&!s&&!n||l||m&&!S||Jf(g,c)&&S||Jf(g,f)&&(!S||r&&S&&!e)||!n&&g.ctrlKey&&S)return!1;if(!n&&g.type==="touchstart"&&((T=g.touches)==null?void 0:T.length)>1)return g.preventDefault(),!1;if(!x&&!r&&!v&&S||!i&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(i)&&!i.includes(g.button)&&g.type==="mousedown")return!1;const A=Array.isArray(i)&&i.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||S)&&A}}function sK({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:s,onPanZoomStart:l,onPanZoomEnd:c,onDraggingChange:f}){const p={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),g=Pk().scaleExtent([t,n]).translateExtent(i),x=ns(e).call(g);N({x:r.x,y:r.y,zoom:gh(r.zoom,t,n)},[[0,0],[m.width,m.height]],i);const v=x.on("wheel.zoom"),S=x.on("dblclick.zoom");g.wheelDelta(mN);function A(P,q){return x?new Promise(ne=>{g==null||g.interpolate((q==null?void 0:q.interpolate)==="linear"?Mm:v0).transform(Rv(x,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>ne(!0)),P)}):Promise.resolve(!1)}function T({noWheelClassName:P,noPanClassName:q,onPaneContextMenu:ne,userSelectionActive:I,panOnScroll:$,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:W,zoomOnPinch:B,zoomOnScroll:K,zoomOnDoubleClick:J,zoomActivationKeyPressed:X,lib:ce,onTransformChange:ie,connectionInProgress:de,paneClickDistance:ye,selectionOnDrag:me}){I&&!p.isZoomingOrPanning&&C();const le=$&&!X&&!I;g.clickDistance(me?1/0:!xl(ye)||ye<0?0:ye);const Re=le?eK({zoomPanValues:p,noWheelClassName:P,d3Selection:x,d3Zoom:g,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:B,onPanZoomStart:l,onPanZoom:s,onPanZoomEnd:c}):tK({noWheelClassName:P,preventScrolling:W,d3ZoomHandler:v});if(x.on("wheel.zoom",Re,{passive:!1}),!I){const je=nK({zoomPanValues:p,onDraggingChange:f,onPanZoomStart:l});g.on("start",je);const He=iK({zoomPanValues:p,panOnDrag:z,onPaneContextMenu:!!ne,onPanZoom:s,onTransformChange:ie});g.on("zoom",He);const Qe=rK({zoomPanValues:p,panOnDrag:z,panOnScroll:$,onPaneContextMenu:ne,onPanZoomEnd:c,onDraggingChange:f});g.on("end",Qe)}const Le=aK({zoomActivationKeyPressed:X,panOnDrag:z,zoomOnScroll:K,panOnScroll:$,zoomOnDoubleClick:J,zoomOnPinch:B,userSelectionActive:I,noPanClassName:q,noWheelClassName:P,lib:ce,connectionInProgress:de});g.filter(Le),J?x.on("dblclick.zoom",S):x.on("dblclick.zoom",null)}function C(){g.on("zoom",null)}async function N(P,q,ne){const I=Mv(P),$=g==null?void 0:g.constrain()(I,q,ne);return $&&await A($),new Promise(z=>z($))}async function R(P,q){const ne=Mv(P);return await A(ne,q),new Promise(I=>I(ne))}function O(P){if(x){const q=Mv(P),ne=x.property("__zoom");(ne.k!==P.zoom||ne.x!==P.x||ne.y!==P.y)&&(g==null||g.transform(x,q,null,{sync:!0}))}}function H(){const P=x?Hk(x.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}function D(P,q){return x?new Promise(ne=>{g==null||g.interpolate((q==null?void 0:q.interpolate)==="linear"?Mm:v0).scaleTo(Rv(x,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>ne(!0)),P)}):Promise.resolve(!1)}function F(P,q){return x?new Promise(ne=>{g==null||g.interpolate((q==null?void 0:q.interpolate)==="linear"?Mm:v0).scaleBy(Rv(x,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>ne(!0)),P)}):Promise.resolve(!1)}function Z(P){g==null||g.scaleExtent(P)}function V(P){g==null||g.translateExtent(P)}function Y(P){const q=!xl(P)||P<0?0:P;g==null||g.clickDistance(q)}return{update:T,destroy:C,setViewport:R,setViewportConstrained:N,getViewport:H,scaleTo:D,scaleBy:F,setScaleExtent:Z,setTranslateExtent:V,syncViewport:O,setClickDistance:Y}}var bh;(function(e){e.Line="line",e.Handle="handle"})(bh||(bh={}));function lK({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:s}){const l=e-t,c=n-i,f=[l>0?1:l<0?-1:0,c>0?1:c<0?-1:0];return l&&r&&(f[0]=f[0]*-1),c&&s&&(f[1]=f[1]*-1),f}function GT(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function tu(e,t){return Math.max(0,t-e)}function nu(e,t){return Math.max(0,e-t)}function u0(e,t,n){return Math.max(0,t-e,e-n)}function qT(e,t){return e?!t:t}function oK(e,t,n,i,r,s,l,c){let{affectsX:f,affectsY:p}=t;const{isHorizontal:m,isVertical:g}=t,x=m&&g,{xSnapped:v,ySnapped:S}=n,{minWidth:A,maxWidth:T,minHeight:C,maxHeight:N}=i,{x:R,y:O,width:H,height:D,aspectRatio:F}=e;let Z=Math.floor(m?v-e.pointerX:0),V=Math.floor(g?S-e.pointerY:0);const Y=H+(f?-Z:Z),P=D+(p?-V:V),q=-s[0]*H,ne=-s[1]*D;let I=u0(Y,A,T),$=u0(P,C,N);if(l){let Q=0,W=0;f&&Z<0?Q=tu(R+Z+q,l[0][0]):!f&&Z>0&&(Q=nu(R+Y+q,l[1][0])),p&&V<0?W=tu(O+V+ne,l[0][1]):!p&&V>0&&(W=nu(O+P+ne,l[1][1])),I=Math.max(I,Q),$=Math.max($,W)}if(c){let Q=0,W=0;f&&Z>0?Q=nu(R+Z,c[0][0]):!f&&Z<0&&(Q=tu(R+Y,c[1][0])),p&&V>0?W=nu(O+V,c[0][1]):!p&&V<0&&(W=tu(O+P,c[1][1])),I=Math.max(I,Q),$=Math.max($,W)}if(r){if(m){const Q=u0(Y/F,C,N)*F;if(I=Math.max(I,Q),l){let W=0;!f&&!p||f&&!p&&x?W=nu(O+ne+Y/F,l[1][1])*F:W=tu(O+ne+(f?Z:-Z)/F,l[0][1])*F,I=Math.max(I,W)}if(c){let W=0;!f&&!p||f&&!p&&x?W=tu(O+Y/F,c[1][1])*F:W=nu(O+(f?Z:-Z)/F,c[0][1])*F,I=Math.max(I,W)}}if(g){const Q=u0(P*F,A,T)/F;if($=Math.max($,Q),l){let W=0;!f&&!p||p&&!f&&x?W=nu(R+P*F+q,l[1][0])/F:W=tu(R+(p?V:-V)*F+q,l[0][0])/F,$=Math.max($,W)}if(c){let W=0;!f&&!p||p&&!f&&x?W=tu(R+P*F,c[1][0])/F:W=nu(R+(p?V:-V)*F,c[0][0])/F,$=Math.max($,W)}}}V=V+(V<0?$:-$),Z=Z+(Z<0?I:-I),r&&(x?Y>P*F?V=(qT(f,p)?-Z:Z)/F:Z=(qT(f,p)?-V:V)*F:m?(V=Z/F,p=f):(Z=V*F,f=p));const z=f?R+Z:R,G=p?O+V:O;return{width:H+(f?-Z:Z),height:D+(p?-V:V),x:s[0]*Z*(f?-1:1)+z,y:s[1]*V*(p?-1:1)+G}}const gN={width:0,height:0,x:0,y:0},cK={...gN,pointerX:0,pointerY:0,aspectRatio:1};function uK(e){return[[0,0],[e.measured.width,e.measured.height]]}function dK(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,s=e.measured.width??0,l=e.measured.height??0,c=n[0]*s,f=n[1]*l;return[[i-c,r-f],[i+s-c,r+l-f]]}function fK({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const s=ns(e);let l={controlDirection:GT("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:p,boundaries:m,keepAspectRatio:g,resizeDirection:x,onResizeStart:v,onResize:S,onResizeEnd:A,shouldResize:T}){let C={...gN},N={...cK};l={boundaries:m,resizeDirection:x,keepAspectRatio:g,controlDirection:GT(p)};let R,O=null,H=[],D,F,Z,V=!1;const Y=Ck().on("start",P=>{const{nodeLookup:q,transform:ne,snapGrid:I,snapToGrid:$,nodeOrigin:z,paneDomNode:G}=n();if(R=q.get(t),!R)return;O=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:W}=Rm(P.sourceEvent,{transform:ne,snapGrid:I,snapToGrid:$,containerBounds:O});C={width:R.measured.width??0,height:R.measured.height??0,x:R.position.x??0,y:R.position.y??0},N={...C,pointerX:Q,pointerY:W,aspectRatio:C.width/C.height},D=void 0,R.parentId&&(R.extent==="parent"||R.expandParent)&&(D=q.get(R.parentId),F=D&&R.extent==="parent"?uK(D):void 0),H=[],Z=void 0;for(const[B,K]of q)if(K.parentId===t&&(H.push({id:B,position:{...K.position},extent:K.extent}),K.extent==="parent"||K.expandParent)){const J=dK(K,R,K.origin??z);Z?Z=[[Math.min(J[0][0],Z[0][0]),Math.min(J[0][1],Z[0][1])],[Math.max(J[1][0],Z[1][0]),Math.max(J[1][1],Z[1][1])]]:Z=J}v==null||v(P,{...C})}).on("drag",P=>{const{transform:q,snapGrid:ne,snapToGrid:I,nodeOrigin:$}=n(),z=Rm(P.sourceEvent,{transform:q,snapGrid:ne,snapToGrid:I,containerBounds:O}),G=[];if(!R)return;const{x:Q,y:W,width:B,height:K}=C,J={},X=R.origin??$,{width:ce,height:ie,x:de,y:ye}=oK(N,l.controlDirection,z,l.boundaries,l.keepAspectRatio,X,F,Z),me=ce!==B,le=ie!==K,Re=de!==Q&&me,Le=ye!==W&≤if(!Re&&!Le&&!me&&!le)return;if((Re||Le||X[0]===1||X[1]===1)&&(J.x=Re?de:C.x,J.y=Le?ye:C.y,C.x=J.x,C.y=J.y,H.length>0)){const ot=de-Q,Ue=ye-W;for(const wt of H)wt.position={x:wt.position.x-ot+X[0]*(ce-B),y:wt.position.y-Ue+X[1]*(ie-K)},G.push(wt)}if((me||le)&&(J.width=me&&(!l.resizeDirection||l.resizeDirection==="horizontal")?ce:C.width,J.height=le&&(!l.resizeDirection||l.resizeDirection==="vertical")?ie:C.height,C.width=J.width,C.height=J.height),D&&R.expandParent){const ot=X[0]*(J.width??0);J.x&&J.x<ot&&(C.x=ot,N.x=N.x-(J.x-ot));const Ue=X[1]*(J.height??0);J.y&&J.y<Ue&&(C.y=Ue,N.y=N.y-(J.y-Ue))}const je=lK({width:C.width,prevWidth:B,height:C.height,prevHeight:K,affectsX:l.controlDirection.affectsX,affectsY:l.controlDirection.affectsY}),He={...C,direction:je};(T==null?void 0:T(P,He))!==!1&&(V=!0,S==null||S(P,He),i(J,G))}).on("end",P=>{V&&(A==null||A(P,{...C}),r==null||r({...C}),V=!1)});s.call(Y)}function f(){s.on(".drag",null)}return{update:c,destroy:f}}var kv={exports:{}},Nv={},Ov={exports:{}},Dv={};/**
|
|
379
379
|
* @license React
|
|
380
380
|
* use-sync-external-store-shim.production.js
|
|
381
381
|
*
|
|
@@ -397,4 +397,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),In=Ne,Xt=Ke),vt===void
|
|
|
397
397
|
`,`
|
|
398
398
|
+`).split(`
|
|
399
399
|
`)),m=p.reduce((g,x)=>g.concat(...x),[]);return[p,m]}return[[],[]]},[e]);return j.useEffect(()=>{const f=(t==null?void 0:t.target)??tC,p=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=v=>{var T,C;if(r.current=v.ctrlKey||v.metaKey||v.shiftKey||v.altKey,(!r.current||r.current&&!p)&&eN(v))return!1;const A=iC(v.code,c);if(s.current.add(v[A]),nC(l,s.current,!1)){const N=((C=(T=v.composedPath)==null?void 0:T.call(v))==null?void 0:C[0])||v.target,R=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(r.current||!R)&&v.preventDefault(),i(!0)}},g=v=>{const S=iC(v.code,c);nC(l,s.current,!0)?(i(!1),s.current.clear()):s.current.delete(v[S]),v.key==="Meta"&&s.current.clear(),r.current=!1},x=()=>{s.current.clear(),i(!1)};return f==null||f.addEventListener("keydown",m),f==null||f.addEventListener("keyup",g),window.addEventListener("blur",x),window.addEventListener("contextmenu",x),()=>{f==null||f.removeEventListener("keydown",m),f==null||f.removeEventListener("keyup",g),window.removeEventListener("blur",x),window.removeEventListener("contextmenu",x)}}},[e,i]),n}function nC(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function iC(e,t){return t.includes(e)?"code":"key"}const GK=()=>{const e=Zn();return j.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,r,s],panZoom:l}=e.getState();return l?(await l.setViewport({x:t.x??i,y:t.y??r,zoom:t.zoom??s},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:r,minZoom:s,maxZoom:l,panZoom:c}=e.getState(),f=X_(t,i,r,s,l,(n==null?void 0:n.padding)??.1);return c?(await c.setViewport(f,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:r,snapToGrid:s,domNode:l}=e.getState();if(!l)return t;const{x:c,y:f}=l.getBoundingClientRect(),p={x:t.x-c,y:t.y-f},m=n.snapGrid??r,g=n.snapToGrid??s;return cg(p,i,g,m)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:r,y:s}=i.getBoundingClientRect(),l=K0(t,n);return{x:l.x+r,y:l.y+s}}}),[])};function SN(e,t){const n=[],i=new Map,r=[];for(const s of e)if(s.type==="add"){r.push(s);continue}else if(s.type==="remove"||s.type==="replace")i.set(s.id,[s]);else{const l=i.get(s.id);l?l.push(s):i.set(s.id,[s])}for(const s of t){const l=i.get(s.id);if(!l){n.push(s);continue}if(l[0].type==="remove")continue;if(l[0].type==="replace"){n.push({...l[0].item});continue}const c={...s};for(const f of l)qK(f,c);n.push(c)}return r.length&&r.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function qK(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function YK(e,t){return SN(e,t)}function VK(e,t){return SN(e,t)}function pd(e,t){return{id:e,type:"select",selected:t}}function eh(e,t=new Set,n=!1){const i=[];for(const[r,s]of e){const l=t.has(r);!(s.selected===void 0&&!l)&&s.selected!==l&&(n&&(s.selected=l),i.push(pd(s.id,l)))}return i}function rC({items:e=[],lookup:t}){var r;const n=[],i=new Map(e.map(s=>[s.id,s]));for(const[s,l]of e.entries()){const c=t.get(l.id),f=((r=c==null?void 0:c.internals)==null?void 0:r.userNode)??c;f!==void 0&&f!==l&&n.push({id:l.id,item:l,type:"replace"}),f===void 0&&n.push({item:l,type:"add",index:s})}for(const[s]of t)i.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function aC(e){return{id:e.id,type:"remove"}}const sC=e=>pX(e),XK=e=>Vk(e);function EN(e){return j.forwardRef(e)}const KK=typeof window<"u"?j.useLayoutEffect:j.useEffect;function lC(e){const[t,n]=j.useState(BigInt(0)),[i]=j.useState(()=>$K(()=>n(r=>r+BigInt(1))));return KK(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function $K(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const wN=j.createContext(null);function WK({children:e}){const t=Zn(),n=j.useCallback(c=>{const{nodes:f=[],setNodes:p,hasDefaultNodes:m,onNodesChange:g,nodeLookup:x,fitViewQueued:v,onNodesChangeMiddlewareMap:S}=t.getState();let A=f;for(const C of c)A=typeof C=="function"?C(A):C;let T=rC({items:A,lookup:x});for(const C of S.values())T=C(T);m&&p(A),T.length>0?g==null||g(T):v&&window.requestAnimationFrame(()=>{const{fitViewQueued:C,nodes:N,setNodes:R}=t.getState();C&&R(N)})},[]),i=lC(n),r=j.useCallback(c=>{const{edges:f=[],setEdges:p,hasDefaultEdges:m,onEdgesChange:g,edgeLookup:x}=t.getState();let v=f;for(const S of c)v=typeof S=="function"?S(v):S;m?p(v):g&&g(rC({items:v,lookup:x}))},[]),s=lC(r),l=j.useMemo(()=>({nodeQueue:i,edgeQueue:s}),[]);return _.jsx(wN.Provider,{value:l,children:e})}function QK(){const e=j.useContext(wN);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const ZK=e=>!!e.panZoom;function Sx(){const e=GK(),t=Zn(),n=QK(),i=$t(ZK),r=j.useMemo(()=>{const s=g=>t.getState().nodeLookup.get(g),l=g=>{n.nodeQueue.push(g)},c=g=>{n.edgeQueue.push(g)},f=g=>{var C,N;const{nodeLookup:x,nodeOrigin:v}=t.getState(),S=sC(g)?g:x.get(g.id),A=S.parentId?Zk(S.position,S.measured,S.parentId,x,v):S.position,T={...S,position:A,width:((C=S.measured)==null?void 0:C.width)??S.width,height:((N=S.measured)==null?void 0:N.height)??S.height};return yh(T)},p=(g,x,v={replace:!1})=>{l(S=>S.map(A=>{if(A.id===g){const T=typeof x=="function"?x(A):x;return v.replace&&sC(T)?T:{...A,...T}}return A}))},m=(g,x,v={replace:!1})=>{c(S=>S.map(A=>{if(A.id===g){const T=typeof x=="function"?x(A):x;return v.replace&&XK(T)?T:{...A,...T}}return A}))};return{getNodes:()=>t.getState().nodes.map(g=>({...g})),getNode:g=>{var x;return(x=s(g))==null?void 0:x.internals.userNode},getInternalNode:s,getEdges:()=>{const{edges:g=[]}=t.getState();return g.map(x=>({...x}))},getEdge:g=>t.getState().edgeLookup.get(g),setNodes:l,setEdges:c,addNodes:g=>{const x=Array.isArray(g)?g:[g];n.nodeQueue.push(v=>[...v,...x])},addEdges:g=>{const x=Array.isArray(g)?g:[g];n.edgeQueue.push(v=>[...v,...x])},toObject:()=>{const{nodes:g=[],edges:x=[],transform:v}=t.getState(),[S,A,T]=v;return{nodes:g.map(C=>({...C})),edges:x.map(C=>({...C})),viewport:{x:S,y:A,zoom:T}}},deleteElements:async({nodes:g=[],edges:x=[]})=>{const{nodes:v,edges:S,onNodesDelete:A,onEdgesDelete:T,triggerNodeChanges:C,triggerEdgeChanges:N,onDelete:R,onBeforeDelete:O}=t.getState(),{nodes:H,edges:D}=await bX({nodesToRemove:g,edgesToRemove:x,nodes:v,edges:S,onBeforeDelete:O}),F=D.length>0,Z=H.length>0;if(F){const V=D.map(aC);T==null||T(D),N(V)}if(Z){const V=H.map(aC);A==null||A(H),C(V)}return(Z||F)&&(R==null||R({nodes:H,edges:D})),{deletedNodes:H,deletedEdges:D}},getIntersectingNodes:(g,x=!0,v)=>{const S=OT(g),A=S?g:f(g),T=v!==void 0;return A?(v||t.getState().nodes).filter(C=>{const N=t.getState().nodeLookup.get(C.id);if(N&&!S&&(C.id===g.id||!N.internals.positionAbsolute))return!1;const R=yh(T?C:N),O=Vm(R,A);return x&&O>0||O>=R.width*R.height||O>=A.width*A.height}):[]},isNodeIntersecting:(g,x,v=!0)=>{const A=OT(g)?g:f(g);if(!A)return!1;const T=Vm(A,x);return v&&T>0||T>=x.width*x.height||T>=A.width*A.height},updateNode:p,updateNodeData:(g,x,v={replace:!1})=>{p(g,S=>{const A=typeof x=="function"?x(S):x;return v.replace?{...S,data:A}:{...S,data:{...S.data,...A}}},v)},updateEdge:m,updateEdgeData:(g,x,v={replace:!1})=>{m(g,S=>{const A=typeof x=="function"?x(S):x;return v.replace?{...S,data:A}:{...S,data:{...S.data,...A}}},v)},getNodesBounds:g=>{const{nodeLookup:x,nodeOrigin:v}=t.getState();return mX(g,{nodeLookup:x,nodeOrigin:v})},getHandleConnections:({type:g,id:x,nodeId:v})=>{var S;return Array.from(((S=t.getState().connectionLookup.get(`${v}-${g}${x?`-${x}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:g,handleId:x,nodeId:v})=>{var S;return Array.from(((S=t.getState().connectionLookup.get(`${v}${g?x?`-${g}-${x}`:`-${g}`:""}`))==null?void 0:S.values())??[])},fitView:async g=>{const x=t.getState().fitViewResolver??EX();return t.setState({fitViewQueued:!0,fitViewOptions:g,fitViewResolver:x}),n.nodeQueue.push(v=>[...v]),x.promise}}},[]);return j.useMemo(()=>({...r,...e,viewportInitialized:i}),[i])}const oC=e=>e.selected,JK=typeof window<"u"?window:void 0;function e$({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Zn(),{deleteElements:i}=Sx(),r=Km(e,{actInsideInputWithModifier:!1}),s=Km(t,{target:JK});j.useEffect(()=>{if(r){const{edges:l,nodes:c}=n.getState();i({nodes:c.filter(oC),edges:l.filter(oC)}),n.setState({nodesSelectionActive:!1})}},[r]),j.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])}function t$(e){const t=Zn();j.useEffect(()=>{const n=()=>{var r,s,l,c;if(!e.current||!(((s=(r=e.current).checkVisibility)==null?void 0:s.call(r))??!0))return!1;const i=K_(e.current);(i.height===0||i.width===0)&&((c=(l=t.getState()).onError)==null||c.call(l,"004",go.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const Ex={position:"absolute",width:"100%",height:"100%",top:0,left:0},n$=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function i$({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panOnScrollSpeed:r=.5,panOnScrollMode:s=bd.Free,zoomOnDoubleClick:l=!0,panOnDrag:c=!0,defaultViewport:f,translateExtent:p,minZoom:m,maxZoom:g,zoomActivationKeyCode:x,preventScrolling:v=!0,children:S,noWheelClassName:A,noPanClassName:T,onViewportChange:C,isControlledViewport:N,paneClickDistance:R,selectionOnDrag:O}){const H=Zn(),D=j.useRef(null),{userSelectionActive:F,lib:Z,connectionInProgress:V}=$t(n$,Qn),Y=Km(x),P=j.useRef();t$(D);const q=j.useCallback(ne=>{C==null||C({x:ne[0],y:ne[1],zoom:ne[2]}),N||H.setState({transform:ne})},[C,N]);return j.useEffect(()=>{if(D.current){P.current=sK({domNode:D.current,minZoom:m,maxZoom:g,translateExtent:p,viewport:f,onDraggingChange:z=>H.setState(G=>G.paneDragging===z?G:{paneDragging:z}),onPanZoomStart:(z,G)=>{const{onViewportChangeStart:Q,onMoveStart:W}=H.getState();W==null||W(z,G),Q==null||Q(G)},onPanZoom:(z,G)=>{const{onViewportChange:Q,onMove:W}=H.getState();W==null||W(z,G),Q==null||Q(G)},onPanZoomEnd:(z,G)=>{const{onViewportChangeEnd:Q,onMoveEnd:W}=H.getState();W==null||W(z,G),Q==null||Q(G)}});const{x:ne,y:I,zoom:$}=P.current.getViewport();return H.setState({panZoom:P.current,transform:[ne,I,$],domNode:D.current.closest(".react-flow")}),()=>{var z;(z=P.current)==null||z.destroy()}}},[]),j.useEffect(()=>{var ne;(ne=P.current)==null||ne.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panOnScrollSpeed:r,panOnScrollMode:s,zoomOnDoubleClick:l,panOnDrag:c,zoomActivationKeyPressed:Y,preventScrolling:v,noPanClassName:T,userSelectionActive:F,noWheelClassName:A,lib:Z,onTransformChange:q,connectionInProgress:V,selectionOnDrag:O,paneClickDistance:R})},[e,t,n,i,r,s,l,c,Y,v,T,F,A,Z,q,V,O,R]),_.jsx("div",{className:"react-flow__renderer",ref:D,style:Ex,children:S})}const r$=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function a$(){const{userSelectionActive:e,userSelectionRect:t}=$t(r$,Qn);return e&&t?_.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const zv=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},s$=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function l$({isSelecting:e,selectionKeyPressed:t,selectionMode:n=qm.Full,panOnDrag:i,paneClickDistance:r,selectionOnDrag:s,onSelectionStart:l,onSelectionEnd:c,onPaneClick:f,onPaneContextMenu:p,onPaneScroll:m,onPaneMouseEnter:g,onPaneMouseMove:x,onPaneMouseLeave:v,children:S}){const A=Zn(),{userSelectionActive:T,elementsSelectable:C,dragging:N,connectionInProgress:R}=$t(s$,Qn),O=C&&(e||T),H=j.useRef(null),D=j.useRef(),F=j.useRef(new Set),Z=j.useRef(new Set),V=j.useRef(!1),Y=Q=>{if(V.current||R){V.current=!1;return}f==null||f(Q),A.getState().resetSelectedElements(),A.setState({nodesSelectionActive:!1})},P=Q=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){Q.preventDefault();return}p==null||p(Q)},q=m?Q=>m(Q):void 0,ne=Q=>{V.current&&(Q.stopPropagation(),V.current=!1)},I=Q=>{var ie,de;const{domNode:W}=A.getState();if(D.current=W==null?void 0:W.getBoundingClientRect(),!D.current)return;const B=Q.target===H.current;if(!B&&!!Q.target.closest(".nokey")||!e||!(s&&B||t)||Q.button!==0||!Q.isPrimary)return;(de=(ie=Q.target)==null?void 0:ie.setPointerCapture)==null||de.call(ie,Q.pointerId),V.current=!1;const{x:X,y:ce}=bl(Q.nativeEvent,D.current);A.setState({userSelectionRect:{width:0,height:0,startX:X,startY:ce,x:X,y:ce}}),B||(Q.stopPropagation(),Q.preventDefault())},$=Q=>{const{userSelectionRect:W,transform:B,nodeLookup:K,edgeLookup:J,connectionLookup:X,triggerNodeChanges:ce,triggerEdgeChanges:ie,defaultEdgeOptions:de,resetSelectedElements:ye}=A.getState();if(!D.current||!W)return;const{x:me,y:le}=bl(Q.nativeEvent,D.current),{startX:Re,startY:Le}=W;if(!V.current){const Ue=t?0:r;if(Math.hypot(me-Re,le-Le)<=Ue)return;ye(),l==null||l(Q)}V.current=!0;const je={startX:Re,startY:Le,x:me<Re?me:Re,y:le<Le?le:Le,width:Math.abs(me-Re),height:Math.abs(le-Le)},He=F.current,Qe=Z.current;F.current=new Set(V_(K,je,B,n===qm.Partial,!0).map(Ue=>Ue.id)),Z.current=new Set;const ot=(de==null?void 0:de.selectable)??!0;for(const Ue of F.current){const wt=X.get(Ue);if(wt)for(const{edgeId:_n}of wt.values()){const Sn=J.get(_n);Sn&&(Sn.selectable??ot)&&Z.current.add(_n)}}if(!DT(He,F.current)){const Ue=eh(K,F.current,!0);ce(Ue)}if(!DT(Qe,Z.current)){const Ue=eh(J,Z.current);ie(Ue)}A.setState({userSelectionRect:je,userSelectionActive:!0,nodesSelectionActive:!1})},z=Q=>{var W,B;Q.button===0&&((B=(W=Q.target)==null?void 0:W.releasePointerCapture)==null||B.call(W,Q.pointerId),!T&&Q.target===H.current&&A.getState().userSelectionRect&&(Y==null||Y(Q)),A.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(c==null||c(Q),A.setState({nodesSelectionActive:F.current.size>0})))},G=i===!0||Array.isArray(i)&&i.includes(0);return _.jsxs("div",{className:zi(["react-flow__pane",{draggable:G,dragging:N,selection:e}]),onClick:O?void 0:zv(Y,H),onContextMenu:zv(P,H),onWheel:zv(q,H),onPointerEnter:O?void 0:g,onPointerMove:O?$:x,onPointerUp:O?z:void 0,onPointerDownCapture:O?I:void 0,onClickCapture:O?ne:void 0,onPointerLeave:v,ref:H,style:Ex,children:[S,_.jsx(a$,{})]})}function G1({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:l,nodeLookup:c,onError:f}=t.getState(),p=c.get(e);if(!p){f==null||f("012",go.error012(e));return}t.setState({nodesSelectionActive:!1}),p.selected?(n||p.selected&&l)&&(s({nodes:[p],edges:[]}),requestAnimationFrame(()=>{var m;return(m=i==null?void 0:i.current)==null?void 0:m.blur()})):r([e])}function TN({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:r,isSelectable:s,nodeClickDistance:l}){const c=Zn(),[f,p]=j.useState(!1),m=j.useRef();return j.useEffect(()=>{m.current=VX({getStoreItems:()=>c.getState(),onNodeMouseDown:g=>{G1({id:g,store:c,nodeRef:e})},onDragStart:()=>{p(!0)},onDragStop:()=>{p(!1)}})},[]),j.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:s,nodeId:r,nodeClickDistance:l}),()=>{var g;(g=m.current)==null||g.destroy()}},[n,i,t,s,e,r,l]),f}const o$=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function CN(){const e=Zn();return j.useCallback(n=>{const{nodeExtent:i,snapToGrid:r,snapGrid:s,nodesDraggable:l,onError:c,updateNodePositions:f,nodeLookup:p,nodeOrigin:m}=e.getState(),g=new Map,x=o$(l),v=r?s[0]:5,S=r?s[1]:5,A=n.direction.x*v*n.factor,T=n.direction.y*S*n.factor;for(const[,C]of p){if(!x(C))continue;let N={x:C.internals.positionAbsolute.x+A,y:C.internals.positionAbsolute.y+T};r&&(N=og(N,s));const{position:R,positionAbsolute:O}=Xk({nodeId:C.id,nextPosition:N,nodeLookup:p,nodeExtent:i,nodeOrigin:m,onError:c});C.position=R,C.internals.positionAbsolute=O,g.set(C.id,C)}f(g)},[])}const eS=j.createContext(null),c$=eS.Provider;eS.Consumer;const AN=()=>j.useContext(eS),u$=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),d$=(e,t,n)=>i=>{const{connectionClickStartHandle:r,connectionMode:s,connection:l}=i,{fromHandle:c,toHandle:f,isValid:p}=l,m=(f==null?void 0:f.nodeId)===e&&(f==null?void 0:f.id)===t&&(f==null?void 0:f.type)===n;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n,connectingTo:m,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:s===mh.Strict?(c==null?void 0:c.type)!==n:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!r,valid:m&&p}};function f$({type:e="source",position:t=We.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:l,onConnect:c,children:f,className:p,onMouseDown:m,onTouchStart:g,...x},v){var $,z;const S=l||null,A=e==="target",T=Zn(),C=AN(),{connectOnClick:N,noPanClassName:R,rfId:O}=$t(u$,Qn),{connectingFrom:H,connectingTo:D,clickConnecting:F,isPossibleEndHandle:Z,connectionInProcess:V,clickConnectionInProcess:Y,valid:P}=$t(d$(C,S,e),Qn);C||(z=($=T.getState()).onError)==null||z.call($,"010",go.error010());const q=G=>{const{defaultEdgeOptions:Q,onConnect:W,hasDefaultEdges:B}=T.getState(),K={...Q,...G};if(B){const{edges:J,setEdges:X}=T.getState();X(kX(K,J))}W==null||W(K),c==null||c(K)},ne=G=>{if(!C)return;const Q=tN(G.nativeEvent);if(r&&(Q&&G.button===0||!Q)){const W=T.getState();F1.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:W.autoPanOnConnect,connectionMode:W.connectionMode,connectionRadius:W.connectionRadius,domNode:W.domNode,nodeLookup:W.nodeLookup,lib:W.lib,isTarget:A,handleId:S,nodeId:C,flowId:W.rfId,panBy:W.panBy,cancelConnection:W.cancelConnection,onConnectStart:W.onConnectStart,onConnectEnd:(...B)=>{var K,J;return(J=(K=T.getState()).onConnectEnd)==null?void 0:J.call(K,...B)},updateConnection:W.updateConnection,onConnect:q,isValidConnection:n||((...B)=>{var K,J;return((J=(K=T.getState()).isValidConnection)==null?void 0:J.call(K,...B))??!0}),getTransform:()=>T.getState().transform,getFromHandle:()=>T.getState().connection.fromHandle,autoPanSpeed:W.autoPanSpeed,dragThreshold:W.connectionDragThreshold})}Q?m==null||m(G):g==null||g(G)},I=G=>{const{onClickConnectStart:Q,onClickConnectEnd:W,connectionClickStartHandle:B,connectionMode:K,isValidConnection:J,lib:X,rfId:ce,nodeLookup:ie,connection:de}=T.getState();if(!C||!B&&!r)return;if(!B){Q==null||Q(G.nativeEvent,{nodeId:C,handleId:S,handleType:e}),T.setState({connectionClickStartHandle:{nodeId:C,type:e,id:S}});return}const ye=Jk(G.target),me=n||J,{connection:le,isValid:Re}=F1.isValid(G.nativeEvent,{handle:{nodeId:C,id:S,type:e},connectionMode:K,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:me,flowId:ce,doc:ye,lib:X,nodeLookup:ie});Re&&le&&q(le);const Le=structuredClone(de);delete Le.inProgress,Le.toPosition=Le.toHandle?Le.toHandle.position:null,W==null||W(G,Le),T.setState({connectionClickStartHandle:null})};return _.jsx("div",{"data-handleid":S,"data-nodeid":C,"data-handlepos":t,"data-id":`${O}-${C}-${S}-${e}`,className:zi(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",R,p,{source:!A,target:A,connectable:i,connectablestart:r,connectableend:s,clickconnecting:F,connectingfrom:H,connectingto:D,valid:P,connectionindicator:i&&(!V||Z)&&(V||Y?s:r)}]),onMouseDown:ne,onTouchStart:ne,onClick:N?I:void 0,ref:v,...x,children:f})}const Sl=j.memo(EN(f$));function h$({data:e,isConnectable:t,sourcePosition:n=We.Bottom}){return _.jsxs(_.Fragment,{children:[e==null?void 0:e.label,_.jsx(Sl,{type:"source",position:n,isConnectable:t})]})}function p$({data:e,isConnectable:t,targetPosition:n=We.Top,sourcePosition:i=We.Bottom}){return _.jsxs(_.Fragment,{children:[_.jsx(Sl,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,_.jsx(Sl,{type:"source",position:i,isConnectable:t})]})}function m$(){return null}function g$({data:e,isConnectable:t,targetPosition:n=We.Top}){return _.jsxs(_.Fragment,{children:[_.jsx(Sl,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const $0={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},cC={input:h$,default:p$,output:g$,group:m$};function y$(e){var t,n,i,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const x$=e=>{const{width:t,height:n,x:i,y:r}=lg(e.nodeLookup,{filter:s=>!!s.selected});return{width:xl(t)?t:null,height:xl(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${r}px)`}};function b$({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=Zn(),{width:r,height:s,transformString:l,userSelectionActive:c}=$t(x$,Qn),f=CN(),p=j.useRef(null);j.useEffect(()=>{var v;n||(v=p.current)==null||v.focus({preventScroll:!0})},[n]);const m=!c&&r!==null&&s!==null;if(TN({nodeRef:p,disabled:!m}),!m)return null;const g=e?v=>{const S=i.getState().nodes.filter(A=>A.selected);e(v,S)}:void 0,x=v=>{Object.prototype.hasOwnProperty.call($0,v.key)&&(v.preventDefault(),f({direction:$0[v.key],factor:v.shiftKey?4:1}))};return _.jsx("div",{className:zi(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l},children:_.jsx("div",{ref:p,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:x,style:{width:r,height:s}})})}const uC=typeof window<"u"?window:void 0,v$=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function MN({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:l,paneClickDistance:c,deleteKeyCode:f,selectionKeyCode:p,selectionOnDrag:m,selectionMode:g,onSelectionStart:x,onSelectionEnd:v,multiSelectionKeyCode:S,panActivationKeyCode:A,zoomActivationKeyCode:T,elementsSelectable:C,zoomOnScroll:N,zoomOnPinch:R,panOnScroll:O,panOnScrollSpeed:H,panOnScrollMode:D,zoomOnDoubleClick:F,panOnDrag:Z,defaultViewport:V,translateExtent:Y,minZoom:P,maxZoom:q,preventScrolling:ne,onSelectionContextMenu:I,noWheelClassName:$,noPanClassName:z,disableKeyboardA11y:G,onViewportChange:Q,isControlledViewport:W}){const{nodesSelectionActive:B,userSelectionActive:K}=$t(v$,Qn),J=Km(p,{target:uC}),X=Km(A,{target:uC}),ce=X||Z,ie=X||O,de=m&&ce!==!0,ye=J||K||de;return e$({deleteKeyCode:f,multiSelectionKeyCode:S}),_.jsx(i$,{onPaneContextMenu:s,elementsSelectable:C,zoomOnScroll:N,zoomOnPinch:R,panOnScroll:ie,panOnScrollSpeed:H,panOnScrollMode:D,zoomOnDoubleClick:F,panOnDrag:!J&&ce,defaultViewport:V,translateExtent:Y,minZoom:P,maxZoom:q,zoomActivationKeyCode:T,preventScrolling:ne,noWheelClassName:$,noPanClassName:z,onViewportChange:Q,isControlledViewport:W,paneClickDistance:c,selectionOnDrag:de,children:_.jsxs(l$,{onSelectionStart:x,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:l,panOnDrag:ce,isSelecting:!!ye,selectionMode:g,selectionKeyPressed:J,paneClickDistance:c,selectionOnDrag:de,children:[e,B&&_.jsx(b$,{onSelectionContextMenu:I,noPanClassName:z,disableKeyboardA11y:G})]})})}MN.displayName="FlowRenderer";const _$=j.memo(MN),S$=e=>t=>e?V_(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function E$(e){return $t(j.useCallback(S$(e),[e]),Qn)}const w$=e=>e.updateNodeInternals;function T$(){const e=$t(w$),[t]=j.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(r=>{const s=r.target.getAttribute("data-id");i.set(s,{id:s,nodeElement:r.target,force:!0})}),e(i)}));return j.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function C$({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const r=Zn(),s=j.useRef(null),l=j.useRef(null),c=j.useRef(e.sourcePosition),f=j.useRef(e.targetPosition),p=j.useRef(t),m=n&&!!e.internals.handleBounds;return j.useEffect(()=>{s.current&&!e.hidden&&(!m||l.current!==s.current)&&(l.current&&(i==null||i.unobserve(l.current)),i==null||i.observe(s.current),l.current=s.current)},[m,e.hidden]),j.useEffect(()=>()=>{l.current&&(i==null||i.unobserve(l.current),l.current=null)},[]),j.useEffect(()=>{if(s.current){const g=p.current!==t,x=c.current!==e.sourcePosition,v=f.current!==e.targetPosition;(g||x||v)&&(p.current=t,c.current=e.sourcePosition,f.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function A$({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:r,onContextMenu:s,onDoubleClick:l,nodesDraggable:c,elementsSelectable:f,nodesConnectable:p,nodesFocusable:m,resizeObserver:g,noDragClassName:x,noPanClassName:v,disableKeyboardA11y:S,rfId:A,nodeTypes:T,nodeClickDistance:C,onError:N}){const{node:R,internals:O,isParent:H}=$t(me=>{const le=me.nodeLookup.get(e),Re=me.parentLookup.has(e);return{node:le,internals:le.internals,isParent:Re}},Qn);let D=R.type||"default",F=(T==null?void 0:T[D])||cC[D];F===void 0&&(N==null||N("003",go.error003(D)),D="default",F=(T==null?void 0:T.default)||cC.default);const Z=!!(R.draggable||c&&typeof R.draggable>"u"),V=!!(R.selectable||f&&typeof R.selectable>"u"),Y=!!(R.connectable||p&&typeof R.connectable>"u"),P=!!(R.focusable||m&&typeof R.focusable>"u"),q=Zn(),ne=Qk(R),I=C$({node:R,nodeType:D,hasDimensions:ne,resizeObserver:g}),$=TN({nodeRef:I,disabled:R.hidden||!Z,noDragClassName:x,handleSelector:R.dragHandle,nodeId:e,isSelectable:V,nodeClickDistance:C}),z=CN();if(R.hidden)return null;const G=dc(R),Q=y$(R),W=V||Z||t||n||i||r,B=n?me=>n(me,{...O.userNode}):void 0,K=i?me=>i(me,{...O.userNode}):void 0,J=r?me=>r(me,{...O.userNode}):void 0,X=s?me=>s(me,{...O.userNode}):void 0,ce=l?me=>l(me,{...O.userNode}):void 0,ie=me=>{const{selectNodesOnDrag:le,nodeDragThreshold:Re}=q.getState();V&&(!le||!Z||Re>0)&&G1({id:e,store:q,nodeRef:I}),t&&t(me,{...O.userNode})},de=me=>{if(!(eN(me.nativeEvent)||S)){if(Fk.includes(me.key)&&V){const le=me.key==="Escape";G1({id:e,store:q,unselect:le,nodeRef:I})}else if(Z&&R.selected&&Object.prototype.hasOwnProperty.call($0,me.key)){me.preventDefault();const{ariaLabelConfig:le}=q.getState();q.setState({ariaLiveMessage:le["node.a11yDescription.ariaLiveMessage"]({direction:me.key.replace("Arrow","").toLowerCase(),x:~~O.positionAbsolute.x,y:~~O.positionAbsolute.y})}),z({direction:$0[me.key],factor:me.shiftKey?4:1})}}},ye=()=>{var Qe;if(S||!((Qe=I.current)!=null&&Qe.matches(":focus-visible")))return;const{transform:me,width:le,height:Re,autoPanOnNodeFocus:Le,setCenter:je}=q.getState();if(!Le)return;V_(new Map([[e,R]]),{x:0,y:0,width:le,height:Re},me,!0).length>0||je(R.position.x+G.width/2,R.position.y+G.height/2,{zoom:me[2]})};return _.jsx("div",{className:zi(["react-flow__node",`react-flow__node-${D}`,{[v]:Z},R.className,{selected:R.selected,selectable:V,parent:H,draggable:Z,dragging:$}]),ref:I,style:{zIndex:O.z,transform:`translate(${O.positionAbsolute.x}px,${O.positionAbsolute.y}px)`,pointerEvents:W?"all":"none",visibility:ne?"visible":"hidden",...R.style,...Q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:K,onMouseLeave:J,onContextMenu:X,onClick:ie,onDoubleClick:ce,onKeyDown:P?de:void 0,tabIndex:P?0:void 0,onFocus:P?ye:void 0,role:R.ariaRole??(P?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${bN}-${A}`,"aria-label":R.ariaLabel,...R.domAttributes,children:_.jsx(c$,{value:e,children:_.jsx(F,{id:e,data:R.data,type:D,positionAbsoluteX:O.positionAbsolute.x,positionAbsoluteY:O.positionAbsolute.y,selected:R.selected??!1,selectable:V,draggable:Z,deletable:R.deletable??!0,isConnectable:Y,sourcePosition:R.sourcePosition,targetPosition:R.targetPosition,dragging:$,dragHandle:R.dragHandle,zIndex:O.z,parentId:R.parentId,...G})})})}var M$=j.memo(A$);const R$=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function RN(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,onError:s}=$t(R$,Qn),l=E$(e.onlyRenderVisibleElements),c=T$();return _.jsx("div",{className:"react-flow__nodes",style:Ex,children:l.map(f=>_.jsx(M$,{id:f,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:s},f))})}RN.displayName="NodeRenderer";const k$=j.memo(RN);function N$(e){return $t(j.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const i=[];if(n.width&&n.height)for(const r of n.edges){const s=n.nodeLookup.get(r.source),l=n.nodeLookup.get(r.target);s&&l&&AX({sourceNode:s,targetNode:l,width:n.width,height:n.height,transform:n.transform})&&i.push(r.id)}return i},[e]),Qn)}const O$=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return _.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},D$=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return _.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},dC={[Ym.Arrow]:O$,[Ym.ArrowClosed]:D$};function z$(e){const t=Zn();return j.useMemo(()=>{var r,s;return Object.prototype.hasOwnProperty.call(dC,e)?dC[e]:((s=(r=t.getState()).onError)==null||s.call(r,"009",go.error009(e)),null)},[e])}const B$=({id:e,type:t,color:n,width:i=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:l,orient:c="auto-start-reverse"})=>{const f=z$(t);return f?_.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:c,refX:"0",refY:"0",children:_.jsx(f,{color:n,strokeWidth:l})}):null},kN=({defaultColor:e,rfId:t})=>{const n=$t(s=>s.edges),i=$t(s=>s.defaultEdgeOptions),r=j.useMemo(()=>BX(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return r.length?_.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:_.jsx("defs",{children:r.map(s=>_.jsx(B$,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};kN.displayName="MarkerDefinitions";var L$=j.memo(kN);function NN({x:e,y:t,label:n,labelStyle:i,labelShowBg:r=!0,labelBgStyle:s,labelBgPadding:l=[2,4],labelBgBorderRadius:c=2,children:f,className:p,...m}){const[g,x]=j.useState({x:1,y:0,width:0,height:0}),v=zi(["react-flow__edge-textwrapper",p]),S=j.useRef(null);return j.useEffect(()=>{if(S.current){const A=S.current.getBBox();x({x:A.x,y:A.y,width:A.width,height:A.height})}},[n]),n?_.jsxs("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:v,visibility:g.width?"visible":"hidden",...m,children:[r&&_.jsx("rect",{width:g.width+2*l[0],x:-l[0],y:-l[1],height:g.height+2*l[1],className:"react-flow__edge-textbg",style:s,rx:c,ry:c}),_.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:S,style:i,children:n}),f]}):null}NN.displayName="EdgeText";const j$=j.memo(NN);function wx({path:e,labelX:t,labelY:n,label:i,labelStyle:r,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:f,interactionWidth:p=20,...m}){return _.jsxs(_.Fragment,{children:[_.jsx("path",{...m,d:e,fill:"none",className:zi(["react-flow__edge-path",m.className])}),p?_.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:p,className:"react-flow__edge-interaction"}):null,i&&xl(t)&&xl(n)?_.jsx(j$,{x:t,y:n,label:i,labelStyle:r,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:f}):null]})}function fC({pos:e,x1:t,y1:n,x2:i,y2:r}){return e===We.Left||e===We.Right?[.5*(t+i),n]:[t,.5*(n+r)]}function ON({sourceX:e,sourceY:t,sourcePosition:n=We.Bottom,targetX:i,targetY:r,targetPosition:s=We.Top}){const[l,c]=fC({pos:n,x1:e,y1:t,x2:i,y2:r}),[f,p]=fC({pos:s,x1:i,y1:r,x2:e,y2:t}),[m,g,x,v]=nN({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:l,sourceControlY:c,targetControlX:f,targetControlY:p});return[`M${e},${t} C${l},${c} ${f},${p} ${i},${r}`,m,g,x,v]}function DN(e){return j.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,sourcePosition:l,targetPosition:c,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:v,style:S,markerEnd:A,markerStart:T,interactionWidth:C})=>{const[N,R,O]=ON({sourceX:n,sourceY:i,sourcePosition:l,targetX:r,targetY:s,targetPosition:c}),H=e.isInternal?void 0:t;return _.jsx(wx,{id:H,path:N,labelX:R,labelY:O,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:v,style:S,markerEnd:A,markerStart:T,interactionWidth:C})})}const I$=DN({isInternal:!1}),zN=DN({isInternal:!0});I$.displayName="SimpleBezierEdge";zN.displayName="SimpleBezierEdgeInternal";function BN(e){return j.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:g,style:x,sourcePosition:v=We.Bottom,targetPosition:S=We.Top,markerEnd:A,markerStart:T,pathOptions:C,interactionWidth:N})=>{const[R,O,H]=U1({sourceX:n,sourceY:i,sourcePosition:v,targetX:r,targetY:s,targetPosition:S,borderRadius:C==null?void 0:C.borderRadius,offset:C==null?void 0:C.offset,stepPosition:C==null?void 0:C.stepPosition}),D=e.isInternal?void 0:t;return _.jsx(wx,{id:D,path:R,labelX:O,labelY:H,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:g,style:x,markerEnd:A,markerStart:T,interactionWidth:N})})}const LN=BN({isInternal:!1}),jN=BN({isInternal:!0});LN.displayName="SmoothStepEdge";jN.displayName="SmoothStepEdgeInternal";function IN(e){return j.memo(({id:t,...n})=>{var r;const i=e.isInternal?void 0:t;return _.jsx(LN,{...n,id:i,pathOptions:j.useMemo(()=>{var s;return{borderRadius:0,offset:(s=n.pathOptions)==null?void 0:s.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const U$=IN({isInternal:!1}),UN=IN({isInternal:!0});U$.displayName="StepEdge";UN.displayName="StepEdgeInternal";function HN(e){return j.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:g,style:x,markerEnd:v,markerStart:S,interactionWidth:A})=>{const[T,C,N]=aN({sourceX:n,sourceY:i,targetX:r,targetY:s}),R=e.isInternal?void 0:t;return _.jsx(wx,{id:R,path:T,labelX:C,labelY:N,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:g,style:x,markerEnd:v,markerStart:S,interactionWidth:A})})}const H$=HN({isInternal:!1}),PN=HN({isInternal:!0});H$.displayName="StraightEdge";PN.displayName="StraightEdgeInternal";function FN(e){return j.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:s,sourcePosition:l=We.Bottom,targetPosition:c=We.Top,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:v,style:S,markerEnd:A,markerStart:T,pathOptions:C,interactionWidth:N})=>{const[R,O,H]=iN({sourceX:n,sourceY:i,sourcePosition:l,targetX:r,targetY:s,targetPosition:c,curvature:C==null?void 0:C.curvature}),D=e.isInternal?void 0:t;return _.jsx(wx,{id:D,path:R,labelX:O,labelY:H,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:v,style:S,markerEnd:A,markerStart:T,interactionWidth:N})})}const P$=FN({isInternal:!1}),GN=FN({isInternal:!0});P$.displayName="BezierEdge";GN.displayName="BezierEdgeInternal";const hC={default:GN,straight:PN,step:UN,smoothstep:jN,simplebezier:zN},pC={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},F$=(e,t,n)=>n===We.Left?e-t:n===We.Right?e+t:e,G$=(e,t,n)=>n===We.Top?e-t:n===We.Bottom?e+t:e,mC="react-flow__edgeupdater";function gC({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:r,onMouseEnter:s,onMouseOut:l,type:c}){return _.jsx("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:l,className:zi([mC,`${mC}-${c}`]),cx:F$(t,i,e),cy:G$(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function q$({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:r,targetX:s,targetY:l,sourcePosition:c,targetPosition:f,onReconnect:p,onReconnectStart:m,onReconnectEnd:g,setReconnecting:x,setUpdateHover:v}){const S=Zn(),A=(O,H)=>{if(O.button!==0)return;const{autoPanOnConnect:D,domNode:F,connectionMode:Z,connectionRadius:V,lib:Y,onConnectStart:P,cancelConnection:q,nodeLookup:ne,rfId:I,panBy:$,updateConnection:z}=S.getState(),G=H.type==="target",Q=(K,J)=>{x(!1),g==null||g(K,n,H.type,J)},W=K=>p==null?void 0:p(n,K),B=(K,J)=>{x(!0),m==null||m(O,n,H.type),P==null||P(K,J)};F1.onPointerDown(O.nativeEvent,{autoPanOnConnect:D,connectionMode:Z,connectionRadius:V,domNode:F,handleId:H.id,nodeId:H.nodeId,nodeLookup:ne,isTarget:G,edgeUpdaterType:H.type,lib:Y,flowId:I,cancelConnection:q,panBy:$,isValidConnection:(...K)=>{var J,X;return((X=(J=S.getState()).isValidConnection)==null?void 0:X.call(J,...K))??!0},onConnect:W,onConnectStart:B,onConnectEnd:(...K)=>{var J,X;return(X=(J=S.getState()).onConnectEnd)==null?void 0:X.call(J,...K)},onReconnectEnd:Q,updateConnection:z,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:O.currentTarget})},T=O=>A(O,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),C=O=>A(O,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),N=()=>v(!0),R=()=>v(!1);return _.jsxs(_.Fragment,{children:[(e===!0||e==="source")&&_.jsx(gC,{position:c,centerX:i,centerY:r,radius:t,onMouseDown:T,onMouseEnter:N,onMouseOut:R,type:"source"}),(e===!0||e==="target")&&_.jsx(gC,{position:f,centerX:s,centerY:l,radius:t,onMouseDown:C,onMouseEnter:N,onMouseOut:R,type:"target"})]})}function Y$({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:r,onDoubleClick:s,onContextMenu:l,onMouseEnter:c,onMouseMove:f,onMouseLeave:p,reconnectRadius:m,onReconnect:g,onReconnectStart:x,onReconnectEnd:v,rfId:S,edgeTypes:A,noPanClassName:T,onError:C,disableKeyboardA11y:N}){let R=$t(je=>je.edgeLookup.get(e));const O=$t(je=>je.defaultEdgeOptions);R=O?{...O,...R}:R;let H=R.type||"default",D=(A==null?void 0:A[H])||hC[H];D===void 0&&(C==null||C("011",go.error011(H)),H="default",D=(A==null?void 0:A.default)||hC.default);const F=!!(R.focusable||t&&typeof R.focusable>"u"),Z=typeof g<"u"&&(R.reconnectable||n&&typeof R.reconnectable>"u"),V=!!(R.selectable||i&&typeof R.selectable>"u"),Y=j.useRef(null),[P,q]=j.useState(!1),[ne,I]=j.useState(!1),$=Zn(),{zIndex:z,sourceX:G,sourceY:Q,targetX:W,targetY:B,sourcePosition:K,targetPosition:J}=$t(j.useCallback(je=>{const He=je.nodeLookup.get(R.source),Qe=je.nodeLookup.get(R.target);if(!He||!Qe)return{zIndex:R.zIndex,...pC};const ot=zX({id:e,sourceNode:He,targetNode:Qe,sourceHandle:R.sourceHandle||null,targetHandle:R.targetHandle||null,connectionMode:je.connectionMode,onError:C});return{zIndex:CX({selected:R.selected,zIndex:R.zIndex,sourceNode:He,targetNode:Qe,elevateOnSelect:je.elevateEdgesOnSelect,zIndexMode:je.zIndexMode}),...ot||pC}},[R.source,R.target,R.sourceHandle,R.targetHandle,R.selected,R.zIndex]),Qn),X=j.useMemo(()=>R.markerStart?`url('#${H1(R.markerStart,S)}')`:void 0,[R.markerStart,S]),ce=j.useMemo(()=>R.markerEnd?`url('#${H1(R.markerEnd,S)}')`:void 0,[R.markerEnd,S]);if(R.hidden||G===null||Q===null||W===null||B===null)return null;const ie=je=>{var Ue;const{addSelectedEdges:He,unselectNodesAndEdges:Qe,multiSelectionActive:ot}=$.getState();V&&($.setState({nodesSelectionActive:!1}),R.selected&&ot?(Qe({nodes:[],edges:[R]}),(Ue=Y.current)==null||Ue.blur()):He([e])),r&&r(je,R)},de=s?je=>{s(je,{...R})}:void 0,ye=l?je=>{l(je,{...R})}:void 0,me=c?je=>{c(je,{...R})}:void 0,le=f?je=>{f(je,{...R})}:void 0,Re=p?je=>{p(je,{...R})}:void 0,Le=je=>{var He;if(!N&&Fk.includes(je.key)&&V){const{unselectNodesAndEdges:Qe,addSelectedEdges:ot}=$.getState();je.key==="Escape"?((He=Y.current)==null||He.blur(),Qe({edges:[R]})):ot([e])}};return _.jsx("svg",{style:{zIndex:z},children:_.jsxs("g",{className:zi(["react-flow__edge",`react-flow__edge-${H}`,R.className,T,{selected:R.selected,animated:R.animated,inactive:!V&&!r,updating:P,selectable:V}]),onClick:ie,onDoubleClick:de,onContextMenu:ye,onMouseEnter:me,onMouseMove:le,onMouseLeave:Re,onKeyDown:F?Le:void 0,tabIndex:F?0:void 0,role:R.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":R.ariaLabel===null?void 0:R.ariaLabel||`Edge from ${R.source} to ${R.target}`,"aria-describedby":F?`${vN}-${S}`:void 0,ref:Y,...R.domAttributes,children:[!ne&&_.jsx(D,{id:e,source:R.source,target:R.target,type:R.type,selected:R.selected,animated:R.animated,selectable:V,deletable:R.deletable??!0,label:R.label,labelStyle:R.labelStyle,labelShowBg:R.labelShowBg,labelBgStyle:R.labelBgStyle,labelBgPadding:R.labelBgPadding,labelBgBorderRadius:R.labelBgBorderRadius,sourceX:G,sourceY:Q,targetX:W,targetY:B,sourcePosition:K,targetPosition:J,data:R.data,style:R.style,sourceHandleId:R.sourceHandle,targetHandleId:R.targetHandle,markerStart:X,markerEnd:ce,pathOptions:"pathOptions"in R?R.pathOptions:void 0,interactionWidth:R.interactionWidth}),Z&&_.jsx(q$,{edge:R,isReconnectable:Z,reconnectRadius:m,onReconnect:g,onReconnectStart:x,onReconnectEnd:v,sourceX:G,sourceY:Q,targetX:W,targetY:B,sourcePosition:K,targetPosition:J,setUpdateHover:q,setReconnecting:I})]})})}var V$=j.memo(Y$);const X$=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function qN({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:r,onReconnect:s,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:f,onEdgeMouseLeave:p,onEdgeClick:m,reconnectRadius:g,onEdgeDoubleClick:x,onReconnectStart:v,onReconnectEnd:S,disableKeyboardA11y:A}){const{edgesFocusable:T,edgesReconnectable:C,elementsSelectable:N,onError:R}=$t(X$,Qn),O=N$(t);return _.jsxs("div",{className:"react-flow__edges",children:[_.jsx(L$,{defaultColor:e,rfId:n}),O.map(H=>_.jsx(V$,{id:H,edgesFocusable:T,edgesReconnectable:C,elementsSelectable:N,noPanClassName:r,onReconnect:s,onContextMenu:l,onMouseEnter:c,onMouseMove:f,onMouseLeave:p,onClick:m,reconnectRadius:g,onDoubleClick:x,onReconnectStart:v,onReconnectEnd:S,rfId:n,onError:R,edgeTypes:i,disableKeyboardA11y:A},H))]})}qN.displayName="EdgeRenderer";const K$=j.memo(qN),$$=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function W$({children:e}){const t=$t($$);return _.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Q$(e){const t=Sx(),n=j.useRef(!1);j.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Z$=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function J$(e){const t=$t(Z$),n=Zn();return j.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function eW(e){return e.connection.inProgress?{...e.connection,to:cg(e.connection.to,e.transform)}:{...e.connection}}function tW(e){return eW}function nW(e){const t=tW();return $t(t,Qn)}const iW=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function rW({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:r,width:s,height:l,isValid:c,inProgress:f}=$t(iW,Qn);return!(s&&r&&f)?null:_.jsx("svg",{style:e,width:s,height:l,className:"react-flow__connectionline react-flow__container",children:_.jsx("g",{className:zi(["react-flow__connection",Yk(c)]),children:_.jsx(YN,{style:t,type:n,CustomComponent:i,isValid:c})})})}const YN=({style:e,type:t=su.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:r,from:s,fromNode:l,fromHandle:c,fromPosition:f,to:p,toNode:m,toHandle:g,toPosition:x,pointer:v}=nW();if(!r)return;if(n)return _.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:l,fromHandle:c,fromX:s.x,fromY:s.y,toX:p.x,toY:p.y,fromPosition:f,toPosition:x,connectionStatus:Yk(i),toNode:m,toHandle:g,pointer:v});let S="";const A={sourceX:s.x,sourceY:s.y,sourcePosition:f,targetX:p.x,targetY:p.y,targetPosition:x};switch(t){case su.Bezier:[S]=iN(A);break;case su.SimpleBezier:[S]=ON(A);break;case su.Step:[S]=U1({...A,borderRadius:0});break;case su.SmoothStep:[S]=U1(A);break;default:[S]=aN(A)}return _.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:e})};YN.displayName="ConnectionLine";const aW={};function yC(e=aW){j.useRef(e),Zn(),j.useEffect(()=>{},[e])}function sW(){Zn(),j.useRef(!1),j.useEffect(()=>{},[])}function VN({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:s,onEdgeDoubleClick:l,onNodeMouseEnter:c,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:m,onSelectionContextMenu:g,onSelectionStart:x,onSelectionEnd:v,connectionLineType:S,connectionLineStyle:A,connectionLineComponent:T,connectionLineContainerStyle:C,selectionKeyCode:N,selectionOnDrag:R,selectionMode:O,multiSelectionKeyCode:H,panActivationKeyCode:D,zoomActivationKeyCode:F,deleteKeyCode:Z,onlyRenderVisibleElements:V,elementsSelectable:Y,defaultViewport:P,translateExtent:q,minZoom:ne,maxZoom:I,preventScrolling:$,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:Q,panOnScroll:W,panOnScrollSpeed:B,panOnScrollMode:K,zoomOnDoubleClick:J,panOnDrag:X,onPaneClick:ce,onPaneMouseEnter:ie,onPaneMouseMove:de,onPaneMouseLeave:ye,onPaneScroll:me,onPaneContextMenu:le,paneClickDistance:Re,nodeClickDistance:Le,onEdgeContextMenu:je,onEdgeMouseEnter:He,onEdgeMouseMove:Qe,onEdgeMouseLeave:ot,reconnectRadius:Ue,onReconnect:wt,onReconnectStart:_n,onReconnectEnd:Sn,noDragClassName:hn,noWheelClassName:oi,noPanClassName:Ur,disableKeyboardA11y:Ci,nodeExtent:Wt,rfId:sr,viewport:Ee,onViewportChange:ke}){return yC(e),yC(t),sW(),Q$(n),J$(Ee),_.jsx(_$,{onPaneClick:ce,onPaneMouseEnter:ie,onPaneMouseMove:de,onPaneMouseLeave:ye,onPaneContextMenu:le,onPaneScroll:me,paneClickDistance:Re,deleteKeyCode:Z,selectionKeyCode:N,selectionOnDrag:R,selectionMode:O,onSelectionStart:x,onSelectionEnd:v,multiSelectionKeyCode:H,panActivationKeyCode:D,zoomActivationKeyCode:F,elementsSelectable:Y,zoomOnScroll:G,zoomOnPinch:Q,zoomOnDoubleClick:J,panOnScroll:W,panOnScrollSpeed:B,panOnScrollMode:K,panOnDrag:X,defaultViewport:P,translateExtent:q,minZoom:ne,maxZoom:I,onSelectionContextMenu:g,preventScrolling:$,noDragClassName:hn,noWheelClassName:oi,noPanClassName:Ur,disableKeyboardA11y:Ci,onViewportChange:ke,isControlledViewport:!!Ee,children:_.jsxs(W$,{children:[_.jsx(K$,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:l,onReconnect:wt,onReconnectStart:_n,onReconnectEnd:Sn,onlyRenderVisibleElements:V,onEdgeContextMenu:je,onEdgeMouseEnter:He,onEdgeMouseMove:Qe,onEdgeMouseLeave:ot,reconnectRadius:Ue,defaultMarkerColor:z,noPanClassName:Ur,disableKeyboardA11y:Ci,rfId:sr}),_.jsx(rW,{style:A,type:S,component:T,containerStyle:C}),_.jsx("div",{className:"react-flow__edgelabel-renderer"}),_.jsx(k$,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:m,nodeClickDistance:Le,onlyRenderVisibleElements:V,noPanClassName:Ur,noDragClassName:hn,disableKeyboardA11y:Ci,nodeExtent:Wt,rfId:sr}),_.jsx("div",{className:"react-flow__viewport-portal"})]})})}VN.displayName="GraphView";const lW=j.memo(VN),xC=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:s,fitView:l,fitViewOptions:c,minZoom:f=.5,maxZoom:p=2,nodeOrigin:m,nodeExtent:g,zIndexMode:x="basic"}={})=>{const v=new Map,S=new Map,A=new Map,T=new Map,C=i??t??[],N=n??e??[],R=m??[0,0],O=g??Gm;oN(A,T,C);const H=P1(N,v,S,{nodeOrigin:R,nodeExtent:O,zIndexMode:x});let D=[0,0,1];if(l&&r&&s){const F=lg(v,{filter:P=>!!((P.width||P.initialWidth)&&(P.height||P.initialHeight))}),{x:Z,y:V,zoom:Y}=X_(F,r,s,f,p,(c==null?void 0:c.padding)??.1);D=[Z,V,Y]}return{rfId:"1",width:r??0,height:s??0,transform:D,nodes:N,nodesInitialized:H,nodeLookup:v,parentLookup:S,edges:C,edgeLookup:T,connectionLookup:A,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:f,maxZoom:p,translateExtent:Gm,nodeExtent:O,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:mh.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:R,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:l??!1,fitViewOptions:c,fitViewResolver:null,connection:{...qk},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:vX,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Gk,zIndexMode:x,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},oW=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:s,fitView:l,fitViewOptions:c,minZoom:f,maxZoom:p,nodeOrigin:m,nodeExtent:g,zIndexMode:x})=>wK((v,S)=>{async function A(){const{nodeLookup:T,panZoom:C,fitViewOptions:N,fitViewResolver:R,width:O,height:H,minZoom:D,maxZoom:F}=S();C&&(await xX({nodes:T,width:O,height:H,panZoom:C,minZoom:D,maxZoom:F},N),R==null||R.resolve(!0),v({fitViewResolver:null}))}return{...xC({nodes:e,edges:t,width:r,height:s,fitView:l,fitViewOptions:c,minZoom:f,maxZoom:p,nodeOrigin:m,nodeExtent:g,defaultNodes:n,defaultEdges:i,zIndexMode:x}),setNodes:T=>{const{nodeLookup:C,parentLookup:N,nodeOrigin:R,elevateNodesOnSelect:O,fitViewQueued:H,zIndexMode:D}=S(),F=P1(T,C,N,{nodeOrigin:R,nodeExtent:g,elevateNodesOnSelect:O,checkEquality:!0,zIndexMode:D});H&&F?(A(),v({nodes:T,nodesInitialized:F,fitViewQueued:!1,fitViewOptions:void 0})):v({nodes:T,nodesInitialized:F})},setEdges:T=>{const{connectionLookup:C,edgeLookup:N}=S();oN(C,N,T),v({edges:T})},setDefaultNodesAndEdges:(T,C)=>{if(T){const{setNodes:N}=S();N(T),v({hasDefaultNodes:!0})}if(C){const{setEdges:N}=S();N(C),v({hasDefaultEdges:!0})}},updateNodeInternals:T=>{const{triggerNodeChanges:C,nodeLookup:N,parentLookup:R,domNode:O,nodeOrigin:H,nodeExtent:D,debug:F,fitViewQueued:Z,zIndexMode:V}=S(),{changes:Y,updatedInternals:P}=FX(T,N,R,O,H,D,V);P&&(IX(N,R,{nodeOrigin:H,nodeExtent:D,zIndexMode:V}),Z?(A(),v({fitViewQueued:!1,fitViewOptions:void 0})):v({}),(Y==null?void 0:Y.length)>0&&(F&&console.log("React Flow: trigger node changes",Y),C==null||C(Y)))},updateNodePositions:(T,C=!1)=>{const N=[];let R=[];const{nodeLookup:O,triggerNodeChanges:H,connection:D,updateConnection:F,onNodesChangeMiddlewareMap:Z}=S();for(const[V,Y]of T){const P=O.get(V),q=!!(P!=null&&P.expandParent&&(P!=null&&P.parentId)&&(Y!=null&&Y.position)),ne={id:V,type:"position",position:q?{x:Math.max(0,Y.position.x),y:Math.max(0,Y.position.y)}:Y.position,dragging:C};if(P&&D.inProgress&&D.fromNode.id===P.id){const I=Cd(P,D.fromHandle,We.Left,!0);F({...D,from:I})}q&&P.parentId&&N.push({id:V,parentId:P.parentId,rect:{...Y.internals.positionAbsolute,width:Y.measured.width??0,height:Y.measured.height??0}}),R.push(ne)}if(N.length>0){const{parentLookup:V,nodeOrigin:Y}=S(),P=J_(N,O,V,Y);R.push(...P)}for(const V of Z.values())R=V(R);H(R)},triggerNodeChanges:T=>{const{onNodesChange:C,setNodes:N,nodes:R,hasDefaultNodes:O,debug:H}=S();if(T!=null&&T.length){if(O){const D=YK(T,R);N(D)}H&&console.log("React Flow: trigger node changes",T),C==null||C(T)}},triggerEdgeChanges:T=>{const{onEdgesChange:C,setEdges:N,edges:R,hasDefaultEdges:O,debug:H}=S();if(T!=null&&T.length){if(O){const D=VK(T,R);N(D)}H&&console.log("React Flow: trigger edge changes",T),C==null||C(T)}},addSelectedNodes:T=>{const{multiSelectionActive:C,edgeLookup:N,nodeLookup:R,triggerNodeChanges:O,triggerEdgeChanges:H}=S();if(C){const D=T.map(F=>pd(F,!0));O(D);return}O(eh(R,new Set([...T]),!0)),H(eh(N))},addSelectedEdges:T=>{const{multiSelectionActive:C,edgeLookup:N,nodeLookup:R,triggerNodeChanges:O,triggerEdgeChanges:H}=S();if(C){const D=T.map(F=>pd(F,!0));H(D);return}H(eh(N,new Set([...T]))),O(eh(R,new Set,!0))},unselectNodesAndEdges:({nodes:T,edges:C}={})=>{const{edges:N,nodes:R,nodeLookup:O,triggerNodeChanges:H,triggerEdgeChanges:D}=S(),F=T||R,Z=C||N,V=[];for(const P of F){if(!P.selected)continue;const q=O.get(P.id);q&&(q.selected=!1),V.push(pd(P.id,!1))}const Y=[];for(const P of Z)P.selected&&Y.push(pd(P.id,!1));H(V),D(Y)},setMinZoom:T=>{const{panZoom:C,maxZoom:N}=S();C==null||C.setScaleExtent([T,N]),v({minZoom:T})},setMaxZoom:T=>{const{panZoom:C,minZoom:N}=S();C==null||C.setScaleExtent([N,T]),v({maxZoom:T})},setTranslateExtent:T=>{var C;(C=S().panZoom)==null||C.setTranslateExtent(T),v({translateExtent:T})},resetSelectedElements:()=>{const{edges:T,nodes:C,triggerNodeChanges:N,triggerEdgeChanges:R,elementsSelectable:O}=S();if(!O)return;const H=C.reduce((F,Z)=>Z.selected?[...F,pd(Z.id,!1)]:F,[]),D=T.reduce((F,Z)=>Z.selected?[...F,pd(Z.id,!1)]:F,[]);N(H),R(D)},setNodeExtent:T=>{const{nodes:C,nodeLookup:N,parentLookup:R,nodeOrigin:O,elevateNodesOnSelect:H,nodeExtent:D,zIndexMode:F}=S();T[0][0]===D[0][0]&&T[0][1]===D[0][1]&&T[1][0]===D[1][0]&&T[1][1]===D[1][1]||(P1(C,N,R,{nodeOrigin:O,nodeExtent:T,elevateNodesOnSelect:H,checkEquality:!1,zIndexMode:F}),v({nodeExtent:T}))},panBy:T=>{const{transform:C,width:N,height:R,panZoom:O,translateExtent:H}=S();return GX({delta:T,panZoom:O,transform:C,translateExtent:H,width:N,height:R})},setCenter:async(T,C,N)=>{const{width:R,height:O,maxZoom:H,panZoom:D}=S();if(!D)return Promise.resolve(!1);const F=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:H;return await D.setViewport({x:R/2-T*F,y:O/2-C*F,zoom:F},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{v({connection:{...qk}})},updateConnection:T=>{v({connection:T})},reset:()=>v({...xC()})}},Object.is);function XN({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:r,initialHeight:s,initialMinZoom:l,initialMaxZoom:c,initialFitViewOptions:f,fitView:p,nodeOrigin:m,nodeExtent:g,zIndexMode:x,children:v}){const[S]=j.useState(()=>oW({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:s,fitView:p,minZoom:l,maxZoom:c,fitViewOptions:f,nodeOrigin:m,nodeExtent:g,zIndexMode:x}));return _.jsx(TK,{value:S,children:_.jsx(WK,{children:v})})}function cW({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:r,width:s,height:l,fitView:c,fitViewOptions:f,minZoom:p,maxZoom:m,nodeOrigin:g,nodeExtent:x,zIndexMode:v}){return j.useContext(vx)?_.jsx(_.Fragment,{children:e}):_.jsx(XN,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:r,initialWidth:s,initialHeight:l,fitView:c,initialFitViewOptions:f,initialMinZoom:p,initialMaxZoom:m,nodeOrigin:g,nodeExtent:x,zIndexMode:v,children:e})}const uW={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function dW({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:r,nodeTypes:s,edgeTypes:l,onNodeClick:c,onEdgeClick:f,onInit:p,onMove:m,onMoveStart:g,onMoveEnd:x,onConnect:v,onConnectStart:S,onConnectEnd:A,onClickConnectStart:T,onClickConnectEnd:C,onNodeMouseEnter:N,onNodeMouseMove:R,onNodeMouseLeave:O,onNodeContextMenu:H,onNodeDoubleClick:D,onNodeDragStart:F,onNodeDrag:Z,onNodeDragStop:V,onNodesDelete:Y,onEdgesDelete:P,onDelete:q,onSelectionChange:ne,onSelectionDragStart:I,onSelectionDrag:$,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:W,onBeforeDelete:B,connectionMode:K,connectionLineType:J=su.Bezier,connectionLineStyle:X,connectionLineComponent:ce,connectionLineContainerStyle:ie,deleteKeyCode:de="Backspace",selectionKeyCode:ye="Shift",selectionOnDrag:me=!1,selectionMode:le=qm.Full,panActivationKeyCode:Re="Space",multiSelectionKeyCode:Le=Xm()?"Meta":"Control",zoomActivationKeyCode:je=Xm()?"Meta":"Control",snapToGrid:He,snapGrid:Qe,onlyRenderVisibleElements:ot=!1,selectNodesOnDrag:Ue,nodesDraggable:wt,autoPanOnNodeFocus:_n,nodesConnectable:Sn,nodesFocusable:hn,nodeOrigin:oi=_N,edgesFocusable:Ur,edgesReconnectable:Ci,elementsSelectable:Wt=!0,defaultViewport:sr=IK,minZoom:Ee=.5,maxZoom:ke=2,translateExtent:oe=Gm,preventScrolling:Pe=!0,nodeExtent:ct,defaultMarkerColor:tn="#b1b1b7",zoomOnScroll:ci=!0,zoomOnPinch:Qt=!0,panOnScroll:Zt=!1,panOnScrollSpeed:Gn=.5,panOnScrollMode:Pt=bd.Free,zoomOnDoubleClick:Yi=!0,panOnDrag:Jn=!0,onPaneClick:vo,onPaneMouseEnter:ls,onPaneMouseMove:Ba,onPaneMouseLeave:os,onPaneScroll:vi,onPaneContextMenu:se,paneClickDistance:Te=1,nodeClickDistance:Ie=0,children:tt,onReconnect:nn,onReconnectStart:rn,onReconnectEnd:Ye,onEdgeContextMenu:Ge,onEdgeDoubleClick:nt,onEdgeMouseEnter:Rn,onEdgeMouseMove:Ft,onEdgeMouseLeave:ga,reconnectRadius:lr=10,onNodesChange:Vi,onEdgesChange:or,noDragClassName:bt="nodrag",noWheelClassName:ui="nowheel",noPanClassName:Hr="nopan",fitView:Us,fitViewOptions:Cl,connectOnClick:Al,attributionPosition:Ml,proOptions:La,defaultEdgeOptions:Hs,elevateNodesOnSelect:an=!0,elevateEdgesOnSelect:sn=!1,disableKeyboardA11y:cr=!1,autoPanOnConnect:Pr,autoPanOnNodeDrag:jn,autoPanSpeed:Sr,connectionRadius:ya,isValidConnection:Fr,onError:Ne,style:Ke,id:vt,nodeDragThreshold:Xt,connectionDragThreshold:In,viewport:_i,onViewportChange:Xi,width:Ai,height:pn,colorMode:ur="light",debug:_o,onScroll:xa,ariaLabelConfig:Rl,zIndexMode:ja="basic",...fc},Bi){const cs=vt||"1",us=FK(ur),Ps=j.useCallback(di=>{di.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),xa==null||xa(di)},[xa]);return _.jsx("div",{"data-testid":"rf__wrapper",...fc,onScroll:Ps,style:{...Ke,...uW},ref:Bi,className:zi(["react-flow",r,us]),id:vt,role:"application",children:_.jsxs(cW,{nodes:e,edges:t,width:Ai,height:pn,fitView:Us,fitViewOptions:Cl,minZoom:Ee,maxZoom:ke,nodeOrigin:oi,nodeExtent:ct,zIndexMode:ja,children:[_.jsx(lW,{onInit:p,onNodeClick:c,onEdgeClick:f,onNodeMouseEnter:N,onNodeMouseMove:R,onNodeMouseLeave:O,onNodeContextMenu:H,onNodeDoubleClick:D,nodeTypes:s,edgeTypes:l,connectionLineType:J,connectionLineStyle:X,connectionLineComponent:ce,connectionLineContainerStyle:ie,selectionKeyCode:ye,selectionOnDrag:me,selectionMode:le,deleteKeyCode:de,multiSelectionKeyCode:Le,panActivationKeyCode:Re,zoomActivationKeyCode:je,onlyRenderVisibleElements:ot,defaultViewport:sr,translateExtent:oe,minZoom:Ee,maxZoom:ke,preventScrolling:Pe,zoomOnScroll:ci,zoomOnPinch:Qt,zoomOnDoubleClick:Yi,panOnScroll:Zt,panOnScrollSpeed:Gn,panOnScrollMode:Pt,panOnDrag:Jn,onPaneClick:vo,onPaneMouseEnter:ls,onPaneMouseMove:Ba,onPaneMouseLeave:os,onPaneScroll:vi,onPaneContextMenu:se,paneClickDistance:Te,nodeClickDistance:Ie,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:W,onReconnect:nn,onReconnectStart:rn,onReconnectEnd:Ye,onEdgeContextMenu:Ge,onEdgeDoubleClick:nt,onEdgeMouseEnter:Rn,onEdgeMouseMove:Ft,onEdgeMouseLeave:ga,reconnectRadius:lr,defaultMarkerColor:tn,noDragClassName:bt,noWheelClassName:ui,noPanClassName:Hr,rfId:cs,disableKeyboardA11y:cr,nodeExtent:ct,viewport:_i,onViewportChange:Xi}),_.jsx(PK,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:v,onConnectStart:S,onConnectEnd:A,onClickConnectStart:T,onClickConnectEnd:C,nodesDraggable:wt,autoPanOnNodeFocus:_n,nodesConnectable:Sn,nodesFocusable:hn,edgesFocusable:Ur,edgesReconnectable:Ci,elementsSelectable:Wt,elevateNodesOnSelect:an,elevateEdgesOnSelect:sn,minZoom:Ee,maxZoom:ke,nodeExtent:ct,onNodesChange:Vi,onEdgesChange:or,snapToGrid:He,snapGrid:Qe,connectionMode:K,translateExtent:oe,connectOnClick:Al,defaultEdgeOptions:Hs,fitView:Us,fitViewOptions:Cl,onNodesDelete:Y,onEdgesDelete:P,onDelete:q,onNodeDragStart:F,onNodeDrag:Z,onNodeDragStop:V,onSelectionDrag:$,onSelectionDragStart:I,onSelectionDragStop:z,onMove:m,onMoveStart:g,onMoveEnd:x,noPanClassName:Hr,nodeOrigin:oi,rfId:cs,autoPanOnConnect:Pr,autoPanOnNodeDrag:jn,autoPanSpeed:Sr,onError:Ne,connectionRadius:ya,isValidConnection:Fr,selectNodesOnDrag:Ue,nodeDragThreshold:Xt,connectionDragThreshold:In,onBeforeDelete:B,debug:_o,ariaLabelConfig:Rl,zIndexMode:ja}),_.jsx(jK,{onSelectionChange:ne}),tt,_.jsx(OK,{proOptions:La,position:Ml}),_.jsx(NK,{rfId:cs,disableKeyboardA11y:cr})]})})}var fW=EN(dW);function hW({dimensions:e,lineWidth:t,variant:n,className:i}){return _.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:zi(["react-flow__background-pattern",n,i])})}function pW({radius:e,className:t}){return _.jsx("circle",{cx:e,cy:e,r:e,className:zi(["react-flow__background-pattern","dots",t])})}var cu;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(cu||(cu={}));const mW={[cu.Dots]:1,[cu.Lines]:1,[cu.Cross]:6},gW=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function KN({id:e,variant:t=cu.Dots,gap:n=20,size:i,lineWidth:r=1,offset:s=0,color:l,bgColor:c,style:f,className:p,patternClassName:m}){const g=j.useRef(null),{transform:x,patternId:v}=$t(gW,Qn),S=i||mW[t],A=t===cu.Dots,T=t===cu.Cross,C=Array.isArray(n)?n:[n,n],N=[C[0]*x[2]||1,C[1]*x[2]||1],R=S*x[2],O=Array.isArray(s)?s:[s,s],H=T?[R,R]:N,D=[O[0]*x[2]||1+H[0]/2,O[1]*x[2]||1+H[1]/2],F=`${v}${e||""}`;return _.jsxs("svg",{className:zi(["react-flow__background",p]),style:{...f,...Ex,"--xy-background-color-props":c,"--xy-background-pattern-color-props":l},ref:g,"data-testid":"rf__background",children:[_.jsx("pattern",{id:F,x:x[0]%N[0],y:x[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:A?_.jsx(pW,{radius:R/2,className:m}):_.jsx(hW,{dimensions:H,lineWidth:r,variant:t,className:m})}),_.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}KN.displayName="Background";const yW=j.memo(KN);function xW(){return _.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:_.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function bW(){return _.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:_.jsx("path",{d:"M0 0h32v4.2H0z"})})}function vW(){return _.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:_.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function _W(){return _.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:_.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function SW(){return _.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:_.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function f0({children:e,className:t,...n}){return _.jsx("button",{type:"button",className:zi(["react-flow__controls-button",t]),...n,children:e})}const EW=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function $N({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:l,onFitView:c,onInteractiveChange:f,className:p,children:m,position:g="bottom-left",orientation:x="vertical","aria-label":v}){const S=Zn(),{isInteractive:A,minZoomReached:T,maxZoomReached:C,ariaLabelConfig:N}=$t(EW,Qn),{zoomIn:R,zoomOut:O,fitView:H}=Sx(),D=()=>{R(),s==null||s()},F=()=>{O(),l==null||l()},Z=()=>{H(r),c==null||c()},V=()=>{S.setState({nodesDraggable:!A,nodesConnectable:!A,elementsSelectable:!A}),f==null||f(!A)},Y=x==="horizontal"?"horizontal":"vertical";return _.jsxs(_x,{className:zi(["react-flow__controls",Y,p]),position:g,style:e,"data-testid":"rf__controls","aria-label":v??N["controls.ariaLabel"],children:[t&&_.jsxs(_.Fragment,{children:[_.jsx(f0,{onClick:D,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:C,children:_.jsx(xW,{})}),_.jsx(f0,{onClick:F,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:T,children:_.jsx(bW,{})})]}),n&&_.jsx(f0,{className:"react-flow__controls-fitview",onClick:Z,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:_.jsx(vW,{})}),i&&_.jsx(f0,{className:"react-flow__controls-interactive",onClick:V,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:A?_.jsx(SW,{}):_.jsx(_W,{})}),m]})}$N.displayName="Controls";const wW=j.memo($N);function TW({id:e,x:t,y:n,width:i,height:r,style:s,color:l,strokeColor:c,strokeWidth:f,className:p,borderRadius:m,shapeRendering:g,selected:x,onClick:v}){const{background:S,backgroundColor:A}=s||{},T=l||S||A;return _.jsx("rect",{className:zi(["react-flow__minimap-node",{selected:x},p]),x:t,y:n,rx:m,ry:m,width:i,height:r,style:{fill:T,stroke:c,strokeWidth:f},shapeRendering:g,onClick:v?C=>v(C,e):void 0})}const CW=j.memo(TW),AW=e=>e.nodes.map(t=>t.id),Bv=e=>e instanceof Function?e:()=>e;function MW({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:s=CW,onClick:l}){const c=$t(AW,Qn),f=Bv(t),p=Bv(e),m=Bv(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return _.jsx(_.Fragment,{children:c.map(x=>_.jsx(kW,{id:x,nodeColorFunc:f,nodeStrokeColorFunc:p,nodeClassNameFunc:m,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:s,onClick:l,shapeRendering:g},x))})}function RW({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:s,shapeRendering:l,NodeComponent:c,onClick:f}){const{node:p,x:m,y:g,width:x,height:v}=$t(S=>{const A=S.nodeLookup.get(e);if(!A)return{node:void 0,x:0,y:0,width:0,height:0};const T=A.internals.userNode,{x:C,y:N}=A.internals.positionAbsolute,{width:R,height:O}=dc(T);return{node:T,x:C,y:N,width:R,height:O}},Qn);return!p||p.hidden||!Qk(p)?null:_.jsx(c,{x:m,y:g,width:x,height:v,style:p.style,selected:!!p.selected,className:i(p),color:t(p),borderRadius:r,strokeColor:n(p),strokeWidth:s,shapeRendering:l,onClick:f,id:p.id})}const kW=j.memo(RW);var NW=j.memo(MW);const OW=200,DW=150,zW=e=>!e.hidden,BW=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Wk(lg(e.nodeLookup,{filter:zW}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},LW="react-flow__minimap-desc";function WN({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:r="",nodeBorderRadius:s=5,nodeStrokeWidth:l,nodeComponent:c,bgColor:f,maskColor:p,maskStrokeColor:m,maskStrokeWidth:g,position:x="bottom-right",onClick:v,onNodeClick:S,pannable:A=!1,zoomable:T=!1,ariaLabel:C,inversePan:N,zoomStep:R=1,offsetScale:O=5}){const H=Zn(),D=j.useRef(null),{boundingRect:F,viewBB:Z,rfId:V,panZoom:Y,translateExtent:P,flowWidth:q,flowHeight:ne,ariaLabelConfig:I}=$t(BW,Qn),$=(e==null?void 0:e.width)??OW,z=(e==null?void 0:e.height)??DW,G=F.width/$,Q=F.height/z,W=Math.max(G,Q),B=W*$,K=W*z,J=O*W,X=F.x-(B-F.width)/2-J,ce=F.y-(K-F.height)/2-J,ie=B+J*2,de=K+J*2,ye=`${LW}-${V}`,me=j.useRef(0),le=j.useRef();me.current=W,j.useEffect(()=>{if(D.current&&Y)return le.current=ZX({domNode:D.current,panZoom:Y,getTransform:()=>H.getState().transform,getViewScale:()=>me.current}),()=>{var He;(He=le.current)==null||He.destroy()}},[Y]),j.useEffect(()=>{var He;(He=le.current)==null||He.update({translateExtent:P,width:q,height:ne,inversePan:N,pannable:A,zoomStep:R,zoomable:T})},[A,T,N,R,P,q,ne]);const Re=v?He=>{var Ue;const[Qe,ot]=((Ue=le.current)==null?void 0:Ue.pointer(He))||[0,0];v(He,{x:Qe,y:ot})}:void 0,Le=S?j.useCallback((He,Qe)=>{const ot=H.getState().nodeLookup.get(Qe).internals.userNode;S(He,ot)},[]):void 0,je=C??I["minimap.ariaLabel"];return _.jsx(_x,{position:x,style:{...e,"--xy-minimap-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof g=="number"?g*W:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof l=="number"?l:void 0},className:zi(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:_.jsxs("svg",{width:$,height:z,viewBox:`${X} ${ce} ${ie} ${de}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ye,ref:D,onClick:Re,children:[je&&_.jsx("title",{id:ye,children:je}),_.jsx(NW,{onClick:Le,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:r,nodeStrokeWidth:l,nodeComponent:c}),_.jsx("path",{className:"react-flow__minimap-mask",d:`M${X-J},${ce-J}h${ie+J*2}v${de+J*2}h${-ie-J*2}z
|
|
400
|
-
M${Z.x},${Z.y}h${Z.width}v${Z.height}h${-Z.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}WN.displayName="MiniMap";const jW=j.memo(WN),IW=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,UW={[bh.Line]:"right",[bh.Handle]:"bottom-right"};function HW({nodeId:e,position:t,variant:n=bh.Handle,className:i,style:r=void 0,children:s,color:l,minWidth:c=10,minHeight:f=10,maxWidth:p=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:x,autoScale:v=!0,shouldResize:S,onResizeStart:A,onResize:T,onResizeEnd:C}){const N=AN(),R=typeof e=="string"?e:N,O=Zn(),H=j.useRef(null),D=n===bh.Handle,F=$t(j.useCallback(IW(D&&v),[D,v]),Qn),Z=j.useRef(null),V=t??UW[n];j.useEffect(()=>{if(!(!H.current||!R))return Z.current||(Z.current=fK({domNode:H.current,nodeId:R,getStoreItems:()=>{const{nodeLookup:P,transform:q,snapGrid:ne,snapToGrid:I,nodeOrigin:$,domNode:z}=O.getState();return{nodeLookup:P,transform:q,snapGrid:ne,snapToGrid:I,nodeOrigin:$,paneDomNode:z}},onChange:(P,q)=>{const{triggerNodeChanges:ne,nodeLookup:I,parentLookup:$,nodeOrigin:z}=O.getState(),G=[],Q={x:P.x,y:P.y},W=I.get(R);if(W&&W.expandParent&&W.parentId){const B=W.origin??z,K=P.width??W.measured.width??0,J=P.height??W.measured.height??0,X={id:W.id,parentId:W.parentId,rect:{width:K,height:J,...Zk({x:P.x??W.position.x,y:P.y??W.position.y},{width:K,height:J},W.parentId,I,B)}},ce=J_([X],I,$,z);G.push(...ce),Q.x=P.x?Math.max(B[0]*K,P.x):void 0,Q.y=P.y?Math.max(B[1]*J,P.y):void 0}if(Q.x!==void 0&&Q.y!==void 0){const B={id:R,type:"position",position:{...Q}};G.push(B)}if(P.width!==void 0&&P.height!==void 0){const K={id:R,type:"dimensions",resizing:!0,setAttributes:x?x==="horizontal"?"width":"height":!0,dimensions:{width:P.width,height:P.height}};G.push(K)}for(const B of q){const K={...B,type:"position"};G.push(K)}ne(G)},onEnd:({width:P,height:q})=>{const ne={id:R,type:"dimensions",resizing:!1,dimensions:{width:P,height:q}};O.getState().triggerNodeChanges([ne])}})),Z.current.update({controlPosition:V,boundaries:{minWidth:c,minHeight:f,maxWidth:p,maxHeight:m},keepAspectRatio:g,resizeDirection:x,onResizeStart:A,onResize:T,onResizeEnd:C,shouldResize:S}),()=>{var P;(P=Z.current)==null||P.destroy()}},[V,c,f,p,m,g,A,T,C,S]);const Y=V.split("-");return _.jsx("div",{className:zi(["react-flow__resize-control","nodrag",...Y,n,i]),ref:H,style:{...r,scale:F,...l&&{[D?"backgroundColor":"borderColor"]:l}},children:s})}j.memo(HW);const q1={background:"rgba(0, 200, 255, 0.4)",width:6,height:6,border:"none"},bC={background:"rgba(0, 230, 138, 0.4)",width:6,height:6,border:"none"},vC={background:"rgba(255, 171, 64, 0.4)",width:6,height:6,border:"none"};function PW({data:e}){return _.jsxs("div",{style:{padding:"16px 32px",border:"2px solid rgba(0, 200, 255, 0.4)",borderRadius:12,background:"var(--surface-2)",boxShadow:"0 0 30px rgba(0, 200, 255, 0.15), 0 4px 16px rgba(0,0,0,0.2)",textAlign:"center",minWidth:200},children:[_.jsx(Sl,{type:"source",position:We.Bottom,style:q1}),_.jsx("div",{style:{width:44,height:44,borderRadius:8,background:"linear-gradient(135deg, var(--accent), var(--accent-dim))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem",fontWeight:700,color:"var(--text-inverse)",margin:"0 auto 8px",boxShadow:"var(--shadow-glow-strong)"},children:e.label.slice(0,2).toUpperCase()}),_.jsx("div",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1rem",color:"var(--text-primary)"},children:e.label}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",marginTop:3},children:"CEO"})]})}function FW({data:e}){const t=e.agents;return _.jsxs("div",{style:{padding:"14px 20px",border:"1px solid var(--status-active-glow)",borderRadius:10,background:"var(--surface-2)",boxShadow:"0 0 16px rgba(0, 230, 138, 0.08), 0 2px 8px rgba(0,0,0,0.15)",textAlign:"center",minWidth:160},children:[_.jsx(Sl,{type:"target",position:We.Top,style:bC}),_.jsx(Sl,{type:"source",position:We.Bottom,style:bC}),_.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginBottom:4},children:[_.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:5,background:"rgba(0, 230, 138, 0.15)",border:"1px solid rgba(0, 230, 138, 0.25)",fontSize:"0.6rem",color:"var(--status-active)",fontWeight:700},children:e.label.slice(0,1).toUpperCase()}),_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:600,fontSize:"0.82rem",color:"var(--status-active)"},children:e.label})]}),e.description?_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",marginBottom:4,maxWidth:180},children:String(e.description)}):null,_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)"},children:[t.length," agent",t.length!==1?"s":""]})]})}function GW({data:e}){return _.jsxs("div",{style:{padding:"8px 16px",border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--surface-1)",boxShadow:"0 1px 4px rgba(0,0,0,0.15)",textAlign:"center",minWidth:110},children:[_.jsx(Sl,{type:"target",position:We.Top,style:q1}),_.jsx(Sl,{type:"source",position:We.Bottom,style:q1}),_.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[_.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--status-active)",boxShadow:"0 0 6px var(--status-active-glow)",flexShrink:0}}),_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:500,fontSize:"0.72rem",color:"var(--text-secondary)"},children:e.label})]}),e.stepLabel?_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.5rem",color:"var(--text-muted)",marginTop:3,maxWidth:160,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:String(e.stepLabel)}):null]})}function qW({data:e}){return _.jsxs("div",{style:{padding:"5px 12px",border:"1px solid rgba(255, 171, 64, 0.3)",borderRadius:4,background:"var(--surface-2)",textAlign:"center",minWidth:80},children:[_.jsx(Sl,{type:"target",position:We.Top,style:vC}),_.jsx(Sl,{type:"source",position:We.Bottom,style:vC}),_.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--status-warning)"},children:"⏸"}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontWeight:500,fontSize:"0.6rem",color:"var(--status-warning)"},children:e.label})]})]})}const YW={company:PW,squad:FW,agent:GW,checkpoint:qW},_C=300,Lv=60;function VW(e){const{tree:t,squads:n}=e,i=[],r=[];if(n.length===0)return i.push({id:"company",type:"company",position:{x:0,y:0},data:{label:t.name},draggable:!0}),{nodes:i,edges:r};const l=n.length*_C/2-100;return i.push({id:"company",type:"company",position:{x:l,y:0},data:{label:t.name},draggable:!0}),n.forEach((c,f)=>{const p=`squad-${c.code}`,m=f*_C,g=new Map(c.agents.map(S=>[S.id,S]));i.push({id:p,type:"squad",position:{x:m,y:200},data:{label:c.name,description:c.description,agents:c.agents},draggable:!0}),r.push({id:`company-${p}`,source:"company",target:p,style:{stroke:"rgba(0, 230, 138, 0.3)",strokeWidth:2},animated:!1});const x=c.pipeline||[];if(x.length===0){c.agents.forEach((S,A)=>{const T=`agent-${c.code}-${S.id}`;i.push({id:T,type:"agent",position:{x:m+25,y:340+A*Lv},data:{label:S.name},draggable:!0}),r.push({id:`${p}-${T}`,source:p,target:T,style:{stroke:"rgba(100, 120, 200, 0.15)",strokeWidth:1}})});return}let v=p;x.forEach((S,A)=>{const T=S.type==="checkpoint",C=S.agent?g.get(S.agent):null,N=`step-${c.code}-${S.id}`;T?i.push({id:N,type:"checkpoint",position:{x:m+40,y:340+A*Lv},data:{label:S.label},draggable:!0}):i.push({id:N,type:"agent",position:{x:m+25,y:340+A*Lv},data:{label:(C==null?void 0:C.name)||S.agent||S.id,stepLabel:S.label},draggable:!0});const R=T?{stroke:"rgba(255, 171, 64, 0.3)",strokeWidth:1}:{stroke:"rgba(0, 200, 255, 0.25)",strokeWidth:1.5};r.push({id:`chain-${c.code}-${v}-${N}`,source:v,target:N,style:R,markerEnd:T?void 0:{type:Ym.ArrowClosed,color:"rgba(0, 200, 255, 0.35)",width:12,height:12},animated:!T}),v=N})}),{nodes:i,edges:r}}function XW({data:e}){const{fitView:t}=Sx(),{nodes:n,edges:i}=j.useMemo(()=>VW(e),[e]);j.useEffect(()=>{const s=setTimeout(()=>t({padding:.12,duration:400}),50);return()=>clearTimeout(s)},[n.length,t]);const r=e.squads.reduce((s,l)=>s+l.agents.length,0);return _.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",animation:"fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both"},children:[_.jsxs("div",{style:{padding:"16px 20px 12px",flexShrink:0},children:[_.jsxs("h2",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1.1rem",color:"var(--text-primary)",marginBottom:2},children:[e.tree.name," — Org Chart"]}),_.jsxs("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)"},children:[e.squads.length," active squad",e.squads.length!==1?"s":""," / ",r," agents"]})]}),_.jsx("div",{style:{flex:1,minHeight:0},children:_.jsxs(fW,{nodes:n,edges:i,nodeTypes:YW,fitView:!0,fitViewOptions:{padding:.12},minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},style:{background:"var(--surface-0)"},nodesDraggable:!0,nodesConnectable:!1,children:[_.jsx(yW,{color:"rgba(100, 120, 200, 0.04)",gap:24,size:1}),_.jsx(wW,{showInteractive:!1,style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:8}}),_.jsx(jW,{nodeColor:s=>s.type==="company"?"#007acc":s.type==="squad"?"#00e68a":s.type==="checkpoint"?"#ffab40":"#888",maskColor:"var(--glass-bg)",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8}})]})})]})}function KW(){const[e,t]=j.useState(null),[n,i]=j.useState(!0),[r,s]=j.useState(null);return j.useEffect(()=>{fetch("/api/orgchart",{credentials:"include"}).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return l.json()}).then(l=>{t(l),i(!1)}).catch(l=>{s(l.message),i(!1)})},[]),n?_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)"},children:"Loading org chart..."}):r||!e?_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--status-error)"},children:r||"Failed to load org chart"}):_.jsx(XN,{children:_.jsx(XW,{data:e})})}const QN={squad:"#00c8ff",agent:"#00e68a",memory:"#b388ff",skill:"#ffab40"},Y1={squad:18,agent:12,memory:8,skill:8},SC={contains:"rgba(255,255,255,0.08)",pipeline:"rgba(0,200,255,0.4)",delivers:"rgba(0,230,138,0.5)",uses_skill:"rgba(255,171,64,0.15)",has_memory:"rgba(179,136,255,0.15)",shared_skill:"rgba(255,171,64,0.3)",shared_memory:"rgba(179,136,255,0.3)"};function $W(e,t,n,i,r){const s=n/2,l=i/2,c=3e3*r,f=.008*r,p=.01*r,m=.85;for(let x=0;x<e.length;x++){let v=0,S=0;for(let A=0;A<e.length;A++){if(x===A)continue;const T=e[x].x-e[A].x,C=e[x].y-e[A].y,N=T*T+C*C+1,R=c/N,O=Math.sqrt(N);v+=T/O*R,S+=C/O*R}v+=(s-e[x].x)*p,S+=(l-e[x].y)*p,e[x].vx=(e[x].vx+v)*m,e[x].vy=(e[x].vy+S)*m}for(const x of t){const v=e.findIndex(H=>H.id===x.source),S=e.findIndex(H=>H.id===x.target);if(v===-1||S===-1)continue;const A=e[S].x-e[v].x,T=e[S].y-e[v].y,C=Math.sqrt(A*A+T*T)+1,N=(C-100)*f,R=A/C*N,O=T/C*N;e[v].vx+=R,e[v].vy+=O,e[S].vx-=R,e[S].vy-=O}let g=0;for(const x of e)x.x+=x.vx,x.y+=x.vy,g+=x.vx*x.vx+x.vy*x.vy;return g}function WW(e,t){const n=new Map;for(const l of t)n.has(l.source)||n.set(l.source,[]),n.has(l.target)||n.set(l.target,[]),n.get(l.source).push(l.target),n.get(l.target).push(l.source);const i=new Map;i.set(e,0);const r=[e];let s=0;for(;s<r.length;){const l=r[s++],c=i.get(l);for(const f of n.get(l)||[])i.has(f)||(i.set(f,c+1),r.push(f))}return i}function QW(e,t,n,i,r,s,l,c,f){const p=getComputedStyle(document.documentElement).getPropertyValue("--surface-0").trim()||"#1e1e1e";e.fillStyle=p,e.fillRect(0,0,i,r),e.save(),e.translate(l,c),e.scale(f,f);const m=new Map(t.map(v=>[v.id,v]));let g=null;if(s){g=WW(s.id,n);for(const v of g.values());}const x=v=>{if(!s||!g||v===s.id)return 1;const S=g.get(v);return S===void 0?.06:Math.max(.08,1-S*.28)};for(const v of n){const S=m.get(v.source),A=m.get(v.target);if(!S||!A)continue;const T=Math.min(x(v.source),x(v.target)),C=s&&(v.source===s.id||v.target===s.id);if(e.globalAlpha=T,e.beginPath(),e.moveTo(S.x,S.y),e.lineTo(A.x,A.y),e.strokeStyle=C?"rgba(255,255,255,0.6)":SC[v.type]||"rgba(255,255,255,0.06)",e.lineWidth=C?1.8:v.type==="delivers"||v.type==="pipeline"?1.2:.5,e.stroke(),v.type==="delivers"||v.type==="pipeline"){const N=Math.atan2(A.y-S.y,A.x-S.x),R=Y1[A.type]||10,O=A.x-Math.cos(N)*(R+4),H=A.y-Math.sin(N)*(R+4);e.beginPath(),e.moveTo(O,H),e.lineTo(O-Math.cos(N-.4)*6,H-Math.sin(N-.4)*6),e.lineTo(O-Math.cos(N+.4)*6,H-Math.sin(N+.4)*6),e.closePath(),e.fillStyle=SC[v.type],e.fill()}}e.globalAlpha=1;for(const v of t){const S=Y1[v.type]||10,A=QN[v.type]||"#888",T=(s==null?void 0:s.id)===v.id,C=x(v.id);e.globalAlpha=C,e.beginPath(),e.arc(v.x,v.y,S,0,Math.PI*2),T&&(e.shadowColor=A,e.shadowBlur=24),e.fillStyle=A,e.fill(),e.shadowBlur=0;const N=v.type==="squad"?11:9;e.font=`${v.type==="squad"?"600":"400"} ${N}px "JetBrains Mono", monospace`,e.textAlign="center",e.textBaseline="top";const R=getComputedStyle(document.documentElement).getPropertyValue("--text-primary").trim()||"#fff";e.fillStyle=R,e.fillText(v.label,v.x,v.y+S+4)}e.globalAlpha=1,e.restore()}function ZW(){const e=j.useRef(null),[t,n]=j.useState([]),[i,r]=j.useState([]),[s,l]=j.useState(!0),[c,f]=j.useState(null),p=j.useRef(null),m=j.useRef(null),g=j.useRef(null),x=j.useRef(!1),v=j.useRef({x:0,y:0}),S=j.useRef(1),A=j.useRef(!1),T=j.useRef({x:0,y:0}),C=j.useRef([]),N=j.useRef([]),R=j.useRef(0),O=j.useRef(1),H=j.useRef(!0),D=j.useRef(null);j.useEffect(()=>{fetch("/api/graph",{credentials:"include"}).then(V=>V.json()).then(V=>{const Y=window.innerWidth,P=window.innerHeight,q=V.nodes.map((ne,I)=>({...ne,x:Y/2+(Math.random()-.5)*400,y:P/2+(Math.random()-.5)*400,vx:0,vy:0}));C.current=q,N.current=V.edges,n(q),r(V.edges),l(!1)}).catch(()=>{f("Failed to load graph data"),l(!1)})},[]);const F=j.useCallback((V,Y)=>{const P=v.current,q=S.current,ne=(V-P.x)/q,I=(Y-P.y)/q;for(let $=C.current.length-1;$>=0;$--){const z=C.current[$],G=Y1[z.type]||10,Q=ne-z.x,W=I-z.y;if(Q*Q+W*W<(G+4)*(G+4))return z}return null},[]);j.useEffect(()=>{const V=e.current;if(!V)return;const Y=$=>{const z=V.getBoundingClientRect(),G=$.clientX-z.left,Q=$.clientY-z.top;if(g.current){x.current=!0;const J=S.current,X=v.current;g.current.x=(G-X.x)/J,g.current.y=(Q-X.y)/J,g.current.vx=0,g.current.vy=0,O.current=.3,H.current=!0;return}if(A.current){v.current.x+=G-T.current.x,v.current.y+=Q-T.current.y,T.current={x:G,y:Q};return}const W=S.current,B=v.current;D.current={x:(G-B.x)/W,y:(Q-B.y)/W};const K=F(G,Q);p.current=K,V.style.cursor=K?"grab":"default"},P=$=>{const z=V.getBoundingClientRect(),G=$.clientX-z.left,Q=$.clientY-z.top;x.current=!1;const W=F(G,Q);W?(g.current=W,V.style.cursor="grabbing"):(A.current=!0,T.current={x:G,y:Q},V.style.cursor="move")},q=$=>{var G;g.current;const z=A.current;if(g.current=null,A.current=!1,V.style.cursor="default",!x.current){const Q=V.getBoundingClientRect(),W=$.clientX-Q.left,B=$.clientY-Q.top,K=F(W,B);K?m.current=((G=m.current)==null?void 0:G.id)===K.id?null:K:z||(m.current=null)}},ne=$=>{$.preventDefault();const z=V.getBoundingClientRect(),G=$.clientX-z.left,Q=$.clientY-z.top,W=$.deltaY>0?.92:1.08,B=Math.max(.2,Math.min(5,S.current*W)),K=B/S.current;v.current.x=G-(G-v.current.x)*K,v.current.y=Q-(Q-v.current.y)*K,S.current=B},I=()=>{g.current=null,A.current=!1,D.current=null,V.style.cursor="default"};return V.addEventListener("mousemove",Y),V.addEventListener("mousedown",P),V.addEventListener("mouseup",q),V.addEventListener("mouseleave",I),V.addEventListener("wheel",ne,{passive:!1}),()=>{V.removeEventListener("mousemove",Y),V.removeEventListener("mousedown",P),V.removeEventListener("mouseup",q),V.removeEventListener("mouseleave",I),V.removeEventListener("wheel",ne)}},[F,s]),j.useEffect(()=>{if(s||C.current.length===0)return;const V=e.current;if(!V)return;const Y=()=>{const I=V.parentElement;I&&(V.width=I.clientWidth*window.devicePixelRatio,V.height=I.clientHeight*window.devicePixelRatio,V.style.width=I.clientWidth+"px",V.style.height=I.clientHeight+"px")};Y(),window.addEventListener("resize",Y);const P=V.getContext("2d");let q=!0;const ne=()=>{if(!q)return;const I=V.width/window.devicePixelRatio,$=V.height/window.devicePixelRatio;P.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),H.current&&($W(C.current,N.current,I,$,O.current),O.current*=.98,O.current<.001&&(H.current=!1,O.current=0));const z=D.current;if(z&&!g.current&&!A.current)for(const W of C.current){const B=W.x-z.x,K=W.y-z.y,J=B*B+K*K;if(J<14400&&J>1){const X=Math.sqrt(J),ce=.8*(1-X/120);W.x+=B/X*ce,W.y+=K/X*ce}}QW(P,C.current,N.current,I,$,m.current,v.current.x,v.current.y,S.current),R.current=requestAnimationFrame(ne)};return R.current=requestAnimationFrame(ne),()=>{q=!1,cancelAnimationFrame(R.current),window.removeEventListener("resize",Y)}},[s]);const Z=j.useCallback(V=>{const Y=e.current;if(!Y)return;const P=V==="in"?1.25:.8,q=Y.clientWidth/2,ne=Y.clientHeight/2,I=Math.max(.2,Math.min(5,S.current*P)),$=I/S.current;v.current.x=q-(q-v.current.x)*$,v.current.y=ne-(ne-v.current.y)*$,S.current=I},[]);return s?_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.8rem"},children:"Loading graph..."}):c?_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--status-error)",fontFamily:"var(--font-mono)",fontSize:"0.8rem"},children:c}):_.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:"var(--surface-0)"},children:[_.jsx("canvas",{ref:e,style:{display:"block",touchAction:"none"}}),_.jsx("div",{style:{position:"absolute",bottom:16,left:16,background:"rgba(10, 12, 16, 0.85)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",display:"flex",flexDirection:"column",gap:6},children:Object.entries(QN).map(([V,Y])=>_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[_.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:Y,display:"inline-block"}}),_.jsx("span",{style:{textTransform:"capitalize"},children:V})]},V))}),_.jsxs("div",{style:{position:"absolute",top:16,right:16,background:"rgba(10, 12, 16, 0.85)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",display:"flex",gap:16},children:[_.jsxs("span",{children:[t.length," nodes"]}),_.jsxs("span",{children:[i.length," edges"]})]}),_.jsx("div",{style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4},children:[{label:"+",action:"in"},{label:"−",action:"out"}].map(({label:V,action:Y})=>_.jsx("button",{onClick:()=>Z(Y),style:{width:32,height:32,background:"rgba(10, 12, 16, 0.85)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"1rem",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:V},Y))})]})}function JW(){const[e,t]=j.useState([]),[n,i]=j.useState(null),[r,s]=j.useState(""),[l,c]=j.useState(""),[f,p]=j.useState(!1),[m,g]=j.useState(!1),[x,v]=j.useState(new Set),[S,A]=j.useState(""),T=j.useRef(null);j.useEffect(()=>{fetch("/api/files",{credentials:"include"}).then(D=>D.json()).then(D=>{const F=new Map;for(const V of D)F.has(V.squad)||F.set(V.squad,{squad:V.squad,squadName:V.squadName,files:[]}),F.get(V.squad).files.push(V);const Z=[...F.values()];t(Z)})},[]);const C=j.useCallback(D=>{i(D),g(!0),fetch(`/api/files/${D.squad}/${D.path}`,{credentials:"include"}).then(F=>F.json()).then(F=>{s(F.content),c(F.content),g(!1)}).catch(()=>{s(""),c(""),g(!1)})},[]),N=j.useCallback(async()=>{n&&(p(!0),await fetch(`/api/files/${n.squad}/${n.path}`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})}),c(r),p(!1))},[n,r]),R=j.useCallback(D=>{v(F=>{const Z=new Set(F);return Z.has(D)?Z.delete(D):Z.add(D),Z})},[]),O=r!==l;j.useEffect(()=>{const D=F=>{(F.metaKey||F.ctrlKey)&&F.key==="s"&&(F.preventDefault(),O&&n&&N())};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[O,n,N]);const H=D=>D==="squad.yaml"?"⚙":D==="memories.md"?"◆":"◇";return _.jsxs("div",{style:{display:"flex",height:"100%",overflow:"hidden"},children:[_.jsxs("div",{style:{width:260,minWidth:260,borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[_.jsx("div",{style:{padding:"12px 14px",fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.1em",borderBottom:"1px solid var(--border-subtle)"},children:"Squad Files"}),_.jsx("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border-subtle)"},children:_.jsx("input",{type:"text",placeholder:"Search squads...",value:S,onChange:D=>A(D.target.value),style:{width:"100%",padding:"5px 8px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.7rem",outline:"none"}})}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"8px 0"},children:[e.filter(D=>{if(!S)return!0;const F=S.toLowerCase();return D.squadName.toLowerCase().includes(F)||D.squad.toLowerCase().includes(F)}).map(D=>_.jsxs("div",{children:[_.jsxs("button",{onClick:()=>R(D.squad),style:{width:"100%",background:"none",border:"none",padding:"6px 14px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.75rem",fontWeight:600,color:"var(--text-primary)",textAlign:"left"},children:[_.jsx("span",{style:{fontSize:"0.6rem",transition:"transform 0.15s ease",transform:x.has(D.squad)?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),D.squadName]}),x.has(D.squad)&&_.jsx("div",{style:{paddingLeft:14},children:D.files.map(F=>{const Z=(n==null?void 0:n.squad)===F.squad&&(n==null?void 0:n.path)===F.path;return _.jsxs("button",{onClick:()=>C(F),style:{width:"100%",background:Z?"var(--accent-glow)":"none",border:Z?"1px solid rgba(0, 200, 255, 0.12)":"1px solid transparent",borderRadius:"var(--radius-xs)",padding:"5px 10px",display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:Z?"var(--accent)":"var(--text-secondary)",textAlign:"left"},children:[_.jsx("span",{style:{opacity:.6},children:H(F.file)}),F.file]},`${F.squad}/${F.path}`)})})]},D.squad)),e.length===0&&_.jsx("div",{style:{padding:"20px 14px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)",textAlign:"center"},children:"No squads found"})]})]}),_.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:n?_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)",display:"flex",alignItems:"center",gap:8},children:[_.jsx("span",{style:{color:"var(--text-muted)"},children:n.squadName}),_.jsx("span",{style:{color:"var(--text-muted)",opacity:.4},children:"/"}),_.jsx("span",{children:n.file}),O&&_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--accent)",display:"inline-block"}})]}),_.jsxs("button",{onClick:N,disabled:!O||f,style:{background:O?"var(--accent)":"var(--surface-3)",border:"none",borderRadius:"var(--radius-xs)",padding:"4px 14px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:O?"var(--text-inverse)":"var(--text-muted)",cursor:O?"pointer":"default",opacity:O?1:.5,transition:"all 0.15s ease"},children:[f?"Saving...":"Save",_.jsx("span",{style:{marginLeft:6,fontSize:"0.6rem",opacity:.7},children:"⌘S"})]})]}),m?_.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.8rem"},children:"Loading..."}):_.jsx("textarea",{ref:T,value:r,onChange:D=>s(D.target.value),spellCheck:!1,style:{flex:1,width:"100%",padding:"16px 20px",border:"none",outline:"none",resize:"none",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:'"JetBrains Mono", "Fira Code", monospace',fontSize:"0.8rem",lineHeight:1.7,tabSize:2,whiteSpace:"pre",overflowWrap:"normal",overflowX:"auto"}})]}):_.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:[_.jsx("span",{style:{fontSize:"2rem",opacity:.3},children:"◇"}),_.jsx("span",{style:{fontSize:"0.8rem"},children:"Select a file to edit"})]})})]})}function xm(e){return e>=70?"#4ade80":e>=40?"#f59e0b":"#f44747"}function Ff(e,t,n){const i=n>0?Math.round(e/n*100):0,r=e+t>0?Math.round(e/(e+t)*100):0,s=Math.round((i+r)/2);return{r:i,q:r,e:s}}function EC(e,t){const n=Math.max(0,Math.floor((t-new Date(e).getTime())/1e3)),i=Math.floor(n/3600).toString().padStart(2,"0"),r=Math.floor(n%3600/60).toString().padStart(2,"0"),s=(n%60).toString().padStart(2,"0");return`${i}:${r}:${s}`}function jv(e,t){return t[e]??e.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function eQ({name:e,size:t=28}){const n=[...e].reduce((i,r)=>i+r.charCodeAt(0),0)%360;return _.jsx("div",{style:{width:t,height:t,borderRadius:"50%",flexShrink:0,background:`hsl(${n},45%,20%)`,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"var(--font-mono)",fontWeight:700,fontSize:Math.round(t*.38),color:`hsl(${n},55%,68%)`},children:e.slice(0,1).toUpperCase()})}function tQ({rank:e}){const t=["#FFD700","#C0C0C0","#CD7F32"],n=e<=3?t[e-1]:"var(--text-muted)";return _.jsx("div",{style:{width:20,height:20,borderRadius:"50%",flexShrink:0,background:e<=3?`${n}22`:"transparent",border:`1.5px solid ${n}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.55rem",fontWeight:700,color:n},children:e})}function ld({label:e,value:t,sub:n,color:i,icon:r}){return _.jsxs("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"14px 14px 12px",display:"flex",flexDirection:"column",gap:6},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[_.jsx("span",{style:{fontSize:"0.58rem",color:"var(--text-muted)",fontFamily:"var(--font-mono)",textTransform:"uppercase",letterSpacing:"0.08em"},children:e}),r&&_.jsx("span",{style:{fontSize:"0.75rem",opacity:.5},children:r})]}),_.jsx("div",{style:{fontSize:"1.9rem",fontWeight:800,fontFamily:"var(--font-display)",color:i??"var(--text-bright)",lineHeight:1},children:t}),_.jsx("div",{style:{fontSize:"0.58rem",color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:n})]})}function Iv({label:e,value:t,description:n}){const i=xm(t);return _.jsxs("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:16},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:10},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",fontWeight:700,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.08em"},children:e}),_.jsxs("span",{style:{fontFamily:"var(--font-display)",fontSize:"1.15rem",fontWeight:800,color:i},children:[t,"%"]})]}),_.jsx("div",{style:{height:5,background:"var(--surface-3)",borderRadius:3,overflow:"hidden"},children:_.jsx("div",{style:{height:"100%",width:`${t}%`,background:i,borderRadius:3,transition:"width 0.6s ease"}})}),_.jsx("p",{style:{fontSize:"0.58rem",color:"var(--text-muted)",fontFamily:"var(--font-mono)",marginTop:8,lineHeight:1.6},children:n})]})}function wC({bars:e,height:t=100,showSecondary:n=!1}){const i=Math.max(...e.flatMap(s=>[s.primary,s.secondary??0]),1),r=t-16;return _.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:2,height:t},children:e.map((s,l)=>_.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[_.jsxs("div",{style:{display:"flex",gap:1,alignItems:"flex-end",width:"100%",height:r},children:[n&&s.secondary!==void 0&&_.jsx("div",{style:{flex:1,alignSelf:"flex-end",height:Math.max(s.secondary>0?2:0,Math.round(s.secondary/i*r)),background:"rgba(255,255,255,0.1)",borderRadius:"2px 2px 0 0"}}),_.jsx("div",{style:{flex:1,alignSelf:"flex-end",height:Math.max(s.primary>0?2:0,Math.round(s.primary/i*r)),background:"#4ade80",borderRadius:"2px 2px 0 0"}})]}),_.jsx("span",{style:{fontSize:"0.42rem",color:"var(--text-muted)",whiteSpace:"nowrap",fontFamily:"var(--font-mono)"},children:s.label})]},l))})}function Uv({rank:e,name:t,score:n,sub:i,barColor:r}){return _.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:3},children:[_.jsx(tQ,{rank:e}),_.jsx(eQ,{name:t,size:26}),_.jsxs("div",{style:{flex:1,minWidth:0},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.63rem",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.48rem",color:"var(--text-muted)"},children:i})]}),_.jsxs("span",{style:{fontFamily:"var(--font-display)",fontSize:"0.82rem",fontWeight:800,color:r,flexShrink:0},children:[n,"%"]})]}),_.jsx("div",{style:{height:2,background:"var(--surface-3)",borderRadius:1,marginLeft:55},children:_.jsx("div",{style:{height:"100%",width:`${n}%`,background:r,borderRadius:1}})})]})}function nQ(){var W;const[e,t]=j.useState(null),[n,i]=j.useState(Date.now()),[r,s]=j.useState(null),[l,c]=j.useState(!1),[f,p]=j.useState(!1),[m,g]=j.useState(!1),x=vr(B=>B.squads),v=Object.fromEntries(x.map(B=>[B.code,B.name]));j.useEffect(()=>{const B=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(B)},[]);const S=async()=>{try{const B=await fetch("/api/dashboard/stats",{credentials:"include"});B.ok&&t(await B.json())}catch{}};j.useEffect(()=>{S();const B=setInterval(S,3e4);return()=>clearInterval(B)},[]);const A=async B=>{p(!0);try{(await fetch(`/api/dashboard/sessions/${B}/kill`,{method:"POST",credentials:"include"})).ok&&(s(null),c(!1),await S())}catch{}finally{p(!1)}},T=B=>{s(B),c(!1)},C=new Date(n),N=C.toLocaleTimeString("pt-BR",{hour12:!1}),R=C.toLocaleDateString("pt-BR",{weekday:"long",day:"numeric",month:"long"}).toUpperCase(),O=e==null?void 0:e.kpis,H=e==null?void 0:e.metrics,D=(O==null?void 0:O.weekChange)??0,F=(()=>{const B=Object.fromEntries(((e==null?void 0:e.rhythm14)??[]).map(K=>[K.day,K.count]));return Array.from({length:14},(K,J)=>{const X=new Date(n);X.setDate(X.getDate()-(13-J));const ce=X.toISOString().slice(0,10);return{label:`${X.getDate().toString().padStart(2,"0")}/${(X.getMonth()+1).toString().padStart(2,"0")}`,primary:B[ce]??0}})})(),Z=(()=>{const B=Object.fromEntries(((e==null?void 0:e.hourlyToday)??[]).map(J=>[J.hour,J.count])),K=Object.fromEntries(((e==null?void 0:e.hourlyLastWeek)??[]).map(J=>[J.hour,Math.round(J.avg_count)]));return Array.from({length:14},(J,X)=>{const ce=X+7;return{label:`${ce.toString().padStart(2,"0")}h`,primary:B[ce]??0,secondary:K[ce]??0}})})(),V=F.reduce((B,K)=>B+K.primary,0),Y=C.getHours(),P=((W=((e==null?void 0:e.hourlyToday)??[]).find(B=>B.hour===Y))==null?void 0:W.count)??0,q=(e==null?void 0:e.agentPerf)??[],ne=[...q].sort((B,K)=>{const{e:J}=Ff(B.done,B.failed,B.total),{e:X}=Ff(K.done,K.failed,K.total);return X-J}),I=[...q].sort((B,K)=>{const J=B.total>0?B.done/B.total:0;return(K.total>0?K.done/K.total:0)-J}),$=[...q].sort((B,K)=>{const{e:J}=Ff(B.done,B.failed,B.total),{e:X}=Ff(K.done,K.failed,K.total);return X-J}),z={background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:16,overflow:"hidden"},G={display:"flex",alignItems:"center",gap:6,fontFamily:"var(--font-mono)",fontSize:"0.62rem",fontWeight:700,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:14},Q=_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"var(--text-muted)"},children:"Nenhum dado ainda"});return _.jsxs("div",{style:{overflowY:"auto",background:"var(--surface-0)",...m?{position:"fixed",inset:0,zIndex:200}:{height:"100%"}},children:[_.jsxs("div",{style:{padding:"12px 24px",borderBottom:"1px solid var(--border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"flex-start",position:"sticky",top:0,zIndex:10,background:"var(--surface-0)"},children:[_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-display)",fontSize:"1rem",fontWeight:700,color:"var(--text-bright)"},children:"Painel de Operações"}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:2},children:[_.jsx("span",{style:{fontSize:"0.55rem",fontFamily:"var(--font-mono)",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.1em"},children:"em tempo real"}),_.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",display:"inline-block",background:"#4ade80",boxShadow:"0 0 5px #4ade80",animation:"statusPulse 2s ease-in-out infinite"}}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"#4ade80"},children:"Ao vivo"})]})]})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[_.jsx("button",{onClick:()=>g(B=>!B),title:m?"Voltar ao modo normal":"Modo foco — tela cheia",style:{background:m?"rgba(0,200,255,0.1)":"transparent",border:`1px solid ${m?"var(--accent)":"var(--border-subtle)"}`,color:m?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.6rem",padding:"4px 10px",borderRadius:4,whiteSpace:"nowrap"},children:m?"← Normal":"⛶ Foco"}),_.jsxs("div",{style:{textAlign:"right"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"1.5rem",fontWeight:700,color:"var(--text-bright)",lineHeight:1,letterSpacing:"0.04em"},children:N}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)",marginTop:3,letterSpacing:"0.06em"},children:R})]})]})]}),!e&&_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"calc(100% - 64px)"},children:_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)"},children:"Carregando dados..."})}),e&&_.jsxs("div",{style:{padding:"16px 24px 40px",display:"flex",flexDirection:"column",gap:12},children:[_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:10},children:[_.jsx(ld,{label:"Em Aberto",value:O.open,sub:"Tarefas planejadas",icon:"○"}),_.jsx(ld,{label:"Falhas",value:O.delayed,sub:"Tarefas com erro ou falha",color:O.delayed>0?"#f44747":void 0,icon:"△"}),_.jsx(ld,{label:"Concluídas Hoje",value:O.doneToday,sub:`Finalizadas em ${C.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit"})}`,color:"#4ade80",icon:"✓"}),_.jsx(ld,{label:"Squads Rodando",value:O.activeSquads,sub:"Squads com pipeline ativo",color:O.activeSquads>0?"#f59e0b":void 0,icon:"◈"}),_.jsx(ld,{label:"Pipelines Ativos",value:O.runningNow,sub:"Instâncias Claude em execução",color:O.runningNow>0?"#4ade80":void 0,icon:"▶"}),_.jsx(ld,{label:"Horas Rastreadas (7d)",value:`${O.hoursTracked}h`,sub:"Últimos 7 dias",icon:"⏱"}),_.jsx(ld,{label:"Sem. vs Anterior",value:`${D>0?"+":""}${D}%`,sub:"Entregas vs período anterior",color:D>0?"#4ade80":D<0?"#f44747":void 0,icon:D>=0?"↑":"↓"})]}),_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:10},children:[_.jsx(Iv,{label:"Regularidade",value:H.regularidade,description:"Taxa de tarefas concluídas em relação ao total de tarefas registradas."}),_.jsx(Iv,{label:"Qualidade",value:H.qualidade,description:"Taxa de sucesso entre tarefas finalizadas — concluídas vs. falhas."}),_.jsx(Iv,{label:"Eficiência",value:H.eficiencia,description:"Combina regularidade e qualidade para medir o desempenho geral."})]}),_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"55fr 45fr",gap:10},children:[_.jsxs("div",{style:z,children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:14},children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"📈"}),_.jsx("span",{children:"Ritmo de Conclusão"}),_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"últimos 14 dias"})]}),_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)"},children:["Total: ",V," tarefas"]})]}),_.jsx(wC,{bars:F,height:120})]}),_.jsxs("div",{style:z,children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:14},children:[_.jsxs("div",{children:[_.jsxs("div",{style:{...G,marginBottom:6},children:[_.jsx("span",{children:"⏰"}),_.jsx("span",{children:"Ritmo por Hora"}),_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"hoje vs média semana anterior"})]}),_.jsxs("div",{style:{display:"flex",gap:10,marginBottom:8},children:[_.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"#4ade80"},children:[_.jsx("span",{style:{width:8,height:8,borderRadius:2,background:"#4ade80",display:"inline-block"}}),"Hoje"]}),_.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)"},children:[_.jsx("span",{style:{width:8,height:8,borderRadius:2,background:"rgba(255,255,255,0.12)",display:"inline-block"}}),"Média sem. anterior"]})]})]}),_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",textAlign:"right",whiteSpace:"nowrap"},children:[P," nesta hora",_.jsx("br",{}),"Total: ",O.doneToday]})]}),_.jsx(wC,{bars:Z,height:100,showSecondary:!0})]})]}),e.runningSessions.length>0&&_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"#4ade80",boxShadow:"0 0 6px #4ade80",display:"inline-block",animation:"statusPulse 2s ease-in-out infinite"}}),"Pipelines Ativos — ",e.runningSessions.length," instância",e.runningSessions.length!==1?"s":""," Claude em execução"]}),_.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:10},children:e.runningSessions.map(B=>{const K=jv(B.squad_code,v),J=[...B.squad_code].reduce((ie,de)=>ie+de.charCodeAt(0),0)%360,X=B.steps_total>0?Math.round(B.steps_done/B.steps_total*100):0,ce=(e.sessionAgents??[]).filter(ie=>ie.activity_id===B.id);return _.jsxs("div",{onClick:()=>T(B),style:{background:"var(--surface-2)",border:"1px solid rgba(74,222,128,0.15)",borderRadius:6,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,cursor:"pointer",transition:"border-color 0.15s"},onMouseEnter:ie=>ie.currentTarget.style.borderColor="rgba(74,222,128,0.4)",onMouseLeave:ie=>ie.currentTarget.style.borderColor="rgba(74,222,128,0.15)",children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[_.jsx("div",{style:{width:34,height:34,borderRadius:"50%",flexShrink:0,background:`hsl(${J},45%,18%)`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:"0.82rem",fontFamily:"var(--font-mono)",color:`hsl(${J},55%,65%)`},children:K.slice(0,1).toUpperCase()}),_.jsxs("div",{style:{flex:1,minWidth:0},children:[_.jsx("div",{style:{fontFamily:"var(--font-display)",fontSize:"0.76rem",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)",marginTop:1},children:B.squad_code})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,flexShrink:0},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#4ade80",display:"inline-block",boxShadow:"0 0 4px #4ade80"}}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",fontWeight:700,color:"#4ade80"},children:EC(B.started_at,n)})]})]}),B.steps_total>0&&_.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:4},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.5rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Progresso"}),_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",fontWeight:700,color:B.current_task?"#f59e0b":"#4ade80"},children:[B.steps_done,"/",B.steps_total," etapas · ",X,"%"]})]}),_.jsx("div",{style:{height:5,background:"var(--surface-3)",borderRadius:3,overflow:"hidden"},children:_.jsx("div",{style:{height:"100%",width:`${X}%`,background:B.current_task?"#f59e0b":"#4ade80",borderRadius:3,transition:"width 0.4s ease"}})})]}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:B.current_task?"var(--text-secondary)":"var(--text-muted)",display:"flex",alignItems:"center",gap:5,overflow:"hidden"},children:B.current_task?_.jsxs(_.Fragment,{children:[_.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"#f59e0b",display:"inline-block",flexShrink:0,animation:"statusPulse 1.5s ease-in-out infinite"}}),_.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.current_task})]}):_.jsx("span",{style:{color:"var(--text-muted)"},children:"⏳ Aguardando próxima etapa..."})}),ce.length>0&&_.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:ce.map(ie=>{const de=ie.executing_count>0,ye=ie.done_count===ie.total&&ie.executing_count===0,me=ie.failed_count>0&&ie.executing_count===0&&ie.done_count<ie.total,le=de?"#f59e0b":ye?"#4ade80":me?"#f44747":"var(--text-muted)",Re=de?"#f59e0b":ye?"#4ade80":me?"#f44747":"var(--text-muted)",Le=de?"rgba(245,158,11,0.1)":ye?"rgba(74,222,128,0.08)":me?"rgba(244,71,71,0.08)":"rgba(255,255,255,0.04)",je=ie.agent_name.split(/[\s_-]/)[0];return _.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,background:Le,border:`1px solid ${le}33`,borderRadius:20,padding:"2px 7px"},children:[_.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:le,display:"inline-block",flexShrink:0,...de?{animation:"statusPulse 1.5s ease-in-out infinite"}:{}}}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",fontWeight:600,color:Re,whiteSpace:"nowrap"},children:je})]},ie.agent_name)})})]},B.id)})})]}),_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10},children:[_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"👥"})," Performance por Squad"]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.squadPerf.length===0&&Q,[...e.squadPerf].sort((B,K)=>{const J=B.total>0?B.done/B.total:0;return(K.total>0?K.done/K.total:0)-J}).slice(0,6).map((B,K)=>{const J=B.total>0?Math.round(B.done/B.total*100):0,X=jv(B.squad_code,v),ce=xm(J);return _.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:4},children:[_.jsxs("div",{style:{display:"flex",gap:5,alignItems:"flex-start",flex:1,minWidth:0},children:[_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)",paddingTop:1,width:16,flexShrink:0},children:["#",K+1]}),_.jsxs("div",{style:{minWidth:0},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.63rem",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:X}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)",marginTop:1},children:[B.done,"/",B.total," concluídas",B.failed>0&&_.jsxs("span",{style:{color:"#f44747",marginLeft:4},children:[B.failed," falhas"]})]})]})]}),_.jsx("span",{style:{fontFamily:"var(--font-display)",fontSize:"0.9rem",fontWeight:800,color:ce,flexShrink:0,marginLeft:6},children:J})]}),_.jsx("div",{style:{height:3,background:"var(--surface-3)",borderRadius:2},children:_.jsx("div",{style:{height:"100%",width:`${J}%`,background:ce,borderRadius:2}})})]},B.squad_code)})]})]}),_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"🏆"})," Top Performers",_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"score combinado"})]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:9},children:[ne.length===0&&Q,ne.slice(0,5).map((B,K)=>{const J=Ff(B.done,B.failed,B.total);return _.jsx(Uv,{rank:K+1,name:B.agent_name,score:J.e,barColor:xm(J.e),sub:`R: ${J.r}% · Q: ${J.q}% · E: ${J.e}%`},B.agent_name)})]})]}),_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"⭐"})," Top Regularidade",_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"tarefas entregues"})]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:9},children:[I.length===0&&Q,I.slice(0,5).map((B,K)=>{const J=B.total>0?Math.round(B.done/B.total*100):0;return _.jsx(Uv,{rank:K+1,name:B.agent_name,score:J,barColor:xm(J),sub:`${B.done} de ${B.total} concluídas`},B.agent_name)})]})]}),_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"📊"})," Top Eficiência",_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"conclusão vs. andamento"})]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:9},children:[$.length===0&&Q,$.slice(0,5).map((B,K)=>{const{r:J,q:X,e:ce}=Ff(B.done,B.failed,B.total);return _.jsx(Uv,{rank:K+1,name:B.agent_name,score:ce,barColor:xm(ce),sub:`R: ${J}% · Q: ${X}% · E: ${ce}%`},B.agent_name)})]})]})]})]}),r&&(()=>{const B=r,K=jv(B.squad_code,v),J=[...B.squad_code].reduce((de,ye)=>de+ye.charCodeAt(0),0)%360,X=B.steps_total>0?Math.round(B.steps_done/B.steps_total*100):0,ce=new Date(B.started_at).toLocaleTimeString("pt-BR",{hour12:!1}),ie=new Date(B.started_at).toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit"});return _.jsx("div",{onClick:()=>{s(null),c(!1)},style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(3px)",display:"flex",alignItems:"center",justifyContent:"center"},children:_.jsxs("div",{onClick:de=>de.stopPropagation(),style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:12,padding:24,width:440,maxWidth:"calc(100vw - 32px)",display:"flex",flexDirection:"column",gap:16,boxShadow:"0 24px 64px rgba(0,0,0,0.5)"},children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[_.jsx("div",{style:{width:42,height:42,borderRadius:"50%",flexShrink:0,background:`hsl(${J},45%,18%)`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:"1rem",fontFamily:"var(--font-mono)",color:`hsl(${J},55%,65%)`},children:K.slice(0,1).toUpperCase()}),_.jsxs("div",{style:{flex:1,minWidth:0},children:[_.jsx("div",{style:{fontFamily:"var(--font-display)",fontSize:"0.9rem",fontWeight:700,color:"var(--text-bright)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",marginTop:2},children:[B.squad_code," · Iniciado em ",ie," às ",ce]})]}),_.jsx("button",{onClick:()=>{s(null),c(!1)},style:{background:"transparent",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:"1.1rem",padding:"2px 6px",lineHeight:1,borderRadius:4},children:"×"})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,background:"var(--surface-2)",borderRadius:6,padding:"10px 14px",border:"1px solid rgba(74,222,128,0.2)"},children:[_.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"#4ade80",display:"inline-block",boxShadow:"0 0 6px #4ade80",flexShrink:0,animation:"statusPulse 2s ease-in-out infinite"}}),_.jsxs("div",{style:{flex:1},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Em execução há"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"1.1rem",fontWeight:700,color:"#4ade80",letterSpacing:"0.04em"},children:EC(B.started_at,n)})]})]}),_.jsxs("div",{style:{background:"var(--surface-2)",borderRadius:6,padding:"12px 14px",border:"1px solid var(--border-subtle)"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:8},children:"Etapa atual"}),B.current_task?_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:6},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#f59e0b",display:"inline-block",flexShrink:0,marginTop:3,animation:"statusPulse 1.5s ease-in-out infinite"}}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:"var(--text-primary)",lineHeight:1.4},children:B.current_task})]}),B.current_agent&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",marginTop:6,marginLeft:12},children:["Agente: ",B.current_agent,B.current_step&&_.jsxs("span",{style:{marginLeft:8,opacity:.6},children:["· ",B.current_step]})]})]}):_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)"},children:"⏳ Aguardando próxima etapa..."})]}),B.steps_total>0&&_.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:6},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Progresso"}),_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:700,color:"var(--text-secondary)"},children:[B.steps_done," / ",B.steps_total," passos (",X,"%)"]})]}),_.jsx("div",{style:{height:6,background:"var(--surface-3)",borderRadius:3,overflow:"hidden"},children:_.jsx("div",{style:{height:"100%",width:`${X}%`,background:B.current_task?"#f59e0b":"#4ade80",borderRadius:3,transition:"width 0.4s ease"}})})]}),_.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:14,display:"flex",flexDirection:"column",gap:8},children:l?_.jsxs(_.Fragment,{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"#f44747",background:"rgba(244,71,71,0.08)",border:"1px solid rgba(244,71,71,0.25)",borderRadius:6,padding:"8px 12px",lineHeight:1.5},children:"Tem certeza? O pipeline será encerrado e as tarefas em execução serão marcadas como falha."}),_.jsxs("div",{style:{display:"flex",gap:8},children:[_.jsx("button",{onClick:()=>c(!1),disabled:f,style:{flex:1,padding:"8px 14px",borderRadius:6,cursor:"pointer",background:"transparent",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.65rem",opacity:f?.5:1},children:"Cancelar"}),_.jsx("button",{onClick:()=>A(B.id),disabled:f,style:{flex:1,padding:"8px 14px",borderRadius:6,cursor:f?"not-allowed":"pointer",background:"#f44747",border:"none",color:"#fff",fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:700,opacity:f?.6:1},children:f?"Encerrando...":"Confirmar Encerramento"})]})]}):_.jsxs("div",{style:{display:"flex",gap:8},children:[_.jsx("button",{onClick:()=>{s(null),c(!1)},style:{flex:1,padding:"8px 14px",borderRadius:6,cursor:"pointer",background:"transparent",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.65rem"},children:"Fechar"}),_.jsx("button",{onClick:()=>c(!0),style:{flex:1,padding:"8px 14px",borderRadius:6,cursor:"pointer",background:"rgba(244,71,71,0.1)",border:"1px solid rgba(244,71,71,0.4)",color:"#f44747",fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:600},children:"Encerrar Pipeline"})]})})]})})})()]})}const iQ=localStorage.getItem("expx-theme")||"dark";document.documentElement.setAttribute("data-theme",iQ);const rQ=j.lazy(()=>ou(()=>import("./JarvisView-Ex2_oCYo.js"),[]).then(e=>({default:e.JarvisView})));Z3.createRoot(document.getElementById("root")).render(_.jsx(j.StrictMode,{children:_.jsx(S4,{children:_.jsxs(ZO,{children:[_.jsx(ca,{path:"/login",element:_.jsx(fD,{})}),_.jsxs(ca,{path:"/",element:_.jsx(uD,{}),children:[_.jsx(ca,{index:!0,element:_.jsx(WO,{to:"/office",replace:!0})}),_.jsx(ca,{path:"office",element:_.jsx(I8,{})}),_.jsx(ca,{path:"chat",element:_.jsx(dG,{})}),_.jsx(ca,{path:"kanban",element:_.jsx(mG,{})}),_.jsx(ca,{path:"settings",element:_.jsx(CG,{})}),_.jsx(ca,{path:"scheduler",element:_.jsx(kG,{})}),_.jsx(ca,{path:"email",element:_.jsx(zG,{})}),_.jsx(ca,{path:"orgchart",element:_.jsx(KW,{})}),_.jsx(ca,{path:"graph",element:_.jsx(ZW,{})}),_.jsx(ca,{path:"files",element:_.jsx(JW,{})}),_.jsx(ca,{path:"dashboard",element:_.jsx(nQ,{})}),_.jsx(ca,{path:"jarvis",element:_.jsx(j.Suspense,{fallback:null,children:_.jsx(rQ,{})})})]})]})})}));export{i6 as $,XA as A,Bm as B,qi as C,is as D,yo as E,lc as F,Na as G,v5 as H,a_ as I,iD as J,Jm as K,iw as L,Ht as M,y0 as N,i_ as O,Lr as P,qA as Q,Jv as R,E5 as S,Mn as T,M0 as U,Is as V,jA as W,d1 as X,Q5 as Y,J5 as Z,s6 as _,aQ as a,nx as a0,Ad as a1,kD as a2,Zm as a3,r_ as a4,c6 as a5,Da as a6,dA as a7,js as a8,ex as a9,HE as aa,ch as ab,GB as ac,lz as ad,FE as ae,Cb as af,GE as ag,cz as ah,lh as ai,Ti as aj,pA as ak,fB as al,KA as am,en as an,Qm as ao,xi as ap,f5 as aq,l5 as ar,D5 as as,C5 as at,Z5 as au,e6 as av,l6 as aw,a6 as ax,o6 as ay,gb as b,gl as c,vr as d,Gz as e,ka as f,Oz as g,bi as h,Bn as i,_ as j,g0 as k,kt as l,hA as m,T6 as n,ix as o,g6 as p,rx as q,j as r,XC as s,EA as t,C0 as u,li as v,ma as w,Wf as x,qD as y,_r as z};
|
|
400
|
+
M${Z.x},${Z.y}h${Z.width}v${Z.height}h${-Z.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}WN.displayName="MiniMap";const jW=j.memo(WN),IW=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,UW={[bh.Line]:"right",[bh.Handle]:"bottom-right"};function HW({nodeId:e,position:t,variant:n=bh.Handle,className:i,style:r=void 0,children:s,color:l,minWidth:c=10,minHeight:f=10,maxWidth:p=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:x,autoScale:v=!0,shouldResize:S,onResizeStart:A,onResize:T,onResizeEnd:C}){const N=AN(),R=typeof e=="string"?e:N,O=Zn(),H=j.useRef(null),D=n===bh.Handle,F=$t(j.useCallback(IW(D&&v),[D,v]),Qn),Z=j.useRef(null),V=t??UW[n];j.useEffect(()=>{if(!(!H.current||!R))return Z.current||(Z.current=fK({domNode:H.current,nodeId:R,getStoreItems:()=>{const{nodeLookup:P,transform:q,snapGrid:ne,snapToGrid:I,nodeOrigin:$,domNode:z}=O.getState();return{nodeLookup:P,transform:q,snapGrid:ne,snapToGrid:I,nodeOrigin:$,paneDomNode:z}},onChange:(P,q)=>{const{triggerNodeChanges:ne,nodeLookup:I,parentLookup:$,nodeOrigin:z}=O.getState(),G=[],Q={x:P.x,y:P.y},W=I.get(R);if(W&&W.expandParent&&W.parentId){const B=W.origin??z,K=P.width??W.measured.width??0,J=P.height??W.measured.height??0,X={id:W.id,parentId:W.parentId,rect:{width:K,height:J,...Zk({x:P.x??W.position.x,y:P.y??W.position.y},{width:K,height:J},W.parentId,I,B)}},ce=J_([X],I,$,z);G.push(...ce),Q.x=P.x?Math.max(B[0]*K,P.x):void 0,Q.y=P.y?Math.max(B[1]*J,P.y):void 0}if(Q.x!==void 0&&Q.y!==void 0){const B={id:R,type:"position",position:{...Q}};G.push(B)}if(P.width!==void 0&&P.height!==void 0){const K={id:R,type:"dimensions",resizing:!0,setAttributes:x?x==="horizontal"?"width":"height":!0,dimensions:{width:P.width,height:P.height}};G.push(K)}for(const B of q){const K={...B,type:"position"};G.push(K)}ne(G)},onEnd:({width:P,height:q})=>{const ne={id:R,type:"dimensions",resizing:!1,dimensions:{width:P,height:q}};O.getState().triggerNodeChanges([ne])}})),Z.current.update({controlPosition:V,boundaries:{minWidth:c,minHeight:f,maxWidth:p,maxHeight:m},keepAspectRatio:g,resizeDirection:x,onResizeStart:A,onResize:T,onResizeEnd:C,shouldResize:S}),()=>{var P;(P=Z.current)==null||P.destroy()}},[V,c,f,p,m,g,A,T,C,S]);const Y=V.split("-");return _.jsx("div",{className:zi(["react-flow__resize-control","nodrag",...Y,n,i]),ref:H,style:{...r,scale:F,...l&&{[D?"backgroundColor":"borderColor"]:l}},children:s})}j.memo(HW);const q1={background:"rgba(0, 200, 255, 0.4)",width:6,height:6,border:"none"},bC={background:"rgba(0, 230, 138, 0.4)",width:6,height:6,border:"none"},vC={background:"rgba(255, 171, 64, 0.4)",width:6,height:6,border:"none"};function PW({data:e}){return _.jsxs("div",{style:{padding:"16px 32px",border:"2px solid rgba(0, 200, 255, 0.4)",borderRadius:12,background:"var(--surface-2)",boxShadow:"0 0 30px rgba(0, 200, 255, 0.15), 0 4px 16px rgba(0,0,0,0.2)",textAlign:"center",minWidth:200},children:[_.jsx(Sl,{type:"source",position:We.Bottom,style:q1}),_.jsx("div",{style:{width:44,height:44,borderRadius:8,background:"linear-gradient(135deg, var(--accent), var(--accent-dim))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem",fontWeight:700,color:"var(--text-inverse)",margin:"0 auto 8px",boxShadow:"var(--shadow-glow-strong)"},children:e.label.slice(0,2).toUpperCase()}),_.jsx("div",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1rem",color:"var(--text-primary)"},children:e.label}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",marginTop:3},children:"CEO"})]})}function FW({data:e}){const t=e.agents;return _.jsxs("div",{style:{padding:"14px 20px",border:"1px solid var(--status-active-glow)",borderRadius:10,background:"var(--surface-2)",boxShadow:"0 0 16px rgba(0, 230, 138, 0.08), 0 2px 8px rgba(0,0,0,0.15)",textAlign:"center",minWidth:160},children:[_.jsx(Sl,{type:"target",position:We.Top,style:bC}),_.jsx(Sl,{type:"source",position:We.Bottom,style:bC}),_.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginBottom:4},children:[_.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:5,background:"rgba(0, 230, 138, 0.15)",border:"1px solid rgba(0, 230, 138, 0.25)",fontSize:"0.6rem",color:"var(--status-active)",fontWeight:700},children:e.label.slice(0,1).toUpperCase()}),_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:600,fontSize:"0.82rem",color:"var(--status-active)"},children:e.label})]}),e.description?_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",marginBottom:4,maxWidth:180},children:String(e.description)}):null,_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)"},children:[t.length," agent",t.length!==1?"s":""]})]})}function GW({data:e}){return _.jsxs("div",{style:{padding:"8px 16px",border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--surface-1)",boxShadow:"0 1px 4px rgba(0,0,0,0.15)",textAlign:"center",minWidth:110},children:[_.jsx(Sl,{type:"target",position:We.Top,style:q1}),_.jsx(Sl,{type:"source",position:We.Bottom,style:q1}),_.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[_.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--status-active)",boxShadow:"0 0 6px var(--status-active-glow)",flexShrink:0}}),_.jsx("span",{style:{fontFamily:"var(--font-display)",fontWeight:500,fontSize:"0.72rem",color:"var(--text-secondary)"},children:e.label})]}),e.stepLabel?_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.5rem",color:"var(--text-muted)",marginTop:3,maxWidth:160,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:String(e.stepLabel)}):null]})}function qW({data:e}){return _.jsxs("div",{style:{padding:"5px 12px",border:"1px solid rgba(255, 171, 64, 0.3)",borderRadius:4,background:"var(--surface-2)",textAlign:"center",minWidth:80},children:[_.jsx(Sl,{type:"target",position:We.Top,style:vC}),_.jsx(Sl,{type:"source",position:We.Bottom,style:vC}),_.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--status-warning)"},children:"⏸"}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontWeight:500,fontSize:"0.6rem",color:"var(--status-warning)"},children:e.label})]})]})}const YW={company:PW,squad:FW,agent:GW,checkpoint:qW},_C=300,Lv=60;function VW(e){const{tree:t,squads:n}=e,i=[],r=[];if(n.length===0)return i.push({id:"company",type:"company",position:{x:0,y:0},data:{label:t.name},draggable:!0}),{nodes:i,edges:r};const l=n.length*_C/2-100;return i.push({id:"company",type:"company",position:{x:l,y:0},data:{label:t.name},draggable:!0}),n.forEach((c,f)=>{const p=`squad-${c.code}`,m=f*_C,g=new Map(c.agents.map(S=>[S.id,S]));i.push({id:p,type:"squad",position:{x:m,y:200},data:{label:c.name,description:c.description,agents:c.agents},draggable:!0}),r.push({id:`company-${p}`,source:"company",target:p,style:{stroke:"rgba(0, 230, 138, 0.3)",strokeWidth:2},animated:!1});const x=c.pipeline||[];if(x.length===0){c.agents.forEach((S,A)=>{const T=`agent-${c.code}-${S.id}`;i.push({id:T,type:"agent",position:{x:m+25,y:340+A*Lv},data:{label:S.name},draggable:!0}),r.push({id:`${p}-${T}`,source:p,target:T,style:{stroke:"rgba(100, 120, 200, 0.15)",strokeWidth:1}})});return}let v=p;x.forEach((S,A)=>{const T=S.type==="checkpoint",C=S.agent?g.get(S.agent):null,N=`step-${c.code}-${S.id}`;T?i.push({id:N,type:"checkpoint",position:{x:m+40,y:340+A*Lv},data:{label:S.label},draggable:!0}):i.push({id:N,type:"agent",position:{x:m+25,y:340+A*Lv},data:{label:(C==null?void 0:C.name)||S.agent||S.id,stepLabel:S.label},draggable:!0});const R=T?{stroke:"rgba(255, 171, 64, 0.3)",strokeWidth:1}:{stroke:"rgba(0, 200, 255, 0.25)",strokeWidth:1.5};r.push({id:`chain-${c.code}-${v}-${N}`,source:v,target:N,style:R,markerEnd:T?void 0:{type:Ym.ArrowClosed,color:"rgba(0, 200, 255, 0.35)",width:12,height:12},animated:!T}),v=N})}),{nodes:i,edges:r}}function XW({data:e}){const{fitView:t}=Sx(),{nodes:n,edges:i}=j.useMemo(()=>VW(e),[e]);j.useEffect(()=>{const s=setTimeout(()=>t({padding:.12,duration:400}),50);return()=>clearTimeout(s)},[n.length,t]);const r=e.squads.reduce((s,l)=>s+l.agents.length,0);return _.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",animation:"fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both"},children:[_.jsxs("div",{style:{padding:"16px 20px 12px",flexShrink:0},children:[_.jsxs("h2",{style:{fontFamily:"var(--font-display)",fontWeight:700,fontSize:"1.1rem",color:"var(--text-primary)",marginBottom:2},children:[e.tree.name," — Org Chart"]}),_.jsxs("p",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)"},children:[e.squads.length," active squad",e.squads.length!==1?"s":""," / ",r," agents"]})]}),_.jsx("div",{style:{flex:1,minHeight:0},children:_.jsxs(fW,{nodes:n,edges:i,nodeTypes:YW,fitView:!0,fitViewOptions:{padding:.12},minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},style:{background:"var(--surface-0)"},nodesDraggable:!0,nodesConnectable:!1,children:[_.jsx(yW,{color:"rgba(100, 120, 200, 0.04)",gap:24,size:1}),_.jsx(wW,{showInteractive:!1,style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:8}}),_.jsx(jW,{nodeColor:s=>s.type==="company"?"#007acc":s.type==="squad"?"#00e68a":s.type==="checkpoint"?"#ffab40":"#888",maskColor:"var(--glass-bg)",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8}})]})})]})}function KW(){const[e,t]=j.useState(null),[n,i]=j.useState(!0),[r,s]=j.useState(null);return j.useEffect(()=>{fetch("/api/orgchart",{credentials:"include"}).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return l.json()}).then(l=>{t(l),i(!1)}).catch(l=>{s(l.message),i(!1)})},[]),n?_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)"},children:"Loading org chart..."}):r||!e?_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--status-error)"},children:r||"Failed to load org chart"}):_.jsx(XN,{children:_.jsx(XW,{data:e})})}const QN={squad:"#00c8ff",agent:"#00e68a",memory:"#b388ff",skill:"#ffab40"},Y1={squad:18,agent:12,memory:8,skill:8},SC={contains:"rgba(255,255,255,0.08)",pipeline:"rgba(0,200,255,0.4)",delivers:"rgba(0,230,138,0.5)",uses_skill:"rgba(255,171,64,0.15)",has_memory:"rgba(179,136,255,0.15)",shared_skill:"rgba(255,171,64,0.3)",shared_memory:"rgba(179,136,255,0.3)"};function $W(e,t,n,i,r){const s=n/2,l=i/2,c=3e3*r,f=.008*r,p=.01*r,m=.85;for(let x=0;x<e.length;x++){let v=0,S=0;for(let A=0;A<e.length;A++){if(x===A)continue;const T=e[x].x-e[A].x,C=e[x].y-e[A].y,N=T*T+C*C+1,R=c/N,O=Math.sqrt(N);v+=T/O*R,S+=C/O*R}v+=(s-e[x].x)*p,S+=(l-e[x].y)*p,e[x].vx=(e[x].vx+v)*m,e[x].vy=(e[x].vy+S)*m}for(const x of t){const v=e.findIndex(H=>H.id===x.source),S=e.findIndex(H=>H.id===x.target);if(v===-1||S===-1)continue;const A=e[S].x-e[v].x,T=e[S].y-e[v].y,C=Math.sqrt(A*A+T*T)+1,N=(C-100)*f,R=A/C*N,O=T/C*N;e[v].vx+=R,e[v].vy+=O,e[S].vx-=R,e[S].vy-=O}let g=0;for(const x of e)x.x+=x.vx,x.y+=x.vy,g+=x.vx*x.vx+x.vy*x.vy;return g}function WW(e,t){const n=new Map;for(const l of t)n.has(l.source)||n.set(l.source,[]),n.has(l.target)||n.set(l.target,[]),n.get(l.source).push(l.target),n.get(l.target).push(l.source);const i=new Map;i.set(e,0);const r=[e];let s=0;for(;s<r.length;){const l=r[s++],c=i.get(l);for(const f of n.get(l)||[])i.has(f)||(i.set(f,c+1),r.push(f))}return i}function QW(e,t,n,i,r,s,l,c,f){const p=getComputedStyle(document.documentElement).getPropertyValue("--surface-0").trim()||"#1e1e1e";e.fillStyle=p,e.fillRect(0,0,i,r),e.save(),e.translate(l,c),e.scale(f,f);const m=new Map(t.map(v=>[v.id,v]));let g=null;if(s){g=WW(s.id,n);for(const v of g.values());}const x=v=>{if(!s||!g||v===s.id)return 1;const S=g.get(v);return S===void 0?.06:Math.max(.08,1-S*.28)};for(const v of n){const S=m.get(v.source),A=m.get(v.target);if(!S||!A)continue;const T=Math.min(x(v.source),x(v.target)),C=s&&(v.source===s.id||v.target===s.id);if(e.globalAlpha=T,e.beginPath(),e.moveTo(S.x,S.y),e.lineTo(A.x,A.y),e.strokeStyle=C?"rgba(255,255,255,0.6)":SC[v.type]||"rgba(255,255,255,0.06)",e.lineWidth=C?1.8:v.type==="delivers"||v.type==="pipeline"?1.2:.5,e.stroke(),v.type==="delivers"||v.type==="pipeline"){const N=Math.atan2(A.y-S.y,A.x-S.x),R=Y1[A.type]||10,O=A.x-Math.cos(N)*(R+4),H=A.y-Math.sin(N)*(R+4);e.beginPath(),e.moveTo(O,H),e.lineTo(O-Math.cos(N-.4)*6,H-Math.sin(N-.4)*6),e.lineTo(O-Math.cos(N+.4)*6,H-Math.sin(N+.4)*6),e.closePath(),e.fillStyle=SC[v.type],e.fill()}}e.globalAlpha=1;for(const v of t){const S=Y1[v.type]||10,A=QN[v.type]||"#888",T=(s==null?void 0:s.id)===v.id,C=x(v.id);e.globalAlpha=C,e.beginPath(),e.arc(v.x,v.y,S,0,Math.PI*2),T&&(e.shadowColor=A,e.shadowBlur=24),e.fillStyle=A,e.fill(),e.shadowBlur=0;const N=v.type==="squad"?11:9;e.font=`${v.type==="squad"?"600":"400"} ${N}px "JetBrains Mono", monospace`,e.textAlign="center",e.textBaseline="top";const R=getComputedStyle(document.documentElement).getPropertyValue("--text-primary").trim()||"#fff";e.fillStyle=R,e.fillText(v.label,v.x,v.y+S+4)}e.globalAlpha=1,e.restore()}function ZW(){const e=j.useRef(null),[t,n]=j.useState([]),[i,r]=j.useState([]),[s,l]=j.useState(!0),[c,f]=j.useState(null),p=j.useRef(null),m=j.useRef(null),g=j.useRef(null),x=j.useRef(!1),v=j.useRef({x:0,y:0}),S=j.useRef(1),A=j.useRef(!1),T=j.useRef({x:0,y:0}),C=j.useRef([]),N=j.useRef([]),R=j.useRef(0),O=j.useRef(1),H=j.useRef(!0),D=j.useRef(null);j.useEffect(()=>{fetch("/api/graph",{credentials:"include"}).then(V=>V.json()).then(V=>{const Y=window.innerWidth,P=window.innerHeight,q=V.nodes.map((ne,I)=>({...ne,x:Y/2+(Math.random()-.5)*400,y:P/2+(Math.random()-.5)*400,vx:0,vy:0}));C.current=q,N.current=V.edges,n(q),r(V.edges),l(!1)}).catch(()=>{f("Failed to load graph data"),l(!1)})},[]);const F=j.useCallback((V,Y)=>{const P=v.current,q=S.current,ne=(V-P.x)/q,I=(Y-P.y)/q;for(let $=C.current.length-1;$>=0;$--){const z=C.current[$],G=Y1[z.type]||10,Q=ne-z.x,W=I-z.y;if(Q*Q+W*W<(G+4)*(G+4))return z}return null},[]);j.useEffect(()=>{const V=e.current;if(!V)return;const Y=$=>{const z=V.getBoundingClientRect(),G=$.clientX-z.left,Q=$.clientY-z.top;if(g.current){x.current=!0;const J=S.current,X=v.current;g.current.x=(G-X.x)/J,g.current.y=(Q-X.y)/J,g.current.vx=0,g.current.vy=0,O.current=.3,H.current=!0;return}if(A.current){v.current.x+=G-T.current.x,v.current.y+=Q-T.current.y,T.current={x:G,y:Q};return}const W=S.current,B=v.current;D.current={x:(G-B.x)/W,y:(Q-B.y)/W};const K=F(G,Q);p.current=K,V.style.cursor=K?"grab":"default"},P=$=>{const z=V.getBoundingClientRect(),G=$.clientX-z.left,Q=$.clientY-z.top;x.current=!1;const W=F(G,Q);W?(g.current=W,V.style.cursor="grabbing"):(A.current=!0,T.current={x:G,y:Q},V.style.cursor="move")},q=$=>{var G;g.current;const z=A.current;if(g.current=null,A.current=!1,V.style.cursor="default",!x.current){const Q=V.getBoundingClientRect(),W=$.clientX-Q.left,B=$.clientY-Q.top,K=F(W,B);K?m.current=((G=m.current)==null?void 0:G.id)===K.id?null:K:z||(m.current=null)}},ne=$=>{$.preventDefault();const z=V.getBoundingClientRect(),G=$.clientX-z.left,Q=$.clientY-z.top,W=$.deltaY>0?.92:1.08,B=Math.max(.2,Math.min(5,S.current*W)),K=B/S.current;v.current.x=G-(G-v.current.x)*K,v.current.y=Q-(Q-v.current.y)*K,S.current=B},I=()=>{g.current=null,A.current=!1,D.current=null,V.style.cursor="default"};return V.addEventListener("mousemove",Y),V.addEventListener("mousedown",P),V.addEventListener("mouseup",q),V.addEventListener("mouseleave",I),V.addEventListener("wheel",ne,{passive:!1}),()=>{V.removeEventListener("mousemove",Y),V.removeEventListener("mousedown",P),V.removeEventListener("mouseup",q),V.removeEventListener("mouseleave",I),V.removeEventListener("wheel",ne)}},[F,s]),j.useEffect(()=>{if(s||C.current.length===0)return;const V=e.current;if(!V)return;const Y=()=>{const I=V.parentElement;I&&(V.width=I.clientWidth*window.devicePixelRatio,V.height=I.clientHeight*window.devicePixelRatio,V.style.width=I.clientWidth+"px",V.style.height=I.clientHeight+"px")};Y(),window.addEventListener("resize",Y);const P=V.getContext("2d");let q=!0;const ne=()=>{if(!q)return;const I=V.width/window.devicePixelRatio,$=V.height/window.devicePixelRatio;P.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),H.current&&($W(C.current,N.current,I,$,O.current),O.current*=.98,O.current<.001&&(H.current=!1,O.current=0));const z=D.current;if(z&&!g.current&&!A.current)for(const W of C.current){const B=W.x-z.x,K=W.y-z.y,J=B*B+K*K;if(J<14400&&J>1){const X=Math.sqrt(J),ce=.8*(1-X/120);W.x+=B/X*ce,W.y+=K/X*ce}}QW(P,C.current,N.current,I,$,m.current,v.current.x,v.current.y,S.current),R.current=requestAnimationFrame(ne)};return R.current=requestAnimationFrame(ne),()=>{q=!1,cancelAnimationFrame(R.current),window.removeEventListener("resize",Y)}},[s]);const Z=j.useCallback(V=>{const Y=e.current;if(!Y)return;const P=V==="in"?1.25:.8,q=Y.clientWidth/2,ne=Y.clientHeight/2,I=Math.max(.2,Math.min(5,S.current*P)),$=I/S.current;v.current.x=q-(q-v.current.x)*$,v.current.y=ne-(ne-v.current.y)*$,S.current=I},[]);return s?_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.8rem"},children:"Loading graph..."}):c?_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--status-error)",fontFamily:"var(--font-mono)",fontSize:"0.8rem"},children:c}):_.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:"var(--surface-0)"},children:[_.jsx("canvas",{ref:e,style:{display:"block",touchAction:"none"}}),_.jsx("div",{style:{position:"absolute",bottom:16,left:16,background:"rgba(10, 12, 16, 0.85)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",display:"flex",flexDirection:"column",gap:6},children:Object.entries(QN).map(([V,Y])=>_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[_.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:Y,display:"inline-block"}}),_.jsx("span",{style:{textTransform:"capitalize"},children:V})]},V))}),_.jsxs("div",{style:{position:"absolute",top:16,right:16,background:"rgba(10, 12, 16, 0.85)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)",display:"flex",gap:16},children:[_.jsxs("span",{children:[t.length," nodes"]}),_.jsxs("span",{children:[i.length," edges"]})]}),_.jsx("div",{style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4},children:[{label:"+",action:"in"},{label:"−",action:"out"}].map(({label:V,action:Y})=>_.jsx("button",{onClick:()=>Z(Y),style:{width:32,height:32,background:"rgba(10, 12, 16, 0.85)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-sm)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"1rem",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:V},Y))})]})}function JW(){const[e,t]=j.useState([]),[n,i]=j.useState(null),[r,s]=j.useState(""),[l,c]=j.useState(""),[f,p]=j.useState(!1),[m,g]=j.useState(!1),[x,v]=j.useState(new Set),[S,A]=j.useState(""),T=j.useRef(null);j.useEffect(()=>{fetch("/api/files",{credentials:"include"}).then(D=>D.json()).then(D=>{const F=new Map;for(const V of D)F.has(V.squad)||F.set(V.squad,{squad:V.squad,squadName:V.squadName,files:[]}),F.get(V.squad).files.push(V);const Z=[...F.values()];t(Z)})},[]);const C=j.useCallback(D=>{i(D),g(!0),fetch(`/api/files/${D.squad}/${D.path}`,{credentials:"include"}).then(F=>F.json()).then(F=>{s(F.content),c(F.content),g(!1)}).catch(()=>{s(""),c(""),g(!1)})},[]),N=j.useCallback(async()=>{n&&(p(!0),await fetch(`/api/files/${n.squad}/${n.path}`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})}),c(r),p(!1))},[n,r]),R=j.useCallback(D=>{v(F=>{const Z=new Set(F);return Z.has(D)?Z.delete(D):Z.add(D),Z})},[]),O=r!==l;j.useEffect(()=>{const D=F=>{(F.metaKey||F.ctrlKey)&&F.key==="s"&&(F.preventDefault(),O&&n&&N())};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[O,n,N]);const H=D=>D==="squad.yaml"?"⚙":D==="memories.md"?"◆":"◇";return _.jsxs("div",{style:{display:"flex",height:"100%",overflow:"hidden"},children:[_.jsxs("div",{style:{width:260,minWidth:260,borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[_.jsx("div",{style:{padding:"12px 14px",fontFamily:"var(--font-mono)",fontSize:"0.6rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.1em",borderBottom:"1px solid var(--border-subtle)"},children:"Squad Files"}),_.jsx("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border-subtle)"},children:_.jsx("input",{type:"text",placeholder:"Search squads...",value:S,onChange:D=>A(D.target.value),style:{width:"100%",padding:"5px 8px",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-xs)",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:"0.7rem",outline:"none"}})}),_.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"8px 0"},children:[e.filter(D=>{if(!S)return!0;const F=S.toLowerCase();return D.squadName.toLowerCase().includes(F)||D.squad.toLowerCase().includes(F)}).map(D=>_.jsxs("div",{children:[_.jsxs("button",{onClick:()=>R(D.squad),style:{width:"100%",background:"none",border:"none",padding:"6px 14px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.75rem",fontWeight:600,color:"var(--text-primary)",textAlign:"left"},children:[_.jsx("span",{style:{fontSize:"0.6rem",transition:"transform 0.15s ease",transform:x.has(D.squad)?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),D.squadName]}),x.has(D.squad)&&_.jsx("div",{style:{paddingLeft:14},children:D.files.map(F=>{const Z=(n==null?void 0:n.squad)===F.squad&&(n==null?void 0:n.path)===F.path;return _.jsxs("button",{onClick:()=>C(F),style:{width:"100%",background:Z?"var(--accent-glow)":"none",border:Z?"1px solid rgba(0, 200, 255, 0.12)":"1px solid transparent",borderRadius:"var(--radius-xs)",padding:"5px 10px",display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:Z?"var(--accent)":"var(--text-secondary)",textAlign:"left"},children:[_.jsx("span",{style:{opacity:.6},children:H(F.file)}),F.file]},`${F.squad}/${F.path}`)})})]},D.squad)),e.length===0&&_.jsx("div",{style:{padding:"20px 14px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",color:"var(--text-muted)",textAlign:"center"},children:"No squads found"})]})]}),_.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:n?_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-secondary)",display:"flex",alignItems:"center",gap:8},children:[_.jsx("span",{style:{color:"var(--text-muted)"},children:n.squadName}),_.jsx("span",{style:{color:"var(--text-muted)",opacity:.4},children:"/"}),_.jsx("span",{children:n.file}),O&&_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--accent)",display:"inline-block"}})]}),_.jsxs("button",{onClick:N,disabled:!O||f,style:{background:O?"var(--accent)":"var(--surface-3)",border:"none",borderRadius:"var(--radius-xs)",padding:"4px 14px",fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:O?"var(--text-inverse)":"var(--text-muted)",cursor:O?"pointer":"default",opacity:O?1:.5,transition:"all 0.15s ease"},children:[f?"Saving...":"Save",_.jsx("span",{style:{marginLeft:6,fontSize:"0.6rem",opacity:.7},children:"⌘S"})]})]}),m?_.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.8rem"},children:"Loading..."}):_.jsx("textarea",{ref:T,value:r,onChange:D=>s(D.target.value),spellCheck:!1,style:{flex:1,width:"100%",padding:"16px 20px",border:"none",outline:"none",resize:"none",background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:'"JetBrains Mono", "Fira Code", monospace',fontSize:"0.8rem",lineHeight:1.7,tabSize:2,whiteSpace:"pre",overflowWrap:"normal",overflowX:"auto"}})]}):_.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:[_.jsx("span",{style:{fontSize:"2rem",opacity:.3},children:"◇"}),_.jsx("span",{style:{fontSize:"0.8rem"},children:"Select a file to edit"})]})})]})}function xm(e){return e>=70?"#4ade80":e>=40?"#f59e0b":"#f44747"}function Ff(e,t,n){const i=n>0?Math.round(e/n*100):0,r=e+t>0?Math.round(e/(e+t)*100):0,s=Math.round((i+r)/2);return{r:i,q:r,e:s}}function EC(e,t){const n=Math.max(0,Math.floor((t-new Date(e).getTime())/1e3)),i=Math.floor(n/3600).toString().padStart(2,"0"),r=Math.floor(n%3600/60).toString().padStart(2,"0"),s=(n%60).toString().padStart(2,"0");return`${i}:${r}:${s}`}function jv(e,t){return t[e]??e.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function eQ({name:e,size:t=28}){const n=[...e].reduce((i,r)=>i+r.charCodeAt(0),0)%360;return _.jsx("div",{style:{width:t,height:t,borderRadius:"50%",flexShrink:0,background:`hsl(${n},45%,20%)`,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"var(--font-mono)",fontWeight:700,fontSize:Math.round(t*.38),color:`hsl(${n},55%,68%)`},children:e.slice(0,1).toUpperCase()})}function tQ({rank:e}){const t=["#FFD700","#C0C0C0","#CD7F32"],n=e<=3?t[e-1]:"var(--text-muted)";return _.jsx("div",{style:{width:20,height:20,borderRadius:"50%",flexShrink:0,background:e<=3?`${n}22`:"transparent",border:`1.5px solid ${n}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.55rem",fontWeight:700,color:n},children:e})}function ld({label:e,value:t,sub:n,color:i,icon:r}){return _.jsxs("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"14px 14px 12px",display:"flex",flexDirection:"column",gap:6},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[_.jsx("span",{style:{fontSize:"0.58rem",color:"var(--text-muted)",fontFamily:"var(--font-mono)",textTransform:"uppercase",letterSpacing:"0.08em"},children:e}),r&&_.jsx("span",{style:{fontSize:"0.75rem",opacity:.5},children:r})]}),_.jsx("div",{style:{fontSize:"1.9rem",fontWeight:800,fontFamily:"var(--font-display)",color:i??"var(--text-bright)",lineHeight:1},children:t}),_.jsx("div",{style:{fontSize:"0.58rem",color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:n})]})}function Iv({label:e,value:t,description:n}){const i=xm(t);return _.jsxs("div",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:16},children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:10},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",fontWeight:700,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.08em"},children:e}),_.jsxs("span",{style:{fontFamily:"var(--font-display)",fontSize:"1.15rem",fontWeight:800,color:i},children:[t,"%"]})]}),_.jsx("div",{style:{height:5,background:"var(--surface-3)",borderRadius:3,overflow:"hidden"},children:_.jsx("div",{style:{height:"100%",width:`${t}%`,background:i,borderRadius:3,transition:"width 0.6s ease"}})}),_.jsx("p",{style:{fontSize:"0.58rem",color:"var(--text-muted)",fontFamily:"var(--font-mono)",marginTop:8,lineHeight:1.6},children:n})]})}function wC({bars:e,height:t=100,showSecondary:n=!1}){const i=Math.max(...e.flatMap(s=>[s.primary,s.secondary??0]),1),r=t-16;return _.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:2,height:t},children:e.map((s,l)=>_.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[_.jsxs("div",{style:{display:"flex",gap:1,alignItems:"flex-end",width:"100%",height:r},children:[n&&s.secondary!==void 0&&_.jsx("div",{style:{flex:1,alignSelf:"flex-end",height:Math.max(s.secondary>0?2:0,Math.round(s.secondary/i*r)),background:"rgba(255,255,255,0.1)",borderRadius:"2px 2px 0 0"}}),_.jsx("div",{style:{flex:1,alignSelf:"flex-end",height:Math.max(s.primary>0?2:0,Math.round(s.primary/i*r)),background:"#4ade80",borderRadius:"2px 2px 0 0"}})]}),_.jsx("span",{style:{fontSize:"0.42rem",color:"var(--text-muted)",whiteSpace:"nowrap",fontFamily:"var(--font-mono)"},children:s.label})]},l))})}function Uv({rank:e,name:t,score:n,sub:i,barColor:r}){return _.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:3},children:[_.jsx(tQ,{rank:e}),_.jsx(eQ,{name:t,size:26}),_.jsxs("div",{style:{flex:1,minWidth:0},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.63rem",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.48rem",color:"var(--text-muted)"},children:i})]}),_.jsxs("span",{style:{fontFamily:"var(--font-display)",fontSize:"0.82rem",fontWeight:800,color:r,flexShrink:0},children:[n,"%"]})]}),_.jsx("div",{style:{height:2,background:"var(--surface-3)",borderRadius:1,marginLeft:55},children:_.jsx("div",{style:{height:"100%",width:`${n}%`,background:r,borderRadius:1}})})]})}function nQ(){var W;const[e,t]=j.useState(null),[n,i]=j.useState(Date.now()),[r,s]=j.useState(null),[l,c]=j.useState(!1),[f,p]=j.useState(!1),[m,g]=j.useState(!1),x=vr(B=>B.squads),v=Object.fromEntries(x.map(B=>[B.code,B.name]));j.useEffect(()=>{const B=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(B)},[]);const S=async()=>{try{const B=await fetch("/api/dashboard/stats",{credentials:"include"});B.ok&&t(await B.json())}catch{}};j.useEffect(()=>{S();const B=setInterval(S,3e4);return()=>clearInterval(B)},[]);const A=async B=>{p(!0);try{(await fetch(`/api/dashboard/sessions/${B}/kill`,{method:"POST",credentials:"include"})).ok&&(s(null),c(!1),await S())}catch{}finally{p(!1)}},T=B=>{s(B),c(!1)},C=new Date(n),N=C.toLocaleTimeString("pt-BR",{hour12:!1}),R=C.toLocaleDateString("pt-BR",{weekday:"long",day:"numeric",month:"long"}).toUpperCase(),O=e==null?void 0:e.kpis,H=e==null?void 0:e.metrics,D=(O==null?void 0:O.weekChange)??0,F=(()=>{const B=Object.fromEntries(((e==null?void 0:e.rhythm14)??[]).map(K=>[K.day,K.count]));return Array.from({length:14},(K,J)=>{const X=new Date(n);X.setDate(X.getDate()-(13-J));const ce=X.toISOString().slice(0,10);return{label:`${X.getDate().toString().padStart(2,"0")}/${(X.getMonth()+1).toString().padStart(2,"0")}`,primary:B[ce]??0}})})(),Z=(()=>{const B=Object.fromEntries(((e==null?void 0:e.hourlyToday)??[]).map(J=>[J.hour,J.count])),K=Object.fromEntries(((e==null?void 0:e.hourlyLastWeek)??[]).map(J=>[J.hour,Math.round(J.avg_count)]));return Array.from({length:14},(J,X)=>{const ce=X+7;return{label:`${ce.toString().padStart(2,"0")}h`,primary:B[ce]??0,secondary:K[ce]??0}})})(),V=F.reduce((B,K)=>B+K.primary,0),Y=C.getHours(),P=((W=((e==null?void 0:e.hourlyToday)??[]).find(B=>B.hour===Y))==null?void 0:W.count)??0,q=(e==null?void 0:e.agentPerf)??[],ne=[...q].sort((B,K)=>{const{e:J}=Ff(B.done,B.failed,B.total),{e:X}=Ff(K.done,K.failed,K.total);return X-J}),I=[...q].sort((B,K)=>{const J=B.total>0?B.done/B.total:0;return(K.total>0?K.done/K.total:0)-J}),$=[...q].sort((B,K)=>{const{e:J}=Ff(B.done,B.failed,B.total),{e:X}=Ff(K.done,K.failed,K.total);return X-J}),z={background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:16,overflow:"hidden"},G={display:"flex",alignItems:"center",gap:6,fontFamily:"var(--font-mono)",fontSize:"0.62rem",fontWeight:700,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:14},Q=_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"var(--text-muted)"},children:"Nenhum dado ainda"});return _.jsxs("div",{style:{overflowY:"auto",background:"var(--surface-0)",...m?{position:"fixed",inset:0,zIndex:200}:{height:"100%"}},children:[_.jsxs("div",{style:{padding:"12px 24px",borderBottom:"1px solid var(--border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"flex-start",position:"sticky",top:0,zIndex:10,background:"var(--surface-0)"},children:[_.jsxs("div",{children:[_.jsx("div",{style:{fontFamily:"var(--font-display)",fontSize:"1rem",fontWeight:700,color:"var(--text-bright)"},children:"Painel de Operações"}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:2},children:[_.jsx("span",{style:{fontSize:"0.55rem",fontFamily:"var(--font-mono)",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.1em"},children:"em tempo real"}),_.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",display:"inline-block",background:"#4ade80",boxShadow:"0 0 5px #4ade80",animation:"statusPulse 2s ease-in-out infinite"}}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"#4ade80"},children:"Ao vivo"})]})]})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[_.jsx("button",{onClick:()=>g(B=>!B),title:m?"Voltar ao modo normal":"Modo foco — tela cheia",style:{background:m?"rgba(0,200,255,0.1)":"transparent",border:`1px solid ${m?"var(--accent)":"var(--border-subtle)"}`,color:m?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:"0.6rem",padding:"4px 10px",borderRadius:4,whiteSpace:"nowrap"},children:m?"← Normal":"⛶ Foco"}),_.jsxs("div",{style:{textAlign:"right"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"1.5rem",fontWeight:700,color:"var(--text-bright)",lineHeight:1,letterSpacing:"0.04em"},children:N}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)",marginTop:3,letterSpacing:"0.06em"},children:R})]})]})]}),!e&&_.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"calc(100% - 64px)"},children:_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.75rem",color:"var(--text-muted)"},children:"Carregando dados..."})}),e&&_.jsxs("div",{style:{padding:"16px 24px 40px",display:"flex",flexDirection:"column",gap:12},children:[_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:10},children:[_.jsx(ld,{label:"Em Aberto",value:O.open,sub:"Tarefas planejadas",icon:"○"}),_.jsx(ld,{label:"Falhas",value:O.delayed,sub:"Tarefas com erro ou falha",color:O.delayed>0?"#f44747":void 0,icon:"△"}),_.jsx(ld,{label:"Concluídas Hoje",value:O.doneToday,sub:`Finalizadas em ${C.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit"})}`,color:"#4ade80",icon:"✓"}),_.jsx(ld,{label:"Squads Rodando",value:O.activeSquads,sub:"Squads com pipeline ativo",color:O.activeSquads>0?"#f59e0b":void 0,icon:"◈"}),_.jsx(ld,{label:"Pipelines Ativos",value:O.runningNow,sub:"Instâncias Claude em execução",color:O.runningNow>0?"#4ade80":void 0,icon:"▶"}),_.jsx(ld,{label:"Horas Rastreadas (7d)",value:`${O.hoursTracked}h`,sub:"Últimos 7 dias",icon:"⏱"}),_.jsx(ld,{label:"Sem. vs Anterior",value:`${D>0?"+":""}${D}%`,sub:"Entregas vs período anterior",color:D>0?"#4ade80":D<0?"#f44747":void 0,icon:D>=0?"↑":"↓"})]}),_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:10},children:[_.jsx(Iv,{label:"Regularidade",value:H.regularidade,description:"Taxa de tarefas concluídas em relação ao total de tarefas registradas."}),_.jsx(Iv,{label:"Qualidade",value:H.qualidade,description:"Taxa de sucesso entre tarefas finalizadas — concluídas vs. falhas."}),_.jsx(Iv,{label:"Eficiência",value:H.eficiencia,description:"Combina regularidade e qualidade para medir o desempenho geral."})]}),_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"55fr 45fr",gap:10},children:[_.jsxs("div",{style:z,children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:14},children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"📈"}),_.jsx("span",{children:"Ritmo de Conclusão"}),_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"últimos 14 dias"})]}),_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)"},children:["Total: ",V," tarefas"]})]}),_.jsx(wC,{bars:F,height:120})]}),_.jsxs("div",{style:z,children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:14},children:[_.jsxs("div",{children:[_.jsxs("div",{style:{...G,marginBottom:6},children:[_.jsx("span",{children:"⏰"}),_.jsx("span",{children:"Ritmo por Hora"}),_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"hoje vs média semana anterior"})]}),_.jsxs("div",{style:{display:"flex",gap:10,marginBottom:8},children:[_.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"#4ade80"},children:[_.jsx("span",{style:{width:8,height:8,borderRadius:2,background:"#4ade80",display:"inline-block"}}),"Hoje"]}),_.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)"},children:[_.jsx("span",{style:{width:8,height:8,borderRadius:2,background:"rgba(255,255,255,0.12)",display:"inline-block"}}),"Média sem. anterior"]})]})]}),_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",textAlign:"right",whiteSpace:"nowrap"},children:[P," nesta hora",_.jsx("br",{}),"Total: ",O.doneToday]})]}),_.jsx(wC,{bars:Z,height:100,showSecondary:!0})]})]}),e.runningSessions.length>0&&_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"#4ade80",boxShadow:"0 0 6px #4ade80",display:"inline-block",animation:"statusPulse 2s ease-in-out infinite"}}),"Pipelines Ativos — ",e.runningSessions.length," instância",e.runningSessions.length!==1?"s":""," Claude em execução"]}),_.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:10},children:e.runningSessions.map(B=>{const K=jv(B.squad_code,v),J=[...B.squad_code].reduce((ie,de)=>ie+de.charCodeAt(0),0)%360,X=B.steps_total>0?Math.round(B.steps_done/B.steps_total*100):0,ce=(e.sessionAgents??[]).filter(ie=>ie.activity_id===B.id);return _.jsxs("div",{onClick:()=>T(B),style:{background:"var(--surface-2)",border:"1px solid rgba(74,222,128,0.15)",borderRadius:6,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,cursor:"pointer",transition:"border-color 0.15s"},onMouseEnter:ie=>ie.currentTarget.style.borderColor="rgba(74,222,128,0.4)",onMouseLeave:ie=>ie.currentTarget.style.borderColor="rgba(74,222,128,0.15)",children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[_.jsx("div",{style:{width:34,height:34,borderRadius:"50%",flexShrink:0,background:`hsl(${J},45%,18%)`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:"0.82rem",fontFamily:"var(--font-mono)",color:`hsl(${J},55%,65%)`},children:K.slice(0,1).toUpperCase()}),_.jsxs("div",{style:{flex:1,minWidth:0},children:[_.jsx("div",{style:{fontFamily:"var(--font-display)",fontSize:"0.76rem",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)",marginTop:1},children:B.squad_code})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,flexShrink:0},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#4ade80",display:"inline-block",boxShadow:"0 0 4px #4ade80"}}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.72rem",fontWeight:700,color:"#4ade80"},children:EC(B.started_at,n)})]})]}),B.steps_total>0&&_.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:4},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.5rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Progresso"}),_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",fontWeight:700,color:B.current_task?"#f59e0b":"#4ade80"},children:[B.steps_done,"/",B.steps_total," etapas · ",X,"%"]})]}),_.jsx("div",{style:{height:5,background:"var(--surface-3)",borderRadius:3,overflow:"hidden"},children:_.jsx("div",{style:{height:"100%",width:`${X}%`,background:B.current_task?"#f59e0b":"#4ade80",borderRadius:3,transition:"width 0.4s ease"}})})]}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:B.current_task?"var(--text-secondary)":"var(--text-muted)",display:"flex",alignItems:"center",gap:5,overflow:"hidden"},children:B.current_task?_.jsxs(_.Fragment,{children:[_.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"#f59e0b",display:"inline-block",flexShrink:0,animation:"statusPulse 1.5s ease-in-out infinite"}}),_.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.current_task})]}):_.jsx("span",{style:{color:"var(--text-muted)"},children:"⏳ Aguardando próxima etapa..."})}),ce.length>0&&_.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:ce.map(ie=>{const de=ie.executing_count>0,ye=ie.done_count===ie.total&&ie.executing_count===0,me=ie.failed_count>0&&ie.executing_count===0&&ie.done_count<ie.total,le=de?"#f59e0b":ye?"#4ade80":me?"#f44747":"var(--text-muted)",Re=de?"#f59e0b":ye?"#4ade80":me?"#f44747":"var(--text-muted)",Le=de?"rgba(245,158,11,0.1)":ye?"rgba(74,222,128,0.08)":me?"rgba(244,71,71,0.08)":"rgba(255,255,255,0.04)",je=ie.agent_name.split(/[\s_-]/)[0];return _.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,background:Le,border:`1px solid ${le}33`,borderRadius:20,padding:"2px 7px"},children:[_.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:le,display:"inline-block",flexShrink:0,...de?{animation:"statusPulse 1.5s ease-in-out infinite"}:{}}}),_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",fontWeight:600,color:Re,whiteSpace:"nowrap"},children:je})]},ie.agent_name)})})]},B.id)})})]}),_.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10},children:[_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"👥"})," Performance por Squad"]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.squadPerf.length===0&&Q,[...e.squadPerf].sort((B,K)=>{const J=B.total>0?B.done/B.total:0;return(K.total>0?K.done/K.total:0)-J}).slice(0,6).map((B,K)=>{const J=B.total>0?Math.round(B.done/B.total*100):0,X=jv(B.squad_code,v),ce=xm(J);return _.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:4},children:[_.jsxs("div",{style:{display:"flex",gap:5,alignItems:"flex-start",flex:1,minWidth:0},children:[_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)",paddingTop:1,width:16,flexShrink:0},children:["#",K+1]}),_.jsxs("div",{style:{minWidth:0},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.63rem",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:X}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.52rem",color:"var(--text-muted)",marginTop:1},children:[B.done,"/",B.total," concluídas",B.failed>0&&_.jsxs("span",{style:{color:"#f44747",marginLeft:4},children:[B.failed," falhas"]})]})]})]}),_.jsx("span",{style:{fontFamily:"var(--font-display)",fontSize:"0.9rem",fontWeight:800,color:ce,flexShrink:0,marginLeft:6},children:J})]}),_.jsx("div",{style:{height:3,background:"var(--surface-3)",borderRadius:2},children:_.jsx("div",{style:{height:"100%",width:`${J}%`,background:ce,borderRadius:2}})})]},B.squad_code)})]})]}),_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"🏆"})," Top Performers",_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"score combinado"})]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:9},children:[ne.length===0&&Q,ne.slice(0,5).map((B,K)=>{const J=Ff(B.done,B.failed,B.total);return _.jsx(Uv,{rank:K+1,name:B.agent_name,score:J.e,barColor:xm(J.e),sub:`R: ${J.r}% · Q: ${J.q}% · E: ${J.e}%`},B.agent_name)})]})]}),_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"⭐"})," Top Regularidade",_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"tarefas entregues"})]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:9},children:[I.length===0&&Q,I.slice(0,5).map((B,K)=>{const J=B.total>0?Math.round(B.done/B.total*100):0;return _.jsx(Uv,{rank:K+1,name:B.agent_name,score:J,barColor:xm(J),sub:`${B.done} de ${B.total} concluídas`},B.agent_name)})]})]}),_.jsxs("div",{style:z,children:[_.jsxs("div",{style:G,children:[_.jsx("span",{children:"📊"})," Top Eficiência",_.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",fontSize:"0.52rem",textTransform:"none"},children:"conclusão vs. andamento"})]}),_.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:9},children:[$.length===0&&Q,$.slice(0,5).map((B,K)=>{const{r:J,q:X,e:ce}=Ff(B.done,B.failed,B.total);return _.jsx(Uv,{rank:K+1,name:B.agent_name,score:ce,barColor:xm(ce),sub:`R: ${J}% · Q: ${X}% · E: ${ce}%`},B.agent_name)})]})]})]})]}),r&&(()=>{const B=r,K=jv(B.squad_code,v),J=[...B.squad_code].reduce((de,ye)=>de+ye.charCodeAt(0),0)%360,X=B.steps_total>0?Math.round(B.steps_done/B.steps_total*100):0,ce=new Date(B.started_at).toLocaleTimeString("pt-BR",{hour12:!1}),ie=new Date(B.started_at).toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit"});return _.jsx("div",{onClick:()=>{s(null),c(!1)},style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(3px)",display:"flex",alignItems:"center",justifyContent:"center"},children:_.jsxs("div",{onClick:de=>de.stopPropagation(),style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:12,padding:24,width:440,maxWidth:"calc(100vw - 32px)",display:"flex",flexDirection:"column",gap:16,boxShadow:"0 24px 64px rgba(0,0,0,0.5)"},children:[_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[_.jsx("div",{style:{width:42,height:42,borderRadius:"50%",flexShrink:0,background:`hsl(${J},45%,18%)`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:"1rem",fontFamily:"var(--font-mono)",color:`hsl(${J},55%,65%)`},children:K.slice(0,1).toUpperCase()}),_.jsxs("div",{style:{flex:1,minWidth:0},children:[_.jsx("div",{style:{fontFamily:"var(--font-display)",fontSize:"0.9rem",fontWeight:700,color:"var(--text-bright)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K}),_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",marginTop:2},children:[B.squad_code," · Iniciado em ",ie," às ",ce]})]}),_.jsx("button",{onClick:()=>{s(null),c(!1)},style:{background:"transparent",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:"1.1rem",padding:"2px 6px",lineHeight:1,borderRadius:4},children:"×"})]}),_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,background:"var(--surface-2)",borderRadius:6,padding:"10px 14px",border:"1px solid rgba(74,222,128,0.2)"},children:[_.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"#4ade80",display:"inline-block",boxShadow:"0 0 6px #4ade80",flexShrink:0,animation:"statusPulse 2s ease-in-out infinite"}}),_.jsxs("div",{style:{flex:1},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.58rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Em execução há"}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"1.1rem",fontWeight:700,color:"#4ade80",letterSpacing:"0.04em"},children:EC(B.started_at,n)})]})]}),_.jsxs("div",{style:{background:"var(--surface-2)",borderRadius:6,padding:"12px 14px",border:"1px solid var(--border-subtle)"},children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:8},children:"Etapa atual"}),B.current_task?_.jsxs(_.Fragment,{children:[_.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:6},children:[_.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#f59e0b",display:"inline-block",flexShrink:0,marginTop:3,animation:"statusPulse 1.5s ease-in-out infinite"}}),_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.7rem",fontWeight:600,color:"var(--text-primary)",lineHeight:1.4},children:B.current_task})]}),B.current_agent&&_.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",marginTop:6,marginLeft:12},children:["Agente: ",B.current_agent,B.current_step&&_.jsxs("span",{style:{marginLeft:8,opacity:.6},children:["· ",B.current_step]})]})]}):_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",color:"var(--text-muted)"},children:"⏳ Aguardando próxima etapa..."})]}),B.steps_total>0&&_.jsxs("div",{children:[_.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:6},children:[_.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.55rem",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"Progresso"}),_.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:700,color:"var(--text-secondary)"},children:[B.steps_done," / ",B.steps_total," passos (",X,"%)"]})]}),_.jsx("div",{style:{height:6,background:"var(--surface-3)",borderRadius:3,overflow:"hidden"},children:_.jsx("div",{style:{height:"100%",width:`${X}%`,background:B.current_task?"#f59e0b":"#4ade80",borderRadius:3,transition:"width 0.4s ease"}})})]}),_.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:14,display:"flex",flexDirection:"column",gap:8},children:l?_.jsxs(_.Fragment,{children:[_.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:"0.62rem",color:"#f44747",background:"rgba(244,71,71,0.08)",border:"1px solid rgba(244,71,71,0.25)",borderRadius:6,padding:"8px 12px",lineHeight:1.5},children:"Tem certeza? O pipeline será encerrado e as tarefas em execução serão marcadas como falha."}),_.jsxs("div",{style:{display:"flex",gap:8},children:[_.jsx("button",{onClick:()=>c(!1),disabled:f,style:{flex:1,padding:"8px 14px",borderRadius:6,cursor:"pointer",background:"transparent",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.65rem",opacity:f?.5:1},children:"Cancelar"}),_.jsx("button",{onClick:()=>A(B.id),disabled:f,style:{flex:1,padding:"8px 14px",borderRadius:6,cursor:f?"not-allowed":"pointer",background:"#f44747",border:"none",color:"#fff",fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:700,opacity:f?.6:1},children:f?"Encerrando...":"Confirmar Encerramento"})]})]}):_.jsxs("div",{style:{display:"flex",gap:8},children:[_.jsx("button",{onClick:()=>{s(null),c(!1)},style:{flex:1,padding:"8px 14px",borderRadius:6,cursor:"pointer",background:"transparent",border:"1px solid var(--border-subtle)",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:"0.65rem"},children:"Fechar"}),_.jsx("button",{onClick:()=>c(!0),style:{flex:1,padding:"8px 14px",borderRadius:6,cursor:"pointer",background:"rgba(244,71,71,0.1)",border:"1px solid rgba(244,71,71,0.4)",color:"#f44747",fontFamily:"var(--font-mono)",fontSize:"0.65rem",fontWeight:600},children:"Encerrar Pipeline"})]})})]})})})()]})}const iQ=localStorage.getItem("expx-theme")||"dark";document.documentElement.setAttribute("data-theme",iQ);const rQ=j.lazy(()=>ou(()=>import("./JarvisView-CHa8xTzb.js"),[]).then(e=>({default:e.JarvisView})));Z3.createRoot(document.getElementById("root")).render(_.jsx(j.StrictMode,{children:_.jsx(S4,{children:_.jsxs(ZO,{children:[_.jsx(ca,{path:"/login",element:_.jsx(fD,{})}),_.jsxs(ca,{path:"/",element:_.jsx(uD,{}),children:[_.jsx(ca,{index:!0,element:_.jsx(WO,{to:"/office",replace:!0})}),_.jsx(ca,{path:"office",element:_.jsx(I8,{})}),_.jsx(ca,{path:"chat",element:_.jsx(dG,{})}),_.jsx(ca,{path:"kanban",element:_.jsx(mG,{})}),_.jsx(ca,{path:"settings",element:_.jsx(CG,{})}),_.jsx(ca,{path:"scheduler",element:_.jsx(kG,{})}),_.jsx(ca,{path:"email",element:_.jsx(zG,{})}),_.jsx(ca,{path:"orgchart",element:_.jsx(KW,{})}),_.jsx(ca,{path:"graph",element:_.jsx(ZW,{})}),_.jsx(ca,{path:"files",element:_.jsx(JW,{})}),_.jsx(ca,{path:"dashboard",element:_.jsx(nQ,{})}),_.jsx(ca,{path:"jarvis",element:_.jsx(j.Suspense,{fallback:null,children:_.jsx(rQ,{})})})]})]})})}));export{i6 as $,XA as A,Bm as B,qi as C,is as D,yo as E,lc as F,Na as G,v5 as H,a_ as I,iD as J,Jm as K,iw as L,Ht as M,y0 as N,i_ as O,Lr as P,qA as Q,Jv as R,E5 as S,Mn as T,M0 as U,Is as V,jA as W,d1 as X,Q5 as Y,J5 as Z,s6 as _,aQ as a,nx as a0,Ad as a1,kD as a2,Zm as a3,r_ as a4,c6 as a5,Da as a6,dA as a7,js as a8,ex as a9,HE as aa,ch as ab,GB as ac,lz as ad,FE as ae,Cb as af,GE as ag,cz as ah,lh as ai,Ti as aj,pA as ak,fB as al,KA as am,en as an,Qm as ao,xi as ap,f5 as aq,l5 as ar,D5 as as,C5 as at,Z5 as au,e6 as av,l6 as aw,a6 as ax,o6 as ay,gb as b,gl as c,vr as d,Gz as e,ka as f,Oz as g,bi as h,Bn as i,_ as j,g0 as k,kt as l,hA as m,T6 as n,ix as o,g6 as p,rx as q,j as r,XC as s,EA as t,C0 as u,li as v,ma as w,Wf as x,qD as y,_r as z};
|