perf(office-ui): stop per-token full-tree renders, sleep hidden Phaser loop, cut broadcast churn

Company-mode UIs became unusably slow once work items and transcripts
grew. Three presentation-layer fixes, none touching work progression:

- App.tsx: buffer assistant_delta/thinking_delta store writes per task
  and flush every 80ms instead of once per token; any non-delta event
  for the same task flushes first so draft/clearDraft ordering is
  byte-identical. The unconditional per-event setUiTick (whole-app
  re-render per websocket event) is now a 300ms trailing throttle.
- PhaserGame: display:none does not stop requestAnimationFrame, so the
  office scene kept burning CPU on every other page. The loop now
  sleeps when the office page is hidden and wakes (with a parent-bounds
  refresh) on return; bridge writes stay synchronous so no state is lost.
- Kanban collab_sync debounce 0.2s -> 1.5s: the broadcaster is a
  trailing coalescer, so the final board state still always ships; each
  fire is a full-project snapshot build, which at 5/s dominated backend
  CPU on large projects. CommsPanel poll 8s -> 30s (comms_state_dirty
  push already drives freshness) and its interval no longer pins a
  stale onRefresh closure.

Verified: tsc + vite build, App.test.tsx / workItemSessions structural
tests, backend suites (company_review_flow incl. debounce push test,
kanban_push_runtime, actor_runtime_company_mode, task_mode_contract,
work_item_transition — 119 green), and canvas_smoke e2e against a real
server with zero console errors.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
LZH-YS1998andClaude Fable 5 committed 2026-07-09 16:36:39 +08:00
1 parent 5aa57e69ee
commit e3bed49811
7 files changed
+327 -184

No files matched your search

+6 -1
View File
@@ -1391,7 +1391,12 @@ class CompanyWorkItemExecutor:
# and a single background coroutine coalesces + broadcasts.
self._kanban_dirty = False
self._kanban_broadcast_task = None
self._kanban_debounce_sec: float = 0.2
# Trailing debounce: the broadcaster always fires once more after the
# last dirty mark, so the final board state is never lost. Each fire
# runs a full build_collab_sync (whole-project snapshot), which is
# expensive on large projects — keep the window generous. UI-only;
# the state machine never waits on this broadcast.
self._kanban_debounce_sec: float = 1.5
self._runtime_invariant_issue_keys = set()
self.runtime = CompanyRuntime(
org_engine=org_engine,
@@ -1,155 +0,0 @@
import{g as Zo,r as A3}from"./phaser-DFK5Ua9d.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();var Wp={exports:{}},pc={};var lk;function M3(){if(lk)return pc;lk=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,o){var a=null;if(o!==void 0&&(a=""+o),i.key!==void 0&&(a=""+i.key),"key"in i){o={};for(var u in i)u!=="key"&&(o[u]=i[u])}else o=i;return i=o.ref,{$$typeof:e,type:r,key:a,ref:i!==void 0?i:null,props:o}}return pc.Fragment=t,pc.jsx=n,pc.jsxs=n,pc}var ck;function D3(){return ck||(ck=1,Wp.exports=M3()),Wp.exports}var c=D3(),Yp={exports:{}},_t={};var uk;function O3(){if(uk)return _t;uk=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function y(G){return G===null||typeof G!="object"?null:(G=g&&G[g]||G["@@iterator"],typeof G=="function"?G:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,S={};function _(G,J,P){this.props=G,this.context=J,this.refs=S,this.updater=P||v}_.prototype.isReactComponent={},_.prototype.setState=function(G,J){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,J,"setState")},_.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function w(){}w.prototype=_.prototype;function C(G,J,P){this.props=G,this.context=J,this.refs=S,this.updater=P||v}var N=C.prototype=new w;N.constructor=C,k(N,_.prototype),N.isPureReactComponent=!0;var O=Array.isArray;function I(){}var D={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function L(G,J,P){var X=P.ref;return{$$typeof:e,type:G,key:J,ref:X!==void 0?X:null,props:P}}function A(G,J){return L(G.type,J,G.props)}function M(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function $(G){var J={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(P){return J[P]})}var W=/\/+/g;function B(G,J){return typeof G=="object"&&G!==null&&G.key!=null?$(""+G.key):J.toString(36)}function U(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(I,I):(G.status="pending",G.then(function(J){G.status==="pending"&&(G.status="fulfilled",G.value=J)},function(J){G.status==="pending"&&(G.status="rejected",G.reason=J)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function H(G,J,P,X,ee){var te=typeof G;(te==="undefined"||te==="boolean")&&(G=null);var re=!1;if(G===null)re=!0;else switch(te){case"bigint":case"string":case"number":re=!0;break;case"object":switch(G.$$typeof){case e:case t:re=!0;break;case p:return re=G._init,H(re(G._payload),J,P,X,ee)}}if(re)return ee=ee(G),re=X===""?"."+B(G,0):X,O(ee)?(P="",re!=null&&(P=re.replace(W,"$&/")+"/"),H(ee,J,P,"",function(se){return se})):ee!=null&&(M(ee)&&(ee=A(ee,P+(ee.key==null||G&&G.key===ee.key?"":(""+ee.key).replace(W,"$&/")+"/")+re)),J.push(ee)),1;re=0;var oe=X===""?".":X+":";if(O(G))for(var de=0;de<G.length;de++)X=G[de],te=oe+B(X,de),re+=H(X,J,P,te,ee);else if(de=y(G),typeof de=="function")for(G=de.call(G),de=0;!(X=G.next()).done;)X=X.value,te=oe+B(X,de++),re+=H(X,J,P,te,ee);else if(te==="object"){if(typeof G.then=="function")return H(U(G),J,P,X,ee);throw J=String(G),Error("Objects are not valid as a React child (found: "+(J==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":J)+"). If you meant to render a collection of children, use an array instead.")}return re}function V(G,J,P){if(G==null)return G;var X=[],ee=0;return H(G,X,"","",function(te){return J.call(P,te,ee++)}),X}function Y(G){if(G._status===-1){var J=G._result;J=J(),J.then(function(P){(G._status===0||G._status===-1)&&(G._status=1,G._result=P)},function(P){(G._status===0||G._status===-1)&&(G._status=2,G._result=P)}),G._status===-1&&(G._status=0,G._result=J)}if(G._status===1)return G._reLine truncated
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
`+we+s+Ce}var Ge=!1;function Ye(s,l){if(!s||Ge)return"";Ge=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var x={DetermineComponentFrameRoot:function(){try{if(l){var Ie=function(){throw Error()};if(Object.defineProperty(Ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ie,[])}catch(ye){var xe=ye}Reflect.construct(s,[],Ie)}else{try{Ie.call()}catch(ye){xe=ye}s.call(Ie.prototype)}}else{try{throw Error()}catch(ye){xe=ye}(Ie=s())&&typeof Ie.catch=="function"&&Ie.catch(function(){})}}catch(ye){if(ye&&xe&&typeof ye.stack=="string")return[ye.stack,xe.stack]}return[null,null]}};x.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(x.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(x.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var E=x.DetermineComponentFrameRoot(),F=E[0],K=E[1];if(F&&K){var ie=F.split(`
`),pe=K.split(`
`);for(b=x=0;x<ie.length&&!ie[x].includes("DetermineComponentFrameRoot");)x++;for(;b<pe.length&&!pe[b].includes("DetermineComponentFrameRoot");)b++;if(x===ie.length||b===pe.length)for(x=ie.length-1,b=pe.length-1;1<=x&&0<=b&&ie[x]!==pe[b];)b--;for(;1<=x&&0<=b;x--,b--)if(ie[x]!==pe[b]){if(x!==1||b!==1)do if(x--,b--,0>b||ie[x]!==pe[b]){var _e=`
`+ie[x].replace(" at new "," at ");return s.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",s.displayName)),_e}while(1<=x&&0<=b);break}}}finally{Ge=!1,Error.prepareStackTrace=f}return(f=s?s.displayName||s.name:"")?Be(f):""}function yt(s,l){switch(s.tag){case 26:case 27:case 5:return Be(s.type);case 16:return Be("Lazy");case 13:return s.child!==l&&l!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return Ye(s.type,!1);case 11:return Ye(s.type.render,!1);case 1:return Ye(s.type,!0);case 31:return Be("Activity");default:return""}}function Vt(s){try{var l="",f=null;do l+=yt(s,f),f=s,s=s.return;while(s);return l}catch(x){return`
Error generating stack: `+x.message+`
`+x.stack}}var bt=Object.prototype.hasOwnProperty,vt=e.unstable_scheduleCallback,me=e.unstable_cancelCallback,Oe=e.unstable_shouldYield,rt=e.unstable_requestPaint,Qe=e.unstable_now,Je=e.unstable_getCurrentPriorityLevel,fe=e.unstable_ImmediatePriority,be=e.unstable_UserBlockingPriority,Me=e.unstable_NormalPriority,Fe=e.unstable_LowPriority,$e=e.unstable_IdlePriority,Ut=e.log,rn=e.unstable_setDisableYieldValue,ke=null,Te=null;function Pe(s){if(typeof Ut=="function"&&rn(s),Te&&typeof Te.setStrictMode=="function")try{Te.setStrictMode(ke,s)}catch{}}var Ve=Math.clz32?Math.clz32:Mn,qe=Math.log,et=Math.LN2;function Mn(s){return s>>>=0,s===0?32:31-(qe(s)/et|0)|0}var Tn=256,Dn=262144,yn=4194304;function Wt(s){var l=s&42;if(l!==0)return l;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Qt(s,l,f){var x=s.pendingLanes;if(x===0)return 0;var b=0,E=s.suspendedLanes,F=s.pingedLanes;s=s.warmLanes;var K=x&134217727;return K!==0?(x=K&~E,x!==0?b=Wt(x):(F&=K,F!==0?b=Wt(F):f||(f=K&~s,f!==0&&(b=Wt(f))))):(K=x&~E,K!==0?b=Wt(K):F!==0?b=Wt(F):f||(f=x&~s,f!==0&&(b=Wt(f)))),b===0?0:l!==0&&l!==b&&(l&E)===0&&(E=b&-b,f=l&-l,E>=f||E===32&&(f&4194048)!==0)?l:b}function Et(s,l){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&l)===0}function wt(s,l){switch(s){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function tt(){var s=yn;return yn<<=1,(yn&62914560)===0&&(yn=4194304),s}function it(s){for(var l=[],f=0;31>f;f++)l.push(s);return l}function sn(s,l){s.pendingLanes|=l,l!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Jt(s,l,f,x,b,E){var F=s.pendingLanes;s.pendingLanes=f,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=f,s.entangledLanes&=f,s.errorRecoveryDisabledLanes&=f,s.shellSuspendCounter=0;var K=s.entanglements,ie=s.expirationTimes,pe=s.hiddenUpdates;for(f=F&~f;0<f;){var _e=31-Ve(f),Ie=1<<_e;K[_e]=0,ie[_e]=-1;var xe=pe[_e];if(xe!==null)for(pe[_e]=null,_e=0;_e<xe.length;_e++){var ye=xe[_e];ye!==null&&(ye.lane&=-536870913)}f&=~Ie}x!==0&&ht(s,x,0),E!==0&&b===0&&s.tag!==0&&(s.suspendedLanes|=E&~(F&~l))}function ht(s,l,f){s.pendingLanes|=l,s.suspendedLanes&=~l;var x=31-Ve(l);s.entangledLanes|=l,s.entanglements[x]=s.entanglements[x]|1073741824|f&261930}function Bt(s,l){var f=s.entangledLanes|=l;for(s=s.entanglements;f;){var x=31-Ve(f),b=1<<x;b&l|s[x]&l&&(s[x]|=l),f&=~b}}function On(s,l){var f=l&-l;return f=(f&42)!==0?1:vn(f),(f&(s.suspendedLanes|l))!==0?0:f}function vn(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function Rn(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function ve(){var s=V.p;return s!==0?s:(s=window.event,s===void 0?32:tk(s.type))}function Re(s,l){var f=V.p;try{return V.p=s,l()}finally{V.p=f}}var Xe=Math.random().toString(36).slice(2),He="__reactFiber$"+Xe,Tt="__reactProps$"+Xe,mt="__reactContainer$"+Xe,$n="__reactEvents$"+Xe,Ae="__reactListeners$"+Xe,Dt="__reactHandles$"+Xe,kn="__reactResources$"+Xe,nr="__reactMarker$"+Xe;function Sn(s){delete s[He],delete s[Tt],delete s[$n],delete s[Ae],delete s[Dt]}function We(s){var l=s[He];if(l)return l;for(var f=s.parentNode;f;){if(l=f[mt]||f[He]){if(f=l.alternate,l.child!==null||f!==null&&f.child!==null)for(s=B_(s);s!==null;){if(f=s[He])return f;s=B_(s)}return l}s=f,f=s.parentNode}return null}function ar(s){if(s=s[He]||s[mt]){var l=s.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return s}return null}function lr(s){var l=s.tag;if(l===5||l===26||l===27||l===6)return s.stateNode;throw Error(r(33))}function mn(s){var l=s[kn];return l||(l=s[kn]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function zt(s){s[nr]=!0}var Qn=new Set,wn={};function pt(s,l){Tr(s,l),Tr(s+"Capture",l)}function Tr(s,l){for(wn[s]=l,s=0;s<l.length;s++)Qn.add(l[s])}var wr=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u2 Line truncated
`).replace(e3,"")}function I_(s,l){return l=N_(l),N_(s)===l}function dn(s,l,f,x,b,E){switch(f){case"children":typeof x=="string"?l==="body"||l==="textarea"&&x===""||Es(s,x):(typeof x=="number"||typeof x=="bigint")&&l!=="body"&&Es(s,""+x);break;case"className":It(s,"class",x);break;case"tabIndex":It(s,"tabindex",x);break;case"dir":case"role":case"viewBox":case"width":case"height":It(s,f,x);break;case"style":Au(s,x,E);break;case"data":if(l!=="object"){It(s,"data",x);break}case"src":case"href":if(x===""&&(l!=="a"||f!=="href")){s.removeAttribute(f);break}if(x==null||typeof x=="function"||typeof x=="symbol"||typeof x=="boolean"){s.removeAttribute(f);break}x=ea(""+x),s.setAttribute(f,x);break;case"action":case"formAction":if(typeof x=="function"){s.setAttribute(f,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof E=="function"&&(f==="formAction"?(l!=="input"&&dn(s,l,"name",b.name,b,null),dn(s,l,"formEncType",b.formEncType,b,null),dn(s,l,"formMethod",b.formMethod,b,null),dn(s,l,"formTarget",b.formTarget,b,null)):(dn(s,l,"encType",b.encType,b,null),dn(s,l,"method",b.method,b,null),dn(s,l,"target",b.target,b,null)));if(x==null||typeof x=="symbol"||typeof x=="boolean"){s.removeAttribute(f);break}x=ea(""+x),s.setAttribute(f,x);break;case"onClick":x!=null&&(s.onclick=ii);break;case"onScroll":x!=null&&At("scroll",s);break;case"onScrollEnd":x!=null&&At("scrollend",s);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(r(61));if(f=x.__html,f!=null){if(b.children!=null)throw Error(r(60));s.innerHTML=f}}break;case"multiple":s.multiple=x&&typeof x!="function"&&typeof x!="symbol";break;case"muted":s.muted=x&&typeof x!="function"&&typeof x!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(x==null||typeof x=="function"||typeof x=="boolean"||typeof x=="symbol"){s.removeAttribute("xlink:href");break}f=ea(""+x),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":x!=null&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,""+x):s.removeAttribute(f);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":x&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,""):s.removeAttribute(f);break;case"capture":case"download":x===!0?s.setAttribute(f,""):x!==!1&&x!=null&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,x):s.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":x!=null&&typeof x!="function"&&typeof x!="symbol"&&!isNaN(x)&&1<=x?s.setAttribute(f,x):s.removeAttribute(f);break;case"rowSpan":case"start":x==null||typeof x=="function"||typeof x=="symbol"||isNaN(x)?s.removeAttribute(f):s.setAttribute(f,x);break;case"popover":At("beforetoggle",s),At("toggle",s),on(s,"popover",x);break;case"xlinkActuate":pr(s,"http://www.w3.org/1999/xlink","xlink:actuate",x);break;case"xlinkArcrole":pr(s,"http://www.w3.org/1999/xlink","xlink:arcrole",x);break;case"xlinkRole":pr(s,"http://www.w3.org/1999/xlink","xlink:role",x);break;case"xlinkShow":pr(s,"http://www.w3.org/1999/xlink","xlink:show",x);break;case"xlinkTitle":pr(s,"http://www.w3.org/1999/xlink","xlink:title",x);break;case"xlinkType":pr(s,"http://www.w3.org/1999/xlink","xlink:type",x);break;case"xmlBase":pr(s,"http://www.w3.org/XML/1998/namespace","xml:base",x);break;case"xmlLang":pr(s,"http://www.w3.org/XML/1998/namespace","xml:lang",x);break;case"xmlSpace":pr(s,"http://www.w3.org/XML/1998/namespace","xml:space",x);break;case"is":on(s,"is",x);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=Mu.get(f)||f,on(s,f,x))}}function Ip(s,l,f,x,b,E){switch(f){case"style":Au(s,x,E);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(r(61));if(f=x.__html,f!=null){if(b.children!=null)throw Error(r(60));s.innerHTML=f}}break;case"children":typeof x=="string"?Es(s,x):(typeof x=="number"||typeof x=="bigint")&&Es(s,""+x);break;case"onScroll":x!=null&&At("scroll",s);break;case"onScrollEnd":x!=null&&At("scrollend",s);break;case"onClick":x!=null&&(s.onclick=ii);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"inne Line truncated
`),oe=h.map(([de,se])=>` [${de}, ${se}],`).join(`
`);return`const MAP_STR: string[] = [
${re}
]
const SEATS: [number, number][] = [
${oe}
]`})(),J=()=>I(te=>Math.min(te+.25,3)),P=()=>I(te=>Math.max(te-.25,.5)),X=m.flat().filter(te=>te===1).length,ee=m.flat().filter(te=>te===0).length;return c.jsxs("div",{className:"collision-editor",children:[c.jsxs("div",{className:"ce-toolbar",children:[c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("span",{className:"ce-title",children:"Map Editor"}),c.jsx("select",{className:"ce-office-select",value:a,onChange:te=>M(te.target.value),children:i.map(te=>c.jsx("option",{value:te.id,children:te.name},te.id))})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsxs("button",{className:`ce-mode-btn ${y==="wall"?"active wall":""}`,onClick:()=>v("wall"),children:[c.jsx("span",{className:"ce-mode-dot wall"})," Wall"]}),c.jsxs("button",{className:`ce-mode-btn ${y==="floor"?"active floor":""}`,onClick:()=>v("floor"),children:[c.jsx("span",{className:"ce-mode-dot floor"})," Floor"]}),c.jsxs("button",{className:`ce-mode-btn ${y==="seat"?"active seat":""}`,onClick:()=>v("seat"),children:[c.jsx("span",{className:"ce-mode-dot seat"})," Seat"]})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("button",{className:"ce-btn",onClick:P,children:"-"}),c.jsxs("span",{className:"ce-zoom-label",children:[Math.round(O*100),"%"]}),c.jsx("button",{className:"ce-btn",onClick:J,children:"+"}),c.jsx("button",{className:`ce-btn${D?" active":""}`,onClick:()=>T(te=>!te),children:"Grid"})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("button",{className:`ce-btn apply${C?" success":""}`,onClick:Y,children:C?"Applied":"Apply"}),c.jsx("button",{className:`ce-btn${_?" active":""}`,onClick:Z,children:"Export"}),c.jsx("button",{className:"ce-btn danger",onClick:q,children:"Reset"})]}),c.jsxs("div",{className:"ce-toolbar-group ce-stats",children:[c.jsxs("span",{children:["Walls: ",X]}),c.jsxs("span",{children:["Floor: ",ee]}),c.jsxs("span",{children:["Seats: ",h.length]})]})]}),c.jsxs("div",{className:"ce-body",children:[c.jsx("div",{className:"ce-canvas-wrap",style:{overflow:"auto"},children:c.jsx("canvas",{ref:t,style:{width:L*R*O,height:A*R*O,imageRendering:"pixelated",cursor:y==="seat"?"crosshair":"cell"},onMouseDown:U,onMouseMove:H,onMouseUp:V,onMouseLeave:V})}),_&&c.jsxs("div",{className:"ce-export-panel",children:[c.jsxs("div",{className:"ce-export-header",children:[c.jsx("span",{children:"Export — copy to source code"}),c.jsx("button",{className:"ce-btn",onClick:()=>navigator.clipboard.writeText(G),children:"Copy"})]}),c.jsx("textarea",{className:"ce-export-textarea",value:G,readOnly:!0,rows:20})]})]})]})}let qM=0;function tr(e,t,n={}){return{event_id:`test-${++qM}`,type:e,agent_id:t,data:n,timestamp:Date.now()/1e3}}function En(e){return new Promise(t=>setTimeout(t,e))}async function WM(e){const t=[],n=e.getScene();if(!n)return t.push({name:"scene-ready",pass:!1,detail:"OfficeScene not initialized"}),t;console.log("%c[EventTest] Starting full event test suite (multi-office)...","color: #6366f1; font-weight: bold");for(const M of[...n.agents.keys()])n.removeAgent(M);await En(100);const r=Bn();t.push({name:"offices-loaded",pass:r.length>=3,detail:`${r.length} offices loaded: ${r.map(M=>M.name).join(", ")}`});const i=["agent-A","agent-B","agent-C","agent-D","agent-E","agent-F"];for(const M of i)e.pushEvent(tr("agent_active",M));await En(300);const o=new Set;let a=!1;for(const M of i){const $=n.getAgent(M);$&&$.seatId&&(o.has($.seatId)&&(a=!0),o.add($.seatId))}t.push({name:"desk-assignment-unique",pass:!a&&o.size===i.length,detail:`Assigned ${o.size} unique seats to ${i.length} agents. IDs: [${[...o].join(", ")}]`});const u=i.every(M=>n.getAgent(M)?.officeId!=null);t.push({name:"agents-have-officeId",pass:u,detail:i.map(M=>`${M}=${n.getAgent(M)?.officeId}`).join(", ")}),e.pushEvent(tr("tool_start","agent-A",{tool_name:"shell"})),await En(200);const d=n.getAgent("agent-A");t.push({name:"tool_start-state",pass:d.isActive===!0&&d.currentTool==="shell",detail:`isActive=${d.isActive}, currentTool=${d.currentTool}`}),e.pushEvent(tr("tool_done","agent-A",{tool_name:"shell"})),await En(100),t.push({name:"tool_done-celebrate",pass:d.agentState==="celebrate",detail:`state=${d.agentState}`});for(let M=0;M<20&&d.agentState==="celebrate";M++)await En(500);t.push({name:"celebrate-to-idle",pass:d.agentState!=="celebrate",detail:`state=${d.agentState}`}),e.pushEvent(tr("waiting","agent-B")),await En(200);const m=n.getAgent("agent-B");t.push({name:"waiting-state",pass:m.isActive===!1&&(m.agentState==="walk"||m.agentState==="idle"||m.agentState==="coffee"),detail:`isActive=${m.isActive}, state=${m.agentState}`}),e.pushEvent(tr("reflect_start","agent-C")),await En(200);const p=n.getAgent("agent-C");t.push({name:"reflect_start-state",pass:p.currentTool==="Reflect"&&(p.agentState==="walk"||p.agentState==="reflect"),detail:`currentTool=${p.currentTool}, state=${p.agentState}`}),e.pushEvent(tr("reflect_done","agent-C")),await En(100),t.push({name:"reflect_done-celebrate",pass:p.agentState==="celebrate",detail:`staLine truncated
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*S,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(i),o=!1,i}return a.updateDeps=u=>{r=u},a}function Pk(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const i4=(e,t)=>Math.abs(e-t)<1.01,s4=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Bk=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},o4=e=>e,a4=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let i=t;i<=n;i++)r.push(i);return r},l4=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=a=>{const{width:u,height:d}=a;t({width:Math.round(u),height:Math.round(d)})};if(i(Bk(n)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(a=>{const u=()=>{const d=a[0];if(d?.borderBoxSize){const m=d.borderBoxSize[0];if(m){i({width:m.inlineSize,height:m.blockSize});return}}i(Bk(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},$k={passive:!0},Hk=typeof window>"u"?!0:"onscrollend"in window,c4=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let i=0;const o=e.options.useScrollendEvent&&Hk?()=>{}:s4(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),a=p=>()=>{const{horizontal:h,isRtl:g}=e.options;i=h?n.scrollLeft*(g&&-1||1):n.scrollTop,o(),t(i,p)},u=a(!0),d=a(!1);n.addEventListener("scroll",u,$k);const m=e.options.useScrollendEvent&&Hk;return m&&n.addEventListener("scrollend",d,$k),()=>{n.removeEventListener("scroll",u),m&&n.removeEventListener("scrollend",d)}},u4=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},d4=(e,{adjustments:t=0,behavior:n},r)=>{var i,o;const a=e+t;(o=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||o.call(i,{[r.options.horizontal?"left":"top"]:a,behavior:n})};class f4{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,i;return((i=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(o=>{const a=()=>{const u=o.target,d=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var o;return(o=r())==null?void 0:o.observe(i,{box:"border-box"})},unobserve:i=>{var o;return(o=r())==null?void 0:o.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,i])=>{typeof i>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:o4,rangeExtractor:a4,onChange:()=>{},measureElement:u4,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=La(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)} Line truncated
The error may be correlated with this previous error:
${te.current.stack}
`),we}Mf(()=>{te.current=void 0,P.current=void 0,G.current=de});const se=j.useMemo(()=>j.createElement(S,{...de,ref:L}),[L,S,de]);return j.useMemo(()=>v?j.createElement(M.Provider,{value:q},se):se,[M,se,q])}const I=j.memo(N);if(I.WrappedComponent=S,I.displayName=N.displayName=w,d){const T=j.forwardRef(function(A,M){return j.createElement(I,{...A,reactReduxForwardedRef:M})});return T.displayName=w,T.WrappedComponent=S,ky(T,S)}return ky(I,S)}}var Jj=K5;function Z5(e){const{children:t,context:n,serverState:r,store:i}=e,o=j.useMemo(()=>{const d=Kj(i);return{store:i,subscription:d,getServerState:r?()=>r:void 0}},[i,r]),a=j.useMemo(()=>i.getState(),[i]);Mf(()=>{const{subscription:d}=o;return d.onStateChange=d.notifyNestedSubs,d.trySubscribe(),a!==i.getState()&&d.notifyNestedSubs(),()=>{d.tryUnsubscribe(),d.onStateChange=void 0}},[o,a]);const u=n||Qj;return j.createElement(u.Provider,{value:o},t)}var Q5=Z5,J5="Invariant failed";function eD(e,t){throw new Error(J5)}var Ei=function(t){var n=t.top,r=t.right,i=t.bottom,o=t.left,a=r-o,u=i-n,d={top:n,right:r,bottom:i,left:o,width:a,height:u,x:o,y:n,center:{x:(r+o)/2,y:(i+n)/2}};return d},S0=function(t,n){return{top:t.top-n.top,left:t.left-n.left,bottom:t.bottom+n.bottom,right:t.right+n.right}},fS=function(t,n){return{top:t.top+n.top,left:t.left+n.left,bottom:t.bottom-n.bottom,right:t.right-n.right}},tD=function(t,n){return{top:t.top+n.y,left:t.left+n.x,bottom:t.bottom+n.y,right:t.right+n.x}},ug={top:0,right:0,bottom:0,left:0},w0=function(t){var n=t.borderBox,r=t.margin,i=r===void 0?ug:r,o=t.border,a=o===void 0?ug:o,u=t.padding,d=u===void 0?ug:u,m=Ei(S0(n,i)),p=Ei(fS(n,a)),h=Ei(fS(p,d));return{marginBox:m,borderBox:Ei(n),paddingBox:p,contentBox:h,margin:i,border:a,padding:d}},pi=function(t){var n=t.slice(0,-2),r=t.slice(-2);if(r!=="px")return 0;var i=Number(n);return isNaN(i)&&eD(),i},nD=function(){return{x:window.pageXOffset,y:window.pageYOffset}},Df=function(t,n){var r=t.borderBox,i=t.border,o=t.margin,a=t.padding,u=tD(r,n);return w0({borderBox:u,border:i,margin:o,padding:a})},Of=function(t,n){return n===void 0&&(n=nD()),Df(t,n)},eE=function(t,n){var r={top:pi(n.marginTop),right:pi(n.marginRight),bottom:pi(n.marginBottom),left:pi(n.marginLeft)},i={top:pi(n.paddingTop),right:pi(n.paddingRight),bottom:pi(n.paddingBottom),left:pi(n.paddingLeft)},o={top:pi(n.borderTopWidth),right:pi(n.borderRightWidth),bottom:pi(n.borderBottomWidth),left:pi(n.borderLeftWidth)};return w0({borderBox:t,margin:r,padding:i,border:o})},tE=function(t){var n=t.getBoundingClientRect(),r=window.getComputedStyle(t);return eE(n,r)},Jc=function(t){var n=[],r=null,i=function(){for(var a=arguments.length,u=new Array(a),d=0;d<a;d++)u[d]=arguments[d];n=u,!r&&(r=requestAnimationFrame(function(){r=null,t.apply(void 0,n)}))};return i.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},i};function Lf(){return Lf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lf.apply(null,arguments)}function nE(e,t){}nE.bind(null,"warn");nE.bind(null,"error");function ao(){}function rD(e,t){return{...e,...t}}function vi(e,t,n){const r=t.map(i=>{const o=rD(n,i.options);return e.addEventListener(i.eventName,i.fn,o),function(){e.removeEventListener(i.eventName,i.fn,o)}});return function(){r.forEach(o=>{o()})}}const iD="Invariant failed";class zf extends Error{}zf.prototype.toString=function(){return this.message};function Le(e,t){throw new zf(iD)}let sD=class extends St.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=ao,this.onWindowError=n=>{const r=this.getCallbacks();r.isDragging()&&r.tryAbort(),n.error instanceof zf&&n.preventDefault()},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");return this.callbacks},this.setCallbacks=n=>{this.callbacks=n}}componentDidMount(){this.unbind=vi(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof zf){this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}};const oD=`
Press space bar to start a drag.
When dragging you can use the arrow keys to move the item around and escape to cancel.
Some screen readers may require you to be in focus mode or to use your pass through key
`,Pf=e=>e+1,aD=e=>`
You have lifted an item in position ${Pf(e.source.index)}
`,rE=(e,t)=>{const n=e.droppableId===t.droppableId,r=Pf(e.index),i=Pf(t.index);return n?`
You have moved the item from position ${r}
to position ${i}
`:`
You have moved the item from position ${r}
in list ${e.droppableId}
to list ${t.droppableId}
in position ${i}
`},iE=(e,t,n)=>t.droppableId===n.droppableId?`
The item ${e}
has been combined with ${n.draggableId}`:`
The item ${e}
in list ${t.droppableId}
has been combined with ${n.draggableId}
in list ${n.droppableId}
`,lD=e=>{const t=e.destination;if(t)return rE(e.source,t);const n=e.combine;return n?iE(e.draggableId,e.source,n):"You are over an area that cannot be dropped on"},mS=e=>`
The item has returned to its starting position
of ${Pf(e.index)}
`,cD=e=>{if(e.reason==="CANCEL")return`
Movement cancelled.
${mS(e.source)}
`;const t=e.destination,n=e.combine;return t?`
You have dropped the item.
${rE(e.source,t)}
`:n?`
You have dropped the item.
${iE(e.draggableId,e.source,n)}
`:`
The item has been dropped while not over a drop area.
${mS(e.source)}
`},xf={dragHandleUsageInstructions:oD,onDragStart:aD,onDragUpdate:lD,onDragEnd:cD};function uD(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function sE(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!uD(e[n],t[n]))return!1;return!0}function $t(e,t){const n=j.useState(()=>({inputs:t,result:e()}))[0],r=j.useRef(!0),i=j.useRef(n),a=r.current||!!(t&&i.current.inputs&&sE(t,i.current.inputs))?i.current:{inputs:t,result:e()};return j.useEffect(()=>{r.current=!1,i.current=a},[a]),a.result}function st(e,t){return $t(()=>e,t)}const or={x:0,y:0},mr=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),Qr=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),lo=(e,t)=>e.x===t.x&&e.y===t.y,kl=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),Fo=(e,t,n=0)=>e==="x"?{x:t,y:n}:{x:n,y:t},eu=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),hS=(e,t)=>Math.min(...t.map(n=>eu(e,n))),oE=e=>t=>({x:e(t.x),y:e(t.y)});var dD=(e,t)=>{const n=Ei({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return n.width<=0||n.height<=0?null:n};const vu=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),pS=e=>[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.left,y:e.bottom},{x:e.right,y:e.bottom}],fD={top:0,right:0,bottom:0,left:0},mD=(e,t)=>t?vu(e,t.scroll.diff.displacement):e,hD=(e,t,n)=>n&&n.increasedBy?{...e,[t.end]:e[t.end]+n.increasedBy[t.line]}:e,pD=(e,t)=>t&&t.shouldClipSubject?dD(t.pageMarginBox,e):Ei(e);var ol=({page:e,withPlaceholder:t,axis:n,frame:r})=>{const i=mD(e.marginBox,r),o=hD(i,n,t),a=pD(o,r);return{page:e,withPlaceholder:t,active:a}},C0=(e,t)=>{e.frame||Le();const n=e.frame,r=Qr(t,n.scroll.initial),i=kl(r),o={...n,scroll:{initial:n.scroll.initial,current:t,diff:{value:r,displacement:i},max:n.scroll.max}},a=ol({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:o});return{...e,frame:o,subject:a}};function sr(e,t=sE){let n=null;function r(...i){if(n&&n.lastThis===this&&t(i,n.lastArgs))return n.lastResult;const o=e.apply(this,i);return n={lastResult:o,lastArgs:i,lastThis:this},o}return r.clear=function(){n=null},r}const aE=sr(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),lE=sr(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),vm=sr(e=>Object.values(e)),gD=sr(e=>Object.values(e));var Sl=sr((e,t)=>gD(t).filter(r=>e===r.descriptor.droppableId).sort((r,i)=>r.descriptor.index-i.descriptor.index));function j0(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function bm(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var _m=sr((e,t)=>t.filter(n=>n.descriptor.id!==e.descriptor.id)),xD=({isMovingForward:e,draggable:t,destination:n,insideDestination:r,previousImpact:i})=>{if(!n.isCombineEnabled||!j0(i))return null;function a(y){const v={type:"COMBINE",combine:{draggableId:y,droppableId:n.descriptor.id}};return{...i,at:v}}const u=i.displaced.all,d=u.length?u[0]:null;if(e)return d?a(d):null;const m=_m(t,r);if(!d){if(!m.length)return null;const y=m[m.length-1];return a(y.descriptor.id)}const p=m.findIndex(y=>y.descriptor.id===d);p===-1&&Le();const h=p-1;if(h<0)return null;const g=m[h];return a(g.descriptor.id)},wl=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const cE={point:or,value:0},tu={invisible:{},visible:{},all:[]},yD={displaced:tu,displacedBy:cE,at:null};var bi=(e,t)=>n=>e<=n&&n<=t,uE=e=>{const t=bi(e.top,e.bottom),n=bi(e.left,e.right);return r=>{if(t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right))return!0;const o=t(r.top)||t(r.bottom),a=n(r.left)||n(r.right);if(o&&a)return!0;const d=r.top<e.top&&r.bottom>e.bottom,m=r.left<e.left&&r.right>e.right;return d&&m?!0:d&&a||m&&o}},vD=e=>{const t=bi(e.top,e.bottom),n=bi(e.left,e.right);return r=>t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right)};const E0={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},dE={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var bD=e=>t=>{const n=bi(t.top,t.bottom),r=bi(t.left,t.right);return i=>e===E0?n(i.top)&&n(i.bottom):r(i.left)&&r(i.right)};const _D=(e,t)=>{const n=t.frame?t.frame.scroll.diff.displacement:or;return vu(e,n)},kD=(e,t,n)=>t.subject.active?n(t.subject.active)(e):!1,SD=(e,t,n)=>n(t)(e),N0=({target:e,destination:t,viewport:n,withDroppableDisplacement:r,isVisibleThroughFrameFn:i})=>{const o=r?_D(e,t):e;return kD(o,t,i)&&SD(o,n,i)},wD=e=>N0({...e,isVisibleThroughFrameFn:uE}),fE=e=>N0({...e,isVisibleThroughFrameFn:vD}),CD=e=>N0({...e,isVisibleThroughFrameFn:bD(e.destination.axis)}),jD=(e,t,n)=>{if(typeof n=="boolean")return n;if(!t)return!0;const{invisible:r,visible:i}=t;if(r[e])return!1;const o=i[e];return o?o.shouldAnimate:!0};function ED(e,t){const n=e.page.marginBox,r={top:t.point.y,right:0,bottom:0,left:t.point.x};return Ei(S0(n,r))}function nu({afterDragging:e,destination:t,displacedBy:n,viewport:r,forceShouldAnimate:i,la Line truncated
cursor: -webkit-grab;
cursor: grab;
`;return{selector:t(ll.contextId),styles:{always:`
-webkit-touch-callout: none;
-webkit-tap-highlight-color: rgba(0,0,0,0);
touch-action: manipulation;
`,resting:u,dragging:NL,dropAnimating:u}}})(),r=(()=>{const u=`
transition: ${Fc.outOfTheWay};
`;return{selector:t(Ey.contextId),styles:{dragging:u,dropAnimating:u,userCancel:u}}})(),i={selector:t(jL.contextId),styles:{always:"overflow-anchor: none;"}},a=[r,n,i,{selector:"body",styles:{dragging:`
cursor: grabbing;
cursor: -webkit-grabbing;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
overflow-anchor: none;
`}}];return{always:bc(a,"always"),resting:bc(a,"resting"),dragging:bc(a,"dragging"),dropAnimating:bc(a,"dropAnimating"),userCancel:bc(a,"userCancel")}};const ei=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?j.useLayoutEffect:j.useEffect,pg=()=>{const e=document.querySelector("head");return e||Le(),e},IS=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function TL(e,t){const n=$t(()=>IL(e),[e]),r=j.useRef(null),i=j.useRef(null),o=st(sr(h=>{const g=i.current;g||Le(),g.textContent=h}),[]),a=st(h=>{const g=r.current;g||Le(),g.textContent=h},[]);ei(()=>{!r.current&&!i.current||Le();const h=IS(t),g=IS(t);return r.current=h,i.current=g,h.setAttribute(`${al}-always`,e),g.setAttribute(`${al}-dynamic`,e),pg().appendChild(h),pg().appendChild(g),a(n.always),o(n.resting),()=>{const y=v=>{const k=v.current;k||Le(),pg().removeChild(k),v.current=null};y(r),y(i)}},[t,a,o,n.always,n.resting,e]);const u=st(()=>o(n.dragging),[o,n.dragging]),d=st(h=>{if(h==="DROP"){o(n.dropAnimating);return}o(n.userCancel)},[o,n.dropAnimating,n.userCancel]),m=st(()=>{i.current&&o(n.resting)},[o,n.resting]);return $t(()=>({dragging:u,dropping:d,resting:m}),[u,d,m])}function BE(e,t){return Array.from(e.querySelectorAll(t))}var $E=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function Sm(e){return e instanceof $E(e).HTMLElement}function RL(e,t){const n=`[${ll.contextId}="${e}"]`,r=BE(document,n);if(!r.length)return null;const i=r.find(o=>o.getAttribute(ll.draggableId)===t);return!i||!Sm(i)?null:i}function AL(e){const t=j.useRef({}),n=j.useRef(null),r=j.useRef(null),i=j.useRef(!1),o=st(function(g,y){const v={id:g,focus:y};return t.current[g]=v,function(){const S=t.current;S[g]!==v&&delete S[g]}},[]),a=st(function(g){const y=RL(e,g);y&&y!==document.activeElement&&y.focus()},[e]),u=st(function(g,y){n.current===g&&(n.current=y)},[]),d=st(function(){r.current||i.current&&(r.current=requestAnimationFrame(()=>{r.current=null;const g=n.current;g&&a(g)}))},[a]),m=st(function(g){n.current=null;const y=document.activeElement;y&&y.getAttribute(ll.draggableId)===g&&(n.current=g)},[]);return ei(()=>(i.current=!0,function(){i.current=!1;const g=r.current;g&&cancelAnimationFrame(g)}),[]),$t(()=>({register:o,tryRecordFocus:m,tryRestoreFocusRecorded:d,tryShiftRecord:u}),[o,m,d,u])}function ML(){const e={draggables:{},droppables:{}},t=[];function n(h){return t.push(h),function(){const y=t.indexOf(h);y!==-1&&t.splice(y,1)}}function r(h){t.length&&t.forEach(g=>g(h))}function i(h){return e.draggables[h]||null}function o(h){const g=i(h);return g||Le(),g}const a={register:h=>{e.draggables[h.descriptor.id]=h,r({type:"ADDITION",value:h})},update:(h,g)=>{const y=e.draggables[g.descriptor.id];y&&y.uniqueId===h.uniqueId&&(delete e.draggables[g.descriptor.id],e.draggables[h.descriptor.id]=h)},unregister:h=>{const g=h.descriptor.id,y=i(g);y&&h.uniqueId===y.uniqueId&&(delete e.draggables[g],e.droppables[h.descriptor.droppableId]&&r({type:"REMOVAL",value:h}))},getById:o,findById:i,exists:h=>!!i(h),getAllByType:h=>Object.values(e.draggables).filter(g=>g.descriptor.type===h)};function u(h){return e.droppables[h]||null}function d(h){const g=u(h);return g||Le(),g}const m={register:h=>{e.droppables[h.descriptor.id]=h},unregister:h=>{const g=u(h.descriptor.id);g&&h.uniqueId===g.uniqueId&&delete e.droppables[h.descriptor.id]},getById:d,findById:u,exists:h=>!!u(h),getAllByType:h=>Object.values(e.droppables).filter(g=>g.descriptor.type===h)};function p(){e.draggables={},e.droppables={},t.length=0}return{draggable:a,droppable:m,subscribe:n,clean:p}}function DL(){const e=$t(ML,[]);return j.useEffect(()=>function(){e.clean()},[e]),e}var B0=St.createContext(null),$f=()=>{const e=document.body;return e||Le(),e};const OL={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},LL=e=>`rfd-announcement-${e}`;function zL(e){const t=$t(()=>LL(e),[e]),n=j.useRef(null);return j.useEffect(function(){const o=document.createElement("div");return n.current=o,o.id=t,o.setAttribute("aria-live","assertive"),o.setAttribute("aria-atomic","true"),Lf(o.style,OL),$f().appendChild(o),function(){setTimeout(function(){const d=$f();d.contains(o)&&d.removeChild(o),o===n.current&&(n.current=null)})}},[t]),st(i=>{const o=n.current;if(o){o.textContent=i;return}},[])}const PL={separator:"::"};function $0(e,t=PL){const n=St.useId();return $t(()=>`${e}${t.separator}${n}`,[t.separator,e,n])}function BL({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function $L({contextId:e,text:t}){const n=$0("hidden-text",{separator:"-"}),r=$t(()=>BL({contextId:e,uniqueId:n}),[n,e]);return j.useEffect(function(){const o=document.createElement("div");return o.id=r,o.textContent=t,o.style.display="none",$f().appendChild(o),function(){const u=$f();u.contains(o)&&u.removeChild(o)}},[r,t]),r}var wm=St.c Line truncated
`,m="/",p="*",h="",g="comment",y="declaration";function v(S,_){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];_=_||{};var w=1,C=1;function N(B){var U=B.match(t);U&&(w+=U.length);var H=B.lastIndexOf(d);C=~H?B.length-H:C+B.length}function O(){var B={line:w,column:C};return function(U){return U.position=new I(B),L(),U}}function I(B){this.start=B,this.end={line:w,column:C},this.source=_.source}I.prototype.content=S;function D(B){var U=new Error(_.source+":"+w+":"+C+": "+B);if(U.reason=B,U.filename=_.source,U.line=w,U.column=C,U.source=S,!_.silent)throw U}function T(B){var U=B.exec(S);if(U){var H=U[0];return N(H),S=S.slice(H.length),U}}function L(){T(n)}function A(B){var U;for(B=B||[];U=M();)U!==!1&&B.push(U);return B}function M(){var B=O();if(!(m!=S.charAt(0)||p!=S.charAt(1))){for(var U=2;h!=S.charAt(U)&&(p!=S.charAt(U)||m!=S.charAt(U+1));)++U;if(U+=2,h===S.charAt(U-1))return D("End of comment missing");var H=S.slice(2,U-2);return C+=2,N(H),S=S.slice(U),C+=2,B({type:g,comment:H})}}function $(){var B=O(),U=T(r);if(U){if(M(),!T(i))return D("property missing ':'");var H=T(o),V=B({type:y,property:k(U[0].replace(e,h)),value:H?k(H[0].replace(e,h)):h});return T(a),V}}function W(){var B=[];A(B);for(var U;U=$();)U!==!1&&(B.push(U),A(B));return B}return L(),W()}function k(S){return S?S.replace(u,h):h}return wg=v,wg}var WS;function oz(){if(WS)return Ba;WS=1;var e=Ba&&Ba.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ba,"__esModule",{value:!0}),Ba.default=n;const t=e(sz());function n(r,i){let o=null;if(!r||typeof r!="string")return o;const a=(0,t.default)(r),u=typeof i=="function";return a.forEach(d=>{if(d.type!=="declaration")return;const{property:m,value:p}=d;u?i(m,p,d):p&&(o=o||{},o[m]=p)}),o}return Ba}var wc={},YS;function az(){if(YS)return wc;YS=1,Object.defineProperty(wc,"__esModule",{value:!0}),wc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(m){return!m||n.test(m)||e.test(m)},a=function(m,p){return p.toUpperCase()},u=function(m,p){return"".concat(p,"-")},d=function(m,p){return p===void 0&&(p={}),o(m)?m:(m=m.toLowerCase(),p.reactCompat?m=m.replace(i,u):m=m.replace(r,u),m.replace(t,a))};return wc.camelCase=d,wc}var Cc,XS;function lz(){if(XS)return Cc;XS=1;var e=Cc&&Cc.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(oz()),n=az();function r(i,o){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(u,d){u&&d&&(a[(0,n.camelCase)(u,o)]=d)}),a}return r.default=r,Cc=r,Cc}var cz=lz();const uz=Zo(cz),fN=mN("end"),q0=mN("start");function mN(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function dz(e){const t=q0(e),n=fN(e);if(t&&n)return{start:t,end:n}}function Vc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?KS(e.position):"start"in e||"end"in e?KS(e):"line"in e||"column"in e?Ay(e):""}function Ay(e){return ZS(e&&e.line)+":"+ZS(e&&e.column)}function KS(e){return Ay(e&&e.start)+"-"+Ay(e&&e.end)}function ZS(e){return e&&typeof e=="number"?e:1}class Sr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?o.ruleId=r:(o.source=r.slice(0,d),o.ruleId=r.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=u?u.line:void 0,this.name=Vc(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Sr.prototype.file="";Sr.prototype.name="";Sr.prototype.reason="";Sr.prototype.message="";Sr.prototype.stack="";Sr.prototype.column=void 0;Sr.prototype.line=void 0;Sr.prototype.ancestors=void 0;Sr.prototype.cause=void 0;Sr.prototype.fatal=void 0;Sr.prototype.place=void 0;Sr.prototype.ruleId=void 0;Sr.prototype.source=void 0;const W0={}.hasOwnProperty,fz=new Map,mz=/[A-Z]/g,hz=new Set(["table","tbody","thead","tfoot","tr"]),pz=new Set(["td","th"]),hN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function gz(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.j Line truncated
`;break}case-3:{a=`\r
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}function wB(e){const r={constructs:vN([bB,...(e||{}).extensions||[]]),content:i(Bz),defined:[],document:i(Hz),flow:i(sB),lazy:{},string:i(lB),text:i(cB)};return r;function i(o){return a;function a(u){return _B(r,o,u)}}}function CB(e){for(;!wN(e););return e}const aw=/[\0\t\n\r]/g;function jB(){let e=1,t="",n=!0,r;return i;function i(o,a,u){const d=[];let m,p,h,g,y;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),h=0,t="",n&&(o.charCodeAt(0)===65279&&h++,n=void 0);h<o.length;){if(aw.lastIndex=h,m=aw.exec(o),g=m&&m.index!==void 0?m.index:o.length,y=o.charCodeAt(g),!m){t=o.slice(h);break}if(y===10&&h===g&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),h<g&&(d.push(o.slice(h,g)),e+=g-h),y){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}h=g+1}return u&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const EB=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function NB(e){return e.replace(EB,IB)}function IB(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return bN(n.slice(o?2:1),o?16:10)}return Z0(n)||e}const TN={}.hasOwnProperty;function TB(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),RB(n)(CB(wB(n).document().write(jB()(e,t,!0))))}function RB(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(bt),autolinkProtocol:L,autolinkEmail:L,atxHeading:o(Ge),blockQuote:o(se),characterEscape:L,characterReference:L,codeFenced:o(je),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(je,a),codeText:o(we,a),codeTextData:L,data:L,codeFlowValue:L,definition:o(Ce),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Be),hardBreakEscape:o(Ye),hardBreakTrailing:o(Ye),htmlFlow:o(yt,a),htmlFlowData:L,htmlText:o(yt,a),htmlTextData:L,image:o(Vt),label:a,link:o(bt),listItem:o(me),listItemValue:g,listOrdered:o(vt,h),listUnordered:o(vt),paragraph:o(Oe),reference:P,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ge),strong:o(rt),thematicBreak:o(Je)},exit:{atxHeading:d(),atxHeadingSequence:O,autolink:d(),autolinkEmail:de,autolinkProtocol:oe,blockQuote:d(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:te,characterReference:re,codeFenced:d(S),codeFencedFence:k,codeFencedFenceInfo:y,codeFencedFenceMeta:v,codeFlowValue:A,codeIndented:d(_),codeText:d(U),codeTextData:A,data:A,definition:d(),definitionDestinationString:N,definitionLabelString:w,definitionTitleString:C,emphasis:d(),hardBreakEscape:d($),hardBreakTrailing:d($),htmlFlow:d(W),htmlFlowData:A,htmlText:d(B),htmlTextData:A,image:d(V),label:Z,labelText:Y,lineEnding:M,link:d(H),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:X,resourceDestinationString:q,resourceTitleString:G,resource:J,setextHeading:d(T),setextHeadingLineSequence:D,setextHeadingText:I,strong:d(),thematicBreak:d()}};RN(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(fe){let be={type:"root",children:[]};const Me={stack:[be],tokenStack:[],config:t,enter:u,exit:m,buffer:a,resume:p,data:n},Fe=[];let $e=-1;for(;++$e<fe.length;)if(fe[$e][1].type==="listOrdered"||fe[$e][1].type==="listUnordered")if(fe[$e][0]==="enter")Fe.push($e);else{const Ut=Fe.pop();$e=i(fe,Ut,$e)}for($e=-1;++$e<fe.length;){const Ut=t[fe[$e][0]];TN.call(Ut,fe[$e][1].type)&&Ut[fe[$e][1].type].call(Object.assign({sliceSerialize:fe[$e][2].sliceSerialize},Me),fe[$e][1])}if(Me.tokenStack.length>0){const Ut=Me.tokenStack[Me.tokenStack.length-1];(Ut[1]||lw).call(Me,void 0,Ut[0])}for(be.position={start:to(fe.length>0?fe[0][1].start:{line:1,column:1,offset:0}),end:to(fe.length>0?fe[fe.length-2][1].end:{line:1,column:1,offset:0})},$e=-1;++$e<t.transforms.length;)be=t.transforms[$e](be)||be;return be}function i(fe,be,Me){let Fe=be-1,$e=-1,Ut=!1,rn,ke,Te,Pe;for(;++Fe<=Me;){const Ve=fe[Fe];switch(Ve[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ve[0]==="enter"?$e++:$e--,Pe=void 0;break}case"lineEndingBlank":{Ve[0]==="enter"&&(rn&&!Pe&&!$e&&!Te&&(Te=Fe),Pe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Pe=void 0}if(!$e&&Ve[0]==="enter"&&Ve[1].type==="listItemPrefix"||$e===-1&&Ve[0]==="exit"&&(Ve[1].type==="listUnordered"||Ve[1].type==="listOrdered")){if(rn){let qe=Fe;for(ke=void 0;qe--;){const et=fe[qe];if(et[1].type==="lineEnding"||et[1].type==="lineEndingBlank"){if(et[0]==="exit")continue;ke&&(fe[ke][1].type="lineEndingBlank",Ut=!0),et[1].type="lineEnding",ke=qe}else if(!(et[1].type==="linePrefix"||et[1].type==="blockQuotePrefix"||et[1].type==="blockQuotePrefixWhitespace"Line truncated
`}]}function LB(e,t){const n=t.value?t.value+`
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function zB(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PB(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function BB(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=jl(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,u=e.footnoteCounts.get(r);u===void 0?(u=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,u+=1,e.footnoteCounts.set(r,u);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,d);const m={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,m),e.applyData(t,m)}function $B(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function HB(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function AN(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function FB(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AN(e,t);const i={src:jl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function VB(e,t){const n={src:jl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function UB(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function GB(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AN(e,t);const i={href:jl(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function qB(e,t){const n={href:jl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function WB(e,t,n){const r=e.all(t),i=n?YB(n):MN(t),o={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let h;p&&p.type==="element"&&p.tagName==="p"?h=p:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u<r.length;){const p=r[u];(i||u!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:`
`}),p.type==="element"&&p.tagName==="p"&&!i?a.push(...p.children):a.push(p)}const d=r[r.length-1];d&&(i||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
`});const m={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,m),e.applyData(t,m)}function YB(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=MN(n[r])}return t}function MN(e){const t=e.spread;return t??e.children.length>1}function XB(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function KB(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ZB(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function QB(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JB(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},u=q0(t.children[1]),d=fN(t.children[t.children.length-1]);u&&d&&(a.position={start:u,end:d}),i.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function e9(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,u=a?a.length:t.children.length;let d=-1;const m=[];for(;++d<u;){const h=t.children[d],g={},y=a?a[d]:void 0;y&&(g.align=y);let v={type:"element",tagName:o,properties:g,children:[]};h&&(v.children=e.all(h),e.patch(h,v),v=e.applyData(h,v)),m.push(v)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(m,!0)};return e.patch(t,p),e.applyData(t,p)}function t9(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const cw=9,uw=32;function n9(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(dw(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(dw(t.slice(i),i>0,!1)),o.join("")}function dw(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===cw||o===uw;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===cw||o===uw;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function r9(e,t){const n={type:"text",value:n9(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function i9(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const s9={blockquote:DB,break:OB,code:LB,delete:zB,emphasis:PB,footnoteReference:BB,heading:$B,html:HB,imageReference:FB,image:VB,inlineCode:UB,linkReference:GB,link:qB,listItem:WB,list:XB,paragraph:KB,root:ZB,strong:QB,table:JB,tableCell:t9,tableRow:e9,text:r9,thematicBreak:i9,toml:Ud,yaml:Ud,definition:Ud,footnoteDefinition:Ud};function Ud(){}const DN=-1,Tm=0,Gc=1,qf=2,J0=3,ev=4,tv=5,nv=6,ON=7,LN=8,fw=typeof self=="object"?self:globalThis,o9=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,a]=t[i];switch(o){case Tm:case DN:return n(a,i);case Gc:{const u=n([],i);for(const d of a)u.push(r(d));return u}case qf:{const u=n({},i);for(const[d,m]of a)u[r(d)]=r(m);return u}case J0:return n(new Date(a),i);case ev:{const{source:u,flags:d}=a;return n(new RegExp(u,d),i)}case tv:{const u=n(new Map,i);for(const[d,m]of a)u.set(r(d),r(m));return u}case nv:{const u=n(new Set,i);for(const d of a)u.add(r(d));return u}case ON:{const{name:u,message:d}=a;return n(new fw[u](d),i)}case LN:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:u}=new Uint8Array(a);return n(new DataView(u),a)}}return n(new fw[o](a),i)};return r},mw=e=>o9(new Map,e)(0),$a="",{toString:a9}={},{keys:l9}=Object,Ec=e=>{const t=typeof e;if(t!=="object"||!e)return[Tm,t];const n=a9.call(e).slice(8,-1);switch(n){case"Array":return[Gc,$a];case"Object":return[qf,$a];case"Date":return[J0,$a];case"RegExp":return[ev,$a];case"Map":return[tv,$a];case"Set":return[nv,$a];case"DataView":return[Gc,n]}return n.includes("Array")?[Gc,n]:n.includes("Error")?[ON,n]:[qf,n]},Gd=([e,t])=>e===Tm&&(t==="function"||t==="symbol"),c9=(e,t,n,r)=>{const i=(a,u)=>{const d=r.push(a)-1;return n.set(u,d),d},o=a=>{if(n.has(a))return n.get(a);let[u,d]=Ec(a);switch(u){case Tm:{let p=a;switch(d){case"bigint":u=LN,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return i([DN],a)}return i([u,p],a)}case Gc:{if(d){let g=a;return d==="DataView"?g=new Uint8Array(a.buffer):d==="ArrayBuffer"&&(g=new Uint8Array( Line truncated
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:`
`}]}}const Rm=(function(e){if(e==null)return g9;if(typeof e=="function")return Am(e);if(typeof e=="object")return Array.isArray(e)?m9(e):h9(e);if(typeof e=="string")return p9(e);throw new Error("Expected function, string, or object as test")});function m9(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Rm(e[n]);return Am(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function h9(e){const t=e;return Am(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function p9(e){return Am(t);function t(n){return n&&n.type===e}}function Am(e){return t;function t(n,r,i){return!!(x9(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function g9(){return!0}function x9(e){return e!==null&&typeof e=="object"&&"type"in e}const zN=[],y9=!0,Oy=!1,v9="skip";function PN(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=Rm(i),a=r?-1:1;u(e,void 0,[])();function u(d,m,p){const h=d&&typeof d=="object"?d:{};if(typeof h.type=="string"){const y=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=zN,v,k,S;if((!t||o(d,m,p[p.length-1]||void 0))&&(y=b9(n(d,p)),y[0]===Oy))return y;if("children"in d&&d.children){const _=d;if(_.children&&y[0]!==v9)for(k=(r?_.children.length:-1)+a,S=p.concat(_);k>-1&&k<_.children.length;){const w=_.children[k];if(v=u(w,k,S)(),v[0]===Oy)return v;k=typeof v[1]=="number"?v[1]:k+a}}return y}}}function b9(e){return Array.isArray(e)?e:typeof e=="number"?[y9,e]:e==null?zN:[e]}function rv(e,t,n,r){let i,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,i=n):(o=t,a=n,i=r),PN(e,o,u,i);function u(d,m){const p=m[m.length-1],h=p?p.children.indexOf(d):void 0;return a(d,h,p)}}const Ly={}.hasOwnProperty,_9={};function k9(e,t){const n=t||_9,r=new Map,i=new Map,o=new Map,a={...s9,...n.handlers},u={all:m,applyData:w9,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:d,options:n,patch:S9,wrap:j9};return rv(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const h=p.type==="definition"?r:i,g=String(p.identifier).toUpperCase();h.has(g)||h.set(g,p)}}),u;function d(p,h){const g=p.type,y=u.handlers[g];if(Ly.call(u.handlers,g)&&y)return y(u,p,h);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in p){const{children:k,...S}=p,_=Wf(S);return _.children=u.all(p),_}return Wf(p)}return(u.options.unknownHandler||C9)(u,p,h)}function m(p){const h=[];if("children"in p){const g=p.children;let y=-1;for(;++y<g.length;){const v=u.one(g[y],p);if(v){if(y&&g[y-1].type==="break"&&(!Array.isArray(v)&&v.type==="text"&&(v.value=pw(v.value)),!Array.isArray(v)&&v.type==="element")){const k=v.children[0];k&&k.type==="text"&&(k.value=pw(k.value))}Array.isArray(v)?h.push(...v):h.push(v)}}}return h}}function S9(e,t){e.position&&(t.position=dz(e))}function w9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,Wf(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function C9(e,t){const n=t.data||{},r="value"in t&&!(Ly.call(n,"hProperties")||Ly.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function j9(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
`});++r<e.length;)r&&n.push({type:"text",value:`
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
`}),n}function pw(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function gw(e,t){const n=k9(e,t),r=n.one(e,void 0),i=f9(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:`
`},i),o}function E9(e,t){return e&&"run"in e?async function(n,r){const i=gw(n,{file:r,...t});await e.run(i,r)}:function(n,r){return gw(n,{file:r,...e||t})}}function xw(e){if(e)throw e}var Ng,yw;function N9(){if(yw)return Ng;yw=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(m){return typeof Array.isArray=="function"?Array.isArray(m):t.call(m)==="[object Array]"},o=function(m){if(!m||t.call(m)!=="[object Object]")return!1;var p=e.call(m,"constructor"),h=m.constructor&&m.constructor.prototype&&e.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!p&&!h)return!1;var g;for(g in m);return typeof g>"u"||e.call(m,g)},a=function(m,p){n&&p.name==="__proto__"?n(m,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):m[p.name]=p.newValue},u=function(m,p){if(p==="__proto__")if(e.call(m,p)){if(r)return r(m,p).value}else return;return m[p]};return Ng=function d(){var m,p,h,g,y,v,k=arguments[0],S=1,_=arguments.length,w=!1;for(typeof k=="boolean"&&(w=k,k=arguments[1]||{},S=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});S<_;++S)if(m=arguments[S],m!=null)for(p in m)h=u(k,p),g=u(m,p),k!==g&&(w&&g&&(o(g)||(y=i(g)))?(y?(y=!1,v=h&&i(h)?h:[]):v=h&&o(h)?h:{},a(k,{name:p,newValue:d(w,v,g)})):typeof g<"u"&&a(k,{name:p,newValue:g}));return k},Ng}var I9=N9();const Ig=Zo(I9);function zy(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function T9(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);u(null,...i);function u(d,...m){const p=e[++o];let h=-1;if(d){a(d);return}for(;++h<i.length;)(m[h]===null||m[h]===void 0)&&(m[h]=i[h]);i=m,p?R9(p,u)(...m):a(null,...m)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function R9(e,t){let n;return r;function r(...a){const u=e.length>a.length;let d;u&&a.push(i);try{d=e.apply(this,a)}catch(m){const p=m;if(u&&n)throw p;return i(p)}u||(d&&d.then&&typeof d.then=="function"?d.then(o,i):d instanceof Error?i(d):o(d))}function i(a,...u){n||(n=!0,t(a,...u))}function o(a){i(null,a)}}const Hi={basename:A9,dirname:M9,extname:D9,join:O9,sep:"/"};function A9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Su(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,u=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else a<0&&(o=!0,a=i+1),u>-1&&(e.codePointAt(i)===t.codePointAt(u--)?u<0&&(r=i):(u=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function M9(e){if(Su(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function D9(e){Su(e);let t=e.length,n=-1,r=0,i=-1,o=0,a;for(;t--;){const u=e.codePointAt(t);if(u===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),u===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function O9(...e){let t=-1,n;for(;++t<e.length;)Su(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":L9(n)}function L9(e){Su(e);const t=e.codePointAt(0)===47;let n=z9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function z9(e,t){let n="",r=0,i=-1,o=0,a=-1,u,d;for(;++a<=e.length;){if(a<e.length)u=e.codePointAt(a);else{if(u===47)break;u=47}if(u===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),i=a,o=0;continue}}else if(n.length>0){n="",r=0,i=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,o=0}else u===46&&o>-1?o++:o=-1}return n}function Su(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const P9={cwd:B9};function B9(){return"/"}function Py(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function $9(e){if(typeof e=="string")e=new URL(e);else if(!Py(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return H9(e)}function H9(e){if(e.hostname!==""){consLine truncated
`:" ")+o.indentLines(o.containerFlow(r,u.current()),t?FN:R$))),m(),d}}function R$(e,t,n){return t===0?e:FN(e,t,n)}function FN(e,t,n){return(n?"":" ")+e}const A$=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];VN.peek=z$;function M$(){return{canContainEols:["delete"],enter:{strikethrough:O$},exit:{strikethrough:L$}}}function D$(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:A$}],handlers:{delete:VN}}}function O$(e){this.enter({type:"delete",children:[]},e)}function L$(e){this.exit(e)}function VN(e,t,n,r){const i=n.createTracker(r),o=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),o(),a}function z$(){return"~"}function P$(e){return e.length}function B$(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||P$,o=[],a=[],u=[],d=[];let m=0,p=-1;for(;++p<e.length;){const k=[],S=[];let _=-1;for(e[p].length>m&&(m=e[p].length);++_<e[p].length;){const w=$$(e[p][_]);if(n.alignDelimiters!==!1){const C=i(w);S[_]=C,(d[_]===void 0||C>d[_])&&(d[_]=C)}k.push(w)}a[p]=k,u[p]=S}let h=-1;if(typeof r=="object"&&"length"in r)for(;++h<m;)o[h]=Cw(r[h]);else{const k=Cw(r);for(;++h<m;)o[h]=k}h=-1;const g=[],y=[];for(;++h<m;){const k=o[h];let S="",_="";k===99?(S=":",_=":"):k===108?S=":":k===114&&(_=":");let w=n.alignDelimiters===!1?1:Math.max(1,d[h]-S.length-_.length);const C=S+"-".repeat(w)+_;n.alignDelimiters!==!1&&(w=S.length+w+_.length,w>d[h]&&(d[h]=w),y[h]=w),g[h]=C}a.splice(1,0,g),u.splice(1,0,y),p=-1;const v=[];for(;++p<a.length;){const k=a[p],S=u[p];h=-1;const _=[];for(;++h<m;){const w=k[h]||"";let C="",N="";if(n.alignDelimiters!==!1){const O=d[h]-(S[h]||0),I=o[h];I===114?C=" ".repeat(O):I===99?O%2?(C=" ".repeat(O/2+.5),N=" ".repeat(O/2-.5)):(C=" ".repeat(O/2),N=C):N=" ".repeat(O)}n.delimiterStart!==!1&&!h&&_.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&w==="")&&(n.delimiterStart!==!1||h)&&_.push(" "),n.alignDelimiters!==!1&&_.push(C),_.push(w),n.alignDelimiters!==!1&&_.push(N),n.padding!==!1&&_.push(" "),(n.delimiterEnd!==!1||h!==m-1)&&_.push("|")}v.push(n.delimiterEnd===!1?_.join("").replace(/ +$/,""):_.join(""))}return v.join(`
`)}function $$(e){return e==null?"":String(e)}function Cw(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function H$(e,t,n,r){const i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const a=n.indentLines(n.containerFlow(e,o.current()),F$);return i(),a}function F$(e,t,n){return">"+(n?"":" ")+e}function V$(e,t){return jw(e,t.inConstruct,!0)&&!jw(e,t.notInConstruct,!1)}function jw(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Ew(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
`&&V$(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
`}function U$(e,t){const n=String(e);let r=n.indexOf(t),i=r,o=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>a&&(a=o):o=1,i=r+t.length,r=n.indexOf(t,i);return a}function G$(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function q$(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function W$(e,t,n,r){const i=q$(n),o=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(G$(e,n)){const h=n.enter("codeIndented"),g=n.indentLines(o,Y$);return h(),g}const u=n.createTracker(r),d=i.repeat(Math.max(U$(o,i)+1,3)),m=n.enter("codeFenced");let p=u.move(d);if(e.lang){const h=n.enter(`codeFencedLang${a}`);p+=u.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...u.current()})),h()}if(e.lang&&e.meta){const h=n.enter(`codeFencedMeta${a}`);p+=u.move(" "),p+=u.move(n.safe(e.meta,{before:p,after:`
`,encode:["`"],...u.current()})),h()}return p+=u.move(`
`),o&&(p+=u.move(o+`
`)),p+=u.move(d),m(),p}function Y$(e,t,n){return(n?"":" ")+e}function sv(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function X$(e,t,n,r){const i=sv(n),o=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let u=n.enter("label");const d=n.createTracker(r);let m=d.move("[");return m+=d.move(n.safe(n.associationId(e),{before:m,after:"]",...d.current()})),m+=d.move("]: "),u(),!e.url||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),m+=d.move("<"),m+=d.move(n.safe(e.url,{before:m,after:">",...d.current()})),m+=d.move(">")):(u=n.enter("destinationRaw"),m+=d.move(n.safe(e.url,{before:m,after:e.title?" ":`
`,...d.current()}))),u(),e.title&&(u=n.enter(`title${o}`),m+=d.move(" "+i),m+=d.move(n.safe(e.title,{before:m,after:i,...d.current()})),m+=d.move(i),u()),a(),m}function K$(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function lu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Yf(e,t,n){const r=dl(e),i=dl(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}UN.peek=Z$;function UN(e,t,n,r){const i=K$(n),o=n.enter("emphasis"),a=n.createTracker(r),u=a.move(i);let d=a.move(n.containerPhrasing(e,{after:i,before:u,...a.current()}));const m=d.charCodeAt(0),p=Yf(r.before.charCodeAt(r.before.length-1),m,i);p.inside&&(d=lu(m)+d.slice(1));const h=d.charCodeAt(d.length-1),g=Yf(r.after.charCodeAt(0),h,i);g.inside&&(d=d.slice(0,-1)+lu(h));const y=a.move(i);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},u+d+y}function Z$(e,t,n){return n.options.emphasis||"*"}function Q$(e,t){let n=!1;return rv(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Oy}),!!((!e.depth||e.depth<3)&&K0(e)&&(t.options.setext||n))}function J$(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(Q$(e,n)){const p=n.enter("headingSetext"),h=n.enter("phrasing"),g=n.containerPhrasing(e,{...o.current(),before:`
`,after:`
`});return h(),p(),g+`
`+(i===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
`))+1))}const a="#".repeat(i),u=n.enter("headingAtx"),d=n.enter("phrasing");o.move(a+" ");let m=n.containerPhrasing(e,{before:"# ",after:`
`,...o.current()});return/^[\t ]/.test(m)&&(m=lu(m.charCodeAt(0))+m.slice(1)),m=m?a+" "+m:a,n.options.closeAtx&&(m+=" "+a),d(),u(),m}GN.peek=e7;function GN(e){return e.value||""}function e7(){return"<"}qN.peek=t7;function qN(e,t,n,r){const i=sv(n),o=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let u=n.enter("label");const d=n.createTracker(r);let m=d.move("![");return m+=d.move(n.safe(e.alt,{before:m,after:"]",...d.current()})),m+=d.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),m+=d.move("<"),m+=d.move(n.safe(e.url,{before:m,after:">",...d.current()})),m+=d.move(">")):(u=n.enter("destinationRaw"),m+=d.move(n.safe(e.url,{before:m,after:e.title?" ":")",...d.current()}))),u(),e.title&&(u=n.enter(`title${o}`),m+=d.move(" "+i),m+=d.move(n.safe(e.title,{before:m,after:i,...d.current()})),m+=d.move(i),u()),m+=d.move(")"),a(),m}function t7(){return"!"}WN.peek=n7;function WN(e,t,n,r){const i=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const u=n.createTracker(r);let d=u.move("![");const m=n.safe(e.alt,{before:d,after:"]",...u.current()});d+=u.move(m+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return a(),n.stack=p,o(),i==="full"||!m||m!==h?d+=u.move(h+"]"):i==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function n7(){return"!"}YN.peek=r7;function YN(e,t,n){let r=e.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],u=n.compilePattern(a);let d;if(a.atBreak)for(;d=u.exec(r);){let m=d.index;r.charCodeAt(m)===10&&r.charCodeAt(m-1)===13&&m--,r=r.slice(0,m)+" "+r.slice(d.index+1)}}return i+r+i}function r7(){return"`"}function XN(e,t){const n=K0(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}KN.peek=i7;function KN(e,t,n,r){const i=sv(n),o=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let u,d;if(XN(e,n)){const p=n.stack;n.stack=[],u=n.enter("autolink");let h=a.move("<");return h+=a.move(n.containerPhrasing(e,{before:h,after:">",...a.current()})),h+=a.move(">"),u(),n.stack=p,h}u=n.enter("link"),d=n.enter("label");let m=a.move("[");return m+=a.move(n.containerPhrasing(e,{before:m,after:"](",...a.current()})),m+=a.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),m+=a.move("<"),m+=a.move(n.safe(e.url,{before:m,after:">",...a.current()})),m+=a.move(">")):(d=n.enter("destinationRaw"),m+=a.move(n.safe(e.url,{before:m,after:e.title?" ":")",...a.current()}))),d(),e.title&&(d=n.enter(`title${o}`),m+=a.move(" "+i),m+=a.move(n.safe(e.title,{before:m,after:i,...a.current()})),m+=a.move(i),d()),m+=a.move(")"),u(),m}function i7(e,t,n){return XN(e,n)?"<":"["}ZN.peek=s7;function ZN(e,t,n,r){const i=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const u=n.createTracker(r);let d=u.move("[");const m=n.containerPhrasing(e,{before:d,after:"]",...u.current()});d+=u.move(m+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return a(),n.stack=p,o(),i==="full"||!m||m!==h?d+=u.move(h+"]"):i==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function s7(){return"["}function ov(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function o7(e){const t=ov(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function a7(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function QN(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function l7(e,t,n,r){const i=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?a7(n):ov(n);const u=e.ordered?a==="."?")":".":o7(n);let d=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),QN(n)===a&&p){let h=-1;for(;++h<e.chilLine truncated
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:a,tableCell:d,tableRow:u}};function a(y,v,k,S){return m(p(y,k,S),y.align)}function u(y,v,k,S){const _=h(y,k,S),w=m([_]);return w.slice(0,w.indexOf(`
`))}function d(y,v,k,S){const _=k.enter("tableCell"),w=k.enter("phrasing"),C=k.containerPhrasing(y,{...S,before:o,after:o});return w(),_(),C}function m(y,v){return B$(y,{align:v,alignDelimiters:r,padding:n,stringLength:i})}function p(y,v,k){const S=y.children;let _=-1;const w=[],C=v.enter("table");for(;++_<S.length;)w[_]=h(S[_],v,k);return C(),w}function h(y,v,k){const S=y.children;let _=-1;const w=[],C=v.enter("tableRow");for(;++_<S.length;)w[_]=d(S[_],y,v,k);return C(),w}function g(y,v,k){let S=eI.inlineCode(y,v,k);return k.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function j7(){return{exit:{taskListCheckValueChecked:Iw,taskListCheckValueUnchecked:Iw,paragraph:N7}}}function E7(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:I7}}}function Iw(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function N7(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let o=-1,a;for(;++o<i.length;){const u=i[o];if(u.type==="paragraph"){a=u;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function I7(e,t,n,r){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",u=n.createTracker(r);o&&u.move(a);let d=eI.listItem(e,t,n,{...r,...u.current()});return o&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),d;function m(p){return p+a}}function T7(){return[l$(),I$(),M$(),v7(),j7()]}function R7(e){return{extensions:[c$(),T$(e),D$(),C7(e),E7()]}}const A7={tokenize:P7,partial:!0},tI={tokenize:B7,partial:!0},nI={tokenize:$7,partial:!0},rI={tokenize:H7,partial:!0},M7={tokenize:F7,partial:!0},iI={name:"wwwAutolink",tokenize:L7,previous:oI},sI={name:"protocolAutolink",tokenize:z7,previous:aI},Cs={name:"emailAutolink",tokenize:O7,previous:lI},Qi={};function D7(){return{text:Qi}}let Mo=48;for(;Mo<123;)Qi[Mo]=Cs,Mo++,Mo===58?Mo=65:Mo===91&&(Mo=97);Qi[43]=Cs;Qi[45]=Cs;Qi[46]=Cs;Qi[95]=Cs;Qi[72]=[Cs,sI];Qi[104]=[Cs,sI];Qi[87]=[Cs,iI];Qi[119]=[Cs,iI];function O7(e,t,n){const r=this;let i,o;return a;function a(h){return!By(h)||!lI.call(r,r.previous)||av(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(h))}function u(h){return By(h)?(e.consume(h),u):h===64?(e.consume(h),d):n(h)}function d(h){return h===46?e.check(M7,p,m)(h):h===45||h===95||kr(h)?(o=!0,e.consume(h),d):p(h)}function m(h){return e.consume(h),i=!0,d}function p(h){return o&&i&&Ir(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function L7(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!oI.call(r,r.previous)||av(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(A7,e.attempt(tI,e.attempt(nI,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function z7(e,t,n){const r=this;let i="",o=!1;return a;function a(h){return(h===72||h===104)&&aI.call(r,r.previous)&&!av(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),e.consume(h),u):n(h)}function u(h){if(Ir(h)&&i.length<5)return i+=String.fromCodePoint(h),e.consume(h),u;if(h===58){const g=i.toLowerCase();if(g==="http"||g==="https")return e.consume(h),d}return n(h)}function d(h){return h===47?(e.consume(h),o?m:(o=!0,d)):n(h)}function m(h){return h===null||Gf(h)||gn(h)||Uo(h)||Nm(h)?n(h):e.attempt(tI,e.attempt(nI,p),n)(h)}function p(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function P7(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function B7(e,t,n){let r,i,o;return a;function a(m){return m===46||m===95?e.check(rI,d,u)(m):m===null||gn(m)||Uo(m)||m!==45&&Nm(m)?d(m):(o=!0,e.consume(m),a)}function u(m){return m===95?r=!0:(i=r,r=void 0),e.consume(m),a}function d(m){return i||r||!o?n(m):t(m)}}function $7(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(rI,t,o)(a):a===null||gn(a)||Uo(a)?t(a):(e.consume(a),i)}function o(a){return a===41&&r++,e.consume(a),i}}function H7(e,t,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),r):u===38?(e.consume(u),o):u===93?(e.consume(u),i):u===60||u===null||gn(u)||Uo(u)?t(u):n(u)}function i(u){return u===null||u===40||u===91||gn(u)||Uo(u)?t(u):r(u)}function o(u){return Ir(u)?a(u):n(u)}function a(u){re Line truncated
`),m=d.length>fH,p=m?d.length-$g*2:0,h=j.useCallback(()=>{navigator.clipboard.writeText(a),r(!0),setTimeout(()=>r(!1),1500)},[a]);return c.jsxs("div",{className:"code-block-wrap",children:[c.jsxs("div",{className:"code-block-header",children:[c.jsxs("span",{className:"code-block-lang",children:[u||"code",m?` (${d.length} lines)`:""]}),c.jsx("button",{className:"code-block-copy",onClick:h,children:n?c.jsxs(c.Fragment,{children:[c.jsx(_l,{})," ",c.jsx("span",{children:"Copied"})]}):c.jsxs(c.Fragment,{children:[c.jsx(pm,{})," ",c.jsx("span",{children:"Copy"})]})})]}),c.jsx("pre",{children:c.jsx("code",{className:e,children:m&&!i?c.jsxs(c.Fragment,{children:[d.slice(0,$g).join(`
`)+`
`,c.jsxs("span",{className:"code-block-omitted",onClick:()=>o(!0),children:["... +",p," lines (click to expand)"]}),`
`+d.slice(-$g).join(`
`)]}):a})}),m&&i&&c.jsxs("button",{className:"code-block-collapse-btn",onClick:()=>o(!1),children:["Collapse (",d.length," lines)"]})]})}const hH={code({className:e,children:t,...n}){return e?.startsWith("language-")?c.jsx(mH,{className:e,children:t}):c.jsx("code",{className:e,...n,children:t})}},pH=3e3,gH=60,Hg=800;function Rw(e){if(e.length>pH)return!0;let t=0;for(let n=0;n<e.length;n++)if(e[n]===`
`&&++t>=gH)return!0;return!1}function xH(e){const t=e.lastIndexOf(`
`,Hg);return e.slice(0,t>Hg/2?t:Hg)}const ir=St.memo(function({content:t,className:n="msg-content-agent",collapseMode:r="auto"}){const i=r!=="never"&&Rw(t),[o,a]=j.useState(i);j.useEffect(()=>{a(r!=="never"&&Rw(t))},[r,t]);const u=o?xH(t):t,d=t.split(`
`).length,m=t.length;return c.jsxs("div",{className:n,children:[c.jsx(Q9,{remarkPlugins:[dH],components:hH,children:u}),i&&o&&c.jsxs("button",{className:"msg-collapse-toggle",onClick:()=>a(!1),children:["Show more (",d," lines, ",(m/1e3).toFixed(1),"k chars)"]}),i&&!o&&c.jsx("button",{className:"msg-collapse-toggle",onClick:()=>a(!0),children:"Show less"})]})}),Aw={native:"OpenOPC Native",codex:"Codex",claude_code:"Claude Code",cursor:"Cursor",opencode:"OpenCode"},cu="codex",Fg="native",yH=["codex","native","claude_code","cursor","opencode"],vH=["native","codex","claude_code","cursor","opencode"];function cI(e){if(!e)return{kind:"fallback"};if(e.kind==="employee"){const t=String(e.id??e.employee_id??"").trim();return t?{kind:"employee",id:t}:{kind:"fallback"}}if(e.kind==="template"){const t=String(e.id??e.template_id??"").trim();return t?{kind:"template",id:t}:{kind:"fallback"}}return{kind:"fallback"}}function uI(e){const t=cI(e);return t.kind==="fallback"?"fallback:":`${t.kind}:${t.id??""}`}function bH(e,t,n){const r=String(e.role_id??"").trim(),i=String(e.role_label??"").trim(),o=`${r} ${i} ${e.role_responsibility??""}`.toLowerCase(),a=new Set((e.same_role_employee_ids??[]).map(m=>String(m??"").trim()).filter(Boolean)),u=t.map(m=>{const p=String(m.employee_id??"").trim(),h=String(m.employee_name??p).trim()||p,g=String(m.role_id??"").trim(),y=String(m.category??"").trim(),v=[g,y].filter(Boolean).join(" · ")||p;return{kind:"employee",id:p,name:h,subtitle:v,category:y,searchText:`${p} ${h} ${g} ${y} ${(m.domains??[]).join(" ")} ${(m.tags??[]).join(" ")}`.toLowerCase(),rank:a.has(p)||g===r?0:2}}).filter(m=>m.id).sort((m,p)=>m.rank-p.rank||m.name.localeCompare(p.name)),d=n.map(m=>{const p=String(m.template_id??"").trim(),h=String(m.template_name??p).trim()||p,g=String(m.category??"").trim(),y=[g,p].filter(Boolean).join(" · ")||p,v=`${p} ${h} ${g} ${(m.domains??[]).join(" ")} ${(m.tags??[]).join(" ")}`.toLowerCase(),k=o.split(/[^a-z0-9]+/).filter(S=>S.length>=3).reduce((S,_)=>S+(v.includes(_)?1:0),0);return{kind:"template",id:p,name:h,subtitle:y,category:g,searchText:v,rank:k}}).filter(m=>m.id).sort((m,p)=>p.rank-m.rank||m.name.localeCompare(p.name));return[...u,...d,{kind:"fallback",id:"",name:"Fallback role-only",subtitle:"No employee override",category:"fallback",searchText:"fallback role only no employee override"}]}function _H(e,t){const n=uI(t);return e.find(r=>`${r.kind}:${r.id}`===n)??e[0]}function kH(e,t){const n=t.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?!0:n.every(r=>e.searchText.includes(r))}function SH(e){return e.map(t=>{const n=String(t.role_id??"").trim(),r=String(t.existing_employee?.employee_id??"").trim(),i=String(t.candidate?.template_id??"").trim(),o=r?{kind:"employee",id:r}:i?{kind:"template",id:i}:{kind:"fallback"};return{role_id:n,role_label:t.role_labels?.[0]??n,role_responsibility:"",default_selection:o,same_role_employee_ids:t.existing_employee_ids??[],fallback_available:!0,default_agent:t.default_agent??cu,selected_agent:t.selected_agent??t.default_agent??cu,default_source:"recruitment"}}).filter(t=>t.role_id)}function wH(e,t){return t.kind==="template"&&e?.candidate?.template_id===t.id?e.candidate.proposed_name||e.candidate.template_name||t.name:t.kind==="employee"&&e?.existing_employee?.employee_id===t.id&&e.existing_employee.employee_name||t.name}function Mw(e,t){const n={},r=e.staffing_selections??{};for(const i of t){const o=String(i.role_id??"").trim();o&&(n[o]=cI(r[o]??i.default_selection))}return n}function Dw(e,t){const n=e.recruitment_role_agents??{},r={};for(const i of t){const o=String(i.role_id??"").trim();o&&(r[o]=n[o]??i.selected_agent??i.default_agent??cu)}return r}function CH(e){return!!(String(e.checkpoint_response_message_id??"").trim()||String(e.checkpoint_responded_at??"").trim()||String(e.checkpoint_reply_kind??"").trim())}const dI=St.memo(function({meta:t,onReply:n,responded:r}){const i=t.proposals??[],o=j.useMemo(()=>{const L={};for(const A of i){const M=String(A.role_id??"").trim();M&&(L[M]=A)}return L},[i]),a=j.useMemo(()=>t.staffing_roles?.length?t.staffing_roles:SH(i),[t.staffing_roles,i]),u=t.staffing_pool?.employees??[],d=t.staffing_pool?.templates??[],m=t.recruitment_rationales??[],p=j.useMemo(()=>{const L={};for(const A of a){const M=String(A.role_id??"").trim();M&&(L[M]=bH(A,u,d))}return L},[u,a,d]),[h,g]=j.useState({}),[y,v]=j.useState(""),[k,S]=j.useState(()=>Mw(t,a)),[_,w]=j.useState(()=>Dw(t,a)),[C,N]=j.useState(t.recruitment_agent??Fg),O=r;j.useEffect(()=>{!O||!CH(t)||(S(Mw(t,a)),w(Dw(t,a)),N(t.recruitment_agent??Fg))},[O,t,a]),j.useEffect(()=>{N(t.recruitment_agent??Fg)},[t.recruitment_agent]);const I=j.useCallback(L=>{const A=String(t.checkpoint_id??"").trim();if(!A)throw new Error("Recruitment checkpoint reply requires checkpoint_id metadata.");const M=String(t.checkpoint_type??"").trim();return{response_to_checkpoint_id:A,response_to_checkpoint_type:M||"company_recruitment_confirmation",checkpoint_reply_kind:L,staffin Line truncated
`).map(t=>t.trim()).find(Boolean)??e}function OH(e){switch(e){case"timeout":case"timed_out":case"expired":return"Expired";case"stale":case"invalid":return"Inactive";case"cancelled":case"canceled":return"Cancelled";case"resolved":return"Resolved";default:return"Responded"}}const Xf=St.memo(function({meta:t,onReply:n,responded:r}){const i=r,o=String(t.checkpoint_status??"").trim().toLowerCase(),a=OH(o),u=String(t.prompt??t.summary??""),d=j.useMemo(()=>u.split(`
`).map(O=>O.trim()).filter(Boolean),[u]),m=DH(u).replace(/^\[[^\]]+\]\s*/,"")||"Action Required",p=d.slice(1).join(`
`).trim(),h=String(t.summary??"").trim(),g=(t.options??[]).filter(O=>!!O?.id),y=j.useMemo(()=>(t.active_subagents??[]).filter(O=>!!O&&typeof O=="object"),[t.active_subagents]),v=j.useMemo(()=>(t.permission_requests??[]).filter(O=>!!O&&typeof O=="object"),[t.permission_requests]),k=String(t.worktree_path??"").trim(),S=y.length>0||v.length>0||!!k,[_,w]=j.useState(""),C=!!_&&!i;j.useEffect(()=>{if(!C)return;const O=window.setTimeout(()=>w(""),MH);return()=>window.clearTimeout(O)},[C,_]);const N=j.useCallback(O=>{i||C||(w(O.id),n(O.label||O.id))},[i,C,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-escalation",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-escalation",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M8 1.5L14.5 13H1.5L8 1.5Z"}),c.jsx("path",{d:"M8 5.5V9"}),c.jsx("circle",{cx:"8",cy:"11.5",r:"0.75",fill:"currentColor",stroke:"none"})]})}),c.jsx("div",{className:"ckpt-title",children:m}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:String(t.escalation_type??"decision_needed").replace(/_/g," ")}),i&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:a})]}),h&&h!==m&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ir,{content:h,className:"ckpt-markdown"})]}),p&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Request"}),c.jsx(ir,{content:p,className:"ckpt-markdown"})]}),S&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[k&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:k})]}),y.length>0&&c.jsxs("div",{children:["Active subagents: ",y.length]}),v.length>0&&c.jsxs("div",{children:["Pending permission records: ",v.length]})]})]}),!i&&g.length>0&&c.jsx("div",{className:"ckpt-actions ckpt-escalation-actions",children:g.map(O=>c.jsx("button",{className:`ckpt-btn ${O.id.includes("deny")?"ckpt-btn-deny":"ckpt-btn-approve"}${C?" ckpt-btn-submitting":""}`,onClick:()=>N(O),disabled:C,children:C&&_===O.id?"Submitting…":O.label||O.id},O.id))}),C&&c.jsx("div",{className:"ckpt-escalation-hint",children:"Decision sent — waiting for server confirmation…"}),!i&&t.default_action&&c.jsxs("div",{className:"ckpt-escalation-hint",children:["Default on timeout: ",c.jsx("code",{children:t.default_action})]})]})});function LH(e){return e.split(`
`).map(t=>t.trim()).find(Boolean)??e}function zH(e){switch(e){case"ignored":return"Ignored";case"timeout":case"timed_out":case"expired":return"Expired";case"stale":case"invalid":return"Inactive";case"superseded":return"Superseded";case"cancelled":case"canceled":return"Cancelled";case"resolved":return"Resolved";default:return"Responded"}}const gI=St.memo(function({meta:t,onReply:n,responded:r}){const i=r,[o,a]=j.useState(""),[u,d]=j.useState(null),m=String(t.checkpoint_status??"").trim().toLowerCase(),p=zH(m),h=String(t.prompt??t.summary??"").trim(),y=`${String(t.work_item_projection_title??LH(h)??"Human Review").trim()||"Human Review"} (for self-evolution)`,v=String(t.summary??"").trim(),k=j.useMemo(()=>(t.active_subagents??[]).filter(T=>!!T&&typeof T=="object"),[t.active_subagents]),S=j.useMemo(()=>(t.permission_requests??[]).filter(T=>!!T&&typeof T=="object"),[t.permission_requests]),_=String(t.worktree_path??"").trim(),w=k.length>0||S.length>0||!!_,C=i||u!==null,N=j.useCallback((T,L="")=>{const A=String(t.checkpoint_id??"").trim();if(!A)throw new Error("Delivery self-evolution reply requires checkpoint_id metadata.");const M={response_to_checkpoint_id:A,response_to_checkpoint_type:"company_delivery_feedback",checkpoint_reply_kind:T};return(T==="approve"||T==="feedback")&&(M.self_evolution_trigger=!0,M.human_feedback_text=L),M},[t.checkpoint_id]),O=j.useCallback(()=>{if(C)return;const T=N("approve");d("approve"),n("I fully agree with this delivery.",T)},[C,N,n]),I=j.useCallback(()=>{const T=o.trim();if(C||!T)return;const L=N("feedback",T);d("feedback"),n(T,L),a("")},[C,N,o,n]),D=j.useCallback(()=>{if(C)return;const T=N("ignore");d("ignore"),n("Ignore this self-evolution review.",T)},[C,N,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-delivery-feedback",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-user-input",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M8 1.5L14 5v4.5c0 2.25-1.8 4.25-6 5-4.2-.75-6-2.75-6-5V5L8 1.5Z"}),c.jsx("path",{d:"M5.5 8.25L7.25 10l3.25-4"})]})}),c.jsx("div",{className:"ckpt-title",children:y}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:String(t.feedback_scope??"final").replace(/_/g," ")}),i&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:p})]}),v&&v!==y&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ir,{content:v,className:"ckpt-markdown"})]}),h&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Review Request"}),c.jsx(ir,{content:h,className:"ckpt-markdown"})]}),w&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[_&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:_})]}),k.length>0&&c.jsxs("div",{children:["Active subagents: ",k.length]}),S.length>0&&c.jsxs("div",{children:["Pending permission records: ",S.length]})]})]}),!i&&c.jsxs("div",{className:"ckpt-actions ckpt-actions-inline-feedback",children:[c.jsx("button",{className:"ckpt-btn ckpt-btn-approve",onClick:O,disabled:C,children:"Fully Agree"}),c.jsx("button",{className:"ckpt-btn ckpt-btn-cancel",onClick:D,disabled:C,children:"Ignore"}),c.jsx("textarea",{className:"ckpt-feedback-input ckpt-feedback-inline-input",placeholder:"Feedback for self-evolution...",value:o,onChange:T=>a(T.target.value),disabled:C,rows:2}),c.jsx("button",{className:"ckpt-btn ckpt-btn-feedback",onClick:I,disabled:C||!o.trim(),children:"Send Feedback"})]})]})}),Yd="__other__",PH=["A","B","C"];function Fi(e){return String(e??"").trim()}function BH(e,t){const n=Fi(e.question),r=Fi(e.header);if(!n&&!r)return null;const i=(e.options??[]).slice(0,3).map((o,a)=>({id:Fi(o.id)||String.fromCharCode(97+a),label:Fi(o.label),description:Fi(o.description)})).filter(o=>o.label);return{id:Fi(e.id)||`question_${t+1}`,header:r,question:n||r,options:i,allow_freeform:e.allow_freeform!==!1,required:e.required!==!1}}const xI=St.memo(function({meta:t,onReply:n,responded:r}){const[i,o]=j.useState(""),[a,u]=j.useState({}),d=r,m=String(t.work_item_projection_title??t.work_item_projection_id??"Input Needed").trim()||"Input Needed",p=String(t.summary??"").trim(),h=String(t.prompt??"").trim(),g=String(t.context_note??"").trim(),y=String(t.resume_hint??"").trim(),v=j.useMemo(()=>(t.questions??[]).map(V=>String(V).trim()).filter(Boolean),[t.questions]),k=j.useMemo(()=>(t.input_questions??[]).map((V,Y)=>BH(V,Y)).filter(V=>V!==null),[t.input_questions]),S=k.some(V=>(V.options??[]).length>0),_=j.useMemo(()=>(t.required_fields??[]).map(V=>String(V).trim()).filter(Boolean),[t.required_fields]),w=j.useMemo(()=>(t.active_subagents??[]).filter(V=>!!V&&typeof V=="object"),[t.active_subagents]),C=j.useMemo(( Line truncated
`),{user_input_answers:V})},[a,B,k,d,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-user-input",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-user-input",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M3 3.5h10v6H6.5L3 13V3.5Z"}),c.jsx("path",{d:"M5.5 6h5"}),c.jsx("path",{d:"M5.5 8h3.5"})]})}),c.jsx("div",{className:"ckpt-title",children:m}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:"awaiting input"}),d&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:"Responded"})]}),p&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ir,{content:p,className:"ckpt-markdown"})]}),h&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Request"}),c.jsx(ir,{content:h,className:"ckpt-markdown"})]}),S?c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Questions"}),c.jsx("div",{className:"ckpt-choice-list",children:k.map(V=>{const Y=a[V.id]??{freeformText:""},Z=V.options??[],q=V.allow_freeform!==!1,G=q&&(Z.length===0||Y.selectedOptionId===Yd);return c.jsxs("div",{className:"ckpt-choice-question",children:[V.header&&c.jsx("div",{className:"ckpt-question-header",children:V.header}),c.jsx(ir,{content:V.question,className:"ckpt-markdown"}),Z.length>0&&c.jsxs("div",{className:"ckpt-choice-grid",children:[Z.map((J,P)=>{const X=Y.selectedOptionId===J.id;return c.jsxs("button",{className:`ckpt-choice-option${X?" is-selected":""}`,onClick:()=>M(V.id,J.id),children:[c.jsx("span",{className:"ckpt-choice-letter",children:PH[P]??"?"}),c.jsxs("span",{className:"ckpt-choice-copy",children:[c.jsx("span",{className:"ckpt-choice-label",children:J.label}),J.description&&c.jsx("span",{className:"ckpt-choice-desc",children:J.description})]})]},J.id)}),q&&c.jsxs("button",{className:`ckpt-choice-option${Y.selectedOptionId===Yd?" is-selected":""}`,onClick:()=>M(V.id,Yd),children:[c.jsx("span",{className:"ckpt-choice-letter",children:"D"}),c.jsxs("span",{className:"ckpt-choice-copy",children:[c.jsx("span",{className:"ckpt-choice-label",children:"Other"}),c.jsx("span",{className:"ckpt-choice-desc",children:"Enter a custom answer"})]})]})]}),G&&c.jsx("textarea",{className:"ckpt-feedback-input ckpt-other-field",placeholder:"Type your answer...",value:Y.freeformText,onChange:J=>$(V.id,J.target.value),rows:3})]},V.id)})})]}):v.length>0&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Questions"}),c.jsx("ul",{className:"ckpt-task-list",children:v.map(V=>c.jsx("li",{children:V},V))})]}),_.length>0&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Required Fields"}),c.jsx("div",{className:"ckpt-task-tags",children:_.map(V=>c.jsx("span",{className:"ckpt-field-tag",children:V},V))})]}),g&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Context"}),c.jsx(ir,{content:g,className:"ckpt-markdown ckpt-markdown-muted"})]}),y&&c.jsx("div",{className:"ckpt-escalation-hint",children:y}),A&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[O&&c.jsxs("div",{children:["Requester: ",c.jsx("code",{children:O})]}),D&&c.jsxs("div",{children:["Work item: ",c.jsx("code",{children:D})]}),I&&c.jsxs("div",{children:["Task: ",c.jsx("code",{children:I})]}),T&&c.jsxs("div",{children:["Seat: ",c.jsx("code",{children:T})]}),N&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:N})]}),w.length>0&&c.jsxs("div",{children:["Active subagents: ",w.length]}),C.length>0&&c.jsxs("div",{children:["Pending permission records: ",C.length]})]})]}),!d&&c.jsxs("div",{className:"ckpt-feedback-area",children:[S?null:c.jsx("textarea",{className:"ckpt-feedback-input",placeholder:"Reply with the missing input to continue...",value:i,onChange:V=>o(V.target.value),rows:3}),c.jsx("div",{className:"ckpt-feedback-btns",children:c.jsx("button",{className:"ckpt-btn ckpt-btn-approve",onClick:S?H:U,disabled:S?!B:!i.trim(),children:"Send Reply"})})]})]})}),Hy={todo:"To do",in_progress:"In progress",in_review:"In review",done:"Done"};function Ug(e,t){if(t&&t in Hy)return t;switch(e){case"active":return"in_progress";case"waiting":return"in_review";case"done":return"done";case"failed":return"done";case"pending":return"todo";default:return"todo"}}function Xd(e){return Hy[e]??Hy.todo}const Bw={active:0,waiting:1,failed:2,done:3,pending:4};function $H(e){if(e.length===0)return"pending";let t=e[0],n=Bw[t]??99;for(const r of e){const i=Bw[r]??99;i<n&&(t=r,n=i)}return t}const HH={native:"Native",codex:"Codex",claude_code:"Claude Code",cursor Line truncated
`)[0].slice(0,140),tone:"danger"};const o=t.match(/^\[Company:([^\]]+)\]\s*(.+)$/);if(o){const d=o[1].split("::"),m=d[0]||"company",p=o[2].trim(),h=p.toLowerCase(),g=h.includes("completed")||h.includes("done")?"success":h.includes("blocked")||h.includes("failed")?"warning":"info";return{kind:"company_event",label:`${m.toUpperCase()} · ${d[1]??""}`.replace(/ · $/,""),summary:p,tone:g}}const a=t.match(/^(Review needed|Status digest|Blocked|Completion):\s*(.+)$/i);if(a){const d=a[1].replace(/\b\w/g,p=>p.toUpperCase()),m=qc(a[2]);return{kind:"company_event",label:d,summary:m,tone:/^Blocked$/i.test(a[1])?"warning":"info"}}const u=t.match(/^NO_DELEGATION_JUSTIFICATION:\s*(.+)$/i);return u?{kind:"company_event",label:"Delegation check",summary:qc(u[1]).slice(0,180),tone:"info"}:null}function xF(e,t){const{isCompanyRuntime:n,detailMode:r}=t;if(!n||r==="full"||Qc(e.metadata))return null;const i=vI(e.content);if(!i)return null;const o=e.sender==="system"||e.metadata?.type==="system",a=i.kind==="company_event"||e.content.startsWith("[Company:");return!o&&!a?null:{msg:e,classification:i}}function yF(e,t={}){const{isCompanyRuntime:n=!1,detailMode:r="summary"}=t,i=[];let o=[],a=0;const u=new Set,d=new Set,m=()=>{if(o.length===0)return;const p=o[0].msg,h=o[o.length-1].msg;i.push({kind:"ops-bundle",id:`ops:${p.id}:${o.length}:${h.id}`,timestamp:p.timestamp,events:o,sortOrder:a}),o=[]};return e.forEach((p,h)=>{const g=h*2+1,y=xF(p,{isCompanyRuntime:n,detailMode:r});if(y){o.length===0&&(a=g),o.push(y);return}const v=r==="summary"?yI(p.content):null;if(v){const k=[p.sender,Math.round(p.timestamp/1e3),v.kind,qc(v.summary||v.acceptanceSummary||"").slice(0,500),v.verdict??"",v.deliverables.map(S=>`${S.name}:${S.path}`).join("|").slice(0,800)].join("");if(u.has(k))return;u.add(k)}if(r==="summary"){const k=qc(oF(p.content)).slice(0,1200);if(k){const S=aF(p)?["result",k].join(""):[p.sender,Math.round(p.timestamp/1e3),k].join("");if(d.has(S))return;d.add(S)}}m(),i.push({kind:"message",id:p.id,timestamp:p.timestamp,msg:p,sortOrder:g})}),m(),i}const vF=St.memo(function({msg:t,showDate:n,dateStr:r,classification:i}){const[o,a]=j.useState(!1),u=t.content.trim()!==`[${i.label}] ${i.summary}`.trim()&&t.content.trim().length>i.summary.length+4;return c.jsxs("div",{children:[n&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("span",{children:r})}),c.jsxs("div",{className:`msg-ops-row msg-ops-tone-${i.tone}${o?" expanded":""}`,onClick:u?()=>a(d=>!d):void 0,role:u?"button":void 0,tabIndex:u?0:-1,children:[c.jsx("span",{className:"msg-ops-dot","aria-hidden":"true"}),c.jsx("span",{className:"msg-ops-label",children:i.label}),i.summary&&c.jsx("span",{className:"msg-ops-summary",title:i.summary,children:i.summary}),c.jsx("span",{className:"msg-ops-time",title:Xi(t.timestamp),children:Ss(t.timestamp)}),u&&c.jsx("span",{className:`msg-ops-chevron${o?" open":""}`,"aria-hidden":"true",children:c.jsx(qi,{down:o})})]}),u&&o&&c.jsx("div",{className:"msg-ops-details",children:c.jsx("pre",{className:"msg-ops-details-pre",children:t.content})})]})}),bF=St.memo(function({events:t,showDate:n,dateStr:r}){const[i,o]=j.useState(!1);if(t.length===0)return null;const a=t[0].msg,u=t[t.length-1].msg,d=t.reduce((h,g)=>{const y=g.classification.kind==="company_event"?"company":g.classification.kind.startsWith("external")?"runtime":"delegation";return h[y]=(h[y]??0)+1,h},{}),m=Object.entries(d).map(([h,g])=>`${g} ${h}`).join(" · "),p=`${t.length} technical event${t.length===1?"":"s"} hidden`;return c.jsxs("div",{children:[n&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("span",{children:r})}),c.jsxs("button",{type:"button",className:`msg-ops-bundle${i?" expanded":""}`,onClick:()=>o(h=>!h),title:`${Xi(a.timestamp)} - ${Xi(u.timestamp)}`,children:[c.jsx("span",{className:"msg-ops-bundle-dot"}),c.jsx("span",{className:"msg-ops-bundle-title",children:p}),c.jsx("span",{className:"msg-ops-bundle-summary",children:m}),c.jsx("span",{className:"msg-ops-bundle-time",children:Ss(a.timestamp)}),c.jsx("span",{className:"msg-ops-bundle-chevron",children:c.jsx(qi,{down:i})})]}),i&&c.jsx("div",{className:"msg-ops-bundle-details",children:t.map(({msg:h,classification:g})=>c.jsxs("div",{className:`msg-ops-bundle-event msg-ops-tone-${g.tone}`,children:[c.jsx("span",{className:"msg-ops-dot"}),c.jsx("span",{className:"msg-ops-label",children:g.label}),c.jsx("span",{className:"msg-ops-summary",children:g.summary}),c.jsx("span",{className:"msg-ops-time",title:Xi(h.timestamp),children:Ss(h.timestamp)})]},h.id))})]})});function _F(e){return e.kind==="review"?`Review · ${e.verdict?e.verdict.replace(/_/g," "):"review"}`:e.kind==="report"?"Report":"Update"}const kF=St.memo(function({msg:t,payload:n,showDate:r,dateStr:i,isCopied:o,onCopy:a}){const u=lv(t.sender==="system"?t.senderName||"OPC":t.sender),d=t.senderDeleted?"[Deleted]":t.senderName,m=_F(n),p=n.summary||n.acceptanceSummary||m;return c.jsxs("div",{children:[r&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("spa Line truncated
Set up at least one role before running a task.
Go to Org tab now?`)&&n?.(),!1;if(a.length>1&&!u)return confirm(`Your organization has multiple top-level roles but no final decider selected.
Choose one final decider in the Org tab before running a task.
Go to Org tab now?`)&&n?.(),!1;const d=[],m=new Set(r.map(y=>y.role_id));o.runtimeTeams.filter(y=>y.member_role_ids.some(v=>m.has(v))||y.manager_role_id&&m.has(y.manager_role_id)).length===0&&d.push("No runtime teams defined — the system will auto-generate from your roles");const h=new Set(i.map(y=>y.role_id)),g=r.filter(y=>!h.has(y.role_id));if(g.length>0){const y=g.map(v=>v.name).join(", ");d.push(`${g.length} role(s) have no employees: ${y}`)}return d.length>0?confirm(`Before running this task:
`+d.map(y=>"• "+y).join(`
`)+`
Run anyway?`):!0}function tV(e){if(!e)return!1;const t=Em(e);return!!(t.projectRun?.run_id||t.runtimeTeams.length>0||t.runtimeSeats.length>0)}function rC(e,t){const n=!!t?.childDetail;return e?n?"full":e.execMode==="company"||e.execMode==="org"||e.execMode==="custom"?"summary":"full":"summary"}function iC(e){return String(e?.originTaskId??e?.taskId??"").trim()||null}function nV({boardColor:e,title:t,onCommit:n}){const[r,i]=j.useState(!1),[o,a]=j.useState(t),u=j.useRef(null);j.useEffect(()=>{r||a(t)},[t,r]);const d=j.useCallback(()=>{const p=o.trim();p&&p!==t?n(p):a(t),i(!1)},[o,t,n]),m=j.useCallback(()=>{a(t),i(!0),setTimeout(()=>u.current?.select(),0)},[t]);return c.jsx("div",{className:"board-selector",children:c.jsx("div",{className:"board-tabs",children:c.jsxs("span",{className:"board-tab active board-tab-editable",style:{"--board-color":e},children:[c.jsx("span",{className:"board-tab-dot",style:{background:e}}),r?c.jsx("input",{ref:u,className:"board-tab-title-input",value:o,onChange:p=>a(p.target.value),onBlur:d,onKeyDown:p=>{p.key==="Enter"&&d(),p.key==="Escape"&&(a(t),i(!1))}}):c.jsx("span",{className:"board-tab-title",onClick:m,title:"Click to edit session title",children:t})]})})})}function rV({boardStore:e,agents:t,officeMap:n,execMode:r,companyProfile:i,taskPreferredAgent:o,chatStore:a,sessionStore:u,projectId:d,onRunTask:m,onCreateTask:p,onMoveTask:h,onCreateSession:g,onSessionSend:y,onSecretarySend:v,onDeleteSession:k,onTitleChange:S,onSessionConfigChange:_,onSessionTaskAgentChange:w,onContinueInNewChat:C,onSessionStop:N,onSessionResume:O,onSessionComplete:I,onLoadSessionDetail:D,onOpenExecutionPanel:T,onCollabSync:L,orgInfoData:A,onNavigateToOrg:M,recoveryStatus:$,onRecoveryResume:W,onRecoveryCancel:B,commsState:U,commsMessage:H,onCommsRefresh:V,onCommsReadMessage:Y,savedOrgsList:Z,activeSavedOrg:q,onSavedOrgsList:G,onSavedOrgLoad:J}){const{sessions:P,activeSessionId:X,activeSession:ee}=u,[te,re]=j.useState("collapsed"),{width:oe,isResizing:de,handleMouseDown:se}=QF({initialWidth:380,minWidth:300,maxWidth:600,onCollapse:()=>re("collapsed")}),[je,we]=j.useState("chat"),[Ce,Be]=j.useState(null),[Ge,Ye]=j.useState({kind:"activity"}),[yt,Vt]=j.useState([]),[bt,vt]=j.useState(!1),[me,Oe]=j.useState({}),rt=j.useRef(D),Qe=j.useRef({active:null,child:null}),Je=r==="company"||r==="org"||r==="custom",fe=`secretary:${d}`,be=`activity:${d}`,Me=j.useMemo(()=>Ce?P.find(ue=>ue.taskId===Ce)??null:null,[P,Ce]),Fe=j.useMemo(()=>Ge.kind!=="task-detail"?null:e.tasks.find(ue=>ue.id===Ge.taskId)??null,[Ge,e.tasks]),$e=j.useMemo(()=>{const ue=jm(Fe);return ue?P.find(Se=>Se.taskId===ue||Se.runtimeTaskId===ue||Se.executionTurnId===ue)??null:null},[P,Fe]),Ut=j.useMemo(()=>$e?a.getChannelMessages($e.channelId):[],[a.messages,a.getChannelMessages,$e]),rn=j.useMemo(()=>gf(ee,P),[P,ee]),ke=j.useMemo(()=>Tf(ee,P),[P,ee]),Te=j.useMemo(()=>Rf(ee,[...ke,...rn]),[ee,rn,ke]);j.useEffect(()=>{rt.current=D},[D]);const Pe=j.useCallback((ue,Se,Ue="summary")=>{const ft=rt.current;!ft||!ue||(Oe(Yt=>Yt[ue]?Yt:{...Yt,[ue]:!0}),ft(ue,{limit:JF,beforeCreatedAt:Se?.timestamp,beforeMessageId:Se?.id,detailLevel:Ue}),window.setTimeout(()=>{Oe(Yt=>Yt[ue]?{...Yt,[ue]:!1}:Yt)},800))},[]),Ve=j.useCallback(ue=>!!me[ue],[me]);j.useEffect(()=>{Qe.current={active:null,child:null}},[d]),j.useEffect(()=>{Ce&&!Me&&Be(null)},[Ce,Me]),j.useEffect(()=>{Ge.kind==="task-detail"&&!Fe&&Ye({kind:"activity"})},[Ge,Fe]);const qe=j.useRef(null);j.useEffect(()=>{if(!$e){qe.current=null;return}qe.current!==$e.taskId&&(qe.current=$e.taskId,Pe($e.taskId,void 0,"full"))},[$e,Pe]),j.useEffect(()=>{if(!Ce){Qe.current.child=null;return}Qe.current.child!==Ce&&(Qe.current.child=Ce,Pe(Ce,void 0,"full"))},[Ce,Pe]),j.useEffect(()=>{if(!X){Qe.current.active=null;return}const ue=Te.timelineSessions.length>0?Te.timelineSessions:P.find(Ue=>Ue.taskId===X)?[P.find(Ue=>Ue.taskId===X)]:[];if(ue.length===0){Qe.current.active=null;return}const Se=ue.map(Ue=>`${Ue.taskId}:${rC(Ue,{childDetail:Ue.mode==="child"})}`).join("|");if(Qe.current.active!==Se){Qe.current.active=Se;for(const Ue of ue)Pe(Ue.taskId,void 0,rC(Ue,{childDetail:Ue.mode==="child"}))}},[Te.timelineSessions,X,Pe,P]);const et=j.useMemo(()=>Ce?{kind:"child-detail"}:Ge.kind==="task-detail"||Ge.kind==="secretary"?Ge:X?{kind:"session",taskId:X}:{kind:"activity"},[Ge,X,Ce]),Mn=j.useMemo(()=>et.kind==="secretary"?fe:et.kind==="child-detail"&&Me?Me.channelId:et.kind==="session"&&Te.displaySession?Te.displaySession.channelId:et.kind==="session"&&ee?ee.channelId:be,[et,Te.displaySession,ee,Me,fe,be]),Tn=j.useMemo(()=>{if(et.kind==="activity")return[be];if(et.kind==="secretary")return[fe];if(et.kind==="child-detail"&&Me)return[Me.channelId];if(et.kind==="session"){const ue=Te.timelineSessions.map(Se=>Se.channelId).filter((Se,Ue,ft)=>!!Se&&ft.indexOf(Se)===Ue);if(ue.length>0)return ue}return Mn?[Mn]:[]},[et.kind,Te.timelineSessions,Me,be,fe,Mn]),Dn=j.useMemo(()=>{const ue=new Set;for(const Se of P)Se.status!=="cancelled"&&ue.add(Se. Line truncated
`).replace(/\r/g,`
`).split(`
`).map(i=>i.trimEnd()).join(`
`).replace(/\n{3,}/g,`
`).trim(),n=sV(t),r=n.split(/\n{2,}/).map(i=>i.trim()).filter(Boolean);return r.length>1&&/^Verification:\s/i.test(r[r.length-1])?r.slice(0,-1).join(`
`).trim():n}function sV(e){const t=String(e||"").trim(),n=t.match(/^\*\*(.{8,160}?)\*\*:\s+([\s\S]+)$/);if(n){const a=n[2].trim();if(a.length>=80)return a}const r=t.indexOf(": ");if(r<8||r>160)return t;const i=t.slice(0,r).replace(/\*/g,"").trim(),o=t.slice(r+2).trim();return o.length<80||!/[A-Za-z\u4e00-\u9fff]/.test(i)||/^(https?|file)$/i.test(i)?t:o}function qo(e){const t=Go(e),n=new Set,r=typeof t.checkpoint_type=="string"?t.checkpoint_type.trim():"",i=typeof t.checkpoint_id=="string"?t.checkpoint_id.trim():"";for(const o of[e.id,typeof t.ui_message_id=="string"?t.ui_message_id:"",r&&i?`checkpoint:${r}:${i}`:""]){const a=String(o??"").trim();a&&n.add(a)}return n}function oV(e){return e.startsWith("checkpoint:")}function Wi(e){return typeof e.timestamp=="number"?e.timestamp:0}function oC(e){const t=String(e.sender??"").trim().toLowerCase(),n=Go(e),r=typeof n.role=="string"?n.role.trim().toLowerCase():"";return t==="user"||r==="user"?"user":"assistant"}function aC(e){const t=Go(e),n=String(e.sender??"").trim().toLowerCase();let r=0;const i=SI(e);return i&&(r+=1e3+i),t.source==="engine"&&(r+=100),n&&n!=="system"&&(r+=20),n&&!["assistant","system","user"].includes(n)&&(r+=5),e.replyToId&&(r+=2),r+=Math.min(Object.keys(t).length,10),r}function lC(e){return String(Go(e).source??"").trim().toLowerCase()==="engine"}function SI(e){const t=Go(e),n=String(t.transcript_kind??"").trim();if(n)return sC[n]??0;const r=String(t.kind??"").trim();return sC[r]??0}function Zf(e){return SI(e)>0}function wI(e,t){if(e.channelId!==t.channelId)return!1;const n=qo(e),r=qo(t);for(const i of n)if(r.has(i))return!0;return!1}function Gy(e,t){if(wI(e,t))return!0;if(e.channelId!==t.channelId||oC(e)!==oC(t)||Kf(e.content)!==Kf(t.content))return!1;const n=Zf(e)&&Zf(t);if(!n&&String(e.replyToId??"")!==String(t.replyToId??"")||!(lC(e)||lC(t)))return!1;const r=Wi(e),i=Wi(t);return!(!n&&r&&i&&Math.abs(r-i)>dv)}function qy(e,t,n=!1){let r=e,i=t;(n||aC(t)>aC(e))&&(r=t,i=e);const o=[];for(const h of[i.mentions,r.mentions])for(const g of h??[])o.includes(g)||o.push(g);const a=qo(e),u=qo(t);let d="";for(const h of a)if(u.has(h)&&!oV(h)){d=h;break}const m=Kf(r.content),p=m&&m===Kf(i.content)?m:r.content;return{...i,...r,...d?{id:d}:{},content:p,metadata:{...Go(i),...Go(r)},mentions:o,timestamp:Wi(r)||Wi(i)}}function Qg(e){const t=[],n=new Map;for(const r of[...e].sort((i,o)=>Wi(i)-Wi(o))){const i=qo(r);let o=-1,a=!1;for(const d of i){const m=n.get(d);if(m!==void 0){o=m,a=t[m].id===r.id;break}}if(o===-1){const d=Wi(r),m=Zf(r);for(let p=t.length-1;p>=0;p--){const h=Wi(t[p]);if(!m&&d>0&&h>0&&d-h>dv)break;if(Gy(t[p],r)){o=p;break}}}const u=o===-1?t.length:o;o===-1?t.push(r):t[o]=qy(t[o],r,a);for(const d of qo(t[u]))n.has(d)||n.set(d,u)}return t}function aV(e,t){switch(t.type){case"SET":return t.channels;case"CLEAR":return[];case"ADD":return e.some(n=>n.id===t.channel.id)?e:[...e,t.channel];case"REMOVE":return e.filter(n=>n.id!==t.channelId);case"REMOVE_PARTICIPANT":return e.map(n=>({...n,participants:n.participants.filter(r=>r!==t.agentId)}));default:return e}}function lV(e,t){switch(t.type){case"SET":{const n=Qg(t.messages);if(e.length===0)return n;const r=e.filter(i=>typeof i.id=="string"&&i.id.startsWith("msg-")&&!n.some(o=>Gy(i,o)));return r.length===0?n:Qg([...n,...r])}case"CLEAR":return[];case"ADD":{const n=Wi(t.message);qo(t.message);let r=!1;for(let i=e.length-1;i>=0;i--){const o=Wi(e[i]);if(!r&&n>0&&o>0&&n-o>dv&&(r=!0),wI(e[i],t.message)){const a=[...e];return a[i]=qy(e[i],t.message,e[i].id===t.message.id),a}if((Zf(t.message)||!r)&&Gy(e[i],t.message)){const a=[...e];return a[i]=qy(e[i],t.message),a}}return[...e,t.message]}case"MERGE":return t.messages.length===0?e:Qg([...e,...t.messages]);case"MARK_SENDER_DELETED":return e.map(n=>n.sender===t.senderId?{...n,senderDeleted:!0,senderName:"[已删除的 Agent]"}:n);case"REMOVE_BY_CHANNEL":return e.filter(n=>n.channelId!==t.channelId);case"REMOVE_BY_TASK_ID":return e.filter(n=>n.channelId!==`session:${t.taskId}`&&n.metadata?.task_id!==t.taskId);default:return e}}function cV(){const[e,t]=j.useReducer(aV,[]),[n,r]=j.useReducer(lV,[]),[i,o]=j.useState({}),[a,u]=j.useState("default"),d=j.useMemo(()=>{const I={};for(const D of n)I[D.channelId]||(I[D.channelId]=[]),I[D.channelId].push(D);return I},[n]),m=j.useMemo(()=>{const I={};for(const D of n){if(D.sender==="user")continue;const T=i[D.channelId]??0;D.timestamp<=T||(I[D.channelId]=(I[D.channelId]??0)+1)}return I},[n,i]),p=j.useCallback(I=>{const D={id:`msg-${iV()}`,channelId:I.channelId,sender:I.sender,senderName:I.senderName,content:I.content,timestamp:Date.now(),replyToId:I.replyToId,mentions:[],metadata:I.metadata};return r({type:"ADD",message:D}),D},[]),h=j.useCallback(I=>d[I]??[],[d]),g=j.useCallback(I=>m[I]??0,[m]),y=j.useCallback(I=>{o(D=>({...D,[I]:Date.now()}))},[]),v=j.useCallback(I=>{r({type:"MARK_SENDER_DELETED",senderId:I})},[]),k=j.useCallback(I=>{t({type:"REMOVE_PARTICIPANT",agentId:I})},[]),S=j.useCallback(I=>{t({type:"REMOVE",channe Line truncated
${t}`:`${e}${t}`}function uV(e,t){const n=e.trim().replace(/\s+/g," ");return n?n.length>120?`${n.slice(0,120).trimEnd()}...`:n:t||"Thinking"}function dV(e){return{timestamp:Number.isFinite(e.timestamp)?e.timestamp:Date.now(),type:e.type,summary:typeof e.summary=="string"?e.summary:"",detail:typeof e.detail=="string"&&e.detail?e.detail:void 0,turnId:typeof e.turnId=="string"&&e.turnId?e.turnId:void 0,itemId:typeof e.itemId=="string"&&e.itemId?e.itemId:void 0,streamId:typeof e.streamId=="string"&&e.streamId?e.streamId:void 0,toolCallId:typeof e.toolCallId=="string"&&e.toolCallId?e.toolCallId:void 0,permissionGroupKey:typeof e.permissionGroupKey=="string"&&e.permissionGroupKey?e.permissionGroupKey:void 0,seq:typeof e.seq=="number"&&Number.isFinite(e.seq)?e.seq:void 0,executionMode:typeof e.executionMode=="string"&&e.executionMode?e.executionMode:void 0}}function Qf(e){const t=e.itemId||e.streamId;return t?`${e.type}:${e.turnId??""}:${t}`:e.toolCallId&&(e.type==="tool_call"||e.type==="autonomy")?`${e.type}:${e.turnId??""}:${e.toolCallId}`:e.permissionGroupKey&&e.type==="autonomy"?`${e.type}:${e.turnId??""}:${e.permissionGroupKey}`:""}function fV(e,t){const n=Qf(e),r=Qf(t);return n&&r?n===r:t.timestamp-e.timestamp>Mm||e.type!==t.type?!1:e.type==="thinking"?!0:e.type==="tool_call"?e.summary===t.summary:!1}function mV(e,t){return t.timestamp-e.timestamp<=Mm&&e.type===t.type&&e.summary===t.summary&&(e.detail??"")===(t.detail??"")}function hV(e,t){if(e.type==="thinking"){const n=Wy(e.detail??"",t.detail??"","thinking");return{timestamp:t.timestamp,type:"thinking",summary:uV(n,t.summary||e.summary),detail:n||void 0,turnId:t.turnId??e.turnId,itemId:t.itemId??e.itemId,streamId:t.streamId??e.streamId,toolCallId:t.toolCallId??e.toolCallId,permissionGroupKey:t.permissionGroupKey??e.permissionGroupKey,seq:t.seq??e.seq,executionMode:t.executionMode??e.executionMode}}if(e.type==="tool_call"){const n=Wy(e.detail??"",t.detail??"","tool_call");return{timestamp:t.timestamp,type:"tool_call",summary:t.summary||e.summary,detail:n||void 0,turnId:t.turnId??e.turnId,itemId:t.itemId??e.itemId,streamId:t.streamId??e.streamId,toolCallId:t.toolCallId??e.toolCallId,permissionGroupKey:t.permissionGroupKey??e.permissionGroupKey,seq:t.seq??e.seq,executionMode:t.executionMode??e.executionMode}}return t}function CI(e,t,n=100){const r=dV(t),i=Qf(r),o=i?[...e].reverse().findIndex(d=>Qf(d)===i):-1,a=o>=0?e.length-1-o:e.length-1,u=e[a];return u?i&&typeof u.seq=="number"&&typeof r.seq=="number"&&r.seq<=u.seq?e:mV(u,r)?tl([...e.slice(0,a),{...u,timestamp:r.timestamp},...e.slice(a+1)],n):fV(u,r)?tl([...e.slice(0,a),hV(u,r),...e.slice(a+1)],n):tl([...e,r],n):[r]}function jI(e,t=100){return(Array.isArray(e)?e:[]).reduce((n,r)=>CI(n,r,t),[])}function pV(e){return{timestamp:Number.isFinite(e.timestamp)?e.timestamp:Date.now(),type:e.type,workItemProjectionId:typeof e.workItemProjectionId=="string"&&e.workItemProjectionId?e.workItemProjectionId:void 0,workItemTurnType:typeof e.workItemTurnType=="string"&&e.workItemTurnType?e.workItemTurnType:void 0,workItemProjectionTitle:typeof e.workItemProjectionTitle=="string"&&e.workItemProjectionTitle?e.workItemProjectionTitle:void 0,runtimeTaskId:typeof e.runtimeTaskId=="string"&&e.runtimeTaskId?e.runtimeTaskId:void 0,executionTurnId:typeof e.executionTurnId=="string"&&e.executionTurnId?e.executionTurnId:void 0,roleName:typeof e.roleName=="string"&&e.roleName?e.roleName:void 0,detail:typeof e.detail=="string"&&e.detail?e.detail:void 0}}function EI(e,t){return e.type===t.type&&(e.workItemProjectionId??"")===(t.workItemProjectionId??"")&&(e.workItemTurnType??"")===(t.workItemTurnType??"")&&(e.workItemProjectionTitle??"")===(t.workItemProjectionTitle??"")&&(e.executionTurnId??e.runtimeTaskId??"")===(t.executionTurnId??t.runtimeTaskId??"")&&(e.roleName??"")===(t.roleName??"")}function gV(e,t){return t.timestamp-e.timestamp<=Mm&&EI(e,t)&&(e.type==="thinking"||e.type==="tool_call")}function xV(e,t){return EI(e,t)&&(e.detail??"")===(t.detail??"")&&t.timestamp-e.timestamp<=Mm}function yV(e,t){const n=t.type==="tool_call"?"tool_call":"thinking";return{...e,...t,timestamp:t.timestamp,detail:Wy(e.detail??"",t.detail??"",n)||void 0}}function NI(e,t,n=100){const r=pV(t),i=e[e.length-1];return i?xV(i,r)?tl([...e.slice(0,-1),{...i,timestamp:r.timestamp}],n):gV(i,r)?tl([...e.slice(0,-1),yV(i,r)],n):tl([...e,r],n):[r]}function II(e,t=100){return(Array.isArray(e)?e:[]).reduce((n,r)=>NI(n,r,t),[])}function Yy(e){const t=String(e??"").trim().toLowerCase();return t==="company"?"company":t==="org"||t==="custom"?"org":"task"}function vV(e){return String(e??"").trim().toLowerCase()==="custom"?"custom":"corporate"}function TI(e){const t=String(e.execMode??"").trim().toLowerCase(),n=String(e.companyProfile??"").trim().toLowerCase(),r=String(e.orgId??"").trim(),o=t.length>0?Yy(t):n==="custom"||r?"org":Yy(t);return o==="org"?{...e,execMode:"org",companyProfile:"custom",orgId:r||void 0}:o==="company"?{...e,execMode:"company",companyProfile:"co Line truncated
`)),[L,A]=j.useState(!1),M=j.useRef(e.role_id);j.useEffect(()=>{M.current!==e.role_id&&(M.current=e.role_id,d(e.name),p(e.responsibility),g(e.reports_to),v(e.icon??null),S(new Set(e.can_spawn)),w(new Set(e.tools)),N(e.runtime_policy?.execution_strategy??"auto"),I(e.preferred_external_agent??null),T((e.prompt_refs??[]).join(`
`)),A(!1))},[e]);const $=j.useRef({}),W=j.useRef(null),B=j.useRef(e.role_id);j.useEffect(()=>{B.current=e.role_id},[e.role_id]);const U=j.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null);const se=$.current;$.current={},Object.keys(se).length!==0&&i(B.current,se)},[i]),H=j.useCallback(se=>{r||($.current={...$.current,...se},W.current&&clearTimeout(W.current),W.current=setTimeout(U,500))},[U,r]);j.useEffect(()=>()=>{W.current&&(clearTimeout(W.current),W.current=null);const se=$.current;Object.keys(se).length>0&&($.current={},i(B.current,se))},[i]);const V=se=>{d(se),H({name:se})},Y=se=>{p(se),H({responsibility:se})},Z=se=>{g(se),H({reports_to:se})},q=se=>{v(se),H({icon:se})},G=se=>{N(se),H({execution_strategy:se})},J=se=>{I(se),H({preferred_external_agent:se})},P=se=>{T(se);const je=se.split(`
`).map(we=>we.trim()).filter(Boolean);H({prompt_refs:je})},X=se=>{const je=new Set(k);je.has(se)?je.delete(se):je.add(se),S(je),H({can_spawn:Array.from(je)})},ee=se=>{const je=new Set(_);je.has(se)?je.delete(se):je.add(se),w(je),H({tools:Array.from(je)})},te=j.useMemo(()=>t.filter(se=>se.role_id!==e.role_id),[t,e.role_id]),re=j.useMemo(()=>n.filter(se=>(se.role_ids?.length?se.role_ids:[se.role_id]).includes(e.role_id)).length,[n,e.role_id]),oe=j.useMemo(()=>D.split(`
`).filter(se=>se.trim()).length,[D]),de=()=>{if(!L){A(!0);return}U(),o(e.role_id)};return c.jsxs("aside",{className:"ri-panel","aria-label":`Inspector for role ${e.name}`,children:[c.jsxs("header",{className:"ri-panel-header",children:[c.jsx("img",{src:wu(y),alt:"",className:"ri-panel-icon"}),c.jsxs("div",{className:"ri-panel-title-wrap",children:[c.jsx("h3",{className:"ri-panel-title",children:u||"(unnamed)"}),c.jsx("code",{className:"ri-panel-id",children:e.role_id})]}),c.jsx("button",{className:"btn btn-ghost btn-sm ri-panel-close",onClick:a,title:"Close (Esc)",children:"✕"})]}),c.jsxs("div",{className:"ri-panel-body",children:[c.jsxs(Ha,{title:"Identity",defaultExpanded:!0,children:[c.jsx(gi,{label:"Name",children:c.jsx("input",{className:"ri-text-input",value:u,onChange:se=>V(se.target.value),disabled:r})}),c.jsx(gi,{label:"Responsibility",children:c.jsx("textarea",{className:"ri-textarea",rows:3,value:m,onChange:se=>Y(se.target.value),disabled:r})}),c.jsx(gi,{label:"Icon",children:c.jsx(GV,{value:y,onChange:q,readOnly:r})})]}),c.jsxs(Ha,{title:"Hierarchy",defaultExpanded:!0,children:[c.jsx(gi,{label:"Reports to",children:c.jsxs("select",{className:"ri-select",value:h,onChange:se=>Z(se.target.value),disabled:r,children:[c.jsx("option",{value:"owner",children:"You (Owner)"}),te.map(se=>c.jsx("option",{value:se.role_id,children:se.name},se.role_id))]})}),c.jsx(gi,{label:"Can delegate to",children:c.jsx(qV,{allIds:te.map(se=>se.role_id),labelFor:se=>te.find(je=>je.role_id===se)?.name??se,selected:k,onToggle:X,readOnly:r})}),c.jsx(gi,{label:"Employees assigned",children:c.jsx("span",{className:"ri-meta-value",children:re})})]}),c.jsx(Ha,{title:`Tools (${_.size})`,children:c.jsx(WV,{tools:_,onToggle:ee,readOnly:r})}),c.jsx(Ha,{title:`Prompts (${oe})`,children:c.jsx(gi,{label:"Prompt refs / inline",children:c.jsx("textarea",{className:"ri-textarea ri-textarea-mono",rows:5,placeholder:"One prompt ref or inline instruction per line",value:D,onChange:se=>P(se.target.value),disabled:r})})}),c.jsxs(Ha,{title:"Runtime policy",children:[c.jsx(gi,{label:"Execution strategy",children:c.jsx("div",{className:"ri-radio-group",children:VV.map(se=>c.jsxs("label",{className:"ri-radio",title:se.hint,children:[c.jsx("input",{type:"radio",name:`exec-strategy-${e.role_id}`,value:se.value,checked:C===se.value,onChange:()=>G(se.value),disabled:r}),se.label]},se.value))})}),C==="external"&&c.jsx(gi,{label:"Preferred external agent",children:c.jsxs("select",{className:"ri-select",value:O??"",onChange:se=>J(se.target.value||null),disabled:r,children:[c.jsx("option",{value:"",children:"(any)"}),FV.map(se=>c.jsx("option",{value:se,children:se},se))]})})]}),c.jsxs(Ha,{title:"Advanced",children:[c.jsx(gi,{label:"Role type",children:c.jsx("span",{className:"ri-meta-value",children:e.role_type??"worker"})}),c.jsx(gi,{label:"Skills",children:c.jsx("span",{className:"ri-meta-value",children:e.skill_refs&&e.skill_refs.length>0?e.skill_refs.join(", "):"(none)"})}),c.jsx(gi,{label:"Artifact contract",children:c.jsx("span",{className:"ri-meta-value",children:e.artifact_contract_ref??"(none)"})})]})]}),!r&&c.jsx("footer",{className:"ri-panel-footer",children:c.jsx("button",{className:`btn btn-sm ${L?"btn-danger":"btn-ghost"}`,onClick:de,onBlur:()=>A(!1),children:L?"Confirm delete?":"Delete role"})})]})}function Ha({title:e,defaultExpanded:t=!1,children:n}){const[r,i]=j.useState(t);return c.jsxs("section",{className:`ri-group${r?" is-expanded":""}`,children:[c.jsxs("button",{className:"ri-group-header",onClick:()=>i(o=>!o),children:[c.jsx("span",{className:"ri-group-caret",children:r?"▾":"▸"}),c.jsx("span",{className:"ri-group-title",children:e})]}),r&&c.jsx("div",{className:"ri-group-body",children:n})]})}function gi({label:e,children:t}){return c.jsxs("div",{className:"ri-field",children:[c.jsx("label",{className:"ri-field-label",children:e}),c.jsx("div",{className:"ri-field-control",children:t})]})}function GV({value:e,onChange:t,readOnly:n}){const[r,i]=j.useState(!1);return c.jsxs("div",{className:"ri-icon-picker",children:[c.jsxs("button",{className:"ri-icon-picker-trigger",onClick:()=>!n&&i(o=>!o),disabled:n,children:[c.jsx("img",{src:wu(e),alt:"",className:"ri-icon-picker-current"}),c.jsx("span",{className:"ri-icon-picker-label",children:e??"generic"})]}),r&&c.jsxs("div",{className:"ri-icon-picker-popover",children:[c.jsx("button",{className:`ri-icon-option${e===null?" is-active":""}`,onClick:()=>{t(null),i(!1)},title:"Default icon",children:c.jsx("img",{src:Wc.generic,alt:""})}),$V.filter(o=>o!=="generic").map(o=>c.jsx("button",{className:`ri-icon-option${e===o?" is-active":""}`,onClick:()=>{t(o),i(!1)},title:o,children:c.jsx("img",{src:Wc[o],alt:o})},o))]})]})}function qV({allIds:e,labelFor:t,selected:n,onToggle:r,readOnly:i}){const[o,a]=j.useState(!1),u=e.filter(d=>!n.has(d));return c.jsxs("div",{className:"ri-multiselect",children:[c.jsxs("div",{className:"ri-chips",children:[Array.from(n).map(d=>c.jsxs("span",{className:"ri-ch Line truncated
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,n?.key)}return i}}function xt(e,t,n,r){return{debug:()=>{var i;return(i=e?.debugAll)!=null?i:e[t]},key:!1,onChange:r}}function KV(e,t,n,r){const i=()=>{var a;return(a=o.getValue())!=null?a:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:i,getContext:gt(()=>[e,n,t,o],(a,u,d,m)=>({table:a,column:u,row:d,cell:m,getValue:m.getValue,renderValue:m.renderValue}),xt(e.options,"debugCells"))};return e._features.forEach(a=>{a.createCell==null||a.createCell(o,n,t,e)},{}),o}function ZV(e,t,n,r){var i,o;const u={...e._getDefaultColumnDef(),...t},d=u.accessorKey;let m=(i=(o=u.id)!=null?o:d?typeof String.prototype.replaceAll=="function"?d.replaceAll(".","_"):d.replace(/\./g,"_"):void 0)!=null?i:typeof u.header=="string"?u.header:void 0,p;if(u.accessorFn?p=u.accessorFn:d&&(d.includes(".")?p=g=>{let y=g;for(const k of d.split(".")){var v;y=(v=y)==null?void 0:v[k]}return y}:p=g=>g[u.accessorKey]),!m)throw new Error;let h={id:`${String(m)}`,accessorFn:p,parent:r,depth:n,columnDef:u,columns:[],getFlatColumns:gt(()=>[!0],()=>{var g;return[h,...(g=h.columns)==null?void 0:g.flatMap(y=>y.getFlatColumns())]},xt(e.options,"debugColumns")),getLeafColumns:gt(()=>[e._getOrderColumnsFn()],g=>{var y;if((y=h.columns)!=null&&y.length){let v=h.columns.flatMap(k=>k.getLeafColumns());return g(v)}return[h]},xt(e.options,"debugColumns"))};for(const g of e._features)g.createColumn==null||g.createColumn(h,e);return h}const _r="debugHeaders";function mC(e,t,n){var r;let o={id:(r=n.id)!=null?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const a=[],u=d=>{d.subHeaders&&d.subHeaders.length&&d.subHeaders.map(u),a.push(d)};return u(o),a},getContext:()=>({table:e,header:o,column:t})};return e._features.forEach(a=>{a.createHeader==null||a.createHeader(o,e)}),o}const QV={createTable:e=>{e.getHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{var o,a;const u=(o=r?.map(h=>n.find(g=>g.id===h)).filter(Boolean))!=null?o:[],d=(a=i?.map(h=>n.find(g=>g.id===h)).filter(Boolean))!=null?a:[],m=n.filter(h=>!(r!=null&&r.includes(h.id))&&!(i!=null&&i.includes(h.id)));return Jd(t,[...u,...m,...d],e)},xt(e.options,_r)),e.getCenterHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(o=>!(r!=null&&r.includes(o.id))&&!(i!=null&&i.includes(o.id))),Jd(t,n,e,"center")),xt(e.options,_r)),e.getLeftHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var i;const o=(i=r?.map(a=>n.find(u=>u.id===a)).filter(Boolean))!=null?i:[];return Jd(t,o,e,"left")},xt(e.options,_r)),e.getRightHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var i;const o=(i=r?.map(a=>n.find(u=>u.id===a)).filter(Boolean))!=null?i:[];return Jd(t,o,e,"right")},xt(e.options,_r)),e.getFooterGroups=gt(()=>[e.getHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getLeftFooterGroups=gt(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getCenterFooterGroups=gt(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getRightFooterGroups=gt(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getFlatHeaders=gt(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getLeftFlatHeaders=gt(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getCenterFlatHeaders=gt(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getRightFlatHeaders=gt(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getCenterLeafHeaders=gt(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),xt(e.options,_r)),e.getLeftLeafHeaders=gt(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),xt(e.options,_r)),e.getRightLeafHeaders=gt(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),xt(e.options,_r)),e.getLeafHeaders=gt(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,r)=>{var i,o,a,u,d,m;return[...(i=(o=t[0])==null?void 0:o.headers)!=null?i:[],...(a=(u=n[0])==null?void 0:u.headers)!=null?a:[],...(d=(m=r[0])==null?void 0:m.headers)!=null?d:[]].map(p=>p.getLeafHeaders()).flat()},xt(e.options,_r))}};function Jd(e,t,n,r){var i,o;let a=0;const u=function(g,y){y===void 0&&(y=1),a=Math.max(a,y),g.filter(v=>v.getIsVisible()).forEach(v=>{var k;(k=v.columns)!=null&&k.length&&u(v.columns,y+1)},0)};u(e);let d=[];const m=(g,y)=>{const v={depth:y,id:[r,`${y}`].filter(Boolean).jo Line truncated
`).replace(`
`,`
+`).split(`
`)),p=m.reduce((h,g)=>h.concat(...g),[]);return[m,p]}return[[],[]]},[e]);return j.useEffect(()=>{const d=t?.target??s2,m=t?.actInsideInputWithModifier??!0;if(e!==null){const p=y=>{if(i.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!i.current||i.current&&!m)&&NT(y))return!1;const k=a2(y.code,u);if(o.current.add(y[k]),o2(a,o.current,!1)){const S=y.composedPath?.()?.[0]||y.target,_=S?.nodeName==="BUTTON"||S?.nodeName==="A";t.preventDefault!==!1&&(i.current||!_)&&y.preventDefault(),r(!0)}},h=y=>{const v=a2(y.code,u);o2(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(y[v]),y.key==="Meta"&&o.current.clear(),i.current=!1},g=()=>{o.current.clear(),r(!1)};return d?.addEventListener("keydown",p),d?.addEventListener("keyup",h),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{d?.removeEventListener("keydown",p),d?.removeEventListener("keyup",h),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,r]),n}function o2(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function a2(e,t){return t.includes(e)?"code":"key"}const XX=()=>{const e=In();return j.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,i,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:i,minZoom:o,maxZoom:a,panZoom:u}=e.getState(),d=wv(t,r,i,o,a,n?.padding??.1);return u?(await u.setViewport(d,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:i,snapToGrid:o,domNode:a}=e.getState();if(!a)return t;const{x:u,y:d}=a.getBoundingClientRect(),m={x:t.x-u,y:t.y-d},p=n.snapGrid??i,h=n.snapToGrid??o;return Tu(m,r,h,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:i,y:o}=r.getBoundingClientRect(),a=lm(t,n);return{x:a.x+i,y:a.y+o}}}),[])};function KT(e,t){const n=[],r=new Map,i=[];for(const o of e)if(o.type==="add"){i.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const a=r.get(o.id);a?a.push(o):r.set(o.id,[o])}for(const o of t){const a=r.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const u={...o};for(const d of a)KX(d,u);n.push(u)}return i.length&&i.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function KX(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 ZT(e,t){return KT(e,t)}function ZX(e,t){return KT(e,t)}function zo(e,t){return{id:e,type:"select",selected:t}}function Xa(e,t=new Set,n=!1){const r=[];for(const[i,o]of e){const a=t.has(i);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),r.push(zo(o.id,a)))}return r}function l2({items:e=[],lookup:t}){const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,o]of e.entries()){const a=t.get(o.id),u=a?.internals?.userNode??a;u!==void 0&&u!==o&&n.push({id:o.id,item:o,type:"replace"}),u===void 0&&n.push({item:o,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function c2(e){return{id:e.id,type:"remove"}}const u2=e=>bY(e),QX=e=>bT(e);function QT(e){return j.forwardRef(e)}function d2(e){const[t,n]=j.useState(BigInt(0)),[r]=j.useState(()=>JX(()=>n(i=>i+BigInt(1))));return m0(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function JX(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const JT=j.createContext(null);function eK({children:e}){const t=In(),n=j.useCallback(u=>{const{nodes:d=[],setNodes:m,hasDefaultNodes:p,onNodesChange:h,nodeLookup:g,fitViewQueued:y,onNodesChangeMiddlewareMap:v}=t.getState();let k=d;for(const _ of u)k=typeof _=="function"?_(k):_;let S=l2({items:k,lookup:g});for(const _ of v.values())S=_(S);p&&m(k),S.length>0?h?.(S):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:w,setNodes:C}=t.getState();_&&C(w)})},[]),r=d2(n),i=j.useCallback(u=>{const{edges:d=[],setEdges:m,hasDefaul Line truncated
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}CR.displayName="MiniMap";const HZ=j.memo(CR),FZ=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,VZ={[yl.Line]:"right",[yl.Handle]:"bottom-right"};function UZ({nodeId:e,position:t,variant:n=yl.Handle,className:r,style:i=void 0,children:o,color:a,minWidth:u=10,minHeight:d=10,maxWidth:m=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:g,autoScale:y=!0,shouldResize:v,onResizeStart:k,onResize:S,onResizeEnd:_}){const w=nR(),C=typeof e=="string"?e:w,N=In(),O=j.useRef(null),I=n===yl.Handle,D=Ft(j.useCallback(FZ(I&&y),[I,y]),Nn),T=j.useRef(null),L=t??VZ[n];j.useEffect(()=>{if(!(!O.current||!C))return T.current||(T.current=yX({domNode:O.current,nodeId:C,getStoreItems:()=>{const{nodeLookup:M,transform:$,snapGrid:W,snapToGrid:B,nodeOrigin:U,domNode:H}=N.getState();return{nodeLookup:M,transform:$,snapGrid:W,snapToGrid:B,nodeOrigin:U,paneDomNode:H}},onChange:(M,$)=>{const{triggerNodeChanges:W,nodeLookup:B,parentLookup:U,nodeOrigin:H}=N.getState(),V=[],Y={x:M.x,y:M.y},Z=B.get(C);if(Z&&Z.expandParent&&Z.parentId){const q=Z.origin??H,G=M.width??Z.measured.width??0,J=M.height??Z.measured.height??0,P={id:Z.id,parentId:Z.parentId,rect:{width:G,height:J,...jT({x:M.x??Z.position.x,y:M.y??Z.position.y},{width:G,height:J},Z.parentId,B,q)}},X=Tv([P],B,U,H);V.push(...X),Y.x=M.x?Math.max(q[0]*G,M.x):void 0,Y.y=M.y?Math.max(q[1]*J,M.y):void 0}if(Y.x!==void 0&&Y.y!==void 0){const q={id:C,type:"position",position:{...Y}};V.push(q)}if(M.width!==void 0&&M.height!==void 0){const G={id:C,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};V.push(G)}for(const q of $){const G={...q,type:"position"};V.push(G)}W(V)},onEnd:({width:M,height:$})=>{const W={id:C,type:"dimensions",resizing:!1,dimensions:{width:M,height:$}};N.getState().triggerNodeChanges([W])}})),T.current.update({controlPosition:L,boundaries:{minWidth:u,minHeight:d,maxWidth:m,maxHeight:p},keepAspectRatio:h,resizeDirection:g,onResizeStart:k,onResize:S,onResizeEnd:_,shouldResize:v}),()=>{T.current?.destroy()}},[L,u,d,m,p,h,k,S,_,v]);const A=L.split("-");return c.jsx("div",{className:Zn(["react-flow__resize-control","nodrag",...A,n,r]),ref:O,style:{...i,scale:D,...a&&{[I?"backgroundColor":"borderColor"]:a}},children:o})}j.memo(UZ);const GZ=j.memo(function({data:t}){const n=["oc-canvas-node",t.isOwner&&"is-owner",t.isSelected&&"is-selected",t.isDropTarget&&"is-drop-target"].filter(Boolean).join(" "),r=wu(t.icon);return c.jsxs("div",{className:n,children:[c.jsx(vl,{type:"target",position:at.Top,className:"oc-canvas-handle"}),c.jsxs("div",{className:"oc-canvas-node-row",children:[c.jsx("div",{className:"oc-canvas-node-chip",children:c.jsx("span",{className:"oc-canvas-node-chip-icon",style:{WebkitMaskImage:`url("${r}")`,maskImage:`url("${r}")`},"aria-hidden":!0})}),c.jsxs("div",{className:"oc-canvas-node-text",children:[c.jsx("span",{className:"oc-canvas-node-name",children:t.name}),c.jsxs("div",{className:"oc-canvas-node-meta",children:[t.employeeNames.length>0?c.jsxs("span",{className:"oc-canvas-node-person",title:t.employeeNames.join(", "),children:[t.employeeNames[0],t.employeeNames.length>1?` +${t.employeeNames.length-1}`:""]}):c.jsx("span",{className:"oc-canvas-node-id",children:t.roleId}),t.employeeCount>0&&c.jsx("span",{className:"oc-canvas-node-badge",children:t.employeeCount})]})]})]}),c.jsx(vl,{type:"source",position:at.Bottom,className:"oc-canvas-handle"})]})});var bx,S2;function Mv(){if(S2)return bx;S2=1;var e="\0",t="\0",n="";class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(p){p&&(this._isDirected=Object.hasOwn(p,"directed")?p.directed:!0,this._isMultigraph=Object.hasOwn(p,"multigraph")?p.multigraph:!1,this._isCompound=Object.hasOwn(p,"compound")?p.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(p){return this._label=p,this}graph(){return this._label}setDefaultNodeLabel(p){return this._defaultNodeLabelFn=p,typeof p!="function"&&(this._defaultNodeLabelFn=()=>p),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var p=this;return this.nodes().filter(h=>Object.keys(p._in[h]).length===0)}sinks(){var p=this;return this.nodes().filter(h=>Object.keys(p._out[h]).length===0)}setNodes(p,h){var g=arguments,y=this;return p.forEach(function(v){g.length>1?y.setNode(v,h):y.setNode(v)}),this}setNode(p,h){return Object.hasOwn(this._nodes,p)?(arguments.length>1&&(this._nodes[p]=h),this):(this._nodes[p]=arguments.length>1?h:this._defaultNodeLabelFn(p),this._isCompound&&(this._parent[p]=t, Line truncated
${r}`}),c.jsx(RV,{projects:Rr.projects,activeId:Rr.activeProjectId,onSelect:Q=>{const z=Es(Q);t.current?.switchProject(Q,z)},onCreate:Q=>{t.current?.createProject(Q)},onDelete:Q=>t.current?.deleteProject(Q)})]}),c.jsxs("div",{className:"topbar-center",children:[c.jsxs("div",{className:"page-nav",children:[c.jsxs("button",{className:`page-nav-btn${$==="workspace"?" active":""}`,onClick:()=>W("workspace"),children:["Workspace",(()=>{const Q=Cr.channels.reduce((z,ne)=>z+Cr.getUnreadCount(ne.id),0);return Q>0?c.jsx("span",{className:"nav-unread-badge",children:Q>99?"99+":Q}):null})()]}),c.jsx("button",{className:`page-nav-btn${$==="office"?" active":""}`,onClick:()=>W("office"),children:"Office"}),c.jsx("button",{className:`page-nav-btn${$==="org"?" active":""}`,onClick:()=>W("org"),children:"Org"})]}),c.jsxs("div",{className:"stat-chips",children:[c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:ii.totalAgents})," agents"]}),c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:ii.totalSkills})," skills"]}),c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:Hn.getOpenTaskCount()})," tasks"]})]})]}),c.jsxs("div",{className:"topbar-right",children:[c.jsxs("select",{className:"theme-select",value:Tr,title:"Outdoor lighting override",onChange:Q=>{const z=Q.target.value;wr(z);try{z==="auto"?(localStorage.removeItem("opc_outdoor_override"),localStorage.removeItem("opc_outdoor_day"),localStorage.removeItem("opc_outdoor_night")):(localStorage.setItem("opc_outdoor_override",z),localStorage.removeItem("opc_outdoor_day"),localStorage.removeItem("opc_outdoor_night"))}catch{}e.current.syncOutdoorLighting()},children:[c.jsx("option",{value:"auto",children:"Outdoor auto"}),c.jsx("option",{value:"day",children:"Outdoor day"}),c.jsx("option",{value:"night",children:"Outdoor night"})]}),c.jsxs("select",{className:"theme-select",value:C,onChange:Q=>N(Q.target.value),children:[c.jsx("option",{value:"midnight",children:"Midnight"}),c.jsx("option",{value:"neon",children:"Neon"}),c.jsx("option",{value:"paper",children:"Paper"}),c.jsx("option",{value:"retro",children:"Retro"}),c.jsx("option",{value:"terminal",children:"Terminal"}),c.jsx("option",{value:"cozy",children:"Cozy"}),c.jsx("option",{value:"openopc",children:"OpenOPC"})]}),c.jsx("button",{className:`icon-btn ${H?"active":""}`,onClick:()=>V(Q=>!Q),title:"Developer Tools",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[c.jsx("path",{d:"M5.5 2L2 5.5 5.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M10.5 7L14 10.5 10.5 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),$==="workspace"&&c.jsx(rV,{boardStore:Hn,chatStore:Cr,sessionStore:hn,agents:B,officeMap:Is,execMode:q,companyProfile:J,taskPreferredAgent:X,projectId:Rr.activeProjectId,orgInfoData:te,onNavigateToOrg:()=>W("org"),savedOrgsList:rn,activeSavedOrg:Te,onSavedOrgsList:El,onSavedOrgLoad:Mu,recoveryStatus:oe,onRecoveryResume:Q=>t.current?.recoveryAction(ct(),"resume",Q),onRecoveryCancel:Q=>t.current?.recoveryAction(ct(),"cancel",Q),commsState:se,commsMessage:we,onCommsRefresh:Q=>{const{project_id:z,...ne}=Q??{};t.current?.commsState(ct(),ne)},onCommsReadMessage:Q=>t.current?.commsReadMessage(ct(),Q),onRunTask:(Q,z,ne,le,ge)=>{t.current?.send({type:"run_task",project_id:ct(),task_id:Q,title:z,description:ne,mode:le,profile:ge})},onCreateTask:(Q,z,ne,le)=>{t.current?.send({type:"kanban_create_task",project_id:ct(),title:Q,board_id:z,column_id:ne,task_id:le})},onMoveTask:(Q,z)=>{t.current?.send({type:"kanban_move_task",project_id:ct(),task_id:Q,column_id:z})},onCreateSession:()=>{if(vn.current||Tt.current)return;const Q=ct();Cn(Q),t.current?.createSession(Q,void 0,q,py(q),X,Do(q,Te))},onSessionSend:(Q,z,ne,le)=>t.current?.sessionSend(ct(),Q,z,ne,le),onSecretarySend:Q=>t.current?.secretarySend(ct(),Q),onDeleteSession:Q=>t.current?.deleteSession(ct(),Q),onTitleChange:(Q,z)=>t.current?.sessionUpdateTitle(ct(),Q,z),onSessionConfigChange:Ou,onSessionTaskAgentChange:xr,onContinueInNewChat:es,onSessionStop:go,onSessionResume:Zm,onSessionComplete:Q=>t.current?.sessionComplete(ct(),Q),onLoadSessionDetail:(Q,z)=>t.current?.sessionDetail(ct(),Q,{...z,include:z?.detailLevel==="full"?["messages","session_state","progress","work_items","runtime_context"]:["messages","session_state"],viewGeneration:ve.current}),onOpenExecutionPanel:Q=>pt(Q),onCollabSync:()=>t.current?.collabSync(ct(),void 0,ve.current)}),$==="org"&&c.jsx("div",{className:"org-page",children:c.jsx(eJ,{data:te,sessionRecruitmentByRole:Ru,talents:Be,employeeDetail:Vt,reorgProposals:vt,isCustomMode:Oi,onRequestData:()=>t.current?.orgInfo(),onRequestTalents:()=>t.current?.talentList(),onRequestEmployeeDetail:Q=>t.current?.employeeDetail(Q),onHireTalent:(Q,z)=>{kn(Q),t.current?.talentHire(Q,z,void 0,te?.organization_id||Te||void 0)},hiringTemplateId:Dt,onImportEmployee:Q=>t.curre Line truncated
@@ -0,0 +1,155 @@
import{g as ta,r as A3}from"./phaser-DFK5Ua9d.js";(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 o of r)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();var ig={exports:{}},Cc={};var hk;function M3(){if(hk)return Cc;hk=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(i,r,o){var a=null;if(o!==void 0&&(a=""+o),r.key!==void 0&&(a=""+r.key),"key"in r){o={};for(var u in r)u!=="key"&&(o[u]=r[u])}else o=r;return r=o.ref,{$$typeof:e,type:i,key:a,ref:r!==void 0?r:null,props:o}}return Cc.Fragment=t,Cc.jsx=n,Cc.jsxs=n,Cc}var gk;function D3(){return gk||(gk=1,ig.exports=M3()),ig.exports}var c=D3(),rg={exports:{}},xt={};var xk;function O3(){if(xk)return xt;xk=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),g=Symbol.iterator;function y(G){return G===null||typeof G!="object"?null:(G=g&&G[g]||G["@@iterator"],typeof G=="function"?G:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,S={};function _(G,J,P){this.props=G,this.context=J,this.refs=S,this.updater=P||v}_.prototype.isReactComponent={},_.prototype.setState=function(G,J){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,J,"setState")},_.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function w(){}w.prototype=_.prototype;function C(G,J,P){this.props=G,this.context=J,this.refs=S,this.updater=P||v}var N=C.prototype=new w;N.constructor=C,k(N,_.prototype),N.isPureReactComponent=!0;var O=Array.isArray;function I(){}var D={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function L(G,J,P){var K=P.ref;return{$$typeof:e,type:G,key:J,ref:K!==void 0?K:null,props:P}}function A(G,J){return L(G.type,J,G.props)}function M(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function $(G){var J={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(P){return J[P]})}var W=/\/+/g;function B(G,J){return typeof G=="object"&&G!==null&&G.key!=null?$(""+G.key):J.toString(36)}function U(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(I,I):(G.status="pending",G.then(function(J){G.status==="pending"&&(G.status="fulfilled",G.value=J)},function(J){G.status==="pending"&&(G.status="rejected",G.reason=J)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function F(G,J,P,K,ee){var te=typeof G;(te==="undefined"||te==="boolean")&&(G=null);var ie=!1;if(G===null)ie=!0;else switch(te){case"bigint":case"string":case"number":ie=!0;break;case"object":switch(G.$$typeof){case e:case t:ie=!0;break;case h:return ie=G._init,F(ie(G._payload),J,P,K,ee)}}if(ie)return ee=ee(G),ie=K===""?"."+B(G,0):K,O(ee)?(P="",ie!=null&&(P=ie.replace(W,"$&/")+"/"),F(ee,J,P,"",function(se){return se})):ee!=null&&(M(ee)&&(ee=A(ee,P+(ee.key==null||G&&G.key===ee.key?"":(""+ee.key).replace(W,"$&/")+"/")+ie)),J.push(ee)),1;ie=0;var oe=K===""?".":K+":";if(O(G))for(var fe=0;fe<G.length;fe++)K=G[fe],te=oe+B(K,fe),ie+=F(K,J,P,te,ee);else if(fe=y(G),typeof fe=="function")for(G=fe.call(G),fe=0;!(K=G.next()).done;)K=K.value,te=oe+B(K,fe++),ie+=F(K,J,P,te,ee);else if(te==="object"){if(typeof G.then=="function")return F(U(G),J,P,K,ee);throw J=String(G),Error("Objects are not valid as a React child (found: "+(J==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":J)+"). If you meant to render a collection of children, use an array instead.")}return ie}function V(G,J,P){if(G==null)return G;var K=[],ee=0;return F(G,K,"","",function(te){return J.call(P,te,ee++)}),K}function Y(G){if(G._status===-1){var J=G._result;J=J(),J.then(function(P){(G._status===0||G._status===-1)&&(G._status=1,G._result=P)},function(P){(G._status===0||G._status===-1)&&(G._status=2,G._result=P)}),G._status===-1&&(G._status=0,G._result=J)}if(G._status===1)return G._reLine truncated
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
`+we+s+Ce}var Ve=!1;function Ye(s,l){if(!s||Ve)return"";Ve=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var x={DetermineComponentFrameRoot:function(){try{if(l){var Ne=function(){throw Error()};if(Object.defineProperty(Ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ne,[])}catch(ye){var xe=ye}Reflect.construct(s,[],Ne)}else{try{Ne.call()}catch(ye){xe=ye}s.call(Ne.prototype)}}else{try{throw Error()}catch(ye){xe=ye}(Ne=s())&&typeof Ne.catch=="function"&&Ne.catch(function(){})}}catch(ye){if(ye&&xe&&typeof ye.stack=="string")return[ye.stack,xe.stack]}return[null,null]}};x.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(x.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(x.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=x.DetermineComponentFrameRoot(),H=j[0],X=j[1];if(H&&X){var re=H.split(`
`),ge=X.split(`
`);for(b=x=0;x<re.length&&!re[x].includes("DetermineComponentFrameRoot");)x++;for(;b<ge.length&&!ge[b].includes("DetermineComponentFrameRoot");)b++;if(x===re.length||b===ge.length)for(x=re.length-1,b=ge.length-1;1<=x&&0<=b&&re[x]!==ge[b];)b--;for(;1<=x&&0<=b;x--,b--)if(re[x]!==ge[b]){if(x!==1||b!==1)do if(x--,b--,0>b||re[x]!==ge[b]){var ke=`
`+re[x].replace(" at new "," at ");return s.displayName&&ke.includes("<anonymous>")&&(ke=ke.replace("<anonymous>",s.displayName)),ke}while(1<=x&&0<=b);break}}}finally{Ve=!1,Error.prepareStackTrace=f}return(f=s?s.displayName||s.name:"")?Be(f):""}function ht(s,l){switch(s.tag){case 26:case 27:case 5:return Be(s.type);case 16:return Be("Lazy");case 13:return s.child!==l&&l!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return Ye(s.type,!1);case 11:return Ye(s.type.render,!1);case 1:return Ye(s.type,!0);case 31:return Be("Activity");default:return""}}function zt(s){try{var l="",f=null;do l+=ht(s,f),f=s,s=s.return;while(s);return l}catch(x){return`
Error generating stack: `+x.message+`
`+x.stack}}var bt=Object.prototype.hasOwnProperty,Nt=e.unstable_scheduleCallback,me=e.unstable_cancelCallback,ze=e.unstable_shouldYield,lt=e.unstable_requestPaint,tt=e.unstable_now,qe=e.unstable_getCurrentPriorityLevel,ce=e.unstable_ImmediatePriority,ve=e.unstable_UserBlockingPriority,Ae=e.unstable_NormalPriority,$e=e.unstable_LowPriority,He=e.unstable_IdlePriority,Kt=e.log,Yt=e.unstable_setDisableYieldValue,be=null,Re=null;function Ue(s){if(typeof Kt=="function"&&Yt(s),Re&&typeof Re.setStrictMode=="function")try{Re.setStrictMode(be,s)}catch{}}var Xe=Math.clz32?Math.clz32:qn,Ge=Math.log,Je=Math.LN2;function qn(s){return s>>>=0,s===0?32:31-(Ge(s)/Je|0)|0}var In=256,Dn=262144,Ie=4194304;function Te(s){var l=s&42;if(l!==0)return l;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ke(s,l,f){var x=s.pendingLanes;if(x===0)return 0;var b=0,j=s.suspendedLanes,H=s.pingedLanes;s=s.warmLanes;var X=x&134217727;return X!==0?(x=X&~j,x!==0?b=Te(x):(H&=X,H!==0?b=Te(H):f||(f=X&~s,f!==0&&(b=Te(f))))):(X=x&~j,X!==0?b=Te(X):H!==0?b=Te(H):f||(f=x&~s,f!==0&&(b=Te(f)))),b===0?0:l!==0&&l!==b&&(l&j)===0&&(j=b&-b,f=l&-l,j>=f||j===32&&(f&4194048)!==0)?l:b}function We(s,l){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&l)===0}function gt(s,l){switch(s){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Oe(){var s=Ie;return Ie<<=1,(Ie&62914560)===0&&(Ie=4194304),s}function nt(s){for(var l=[],f=0;31>f;f++)l.push(s);return l}function on(s,l){s.pendingLanes|=l,l!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Zt(s,l,f,x,b,j){var H=s.pendingLanes;s.pendingLanes=f,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=f,s.entangledLanes&=f,s.errorRecoveryDisabledLanes&=f,s.shellSuspendCounter=0;var X=s.entanglements,re=s.expirationTimes,ge=s.hiddenUpdates;for(f=H&~f;0<f;){var ke=31-Xe(f),Ne=1<<ke;X[ke]=0,re[ke]=-1;var xe=ge[ke];if(xe!==null)for(ge[ke]=null,ke=0;ke<xe.length;ke++){var ye=xe[ke];ye!==null&&(ye.lane&=-536870913)}f&=~Ne}x!==0&&_t(s,x,0),j!==0&&b===0&&s.tag!==0&&(s.suspendedLanes|=j&~(H&~l))}function _t(s,l,f){s.pendingLanes|=l,s.suspendedLanes&=~l;var x=31-Xe(l);s.entangledLanes|=l,s.entanglements[x]=s.entanglements[x]|1073741824|f&261930}function Qt(s,l){var f=s.entangledLanes|=l;for(s=s.entanglements;f;){var x=31-Xe(f),b=1<<x;b&l|s[x]&l&&(s[x]|=l),f&=~b}}function Cn(s,l){var f=l&-l;return f=(f&42)!==0?1:dt(f),(f&(s.suspendedLanes|l))!==0?0:f}function dt(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function jn(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function Jt(){var s=V.p;return s!==0?s:(s=window.event,s===void 0?32:lk(s.type))}function En(s,l){var f=V.p;try{return V.p=s,l()}finally{V.p=f}}var hn=Math.random().toString(36).slice(2),jt="__reactFiber$"+hn,yt="__reactProps$"+hn,gn="__reactContainer$"+hn,ri="__reactEvents$"+hn,Me="__reactListeners$"+hn,$t="__reactHandles$"+hn,Wn="__reactResources$"+hn,_i="__reactMarker$"+hn;function On(s){delete s[jt],delete s[yt],delete s[ri],delete s[Me],delete s[$t]}function vt(s){var l=s[jt];if(l)return l;for(var f=s.parentNode;f;){if(l=f[gn]||f[jt]){if(f=l.alternate,l.child!==null||f!==null&&f.child!==null)for(s=q_(s);s!==null;){if(f=s[jt])return f;s=q_(s)}return l}s=f,f=s.parentNode}return null}function Ni(s){if(s=s[jt]||s[gn]){var l=s.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return s}return null}function Ii(s){var l=s.tag;if(l===5||l===26||l===27||l===6)return s.stateNode;throw Error(i(33))}function Yn(s){var l=s[Wn];return l||(l=s[Wn]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function dn(s){s[_i]=!0}var Hi=new Set,Or={};function Et(s,l){Ti(s,l),Ti(s+"Capture",l)}function Ti(s,l){for(Or[s]=l,s=0;s<l.length;s++)Hi.add(l[s])}var ki=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u2 Line truncated
`).replace(e3,"")}function L_(s,l){return l=O_(l),O_(s)===l}function cn(s,l,f,x,b,j){switch(f){case"children":typeof x=="string"?l==="body"||l==="textarea"&&x===""||Rs(s,x):(typeof x=="number"||typeof x=="bigint")&&l!=="body"&&Rs(s,""+x);break;case"className":It(s,"class",x);break;case"tabIndex":It(s,"tabindex",x);break;case"dir":case"role":case"viewBox":case"width":case"height":It(s,f,x);break;case"style":rr(s,x,j);break;case"data":if(l!=="object"){It(s,"data",x);break}case"src":case"href":if(x===""&&(l!=="a"||f!=="href")){s.removeAttribute(f);break}if(x==null||typeof x=="function"||typeof x=="symbol"||typeof x=="boolean"){s.removeAttribute(f);break}x=sa(""+x),s.setAttribute(f,x);break;case"action":case"formAction":if(typeof x=="function"){s.setAttribute(f,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof j=="function"&&(f==="formAction"?(l!=="input"&&cn(s,l,"name",b.name,b,null),cn(s,l,"formEncType",b.formEncType,b,null),cn(s,l,"formMethod",b.formMethod,b,null),cn(s,l,"formTarget",b.formTarget,b,null)):(cn(s,l,"encType",b.encType,b,null),cn(s,l,"method",b.method,b,null),cn(s,l,"target",b.target,b,null)));if(x==null||typeof x=="symbol"||typeof x=="boolean"){s.removeAttribute(f);break}x=sa(""+x),s.setAttribute(f,x);break;case"onClick":x!=null&&(s.onclick=sr);break;case"onScroll":x!=null&&At("scroll",s);break;case"onScrollEnd":x!=null&&At("scrollend",s);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(i(61));if(f=x.__html,f!=null){if(b.children!=null)throw Error(i(60));s.innerHTML=f}}break;case"multiple":s.multiple=x&&typeof x!="function"&&typeof x!="symbol";break;case"muted":s.muted=x&&typeof x!="function"&&typeof x!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(x==null||typeof x=="function"||typeof x=="boolean"||typeof x=="symbol"){s.removeAttribute("xlink:href");break}f=sa(""+x),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":x!=null&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,""+x):s.removeAttribute(f);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":x&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,""):s.removeAttribute(f);break;case"capture":case"download":x===!0?s.setAttribute(f,""):x!==!1&&x!=null&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,x):s.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":x!=null&&typeof x!="function"&&typeof x!="symbol"&&!isNaN(x)&&1<=x?s.setAttribute(f,x):s.removeAttribute(f);break;case"rowSpan":case"start":x==null||typeof x=="function"||typeof x=="symbol"||isNaN(x)?s.removeAttribute(f):s.setAttribute(f,x);break;case"popover":At("beforetoggle",s),At("toggle",s),tn(s,"popover",x);break;case"xlinkActuate":pi(s,"http://www.w3.org/1999/xlink","xlink:actuate",x);break;case"xlinkArcrole":pi(s,"http://www.w3.org/1999/xlink","xlink:arcrole",x);break;case"xlinkRole":pi(s,"http://www.w3.org/1999/xlink","xlink:role",x);break;case"xlinkShow":pi(s,"http://www.w3.org/1999/xlink","xlink:show",x);break;case"xlinkTitle":pi(s,"http://www.w3.org/1999/xlink","xlink:title",x);break;case"xlinkType":pi(s,"http://www.w3.org/1999/xlink","xlink:type",x);break;case"xmlBase":pi(s,"http://www.w3.org/XML/1998/namespace","xml:base",x);break;case"xmlLang":pi(s,"http://www.w3.org/XML/1998/namespace","xml:lang",x);break;case"xmlSpace":pi(s,"http://www.w3.org/XML/1998/namespace","xml:space",x);break;case"is":tn(s,"is",x);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=op.get(f)||f,tn(s,f,x))}}function Bh(s,l,f,x,b,j){switch(f){case"style":rr(s,x,j);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(i(61));if(f=x.__html,f!=null){if(b.children!=null)throw Error(i(60));s.innerHTML=f}}break;case"children":typeof x=="string"?Rs(s,x):(typeof x=="number"||typeof x=="bigint")&&Rs(s,""+x);break;case"onScroll":x!=null&&At("scroll",s);break;case"onScrollEnd":x!=null&&At("scrollend",s);break;case"onClick":x!=null&&(s.onclick=sr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"inne Line truncated
`),oe=p.map(([fe,se])=>` [${fe}, ${se}],`).join(`
`);return`const MAP_STR: string[] = [
${ie}
]
const SEATS: [number, number][] = [
${oe}
]`})(),J=()=>I(te=>Math.min(te+.25,3)),P=()=>I(te=>Math.max(te-.25,.5)),K=m.flat().filter(te=>te===1).length,ee=m.flat().filter(te=>te===0).length;return c.jsxs("div",{className:"collision-editor",children:[c.jsxs("div",{className:"ce-toolbar",children:[c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("span",{className:"ce-title",children:"Map Editor"}),c.jsx("select",{className:"ce-office-select",value:a,onChange:te=>M(te.target.value),children:r.map(te=>c.jsx("option",{value:te.id,children:te.name},te.id))})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsxs("button",{className:`ce-mode-btn ${y==="wall"?"active wall":""}`,onClick:()=>v("wall"),children:[c.jsx("span",{className:"ce-mode-dot wall"})," Wall"]}),c.jsxs("button",{className:`ce-mode-btn ${y==="floor"?"active floor":""}`,onClick:()=>v("floor"),children:[c.jsx("span",{className:"ce-mode-dot floor"})," Floor"]}),c.jsxs("button",{className:`ce-mode-btn ${y==="seat"?"active seat":""}`,onClick:()=>v("seat"),children:[c.jsx("span",{className:"ce-mode-dot seat"})," Seat"]})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("button",{className:"ce-btn",onClick:P,children:"-"}),c.jsxs("span",{className:"ce-zoom-label",children:[Math.round(O*100),"%"]}),c.jsx("button",{className:"ce-btn",onClick:J,children:"+"}),c.jsx("button",{className:`ce-btn${D?" active":""}`,onClick:()=>T(te=>!te),children:"Grid"})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("button",{className:`ce-btn apply${C?" success":""}`,onClick:Y,children:C?"Applied":"Apply"}),c.jsx("button",{className:`ce-btn${_?" active":""}`,onClick:Q,children:"Export"}),c.jsx("button",{className:"ce-btn danger",onClick:q,children:"Reset"})]}),c.jsxs("div",{className:"ce-toolbar-group ce-stats",children:[c.jsxs("span",{children:["Walls: ",K]}),c.jsxs("span",{children:["Floor: ",ee]}),c.jsxs("span",{children:["Seats: ",p.length]})]})]}),c.jsxs("div",{className:"ce-body",children:[c.jsx("div",{className:"ce-canvas-wrap",style:{overflow:"auto"},children:c.jsx("canvas",{ref:t,style:{width:L*R*O,height:A*R*O,imageRendering:"pixelated",cursor:y==="seat"?"crosshair":"cell"},onMouseDown:U,onMouseMove:F,onMouseUp:V,onMouseLeave:V})}),_&&c.jsxs("div",{className:"ce-export-panel",children:[c.jsxs("div",{className:"ce-export-header",children:[c.jsx("span",{children:"Export — copy to source code"}),c.jsx("button",{className:"ce-btn",onClick:()=>navigator.clipboard.writeText(G),children:"Copy"})]}),c.jsx("textarea",{className:"ce-export-textarea",value:G,readOnly:!0,rows:20})]})]})]})}let qM=0;function Qn(e,t,n={}){return{event_id:`test-${++qM}`,type:e,agent_id:t,data:n,timestamp:Date.now()/1e3}}function kn(e){return new Promise(t=>setTimeout(t,e))}async function WM(e){const t=[],n=e.getScene();if(!n)return t.push({name:"scene-ready",pass:!1,detail:"OfficeScene not initialized"}),t;console.log("%c[EventTest] Starting full event test suite (multi-office)...","color: #6366f1; font-weight: bold");for(const M of[...n.agents.keys()])n.removeAgent(M);await kn(100);const i=Mn();t.push({name:"offices-loaded",pass:i.length>=3,detail:`${i.length} offices loaded: ${i.map(M=>M.name).join(", ")}`});const r=["agent-A","agent-B","agent-C","agent-D","agent-E","agent-F"];for(const M of r)e.pushEvent(Qn("agent_active",M));await kn(300);const o=new Set;let a=!1;for(const M of r){const $=n.getAgent(M);$&&$.seatId&&(o.has($.seatId)&&(a=!0),o.add($.seatId))}t.push({name:"desk-assignment-unique",pass:!a&&o.size===r.length,detail:`Assigned ${o.size} unique seats to ${r.length} agents. IDs: [${[...o].join(", ")}]`});const u=r.every(M=>n.getAgent(M)?.officeId!=null);t.push({name:"agents-have-officeId",pass:u,detail:r.map(M=>`${M}=${n.getAgent(M)?.officeId}`).join(", ")}),e.pushEvent(Qn("tool_start","agent-A",{tool_name:"shell"})),await kn(200);const d=n.getAgent("agent-A");t.push({name:"tool_start-state",pass:d.isActive===!0&&d.currentTool==="shell",detail:`isActive=${d.isActive}, currentTool=${d.currentTool}`}),e.pushEvent(Qn("tool_done","agent-A",{tool_name:"shell"})),await kn(100),t.push({name:"tool_done-celebrate",pass:d.agentState==="celebrate",detail:`state=${d.agentState}`});for(let M=0;M<20&&d.agentState==="celebrate";M++)await kn(500);t.push({name:"celebrate-to-idle",pass:d.agentState!=="celebrate",detail:`state=${d.agentState}`}),e.pushEvent(Qn("waiting","agent-B")),await kn(200);const m=n.getAgent("agent-B");t.push({name:"waiting-state",pass:m.isActive===!1&&(m.agentState==="walk"||m.agentState==="idle"||m.agentState==="coffee"),detail:`isActive=${m.isActive}, state=${m.agentState}`}),e.pushEvent(Qn("reflect_start","agent-C")),await kn(200);const h=n.getAgent("agent-C");t.push({name:"reflect_start-state",pass:h.currentTool==="Reflect"&&(h.agentState==="walk"||h.agentState==="reflect"),detail:`currentTool=${h.currentTool}, state=${h.agentState}`}),e.pushEvent(Qn("reflect_done","agent-C")),await kn(100),t.push({name:"reflect_done-celebrate",pass:h.agentState==="celebrate",detail:`staLine truncated
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*S,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(r),o=!1,r}return a.updateDeps=u=>{i=u},a}function Gk(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const r4=(e,t)=>Math.abs(e-t)<1.01,s4=(e,t,n)=>{let i;return function(...r){e.clearTimeout(i),i=e.setTimeout(()=>t.apply(this,r),n)}},qk=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},o4=e=>e,a4=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),i=[];for(let r=t;r<=n;r++)i.push(r);return i},l4=(e,t)=>{const n=e.scrollElement;if(!n)return;const i=e.targetWindow;if(!i)return;const r=a=>{const{width:u,height:d}=a;t({width:Math.round(u),height:Math.round(d)})};if(r(qk(n)),!i.ResizeObserver)return()=>{};const o=new i.ResizeObserver(a=>{const u=()=>{const d=a[0];if(d?.borderBoxSize){const m=d.borderBoxSize[0];if(m){r({width:m.inlineSize,height:m.blockSize});return}}r(qk(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},Wk={passive:!0},Yk=typeof window>"u"?!0:"onscrollend"in window,c4=(e,t)=>{const n=e.scrollElement;if(!n)return;const i=e.targetWindow;if(!i)return;let r=0;const o=e.options.useScrollendEvent&&Yk?()=>{}:s4(i,()=>{t(r,!1)},e.options.isScrollingResetDelay),a=h=>()=>{const{horizontal:p,isRtl:g}=e.options;r=p?n.scrollLeft*(g&&-1||1):n.scrollTop,o(),t(r,h)},u=a(!0),d=a(!1);n.addEventListener("scroll",u,Wk);const m=e.options.useScrollendEvent&&Yk;return m&&n.addEventListener("scrollend",d,Wk),()=>{n.removeEventListener("scroll",u),m&&n.removeEventListener("scrollend",d)}},u4=(e,t,n)=>{if(t?.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},d4=(e,{adjustments:t=0,behavior:n},i)=>{var r,o;const a=e+t;(o=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||o.call(r,{[i.options.horizontal?"left":"top"]:a,behavior:n})};class f4{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,i,r;return((r=(i=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let n=null;const i=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(o=>{const a=()=>{const u=o.target,d=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),n=null},observe:r=>{var o;return(o=i())==null?void 0:o.observe(r,{box:"border-box"})},unobserve:r=>{var o;return(o=i())==null?void 0:o.unobserve(r)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([i,r])=>{typeof r>"u"&&delete n[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:o4,rangeExtractor:a4,onChange:()=>{},measureElement:u4,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,n)},this.maybeNotify=Va(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)} Line truncated
The error may be correlated with this previous error:
${te.current.stack}
`),we}Vf(()=>{te.current=void 0,P.current=void 0,G.current=fe});const se=E.useMemo(()=>E.createElement(S,{...fe,ref:L}),[L,S,fe]);return E.useMemo(()=>v?E.createElement(M.Provider,{value:q},se):se,[M,se,q])}const I=E.memo(N);if(I.WrappedComponent=S,I.displayName=N.displayName=w,d){const T=E.forwardRef(function(A,M){return E.createElement(I,{...A,reactReduxForwardedRef:M})});return T.displayName=w,T.WrappedComponent=S,Ay(T,S)}return Ay(I,S)}}var sE=K5;function Z5(e){const{children:t,context:n,serverState:i,store:r}=e,o=E.useMemo(()=>{const d=nE(r);return{store:r,subscription:d,getServerState:i?()=>i:void 0}},[r,i]),a=E.useMemo(()=>r.getState(),[r]);Vf(()=>{const{subscription:d}=o;return d.onStateChange=d.notifyNestedSubs,d.trySubscribe(),a!==r.getState()&&d.notifyNestedSubs(),()=>{d.tryUnsubscribe(),d.onStateChange=void 0}},[o,a]);const u=n||rE;return E.createElement(u.Provider,{value:o},t)}var Q5=Z5,J5="Invariant failed";function eD(e,t){throw new Error(J5)}var Nr=function(t){var n=t.top,i=t.right,r=t.bottom,o=t.left,a=i-o,u=r-n,d={top:n,right:i,bottom:r,left:o,width:a,height:u,x:o,y:n,center:{x:(i+o)/2,y:(r+n)/2}};return d},M0=function(t,n){return{top:t.top-n.top,left:t.left-n.left,bottom:t.bottom+n.bottom,right:t.right+n.right}},vS=function(t,n){return{top:t.top+n.top,left:t.left+n.left,bottom:t.bottom-n.bottom,right:t.right-n.right}},tD=function(t,n){return{top:t.top+n.y,left:t.left+n.x,bottom:t.bottom+n.y,right:t.right+n.x}},bg={top:0,right:0,bottom:0,left:0},D0=function(t){var n=t.borderBox,i=t.margin,r=i===void 0?bg:i,o=t.border,a=o===void 0?bg:o,u=t.padding,d=u===void 0?bg:u,m=Nr(M0(n,r)),h=Nr(vS(n,a)),p=Nr(vS(h,d));return{marginBox:m,borderBox:Nr(n),paddingBox:h,contentBox:p,margin:r,border:a,padding:d}},hr=function(t){var n=t.slice(0,-2),i=t.slice(-2);if(i!=="px")return 0;var r=Number(n);return isNaN(r)&&eD(),r},nD=function(){return{x:window.pageXOffset,y:window.pageYOffset}},Uf=function(t,n){var i=t.borderBox,r=t.border,o=t.margin,a=t.padding,u=tD(i,n);return D0({borderBox:u,border:r,margin:o,padding:a})},Gf=function(t,n){return n===void 0&&(n=nD()),Uf(t,n)},oE=function(t,n){var i={top:hr(n.marginTop),right:hr(n.marginRight),bottom:hr(n.marginBottom),left:hr(n.marginLeft)},r={top:hr(n.paddingTop),right:hr(n.paddingRight),bottom:hr(n.paddingBottom),left:hr(n.paddingLeft)},o={top:hr(n.borderTopWidth),right:hr(n.borderRightWidth),bottom:hr(n.borderBottomWidth),left:hr(n.borderLeftWidth)};return D0({borderBox:t,margin:i,padding:r,border:o})},aE=function(t){var n=t.getBoundingClientRect(),i=window.getComputedStyle(t);return oE(n,i)},cu=function(t){var n=[],i=null,r=function(){for(var a=arguments.length,u=new Array(a),d=0;d<a;d++)u[d]=arguments[d];n=u,!i&&(i=requestAnimationFrame(function(){i=null,t.apply(void 0,n)}))};return r.cancel=function(){i&&(cancelAnimationFrame(i),i=null)},r};function qf(){return qf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},qf.apply(null,arguments)}function lE(e,t){}lE.bind(null,"warn");lE.bind(null,"error");function uo(){}function iD(e,t){return{...e,...t}}function vr(e,t,n){const i=t.map(r=>{const o=iD(n,r.options);return e.addEventListener(r.eventName,r.fn,o),function(){e.removeEventListener(r.eventName,r.fn,o)}});return function(){i.forEach(o=>{o()})}}const rD="Invariant failed";class Wf extends Error{}Wf.prototype.toString=function(){return this.message};function Le(e,t){throw new Wf(rD)}let sD=class extends St.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=uo,this.onWindowError=n=>{const i=this.getCallbacks();i.isDragging()&&i.tryAbort(),n.error instanceof Wf&&n.preventDefault()},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");return this.callbacks},this.setCallbacks=n=>{this.callbacks=n}}componentDidMount(){this.unbind=vr(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof Wf){this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}};const oD=`
Press space bar to start a drag.
When dragging you can use the arrow keys to move the item around and escape to cancel.
Some screen readers may require you to be in focus mode or to use your pass through key
`,Yf=e=>e+1,aD=e=>`
You have lifted an item in position ${Yf(e.source.index)}
`,cE=(e,t)=>{const n=e.droppableId===t.droppableId,i=Yf(e.index),r=Yf(t.index);return n?`
You have moved the item from position ${i}
to position ${r}
`:`
You have moved the item from position ${i}
in list ${e.droppableId}
to list ${t.droppableId}
in position ${r}
`},uE=(e,t,n)=>t.droppableId===n.droppableId?`
The item ${e}
has been combined with ${n.draggableId}`:`
The item ${e}
in list ${t.droppableId}
has been combined with ${n.draggableId}
in list ${n.droppableId}
`,lD=e=>{const t=e.destination;if(t)return cE(e.source,t);const n=e.combine;return n?uE(e.draggableId,e.source,n):"You are over an area that cannot be dropped on"},bS=e=>`
The item has returned to its starting position
of ${Yf(e.index)}
`,cD=e=>{if(e.reason==="CANCEL")return`
Movement cancelled.
${bS(e.source)}
`;const t=e.destination,n=e.combine;return t?`
You have dropped the item.
${cE(e.source,t)}
`:n?`
You have dropped the item.
${uE(e.draggableId,e.source,n)}
`:`
The item has been dropped while not over a drop area.
${bS(e.source)}
`},Ef={dragHandleUsageInstructions:oD,onDragStart:aD,onDragUpdate:lD,onDragEnd:cD};function uD(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function dE(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!uD(e[n],t[n]))return!1;return!0}function Ft(e,t){const n=E.useState(()=>({inputs:t,result:e()}))[0],i=E.useRef(!0),r=E.useRef(n),a=i.current||!!(t&&r.current.inputs&&dE(t,r.current.inputs))?r.current:{inputs:t,result:e()};return E.useEffect(()=>{i.current=!1,r.current=a},[a]),a.result}function it(e,t){return Ft(()=>e,t)}const ii={x:0,y:0},fi=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),Qi=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),fo=(e,t)=>e.x===t.x&&e.y===t.y,Il=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),qo=(e,t,n=0)=>e==="x"?{x:t,y:n}:{x:n,y:t},uu=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),_S=(e,t)=>Math.min(...t.map(n=>uu(e,n))),fE=e=>t=>({x:e(t.x),y:e(t.y)});var dD=(e,t)=>{const n=Nr({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return n.width<=0||n.height<=0?null:n};const Iu=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),kS=e=>[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.left,y:e.bottom},{x:e.right,y:e.bottom}],fD={top:0,right:0,bottom:0,left:0},mD=(e,t)=>t?Iu(e,t.scroll.diff.displacement):e,pD=(e,t,n)=>n&&n.increasedBy?{...e,[t.end]:e[t.end]+n.increasedBy[t.line]}:e,hD=(e,t)=>t&&t.shouldClipSubject?dD(t.pageMarginBox,e):Nr(e);var ml=({page:e,withPlaceholder:t,axis:n,frame:i})=>{const r=mD(e.marginBox,i),o=pD(r,n,t),a=hD(o,i);return{page:e,withPlaceholder:t,active:a}},O0=(e,t)=>{e.frame||Le();const n=e.frame,i=Qi(t,n.scroll.initial),r=Il(i),o={...n,scroll:{initial:n.scroll.initial,current:t,diff:{value:i,displacement:r},max:n.scroll.max}},a=ml({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:o});return{...e,frame:o,subject:a}};function ni(e,t=dE){let n=null;function i(...r){if(n&&n.lastThis===this&&t(r,n.lastArgs))return n.lastResult;const o=e.apply(this,r);return n={lastResult:o,lastArgs:r,lastThis:this},o}return i.clear=function(){n=null},i}const mE=ni(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),pE=ni(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),Im=ni(e=>Object.values(e)),gD=ni(e=>Object.values(e));var Tl=ni((e,t)=>gD(t).filter(i=>e===i.descriptor.droppableId).sort((i,r)=>i.descriptor.index-r.descriptor.index));function L0(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function Tm(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var Rm=ni((e,t)=>t.filter(n=>n.descriptor.id!==e.descriptor.id)),xD=({isMovingForward:e,draggable:t,destination:n,insideDestination:i,previousImpact:r})=>{if(!n.isCombineEnabled||!L0(r))return null;function a(y){const v={type:"COMBINE",combine:{draggableId:y,droppableId:n.descriptor.id}};return{...r,at:v}}const u=r.displaced.all,d=u.length?u[0]:null;if(e)return d?a(d):null;const m=Rm(t,i);if(!d){if(!m.length)return null;const y=m[m.length-1];return a(y.descriptor.id)}const h=m.findIndex(y=>y.descriptor.id===d);h===-1&&Le();const p=h-1;if(p<0)return null;const g=m[p];return a(g.descriptor.id)},Rl=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const hE={point:ii,value:0},du={invisible:{},visible:{},all:[]},yD={displaced:du,displacedBy:hE,at:null};var br=(e,t)=>n=>e<=n&&n<=t,gE=e=>{const t=br(e.top,e.bottom),n=br(e.left,e.right);return i=>{if(t(i.top)&&t(i.bottom)&&n(i.left)&&n(i.right))return!0;const o=t(i.top)||t(i.bottom),a=n(i.left)||n(i.right);if(o&&a)return!0;const d=i.top<e.top&&i.bottom>e.bottom,m=i.left<e.left&&i.right>e.right;return d&&m?!0:d&&a||m&&o}},vD=e=>{const t=br(e.top,e.bottom),n=br(e.left,e.right);return i=>t(i.top)&&t(i.bottom)&&n(i.left)&&n(i.right)};const z0={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},xE={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var bD=e=>t=>{const n=br(t.top,t.bottom),i=br(t.left,t.right);return r=>e===z0?n(r.top)&&n(r.bottom):i(r.left)&&i(r.right)};const _D=(e,t)=>{const n=t.frame?t.frame.scroll.diff.displacement:ii;return Iu(e,n)},kD=(e,t,n)=>t.subject.active?n(t.subject.active)(e):!1,SD=(e,t,n)=>n(t)(e),P0=({target:e,destination:t,viewport:n,withDroppableDisplacement:i,isVisibleThroughFrameFn:r})=>{const o=i?_D(e,t):e;return kD(o,t,r)&&SD(o,n,r)},wD=e=>P0({...e,isVisibleThroughFrameFn:gE}),yE=e=>P0({...e,isVisibleThroughFrameFn:vD}),CD=e=>P0({...e,isVisibleThroughFrameFn:bD(e.destination.axis)}),jD=(e,t,n)=>{if(typeof n=="boolean")return n;if(!t)return!0;const{invisible:i,visible:r}=t;if(i[e])return!1;const o=r[e];return o?o.shouldAnimate:!0};function ED(e,t){const n=e.page.marginBox,i={top:t.point.y,right:0,bottom:0,left:t.point.x};return Nr(M0(n,i))}function fu({afterDragging:e,destination:t,displacedBy:n,viewport:i,forceShouldAnimate:r,la Line truncated
cursor: -webkit-grab;
cursor: grab;
`;return{selector:t(hl.contextId),styles:{always:`
-webkit-touch-callout: none;
-webkit-tap-highlight-color: rgba(0,0,0,0);
touch-action: manipulation;
`,resting:u,dragging:NL,dropAnimating:u}}})(),i=(()=>{const u=`
transition: ${Qc.outOfTheWay};
`;return{selector:t(zy.contextId),styles:{dragging:u,dropAnimating:u,userCancel:u}}})(),r={selector:t(jL.contextId),styles:{always:"overflow-anchor: none;"}},a=[i,n,r,{selector:"body",styles:{dragging:`
cursor: grabbing;
cursor: -webkit-grabbing;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
overflow-anchor: none;
`}}];return{always:Tc(a,"always"),resting:Tc(a,"resting"),dragging:Tc(a,"dragging"),dropAnimating:Tc(a,"dropAnimating"),userCancel:Tc(a,"userCancel")}};const er=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?E.useLayoutEffect:E.useEffect,Cg=()=>{const e=document.querySelector("head");return e||Le(),e},LS=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function TL(e,t){const n=Ft(()=>IL(e),[e]),i=E.useRef(null),r=E.useRef(null),o=it(ni(p=>{const g=r.current;g||Le(),g.textContent=p}),[]),a=it(p=>{const g=i.current;g||Le(),g.textContent=p},[]);er(()=>{!i.current&&!r.current||Le();const p=LS(t),g=LS(t);return i.current=p,r.current=g,p.setAttribute(`${pl}-always`,e),g.setAttribute(`${pl}-dynamic`,e),Cg().appendChild(p),Cg().appendChild(g),a(n.always),o(n.resting),()=>{const y=v=>{const k=v.current;k||Le(),Cg().removeChild(k),v.current=null};y(i),y(r)}},[t,a,o,n.always,n.resting,e]);const u=it(()=>o(n.dragging),[o,n.dragging]),d=it(p=>{if(p==="DROP"){o(n.dropAnimating);return}o(n.userCancel)},[o,n.dropAnimating,n.userCancel]),m=it(()=>{r.current&&o(n.resting)},[o,n.resting]);return Ft(()=>({dragging:u,dropping:d,resting:m}),[u,d,m])}function GE(e,t){return Array.from(e.querySelectorAll(t))}var qE=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function Mm(e){return e instanceof qE(e).HTMLElement}function RL(e,t){const n=`[${hl.contextId}="${e}"]`,i=GE(document,n);if(!i.length)return null;const r=i.find(o=>o.getAttribute(hl.draggableId)===t);return!r||!Mm(r)?null:r}function AL(e){const t=E.useRef({}),n=E.useRef(null),i=E.useRef(null),r=E.useRef(!1),o=it(function(g,y){const v={id:g,focus:y};return t.current[g]=v,function(){const S=t.current;S[g]!==v&&delete S[g]}},[]),a=it(function(g){const y=RL(e,g);y&&y!==document.activeElement&&y.focus()},[e]),u=it(function(g,y){n.current===g&&(n.current=y)},[]),d=it(function(){i.current||r.current&&(i.current=requestAnimationFrame(()=>{i.current=null;const g=n.current;g&&a(g)}))},[a]),m=it(function(g){n.current=null;const y=document.activeElement;y&&y.getAttribute(hl.draggableId)===g&&(n.current=g)},[]);return er(()=>(r.current=!0,function(){r.current=!1;const g=i.current;g&&cancelAnimationFrame(g)}),[]),Ft(()=>({register:o,tryRecordFocus:m,tryRestoreFocusRecorded:d,tryShiftRecord:u}),[o,m,d,u])}function ML(){const e={draggables:{},droppables:{}},t=[];function n(p){return t.push(p),function(){const y=t.indexOf(p);y!==-1&&t.splice(y,1)}}function i(p){t.length&&t.forEach(g=>g(p))}function r(p){return e.draggables[p]||null}function o(p){const g=r(p);return g||Le(),g}const a={register:p=>{e.draggables[p.descriptor.id]=p,i({type:"ADDITION",value:p})},update:(p,g)=>{const y=e.draggables[g.descriptor.id];y&&y.uniqueId===p.uniqueId&&(delete e.draggables[g.descriptor.id],e.draggables[p.descriptor.id]=p)},unregister:p=>{const g=p.descriptor.id,y=r(g);y&&p.uniqueId===y.uniqueId&&(delete e.draggables[g],e.droppables[p.descriptor.droppableId]&&i({type:"REMOVAL",value:p}))},getById:o,findById:r,exists:p=>!!r(p),getAllByType:p=>Object.values(e.draggables).filter(g=>g.descriptor.type===p)};function u(p){return e.droppables[p]||null}function d(p){const g=u(p);return g||Le(),g}const m={register:p=>{e.droppables[p.descriptor.id]=p},unregister:p=>{const g=u(p.descriptor.id);g&&p.uniqueId===g.uniqueId&&delete e.droppables[p.descriptor.id]},getById:d,findById:u,exists:p=>!!u(p),getAllByType:p=>Object.values(e.droppables).filter(g=>g.descriptor.type===p)};function h(){e.draggables={},e.droppables={},t.length=0}return{draggable:a,droppable:m,subscribe:n,clean:h}}function DL(){const e=Ft(ML,[]);return E.useEffect(()=>function(){e.clean()},[e]),e}var X0=St.createContext(null),Kf=()=>{const e=document.body;return e||Le(),e};const OL={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},LL=e=>`rfd-announcement-${e}`;function zL(e){const t=Ft(()=>LL(e),[e]),n=E.useRef(null);return E.useEffect(function(){const o=document.createElement("div");return n.current=o,o.id=t,o.setAttribute("aria-live","assertive"),o.setAttribute("aria-atomic","true"),qf(o.style,OL),Kf().appendChild(o),function(){setTimeout(function(){const d=Kf();d.contains(o)&&d.removeChild(o),o===n.current&&(n.current=null)})}},[t]),it(r=>{const o=n.current;if(o){o.textContent=r;return}},[])}const PL={separator:"::"};function K0(e,t=PL){const n=St.useId();return Ft(()=>`${e}${t.separator}${n}`,[t.separator,e,n])}function BL({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function $L({contextId:e,text:t}){const n=K0("hidden-text",{separator:"-"}),i=Ft(()=>BL({contextId:e,uniqueId:n}),[n,e]);return E.useEffect(function(){const o=document.createElement("div");return o.id=i,o.textContent=t,o.style.display="none",Kf().appendChild(o),function(){const u=Kf();u.contains(o)&&u.removeChild(o)}},[i,t]),i}var Dm=St.c Line truncated
`,m="/",h="*",p="",g="comment",y="declaration";function v(S,_){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];_=_||{};var w=1,C=1;function N(B){var U=B.match(t);U&&(w+=U.length);var F=B.lastIndexOf(d);C=~F?B.length-F:C+B.length}function O(){var B={line:w,column:C};return function(U){return U.position=new I(B),L(),U}}function I(B){this.start=B,this.end={line:w,column:C},this.source=_.source}I.prototype.content=S;function D(B){var U=new Error(_.source+":"+w+":"+C+": "+B);if(U.reason=B,U.filename=_.source,U.line=w,U.column=C,U.source=S,!_.silent)throw U}function T(B){var U=B.exec(S);if(U){var F=U[0];return N(F),S=S.slice(F.length),U}}function L(){T(n)}function A(B){var U;for(B=B||[];U=M();)U!==!1&&B.push(U);return B}function M(){var B=O();if(!(m!=S.charAt(0)||h!=S.charAt(1))){for(var U=2;p!=S.charAt(U)&&(h!=S.charAt(U)||m!=S.charAt(U+1));)++U;if(U+=2,p===S.charAt(U-1))return D("End of comment missing");var F=S.slice(2,U-2);return C+=2,N(F),S=S.slice(U),C+=2,B({type:g,comment:F})}}function $(){var B=O(),U=T(i);if(U){if(M(),!T(r))return D("property missing ':'");var F=T(o),V=B({type:y,property:k(U[0].replace(e,p)),value:F?k(F[0].replace(e,p)):p});return T(a),V}}function W(){var B=[];A(B);for(var U;U=$();)U!==!1&&(B.push(U),A(B));return B}return L(),W()}function k(S){return S?S.replace(u,p):p}return Dg=v,Dg}var ew;function oz(){if(ew)return qa;ew=1;var e=qa&&qa.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(qa,"__esModule",{value:!0}),qa.default=n;const t=e(sz());function n(i,r){let o=null;if(!i||typeof i!="string")return o;const a=(0,t.default)(i),u=typeof r=="function";return a.forEach(d=>{if(d.type!=="declaration")return;const{property:m,value:h}=d;u?r(m,h,d):h&&(o=o||{},o[m]=h)}),o}return qa}var Dc={},tw;function az(){if(tw)return Dc;tw=1,Object.defineProperty(Dc,"__esModule",{value:!0}),Dc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,r=/^-(ms)-/,o=function(m){return!m||n.test(m)||e.test(m)},a=function(m,h){return h.toUpperCase()},u=function(m,h){return"".concat(h,"-")},d=function(m,h){return h===void 0&&(h={}),o(m)?m:(m=m.toLowerCase(),h.reactCompat?m=m.replace(r,u):m=m.replace(i,u),m.replace(t,a))};return Dc.camelCase=d,Dc}var Oc,nw;function lz(){if(nw)return Oc;nw=1;var e=Oc&&Oc.__importDefault||function(r){return r&&r.__esModule?r:{default:r}},t=e(oz()),n=az();function i(r,o){var a={};return!r||typeof r!="string"||(0,t.default)(r,function(u,d){u&&d&&(a[(0,n.camelCase)(u,o)]=d)}),a}return i.default=i,Oc=i,Oc}var cz=lz();const uz=ta(cz),yN=vN("end"),nv=vN("start");function vN(e){return t;function t(n){const i=n&&n.position&&n.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function dz(e){const t=nv(e),n=yN(e);if(t&&n)return{start:t,end:n}}function Jc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?iw(e.position):"start"in e||"end"in e?iw(e):"line"in e||"column"in e?Fy(e):""}function Fy(e){return rw(e&&e.line)+":"+rw(e&&e.column)}function iw(e){return Fy(e&&e.start)+"-"+Fy(e&&e.end)}function rw(e){return e&&typeof e=="number"?e:1}class bi extends Error{constructor(t,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let r="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?r=t:!o.cause&&t&&(a=!0,r=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof i=="string"){const d=i.indexOf(":");d===-1?o.ruleId=i:(o.source=i.slice(0,d),o.ruleId=i.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=u?u.line:void 0,this.name=Jc(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}bi.prototype.file="";bi.prototype.name="";bi.prototype.reason="";bi.prototype.message="";bi.prototype.stack="";bi.prototype.column=void 0;bi.prototype.line=void 0;bi.prototype.ancestors=void 0;bi.prototype.cause=void 0;bi.prototype.fatal=void 0;bi.prototype.place=void 0;bi.prototype.ruleId=void 0;bi.prototype.source=void 0;const iv={}.hasOwnProperty,fz=new Map,mz=/[A-Z]/g,pz=new Set(["table","tbody","thead","tfoot","tr"]),hz=new Set(["td","th"]),bN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function gz(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let i;if(t.development){if(typeof t.j Line truncated
`;break}case-3:{a=`\r
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&r)continue;a=" ";break}default:a=String.fromCharCode(o)}r=o===-2,i.push(a)}return i.join("")}function wB(e){const i={constructs:CN([bB,...(e||{}).extensions||[]]),content:r(Bz),defined:[],document:r(Hz),flow:r(sB),lazy:{},string:r(lB),text:r(cB)};return i;function r(o){return a;function a(u){return _B(i,o,u)}}}function CB(e){for(;!TN(e););return e}const pw=/[\0\t\n\r]/g;function jB(){let e=1,t="",n=!0,i;return r;function r(o,a,u){const d=[];let m,h,p,g,y;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),p=0,t="",n&&(o.charCodeAt(0)===65279&&p++,n=void 0);p<o.length;){if(pw.lastIndex=p,m=pw.exec(o),g=m&&m.index!==void 0?m.index:o.length,y=o.charCodeAt(g),!m){t=o.slice(p);break}if(y===10&&p===g&&i)d.push(-3),i=void 0;else switch(i&&(d.push(-5),i=void 0),p<g&&(d.push(o.slice(p,g)),e+=g-p),y){case 0:{d.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,d.push(-2);e++<h;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:i=!0,e=1}p=g+1}return u&&(i&&d.push(-5),t&&d.push(t),d.push(null)),d}}const EB=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function NB(e){return e.replace(EB,IB)}function IB(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const r=n.charCodeAt(1),o=r===120||r===88;return jN(n.slice(o?2:1),o?16:10)}return av(n)||e}const LN={}.hasOwnProperty;function TB(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),RB(n)(CB(wB(n).document().write(jB()(e,t,!0))))}function RB(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(bt),autolinkProtocol:L,autolinkEmail:L,atxHeading:o(Ve),blockQuote:o(se),characterEscape:L,characterReference:L,codeFenced:o(_e),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(_e,a),codeText:o(we,a),codeTextData:L,data:L,codeFlowValue:L,definition:o(Ce),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Be),hardBreakEscape:o(Ye),hardBreakTrailing:o(Ye),htmlFlow:o(ht,a),htmlFlowData:L,htmlText:o(ht,a),htmlTextData:L,image:o(zt),label:a,link:o(bt),listItem:o(me),listItemValue:g,listOrdered:o(Nt,p),listUnordered:o(Nt),paragraph:o(ze),reference:P,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ve),strong:o(lt),thematicBreak:o(qe)},exit:{atxHeading:d(),atxHeadingSequence:O,autolink:d(),autolinkEmail:fe,autolinkProtocol:oe,blockQuote:d(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:te,characterReference:ie,codeFenced:d(S),codeFencedFence:k,codeFencedFenceInfo:y,codeFencedFenceMeta:v,codeFlowValue:A,codeIndented:d(_),codeText:d(U),codeTextData:A,data:A,definition:d(),definitionDestinationString:N,definitionLabelString:w,definitionTitleString:C,emphasis:d(),hardBreakEscape:d($),hardBreakTrailing:d($),htmlFlow:d(W),htmlFlowData:A,htmlText:d(B),htmlTextData:A,image:d(V),label:Q,labelText:Y,lineEnding:M,link:d(F),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:K,resourceDestinationString:q,resourceTitleString:G,resource:J,setextHeading:d(T),setextHeadingLineSequence:D,setextHeadingText:I,strong:d(),thematicBreak:d()}};zN(t,(e||{}).mdastExtensions||[]);const n={};return i;function i(ce){let ve={type:"root",children:[]};const Ae={stack:[ve],tokenStack:[],config:t,enter:u,exit:m,buffer:a,resume:h,data:n},$e=[];let He=-1;for(;++He<ce.length;)if(ce[He][1].type==="listOrdered"||ce[He][1].type==="listUnordered")if(ce[He][0]==="enter")$e.push(He);else{const Kt=$e.pop();He=r(ce,Kt,He)}for(He=-1;++He<ce.length;){const Kt=t[ce[He][0]];LN.call(Kt,ce[He][1].type)&&Kt[ce[He][1].type].call(Object.assign({sliceSerialize:ce[He][2].sliceSerialize},Ae),ce[He][1])}if(Ae.tokenStack.length>0){const Kt=Ae.tokenStack[Ae.tokenStack.length-1];(Kt[1]||hw).call(Ae,void 0,Kt[0])}for(ve.position={start:ro(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:ro(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},He=-1;++He<t.transforms.length;)ve=t.transforms[He](ve)||ve;return ve}function r(ce,ve,Ae){let $e=ve-1,He=-1,Kt=!1,Yt,be,Re,Ue;for(;++$e<=Ae;){const Xe=ce[$e];switch(Xe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Xe[0]==="enter"?He++:He--,Ue=void 0;break}case"lineEndingBlank":{Xe[0]==="enter"&&(Yt&&!Ue&&!He&&!Re&&(Re=$e),Ue=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ue=void 0}if(!He&&Xe[0]==="enter"&&Xe[1].type==="listItemPrefix"||He===-1&&Xe[0]==="exit"&&(Xe[1].type==="listUnordered"||Xe[1].type==="listOrdered")){if(Yt){let Ge=$e;for(be=void 0;Ge--;){const Je=ce[Ge];if(Je[1].type==="lineEnding"||Je[1].type==="lineEndingBlank"){if(Je[0]==="exit")continue;be&&(ce[be][1].type="lineEndingBlank",Kt=!0),Je[1].type="lineEnding",be=Ge}else if(!(Je[1].type==="linePrefix"||Je[1].type==="blockQuotePrefix"||Je[1].type==="blockQuotePrefixWhitespace"Line truncated
`}]}function LB(e,t){const n=t.value?t.value+`
`:"",i={},r=t.lang?t.lang.split(/\s+/):[];r.length>0&&(i.className=["language-"+r[0]]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function zB(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PB(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function BB(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),r=Ml(i.toLowerCase()),o=e.footnoteOrder.indexOf(i);let a,u=e.footnoteCounts.get(i);u===void 0?(u=0,e.footnoteOrder.push(i),a=e.footnoteOrder.length):a=o+1,u+=1,e.footnoteCounts.set(i,u);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,d);const m={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,m),e.applyData(t,m)}function $B(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function HB(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function PN(e,t){const n=t.referenceType;let i="]";if(n==="collapsed"?i+="[]":n==="full"&&(i+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+i}];const r=e.all(t),o=r[0];o&&o.type==="text"?o.value="["+o.value:r.unshift({type:"text",value:"["});const a=r[r.length-1];return a&&a.type==="text"?a.value+=i:r.push({type:"text",value:i}),r}function FB(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return PN(e,t);const r={src:Ml(i.url||""),alt:t.alt};i.title!==null&&i.title!==void 0&&(r.title=i.title);const o={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,o),e.applyData(t,o)}function VB(e,t){const n={src:Ml(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,i),e.applyData(t,i)}function UB(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const i={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,i),e.applyData(t,i)}function GB(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return PN(e,t);const r={href:Ml(i.url||"")};i.title!==null&&i.title!==void 0&&(r.title=i.title);const o={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function qB(e,t){const n={href:Ml(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function WB(e,t,n){const i=e.all(t),r=n?YB(n):BN(t),o={},a=[];if(typeof t.checked=="boolean"){const h=i[0];let p;h&&h.type==="element"&&h.tagName==="p"?p=h:(p={type:"element",tagName:"p",properties:{},children:[]},i.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u<i.length;){const h=i[u];(r||u!==0||h.type!=="element"||h.tagName!=="p")&&a.push({type:"text",value:`
`}),h.type==="element"&&h.tagName==="p"&&!r?a.push(...h.children):a.push(h)}const d=i[i.length-1];d&&(r||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
`});const m={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,m),e.applyData(t,m)}function YB(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let i=-1;for(;!t&&++i<n.length;)t=BN(n[i])}return t}function BN(e){const t=e.spread;return t??e.children.length>1}function XB(e,t){const n={},i=e.all(t);let r=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++r<i.length;){const a=i[r];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function KB(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ZB(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function QB(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JB(e,t){const n=e.all(t),i=n.shift(),r=[];if(i){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(t.children[0],a),r.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},u=nv(t.children[1]),d=yN(t.children[t.children.length-1]);u&&d&&(a.position={start:u,end:d}),r.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function e9(e,t,n){const i=n?n.children:void 0,o=(i?i.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,u=a?a.length:t.children.length;let d=-1;const m=[];for(;++d<u;){const p=t.children[d],g={},y=a?a[d]:void 0;y&&(g.align=y);let v={type:"element",tagName:o,properties:g,children:[]};p&&(v.children=e.all(p),e.patch(p,v),v=e.applyData(p,v)),m.push(v)}const h={type:"element",tagName:"tr",properties:{},children:e.wrap(m,!0)};return e.patch(t,h),e.applyData(t,h)}function t9(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const gw=9,xw=32;function n9(e){const t=String(e),n=/\r?\n|\r/g;let i=n.exec(t),r=0;const o=[];for(;i;)o.push(yw(t.slice(r,i.index),r>0,!0),i[0]),r=i.index+i[0].length,i=n.exec(t);return o.push(yw(t.slice(r),r>0,!1)),o.join("")}function yw(e,t,n){let i=0,r=e.length;if(t){let o=e.codePointAt(i);for(;o===gw||o===xw;)i++,o=e.codePointAt(i)}if(n){let o=e.codePointAt(r-1);for(;o===gw||o===xw;)r--,o=e.codePointAt(r-1)}return r>i?e.slice(i,r):""}function i9(e,t){const n={type:"text",value:n9(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function r9(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const s9={blockquote:DB,break:OB,code:LB,delete:zB,emphasis:PB,footnoteReference:BB,heading:$B,html:HB,imageReference:FB,image:VB,inlineCode:UB,linkReference:GB,link:qB,listItem:WB,list:XB,paragraph:KB,root:ZB,strong:QB,table:JB,tableCell:t9,tableRow:e9,text:i9,thematicBreak:r9,toml:ef,yaml:ef,definition:ef,footnoteDefinition:ef};function ef(){}const $N=-1,$m=0,tu=1,nm=2,cv=3,uv=4,dv=5,fv=6,HN=7,FN=8,vw=typeof self=="object"?self:globalThis,o9=(e,t)=>{const n=(r,o)=>(e.set(o,r),r),i=r=>{if(e.has(r))return e.get(r);const[o,a]=t[r];switch(o){case $m:case $N:return n(a,r);case tu:{const u=n([],r);for(const d of a)u.push(i(d));return u}case nm:{const u=n({},r);for(const[d,m]of a)u[i(d)]=i(m);return u}case cv:return n(new Date(a),r);case uv:{const{source:u,flags:d}=a;return n(new RegExp(u,d),r)}case dv:{const u=n(new Map,r);for(const[d,m]of a)u.set(i(d),i(m));return u}case fv:{const u=n(new Set,r);for(const d of a)u.add(i(d));return u}case HN:{const{name:u,message:d}=a;return n(new vw[u](d),r)}case FN:return n(BigInt(a),r);case"BigInt":return n(Object(BigInt(a)),r);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:u}=new Uint8Array(a);return n(new DataView(u),a)}}return n(new vw[o](a),r)};return i},bw=e=>o9(new Map,e)(0),Wa="",{toString:a9}={},{keys:l9}=Object,zc=e=>{const t=typeof e;if(t!=="object"||!e)return[$m,t];const n=a9.call(e).slice(8,-1);switch(n){case"Array":return[tu,Wa];case"Object":return[nm,Wa];case"Date":return[cv,Wa];case"RegExp":return[uv,Wa];case"Map":return[dv,Wa];case"Set":return[fv,Wa];case"DataView":return[tu,n]}return n.includes("Array")?[tu,n]:n.includes("Error")?[HN,n]:[nm,n]},tf=([e,t])=>e===$m&&(t==="function"||t==="symbol"),c9=(e,t,n,i)=>{const r=(a,u)=>{const d=i.push(a)-1;return n.set(u,d),d},o=a=>{if(n.has(a))return n.get(a);let[u,d]=zc(a);switch(u){case $m:{let h=a;switch(d){case"bigint":u=FN,h=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);h=null;break;case"undefined":return r([$N],a)}return r([u,h],a)}case tu:{if(d){let g=a;return d==="DataView"?g=new Uint8Array(a.buffer):d==="ArrayBuffer"&&(g=new Uint8Array( Line truncated
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:`
`}]}}const Hm=(function(e){if(e==null)return g9;if(typeof e=="function")return Fm(e);if(typeof e=="object")return Array.isArray(e)?m9(e):p9(e);if(typeof e=="string")return h9(e);throw new Error("Expected function, string, or object as test")});function m9(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Hm(e[n]);return Fm(i);function i(...r){let o=-1;for(;++o<t.length;)if(t[o].apply(this,r))return!0;return!1}}function p9(e){const t=e;return Fm(n);function n(i){const r=i;let o;for(o in e)if(r[o]!==t[o])return!1;return!0}}function h9(e){return Fm(t);function t(n){return n&&n.type===e}}function Fm(e){return t;function t(n,i,r){return!!(x9(n)&&e.call(this,n,typeof i=="number"?i:void 0,r||void 0))}}function g9(){return!0}function x9(e){return e!==null&&typeof e=="object"&&"type"in e}const VN=[],y9=!0,Gy=!1,v9="skip";function UN(e,t,n,i){let r;typeof t=="function"&&typeof n!="function"?(i=n,n=t):r=t;const o=Hm(r),a=i?-1:1;u(e,void 0,[])();function u(d,m,h){const p=d&&typeof d=="object"?d:{};if(typeof p.type=="string"){const y=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=VN,v,k,S;if((!t||o(d,m,h[h.length-1]||void 0))&&(y=b9(n(d,h)),y[0]===Gy))return y;if("children"in d&&d.children){const _=d;if(_.children&&y[0]!==v9)for(k=(i?_.children.length:-1)+a,S=h.concat(_);k>-1&&k<_.children.length;){const w=_.children[k];if(v=u(w,k,S)(),v[0]===Gy)return v;k=typeof v[1]=="number"?v[1]:k+a}}return y}}}function b9(e){return Array.isArray(e)?e:typeof e=="number"?[y9,e]:e==null?VN:[e]}function mv(e,t,n,i){let r,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,r=n):(o=t,a=n,r=i),UN(e,o,u,r);function u(d,m){const h=m[m.length-1],p=h?h.children.indexOf(d):void 0;return a(d,p,h)}}const qy={}.hasOwnProperty,_9={};function k9(e,t){const n=t||_9,i=new Map,r=new Map,o=new Map,a={...s9,...n.handlers},u={all:m,applyData:w9,definitionById:i,footnoteById:r,footnoteCounts:o,footnoteOrder:[],handlers:a,one:d,options:n,patch:S9,wrap:j9};return mv(e,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const p=h.type==="definition"?i:r,g=String(h.identifier).toUpperCase();p.has(g)||p.set(g,h)}}),u;function d(h,p){const g=h.type,y=u.handlers[g];if(qy.call(u.handlers,g)&&y)return y(u,h,p);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in h){const{children:k,...S}=h,_=im(S);return _.children=u.all(h),_}return im(h)}return(u.options.unknownHandler||C9)(u,h,p)}function m(h){const p=[];if("children"in h){const g=h.children;let y=-1;for(;++y<g.length;){const v=u.one(g[y],h);if(v){if(y&&g[y-1].type==="break"&&(!Array.isArray(v)&&v.type==="text"&&(v.value=kw(v.value)),!Array.isArray(v)&&v.type==="element")){const k=v.children[0];k&&k.type==="text"&&(k.value=kw(k.value))}Array.isArray(v)?p.push(...v):p.push(v)}}}return p}}function S9(e,t){e.position&&(t.position=dz(e))}function w9(e,t){let n=t;if(e&&e.data){const i=e.data.hName,r=e.data.hChildren,o=e.data.hProperties;if(typeof i=="string")if(n.type==="element")n.tagName=i;else{const a="children"in n?n.children:[n];n={type:"element",tagName:i,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,im(o)),"children"in n&&n.children&&r!==null&&r!==void 0&&(n.children=r)}return n}function C9(e,t){const n=t.data||{},i="value"in t&&!(qy.call(n,"hProperties")||qy.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function j9(e,t){const n=[];let i=-1;for(t&&n.push({type:"text",value:`
`});++i<e.length;)i&&n.push({type:"text",value:`
`}),n.push(e[i]);return t&&e.length>0&&n.push({type:"text",value:`
`}),n}function kw(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Sw(e,t){const n=k9(e,t),i=n.one(e,void 0),r=f9(n),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return r&&o.children.push({type:"text",value:`
`},r),o}function E9(e,t){return e&&"run"in e?async function(n,i){const r=Sw(n,{file:i,...t});await e.run(r,i)}:function(n,i){return Sw(n,{file:i,...e||t})}}function ww(e){if(e)throw e}var Pg,Cw;function N9(){if(Cw)return Pg;Cw=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=function(m){return typeof Array.isArray=="function"?Array.isArray(m):t.call(m)==="[object Array]"},o=function(m){if(!m||t.call(m)!=="[object Object]")return!1;var h=e.call(m,"constructor"),p=m.constructor&&m.constructor.prototype&&e.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!h&&!p)return!1;var g;for(g in m);return typeof g>"u"||e.call(m,g)},a=function(m,h){n&&h.name==="__proto__"?n(m,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):m[h.name]=h.newValue},u=function(m,h){if(h==="__proto__")if(e.call(m,h)){if(i)return i(m,h).value}else return;return m[h]};return Pg=function d(){var m,h,p,g,y,v,k=arguments[0],S=1,_=arguments.length,w=!1;for(typeof k=="boolean"&&(w=k,k=arguments[1]||{},S=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});S<_;++S)if(m=arguments[S],m!=null)for(h in m)p=u(k,h),g=u(m,h),k!==g&&(w&&g&&(o(g)||(y=r(g)))?(y?(y=!1,v=p&&r(p)?p:[]):v=p&&o(p)?p:{},a(k,{name:h,newValue:d(w,v,g)})):typeof g<"u"&&a(k,{name:h,newValue:g}));return k},Pg}var I9=N9();const Bg=ta(I9);function Wy(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function T9(){const e=[],t={run:n,use:i};return t;function n(...r){let o=-1;const a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);u(null,...r);function u(d,...m){const h=e[++o];let p=-1;if(d){a(d);return}for(;++p<r.length;)(m[p]===null||m[p]===void 0)&&(m[p]=r[p]);r=m,h?R9(h,u)(...m):a(null,...m)}}function i(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function R9(e,t){let n;return i;function i(...a){const u=e.length>a.length;let d;u&&a.push(r);try{d=e.apply(this,a)}catch(m){const h=m;if(u&&n)throw h;return r(h)}u||(d&&d.then&&typeof d.then=="function"?d.then(o,r):d instanceof Error?r(d):o(d))}function r(a,...u){n||(n=!0,t(a,...u))}function o(a){r(null,a)}}const Vr={basename:A9,dirname:M9,extname:D9,join:O9,sep:"/"};function A9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Mu(e);let n=0,i=-1,r=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(o){n=r+1;break}}else i<0&&(o=!0,i=r+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let a=-1,u=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(o){n=r+1;break}}else a<0&&(o=!0,a=r+1),u>-1&&(e.codePointAt(r)===t.codePointAt(u--)?u<0&&(i=r):(u=-1,i=a));return n===i?i=a:i<0&&(i=e.length),e.slice(n,i)}function M9(e){if(Mu(e),e.length===0)return".";let t=-1,n=e.length,i;for(;--n;)if(e.codePointAt(n)===47){if(i){t=n;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function D9(e){Mu(e);let t=e.length,n=-1,i=0,r=-1,o=0,a;for(;t--;){const u=e.codePointAt(t);if(u===47){if(a){i=t+1;break}continue}n<0&&(a=!0,n=t+1),u===46?r<0?r=t:o!==1&&(o=1):r>-1&&(o=-1)}return r<0||n<0||o===0||o===1&&r===n-1&&r===i+1?"":e.slice(r,n)}function O9(...e){let t=-1,n;for(;++t<e.length;)Mu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":L9(n)}function L9(e){Mu(e);const t=e.codePointAt(0)===47;let n=z9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function z9(e,t){let n="",i=0,r=-1,o=0,a=-1,u,d;for(;++a<=e.length;){if(a<e.length)u=e.codePointAt(a);else{if(u===47)break;u=47}if(u===47){if(!(r===a-1||o===1))if(r!==a-1&&o===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",i=0):(n=n.slice(0,d),i=n.length-1-n.lastIndexOf("/")),r=a,o=0;continue}}else if(n.length>0){n="",i=0,r=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(r+1,a):n=e.slice(r+1,a),i=a-r-1;r=a,o=0}else u===46&&o>-1?o++:o=-1}return n}function Mu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const P9={cwd:B9};function B9(){return"/"}function Yy(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function $9(e){if(typeof e=="string")e=new URL(e);else if(!Yy(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return H9(e)}function H9(e){if(e.hostname!==""){consLine truncated
`:" ")+o.indentLines(o.containerFlow(i,u.current()),t?YN:R$))),m(),d}}function R$(e,t,n){return t===0?e:YN(e,t,n)}function YN(e,t,n){return(n?"":" ")+e}const A$=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];XN.peek=z$;function M$(){return{canContainEols:["delete"],enter:{strikethrough:O$},exit:{strikethrough:L$}}}function D$(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:A$}],handlers:{delete:XN}}}function O$(e){this.enter({type:"delete",children:[]},e)}function L$(e){this.exit(e)}function XN(e,t,n,i){const r=n.createTracker(i),o=n.enter("strikethrough");let a=r.move("~~");return a+=n.containerPhrasing(e,{...r.current(),before:a,after:"~"}),a+=r.move("~~"),o(),a}function z$(){return"~"}function P$(e){return e.length}function B$(e,t){const n=t||{},i=(n.align||[]).concat(),r=n.stringLength||P$,o=[],a=[],u=[],d=[];let m=0,h=-1;for(;++h<e.length;){const k=[],S=[];let _=-1;for(e[h].length>m&&(m=e[h].length);++_<e[h].length;){const w=$$(e[h][_]);if(n.alignDelimiters!==!1){const C=r(w);S[_]=C,(d[_]===void 0||C>d[_])&&(d[_]=C)}k.push(w)}a[h]=k,u[h]=S}let p=-1;if(typeof i=="object"&&"length"in i)for(;++p<m;)o[p]=Aw(i[p]);else{const k=Aw(i);for(;++p<m;)o[p]=k}p=-1;const g=[],y=[];for(;++p<m;){const k=o[p];let S="",_="";k===99?(S=":",_=":"):k===108?S=":":k===114&&(_=":");let w=n.alignDelimiters===!1?1:Math.max(1,d[p]-S.length-_.length);const C=S+"-".repeat(w)+_;n.alignDelimiters!==!1&&(w=S.length+w+_.length,w>d[p]&&(d[p]=w),y[p]=w),g[p]=C}a.splice(1,0,g),u.splice(1,0,y),h=-1;const v=[];for(;++h<a.length;){const k=a[h],S=u[h];p=-1;const _=[];for(;++p<m;){const w=k[p]||"";let C="",N="";if(n.alignDelimiters!==!1){const O=d[p]-(S[p]||0),I=o[p];I===114?C=" ".repeat(O):I===99?O%2?(C=" ".repeat(O/2+.5),N=" ".repeat(O/2-.5)):(C=" ".repeat(O/2),N=C):N=" ".repeat(O)}n.delimiterStart!==!1&&!p&&_.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&w==="")&&(n.delimiterStart!==!1||p)&&_.push(" "),n.alignDelimiters!==!1&&_.push(C),_.push(w),n.alignDelimiters!==!1&&_.push(N),n.padding!==!1&&_.push(" "),(n.delimiterEnd!==!1||p!==m-1)&&_.push("|")}v.push(n.delimiterEnd===!1?_.join("").replace(/ +$/,""):_.join(""))}return v.join(`
`)}function $$(e){return e==null?"":String(e)}function Aw(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function H$(e,t,n,i){const r=n.enter("blockquote"),o=n.createTracker(i);o.move("> "),o.shift(2);const a=n.indentLines(n.containerFlow(e,o.current()),F$);return r(),a}function F$(e,t,n){return">"+(n?"":" ")+e}function V$(e,t){return Mw(e,t.inConstruct,!0)&&!Mw(e,t.notInConstruct,!1)}function Mw(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let i=-1;for(;++i<t.length;)if(e.includes(t[i]))return!0;return!1}function Dw(e,t,n,i){let r=-1;for(;++r<n.unsafe.length;)if(n.unsafe[r].character===`
`&&V$(n.stack,n.unsafe[r]))return/[ \t]/.test(i.before)?"":" ";return`\\
`}function U$(e,t){const n=String(e);let i=n.indexOf(t),r=i,o=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===r?++o>a&&(a=o):o=1,r=i+t.length,i=n.indexOf(t,r);return a}function G$(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function q$(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function W$(e,t,n,i){const r=q$(n),o=e.value||"",a=r==="`"?"GraveAccent":"Tilde";if(G$(e,n)){const p=n.enter("codeIndented"),g=n.indentLines(o,Y$);return p(),g}const u=n.createTracker(i),d=r.repeat(Math.max(U$(o,r)+1,3)),m=n.enter("codeFenced");let h=u.move(d);if(e.lang){const p=n.enter(`codeFencedLang${a}`);h+=u.move(n.safe(e.lang,{before:h,after:" ",encode:["`"],...u.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${a}`);h+=u.move(" "),h+=u.move(n.safe(e.meta,{before:h,after:`
`,encode:["`"],...u.current()})),p()}return h+=u.move(`
`),o&&(h+=u.move(o+`
`)),h+=u.move(d),m(),h}function Y$(e,t,n){return(n?"":" ")+e}function hv(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function X$(e,t,n,i){const r=hv(n),o=r==='"'?"Quote":"Apostrophe",a=n.enter("definition");let u=n.enter("label");const d=n.createTracker(i);let m=d.move("[");return m+=d.move(n.safe(n.associationId(e),{before:m,after:"]",...d.current()})),m+=d.move("]: "),u(),!e.url||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),m+=d.move("<"),m+=d.move(n.safe(e.url,{before:m,after:">",...d.current()})),m+=d.move(">")):(u=n.enter("destinationRaw"),m+=d.move(n.safe(e.url,{before:m,after:e.title?" ":`
`,...d.current()}))),u(),e.title&&(u=n.enter(`title${o}`),m+=d.move(" "+r),m+=d.move(n.safe(e.title,{before:m,after:r,...d.current()})),m+=d.move(r),u()),a(),m}function K$(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function yu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function rm(e,t,n){const i=yl(e),r=yl(t);return i===void 0?r===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}KN.peek=Z$;function KN(e,t,n,i){const r=K$(n),o=n.enter("emphasis"),a=n.createTracker(i),u=a.move(r);let d=a.move(n.containerPhrasing(e,{after:r,before:u,...a.current()}));const m=d.charCodeAt(0),h=rm(i.before.charCodeAt(i.before.length-1),m,r);h.inside&&(d=yu(m)+d.slice(1));const p=d.charCodeAt(d.length-1),g=rm(i.after.charCodeAt(0),p,r);g.inside&&(d=d.slice(0,-1)+yu(p));const y=a.move(r);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:h.outside},u+d+y}function Z$(e,t,n){return n.options.emphasis||"*"}function Q$(e,t){let n=!1;return mv(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return n=!0,Gy}),!!((!e.depth||e.depth<3)&&ov(e)&&(t.options.setext||n))}function J$(e,t,n,i){const r=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(i);if(Q$(e,n)){const h=n.enter("headingSetext"),p=n.enter("phrasing"),g=n.containerPhrasing(e,{...o.current(),before:`
`,after:`
`});return p(),h(),g+`
`+(r===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
`))+1))}const a="#".repeat(r),u=n.enter("headingAtx"),d=n.enter("phrasing");o.move(a+" ");let m=n.containerPhrasing(e,{before:"# ",after:`
`,...o.current()});return/^[\t ]/.test(m)&&(m=yu(m.charCodeAt(0))+m.slice(1)),m=m?a+" "+m:a,n.options.closeAtx&&(m+=" "+a),d(),u(),m}ZN.peek=e7;function ZN(e){return e.value||""}function e7(){return"<"}QN.peek=t7;function QN(e,t,n,i){const r=hv(n),o=r==='"'?"Quote":"Apostrophe",a=n.enter("image");let u=n.enter("label");const d=n.createTracker(i);let m=d.move("![");return m+=d.move(n.safe(e.alt,{before:m,after:"]",...d.current()})),m+=d.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),m+=d.move("<"),m+=d.move(n.safe(e.url,{before:m,after:">",...d.current()})),m+=d.move(">")):(u=n.enter("destinationRaw"),m+=d.move(n.safe(e.url,{before:m,after:e.title?" ":")",...d.current()}))),u(),e.title&&(u=n.enter(`title${o}`),m+=d.move(" "+r),m+=d.move(n.safe(e.title,{before:m,after:r,...d.current()})),m+=d.move(r),u()),m+=d.move(")"),a(),m}function t7(){return"!"}JN.peek=n7;function JN(e,t,n,i){const r=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const u=n.createTracker(i);let d=u.move("![");const m=n.safe(e.alt,{before:d,after:"]",...u.current()});d+=u.move(m+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return a(),n.stack=h,o(),r==="full"||!m||m!==p?d+=u.move(p+"]"):r==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function n7(){return"!"}eI.peek=i7;function eI(e,t,n){let i=e.value||"",r="`",o=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(i);)r+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++o<n.unsafe.length;){const a=n.unsafe[o],u=n.compilePattern(a);let d;if(a.atBreak)for(;d=u.exec(i);){let m=d.index;i.charCodeAt(m)===10&&i.charCodeAt(m-1)===13&&m--,i=i.slice(0,m)+" "+i.slice(d.index+1)}}return r+i+r}function i7(){return"`"}function tI(e,t){const n=ov(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}nI.peek=r7;function nI(e,t,n,i){const r=hv(n),o=r==='"'?"Quote":"Apostrophe",a=n.createTracker(i);let u,d;if(tI(e,n)){const h=n.stack;n.stack=[],u=n.enter("autolink");let p=a.move("<");return p+=a.move(n.containerPhrasing(e,{before:p,after:">",...a.current()})),p+=a.move(">"),u(),n.stack=h,p}u=n.enter("link"),d=n.enter("label");let m=a.move("[");return m+=a.move(n.containerPhrasing(e,{before:m,after:"](",...a.current()})),m+=a.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),m+=a.move("<"),m+=a.move(n.safe(e.url,{before:m,after:">",...a.current()})),m+=a.move(">")):(d=n.enter("destinationRaw"),m+=a.move(n.safe(e.url,{before:m,after:e.title?" ":")",...a.current()}))),d(),e.title&&(d=n.enter(`title${o}`),m+=a.move(" "+r),m+=a.move(n.safe(e.title,{before:m,after:r,...a.current()})),m+=a.move(r),d()),m+=a.move(")"),u(),m}function r7(e,t,n){return tI(e,n)?"<":"["}iI.peek=s7;function iI(e,t,n,i){const r=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const u=n.createTracker(i);let d=u.move("[");const m=n.containerPhrasing(e,{before:d,after:"]",...u.current()});d+=u.move(m+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return a(),n.stack=h,o(),r==="full"||!m||m!==p?d+=u.move(p+"]"):r==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function s7(){return"["}function gv(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function o7(e){const t=gv(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function a7(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function rI(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function l7(e,t,n,i){const r=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?a7(n):gv(n);const u=e.ordered?a==="."?")":".":o7(n);let d=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),rI(n)===a&&h){let p=-1;for(;++p<e.chilLine truncated
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:a,tableCell:d,tableRow:u}};function a(y,v,k,S){return m(h(y,k,S),y.align)}function u(y,v,k,S){const _=p(y,k,S),w=m([_]);return w.slice(0,w.indexOf(`
`))}function d(y,v,k,S){const _=k.enter("tableCell"),w=k.enter("phrasing"),C=k.containerPhrasing(y,{...S,before:o,after:o});return w(),_(),C}function m(y,v){return B$(y,{align:v,alignDelimiters:i,padding:n,stringLength:r})}function h(y,v,k){const S=y.children;let _=-1;const w=[],C=v.enter("table");for(;++_<S.length;)w[_]=p(S[_],v,k);return C(),w}function p(y,v,k){const S=y.children;let _=-1;const w=[],C=v.enter("tableRow");for(;++_<S.length;)w[_]=d(S[_],y,v,k);return C(),w}function g(y,v,k){let S=oI.inlineCode(y,v,k);return k.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function j7(){return{exit:{taskListCheckValueChecked:Lw,taskListCheckValueUnchecked:Lw,paragraph:N7}}}function E7(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:I7}}}function Lw(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function N7(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const i=n.children[0];if(i&&i.type==="text"){const r=t.children;let o=-1,a;for(;++o<r.length;){const u=r[o];if(u.type==="paragraph"){a=u;break}}a===n&&(i.value=i.value.slice(1),i.value.length===0?n.children.shift():n.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,n.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function I7(e,t,n,i){const r=e.children[0],o=typeof e.checked=="boolean"&&r&&r.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",u=n.createTracker(i);o&&u.move(a);let d=oI.listItem(e,t,n,{...i,...u.current()});return o&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),d;function m(h){return h+a}}function T7(){return[l$(),I$(),M$(),v7(),j7()]}function R7(e){return{extensions:[c$(),T$(e),D$(),C7(e),E7()]}}const A7={tokenize:P7,partial:!0},aI={tokenize:B7,partial:!0},lI={tokenize:$7,partial:!0},cI={tokenize:H7,partial:!0},M7={tokenize:F7,partial:!0},uI={name:"wwwAutolink",tokenize:L7,previous:fI},dI={name:"protocolAutolink",tokenize:z7,previous:mI},Is={name:"emailAutolink",tokenize:O7,previous:pI},es={};function D7(){return{text:es}}let zo=48;for(;zo<123;)es[zo]=Is,zo++,zo===58?zo=65:zo===91&&(zo=97);es[43]=Is;es[45]=Is;es[46]=Is;es[95]=Is;es[72]=[Is,dI];es[104]=[Is,dI];es[87]=[Is,uI];es[119]=[Is,uI];function O7(e,t,n){const i=this;let r,o;return a;function a(p){return!Xy(p)||!pI.call(i,i.previous)||xv(i.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(p))}function u(p){return Xy(p)?(e.consume(p),u):p===64?(e.consume(p),d):n(p)}function d(p){return p===46?e.check(M7,h,m)(p):p===45||p===95||vi(p)?(o=!0,e.consume(p),d):h(p)}function m(p){return e.consume(p),r=!0,d}function h(p){return o&&r&&Ei(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function L7(e,t,n){const i=this;return r;function r(a){return a!==87&&a!==119||!fI.call(i,i.previous)||xv(i.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(A7,e.attempt(aI,e.attempt(lI,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function z7(e,t,n){const i=this;let r="",o=!1;return a;function a(p){return(p===72||p===104)&&mI.call(i,i.previous)&&!xv(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(p),e.consume(p),u):n(p)}function u(p){if(Ei(p)&&r.length<5)return r+=String.fromCodePoint(p),e.consume(p),u;if(p===58){const g=r.toLowerCase();if(g==="http"||g==="https")return e.consume(p),d}return n(p)}function d(p){return p===47?(e.consume(p),o?m:(o=!0,d)):n(p)}function m(p){return p===null||tm(p)||pn(p)||Yo(p)||Pm(p)?n(p):e.attempt(aI,e.attempt(lI,h),n)(p)}function h(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function P7(e,t,n){let i=0;return r;function r(a){return(a===87||a===119)&&i<3?(i++,e.consume(a),r):a===46&&i===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function B7(e,t,n){let i,r,o;return a;function a(m){return m===46||m===95?e.check(cI,d,u)(m):m===null||pn(m)||Yo(m)||m!==45&&Pm(m)?d(m):(o=!0,e.consume(m),a)}function u(m){return m===95?i=!0:(r=i,i=void 0),e.consume(m),a}function d(m){return r||i||!o?n(m):t(m)}}function $7(e,t){let n=0,i=0;return r;function r(a){return a===40?(n++,e.consume(a),r):a===41&&i<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(cI,t,o)(a):a===null||pn(a)||Yo(a)?t(a):(e.consume(a),r)}function o(a){return a===41&&i++,e.consume(a),r}}function H7(e,t,n){return i;function i(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),i):u===38?(e.consume(u),o):u===93?(e.consume(u),r):u===60||u===null||pn(u)||Yo(u)?t(u):n(u)}function r(u){return u===null||u===40||u===91||pn(u)||Yo(u)?t(u):i(u)}function o(u){return Ei(u)?a(u):n(u)}function a(u){re Line truncated
`),m=d.length>fH,h=m?d.length-Kg*2:0,p=E.useCallback(()=>{navigator.clipboard.writeText(a),i(!0),setTimeout(()=>i(!1),1500)},[a]);return c.jsxs("div",{className:"code-block-wrap",children:[c.jsxs("div",{className:"code-block-header",children:[c.jsxs("span",{className:"code-block-lang",children:[u||"code",m?` (${d.length} lines)`:""]}),c.jsx("button",{className:"code-block-copy",onClick:p,children:n?c.jsxs(c.Fragment,{children:[c.jsx(Nl,{})," ",c.jsx("span",{children:"Copied"})]}):c.jsxs(c.Fragment,{children:[c.jsx(Cm,{})," ",c.jsx("span",{children:"Copy"})]})})]}),c.jsx("pre",{children:c.jsx("code",{className:e,children:m&&!r?c.jsxs(c.Fragment,{children:[d.slice(0,Kg).join(`
`)+`
`,c.jsxs("span",{className:"code-block-omitted",onClick:()=>o(!0),children:["... +",h," lines (click to expand)"]}),`
`+d.slice(-Kg).join(`
`)]}):a})}),m&&r&&c.jsxs("button",{className:"code-block-collapse-btn",onClick:()=>o(!1),children:["Collapse (",d.length," lines)"]})]})}const pH={code({className:e,children:t,...n}){return e?.startsWith("language-")?c.jsx(mH,{className:e,children:t}):c.jsx("code",{className:e,...n,children:t})}},hH=3e3,gH=60,Zg=800;function Pw(e){if(e.length>hH)return!0;let t=0;for(let n=0;n<e.length;n++)if(e[n]===`
`&&++t>=gH)return!0;return!1}function xH(e){const t=e.lastIndexOf(`
`,Zg);return e.slice(0,t>Zg/2?t:Zg)}const ti=St.memo(function({content:t,className:n="msg-content-agent",collapseMode:i="auto"}){const r=i!=="never"&&Pw(t),[o,a]=E.useState(r);E.useEffect(()=>{a(i!=="never"&&Pw(t))},[i,t]);const u=o?xH(t):t,d=t.split(`
`).length,m=t.length;return c.jsxs("div",{className:n,children:[c.jsx(Q9,{remarkPlugins:[dH],components:pH,children:u}),r&&o&&c.jsxs("button",{className:"msg-collapse-toggle",onClick:()=>a(!1),children:["Show more (",d," lines, ",(m/1e3).toFixed(1),"k chars)"]}),r&&!o&&c.jsx("button",{className:"msg-collapse-toggle",onClick:()=>a(!0),children:"Show less"})]})}),Bw={native:"OpenOPC Native",codex:"Codex",claude_code:"Claude Code",cursor:"Cursor",opencode:"OpenCode"},vu="codex",Qg="native",yH=["codex","native","claude_code","cursor","opencode"],vH=["native","codex","claude_code","cursor","opencode"];function hI(e){if(!e)return{kind:"fallback"};if(e.kind==="employee"){const t=String(e.id??e.employee_id??"").trim();return t?{kind:"employee",id:t}:{kind:"fallback"}}if(e.kind==="template"){const t=String(e.id??e.template_id??"").trim();return t?{kind:"template",id:t}:{kind:"fallback"}}return{kind:"fallback"}}function gI(e){const t=hI(e);return t.kind==="fallback"?"fallback:":`${t.kind}:${t.id??""}`}function bH(e,t,n){const i=String(e.role_id??"").trim(),r=String(e.role_label??"").trim(),o=`${i} ${r} ${e.role_responsibility??""}`.toLowerCase(),a=new Set((e.same_role_employee_ids??[]).map(m=>String(m??"").trim()).filter(Boolean)),u=t.map(m=>{const h=String(m.employee_id??"").trim(),p=String(m.employee_name??h).trim()||h,g=String(m.role_id??"").trim(),y=String(m.category??"").trim(),v=[g,y].filter(Boolean).join(" · ")||h;return{kind:"employee",id:h,name:p,subtitle:v,category:y,searchText:`${h} ${p} ${g} ${y} ${(m.domains??[]).join(" ")} ${(m.tags??[]).join(" ")}`.toLowerCase(),rank:a.has(h)||g===i?0:2}}).filter(m=>m.id).sort((m,h)=>m.rank-h.rank||m.name.localeCompare(h.name)),d=n.map(m=>{const h=String(m.template_id??"").trim(),p=String(m.template_name??h).trim()||h,g=String(m.category??"").trim(),y=[g,h].filter(Boolean).join(" · ")||h,v=`${h} ${p} ${g} ${(m.domains??[]).join(" ")} ${(m.tags??[]).join(" ")}`.toLowerCase(),k=o.split(/[^a-z0-9]+/).filter(S=>S.length>=3).reduce((S,_)=>S+(v.includes(_)?1:0),0);return{kind:"template",id:h,name:p,subtitle:y,category:g,searchText:v,rank:k}}).filter(m=>m.id).sort((m,h)=>h.rank-m.rank||m.name.localeCompare(h.name));return[...u,...d,{kind:"fallback",id:"",name:"Fallback role-only",subtitle:"No employee override",category:"fallback",searchText:"fallback role only no employee override"}]}function _H(e,t){const n=gI(t);return e.find(i=>`${i.kind}:${i.id}`===n)??e[0]}function kH(e,t){const n=t.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?!0:n.every(i=>e.searchText.includes(i))}function SH(e){return e.map(t=>{const n=String(t.role_id??"").trim(),i=String(t.existing_employee?.employee_id??"").trim(),r=String(t.candidate?.template_id??"").trim(),o=i?{kind:"employee",id:i}:r?{kind:"template",id:r}:{kind:"fallback"};return{role_id:n,role_label:t.role_labels?.[0]??n,role_responsibility:"",default_selection:o,same_role_employee_ids:t.existing_employee_ids??[],fallback_available:!0,default_agent:t.default_agent??vu,selected_agent:t.selected_agent??t.default_agent??vu,default_source:"recruitment"}}).filter(t=>t.role_id)}function wH(e,t){return t.kind==="template"&&e?.candidate?.template_id===t.id?e.candidate.proposed_name||e.candidate.template_name||t.name:t.kind==="employee"&&e?.existing_employee?.employee_id===t.id&&e.existing_employee.employee_name||t.name}function $w(e,t){const n={},i=e.staffing_selections??{};for(const r of t){const o=String(r.role_id??"").trim();o&&(n[o]=hI(i[o]??r.default_selection))}return n}function Hw(e,t){const n=e.recruitment_role_agents??{},i={};for(const r of t){const o=String(r.role_id??"").trim();o&&(i[o]=n[o]??r.selected_agent??r.default_agent??vu)}return i}function CH(e){return!!(String(e.checkpoint_response_message_id??"").trim()||String(e.checkpoint_responded_at??"").trim()||String(e.checkpoint_reply_kind??"").trim())}const xI=St.memo(function({meta:t,onReply:n,responded:i}){const r=t.proposals??[],o=E.useMemo(()=>{const L={};for(const A of r){const M=String(A.role_id??"").trim();M&&(L[M]=A)}return L},[r]),a=E.useMemo(()=>t.staffing_roles?.length?t.staffing_roles:SH(r),[t.staffing_roles,r]),u=t.staffing_pool?.employees??[],d=t.staffing_pool?.templates??[],m=t.recruitment_rationales??[],h=E.useMemo(()=>{const L={};for(const A of a){const M=String(A.role_id??"").trim();M&&(L[M]=bH(A,u,d))}return L},[u,a,d]),[p,g]=E.useState({}),[y,v]=E.useState(""),[k,S]=E.useState(()=>$w(t,a)),[_,w]=E.useState(()=>Hw(t,a)),[C,N]=E.useState(t.recruitment_agent??Qg),O=i;E.useEffect(()=>{!O||!CH(t)||(S($w(t,a)),w(Hw(t,a)),N(t.recruitment_agent??Qg))},[O,t,a]),E.useEffect(()=>{N(t.recruitment_agent??Qg)},[t.recruitment_agent]);const I=E.useCallback(L=>{const A=String(t.checkpoint_id??"").trim();if(!A)throw new Error("Recruitment checkpoint reply requires checkpoint_id metadata.");const M=String(t.checkpoint_type??"").trim();return{response_to_checkpoint_id:A,response_to_checkpoint_type:M||"company_recruitment_confirmation",checkpoint_reply_kind:L,staffin Line truncated
`).map(t=>t.trim()).find(Boolean)??e}function OH(e){switch(e){case"timeout":case"timed_out":case"expired":return"Expired";case"stale":case"invalid":return"Inactive";case"cancelled":case"canceled":return"Cancelled";case"resolved":return"Resolved";default:return"Responded"}}const sm=St.memo(function({meta:t,onReply:n,responded:i}){const r=i,o=String(t.checkpoint_status??"").trim().toLowerCase(),a=OH(o),u=String(t.prompt??t.summary??""),d=E.useMemo(()=>u.split(`
`).map(O=>O.trim()).filter(Boolean),[u]),m=DH(u).replace(/^\[[^\]]+\]\s*/,"")||"Action Required",h=d.slice(1).join(`
`).trim(),p=String(t.summary??"").trim(),g=(t.options??[]).filter(O=>!!O?.id),y=E.useMemo(()=>(t.active_subagents??[]).filter(O=>!!O&&typeof O=="object"),[t.active_subagents]),v=E.useMemo(()=>(t.permission_requests??[]).filter(O=>!!O&&typeof O=="object"),[t.permission_requests]),k=String(t.worktree_path??"").trim(),S=y.length>0||v.length>0||!!k,[_,w]=E.useState(""),C=!!_&&!r;E.useEffect(()=>{if(!C)return;const O=window.setTimeout(()=>w(""),MH);return()=>window.clearTimeout(O)},[C,_]);const N=E.useCallback(O=>{r||C||(w(O.id),n(O.label||O.id))},[r,C,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-escalation",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-escalation",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M8 1.5L14.5 13H1.5L8 1.5Z"}),c.jsx("path",{d:"M8 5.5V9"}),c.jsx("circle",{cx:"8",cy:"11.5",r:"0.75",fill:"currentColor",stroke:"none"})]})}),c.jsx("div",{className:"ckpt-title",children:m}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:String(t.escalation_type??"decision_needed").replace(/_/g," ")}),r&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:a})]}),p&&p!==m&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ti,{content:p,className:"ckpt-markdown"})]}),h&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Request"}),c.jsx(ti,{content:h,className:"ckpt-markdown"})]}),S&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[k&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:k})]}),y.length>0&&c.jsxs("div",{children:["Active subagents: ",y.length]}),v.length>0&&c.jsxs("div",{children:["Pending permission records: ",v.length]})]})]}),!r&&g.length>0&&c.jsx("div",{className:"ckpt-actions ckpt-escalation-actions",children:g.map(O=>c.jsx("button",{className:`ckpt-btn ${O.id.includes("deny")?"ckpt-btn-deny":"ckpt-btn-approve"}${C?" ckpt-btn-submitting":""}`,onClick:()=>N(O),disabled:C,children:C&&_===O.id?"Submitting…":O.label||O.id},O.id))}),C&&c.jsx("div",{className:"ckpt-escalation-hint",children:"Decision sent — waiting for server confirmation…"}),!r&&t.default_action&&c.jsxs("div",{className:"ckpt-escalation-hint",children:["Default on timeout: ",c.jsx("code",{children:t.default_action})]})]})});function LH(e){return e.split(`
`).map(t=>t.trim()).find(Boolean)??e}function zH(e){switch(e){case"ignored":return"Ignored";case"timeout":case"timed_out":case"expired":return"Expired";case"stale":case"invalid":return"Inactive";case"superseded":return"Superseded";case"cancelled":case"canceled":return"Cancelled";case"resolved":return"Resolved";default:return"Responded"}}const kI=St.memo(function({meta:t,onReply:n,responded:i}){const r=i,[o,a]=E.useState(""),[u,d]=E.useState(null),m=String(t.checkpoint_status??"").trim().toLowerCase(),h=zH(m),p=String(t.prompt??t.summary??"").trim(),y=`${String(t.work_item_projection_title??LH(p)??"Human Review").trim()||"Human Review"} (for self-evolution)`,v=String(t.summary??"").trim(),k=E.useMemo(()=>(t.active_subagents??[]).filter(T=>!!T&&typeof T=="object"),[t.active_subagents]),S=E.useMemo(()=>(t.permission_requests??[]).filter(T=>!!T&&typeof T=="object"),[t.permission_requests]),_=String(t.worktree_path??"").trim(),w=k.length>0||S.length>0||!!_,C=r||u!==null,N=E.useCallback((T,L="")=>{const A=String(t.checkpoint_id??"").trim();if(!A)throw new Error("Delivery self-evolution reply requires checkpoint_id metadata.");const M={response_to_checkpoint_id:A,response_to_checkpoint_type:"company_delivery_feedback",checkpoint_reply_kind:T};return(T==="approve"||T==="feedback")&&(M.self_evolution_trigger=!0,M.human_feedback_text=L),M},[t.checkpoint_id]),O=E.useCallback(()=>{if(C)return;const T=N("approve");d("approve"),n("I fully agree with this delivery.",T)},[C,N,n]),I=E.useCallback(()=>{const T=o.trim();if(C||!T)return;const L=N("feedback",T);d("feedback"),n(T,L),a("")},[C,N,o,n]),D=E.useCallback(()=>{if(C)return;const T=N("ignore");d("ignore"),n("Ignore this self-evolution review.",T)},[C,N,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-delivery-feedback",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-user-input",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M8 1.5L14 5v4.5c0 2.25-1.8 4.25-6 5-4.2-.75-6-2.75-6-5V5L8 1.5Z"}),c.jsx("path",{d:"M5.5 8.25L7.25 10l3.25-4"})]})}),c.jsx("div",{className:"ckpt-title",children:y}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:String(t.feedback_scope??"final").replace(/_/g," ")}),r&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:h})]}),v&&v!==y&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ti,{content:v,className:"ckpt-markdown"})]}),p&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Review Request"}),c.jsx(ti,{content:p,className:"ckpt-markdown"})]}),w&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[_&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:_})]}),k.length>0&&c.jsxs("div",{children:["Active subagents: ",k.length]}),S.length>0&&c.jsxs("div",{children:["Pending permission records: ",S.length]})]})]}),!r&&c.jsxs("div",{className:"ckpt-actions ckpt-actions-inline-feedback",children:[c.jsx("button",{className:"ckpt-btn ckpt-btn-approve",onClick:O,disabled:C,children:"Fully Agree"}),c.jsx("button",{className:"ckpt-btn ckpt-btn-cancel",onClick:D,disabled:C,children:"Ignore"}),c.jsx("textarea",{className:"ckpt-feedback-input ckpt-feedback-inline-input",placeholder:"Feedback for self-evolution...",value:o,onChange:T=>a(T.target.value),disabled:C,rows:2}),c.jsx("button",{className:"ckpt-btn ckpt-btn-feedback",onClick:I,disabled:C||!o.trim(),children:"Send Feedback"})]})]})}),sf="__other__",PH=["A","B","C"];function Ur(e){return String(e??"").trim()}function BH(e,t){const n=Ur(e.question),i=Ur(e.header);if(!n&&!i)return null;const r=(e.options??[]).slice(0,3).map((o,a)=>({id:Ur(o.id)||String.fromCharCode(97+a),label:Ur(o.label),description:Ur(o.description)})).filter(o=>o.label);return{id:Ur(e.id)||`question_${t+1}`,header:i,question:n||i,options:r,allow_freeform:e.allow_freeform!==!1,required:e.required!==!1}}const SI=St.memo(function({meta:t,onReply:n,responded:i}){const[r,o]=E.useState(""),[a,u]=E.useState({}),d=i,m=String(t.work_item_projection_title??t.work_item_projection_id??"Input Needed").trim()||"Input Needed",h=String(t.summary??"").trim(),p=String(t.prompt??"").trim(),g=String(t.context_note??"").trim(),y=String(t.resume_hint??"").trim(),v=E.useMemo(()=>(t.questions??[]).map(V=>String(V).trim()).filter(Boolean),[t.questions]),k=E.useMemo(()=>(t.input_questions??[]).map((V,Y)=>BH(V,Y)).filter(V=>V!==null),[t.input_questions]),S=k.some(V=>(V.options??[]).length>0),_=E.useMemo(()=>(t.required_fields??[]).map(V=>String(V).trim()).filter(Boolean),[t.required_fields]),w=E.useMemo(()=>(t.active_subagents??[]).filter(V=>!!V&&typeof V=="object"),[t.active_subagents]),C=E.useMemo(( Line truncated
`),{user_input_answers:V})},[a,B,k,d,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-user-input",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-user-input",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M3 3.5h10v6H6.5L3 13V3.5Z"}),c.jsx("path",{d:"M5.5 6h5"}),c.jsx("path",{d:"M5.5 8h3.5"})]})}),c.jsx("div",{className:"ckpt-title",children:m}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:"awaiting input"}),d&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:"Responded"})]}),h&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ti,{content:h,className:"ckpt-markdown"})]}),p&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Request"}),c.jsx(ti,{content:p,className:"ckpt-markdown"})]}),S?c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Questions"}),c.jsx("div",{className:"ckpt-choice-list",children:k.map(V=>{const Y=a[V.id]??{freeformText:""},Q=V.options??[],q=V.allow_freeform!==!1,G=q&&(Q.length===0||Y.selectedOptionId===sf);return c.jsxs("div",{className:"ckpt-choice-question",children:[V.header&&c.jsx("div",{className:"ckpt-question-header",children:V.header}),c.jsx(ti,{content:V.question,className:"ckpt-markdown"}),Q.length>0&&c.jsxs("div",{className:"ckpt-choice-grid",children:[Q.map((J,P)=>{const K=Y.selectedOptionId===J.id;return c.jsxs("button",{className:`ckpt-choice-option${K?" is-selected":""}`,onClick:()=>M(V.id,J.id),children:[c.jsx("span",{className:"ckpt-choice-letter",children:PH[P]??"?"}),c.jsxs("span",{className:"ckpt-choice-copy",children:[c.jsx("span",{className:"ckpt-choice-label",children:J.label}),J.description&&c.jsx("span",{className:"ckpt-choice-desc",children:J.description})]})]},J.id)}),q&&c.jsxs("button",{className:`ckpt-choice-option${Y.selectedOptionId===sf?" is-selected":""}`,onClick:()=>M(V.id,sf),children:[c.jsx("span",{className:"ckpt-choice-letter",children:"D"}),c.jsxs("span",{className:"ckpt-choice-copy",children:[c.jsx("span",{className:"ckpt-choice-label",children:"Other"}),c.jsx("span",{className:"ckpt-choice-desc",children:"Enter a custom answer"})]})]})]}),G&&c.jsx("textarea",{className:"ckpt-feedback-input ckpt-other-field",placeholder:"Type your answer...",value:Y.freeformText,onChange:J=>$(V.id,J.target.value),rows:3})]},V.id)})})]}):v.length>0&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Questions"}),c.jsx("ul",{className:"ckpt-task-list",children:v.map(V=>c.jsx("li",{children:V},V))})]}),_.length>0&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Required Fields"}),c.jsx("div",{className:"ckpt-task-tags",children:_.map(V=>c.jsx("span",{className:"ckpt-field-tag",children:V},V))})]}),g&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Context"}),c.jsx(ti,{content:g,className:"ckpt-markdown ckpt-markdown-muted"})]}),y&&c.jsx("div",{className:"ckpt-escalation-hint",children:y}),A&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[O&&c.jsxs("div",{children:["Requester: ",c.jsx("code",{children:O})]}),D&&c.jsxs("div",{children:["Work item: ",c.jsx("code",{children:D})]}),I&&c.jsxs("div",{children:["Task: ",c.jsx("code",{children:I})]}),T&&c.jsxs("div",{children:["Seat: ",c.jsx("code",{children:T})]}),N&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:N})]}),w.length>0&&c.jsxs("div",{children:["Active subagents: ",w.length]}),C.length>0&&c.jsxs("div",{children:["Pending permission records: ",C.length]})]})]}),!d&&c.jsxs("div",{className:"ckpt-feedback-area",children:[S?null:c.jsx("textarea",{className:"ckpt-feedback-input",placeholder:"Reply with the missing input to continue...",value:r,onChange:V=>o(V.target.value),rows:3}),c.jsx("div",{className:"ckpt-feedback-btns",children:c.jsx("button",{className:"ckpt-btn ckpt-btn-approve",onClick:S?F:U,disabled:S?!B:!r.trim(),children:"Send Reply"})})]})]})}),Zy={todo:"To do",in_progress:"In progress",in_review:"In review",done:"Done"};function ex(e,t){if(t&&t in Zy)return t;switch(e){case"active":return"in_progress";case"waiting":return"in_review";case"done":return"done";case"failed":return"done";case"pending":return"todo";default:return"todo"}}function of(e){return Zy[e]??Zy.todo}const qw={active:0,waiting:1,failed:2,done:3,pending:4};function $H(e){if(e.length===0)return"pending";let t=e[0],n=qw[t]??99;for(const i of e){const r=qw[i]??99;r<n&&(t=i,n=r)}return t}const HH={native:"Native",codex:"Codex",claude_code:"Claude Code",cursor Line truncated
`)[0].slice(0,140),tone:"danger"};const o=t.match(/^\[Company:([^\]]+)\]\s*(.+)$/);if(o){const d=o[1].split("::"),m=d[0]||"company",h=o[2].trim(),p=h.toLowerCase(),g=p.includes("completed")||p.includes("done")?"success":p.includes("blocked")||p.includes("failed")?"warning":"info";return{kind:"company_event",label:`${m.toUpperCase()} · ${d[1]??""}`.replace(/ · $/,""),summary:h,tone:g}}const a=t.match(/^(Review needed|Status digest|Blocked|Completion):\s*(.+)$/i);if(a){const d=a[1].replace(/\b\w/g,h=>h.toUpperCase()),m=nu(a[2]);return{kind:"company_event",label:d,summary:m,tone:/^Blocked$/i.test(a[1])?"warning":"info"}}const u=t.match(/^NO_DELEGATION_JUSTIFICATION:\s*(.+)$/i);return u?{kind:"company_event",label:"Delegation check",summary:nu(u[1]).slice(0,180),tone:"info"}:null}function xF(e,t){const{isCompanyRuntime:n,detailMode:i}=t;if(!n||i==="full"||lu(e.metadata))return null;const r=CI(e.content);if(!r)return null;const o=e.sender==="system"||e.metadata?.type==="system",a=r.kind==="company_event"||e.content.startsWith("[Company:");return!o&&!a?null:{msg:e,classification:r}}function yF(e,t={}){const{isCompanyRuntime:n=!1,detailMode:i="summary"}=t,r=[];let o=[],a=0;const u=new Set,d=new Set,m=()=>{if(o.length===0)return;const h=o[0].msg,p=o[o.length-1].msg;r.push({kind:"ops-bundle",id:`ops:${h.id}:${o.length}:${p.id}`,timestamp:h.timestamp,events:o,sortOrder:a}),o=[]};return e.forEach((h,p)=>{const g=p*2+1,y=xF(h,{isCompanyRuntime:n,detailMode:i});if(y){o.length===0&&(a=g),o.push(y);return}const v=i==="summary"?wI(h.content):null;if(v){const k=[h.sender,Math.round(h.timestamp/1e3),v.kind,nu(v.summary||v.acceptanceSummary||"").slice(0,500),v.verdict??"",v.deliverables.map(S=>`${S.name}:${S.path}`).join("|").slice(0,800)].join("");if(u.has(k))return;u.add(k)}if(i==="summary"){const k=nu(oF(h.content)).slice(0,1200);if(k){const S=aF(h)?["result",k].join(""):[h.sender,Math.round(h.timestamp/1e3),k].join("");if(d.has(S))return;d.add(S)}}m(),r.push({kind:"message",id:h.id,timestamp:h.timestamp,msg:h,sortOrder:g})}),m(),r}const vF=St.memo(function({msg:t,showDate:n,dateStr:i,classification:r}){const[o,a]=E.useState(!1),u=t.content.trim()!==`[${r.label}] ${r.summary}`.trim()&&t.content.trim().length>r.summary.length+4;return c.jsxs("div",{children:[n&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("span",{children:i})}),c.jsxs("div",{className:`msg-ops-row msg-ops-tone-${r.tone}${o?" expanded":""}`,onClick:u?()=>a(d=>!d):void 0,role:u?"button":void 0,tabIndex:u?0:-1,children:[c.jsx("span",{className:"msg-ops-dot","aria-hidden":"true"}),c.jsx("span",{className:"msg-ops-label",children:r.label}),r.summary&&c.jsx("span",{className:"msg-ops-summary",title:r.summary,children:r.summary}),c.jsx("span",{className:"msg-ops-time",title:Zr(t.timestamp),children:Es(t.timestamp)}),u&&c.jsx("span",{className:`msg-ops-chevron${o?" open":""}`,"aria-hidden":"true",children:c.jsx(Yr,{down:o})})]}),u&&o&&c.jsx("div",{className:"msg-ops-details",children:c.jsx("pre",{className:"msg-ops-details-pre",children:t.content})})]})}),bF=St.memo(function({events:t,showDate:n,dateStr:i}){const[r,o]=E.useState(!1);if(t.length===0)return null;const a=t[0].msg,u=t[t.length-1].msg,d=t.reduce((p,g)=>{const y=g.classification.kind==="company_event"?"company":g.classification.kind.startsWith("external")?"runtime":"delegation";return p[y]=(p[y]??0)+1,p},{}),m=Object.entries(d).map(([p,g])=>`${g} ${p}`).join(" · "),h=`${t.length} technical event${t.length===1?"":"s"} hidden`;return c.jsxs("div",{children:[n&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("span",{children:i})}),c.jsxs("button",{type:"button",className:`msg-ops-bundle${r?" expanded":""}`,onClick:()=>o(p=>!p),title:`${Zr(a.timestamp)} - ${Zr(u.timestamp)}`,children:[c.jsx("span",{className:"msg-ops-bundle-dot"}),c.jsx("span",{className:"msg-ops-bundle-title",children:h}),c.jsx("span",{className:"msg-ops-bundle-summary",children:m}),c.jsx("span",{className:"msg-ops-bundle-time",children:Es(a.timestamp)}),c.jsx("span",{className:"msg-ops-bundle-chevron",children:c.jsx(Yr,{down:r})})]}),r&&c.jsx("div",{className:"msg-ops-bundle-details",children:t.map(({msg:p,classification:g})=>c.jsxs("div",{className:`msg-ops-bundle-event msg-ops-tone-${g.tone}`,children:[c.jsx("span",{className:"msg-ops-dot"}),c.jsx("span",{className:"msg-ops-label",children:g.label}),c.jsx("span",{className:"msg-ops-summary",children:g.summary}),c.jsx("span",{className:"msg-ops-time",title:Zr(p.timestamp),children:Es(p.timestamp)})]},p.id))})]})});function _F(e){return e.kind==="review"?`Review · ${e.verdict?e.verdict.replace(/_/g," "):"review"}`:e.kind==="report"?"Report":"Update"}const kF=St.memo(function({msg:t,payload:n,showDate:i,dateStr:r,isCopied:o,onCopy:a}){const u=yv(t.sender==="system"?t.senderName||"OPC":t.sender),d=t.senderDeleted?"[Deleted]":t.senderName,m=_F(n),h=n.summary||n.acceptanceSummary||m;return c.jsxs("div",{children:[i&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("spa Line truncated
Set up at least one role before running a task.
Go to Org tab now?`)&&n?.(),!1;if(a.length>1&&!u)return confirm(`Your organization has multiple top-level roles but no final decider selected.
Choose one final decider in the Org tab before running a task.
Go to Org tab now?`)&&n?.(),!1;const d=[],m=new Set(i.map(y=>y.role_id));o.runtimeTeams.filter(y=>y.member_role_ids.some(v=>m.has(v))||y.manager_role_id&&m.has(y.manager_role_id)).length===0&&d.push("No runtime teams defined — the system will auto-generate from your roles");const p=new Set(r.map(y=>y.role_id)),g=i.filter(y=>!p.has(y.role_id));if(g.length>0){const y=g.map(v=>v.name).join(", ");d.push(`${g.length} role(s) have no employees: ${y}`)}return d.length>0?confirm(`Before running this task:
`+d.map(y=>"• "+y).join(`
`)+`
Run anyway?`):!0}function tV(e){if(!e)return!1;const t=zm(e);return!!(t.projectRun?.run_id||t.runtimeTeams.length>0||t.runtimeSeats.length>0)}function cC(e,t){const n=!!t?.childDetail;return e?n?"full":e.execMode==="company"||e.execMode==="org"||e.execMode==="custom"?"summary":"full":"summary"}function uC(e){return String(e?.originTaskId??e?.taskId??"").trim()||null}function nV({boardColor:e,title:t,onCommit:n}){const[i,r]=E.useState(!1),[o,a]=E.useState(t),u=E.useRef(null);E.useEffect(()=>{i||a(t)},[t,i]);const d=E.useCallback(()=>{const h=o.trim();h&&h!==t?n(h):a(t),r(!1)},[o,t,n]),m=E.useCallback(()=>{a(t),r(!0),setTimeout(()=>u.current?.select(),0)},[t]);return c.jsx("div",{className:"board-selector",children:c.jsx("div",{className:"board-tabs",children:c.jsxs("span",{className:"board-tab active board-tab-editable",style:{"--board-color":e},children:[c.jsx("span",{className:"board-tab-dot",style:{background:e}}),i?c.jsx("input",{ref:u,className:"board-tab-title-input",value:o,onChange:h=>a(h.target.value),onBlur:d,onKeyDown:h=>{h.key==="Enter"&&d(),h.key==="Escape"&&(a(t),r(!1))}}):c.jsx("span",{className:"board-tab-title",onClick:m,title:"Click to edit session title",children:t})]})})})}function iV({boardStore:e,agents:t,officeMap:n,execMode:i,companyProfile:r,taskPreferredAgent:o,chatStore:a,sessionStore:u,projectId:d,onRunTask:m,onCreateTask:h,onMoveTask:p,onCreateSession:g,onSessionSend:y,onSecretarySend:v,onDeleteSession:k,onTitleChange:S,onSessionConfigChange:_,onSessionTaskAgentChange:w,onContinueInNewChat:C,onSessionStop:N,onSessionResume:O,onSessionComplete:I,onLoadSessionDetail:D,onOpenExecutionPanel:T,onCollabSync:L,orgInfoData:A,onNavigateToOrg:M,recoveryStatus:$,onRecoveryResume:W,onRecoveryCancel:B,commsState:U,commsMessage:F,onCommsRefresh:V,onCommsReadMessage:Y,savedOrgsList:Q,activeSavedOrg:q,onSavedOrgsList:G,onSavedOrgLoad:J}){const{sessions:P,activeSessionId:K,activeSession:ee}=u,[te,ie]=E.useState("collapsed"),{width:oe,isResizing:fe,handleMouseDown:se}=QF({initialWidth:380,minWidth:300,maxWidth:600,onCollapse:()=>ie("collapsed")}),[_e,we]=E.useState("chat"),[Ce,Be]=E.useState(null),[Ve,Ye]=E.useState({kind:"activity"}),[ht,zt]=E.useState([]),[bt,Nt]=E.useState(!1),[me,ze]=E.useState({}),lt=E.useRef(D),tt=E.useRef({active:null,child:null}),qe=i==="company"||i==="org"||i==="custom",ce=`secretary:${d}`,ve=`activity:${d}`,Ae=E.useMemo(()=>Ce?P.find(de=>de.taskId===Ce)??null:null,[P,Ce]),$e=E.useMemo(()=>Ve.kind!=="task-detail"?null:e.tasks.find(de=>de.id===Ve.taskId)??null,[Ve,e.tasks]),He=E.useMemo(()=>{const de=Lm($e);return de?P.find(Se=>Se.taskId===de||Se.runtimeTaskId===de||Se.executionTurnId===de)??null:null},[P,$e]),Kt=E.useMemo(()=>He?a.getChannelMessages(He.channelId):[],[a.messages,a.getChannelMessages,He]),Yt=E.useMemo(()=>jf(ee,P),[P,ee]),be=E.useMemo(()=>$f(ee,P),[P,ee]),Re=E.useMemo(()=>Hf(ee,[...be,...Yt]),[ee,Yt,be]);E.useEffect(()=>{lt.current=D},[D]);const Ue=E.useCallback((de,Se,Fe="summary")=>{const ft=lt.current;!ft||!de||(ze(Gt=>Gt[de]?Gt:{...Gt,[de]:!0}),ft(de,{limit:JF,beforeCreatedAt:Se?.timestamp,beforeMessageId:Se?.id,detailLevel:Fe}),window.setTimeout(()=>{ze(Gt=>Gt[de]?{...Gt,[de]:!1}:Gt)},800))},[]),Xe=E.useCallback(de=>!!me[de],[me]);E.useEffect(()=>{tt.current={active:null,child:null}},[d]),E.useEffect(()=>{Ce&&!Ae&&Be(null)},[Ce,Ae]),E.useEffect(()=>{Ve.kind==="task-detail"&&!$e&&Ye({kind:"activity"})},[Ve,$e]);const Ge=E.useRef(null);E.useEffect(()=>{if(!He){Ge.current=null;return}Ge.current!==He.taskId&&(Ge.current=He.taskId,Ue(He.taskId,void 0,"full"))},[He,Ue]),E.useEffect(()=>{if(!Ce){tt.current.child=null;return}tt.current.child!==Ce&&(tt.current.child=Ce,Ue(Ce,void 0,"full"))},[Ce,Ue]),E.useEffect(()=>{if(!K){tt.current.active=null;return}const de=Re.timelineSessions.length>0?Re.timelineSessions:P.find(Fe=>Fe.taskId===K)?[P.find(Fe=>Fe.taskId===K)]:[];if(de.length===0){tt.current.active=null;return}const Se=de.map(Fe=>`${Fe.taskId}:${cC(Fe,{childDetail:Fe.mode==="child"})}`).join("|");if(tt.current.active!==Se){tt.current.active=Se;for(const Fe of de)Ue(Fe.taskId,void 0,cC(Fe,{childDetail:Fe.mode==="child"}))}},[Re.timelineSessions,K,Ue,P]);const Je=E.useMemo(()=>Ce?{kind:"child-detail"}:Ve.kind==="task-detail"||Ve.kind==="secretary"?Ve:K?{kind:"session",taskId:K}:{kind:"activity"},[Ve,K,Ce]),qn=E.useMemo(()=>Je.kind==="secretary"?ce:Je.kind==="child-detail"&&Ae?Ae.channelId:Je.kind==="session"&&Re.displaySession?Re.displaySession.channelId:Je.kind==="session"&&ee?ee.channelId:ve,[Je,Re.displaySession,ee,Ae,ce,ve]),In=E.useMemo(()=>{if(Je.kind==="activity")return[ve];if(Je.kind==="secretary")return[ce];if(Je.kind==="child-detail"&&Ae)return[Ae.channelId];if(Je.kind==="session"){const de=Re.timelineSessions.map(Se=>Se.channelId).filter((Se,Fe,ft)=>!!Se&&ft.indexOf(Se)===Fe);if(de.length>0)return de}return qn?[qn]:[]},[Je.kind,Re.timelineSessions,Ae,ve,ce,qn]),Dn=E.useMemo(()=>{const de=new Set;for(const Se of P)Se.status!=="cancelled"&&de.add(Se. Line truncated
`).replace(/\r/g,`
`).split(`
`).map(r=>r.trimEnd()).join(`
`).replace(/\n{3,}/g,`
`).trim(),n=sV(t),i=n.split(/\n{2,}/).map(r=>r.trim()).filter(Boolean);return i.length>1&&/^Verification:\s/i.test(i[i.length-1])?i.slice(0,-1).join(`
`).trim():n}function sV(e){const t=String(e||"").trim(),n=t.match(/^\*\*(.{8,160}?)\*\*:\s+([\s\S]+)$/);if(n){const a=n[2].trim();if(a.length>=80)return a}const i=t.indexOf(": ");if(i<8||i>160)return t;const r=t.slice(0,i).replace(/\*/g,"").trim(),o=t.slice(i+2).trim();return o.length<80||!/[A-Za-z\u4e00-\u9fff]/.test(r)||/^(https?|file)$/i.test(r)?t:o}function Ko(e){const t=Xo(e),n=new Set,i=typeof t.checkpoint_type=="string"?t.checkpoint_type.trim():"",r=typeof t.checkpoint_id=="string"?t.checkpoint_id.trim():"";for(const o of[e.id,typeof t.ui_message_id=="string"?t.ui_message_id:"",i&&r?`checkpoint:${i}:${r}`:""]){const a=String(o??"").trim();a&&n.add(a)}return n}function oV(e){return e.startsWith("checkpoint:")}function Xr(e){return typeof e.timestamp=="number"?e.timestamp:0}function fC(e){const t=String(e.sender??"").trim().toLowerCase(),n=Xo(e),i=typeof n.role=="string"?n.role.trim().toLowerCase():"";return t==="user"||i==="user"?"user":"assistant"}function mC(e){const t=Xo(e),n=String(e.sender??"").trim().toLowerCase();let i=0;const r=II(e);return r&&(i+=1e3+r),t.source==="engine"&&(i+=100),n&&n!=="system"&&(i+=20),n&&!["assistant","system","user"].includes(n)&&(i+=5),e.replyToId&&(i+=2),i+=Math.min(Object.keys(t).length,10),i}function pC(e){return String(Xo(e).source??"").trim().toLowerCase()==="engine"}function II(e){const t=Xo(e),n=String(t.transcript_kind??"").trim();if(n)return dC[n]??0;const i=String(t.kind??"").trim();return dC[i]??0}function am(e){return II(e)>0}function TI(e,t){if(e.channelId!==t.channelId)return!1;const n=Ko(e),i=Ko(t);for(const r of n)if(i.has(r))return!0;return!1}function t0(e,t){if(TI(e,t))return!0;if(e.channelId!==t.channelId||fC(e)!==fC(t)||om(e.content)!==om(t.content))return!1;const n=am(e)&&am(t);if(!n&&String(e.replyToId??"")!==String(t.replyToId??"")||!(pC(e)||pC(t)))return!1;const i=Xr(e),r=Xr(t);return!(!n&&i&&r&&Math.abs(i-r)>_v)}function n0(e,t,n=!1){let i=e,r=t;(n||mC(t)>mC(e))&&(i=t,r=e);const o=[];for(const p of[r.mentions,i.mentions])for(const g of p??[])o.includes(g)||o.push(g);const a=Ko(e),u=Ko(t);let d="";for(const p of a)if(u.has(p)&&!oV(p)){d=p;break}const m=om(i.content),h=m&&m===om(r.content)?m:i.content;return{...r,...i,...d?{id:d}:{},content:h,metadata:{...Xo(r),...Xo(i)},mentions:o,timestamp:Xr(i)||Xr(r)}}function lx(e){const t=[],n=new Map;for(const i of[...e].sort((r,o)=>Xr(r)-Xr(o))){const r=Ko(i);let o=-1,a=!1;for(const d of r){const m=n.get(d);if(m!==void 0){o=m,a=t[m].id===i.id;break}}if(o===-1){const d=Xr(i),m=am(i);for(let h=t.length-1;h>=0;h--){const p=Xr(t[h]);if(!m&&d>0&&p>0&&d-p>_v)break;if(t0(t[h],i)){o=h;break}}}const u=o===-1?t.length:o;o===-1?t.push(i):t[o]=n0(t[o],i,a);for(const d of Ko(t[u]))n.has(d)||n.set(d,u)}return t}function aV(e,t){switch(t.type){case"SET":return t.channels;case"CLEAR":return[];case"ADD":return e.some(n=>n.id===t.channel.id)?e:[...e,t.channel];case"REMOVE":return e.filter(n=>n.id!==t.channelId);case"REMOVE_PARTICIPANT":return e.map(n=>({...n,participants:n.participants.filter(i=>i!==t.agentId)}));default:return e}}function lV(e,t){switch(t.type){case"SET":{const n=lx(t.messages);if(e.length===0)return n;const i=e.filter(r=>typeof r.id=="string"&&r.id.startsWith("msg-")&&!n.some(o=>t0(r,o)));return i.length===0?n:lx([...n,...i])}case"CLEAR":return[];case"ADD":{const n=Xr(t.message);Ko(t.message);let i=!1;for(let r=e.length-1;r>=0;r--){const o=Xr(e[r]);if(!i&&n>0&&o>0&&n-o>_v&&(i=!0),TI(e[r],t.message)){const a=[...e];return a[r]=n0(e[r],t.message,e[r].id===t.message.id),a}if((am(t.message)||!i)&&t0(e[r],t.message)){const a=[...e];return a[r]=n0(e[r],t.message),a}}return[...e,t.message]}case"MERGE":return t.messages.length===0?e:lx([...e,...t.messages]);case"MARK_SENDER_DELETED":return e.map(n=>n.sender===t.senderId?{...n,senderDeleted:!0,senderName:"[已删除的 Agent]"}:n);case"REMOVE_BY_CHANNEL":return e.filter(n=>n.channelId!==t.channelId);case"REMOVE_BY_TASK_ID":return e.filter(n=>n.channelId!==`session:${t.taskId}`&&n.metadata?.task_id!==t.taskId);default:return e}}function cV(){const[e,t]=E.useReducer(aV,[]),[n,i]=E.useReducer(lV,[]),[r,o]=E.useState({}),[a,u]=E.useState("default"),d=E.useMemo(()=>{const I={};for(const D of n)I[D.channelId]||(I[D.channelId]=[]),I[D.channelId].push(D);return I},[n]),m=E.useMemo(()=>{const I={};for(const D of n){if(D.sender==="user")continue;const T=r[D.channelId]??0;D.timestamp<=T||(I[D.channelId]=(I[D.channelId]??0)+1)}return I},[n,r]),h=E.useCallback(I=>{const D={id:`msg-${rV()}`,channelId:I.channelId,sender:I.sender,senderName:I.senderName,content:I.content,timestamp:Date.now(),replyToId:I.replyToId,mentions:[],metadata:I.metadata};return i({type:"ADD",message:D}),D},[]),p=E.useCallback(I=>d[I]??[],[d]),g=E.useCallback(I=>m[I]??0,[m]),y=E.useCallback(I=>{o(D=>({...D,[I]:Date.now()}))},[]),v=E.useCallback(I=>{i({type:"MARK_SENDER_DELETED",senderId:I})},[]),k=E.useCallback(I=>{t({type:"REMOVE_PARTICIPANT",agentId:I})},[]),S=E.useCallback(I=>{t({type:"REMOVE",channe Line truncated
${t}`:`${e}${t}`}function uV(e,t){const n=e.trim().replace(/\s+/g," ");return n?n.length>120?`${n.slice(0,120).trimEnd()}...`:n:t||"Thinking"}function RI(e){return typeof e.lastTimestamp=="number"&&Number.isFinite(e.lastTimestamp)?e.lastTimestamp:e.timestamp}function dV(e){const t=Number.isFinite(e.timestamp)?e.timestamp:Date.now();return{timestamp:t,lastTimestamp:typeof e.lastTimestamp=="number"&&Number.isFinite(e.lastTimestamp)?e.lastTimestamp:t,type:e.type,summary:typeof e.summary=="string"?e.summary:"",detail:typeof e.detail=="string"&&e.detail?e.detail:void 0,turnId:typeof e.turnId=="string"&&e.turnId?e.turnId:void 0,itemId:typeof e.itemId=="string"&&e.itemId?e.itemId:void 0,streamId:typeof e.streamId=="string"&&e.streamId?e.streamId:void 0,toolCallId:typeof e.toolCallId=="string"&&e.toolCallId?e.toolCallId:void 0,permissionGroupKey:typeof e.permissionGroupKey=="string"&&e.permissionGroupKey?e.permissionGroupKey:void 0,seq:typeof e.seq=="number"&&Number.isFinite(e.seq)?e.seq:void 0,executionMode:typeof e.executionMode=="string"&&e.executionMode?e.executionMode:void 0}}function lm(e){const t=e.itemId||e.streamId;return t?`${e.type}:${e.turnId??""}:${t}`:e.toolCallId&&(e.type==="tool_call"||e.type==="autonomy")?`${e.type}:${e.turnId??""}:${e.toolCallId}`:e.permissionGroupKey&&e.type==="autonomy"?`${e.type}:${e.turnId??""}:${e.permissionGroupKey}`:""}function fV(e,t){const n=lm(e),i=lm(t);return n&&i?n===i:t.timestamp-RI(e)>Vm||e.type!==t.type?!1:e.type==="thinking"?!0:e.type==="tool_call"?e.summary===t.summary:!1}function mV(e,t){return t.timestamp-RI(e)<=Vm&&e.type===t.type&&e.summary===t.summary&&(e.detail??"")===(t.detail??"")}function pV(e,t){if(e.type==="thinking"){const n=i0(e.detail??"",t.detail??"","thinking");return{timestamp:e.timestamp,lastTimestamp:t.timestamp,type:"thinking",summary:uV(n,t.summary||e.summary),detail:n||void 0,turnId:t.turnId??e.turnId,itemId:t.itemId??e.itemId,streamId:t.streamId??e.streamId,toolCallId:t.toolCallId??e.toolCallId,permissionGroupKey:t.permissionGroupKey??e.permissionGroupKey,seq:t.seq??e.seq,executionMode:t.executionMode??e.executionMode}}if(e.type==="tool_call"){const n=i0(e.detail??"",t.detail??"","tool_call");return{timestamp:e.timestamp,lastTimestamp:t.timestamp,type:"tool_call",summary:t.summary||e.summary,detail:n||void 0,turnId:t.turnId??e.turnId,itemId:t.itemId??e.itemId,streamId:t.streamId??e.streamId,toolCallId:t.toolCallId??e.toolCallId,permissionGroupKey:t.permissionGroupKey??e.permissionGroupKey,seq:t.seq??e.seq,executionMode:t.executionMode??e.executionMode}}return{...t,timestamp:e.timestamp,lastTimestamp:t.timestamp}}function AI(e,t,n=100){const i=dV(t),r=lm(i),o=r?[...e].reverse().findIndex(d=>lm(d)===r):-1,a=o>=0?e.length-1-o:e.length-1,u=e[a];return u?r&&typeof u.seq=="number"&&typeof i.seq=="number"&&i.seq<=u.seq?e:mV(u,i)?ll([...e.slice(0,a),{...u,lastTimestamp:i.timestamp},...e.slice(a+1)],n):fV(u,i)?ll([...e.slice(0,a),pV(u,i),...e.slice(a+1)],n):ll([...e,i],n):[i]}function MI(e,t=100){return(Array.isArray(e)?e:[]).reduce((n,i)=>AI(n,i,t),[])}function hV(e){return{timestamp:Number.isFinite(e.timestamp)?e.timestamp:Date.now(),type:e.type,workItemProjectionId:typeof e.workItemProjectionId=="string"&&e.workItemProjectionId?e.workItemProjectionId:void 0,workItemTurnType:typeof e.workItemTurnType=="string"&&e.workItemTurnType?e.workItemTurnType:void 0,workItemProjectionTitle:typeof e.workItemProjectionTitle=="string"&&e.workItemProjectionTitle?e.workItemProjectionTitle:void 0,runtimeTaskId:typeof e.runtimeTaskId=="string"&&e.runtimeTaskId?e.runtimeTaskId:void 0,executionTurnId:typeof e.executionTurnId=="string"&&e.executionTurnId?e.executionTurnId:void 0,roleName:typeof e.roleName=="string"&&e.roleName?e.roleName:void 0,detail:typeof e.detail=="string"&&e.detail?e.detail:void 0}}function DI(e,t){return e.type===t.type&&(e.workItemProjectionId??"")===(t.workItemProjectionId??"")&&(e.workItemTurnType??"")===(t.workItemTurnType??"")&&(e.workItemProjectionTitle??"")===(t.workItemProjectionTitle??"")&&(e.executionTurnId??e.runtimeTaskId??"")===(t.executionTurnId??t.runtimeTaskId??"")&&(e.roleName??"")===(t.roleName??"")}function gV(e,t){return t.timestamp-e.timestamp<=Vm&&DI(e,t)&&(e.type==="thinking"||e.type==="tool_call")}function xV(e,t){return DI(e,t)&&(e.detail??"")===(t.detail??"")&&t.timestamp-e.timestamp<=Vm}function yV(e,t){const n=t.type==="tool_call"?"tool_call":"thinking";return{...e,...t,timestamp:t.timestamp,detail:i0(e.detail??"",t.detail??"",n)||void 0}}function OI(e,t,n=100){const i=hV(t),r=e[e.length-1];return r?xV(r,i)?ll([...e.slice(0,-1),{...r,timestamp:i.timestamp}],n):gV(r,i)?ll([...e.slice(0,-1),yV(r,i)],n):ll([...e,i],n):[i]}function LI(e,t=100){return(Array.isArray(e)?e:[]).reduce((n,i)=>OI(n,i,t),[])}function r0(e){const t=String(e??"").trim().toLowerCase();return t==="company"?"company":t==="org"||t==="custom"?"org":"task"}function vV(e){return String(e??"").trim().toLowerCase()==="custom"?"custom":"corporate"}function Line truncated
`)),[L,A]=E.useState(!1),M=E.useRef(e.role_id);E.useEffect(()=>{M.current!==e.role_id&&(M.current=e.role_id,d(e.name),h(e.responsibility),g(e.reports_to),v(e.icon??null),S(new Set(e.can_spawn)),w(new Set(e.tools)),N(e.runtime_policy?.execution_strategy??"auto"),I(e.preferred_external_agent??null),T((e.prompt_refs??[]).join(`
`)),A(!1))},[e]);const $=E.useRef({}),W=E.useRef(null),B=E.useRef(e.role_id);E.useEffect(()=>{B.current=e.role_id},[e.role_id]);const U=E.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null);const se=$.current;$.current={},Object.keys(se).length!==0&&r(B.current,se)},[r]),F=E.useCallback(se=>{i||($.current={...$.current,...se},W.current&&clearTimeout(W.current),W.current=setTimeout(U,500))},[U,i]);E.useEffect(()=>()=>{W.current&&(clearTimeout(W.current),W.current=null);const se=$.current;Object.keys(se).length>0&&($.current={},r(B.current,se))},[r]);const V=se=>{d(se),F({name:se})},Y=se=>{h(se),F({responsibility:se})},Q=se=>{g(se),F({reports_to:se})},q=se=>{v(se),F({icon:se})},G=se=>{N(se),F({execution_strategy:se})},J=se=>{I(se),F({preferred_external_agent:se})},P=se=>{T(se);const _e=se.split(`
`).map(we=>we.trim()).filter(Boolean);F({prompt_refs:_e})},K=se=>{const _e=new Set(k);_e.has(se)?_e.delete(se):_e.add(se),S(_e),F({can_spawn:Array.from(_e)})},ee=se=>{const _e=new Set(_);_e.has(se)?_e.delete(se):_e.add(se),w(_e),F({tools:Array.from(_e)})},te=E.useMemo(()=>t.filter(se=>se.role_id!==e.role_id),[t,e.role_id]),ie=E.useMemo(()=>n.filter(se=>(se.role_ids?.length?se.role_ids:[se.role_id]).includes(e.role_id)).length,[n,e.role_id]),oe=E.useMemo(()=>D.split(`
`).filter(se=>se.trim()).length,[D]),fe=()=>{if(!L){A(!0);return}U(),o(e.role_id)};return c.jsxs("aside",{className:"ri-panel","aria-label":`Inspector for role ${e.name}`,children:[c.jsxs("header",{className:"ri-panel-header",children:[c.jsx("img",{src:Du(y),alt:"",className:"ri-panel-icon"}),c.jsxs("div",{className:"ri-panel-title-wrap",children:[c.jsx("h3",{className:"ri-panel-title",children:u||"(unnamed)"}),c.jsx("code",{className:"ri-panel-id",children:e.role_id})]}),c.jsx("button",{className:"btn btn-ghost btn-sm ri-panel-close",onClick:a,title:"Close (Esc)",children:"✕"})]}),c.jsxs("div",{className:"ri-panel-body",children:[c.jsxs(Ya,{title:"Identity",defaultExpanded:!0,children:[c.jsx(gr,{label:"Name",children:c.jsx("input",{className:"ri-text-input",value:u,onChange:se=>V(se.target.value),disabled:i})}),c.jsx(gr,{label:"Responsibility",children:c.jsx("textarea",{className:"ri-textarea",rows:3,value:m,onChange:se=>Y(se.target.value),disabled:i})}),c.jsx(gr,{label:"Icon",children:c.jsx(GV,{value:y,onChange:q,readOnly:i})})]}),c.jsxs(Ya,{title:"Hierarchy",defaultExpanded:!0,children:[c.jsx(gr,{label:"Reports to",children:c.jsxs("select",{className:"ri-select",value:p,onChange:se=>Q(se.target.value),disabled:i,children:[c.jsx("option",{value:"owner",children:"You (Owner)"}),te.map(se=>c.jsx("option",{value:se.role_id,children:se.name},se.role_id))]})}),c.jsx(gr,{label:"Can delegate to",children:c.jsx(qV,{allIds:te.map(se=>se.role_id),labelFor:se=>te.find(_e=>_e.role_id===se)?.name??se,selected:k,onToggle:K,readOnly:i})}),c.jsx(gr,{label:"Employees assigned",children:c.jsx("span",{className:"ri-meta-value",children:ie})})]}),c.jsx(Ya,{title:`Tools (${_.size})`,children:c.jsx(WV,{tools:_,onToggle:ee,readOnly:i})}),c.jsx(Ya,{title:`Prompts (${oe})`,children:c.jsx(gr,{label:"Prompt refs / inline",children:c.jsx("textarea",{className:"ri-textarea ri-textarea-mono",rows:5,placeholder:"One prompt ref or inline instruction per line",value:D,onChange:se=>P(se.target.value),disabled:i})})}),c.jsxs(Ya,{title:"Runtime policy",children:[c.jsx(gr,{label:"Execution strategy",children:c.jsx("div",{className:"ri-radio-group",children:VV.map(se=>c.jsxs("label",{className:"ri-radio",title:se.hint,children:[c.jsx("input",{type:"radio",name:`exec-strategy-${e.role_id}`,value:se.value,checked:C===se.value,onChange:()=>G(se.value),disabled:i}),se.label]},se.value))})}),C==="external"&&c.jsx(gr,{label:"Preferred external agent",children:c.jsxs("select",{className:"ri-select",value:O??"",onChange:se=>J(se.target.value||null),disabled:i,children:[c.jsx("option",{value:"",children:"(any)"}),FV.map(se=>c.jsx("option",{value:se,children:se},se))]})})]}),c.jsxs(Ya,{title:"Advanced",children:[c.jsx(gr,{label:"Role type",children:c.jsx("span",{className:"ri-meta-value",children:e.role_type??"worker"})}),c.jsx(gr,{label:"Skills",children:c.jsx("span",{className:"ri-meta-value",children:e.skill_refs&&e.skill_refs.length>0?e.skill_refs.join(", "):"(none)"})}),c.jsx(gr,{label:"Artifact contract",children:c.jsx("span",{className:"ri-meta-value",children:e.artifact_contract_ref??"(none)"})})]})]}),!i&&c.jsx("footer",{className:"ri-panel-footer",children:c.jsx("button",{className:`btn btn-sm ${L?"btn-danger":"btn-ghost"}`,onClick:fe,onBlur:()=>A(!1),children:L?"Confirm delete?":"Delete role"})})]})}function Ya({title:e,defaultExpanded:t=!1,children:n}){const[i,r]=E.useState(t);return c.jsxs("section",{className:`ri-group${i?" is-expanded":""}`,children:[c.jsxs("button",{className:"ri-group-header",onClick:()=>r(o=>!o),children:[c.jsx("span",{className:"ri-group-caret",children:i?"▾":"▸"}),c.jsx("span",{className:"ri-group-title",children:e})]}),i&&c.jsx("div",{className:"ri-group-body",children:n})]})}function gr({label:e,children:t}){return c.jsxs("div",{className:"ri-field",children:[c.jsx("label",{className:"ri-field-label",children:e}),c.jsx("div",{className:"ri-field-control",children:t})]})}function GV({value:e,onChange:t,readOnly:n}){const[i,r]=E.useState(!1);return c.jsxs("div",{className:"ri-icon-picker",children:[c.jsxs("button",{className:"ri-icon-picker-trigger",onClick:()=>!n&&r(o=>!o),disabled:n,children:[c.jsx("img",{src:Du(e),alt:"",className:"ri-icon-picker-current"}),c.jsx("span",{className:"ri-icon-picker-label",children:e??"generic"})]}),i&&c.jsxs("div",{className:"ri-icon-picker-popover",children:[c.jsx("button",{className:`ri-icon-option${e===null?" is-active":""}`,onClick:()=>{t(null),r(!1)},title:"Default icon",children:c.jsx("img",{src:iu.generic,alt:""})}),$V.filter(o=>o!=="generic").map(o=>c.jsx("button",{className:`ri-icon-option${e===o?" is-active":""}`,onClick:()=>{t(o),r(!1)},title:o,children:c.jsx("img",{src:iu[o],alt:o})},o))]})]})}function qV({allIds:e,labelFor:t,selected:n,onToggle:i,readOnly:r}){const[o,a]=E.useState(!1),u=e.filter(d=>!n.has(d));return c.jsxs("div",{className:"ri-multiselect",children:[c.jsxs("div",{className:"ri-chips",children:[Array.from(n).map(d=>c.jsxs("span",{className:"ri-ch Line truncated
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,n?.key)}return r}}function pt(e,t,n,i){return{debug:()=>{var r;return(r=e?.debugAll)!=null?r:e[t]},key:!1,onChange:i}}function KV(e,t,n,i){const r=()=>{var a;return(a=o.getValue())!=null?a:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(i),renderValue:r,getContext:mt(()=>[e,n,t,o],(a,u,d,m)=>({table:a,column:u,row:d,cell:m,getValue:m.getValue,renderValue:m.renderValue}),pt(e.options,"debugCells"))};return e._features.forEach(a=>{a.createCell==null||a.createCell(o,n,t,e)},{}),o}function ZV(e,t,n,i){var r,o;const u={...e._getDefaultColumnDef(),...t},d=u.accessorKey;let m=(r=(o=u.id)!=null?o:d?typeof String.prototype.replaceAll=="function"?d.replaceAll(".","_"):d.replace(/\./g,"_"):void 0)!=null?r:typeof u.header=="string"?u.header:void 0,h;if(u.accessorFn?h=u.accessorFn:d&&(d.includes(".")?h=g=>{let y=g;for(const k of d.split(".")){var v;y=(v=y)==null?void 0:v[k]}return y}:h=g=>g[u.accessorKey]),!m)throw new Error;let p={id:`${String(m)}`,accessorFn:h,parent:i,depth:n,columnDef:u,columns:[],getFlatColumns:mt(()=>[!0],()=>{var g;return[p,...(g=p.columns)==null?void 0:g.flatMap(y=>y.getFlatColumns())]},pt(e.options,"debugColumns")),getLeafColumns:mt(()=>[e._getOrderColumnsFn()],g=>{var y;if((y=p.columns)!=null&&y.length){let v=p.columns.flatMap(k=>k.getLeafColumns());return g(v)}return[p]},pt(e.options,"debugColumns"))};for(const g of e._features)g.createColumn==null||g.createColumn(p,e);return p}const yi="debugHeaders";function vC(e,t,n){var i;let o={id:(i=n.id)!=null?i:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const a=[],u=d=>{d.subHeaders&&d.subHeaders.length&&d.subHeaders.map(u),a.push(d)};return u(o),a},getContext:()=>({table:e,header:o,column:t})};return e._features.forEach(a=>{a.createHeader==null||a.createHeader(o,e)}),o}const QV={createTable:e=>{e.getHeaderGroups=mt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,i,r)=>{var o,a;const u=(o=i?.map(p=>n.find(g=>g.id===p)).filter(Boolean))!=null?o:[],d=(a=r?.map(p=>n.find(g=>g.id===p)).filter(Boolean))!=null?a:[],m=n.filter(p=>!(i!=null&&i.includes(p.id))&&!(r!=null&&r.includes(p.id)));return uf(t,[...u,...m,...d],e)},pt(e.options,yi)),e.getCenterHeaderGroups=mt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,i,r)=>(n=n.filter(o=>!(i!=null&&i.includes(o.id))&&!(r!=null&&r.includes(o.id))),uf(t,n,e,"center")),pt(e.options,yi)),e.getLeftHeaderGroups=mt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,i)=>{var r;const o=(r=i?.map(a=>n.find(u=>u.id===a)).filter(Boolean))!=null?r:[];return uf(t,o,e,"left")},pt(e.options,yi)),e.getRightHeaderGroups=mt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,i)=>{var r;const o=(r=i?.map(a=>n.find(u=>u.id===a)).filter(Boolean))!=null?r:[];return uf(t,o,e,"right")},pt(e.options,yi)),e.getFooterGroups=mt(()=>[e.getHeaderGroups()],t=>[...t].reverse(),pt(e.options,yi)),e.getLeftFooterGroups=mt(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),pt(e.options,yi)),e.getCenterFooterGroups=mt(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),pt(e.options,yi)),e.getRightFooterGroups=mt(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),pt(e.options,yi)),e.getFlatHeaders=mt(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,yi)),e.getLeftFlatHeaders=mt(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,yi)),e.getCenterFlatHeaders=mt(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,yi)),e.getRightFlatHeaders=mt(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,yi)),e.getCenterLeafHeaders=mt(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var i;return!((i=n.subHeaders)!=null&&i.length)}),pt(e.options,yi)),e.getLeftLeafHeaders=mt(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var i;return!((i=n.subHeaders)!=null&&i.length)}),pt(e.options,yi)),e.getRightLeafHeaders=mt(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var i;return!((i=n.subHeaders)!=null&&i.length)}),pt(e.options,yi)),e.getLeafHeaders=mt(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,i)=>{var r,o,a,u,d,m;return[...(r=(o=t[0])==null?void 0:o.headers)!=null?r:[],...(a=(u=n[0])==null?void 0:u.headers)!=null?a:[],...(d=(m=i[0])==null?void 0:m.headers)!=null?d:[]].map(h=>h.getLeafHeaders()).flat()},pt(e.options,yi))}};function uf(e,t,n,i){var r,o;let a=0;const u=function(g,y){y===void 0&&(y=1),a=Math.max(a,y),g.filter(v=>v.getIsVisible()).forEach(v=>{var k;(k=v.columns)!=null&&k.length&&u(v.columns,y+1)},0)};u(e);let d=[];const m=(g,y)=>{const v={depth:y,id:[i,`${y}`].filter(Boolean).jo Line truncated
`).replace(`
`,`
+`).split(`
`)),h=m.reduce((p,g)=>p.concat(...g),[]);return[m,h]}return[[],[]]},[e]);return E.useEffect(()=>{const d=t?.target??d2,m=t?.actInsideInputWithModifier??!0;if(e!==null){const h=y=>{if(r.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!r.current||r.current&&!m)&&OT(y))return!1;const k=m2(y.code,u);if(o.current.add(y[k]),f2(a,o.current,!1)){const S=y.composedPath?.()?.[0]||y.target,_=S?.nodeName==="BUTTON"||S?.nodeName==="A";t.preventDefault!==!1&&(r.current||!_)&&y.preventDefault(),i(!0)}},p=y=>{const v=m2(y.code,u);f2(a,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(y[v]),y.key==="Meta"&&o.current.clear(),r.current=!1},g=()=>{o.current.clear(),i(!1)};return d?.addEventListener("keydown",h),d?.addEventListener("keyup",p),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{d?.removeEventListener("keydown",h),d?.removeEventListener("keyup",p),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,i]),n}function f2(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function m2(e,t){return t.includes(e)?"code":"key"}const XX=()=>{const e=wn();return E.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,r,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??i,y:t.y??r,zoom:t.zoom??o},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:o,maxZoom:a,panZoom:u}=e.getState(),d=Dv(t,i,r,o,a,n?.padding??.1);return u?(await u.setViewport(d,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:r,snapToGrid:o,domNode:a}=e.getState();if(!a)return t;const{x:u,y:d}=a.getBoundingClientRect(),m={x:t.x-u,y:t.y-d},h=n.snapGrid??r,p=n.snapToGrid??o;return $u(m,i,p,h)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:r,y:o}=i.getBoundingClientRect(),a=ym(t,n);return{x:a.x+r,y:a.y+o}}}),[])};function iR(e,t){const n=[],i=new Map,r=[];for(const o of e)if(o.type==="add"){r.push(o);continue}else if(o.type==="remove"||o.type==="replace")i.set(o.id,[o]);else{const a=i.get(o.id);a?a.push(o):i.set(o.id,[o])}for(const o of t){const a=i.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const u={...o};for(const d of a)KX(d,u);n.push(u)}return r.length&&r.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function KX(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 rR(e,t){return iR(e,t)}function ZX(e,t){return iR(e,t)}function Ho(e,t){return{id:e,type:"select",selected:t}}function nl(e,t=new Set,n=!1){const i=[];for(const[r,o]of e){const a=t.has(r);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),i.push(Ho(o.id,a)))}return i}function p2({items:e=[],lookup:t}){const n=[],i=new Map(e.map(r=>[r.id,r]));for(const[r,o]of e.entries()){const a=t.get(o.id),u=a?.internals?.userNode??a;u!==void 0&&u!==o&&n.push({id:o.id,item:o,type:"replace"}),u===void 0&&n.push({item:o,type:"add",index:r})}for(const[r]of t)i.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function h2(e){return{id:e.id,type:"remove"}}const g2=e=>bY(e),QX=e=>ET(e);function sR(e){return E.forwardRef(e)}function x2(e){const[t,n]=E.useState(BigInt(0)),[i]=E.useState(()=>JX(()=>n(r=>r+BigInt(1))));return S0(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function JX(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const oR=E.createContext(null);function eK({children:e}){const t=wn(),n=E.useCallback(u=>{const{nodes:d=[],setNodes:m,hasDefaultNodes:h,onNodesChange:p,nodeLookup:g,fitViewQueued:y,onNodesChangeMiddlewareMap:v}=t.getState();let k=d;for(const _ of u)k=typeof _=="function"?_(k):_;let S=p2({items:k,lookup:g});for(const _ of v.values())S=_(S);h&&m(k),S.length>0?p?.(S):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:w,setNodes:C}=t.getState();_&&C(w)})},[]),i=x2(n),r=E.useCallback(u=>{const{edges:d=[],setEdges:m,hasDefaul Line truncated
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}AR.displayName="MiniMap";const HZ=E.memo(AR),FZ=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,VZ={[Cl.Line]:"right",[Cl.Handle]:"bottom-right"};function UZ({nodeId:e,position:t,variant:n=Cl.Handle,className:i,style:r=void 0,children:o,color:a,minWidth:u=10,minHeight:d=10,maxWidth:m=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:g,autoScale:y=!0,shouldResize:v,onResizeStart:k,onResize:S,onResizeEnd:_}){const w=cR(),C=typeof e=="string"?e:w,N=wn(),O=E.useRef(null),I=n===Cl.Handle,D=Ut(E.useCallback(FZ(I&&y),[I,y]),Sn),T=E.useRef(null),L=t??VZ[n];E.useEffect(()=>{if(!(!O.current||!C))return T.current||(T.current=yX({domNode:O.current,nodeId:C,getStoreItems:()=>{const{nodeLookup:M,transform:$,snapGrid:W,snapToGrid:B,nodeOrigin:U,domNode:F}=N.getState();return{nodeLookup:M,transform:$,snapGrid:W,snapToGrid:B,nodeOrigin:U,paneDomNode:F}},onChange:(M,$)=>{const{triggerNodeChanges:W,nodeLookup:B,parentLookup:U,nodeOrigin:F}=N.getState(),V=[],Y={x:M.x,y:M.y},Q=B.get(C);if(Q&&Q.expandParent&&Q.parentId){const q=Q.origin??F,G=M.width??Q.measured.width??0,J=M.height??Q.measured.height??0,P={id:Q.id,parentId:Q.parentId,rect:{width:G,height:J,...MT({x:M.x??Q.position.x,y:M.y??Q.position.y},{width:G,height:J},Q.parentId,B,q)}},K=$v([P],B,U,F);V.push(...K),Y.x=M.x?Math.max(q[0]*G,M.x):void 0,Y.y=M.y?Math.max(q[1]*J,M.y):void 0}if(Y.x!==void 0&&Y.y!==void 0){const q={id:C,type:"position",position:{...Y}};V.push(q)}if(M.width!==void 0&&M.height!==void 0){const G={id:C,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};V.push(G)}for(const q of $){const G={...q,type:"position"};V.push(G)}W(V)},onEnd:({width:M,height:$})=>{const W={id:C,type:"dimensions",resizing:!1,dimensions:{width:M,height:$}};N.getState().triggerNodeChanges([W])}})),T.current.update({controlPosition:L,boundaries:{minWidth:u,minHeight:d,maxWidth:m,maxHeight:h},keepAspectRatio:p,resizeDirection:g,onResizeStart:k,onResize:S,onResizeEnd:_,shouldResize:v}),()=>{T.current?.destroy()}},[L,u,d,m,h,p,k,S,_,v]);const A=L.split("-");return c.jsx("div",{className:Gn(["react-flow__resize-control","nodrag",...A,n,i]),ref:O,style:{...r,scale:D,...a&&{[I?"backgroundColor":"borderColor"]:a}},children:o})}E.memo(UZ);const GZ=E.memo(function({data:t}){const n=["oc-canvas-node",t.isOwner&&"is-owner",t.isSelected&&"is-selected",t.isDropTarget&&"is-drop-target"].filter(Boolean).join(" "),i=Du(t.icon);return c.jsxs("div",{className:n,children:[c.jsx(jl,{type:"target",position:st.Top,className:"oc-canvas-handle"}),c.jsxs("div",{className:"oc-canvas-node-row",children:[c.jsx("div",{className:"oc-canvas-node-chip",children:c.jsx("span",{className:"oc-canvas-node-chip-icon",style:{WebkitMaskImage:`url("${i}")`,maskImage:`url("${i}")`},"aria-hidden":!0})}),c.jsxs("div",{className:"oc-canvas-node-text",children:[c.jsx("span",{className:"oc-canvas-node-name",children:t.name}),c.jsxs("div",{className:"oc-canvas-node-meta",children:[t.employeeNames.length>0?c.jsxs("span",{className:"oc-canvas-node-person",title:t.employeeNames.join(", "),children:[t.employeeNames[0],t.employeeNames.length>1?` +${t.employeeNames.length-1}`:""]}):c.jsx("span",{className:"oc-canvas-node-id",children:t.roleId}),t.employeeCount>0&&c.jsx("span",{className:"oc-canvas-node-badge",children:t.employeeCount})]})]})]}),c.jsx(jl,{type:"source",position:st.Bottom,className:"oc-canvas-handle"})]})});var Tx,I2;function Vv(){if(I2)return Tx;I2=1;var e="\0",t="\0",n="";class i{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(h){h&&(this._isDirected=Object.hasOwn(h,"directed")?h.directed:!0,this._isMultigraph=Object.hasOwn(h,"multigraph")?h.multigraph:!1,this._isCompound=Object.hasOwn(h,"compound")?h.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(h){return this._label=h,this}graph(){return this._label}setDefaultNodeLabel(h){return this._defaultNodeLabelFn=h,typeof h!="function"&&(this._defaultNodeLabelFn=()=>h),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var h=this;return this.nodes().filter(p=>Object.keys(h._in[p]).length===0)}sinks(){var h=this;return this.nodes().filter(p=>Object.keys(h._out[p]).length===0)}setNodes(h,p){var g=arguments,y=this;return h.forEach(function(v){g.length>1?y.setNode(v,p):y.setNode(v)}),this}setNode(h,p){return Object.hasOwn(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=p),this):(this._nodes[h]=arguments.length>1?p:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=t, Line truncated
${i}`}),c.jsx(RV,{projects:Ri.projects,activeId:Ri.activeProjectId,onSelect:Z=>{const z=Rs(Z);t.current?.switchProject(Z,z)},onCreate:Z=>{t.current?.createProject(Z)},onDelete:Z=>t.current?.deleteProject(Z)})]}),c.jsxs("div",{className:"topbar-center",children:[c.jsxs("div",{className:"page-nav",children:[c.jsxs("button",{className:`page-nav-btn${$==="workspace"?" active":""}`,onClick:()=>W("workspace"),children:["Workspace",(()=>{const Z=Si.channels.reduce((z,ne)=>z+Si.getUnreadCount(ne.id),0);return Z>0?c.jsx("span",{className:"nav-unread-badge",children:Z>99?"99+":Z}):null})()]}),c.jsx("button",{className:`page-nav-btn${$==="office"?" active":""}`,onClick:()=>W("office"),children:"Office"}),c.jsx("button",{className:`page-nav-btn${$==="org"?" active":""}`,onClick:()=>W("org"),children:"Org"})]}),c.jsxs("div",{className:"stat-chips",children:[c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:oa.totalAgents})," agents"]}),c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:oa.totalSkills})," skills"]}),c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:Ln.getOpenTaskCount()})," tasks"]})]})]}),c.jsxs("div",{className:"topbar-right",children:[c.jsxs("select",{className:"theme-select",value:Ti,title:"Outdoor lighting override",onChange:Z=>{const z=Z.target.value;ki(z);try{z==="auto"?(localStorage.removeItem("opc_outdoor_override"),localStorage.removeItem("opc_outdoor_day"),localStorage.removeItem("opc_outdoor_night")):(localStorage.setItem("opc_outdoor_override",z),localStorage.removeItem("opc_outdoor_day"),localStorage.removeItem("opc_outdoor_night"))}catch{}e.current.syncOutdoorLighting()},children:[c.jsx("option",{value:"auto",children:"Outdoor auto"}),c.jsx("option",{value:"day",children:"Outdoor day"}),c.jsx("option",{value:"night",children:"Outdoor night"})]}),c.jsxs("select",{className:"theme-select",value:C,onChange:Z=>N(Z.target.value),children:[c.jsx("option",{value:"midnight",children:"Midnight"}),c.jsx("option",{value:"neon",children:"Neon"}),c.jsx("option",{value:"paper",children:"Paper"}),c.jsx("option",{value:"retro",children:"Retro"}),c.jsx("option",{value:"terminal",children:"Terminal"}),c.jsx("option",{value:"cozy",children:"Cozy"}),c.jsx("option",{value:"openopc",children:"OpenOPC"})]}),c.jsx("button",{className:`icon-btn ${F?"active":""}`,onClick:()=>V(Z=>!Z),title:"Developer Tools",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[c.jsx("path",{d:"M5.5 2L2 5.5 5.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M10.5 7L14 10.5 10.5 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),$==="workspace"&&c.jsx(iV,{boardStore:Ln,chatStore:Si,sessionStore:fn,agents:B,officeMap:kr,execMode:q,companyProfile:J,taskPreferredAgent:K,projectId:Ri.activeProjectId,orgInfoData:te,onNavigateToOrg:()=>W("org"),savedOrgsList:Yt,activeSavedOrg:Re,onSavedOrgsList:sr,onSavedOrgLoad:ns,recoveryStatus:oe,onRecoveryResume:Z=>t.current?.recoveryAction(at(),"resume",Z),onRecoveryCancel:Z=>t.current?.recoveryAction(at(),"cancel",Z),commsState:se,commsMessage:we,onCommsRefresh:Z=>{const{project_id:z,...ne}=Z??{};t.current?.commsState(at(),ne)},onCommsReadMessage:Z=>t.current?.commsReadMessage(at(),Z),onRunTask:(Z,z,ne,ae,pe)=>{t.current?.send({type:"run_task",project_id:at(),task_id:Z,title:z,description:ne,mode:ae,profile:pe})},onCreateTask:(Z,z,ne,ae)=>{t.current?.send({type:"kanban_create_task",project_id:at(),title:Z,board_id:z,column_id:ne,task_id:ae})},onMoveTask:(Z,z)=>{t.current?.send({type:"kanban_move_task",project_id:at(),task_id:Z,column_id:z})},onCreateSession:()=>{if(dt.current||yt.current)return;const Z=at();bn(Z),t.current?.createSession(Z,void 0,q,Cy(q),K,Po(q,Re))},onSessionSend:(Z,z,ne,ae)=>t.current?.sessionSend(at(),Z,z,ne,ae),onSecretarySend:Z=>t.current?.secretarySend(at(),Z),onDeleteSession:Z=>t.current?.deleteSession(at(),Z),onTitleChange:(Z,z)=>t.current?.sessionUpdateTitle(at(),Z,z),onSessionConfigChange:Bl,onSessionTaskAgentChange:$l,onContinueInNewChat:bo,onSessionStop:Uu,onSessionResume:ap,onSessionComplete:Z=>t.current?.sessionComplete(at(),Z),onLoadSessionDetail:(Z,z)=>t.current?.sessionDetail(at(),Z,{...z,include:z?.detailLevel==="full"?["messages","session_state","progress","work_items","runtime_context"]:["messages","session_state"],viewGeneration:Jt.current}),onOpenExecutionPanel:Z=>Et(Z),onCollabSync:()=>t.current?.collabSync(at(),void 0,Jt.current)}),$==="org"&&c.jsx("div",{className:"org-page",children:c.jsx(eJ,{data:te,sessionRecruitmentByRole:Hu,talents:Be,employeeDetail:zt,reorgProposals:Nt,isCustomMode:Os,onRequestData:()=>t.current?.orgInfo(),onRequestTalents:()=>t.current?.talentList(),onRequestEmployeeDetail:Z=>t.current?.employeeDetail(Z),onHireTalent:(Z,z)=>{Wn(Z),t.current?.talentHire(Z,z,void 0,te?.organization_id||Re||void 0)},hiringTemplateId:$t,onImportEmployee:Z=>t.curre Line truncated
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="data:," />
<title>OpenOPC Pixel Office</title>
<script type="module" crossorigin src="./assets/index-D7RDFfgf.js"></script>
<script type="module" crossorigin src="./assets/index-cOg8E2rt.js"></script>
<link rel="modulepreload" crossorigin href="./assets/phaser-DFK5Ua9d.js">
<link rel="stylesheet" crossorigin href="./assets/index-CMqG6mW8.css">
</head>
+122 -20
View File
@@ -749,6 +749,65 @@ export default function App() {
return () => { bridge.off('agentSelected', handler) }
}, [])
// ── Runtime-delta coalescing ────────────────────────────────────────
// assistant_delta / thinking_delta arrive at token frequency; writing each
// one straight into the stores re-renders the whole app once per token.
// Buffer them per task and flush at most every 80ms. Any non-delta event
// for the same task flushes first, so store-write ordering (e.g. clearDraft
// on turn boundaries) is preserved exactly.
const pendingDeltaFlushRef = useRef<Map<string, {
draftText: string
draftIteration?: number
draftTurnId?: string
sessionPatch: Partial<import('./types/kanban').Session>
kanbanPatch: Partial<KanbanTask>
}>>(new Map())
const deltaFlushTimerRef = useRef<number | null>(null)
const flushPendingDeltas = useCallback((onlyTaskId?: string) => {
const pending = pendingDeltaFlushRef.current
if (pending.size === 0) return
const ids = onlyTaskId ? [onlyTaskId] : Array.from(pending.keys())
for (const taskId of ids) {
const entry = pending.get(taskId)
if (!entry) continue
pending.delete(taskId)
const ss = sessionStoreRef.current
if (entry.draftText) {
ss?.appendDraft(taskId, entry.draftText, entry.draftIteration, entry.draftTurnId)
}
ss?.updateSession(taskId, entry.sessionPatch)
if (Object.keys(entry.kanbanPatch).length > 0) {
boardStoreRef.current?.updateTask(taskId, entry.kanbanPatch)
}
}
if (pending.size === 0 && deltaFlushTimerRef.current !== null) {
window.clearTimeout(deltaFlushTimerRef.current)
deltaFlushTimerRef.current = null
}
}, [])
const scheduleDeltaFlush = useCallback(() => {
if (deltaFlushTimerRef.current !== null) return
deltaFlushTimerRef.current = window.setTimeout(() => {
deltaFlushTimerRef.current = null
flushPendingDeltas()
}, 80)
}, [flushPendingDeltas])
// uiTick only feeds the office-page visual memos (cards/offices/seats).
// A trailing 300ms throttle caps their refresh cost regardless of the
// websocket event rate; the office view is cosmetic, so ≤300ms staleness
// is invisible.
const uiTickTimerRef = useRef<number | null>(null)
const bumpUiTickThrottled = useCallback(() => {
if (uiTickTimerRef.current !== null) return
uiTickTimerRef.current = window.setTimeout(() => {
uiTickTimerRef.current = null
setUiTick(n => n + 1)
}, 300)
}, [])
useEffect(() => {
const client = new VisualSocketClient(wsUrl, {
onSnapshot: (data) => {
@@ -842,6 +901,11 @@ export default function App() {
const data = evt.data as Record<string, unknown>
const taskId = typeof data.task_id === 'string' ? data.task_id : ''
if (taskId) {
const isDeltaEvent = evt.type === 'assistant_delta' || evt.type === 'thinking_delta'
// Store-write ordering guarantee: everything buffered for this
// task lands before a non-delta event (turn boundaries call
// clearDraft; the draft must be flushed first, not after).
if (!isDeltaEvent) flushPendingDeltas(taskId)
const ss = sessionStoreRef.current
const bs = boardStoreRef.current
const existingSession = ss?.sessions.find(session => session.taskId === taskId)
@@ -857,7 +921,9 @@ export default function App() {
: typeof data.execution_turn_id === 'string' && data.execution_turn_id
? data.execution_turn_id
: undefined
if (projectionId && projectionId !== 'task_mode_execution' && !isTaskModeRuntime) {
const marksCompanyRuntime =
!!projectionId && projectionId !== 'task_mode_execution' && !isTaskModeRuntime
if (marksCompanyRuntime && !isDeltaEvent && existingSession?.isCompanyRuntime !== true) {
ss?.setCompanyRuntime(taskId, true)
}
@@ -866,29 +932,56 @@ export default function App() {
...(evt.type === 'member_inbox_updated' ? {} : { updatedAt: Date.now() }),
...sessionRuntimePatchFromPayload(data),
}
if (evt.type === 'turn_started') {
ss?.clearDraft(taskId)
} else if (evt.type === 'turn_completed' || evt.type === 'turn_failed' || evt.type === 'checkpoint_saved') {
ss?.clearDraft(taskId)
} else if (evt.type === 'assistant_delta' && typeof data.text === 'string' && data.text) {
ss?.appendDraft(
taskId,
data.text,
typeof data.iteration === 'number'
? data.iteration
: existingSession?.draftIteration,
turnId,
)
}
ss?.updateSession(taskId, runtimePartial)
const toolName = typeof data.tool_name === 'string' ? data.tool_name : undefined
bs?.updateTask(taskId, {
const kanbanPatch: Partial<KanbanTask> = {
...kanbanRuntimePatchFromPayload(data),
// currentTool is active-only (clears between tools); displayTool
// is sticky and only updates on a real, non-empty tool name.
...(toolName !== undefined ? { currentTool: toolName || undefined } : {}),
...(toolName ? { displayTool: toolName } : {}),
})
}
if (isDeltaEvent) {
const pending = pendingDeltaFlushRef.current
let entry = pending.get(taskId)
const deltaText = evt.type === 'assistant_delta' && typeof data.text === 'string'
? data.text
: ''
// A turn boundary inside the buffer would corrupt the draft
// reset logic (APPEND_DRAFT resets on turnId change) — flush
// the previous turn's chunk before starting a new one.
if (
entry && deltaText && entry.draftText &&
entry.draftTurnId !== undefined && turnId !== undefined &&
entry.draftTurnId !== turnId
) {
flushPendingDeltas(taskId)
entry = undefined
}
if (!entry) {
entry = { draftText: '', sessionPatch: {}, kanbanPatch: {} }
pending.set(taskId, entry)
}
if (deltaText) {
entry.draftText += deltaText
entry.draftIteration = typeof data.iteration === 'number'
? data.iteration
: entry.draftIteration ?? existingSession?.draftIteration
if (turnId !== undefined) entry.draftTurnId = turnId
}
entry.sessionPatch = {
...entry.sessionPatch,
...runtimePartial,
...(marksCompanyRuntime ? { isCompanyRuntime: true } : {}),
}
entry.kanbanPatch = { ...entry.kanbanPatch, ...kanbanPatch }
scheduleDeltaFlush()
} else {
if (evt.type === 'turn_started' || evt.type === 'turn_completed' || evt.type === 'turn_failed' || evt.type === 'checkpoint_saved') {
ss?.clearDraft(taskId)
}
ss?.updateSession(taskId, runtimePartial)
bs?.updateTask(taskId, kanbanPatch)
}
const skipDetailRefresh = (
isTaskModeRuntime && TASK_MODE_LOW_VALUE_RUNTIME_EVENTS.has(evt.type)
) || SESSION_DETAIL_REFRESH_LOW_VALUE_RUNTIME_EVENTS.has(evt.type)
@@ -908,7 +1001,7 @@ export default function App() {
}
}
setUiTick((n) => n + 1)
bumpUiTickThrottled()
} catch (e) { console.error('[onEvent] Error:', e, evt) }
},
onAck: (payload) => {
@@ -1838,6 +1931,15 @@ export default function App() {
timersRef.current.clear()
for (const tid of pendingSessionDetailRefreshRef.current.values()) clearTimeout(tid)
pendingSessionDetailRefreshRef.current.clear()
if (deltaFlushTimerRef.current !== null) {
window.clearTimeout(deltaFlushTimerRef.current)
deltaFlushTimerRef.current = null
}
pendingDeltaFlushRef.current.clear()
if (uiTickTimerRef.current !== null) {
window.clearTimeout(uiTickTimerRef.current)
uiTickTimerRef.current = null
}
}
}, [wsUrl])
@@ -2419,7 +2521,7 @@ export default function App() {
<main className={`main-grid${activePage !== 'office' ? ' hidden' : ''}${sidebarCollapsed ? ' sidebar-collapsed' : ''}`}>
{/* Phaser Game Canvas */}
<section className="canvas-wrap">
<PhaserGame bridge={bridgeRef.current} />
<PhaserGame bridge={bridgeRef.current} active={activePage === 'office'} />
<button className="canvas-float-btn" onClick={() => setShowSubagents((v) => !v)} title={showSubagents ? 'Hide sub-agents' : 'Show sub-agents'}>
{showSubagents ? '👥' : '👤'}
</button>
@@ -7,12 +7,38 @@ import { OfficeScene } from './scenes/OfficeScene'
interface Props {
bridge: GameBridge
/** False while the office page is hidden — puts the render loop to sleep.
Bridge calls still apply synchronously to scene state, so nothing is
lost; only the per-frame update/render work stops. */
active?: boolean
}
export function PhaserGame({ bridge }: Props) {
export function PhaserGame({ bridge, active = true }: Props) {
const wrapperRef = useRef<HTMLDivElement>(null)
const containerRef = useRef<HTMLDivElement>(null)
const gameRef = useRef<Phaser.Game | null>(null)
const activeRef = useRef(active)
activeRef.current = active
// display:none does NOT stop requestAnimationFrame — without this, the
// whole game loop (physics, tweens, full canvas redraw) keeps burning CPU
// while the user is on the Workspace/Org pages.
useEffect(() => {
const game = gameRef.current
if (!game || !game.loop) return
// TimeStep.running toggles false on sleep() while `started` stays true.
if (active) {
if (game.loop.started && !game.loop.running) {
game.loop.wake()
// Re-measure after display:none → visible; in RESIZE mode Phaser's
// parent-size poll may still hold the stale hidden bounds.
game.scale.getParentBounds()
game.scale.refresh()
}
} else if (game.loop.running) {
game.loop.sleep()
}
}, [active])
useEffect(() => {
if (!wrapperRef.current || !containerRef.current) return
@@ -26,6 +52,11 @@ export function PhaserGame({ bridge }: Props) {
config.scene = [BootScene, OfficeScene]
const game = new Phaser.Game(config)
game.registry.set('bridge', bridge)
// The game is created lazily on first layout; if the page was switched
// away before boot finished, park the loop immediately.
game.events.once(Phaser.Core.Events.READY, () => {
if (!activeRef.current && game.loop.running) game.loop.sleep()
})
gameRef.current = game
}
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from 'react'
import { useEffect, useMemo, useRef, useState } from 'react'
import type {
CommsStatePayload,
CommsMessagePayload,
@@ -21,18 +21,23 @@ export function CommsPanel({
message,
onRefresh,
onReadMessage,
pollIntervalMs = 8000,
// Freshness is driven by the server's comms_state_dirty push (wsClient
// refetches immediately on it); this poll is only a slow safety net. Each
// tick makes the backend walk every role's comms workspace, so keep it rare.
pollIntervalMs = 30000,
embedded = false,
}: CommsPanelProps) {
const [selectedPath, setSelectedPath] = useState<string | null>(null)
// Auto-refresh
// Auto-refresh fallback. onRefresh goes through a ref so the interval
// always calls the latest callback (the old closure pinned a stale one).
const onRefreshRef = useRef(onRefresh)
onRefreshRef.current = onRefresh
useEffect(() => {
if (!pollIntervalMs) return
onRefresh()
const id = window.setInterval(() => onRefresh(), pollIntervalMs)
onRefreshRef.current()
const id = window.setInterval(() => onRefreshRef.current(), pollIntervalMs)
return () => window.clearInterval(id)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [pollIntervalMs])
const totalUnread = useMemo(() => {