@xfey/tutti 0.1.128 → 0.1.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-assistant/diagnostics.d.ts +10 -1
- package/dist/chat-assistant/failure-messages.d.ts +4 -0
- package/dist/chat-assistant/failure-messages.js +57 -0
- package/dist/chat-assistant/failures.d.ts +16 -16
- package/dist/chat-assistant/failures.js +24 -80
- package/dist/chat-assistant/index.d.ts +4 -2
- package/dist/chat-assistant/index.js +33 -8
- package/dist/chat-assistant/language-context.d.ts +2 -0
- package/dist/chat-assistant/language-context.js +17 -14
- package/dist/chat-assistant/requests.d.ts +5 -1
- package/dist/chat-assistant/requests.js +9 -3
- package/dist/collaboration-state/context-sync-attempts.d.ts +9 -0
- package/dist/collaboration-state/context-sync-attempts.js +13 -0
- package/dist/communication-language/notice-locale.d.ts +4 -0
- package/dist/communication-language/notice-locale.js +14 -0
- package/dist/control-plane/context-sync-completion.d.ts +7 -0
- package/dist/control-plane/context-sync-completion.js +27 -0
- package/dist/control-plane/context-sync.d.ts +1 -0
- package/dist/control-plane/context-sync.js +23 -0
- package/dist/control-plane/index.d.ts +13 -4
- package/dist/control-plane/index.js +30 -23
- package/dist/control-plane/types.d.ts +2 -0
- package/dist/providers/invocation-progress.d.ts +6 -0
- package/dist/providers/invocation-progress.js +24 -0
- package/dist/providers/openai/app-server/read-only-procedure.js +1 -0
- package/dist/providers/openai/chat-assistant.js +2 -1
- package/dist/server-shell/cli/host-server-runtime.js +4 -1
- package/migrations/0026_context_sync_and_chat_locale.sql +12 -0
- package/migrations/README.md +2 -2
- package/package.json +1 -1
- package/web/assets/{homepage-motion-scene-BcMt0AVW.js → homepage-motion-scene-BHhw4CfM.js} +1 -1
- package/web/assets/{index-2eX37Jx6.js → index-5COc1Yku.js} +2 -2
- package/web/index.html +1 -1
|
@@ -46,7 +46,7 @@ Error generating stack: `+e.message+`
|
|
|
46
46
|
`},rD=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},iD=function(){I.useEffect(function(){return document.body.setAttribute(tD,(rD()+1).toString()),function(){var e=rD()-1;e<=0?document.body.removeAttribute(tD):document.body.setAttribute(tD,e.toString())}},[])},aD=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;iD();var a=I.useMemo(function(){return $E(i)},[i]);return I.createElement(eD,{styles:nD(a,!t,i,n?``:`!important`)})},oD=!1;if(typeof window<`u`)try{var sD=Object.defineProperty({},`passive`,{get:function(){return oD=!0,!0}});window.addEventListener(`test`,sD,sD),window.removeEventListener(`test`,sD,sD)}catch{oD=!1}var cD=oD?{passive:!1}:!1,lD=function(e){return e.tagName===`TEXTAREA`},uD=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!lD(e)&&n[t]===`visible`)},dD=function(e){return uD(e,`overflowY`)},fD=function(e){return uD(e,`overflowX`)},pD=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),gD(e,r)){var i=_D(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},mD=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},hD=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},gD=function(e,t){return e===`v`?dD(t):fD(t)},_D=function(e,t){return e===`v`?mD(t):hD(t)},vD=function(e,t){return e===`h`&&t===`rtl`?-1:1},yD=function(e,t,n,r,i){var a=vD(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=_D(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&gD(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},bD=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},xD=function(e){return[e.deltaX,e.deltaY]},SD=function(e){return e&&`current`in e?e.current:e},CD=function(e,t){return e[0]===t[0]&&e[1]===t[1]},wD=function(e){return`
|
|
47
47
|
.block-interactivity-${e} {pointer-events: none;}
|
|
48
48
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
49
|
-
`},TD=0,ED=[];function DD(e){var t=I.useRef([]),n=I.useRef([0,0]),r=I.useRef(),i=I.useState(TD++)[0],a=I.useState(YE)[0],o=I.useRef(e);I.useEffect(function(){o.current=e},[e]),I.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=wE([e.lockRef.current],(e.shards||[]).map(SD),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=I.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=bD(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=pD(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=pD(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return yD(h,t,e,h===`h`?s:c,!0)},[]),c=I.useCallback(function(e){var n=e;if(!(!ED.length||ED[ED.length-1]!==a)){var r=`deltaY`in n?xD(n):bD(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&CD(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(SD).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=I.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:OD(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=I.useCallback(function(e){n.current=bD(e),r.current=void 0},[]),d=I.useCallback(function(t){l(t.type,xD(t),t.target,s(t,e.lockRef.current))},[]),f=I.useCallback(function(t){l(t.type,bD(t),t.target,s(t,e.lockRef.current))},[]);I.useEffect(function(){return ED.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,cD),document.addEventListener(`touchmove`,c,cD),document.addEventListener(`touchstart`,u,cD),function(){ED=ED.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,cD),document.removeEventListener(`touchmove`,c,cD),document.removeEventListener(`touchstart`,u,cD)}},[]);var p=e.removeScrollBar,m=e.inert;return I.createElement(I.Fragment,null,m?I.createElement(a,{styles:wD(i)}):null,p?I.createElement(aD,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function OD(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var kD=RE(zE,DD),AD=I.forwardRef(function(e,t){return I.createElement(VE,SE({},e,{ref:t,sideCar:kD}))});AD.classNames=VE.classNames;var jD=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},MD=new WeakMap,ND=new WeakMap,PD={},FD=0,ID=function(e){return e&&(e.host||ID(e.parentNode))},LD=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=ID(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},RD=function(e,t,n,r){var i=LD(t,Array.isArray(e)?e:[e]);PD[n]||(PD[n]=new WeakMap);var a=PD[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(MD.get(e)||0)+1,l=(a.get(e)||0)+1;MD.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ND.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),FD++,function(){o.forEach(function(e){var t=MD.get(e)-1,i=a.get(e)-1;MD.set(e,t),a.set(e,i),t||(ND.has(e)||e.removeAttribute(r),ND.delete(e)),i||e.removeAttribute(n)}),FD--,FD||(MD=new WeakMap,MD=new WeakMap,ND=new WeakMap,PD={})}},zD=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||jD(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),RD(r,i,n,`aria-hidden`)):function(){return null}},BD=Object.defineProperty,VD=(e,t)=>BD(e,`name`,{value:t,configurable:!0}),HD=`Dialog`,[UD,WD]=$w(HD),[GD,KD]=UD(HD),qD=VD(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=I.useRef(null),c=I.useRef(null),[l,u]=hT({prop:r,defaultProp:i??!1,onChange:a,caller:HD}),[d,f]=I.useState(0),[p,m]=I.useState(0);return(0,L.jsx)(GD,{scope:t,triggerRef:s,contentRef:c,contentId:oT(),titleId:oT(),descriptionId:oT(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:I.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),JD=`DialogPortal`,[YD,XD]=UD(JD,{forceMount:void 0}),ZD=VD(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=KD(JD,t);return(0,L.jsx)(YD,{scope:t,forceMount:n,children:I.Children.map(r,e=>(0,L.jsx)(lE,{present:n||a.open,children:(0,L.jsx)(aE,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),QD=`DialogOverlay`,$D=I.forwardRef(VD(function(e,t){let n=XD(QD,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=KD(QD,e.__scopeDialog);return a.modal?(0,L.jsx)(lE,{present:r||a.open,children:(0,L.jsx)(tO,{...i,ref:t})}):null},`DialogOverlay`)),eO=ow(`DialogOverlay.RemoveScroll`),tO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,...r}=e,i=KD(QD,n),a=rw(t,FT());return(0,L.jsx)(AD,{as:eO,allowPinchZoom:!0,shards:[i.contentRef],children:(0,L.jsx)(ST.div,{"data-state":pO(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),nO=`DialogContent`,rO=I.forwardRef(VD(function(e,t){let n=XD(nO,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=KD(nO,e.__scopeDialog);return(0,L.jsx)(lE,{present:r||a.open,children:a.modal?(0,L.jsx)(iO,{...i,ref:t}):(0,L.jsx)(aO,{...i,ref:t})})},`DialogContent`)),iO=I.forwardRef(VD(function(e,t){let n=KD(nO,e.__scopeDialog),r=I.useRef(null),i=rw(t,n.contentRef,r);return I.useEffect(()=>{let e=r.current;if(e)return zD(e)},[]),(0,L.jsx)(oO,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Gw(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Gw(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Gw(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),aO=I.forwardRef(VD(function(e,t){let n=KD(nO,e.__scopeDialog),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(oO,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),oO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=KD(nO,n);return bE(),(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(KT,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(PT,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":pO(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),sO=`DialogTitle`,cO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,...r}=e,i=KD(sO,n),{setTitleCount:a}=i;return tT(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,L.jsx)(ST.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),lO=`DialogDescription`,uO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,...r}=e,i=KD(lO,n),{setDescriptionCount:a}=i;return tT(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,L.jsx)(ST.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),dO=`DialogClose`,fO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,...r}=e,i=KD(dO,n);return(0,L.jsx)(ST.button,{type:`button`,...r,ref:t,onClick:Gw(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function pO(e){return e?`open`:`closed`}VD(pO,`getState`);function mO({brand:e,visual:t,auth:n,mobileAuth:r,footer:i,className:a,...o}){return(0,L.jsxs)(`section`,{className:J(`homepage-entry`,a),...o,children:[(0,L.jsxs)(`div`,{className:`homepage-entry-desktop`,children:[(0,L.jsxs)(`section`,{className:`homepage-entry-visual-column`,"aria-label":`Tutti product preview`,children:[(0,L.jsx)(`div`,{className:`homepage-entry-brand`,children:e}),(0,L.jsx)(`div`,{className:`homepage-entry-visual`,children:t})]}),(0,L.jsxs)(`aside`,{className:`homepage-entry-auth-rail`,"aria-label":`Sign in to Tutti`,children:[(0,L.jsx)(`div`,{className:`homepage-entry-auth-content`,children:n}),i===void 0?null:(0,L.jsx)(`div`,{className:`homepage-entry-auth-footnote`,children:i})]})]}),(0,L.jsxs)(`section`,{className:`homepage-entry-mobile`,"aria-label":`Sign in to Tutti`,children:[(0,L.jsx)(`div`,{className:`product-appbar`,children:e}),(0,L.jsx)(`div`,{className:`auth-shell`,children:r}),i===void 0?null:(0,L.jsx)(`div`,{className:`homepage-entry-mobile-footnote`,children:i})]})]})}function hO({className:e,...t}){return(0,L.jsx)(`p`,{className:J(`product-entry-footnote`,e),...t})}function gO({title:e,description:t,children:n,action:r,feedback:i,secondaryAction:a,className:o,...s}){return(0,L.jsxs)(`form`,{className:J(`product-entry-auth-form`,o),...s,children:[(0,L.jsxs)(`header`,{className:`product-entry-auth-header`,children:[(0,L.jsx)(`h1`,{children:e}),(0,L.jsx)(`p`,{children:t})]}),(0,L.jsx)(`div`,{className:`product-entry-auth-body`,children:n}),a===void 0?null:(0,L.jsx)(`div`,{className:`product-entry-auth-secondary`,children:a}),i===void 0?null:(0,L.jsx)(`div`,{className:`product-entry-auth-feedback`,children:i}),(0,L.jsx)(`footer`,{className:`product-entry-auth-footer`,children:r})]})}var _O=40.1,vO=_O+.6,yO={openingFadeEnd:1.05,chatEnd:7.45,scratchpadPanEnd:8.8,scratchpadEnd:17.8,runCursorStart:17.95,runCursorArrive:18.65,runClickStart:18.67,runEnd:18.9,executionPrepareEnd:20.35,executionImplementEnd:24.55,executionValidateEnd:26.35,executionComplete:28.15,executionEnd:28.95,fullWorkspace:30.95,artifactLive:30.55,artifactClick:32.65,artifactScroll:36.1,artifactScrollEnd:39.55,finalHoldEnd:_O,fadeEnd:vO},bO={centerX:.325,centerY:.25,scale:1.62},xO={centerX:.325,centerY:.47,scale:1.64},SO={centerX:.855,centerY:.23,scale:1.72},CO={centerX:.855,centerY:.35,scale:1.72},wO={centerX:.855,centerY:.79,scale:1.72},TO={centerX:.5,centerY:.5,scale:1},EO=[{start:1.35,end:5.95,from:bO,to:xO,linearPosition:!0},{start:7.45,end:8.8,from:xO,to:SO},{start:8.8,end:14.3,from:SO,to:CO,linearPosition:!0},{start:14.6,end:17.8,from:CO,to:wO},{start:yO.executionEnd,end:yO.fullWorkspace,from:wO,to:TO}];function DO(e,t=0,n=1){return Math.min(n,Math.max(t,e))}function OO(e){return 1-(1-DO(e))**3}function kO(e){let t=DO(e);return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function AO(e){let t=DO(e);return t<.5?16*t**5:1-(-2*t+2)**5/2}function jO(e,t,n,r=OO){let i=Math.max(.001,n-t);return r(DO((e-t)/i))}function MO(e,t,n){return e+(t-e)*n}function NO(e,t){let n=DO((t-e.start)/Math.max(.001,e.end-e.start)),r=e.linearPosition?n:AO(n);return{centerX:MO(e.from.centerX,e.to.centerX,r),centerY:MO(e.from.centerY,e.to.centerY,r),scale:MO(e.from.scale,e.to.scale,e.linearPosition?n:kO(n))}}function PO(e){if(e<EO[0].start)return bO;for(let t of EO)if(e<=t.end)return e<t.start?t.from:NO(t,e);return TO}function FO(e){return e>=yO.executionComplete?{id:`complete`,label:`Task completed`}:e>=yO.executionValidateEnd?{id:`update`,label:`Synchronizing project`}:e>=yO.executionImplementEnd?{id:`validate`,label:`Validating result`}:e>=yO.executionPrepareEnd?{id:`implement`,label:`Implementing with Codex`}:{id:`prepare`,label:`Preparing workspace`}}function IO(e){return jO(e,yO.artifactScroll,yO.artifactScrollEnd,kO)}function LO(e){return 1-jO(e,_O,vO,kO)}var RO=1500,zO=1e3,BO=2.5,VO=`(min-width: 980px) and (prefers-reduced-motion: no-preference)`,HO=(0,I.lazy)(async()=>({default:(await yS(()=>import(`./homepage-motion-scene-BcMt0AVW.js`),[])).HomepageMotionScene}));function UO(e){let[t,n]=(0,I.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(e).matches);return(0,I.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function WO(){return UO(VO)}function GO(e,t){let[n,r]=(0,I.useState)({elapsed:0,cycle:0}),i=(0,I.useRef)(null),a=vO+t;return(0,I.useEffect)(()=>{if(!e){i.current=null;return}let t=0,n=e=>{let o=i.current??e;i.current=e;let s=Math.min(.1,(e-o)/1e3);r(e=>{let t=e.elapsed+s;return t<a?{...e,elapsed:t}:{elapsed:t%a,cycle:e.cycle+1}}),t=window.requestAnimationFrame(n)};return t=window.requestAnimationFrame(n),()=>window.cancelAnimationFrame(t)},[a,e]),{cycle:n.cycle,time:Math.min(n.elapsed,vO)}}function KO(e,t){let[n,r]=(0,I.useState)(0),i=(0,I.useRef)(t),a=(0,I.useRef)(!1);return i.current=t,(0,I.useEffect)(()=>{if(r(0),a.current=!1,!e)return;let t=0,n=null,o=e=>{n??=e;let s=Math.min((e-n)/1e3,vO);if(r(s),s>=vO){a.current||(a.current=!0,i.current());return}t=window.requestAnimationFrame(o)};return t=window.requestAnimationFrame(o),()=>window.cancelAnimationFrame(t)},[e]),n}function qO(e){let t=(0,I.useRef)(null),[n,r]=(0,I.useState)(0);return(0,I.useLayoutEffect)(()=>{if(!e)return;let n=t.current;if(n===null)return;let i=()=>{let e=n.getBoundingClientRect(),t=Math.min(e.width/RO,e.height/zO);r(Number.isFinite(t)?t:0)};if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(n),()=>a.disconnect()},[e]),{frameRef:t,masterScale:n}}function JO({assets:e,enabled:t,sceneKey:n,time:r,className:i,...a}){let{frameRef:o,masterScale:s}=qO(t);return t?(0,L.jsx)(`div`,{ref:o,className:J(`homepage-motion-frame`,i),...a,children:(0,L.jsx)(`div`,{className:`homepage-motion-master`,style:{"--homepage-motion-scale":s},children:(0,L.jsx)(I.Suspense,{fallback:null,children:(0,L.jsx)(HO,{time:r,assets:e},n)})})}):null}function YO({assets:e,idleSeconds:t=BO,className:n,...r}){let i=WO(),a=GO(i,Math.max(0,t));return(0,L.jsx)(JO,{...r,assets:e,enabled:i,sceneKey:a.cycle,time:a.time,className:n})}function XO({assets:e,onComplete:t,className:n,...r}){let i=WO(),a=KO(i,(0,I.useCallback)(()=>t(),[t]));return(0,L.jsx)(JO,{...r,assets:e,enabled:i,time:a,className:n})}function ZO({onOpen:e,onDismiss:t,className:n,...r}){return(0,L.jsxs)(`aside`,{className:J(`product-tour-pill`,n),"aria-label":`Product tour`,...r,children:[(0,L.jsxs)(Y,{type:`button`,className:`product-tour-pill-open`,onClick:e,children:[(0,L.jsx)(`span`,{className:`product-tour-pill-icon`,"aria-hidden":`true`,children:(0,L.jsx)(ax,{})}),(0,L.jsxs)(`span`,{className:`product-tour-pill-copy`,children:[(0,L.jsx)(`strong`,{children:`New to Tutti?`}),(0,L.jsx)(`span`,{children:`Take a tour`})]})]}),(0,L.jsx)(Sw,{type:`button`,className:`product-tour-pill-dismiss`,label:`Dismiss product tour`,icon:(0,L.jsx)(rS,{"aria-hidden":`true`}),onClick:t})]})}function QO({assets:e,open:t,onOpenChange:n}){let r=WO();return(0,I.useEffect)(()=>{t&&!r&&n(!1)},[r,n,t]),r?(0,L.jsx)(qD,{open:t,onOpenChange:n,children:(0,L.jsxs)(ZD,{children:[(0,L.jsx)($D,{className:`product-tour-dialog-overlay`}),(0,L.jsxs)(rO,{className:`product-tour-dialog-content`,onInteractOutside:e=>e.preventDefault(),onPointerDownOutside:e=>e.preventDefault(),children:[(0,L.jsx)(cO,{className:`product-tour-dialog-title`,children:`Welcome to Tutti`}),(0,L.jsx)(fO,{asChild:!0,children:(0,L.jsx)(Sw,{type:`button`,className:`product-tour-dialog-close`,label:`Close product tour`,icon:(0,L.jsx)(rS,{"aria-hidden":`true`})})}),t?(0,L.jsx)(XO,{className:`product-tour-dialog-motion`,assets:e,onComplete:()=>n(!1)}):null]})]})}):null}function $O({status:e,className:t,...n}){let r=e===`online`?`Online`:e===`connecting`?`Connecting`:e===`stopped`?`Stopped`:e===`offline`?`Offline`:`Status unknown`,i=e===`online`?(0,L.jsx)(Rx,{"aria-hidden":`true`}):e===`connecting`?(0,L.jsx)(zx,{"aria-hidden":`true`}):e===`stopped`?(0,L.jsx)(Ix,{"aria-hidden":`true`}):e===`offline`?(0,L.jsx)(tS,{"aria-hidden":`true`}):(0,L.jsx)(ax,{"aria-hidden":`true`});return(0,L.jsx)(`span`,{className:J(`project-list-status-icon`,`is-${e}`,t),"aria-label":r,role:`img`,...n,children:i})}function ek(e){let t=(0,I.useId)();return(0,L.jsxs)(`fieldset`,{className:`product-choice-cards`,disabled:e.disabled,children:[(0,L.jsx)(`legend`,{children:e.legend}),(0,L.jsx)(`div`,{children:e.options.map(n=>(0,L.jsxs)(`label`,{className:J(`product-choice-card`,n.value===e.value&&`is-selected`),children:[(0,L.jsx)(`input`,{type:`radio`,name:t,value:n.value,checked:n.value===e.value,disabled:n.disabled,onChange:()=>e.onValueChange(n.value)}),(0,L.jsx)(`span`,{className:`product-choice-icon`,"aria-hidden":`true`,children:n.icon}),(0,L.jsx)(`strong`,{children:n.title}),(0,L.jsx)(`small`,{children:n.description}),n.note===void 0?null:(0,L.jsx)(`small`,{className:`product-choice-note`,"aria-live":`polite`,children:n.note})]},n.value))})]})}function tk(e){let t=[{value:`managed`,title:`Tutti credit`,description:`Use Tutti credit for this project`,icon:e.tuttiLogo,note:e.creditNote},{value:`byok`,title:`Custom endpoint`,description:`Use your own API key and model`,icon:e.customIcon,disabled:e.customDisabled}];return(0,L.jsx)(ek,{legend:`Model access`,value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,options:t})}function nk(e){return(0,L.jsx)(ek,{legend:`Where will this project be used?`,value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,options:[{value:`standalone`,title:`Tutti Workspace`,description:`Collaborate in Tutti's own workspace`,icon:e.tuttiLogo},{value:`feishu`,title:`Feishu`,description:`Collaborate in your Feishu group`,icon:e.feishuIcon}]})}function rk({className:e,...t}){return(0,L.jsx)(`div`,{className:J(`product-card-body`,e),...t})}function ik({items:e}){return(0,L.jsx)(`dl`,{className:`product-entry-summary`,children:e.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:e.label}),(0,L.jsx)(`dd`,{className:e.mono?`is-mono`:void 0,children:e.value})]},e.label))})}function ak({items:e}){return(0,L.jsx)(`dl`,{className:`product-metric-list`,children:e.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:e.label}),(0,L.jsx)(`dd`,{children:e.value})]},e.label))})}function ok({title:e,description:t,children:n,action:r}){return(0,L.jsxs)(`div`,{className:`product-access-row`,children:[(0,L.jsxs)(`div`,{className:`product-access-identity`,children:[(0,L.jsx)(`strong`,{children:e}),t===void 0?null:(0,L.jsx)(`small`,{children:t}),n]}),r===void 0?null:(0,L.jsx)(`div`,{className:`product-access-action`,children:r})]})}function sk(e){return(0,L.jsxs)(`div`,{className:`product-account-actions`,"aria-label":`Account actions`,children:[(0,L.jsx)(Y,{type:`button`,disabled:e.disabled,onClick:e.onCredit,"aria-label":`View credits`,children:e.credit}),(0,L.jsxs)(Y,{type:`button`,disabled:e.disabled,onClick:e.onAccount,"aria-label":`Account settings`,children:[(0,L.jsx)(`span`,{className:`product-account-name`,children:e.name}),(0,L.jsx)(nx,{"aria-hidden":`true`})]})]})}function ck({brand:e,account:t,actions:n,toolbar:r,children:i,rail:a}){let o=(0,I.useId)(),s=r.connected&&r.local;return(0,L.jsxs)(`div`,{className:`project-studio`,children:[(0,L.jsxs)(`header`,{className:`studio-header`,children:[e,(0,L.jsx)(`div`,{className:`studio-account`,children:t})]}),(0,L.jsxs)(`main`,{className:`studio-main`,"aria-label":`Project Center`,children:[(0,L.jsxs)(`header`,{className:`studio-heading`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`studio-eyebrow`,children:`One place to begin`}),(0,L.jsxs)(`h1`,{children:[`Projects`,(0,L.jsx)(`span`,{children:`.`})]})]}),(0,L.jsx)(`div`,{className:`studio-heading-actions`,children:n})]}),(0,L.jsxs)(`div`,{className:`studio-grid${s?` is-computer-scope`:``}`,children:[(0,L.jsxs)(`section`,{className:`studio-projects`,"aria-label":`Projects`,children:[(0,L.jsx)(lk,{...r,panelId:o}),(0,L.jsx)(`div`,{id:o,role:r.connected?`tabpanel`:`region`,"aria-labelledby":r.connected?`${o}-${s?`computer`:`account`}`:void 0,"aria-label":r.connected?void 0:`Your projects`,tabIndex:r.connected?0:void 0,className:`studio-project-panel`,children:i})]}),a]})]})]})}function lk({local:e,onLocalChange:t,search:n,onSearchChange:r,connected:i,panelId:a}){return(0,L.jsxs)(`div`,{className:`studio-toolbar`,children:[i?(0,L.jsx)(`div`,{className:`studio-filters`,role:`tablist`,"aria-label":`Project scope`,onKeyDown:n=>{let r=n.key===`Home`?!1:n.key===`End`?!0:n.key===`ArrowLeft`||n.key===`ArrowRight`?!e:null;r!==null&&(n.preventDefault(),t(r),n.currentTarget.querySelectorAll(`[role="tab"]`)[Number(r)]?.focus())},children:[!1,!0].map(n=>(0,L.jsxs)(`button`,{type:`button`,role:`tab`,id:`${a}-${n?`computer`:`account`}`,"aria-controls":a,"aria-selected":e===n,tabIndex:e===n?0:-1,onClick:()=>t(n),children:[n?(0,L.jsx)(jx,{"aria-hidden":`true`}):(0,L.jsx)(gx,{"aria-hidden":`true`}),n?`This computer`:`Your projects`]},String(n)))}):null,(0,L.jsxs)(`label`,{className:`studio-search`,children:[(0,L.jsx)(Ux,{"aria-hidden":`true`}),(0,L.jsx)(`input`,{type:`search`,"aria-label":`Find a project`,placeholder:`Find a project`,value:n,onChange:e=>r(e.target.value)})]})]})}function uk({count:e,open:t,onOpenChange:n,children:r}){let i=(0,I.useId)();return(0,L.jsxs)(`div`,{className:`studio-unavailable`,children:[(0,L.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":i,onClick:()=>n(!t),children:[(0,L.jsx)(nx,{"aria-hidden":`true`}),`Currently unavailable `,(0,L.jsxs)(`span`,{children:[`(`,e,`)`]})]}),(0,L.jsx)(`div`,{id:i,children:t?r:null})]})}function dk({children:e}){return(0,L.jsx)(`div`,{className:`studio-computer-controls`,children:e})}function fk({title:e,status:t,meta:n,local:r,selected:i,onSelect:a,action:o,children:s}){let c=(0,I.useId)(),l=(0,I.useRef)(null);return(0,I.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>{let e=l.current;if(!e)return;let t=e.getBoundingClientRect();t.top>=16&&t.bottom<=window.innerHeight-16||e.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})});return()=>cancelAnimationFrame(e)},[i]),(0,L.jsxs)(`div`,{ref:l,className:`studio-project-item${i?` is-selected`:``}`,children:[(0,L.jsxs)(`div`,{className:`studio-project-row`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`studio-project-select`,onClick:a,"aria-expanded":i,"aria-controls":c,"aria-label":`Details for ${e}`,children:[(0,L.jsx)(`span`,{className:`studio-monogram`,"aria-hidden":`true`,children:Array.from(e)[0]}),(0,L.jsxs)(`span`,{className:`studio-project-copy`,children:[(0,L.jsx)(`strong`,{children:e}),(0,L.jsxs)(`span`,{children:[n,r?(0,L.jsxs)(`span`,{className:`studio-local-label`,children:[(0,L.jsx)(jx,{"aria-hidden":`true`}),`This computer`]}):null]})]}),(0,L.jsx)(nx,{className:`studio-project-chevron`,"aria-hidden":`true`})]}),(0,L.jsx)(`span`,{className:`studio-project-status`,children:(0,L.jsx)($O,{status:t})}),(0,L.jsx)(`div`,{className:`studio-row-actions`,children:o})]}),(0,L.jsx)(`div`,{id:c,hidden:!i,children:i?s:null})]})}function pk({title:e,children:t,actions:n}){return(0,L.jsxs)(`section`,{className:`studio-details`,"aria-label":`Selected project: ${e}`,children:[(0,L.jsx)(`div`,{className:`studio-detail-copy`,children:t}),(0,L.jsx)(`div`,{className:`studio-detail-actions`,children:n})]})}function mk({state:e,version:t,children:n}){return(0,L.jsxs)(`aside`,{className:`studio-computer`,"aria-label":`This computer`,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsx)(`h2`,{children:`This computer`}),(0,L.jsx)(`span`,{className:`studio-connection ${e===`connected`?`is-connected`:``}`,children:e===`connected`?`Connected`:e===`lost`?`Connection lost`:`Not connected`})]}),(0,L.jsx)(`div`,{className:`studio-computer-drawing`,"aria-hidden":`true`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{children:`> tutti`}),(0,L.jsx)(`small`,{children:e===`connected`?`Connected to your projects.`:`Ready to connect.`}),(0,L.jsx)(`span`,{children:`_`})]})}),(0,L.jsx)(`h3`,{children:e===`connected`?(0,L.jsxs)(L.Fragment,{children:[`Your computer.`,(0,L.jsx)(`br`,{}),(0,L.jsx)(`em`,{children:`Your workspace.`})]}):(0,L.jsxs)(L.Fragment,{children:[`Bring your`,(0,L.jsx)(`br`,{}),(0,L.jsx)(`em`,{children:`projects closer.`})]})}),(0,L.jsx)(`p`,{children:e===`connected`?`Manage local projects without leaving this page.`:e===`lost`?`Reconnect to manage local projects. Your hosts may still be running.`:`Connect Tutti on this computer to manage your local projects here.`}),(0,L.jsx)(`div`,{className:`studio-computer-actions`,children:n}),t?(0,L.jsxs)(`small`,{className:`studio-version`,children:[`Tutti `,t]}):null]})}function hk({asChild:e=!1,className:t,...n}){return(0,L.jsx)(e?sw:`section`,{className:J(`product-card`,t),...n})}function gk({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`product-card-header`,t),...n,children:e})}function _k({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`product-card-body`,t),...n,children:e})}function vk({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`product-card-feedback`,t),...n,children:e})}function yk({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`product-card-footer`,t),...n,children:e})}function bk({title:e,description:t,children:n,action:r,feedback:i,secondaryAction:a,size:o=`standard`,className:s,...c}){return(0,L.jsx)(hk,{className:J(`entry-card auth-card`,o===`wide`?`is-wide`:void 0,s),asChild:!0,children:(0,L.jsxs)(`form`,{...c,children:[(0,L.jsx)(`section`,{className:`auth-card-intro`,children:(0,L.jsxs)(gk,{className:`auth-card-header`,children:[(0,L.jsx)(`h1`,{children:e}),(0,L.jsx)(`p`,{children:t})]})}),(0,L.jsx)(`section`,{className:`auth-card-action`,children:(0,L.jsxs)(`div`,{className:`auth-card-action-content`,children:[(0,L.jsx)(_k,{children:n}),a===void 0?null:(0,L.jsx)(`div`,{className:`auth-card-secondary`,children:a}),i===void 0?null:(0,L.jsx)(vk,{children:i}),(0,L.jsx)(yk,{children:r})]})})]})})}function xk({projectName:e,hostLabel:t,hostOnline:n=!1,members:r,invitedBy:i,className:a,...o}){return(0,L.jsxs)(`section`,{className:J(`invite-summary`,a),"aria-label":`Project invitation`,...o,children:[(0,L.jsxs)(`div`,{className:`invite-project`,children:[(0,L.jsx)(`h2`,{children:e}),(0,L.jsxs)(`p`,{className:J(`project-line`,n?`is-online`:`is-offline`),children:[(0,L.jsx)(`span`,{className:`status-dot`,"aria-hidden":`true`}),t]})]}),r===void 0?null:(0,L.jsx)(`div`,{className:`invite-members`,children:r}),i===void 0?null:(0,L.jsxs)(`div`,{className:`invite-meta`,children:[(0,L.jsx)(`span`,{children:`Invited by`}),(0,L.jsx)(`strong`,{children:i})]})]})}function Sk({label:e,value:t,action:n,className:r,...i}){return(0,L.jsxs)(`div`,{className:J(`account-row`,r),...i,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{children:e}),(0,L.jsx)(`strong`,{children:t})]}),n]})}function Ck({title:e,accountName:t,accountAction:n,children:r,className:i,...a}){return(0,L.jsxs)(hk,{className:J(`project-center-card`,i),...a,children:[(0,L.jsxs)(`header`,{className:`project-center-card-header`,children:[(0,L.jsx)(`h1`,{children:e}),t===void 0&&n===void 0?null:(0,L.jsxs)(`div`,{className:`project-center-account`,"aria-label":t===void 0?`Page actions`:`Signed in user`,children:[t===void 0?null:(0,L.jsx)(`span`,{className:`project-center-account-name`,children:t}),n]})]}),r]})}function wk({action:e,description:t,descriptionId:n,disabledTrigger:r=!1,className:i,...a}){return(0,L.jsx)(`div`,{className:J(`project-center-header-action`,i),...a,children:t===void 0?e:(0,L.jsx)(Dw,{content:t,disabledTrigger:r,side:`bottom`,...n===void 0?{}:{contentId:n},children:e})})}function Tk({items:e,className:t,...n}){return(0,L.jsx)(`nav`,{className:J(`project-scope-navigation`,t),"aria-label":`Project scope`,...n,children:(0,L.jsx)(`ul`,{children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`a`,{href:e.href,"aria-current":e.current===!0?`page`:void 0,...e.current!==!0&&e.onClick===void 0?{}:{onClick:t=>{e.current===!0&&t.preventDefault(),e.onClick?.(t)}},children:e.label})},e.id))})})}function Ek({items:e,action:t,className:n,...r}){return(0,L.jsxs)(`section`,{className:J(`project-scope-toolbar`,n),...r,children:[(0,L.jsx)(Tk,{items:e}),(0,L.jsx)(`div`,{className:`project-scope-toolbar-action`,children:t})]})}function Dk({command:e,terminalLabel:t=`Install and start in your terminal`,copyLabel:n=`Copy`,copyAriaLabel:r=`Copy launch command`,commandAriaLabel:i=`Launch command`,onCopyCommand:a,className:o,...s}){return(0,L.jsxs)(`section`,{className:J(`project-launch-terminal`,o),...s,children:[(0,L.jsxs)(`div`,{className:`project-launch-terminal-bar`,children:[(0,L.jsx)(`span`,{children:t}),a===void 0?null:(0,L.jsxs)(Y,{className:`project-launch-copy-button`,type:`button`,"aria-label":r,onClick:()=>a(e),children:[(0,L.jsx)(ux,{"aria-hidden":`true`}),n]})]}),(0,L.jsx)(`pre`,{className:`project-launch-command-block`,"aria-label":i,children:(0,L.jsx)(`code`,{children:(0,L.jsxs)(`span`,{className:`project-launch-command-line`,children:[(0,L.jsx)(`span`,{className:`project-launch-command-prompt`,"aria-hidden":`true`,children:`>`}),(0,L.jsx)(`span`,{children:e})]})})})]})}function Ok({open:e,onOpenChange:t,status:n=`opening`,description:r,command:i,onCopyCommand:a,retryHref:o,onRetry:s}){return(0,L.jsx)(Nk,{open:e,onOpenChange:t,title:`Projects on this computer`,description:n===`opening`?`Opening Tutti…`:`Tutti did not open in this tab.`,className:`project-local-handoff-dialog-card`,children:(0,L.jsxs)(`div`,{className:`project-local-handoff-dialog-body`,children:[(0,L.jsxs)(`div`,{className:`project-local-handoff-intro`,children:[(0,L.jsx)(`span`,{className:`project-local-handoff-icon`,"aria-hidden":`true`,children:(0,L.jsx)(Qx,{})}),(0,L.jsx)(`p`,{children:r})]}),(0,L.jsx)(Dk,{command:i,...a===void 0?{}:{onCopyCommand:a}}),n!==`failed`||o===void 0?null:(0,L.jsx)(`div`,{className:`project-local-handoff-actions`,children:(0,L.jsx)(Cw,{asChild:!0,children:(0,L.jsxs)(`a`,{href:o,...s===void 0?{}:{onClick:s},children:[(0,L.jsx)(zx,{"aria-hidden":`true`}),`Retry`]})})})]})})}function kk({open:e,onOpenChange:t,projectName:n,state:r,command:i,unavailableMessage:a,onCopyCommand:o}){let s=r===`loading`?{icon:(0,L.jsx)(zx,{"aria-hidden":`true`}),message:`Reading the connection state from the running Host…`}:r===`pairing_required`?{icon:(0,L.jsx)(Qx,{"aria-hidden":`true`}),message:`In the target Feishu group, send this command once.`}:r===`connected`?{icon:(0,L.jsx)(Rx,{"aria-hidden":`true`}),message:`This project is connected to its Feishu project group.`}:r===`not_recoverable`?{icon:(0,L.jsx)(ax,{"aria-hidden":`true`}),message:`The previous pairing command is no longer available. Stop and Resume this project to issue a new one.`}:r===`account_handoff_required`?{icon:(0,L.jsx)(ax,{"aria-hidden":`true`}),message:`This Host needs a fresh Tutti account handoff. Sign in to Local Console again, then Stop and Resume the project.`}:{icon:(0,L.jsx)(ax,{"aria-hidden":`true`}),message:a??`The Feishu connection state is temporarily unavailable. Try again from Connect.`};return(0,L.jsx)(Nk,{open:e,onOpenChange:t,title:`Feishu connection`,description:`Connect ${n} to a Feishu project group.`,className:`project-local-handoff-dialog-card`,children:(0,L.jsxs)(`div`,{className:`project-local-handoff-dialog-body`,children:[(0,L.jsxs)(`div`,{className:`project-local-handoff-intro`,"aria-live":`polite`,children:[(0,L.jsx)(`span`,{className:`project-local-handoff-icon`,"aria-hidden":`true`,children:s.icon}),(0,L.jsx)(`p`,{children:s.message})]}),r===`pairing_required`&&i!==void 0?(0,L.jsx)(Dk,{command:i,terminalLabel:`Send in the target Feishu group`,copyAriaLabel:`Copy connection command`,commandAriaLabel:`Connection command`,...o===void 0?{}:{onCopyCommand:o}}):null]})})}function Ak({children:e,className:t,...n}){return(0,L.jsx)(`ul`,{className:J(`project-list`,t),"aria-label":`Recent projects`,...n,children:e})}function jk({children:e,className:t,...n}){return(0,L.jsx)(`section`,{className:J(`project-list-surface`,t),...n,children:(0,L.jsx)(Ak,{children:e})})}function Mk({children:e,className:t,...n}){return(0,L.jsx)(`li`,{className:J(`project-list-item project-list-state-row`,t),...n,children:e})}function Nk({open:e,onOpenChange:t,title:n,description:r,headerAction:i,children:a,closeDisabled:o=!1,explicitCloseOnly:s=!1,className:c}){return(0,L.jsxs)(qD,{open:e,onOpenChange:e=>{(e||!o)&&t(e)},children:[(0,L.jsx)($D,{className:`product-entry-dialog-overlay`}),(0,L.jsx)(rO,{asChild:!0,...r===void 0?{"aria-describedby":void 0}:{},onEscapeKeyDown:e=>{(o||s)&&e.preventDefault()},onInteractOutside:e=>{(o||s)&&e.preventDefault()},onPointerDownOutside:e=>{(o||s)&&e.preventDefault()},children:(0,L.jsxs)(hk,{className:J(`product-entry-dialog-card`,c),children:[(0,L.jsxs)(`header`,{className:`product-entry-dialog-header`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(cO,{children:n}),r===void 0?null:(0,L.jsx)(uO,{children:r})]}),(0,L.jsxs)(`div`,{className:`product-entry-dialog-actions`,children:[i,(0,L.jsx)(fO,{asChild:!0,children:(0,L.jsx)(Sw,{type:`button`,label:`Close`,icon:(0,L.jsx)(rS,{"aria-hidden":`true`}),disabled:o})})]})]}),a]})})]})}function Pk({open:e,onOpenChange:t,inputLabel:n,placeholder:r,value:i,error:a,actionLabel:o=`Continue`,onValueChange:s,className:c,...l}){return(0,L.jsx)(Nk,{open:e,onOpenChange:t,title:`Join a project`,description:`Paste an invitation link or the full invitation message.`,className:`project-join-dialog-card`,children:(0,L.jsxs)(`form`,{className:J(`project-join-dialog-form`,c),...l,children:[(0,L.jsxs)(`div`,{className:`project-join-dialog-body`,children:[(0,L.jsx)(jw,{type:`text`,"aria-label":n,value:i,onChange:e=>s(e.target.value),autoFocus:!0,...r===void 0?{}:{placeholder:r}}),a==null?null:(0,L.jsx)(Iw,{children:a})]}),(0,L.jsx)(`footer`,{className:`project-join-dialog-actions`,children:(0,L.jsxs)(Cw,{type:`submit`,disabled:i.trim()===``,children:[o,(0,L.jsx)(Zb,{"aria-hidden":`true`})]})})]})})}function Fk({open:e,onOpenChange:t,steps:n,currentStep:r,children:i,action:a,backAction:o,feedback:s,closeDisabled:c=!1,explicitCloseOnly:l=!1,className:u,...d}){return(0,L.jsxs)(Nk,{open:e,onOpenChange:t,title:`New project`,description:`Step ${r+1} of ${n.length}`,closeDisabled:c,explicitCloseOnly:l,className:`local-console-create-card`,children:[(0,L.jsx)(`ol`,{className:`local-console-create-steps`,"aria-label":`New project steps`,children:n.map((e,t)=>(0,L.jsxs)(`li`,{className:J(t===r?`is-current`:void 0,t<r?`is-complete`:void 0),"aria-current":t===r?`step`:void 0,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:t+1}),(0,L.jsx)(`small`,{children:e})]},e))}),(0,L.jsxs)(`form`,{className:J(`local-console-create-form`,u),...d,children:[(0,L.jsx)(`div`,{className:`local-console-create-body`,children:i}),s===void 0?null:(0,L.jsx)(`div`,{className:`local-console-create-feedback`,children:s}),(0,L.jsxs)(`footer`,{className:`local-console-create-actions`,children:[(0,L.jsx)(`div`,{children:o}),(0,L.jsx)(`div`,{children:a})]})]})]})}function Ik({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`local-console-form-grid`,t),...n,children:e})}function Lk({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`local-console-inline-actions`,t),...n,children:e})}function Rk({title:e,children:t}){return(0,L.jsxs)(`details`,{className:`local-console-field-group product-disclosure`,children:[(0,L.jsx)(`summary`,{children:e}),(0,L.jsx)(`div`,{className:`local-console-field-group-body`,children:t})]})}function zk({title:e,description:t,children:n,className:r,...i}){return(0,L.jsxs)(`section`,{className:J(`local-console-field-group`,r),...i,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsx)(`strong`,{children:e}),t===void 0?null:(0,L.jsx)(`small`,{children:t})]}),(0,L.jsx)(`div`,{className:`local-console-field-group-body`,children:n})]})}function Bk({path:e,className:t,...n}){let r=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),i=r>0&&r<e.length-1;return(0,L.jsx)(`span`,{className:J(`local-console-project-path`,t),title:e,...n,children:i?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`local-console-project-path-prefix`,children:e.slice(0,r)}),(0,L.jsx)(`span`,{className:`local-console-project-path-separator`,children:e[r]}),(0,L.jsx)(`span`,{className:`local-console-project-path-name`,children:e.slice(r+1)})]}):(0,L.jsx)(`span`,{className:`local-console-project-path-name`,children:e})})}function Vk({title:e,status:t,path:n,createdLabel:r,modelLabel:i,surfaceLabel:a,actions:o,className:s,...c}){return(0,L.jsx)(`li`,{className:J(`project-list-item`,`local-console-project-item`,s),...c,children:(0,L.jsxs)(`div`,{className:J(`local-console-project-row`,t===`stopped`?`is-inactive`:`is-active`),children:[(0,L.jsx)($O,{status:t}),(0,L.jsxs)(`span`,{className:`project-list-identity`,children:[(0,L.jsx)(`span`,{className:`local-console-project-title`,children:(0,L.jsx)(`strong`,{children:e})}),i===void 0&&a===void 0?null:(0,L.jsxs)(`span`,{className:`local-console-project-signals`,children:[i===void 0?null:(0,L.jsx)(`small`,{className:`local-console-provider-model`,children:i}),a===void 0?null:(0,L.jsx)(`small`,{className:`local-console-project-surface`,children:a})]})]}),(0,L.jsxs)(`span`,{className:`local-console-project-metadata`,children:[(0,L.jsx)(`strong`,{className:`local-console-project-date`,children:r}),(0,L.jsx)(Bk,{path:n})]}),(0,L.jsx)(`span`,{className:`local-console-project-actions`,children:o})]})})}function Hk(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Uk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Wk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Gk={};function Kk(e,t){return((t||Gk).jsx?Wk:Uk).test(e)}var qk=/[ \t\n\f\r]/g;function Jk(e){return typeof e==`object`?e.type===`text`?Yk(e.value):!1:Yk(e)}function Yk(e){return e.replace(qk,``)===``}var Xk=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Xk.prototype.normal={},Xk.prototype.property={},Xk.prototype.space=void 0;function Zk(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Xk(n,r,t)}function Qk(e){return e.toLowerCase()}var $k=class{constructor(e,t){this.attribute=t,this.property=e}};$k.prototype.attribute=``,$k.prototype.booleanish=!1,$k.prototype.boolean=!1,$k.prototype.commaOrSpaceSeparated=!1,$k.prototype.commaSeparated=!1,$k.prototype.defined=!1,$k.prototype.mustUseProperty=!1,$k.prototype.number=!1,$k.prototype.overloadedBoolean=!1,$k.prototype.property=``,$k.prototype.spaceSeparated=!1,$k.prototype.space=void 0;var eA=s({boolean:()=>nA,booleanish:()=>rA,commaOrSpaceSeparated:()=>sA,commaSeparated:()=>oA,number:()=>X,overloadedBoolean:()=>iA,spaceSeparated:()=>aA}),tA=0,nA=cA(),rA=cA(),iA=cA(),X=cA(),aA=cA(),oA=cA(),sA=cA();function cA(){return 2**++tA}var lA=Object.keys(eA),uA=class extends $k{constructor(e,t,n,r){let i=-1;if(super(e,t),dA(this,`space`,r),typeof n==`number`)for(;++i<lA.length;){let e=lA[i];dA(this,lA[i],(n&eA[e])===eA[e])}}};uA.prototype.defined=!0;function dA(e,t,n){n&&(e[t]=n)}function fA(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new uA(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Qk(r)]=r,n[Qk(a.attribute)]=r}return new Xk(t,n,e.space)}var pA=fA({properties:{ariaActiveDescendant:null,ariaAtomic:rA,ariaAutoComplete:null,ariaBusy:rA,ariaChecked:rA,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:aA,ariaCurrent:null,ariaDescribedBy:aA,ariaDetails:null,ariaDisabled:rA,ariaDropEffect:aA,ariaErrorMessage:null,ariaExpanded:rA,ariaFlowTo:aA,ariaGrabbed:rA,ariaHasPopup:null,ariaHidden:rA,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:aA,ariaLevel:X,ariaLive:null,ariaModal:rA,ariaMultiLine:rA,ariaMultiSelectable:rA,ariaOrientation:null,ariaOwns:aA,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:rA,ariaReadOnly:rA,ariaRelevant:null,ariaRequired:rA,ariaRoleDescription:aA,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:rA,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function mA(e,t){return t in e?e[t]:t}function hA(e,t){return mA(e,t.toLowerCase())}var gA=fA({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:oA,acceptCharset:aA,accessKey:aA,action:null,allow:null,allowFullScreen:nA,allowPaymentRequest:nA,allowUserMedia:nA,alt:null,as:null,async:nA,autoCapitalize:null,autoComplete:aA,autoFocus:nA,autoPlay:nA,blocking:aA,capture:null,charSet:null,checked:nA,cite:null,className:aA,cols:X,colSpan:null,content:null,contentEditable:rA,controls:nA,controlsList:aA,coords:X|oA,crossOrigin:null,data:null,dateTime:null,decoding:null,default:nA,defer:nA,dir:null,dirName:null,disabled:nA,download:iA,draggable:rA,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:nA,formTarget:null,headers:aA,height:X,hidden:iA,high:X,href:null,hrefLang:null,htmlFor:aA,httpEquiv:aA,id:null,imageSizes:null,imageSrcSet:null,inert:nA,inputMode:null,integrity:null,is:null,isMap:nA,itemId:null,itemProp:aA,itemRef:aA,itemScope:nA,itemType:aA,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:nA,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:nA,muted:nA,name:null,nonce:null,noModule:nA,noValidate:nA,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:nA,optimum:X,pattern:null,ping:aA,placeholder:null,playsInline:nA,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:nA,referrerPolicy:null,rel:aA,required:nA,reversed:nA,rows:X,rowSpan:X,sandbox:aA,scope:null,scoped:nA,seamless:nA,selected:nA,shadowRootClonable:nA,shadowRootDelegatesFocus:nA,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:rA,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:nA,useMap:null,value:rA,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:aA,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:nA,declare:nA,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:nA,noHref:nA,noShade:nA,noWrap:nA,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:rA,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:nA,disableRemotePlayback:nA,prefix:null,property:null,results:X,security:null,unselectable:null},space:`html`,transform:hA}),_A=fA({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:sA,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:aA,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:nA,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:oA,g2:oA,glyphName:oA,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:sA,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:aA,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:sA,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:sA,rev:sA,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:sA,requiredFeatures:sA,requiredFonts:sA,requiredFormats:sA,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:sA,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:sA,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:sA,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:mA}),vA=fA({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),yA=fA({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:hA}),bA=fA({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),xA={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},SA=/[A-Z]/g,CA=/-[a-z]/g,wA=/^data[-\w.:]+$/i;function TA(e,t){let n=Qk(t),r=t,i=$k;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&wA.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(CA,DA);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!CA.test(e)){let n=e.replace(SA,EA);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=uA}return new i(r,t)}function EA(e){return`-`+e.toLowerCase()}function DA(e){return e.charAt(1).toUpperCase()}var OA=Zk([pA,gA,vA,yA,bA],`html`),kA=Zk([pA,_A,vA,yA,bA],`svg`);function AA(e){return e.join(` `).trim()}var jA=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
49
|
+
`},TD=0,ED=[];function DD(e){var t=I.useRef([]),n=I.useRef([0,0]),r=I.useRef(),i=I.useState(TD++)[0],a=I.useState(YE)[0],o=I.useRef(e);I.useEffect(function(){o.current=e},[e]),I.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=wE([e.lockRef.current],(e.shards||[]).map(SD),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=I.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=bD(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=pD(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=pD(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return yD(h,t,e,h===`h`?s:c,!0)},[]),c=I.useCallback(function(e){var n=e;if(!(!ED.length||ED[ED.length-1]!==a)){var r=`deltaY`in n?xD(n):bD(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&CD(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(SD).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=I.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:OD(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=I.useCallback(function(e){n.current=bD(e),r.current=void 0},[]),d=I.useCallback(function(t){l(t.type,xD(t),t.target,s(t,e.lockRef.current))},[]),f=I.useCallback(function(t){l(t.type,bD(t),t.target,s(t,e.lockRef.current))},[]);I.useEffect(function(){return ED.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,cD),document.addEventListener(`touchmove`,c,cD),document.addEventListener(`touchstart`,u,cD),function(){ED=ED.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,cD),document.removeEventListener(`touchmove`,c,cD),document.removeEventListener(`touchstart`,u,cD)}},[]);var p=e.removeScrollBar,m=e.inert;return I.createElement(I.Fragment,null,m?I.createElement(a,{styles:wD(i)}):null,p?I.createElement(aD,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function OD(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var kD=RE(zE,DD),AD=I.forwardRef(function(e,t){return I.createElement(VE,SE({},e,{ref:t,sideCar:kD}))});AD.classNames=VE.classNames;var jD=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},MD=new WeakMap,ND=new WeakMap,PD={},FD=0,ID=function(e){return e&&(e.host||ID(e.parentNode))},LD=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=ID(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},RD=function(e,t,n,r){var i=LD(t,Array.isArray(e)?e:[e]);PD[n]||(PD[n]=new WeakMap);var a=PD[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(MD.get(e)||0)+1,l=(a.get(e)||0)+1;MD.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ND.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),FD++,function(){o.forEach(function(e){var t=MD.get(e)-1,i=a.get(e)-1;MD.set(e,t),a.set(e,i),t||(ND.has(e)||e.removeAttribute(r),ND.delete(e)),i||e.removeAttribute(n)}),FD--,FD||(MD=new WeakMap,MD=new WeakMap,ND=new WeakMap,PD={})}},zD=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||jD(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),RD(r,i,n,`aria-hidden`)):function(){return null}},BD=Object.defineProperty,VD=(e,t)=>BD(e,`name`,{value:t,configurable:!0}),HD=`Dialog`,[UD,WD]=$w(HD),[GD,KD]=UD(HD),qD=VD(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=I.useRef(null),c=I.useRef(null),[l,u]=hT({prop:r,defaultProp:i??!1,onChange:a,caller:HD}),[d,f]=I.useState(0),[p,m]=I.useState(0);return(0,L.jsx)(GD,{scope:t,triggerRef:s,contentRef:c,contentId:oT(),titleId:oT(),descriptionId:oT(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:I.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),JD=`DialogPortal`,[YD,XD]=UD(JD,{forceMount:void 0}),ZD=VD(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=KD(JD,t);return(0,L.jsx)(YD,{scope:t,forceMount:n,children:I.Children.map(r,e=>(0,L.jsx)(lE,{present:n||a.open,children:(0,L.jsx)(aE,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),QD=`DialogOverlay`,$D=I.forwardRef(VD(function(e,t){let n=XD(QD,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=KD(QD,e.__scopeDialog);return a.modal?(0,L.jsx)(lE,{present:r||a.open,children:(0,L.jsx)(tO,{...i,ref:t})}):null},`DialogOverlay`)),eO=ow(`DialogOverlay.RemoveScroll`),tO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,...r}=e,i=KD(QD,n),a=rw(t,FT());return(0,L.jsx)(AD,{as:eO,allowPinchZoom:!0,shards:[i.contentRef],children:(0,L.jsx)(ST.div,{"data-state":pO(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),nO=`DialogContent`,rO=I.forwardRef(VD(function(e,t){let n=XD(nO,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=KD(nO,e.__scopeDialog);return(0,L.jsx)(lE,{present:r||a.open,children:a.modal?(0,L.jsx)(iO,{...i,ref:t}):(0,L.jsx)(aO,{...i,ref:t})})},`DialogContent`)),iO=I.forwardRef(VD(function(e,t){let n=KD(nO,e.__scopeDialog),r=I.useRef(null),i=rw(t,n.contentRef,r);return I.useEffect(()=>{let e=r.current;if(e)return zD(e)},[]),(0,L.jsx)(oO,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Gw(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Gw(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Gw(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),aO=I.forwardRef(VD(function(e,t){let n=KD(nO,e.__scopeDialog),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(oO,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),oO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=KD(nO,n);return bE(),(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(KT,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(PT,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":pO(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),sO=`DialogTitle`,cO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,...r}=e,i=KD(sO,n),{setTitleCount:a}=i;return tT(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,L.jsx)(ST.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),lO=`DialogDescription`,uO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,...r}=e,i=KD(lO,n),{setDescriptionCount:a}=i;return tT(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,L.jsx)(ST.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),dO=`DialogClose`,fO=I.forwardRef(VD(function(e,t){let{__scopeDialog:n,...r}=e,i=KD(dO,n);return(0,L.jsx)(ST.button,{type:`button`,...r,ref:t,onClick:Gw(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function pO(e){return e?`open`:`closed`}VD(pO,`getState`);function mO({brand:e,visual:t,auth:n,mobileAuth:r,footer:i,className:a,...o}){return(0,L.jsxs)(`section`,{className:J(`homepage-entry`,a),...o,children:[(0,L.jsxs)(`div`,{className:`homepage-entry-desktop`,children:[(0,L.jsxs)(`section`,{className:`homepage-entry-visual-column`,"aria-label":`Tutti product preview`,children:[(0,L.jsx)(`div`,{className:`homepage-entry-brand`,children:e}),(0,L.jsx)(`div`,{className:`homepage-entry-visual`,children:t})]}),(0,L.jsxs)(`aside`,{className:`homepage-entry-auth-rail`,"aria-label":`Sign in to Tutti`,children:[(0,L.jsx)(`div`,{className:`homepage-entry-auth-content`,children:n}),i===void 0?null:(0,L.jsx)(`div`,{className:`homepage-entry-auth-footnote`,children:i})]})]}),(0,L.jsxs)(`section`,{className:`homepage-entry-mobile`,"aria-label":`Sign in to Tutti`,children:[(0,L.jsx)(`div`,{className:`product-appbar`,children:e}),(0,L.jsx)(`div`,{className:`auth-shell`,children:r}),i===void 0?null:(0,L.jsx)(`div`,{className:`homepage-entry-mobile-footnote`,children:i})]})]})}function hO({className:e,...t}){return(0,L.jsx)(`p`,{className:J(`product-entry-footnote`,e),...t})}function gO({title:e,description:t,children:n,action:r,feedback:i,secondaryAction:a,className:o,...s}){return(0,L.jsxs)(`form`,{className:J(`product-entry-auth-form`,o),...s,children:[(0,L.jsxs)(`header`,{className:`product-entry-auth-header`,children:[(0,L.jsx)(`h1`,{children:e}),(0,L.jsx)(`p`,{children:t})]}),(0,L.jsx)(`div`,{className:`product-entry-auth-body`,children:n}),a===void 0?null:(0,L.jsx)(`div`,{className:`product-entry-auth-secondary`,children:a}),i===void 0?null:(0,L.jsx)(`div`,{className:`product-entry-auth-feedback`,children:i}),(0,L.jsx)(`footer`,{className:`product-entry-auth-footer`,children:r})]})}var _O=40.1,vO=_O+.6,yO={openingFadeEnd:1.05,chatEnd:7.45,scratchpadPanEnd:8.8,scratchpadEnd:17.8,runCursorStart:17.95,runCursorArrive:18.65,runClickStart:18.67,runEnd:18.9,executionPrepareEnd:20.35,executionImplementEnd:24.55,executionValidateEnd:26.35,executionComplete:28.15,executionEnd:28.95,fullWorkspace:30.95,artifactLive:30.55,artifactClick:32.65,artifactScroll:36.1,artifactScrollEnd:39.55,finalHoldEnd:_O,fadeEnd:vO},bO={centerX:.325,centerY:.25,scale:1.62},xO={centerX:.325,centerY:.47,scale:1.64},SO={centerX:.855,centerY:.23,scale:1.72},CO={centerX:.855,centerY:.35,scale:1.72},wO={centerX:.855,centerY:.79,scale:1.72},TO={centerX:.5,centerY:.5,scale:1},EO=[{start:1.35,end:5.95,from:bO,to:xO,linearPosition:!0},{start:7.45,end:8.8,from:xO,to:SO},{start:8.8,end:14.3,from:SO,to:CO,linearPosition:!0},{start:14.6,end:17.8,from:CO,to:wO},{start:yO.executionEnd,end:yO.fullWorkspace,from:wO,to:TO}];function DO(e,t=0,n=1){return Math.min(n,Math.max(t,e))}function OO(e){return 1-(1-DO(e))**3}function kO(e){let t=DO(e);return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function AO(e){let t=DO(e);return t<.5?16*t**5:1-(-2*t+2)**5/2}function jO(e,t,n,r=OO){let i=Math.max(.001,n-t);return r(DO((e-t)/i))}function MO(e,t,n){return e+(t-e)*n}function NO(e,t){let n=DO((t-e.start)/Math.max(.001,e.end-e.start)),r=e.linearPosition?n:AO(n);return{centerX:MO(e.from.centerX,e.to.centerX,r),centerY:MO(e.from.centerY,e.to.centerY,r),scale:MO(e.from.scale,e.to.scale,e.linearPosition?n:kO(n))}}function PO(e){if(e<EO[0].start)return bO;for(let t of EO)if(e<=t.end)return e<t.start?t.from:NO(t,e);return TO}function FO(e){return e>=yO.executionComplete?{id:`complete`,label:`Task completed`}:e>=yO.executionValidateEnd?{id:`update`,label:`Synchronizing project`}:e>=yO.executionImplementEnd?{id:`validate`,label:`Validating result`}:e>=yO.executionPrepareEnd?{id:`implement`,label:`Implementing with Codex`}:{id:`prepare`,label:`Preparing workspace`}}function IO(e){return jO(e,yO.artifactScroll,yO.artifactScrollEnd,kO)}function LO(e){return 1-jO(e,_O,vO,kO)}var RO=1500,zO=1e3,BO=2.5,VO=`(min-width: 980px) and (prefers-reduced-motion: no-preference)`,HO=(0,I.lazy)(async()=>({default:(await yS(()=>import(`./homepage-motion-scene-BHhw4CfM.js`),[])).HomepageMotionScene}));function UO(e){let[t,n]=(0,I.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(e).matches);return(0,I.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function WO(){return UO(VO)}function GO(e,t){let[n,r]=(0,I.useState)({elapsed:0,cycle:0}),i=(0,I.useRef)(null),a=vO+t;return(0,I.useEffect)(()=>{if(!e){i.current=null;return}let t=0,n=e=>{let o=i.current??e;i.current=e;let s=Math.min(.1,(e-o)/1e3);r(e=>{let t=e.elapsed+s;return t<a?{...e,elapsed:t}:{elapsed:t%a,cycle:e.cycle+1}}),t=window.requestAnimationFrame(n)};return t=window.requestAnimationFrame(n),()=>window.cancelAnimationFrame(t)},[a,e]),{cycle:n.cycle,time:Math.min(n.elapsed,vO)}}function KO(e,t){let[n,r]=(0,I.useState)(0),i=(0,I.useRef)(t),a=(0,I.useRef)(!1);return i.current=t,(0,I.useEffect)(()=>{if(r(0),a.current=!1,!e)return;let t=0,n=null,o=e=>{n??=e;let s=Math.min((e-n)/1e3,vO);if(r(s),s>=vO){a.current||(a.current=!0,i.current());return}t=window.requestAnimationFrame(o)};return t=window.requestAnimationFrame(o),()=>window.cancelAnimationFrame(t)},[e]),n}function qO(e){let t=(0,I.useRef)(null),[n,r]=(0,I.useState)(0);return(0,I.useLayoutEffect)(()=>{if(!e)return;let n=t.current;if(n===null)return;let i=()=>{let e=n.getBoundingClientRect(),t=Math.min(e.width/RO,e.height/zO);r(Number.isFinite(t)?t:0)};if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(n),()=>a.disconnect()},[e]),{frameRef:t,masterScale:n}}function JO({assets:e,enabled:t,sceneKey:n,time:r,className:i,...a}){let{frameRef:o,masterScale:s}=qO(t);return t?(0,L.jsx)(`div`,{ref:o,className:J(`homepage-motion-frame`,i),...a,children:(0,L.jsx)(`div`,{className:`homepage-motion-master`,style:{"--homepage-motion-scale":s},children:(0,L.jsx)(I.Suspense,{fallback:null,children:(0,L.jsx)(HO,{time:r,assets:e},n)})})}):null}function YO({assets:e,idleSeconds:t=BO,className:n,...r}){let i=WO(),a=GO(i,Math.max(0,t));return(0,L.jsx)(JO,{...r,assets:e,enabled:i,sceneKey:a.cycle,time:a.time,className:n})}function XO({assets:e,onComplete:t,className:n,...r}){let i=WO(),a=KO(i,(0,I.useCallback)(()=>t(),[t]));return(0,L.jsx)(JO,{...r,assets:e,enabled:i,time:a,className:n})}function ZO({onOpen:e,onDismiss:t,className:n,...r}){return(0,L.jsxs)(`aside`,{className:J(`product-tour-pill`,n),"aria-label":`Product tour`,...r,children:[(0,L.jsxs)(Y,{type:`button`,className:`product-tour-pill-open`,onClick:e,children:[(0,L.jsx)(`span`,{className:`product-tour-pill-icon`,"aria-hidden":`true`,children:(0,L.jsx)(ax,{})}),(0,L.jsxs)(`span`,{className:`product-tour-pill-copy`,children:[(0,L.jsx)(`strong`,{children:`New to Tutti?`}),(0,L.jsx)(`span`,{children:`Take a tour`})]})]}),(0,L.jsx)(Sw,{type:`button`,className:`product-tour-pill-dismiss`,label:`Dismiss product tour`,icon:(0,L.jsx)(rS,{"aria-hidden":`true`}),onClick:t})]})}function QO({assets:e,open:t,onOpenChange:n}){let r=WO();return(0,I.useEffect)(()=>{t&&!r&&n(!1)},[r,n,t]),r?(0,L.jsx)(qD,{open:t,onOpenChange:n,children:(0,L.jsxs)(ZD,{children:[(0,L.jsx)($D,{className:`product-tour-dialog-overlay`}),(0,L.jsxs)(rO,{className:`product-tour-dialog-content`,onInteractOutside:e=>e.preventDefault(),onPointerDownOutside:e=>e.preventDefault(),children:[(0,L.jsx)(cO,{className:`product-tour-dialog-title`,children:`Welcome to Tutti`}),(0,L.jsx)(fO,{asChild:!0,children:(0,L.jsx)(Sw,{type:`button`,className:`product-tour-dialog-close`,label:`Close product tour`,icon:(0,L.jsx)(rS,{"aria-hidden":`true`})})}),t?(0,L.jsx)(XO,{className:`product-tour-dialog-motion`,assets:e,onComplete:()=>n(!1)}):null]})]})}):null}function $O({status:e,className:t,...n}){let r=e===`online`?`Online`:e===`connecting`?`Connecting`:e===`stopped`?`Stopped`:e===`offline`?`Offline`:`Status unknown`,i=e===`online`?(0,L.jsx)(Rx,{"aria-hidden":`true`}):e===`connecting`?(0,L.jsx)(zx,{"aria-hidden":`true`}):e===`stopped`?(0,L.jsx)(Ix,{"aria-hidden":`true`}):e===`offline`?(0,L.jsx)(tS,{"aria-hidden":`true`}):(0,L.jsx)(ax,{"aria-hidden":`true`});return(0,L.jsx)(`span`,{className:J(`project-list-status-icon`,`is-${e}`,t),"aria-label":r,role:`img`,...n,children:i})}function ek(e){let t=(0,I.useId)();return(0,L.jsxs)(`fieldset`,{className:`product-choice-cards`,disabled:e.disabled,children:[(0,L.jsx)(`legend`,{children:e.legend}),(0,L.jsx)(`div`,{children:e.options.map(n=>(0,L.jsxs)(`label`,{className:J(`product-choice-card`,n.value===e.value&&`is-selected`),children:[(0,L.jsx)(`input`,{type:`radio`,name:t,value:n.value,checked:n.value===e.value,disabled:n.disabled,onChange:()=>e.onValueChange(n.value)}),(0,L.jsx)(`span`,{className:`product-choice-icon`,"aria-hidden":`true`,children:n.icon}),(0,L.jsx)(`strong`,{children:n.title}),(0,L.jsx)(`small`,{children:n.description}),n.note===void 0?null:(0,L.jsx)(`small`,{className:`product-choice-note`,"aria-live":`polite`,children:n.note})]},n.value))})]})}function tk(e){let t=[{value:`managed`,title:`Tutti credit`,description:`Use Tutti credit for this project`,icon:e.tuttiLogo,note:e.creditNote},{value:`byok`,title:`Custom endpoint`,description:`Use your own API key and model`,icon:e.customIcon,disabled:e.customDisabled}];return(0,L.jsx)(ek,{legend:`Model access`,value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,options:t})}function nk(e){return(0,L.jsx)(ek,{legend:`Where will this project be used?`,value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,options:[{value:`standalone`,title:`Tutti Workspace`,description:`Collaborate in Tutti's own workspace`,icon:e.tuttiLogo},{value:`feishu`,title:`Feishu`,description:`Collaborate in your Feishu group`,icon:e.feishuIcon}]})}function rk({className:e,...t}){return(0,L.jsx)(`div`,{className:J(`product-card-body`,e),...t})}function ik({items:e}){return(0,L.jsx)(`dl`,{className:`product-entry-summary`,children:e.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:e.label}),(0,L.jsx)(`dd`,{className:e.mono?`is-mono`:void 0,children:e.value})]},e.label))})}function ak({items:e}){return(0,L.jsx)(`dl`,{className:`product-metric-list`,children:e.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:e.label}),(0,L.jsx)(`dd`,{children:e.value})]},e.label))})}function ok({title:e,description:t,children:n,action:r}){return(0,L.jsxs)(`div`,{className:`product-access-row`,children:[(0,L.jsxs)(`div`,{className:`product-access-identity`,children:[(0,L.jsx)(`strong`,{children:e}),t===void 0?null:(0,L.jsx)(`small`,{children:t}),n]}),r===void 0?null:(0,L.jsx)(`div`,{className:`product-access-action`,children:r})]})}function sk(e){return(0,L.jsxs)(`div`,{className:`product-account-actions`,"aria-label":`Account actions`,children:[(0,L.jsx)(Y,{type:`button`,disabled:e.disabled,onClick:e.onCredit,"aria-label":`View credits`,children:e.credit}),(0,L.jsxs)(Y,{type:`button`,disabled:e.disabled,onClick:e.onAccount,"aria-label":`Account settings`,children:[(0,L.jsx)(`span`,{className:`product-account-name`,children:e.name}),(0,L.jsx)(nx,{"aria-hidden":`true`})]})]})}function ck({brand:e,account:t,actions:n,toolbar:r,children:i,rail:a}){let o=(0,I.useId)(),s=r.connected&&r.local;return(0,L.jsxs)(`div`,{className:`project-studio`,children:[(0,L.jsxs)(`header`,{className:`studio-header`,children:[e,(0,L.jsx)(`div`,{className:`studio-account`,children:t})]}),(0,L.jsxs)(`main`,{className:`studio-main`,"aria-label":`Project Center`,children:[(0,L.jsxs)(`header`,{className:`studio-heading`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`studio-eyebrow`,children:`One place to begin`}),(0,L.jsxs)(`h1`,{children:[`Projects`,(0,L.jsx)(`span`,{children:`.`})]})]}),(0,L.jsx)(`div`,{className:`studio-heading-actions`,children:n})]}),(0,L.jsxs)(`div`,{className:`studio-grid${s?` is-computer-scope`:``}`,children:[(0,L.jsxs)(`section`,{className:`studio-projects`,"aria-label":`Projects`,children:[(0,L.jsx)(lk,{...r,panelId:o}),(0,L.jsx)(`div`,{id:o,role:r.connected?`tabpanel`:`region`,"aria-labelledby":r.connected?`${o}-${s?`computer`:`account`}`:void 0,"aria-label":r.connected?void 0:`Your projects`,tabIndex:r.connected?0:void 0,className:`studio-project-panel`,children:i})]}),a]})]})]})}function lk({local:e,onLocalChange:t,search:n,onSearchChange:r,connected:i,panelId:a}){return(0,L.jsxs)(`div`,{className:`studio-toolbar`,children:[i?(0,L.jsx)(`div`,{className:`studio-filters`,role:`tablist`,"aria-label":`Project scope`,onKeyDown:n=>{let r=n.key===`Home`?!1:n.key===`End`?!0:n.key===`ArrowLeft`||n.key===`ArrowRight`?!e:null;r!==null&&(n.preventDefault(),t(r),n.currentTarget.querySelectorAll(`[role="tab"]`)[Number(r)]?.focus())},children:[!1,!0].map(n=>(0,L.jsxs)(`button`,{type:`button`,role:`tab`,id:`${a}-${n?`computer`:`account`}`,"aria-controls":a,"aria-selected":e===n,tabIndex:e===n?0:-1,onClick:()=>t(n),children:[n?(0,L.jsx)(jx,{"aria-hidden":`true`}):(0,L.jsx)(gx,{"aria-hidden":`true`}),n?`This computer`:`Your projects`]},String(n)))}):null,(0,L.jsxs)(`label`,{className:`studio-search`,children:[(0,L.jsx)(Ux,{"aria-hidden":`true`}),(0,L.jsx)(`input`,{type:`search`,"aria-label":`Find a project`,placeholder:`Find a project`,value:n,onChange:e=>r(e.target.value)})]})]})}function uk({count:e,open:t,onOpenChange:n,children:r}){let i=(0,I.useId)();return(0,L.jsxs)(`div`,{className:`studio-unavailable`,children:[(0,L.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":i,onClick:()=>n(!t),children:[(0,L.jsx)(nx,{"aria-hidden":`true`}),`Currently unavailable `,(0,L.jsxs)(`span`,{children:[`(`,e,`)`]})]}),(0,L.jsx)(`div`,{id:i,children:t?r:null})]})}function dk({children:e}){return(0,L.jsx)(`div`,{className:`studio-computer-controls`,children:e})}function fk({title:e,status:t,meta:n,local:r,selected:i,onSelect:a,action:o,children:s}){let c=(0,I.useId)(),l=(0,I.useRef)(null);return(0,I.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>{let e=l.current;if(!e)return;let t=e.getBoundingClientRect();t.top>=16&&t.bottom<=window.innerHeight-16||e.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})});return()=>cancelAnimationFrame(e)},[i]),(0,L.jsxs)(`div`,{ref:l,className:`studio-project-item${i?` is-selected`:``}`,children:[(0,L.jsxs)(`div`,{className:`studio-project-row`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`studio-project-select`,onClick:a,"aria-expanded":i,"aria-controls":c,"aria-label":`Details for ${e}`,children:[(0,L.jsx)(`span`,{className:`studio-monogram`,"aria-hidden":`true`,children:Array.from(e)[0]}),(0,L.jsxs)(`span`,{className:`studio-project-copy`,children:[(0,L.jsx)(`strong`,{children:e}),(0,L.jsxs)(`span`,{children:[n,r?(0,L.jsxs)(`span`,{className:`studio-local-label`,children:[(0,L.jsx)(jx,{"aria-hidden":`true`}),`This computer`]}):null]})]}),(0,L.jsx)(nx,{className:`studio-project-chevron`,"aria-hidden":`true`})]}),(0,L.jsx)(`span`,{className:`studio-project-status`,children:(0,L.jsx)($O,{status:t})}),(0,L.jsx)(`div`,{className:`studio-row-actions`,children:o})]}),(0,L.jsx)(`div`,{id:c,hidden:!i,children:i?s:null})]})}function pk({title:e,children:t,actions:n}){return(0,L.jsxs)(`section`,{className:`studio-details`,"aria-label":`Selected project: ${e}`,children:[(0,L.jsx)(`div`,{className:`studio-detail-copy`,children:t}),(0,L.jsx)(`div`,{className:`studio-detail-actions`,children:n})]})}function mk({state:e,version:t,children:n}){return(0,L.jsxs)(`aside`,{className:`studio-computer`,"aria-label":`This computer`,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsx)(`h2`,{children:`This computer`}),(0,L.jsx)(`span`,{className:`studio-connection ${e===`connected`?`is-connected`:``}`,children:e===`connected`?`Connected`:e===`lost`?`Connection lost`:`Not connected`})]}),(0,L.jsx)(`div`,{className:`studio-computer-drawing`,"aria-hidden":`true`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{children:`> tutti`}),(0,L.jsx)(`small`,{children:e===`connected`?`Connected to your projects.`:`Ready to connect.`}),(0,L.jsx)(`span`,{children:`_`})]})}),(0,L.jsx)(`h3`,{children:e===`connected`?(0,L.jsxs)(L.Fragment,{children:[`Your computer.`,(0,L.jsx)(`br`,{}),(0,L.jsx)(`em`,{children:`Your workspace.`})]}):(0,L.jsxs)(L.Fragment,{children:[`Bring your`,(0,L.jsx)(`br`,{}),(0,L.jsx)(`em`,{children:`projects closer.`})]})}),(0,L.jsx)(`p`,{children:e===`connected`?`Manage local projects without leaving this page.`:e===`lost`?`Reconnect to manage local projects. Your hosts may still be running.`:`Connect Tutti on this computer to manage your local projects here.`}),(0,L.jsx)(`div`,{className:`studio-computer-actions`,children:n}),t?(0,L.jsxs)(`small`,{className:`studio-version`,children:[`Tutti `,t]}):null]})}function hk({asChild:e=!1,className:t,...n}){return(0,L.jsx)(e?sw:`section`,{className:J(`product-card`,t),...n})}function gk({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`product-card-header`,t),...n,children:e})}function _k({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`product-card-body`,t),...n,children:e})}function vk({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`product-card-feedback`,t),...n,children:e})}function yk({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`product-card-footer`,t),...n,children:e})}function bk({title:e,description:t,children:n,action:r,feedback:i,secondaryAction:a,size:o=`standard`,className:s,...c}){return(0,L.jsx)(hk,{className:J(`entry-card auth-card`,o===`wide`?`is-wide`:void 0,s),asChild:!0,children:(0,L.jsxs)(`form`,{...c,children:[(0,L.jsx)(`section`,{className:`auth-card-intro`,children:(0,L.jsxs)(gk,{className:`auth-card-header`,children:[(0,L.jsx)(`h1`,{children:e}),(0,L.jsx)(`p`,{children:t})]})}),(0,L.jsx)(`section`,{className:`auth-card-action`,children:(0,L.jsxs)(`div`,{className:`auth-card-action-content`,children:[(0,L.jsx)(_k,{children:n}),a===void 0?null:(0,L.jsx)(`div`,{className:`auth-card-secondary`,children:a}),i===void 0?null:(0,L.jsx)(vk,{children:i}),(0,L.jsx)(yk,{children:r})]})})]})})}function xk({projectName:e,hostLabel:t,hostOnline:n=!1,members:r,invitedBy:i,className:a,...o}){return(0,L.jsxs)(`section`,{className:J(`invite-summary`,a),"aria-label":`Project invitation`,...o,children:[(0,L.jsxs)(`div`,{className:`invite-project`,children:[(0,L.jsx)(`h2`,{children:e}),(0,L.jsxs)(`p`,{className:J(`project-line`,n?`is-online`:`is-offline`),children:[(0,L.jsx)(`span`,{className:`status-dot`,"aria-hidden":`true`}),t]})]}),r===void 0?null:(0,L.jsx)(`div`,{className:`invite-members`,children:r}),i===void 0?null:(0,L.jsxs)(`div`,{className:`invite-meta`,children:[(0,L.jsx)(`span`,{children:`Invited by`}),(0,L.jsx)(`strong`,{children:i})]})]})}function Sk({label:e,value:t,action:n,className:r,...i}){return(0,L.jsxs)(`div`,{className:J(`account-row`,r),...i,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{children:e}),(0,L.jsx)(`strong`,{children:t})]}),n]})}function Ck({title:e,accountName:t,accountAction:n,children:r,className:i,...a}){return(0,L.jsxs)(hk,{className:J(`project-center-card`,i),...a,children:[(0,L.jsxs)(`header`,{className:`project-center-card-header`,children:[(0,L.jsx)(`h1`,{children:e}),t===void 0&&n===void 0?null:(0,L.jsxs)(`div`,{className:`project-center-account`,"aria-label":t===void 0?`Page actions`:`Signed in user`,children:[t===void 0?null:(0,L.jsx)(`span`,{className:`project-center-account-name`,children:t}),n]})]}),r]})}function wk({action:e,description:t,descriptionId:n,disabledTrigger:r=!1,className:i,...a}){return(0,L.jsx)(`div`,{className:J(`project-center-header-action`,i),...a,children:t===void 0?e:(0,L.jsx)(Dw,{content:t,disabledTrigger:r,side:`bottom`,...n===void 0?{}:{contentId:n},children:e})})}function Tk({items:e,className:t,...n}){return(0,L.jsx)(`nav`,{className:J(`project-scope-navigation`,t),"aria-label":`Project scope`,...n,children:(0,L.jsx)(`ul`,{children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`a`,{href:e.href,"aria-current":e.current===!0?`page`:void 0,...e.current!==!0&&e.onClick===void 0?{}:{onClick:t=>{e.current===!0&&t.preventDefault(),e.onClick?.(t)}},children:e.label})},e.id))})})}function Ek({items:e,action:t,className:n,...r}){return(0,L.jsxs)(`section`,{className:J(`project-scope-toolbar`,n),...r,children:[(0,L.jsx)(Tk,{items:e}),(0,L.jsx)(`div`,{className:`project-scope-toolbar-action`,children:t})]})}function Dk({command:e,terminalLabel:t=`Install and start in your terminal`,copyLabel:n=`Copy`,copyAriaLabel:r=`Copy launch command`,commandAriaLabel:i=`Launch command`,onCopyCommand:a,className:o,...s}){return(0,L.jsxs)(`section`,{className:J(`project-launch-terminal`,o),...s,children:[(0,L.jsxs)(`div`,{className:`project-launch-terminal-bar`,children:[(0,L.jsx)(`span`,{children:t}),a===void 0?null:(0,L.jsxs)(Y,{className:`project-launch-copy-button`,type:`button`,"aria-label":r,onClick:()=>a(e),children:[(0,L.jsx)(ux,{"aria-hidden":`true`}),n]})]}),(0,L.jsx)(`pre`,{className:`project-launch-command-block`,"aria-label":i,children:(0,L.jsx)(`code`,{children:(0,L.jsxs)(`span`,{className:`project-launch-command-line`,children:[(0,L.jsx)(`span`,{className:`project-launch-command-prompt`,"aria-hidden":`true`,children:`>`}),(0,L.jsx)(`span`,{children:e})]})})})]})}function Ok({open:e,onOpenChange:t,status:n=`opening`,description:r,command:i,onCopyCommand:a,retryHref:o,onRetry:s}){return(0,L.jsx)(Nk,{open:e,onOpenChange:t,title:`Projects on this computer`,description:n===`opening`?`Opening Tutti…`:`Tutti did not open in this tab.`,className:`project-local-handoff-dialog-card`,children:(0,L.jsxs)(`div`,{className:`project-local-handoff-dialog-body`,children:[(0,L.jsxs)(`div`,{className:`project-local-handoff-intro`,children:[(0,L.jsx)(`span`,{className:`project-local-handoff-icon`,"aria-hidden":`true`,children:(0,L.jsx)(Qx,{})}),(0,L.jsx)(`p`,{children:r})]}),(0,L.jsx)(Dk,{command:i,...a===void 0?{}:{onCopyCommand:a}}),n!==`failed`||o===void 0?null:(0,L.jsx)(`div`,{className:`project-local-handoff-actions`,children:(0,L.jsx)(Cw,{asChild:!0,children:(0,L.jsxs)(`a`,{href:o,...s===void 0?{}:{onClick:s},children:[(0,L.jsx)(zx,{"aria-hidden":`true`}),`Retry`]})})})]})})}function kk({open:e,onOpenChange:t,projectName:n,state:r,command:i,unavailableMessage:a,onCopyCommand:o}){let s=r===`loading`?{icon:(0,L.jsx)(zx,{"aria-hidden":`true`}),message:`Reading the connection state from the running Host…`}:r===`pairing_required`?{icon:(0,L.jsx)(Qx,{"aria-hidden":`true`}),message:`In the target Feishu group, send this command once.`}:r===`connected`?{icon:(0,L.jsx)(Rx,{"aria-hidden":`true`}),message:`This project is connected to its Feishu project group.`}:r===`not_recoverable`?{icon:(0,L.jsx)(ax,{"aria-hidden":`true`}),message:`The previous pairing command is no longer available. Stop and Resume this project to issue a new one.`}:r===`account_handoff_required`?{icon:(0,L.jsx)(ax,{"aria-hidden":`true`}),message:`This Host needs a fresh Tutti account handoff. Sign in to Local Console again, then Stop and Resume the project.`}:{icon:(0,L.jsx)(ax,{"aria-hidden":`true`}),message:a??`The Feishu connection state is temporarily unavailable. Try again from Connect.`};return(0,L.jsx)(Nk,{open:e,onOpenChange:t,title:`Feishu connection`,description:`Connect ${n} to a Feishu project group.`,className:`project-local-handoff-dialog-card`,children:(0,L.jsxs)(`div`,{className:`project-local-handoff-dialog-body`,children:[(0,L.jsxs)(`div`,{className:`project-local-handoff-intro`,"aria-live":`polite`,children:[(0,L.jsx)(`span`,{className:`project-local-handoff-icon`,"aria-hidden":`true`,children:s.icon}),(0,L.jsx)(`p`,{children:s.message})]}),r===`pairing_required`&&i!==void 0?(0,L.jsx)(Dk,{command:i,terminalLabel:`Send in the target Feishu group`,copyAriaLabel:`Copy connection command`,commandAriaLabel:`Connection command`,...o===void 0?{}:{onCopyCommand:o}}):null]})})}function Ak({children:e,className:t,...n}){return(0,L.jsx)(`ul`,{className:J(`project-list`,t),"aria-label":`Recent projects`,...n,children:e})}function jk({children:e,className:t,...n}){return(0,L.jsx)(`section`,{className:J(`project-list-surface`,t),...n,children:(0,L.jsx)(Ak,{children:e})})}function Mk({children:e,className:t,...n}){return(0,L.jsx)(`li`,{className:J(`project-list-item project-list-state-row`,t),...n,children:e})}function Nk({open:e,onOpenChange:t,title:n,description:r,headerAction:i,children:a,closeDisabled:o=!1,explicitCloseOnly:s=!1,className:c}){return(0,L.jsxs)(qD,{open:e,onOpenChange:e=>{(e||!o)&&t(e)},children:[(0,L.jsx)($D,{className:`product-entry-dialog-overlay`}),(0,L.jsx)(rO,{asChild:!0,...r===void 0?{"aria-describedby":void 0}:{},onEscapeKeyDown:e=>{(o||s)&&e.preventDefault()},onInteractOutside:e=>{(o||s)&&e.preventDefault()},onPointerDownOutside:e=>{(o||s)&&e.preventDefault()},children:(0,L.jsxs)(hk,{className:J(`product-entry-dialog-card`,c),children:[(0,L.jsxs)(`header`,{className:`product-entry-dialog-header`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(cO,{children:n}),r===void 0?null:(0,L.jsx)(uO,{children:r})]}),(0,L.jsxs)(`div`,{className:`product-entry-dialog-actions`,children:[i,(0,L.jsx)(fO,{asChild:!0,children:(0,L.jsx)(Sw,{type:`button`,label:`Close`,icon:(0,L.jsx)(rS,{"aria-hidden":`true`}),disabled:o})})]})]}),a]})})]})}function Pk({open:e,onOpenChange:t,inputLabel:n,placeholder:r,value:i,error:a,actionLabel:o=`Continue`,onValueChange:s,className:c,...l}){return(0,L.jsx)(Nk,{open:e,onOpenChange:t,title:`Join a project`,description:`Paste an invitation link or the full invitation message.`,className:`project-join-dialog-card`,children:(0,L.jsxs)(`form`,{className:J(`project-join-dialog-form`,c),...l,children:[(0,L.jsxs)(`div`,{className:`project-join-dialog-body`,children:[(0,L.jsx)(jw,{type:`text`,"aria-label":n,value:i,onChange:e=>s(e.target.value),autoFocus:!0,...r===void 0?{}:{placeholder:r}}),a==null?null:(0,L.jsx)(Iw,{children:a})]}),(0,L.jsx)(`footer`,{className:`project-join-dialog-actions`,children:(0,L.jsxs)(Cw,{type:`submit`,disabled:i.trim()===``,children:[o,(0,L.jsx)(Zb,{"aria-hidden":`true`})]})})]})})}function Fk({open:e,onOpenChange:t,steps:n,currentStep:r,children:i,action:a,backAction:o,feedback:s,closeDisabled:c=!1,explicitCloseOnly:l=!1,className:u,...d}){return(0,L.jsxs)(Nk,{open:e,onOpenChange:t,title:`New project`,description:`Step ${r+1} of ${n.length}`,closeDisabled:c,explicitCloseOnly:l,className:`local-console-create-card`,children:[(0,L.jsx)(`ol`,{className:`local-console-create-steps`,"aria-label":`New project steps`,children:n.map((e,t)=>(0,L.jsxs)(`li`,{className:J(t===r?`is-current`:void 0,t<r?`is-complete`:void 0),"aria-current":t===r?`step`:void 0,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:t+1}),(0,L.jsx)(`small`,{children:e})]},e))}),(0,L.jsxs)(`form`,{className:J(`local-console-create-form`,u),...d,children:[(0,L.jsx)(`div`,{className:`local-console-create-body`,children:i}),s===void 0?null:(0,L.jsx)(`div`,{className:`local-console-create-feedback`,children:s}),(0,L.jsxs)(`footer`,{className:`local-console-create-actions`,children:[(0,L.jsx)(`div`,{children:o}),(0,L.jsx)(`div`,{children:a})]})]})]})}function Ik({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`local-console-form-grid`,t),...n,children:e})}function Lk({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`local-console-inline-actions`,t),...n,children:e})}function Rk({title:e,children:t}){return(0,L.jsxs)(`details`,{className:`local-console-field-group product-disclosure`,children:[(0,L.jsx)(`summary`,{children:e}),(0,L.jsx)(`div`,{className:`local-console-field-group-body`,children:t})]})}function zk({title:e,description:t,children:n,className:r,...i}){return(0,L.jsxs)(`section`,{className:J(`local-console-field-group`,r),...i,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsx)(`strong`,{children:e}),t===void 0?null:(0,L.jsx)(`small`,{children:t})]}),(0,L.jsx)(`div`,{className:`local-console-field-group-body`,children:n})]})}function Bk({path:e,className:t,...n}){let r=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),i=r>0&&r<e.length-1;return(0,L.jsx)(`span`,{className:J(`local-console-project-path`,t),title:e,...n,children:i?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`local-console-project-path-prefix`,children:e.slice(0,r)}),(0,L.jsx)(`span`,{className:`local-console-project-path-separator`,children:e[r]}),(0,L.jsx)(`span`,{className:`local-console-project-path-name`,children:e.slice(r+1)})]}):(0,L.jsx)(`span`,{className:`local-console-project-path-name`,children:e})})}function Vk({title:e,status:t,path:n,createdLabel:r,modelLabel:i,surfaceLabel:a,actions:o,className:s,...c}){return(0,L.jsx)(`li`,{className:J(`project-list-item`,`local-console-project-item`,s),...c,children:(0,L.jsxs)(`div`,{className:J(`local-console-project-row`,t===`stopped`?`is-inactive`:`is-active`),children:[(0,L.jsx)($O,{status:t}),(0,L.jsxs)(`span`,{className:`project-list-identity`,children:[(0,L.jsx)(`span`,{className:`local-console-project-title`,children:(0,L.jsx)(`strong`,{children:e})}),i===void 0&&a===void 0?null:(0,L.jsxs)(`span`,{className:`local-console-project-signals`,children:[i===void 0?null:(0,L.jsx)(`small`,{className:`local-console-provider-model`,children:i}),a===void 0?null:(0,L.jsx)(`small`,{className:`local-console-project-surface`,children:a})]})]}),(0,L.jsxs)(`span`,{className:`local-console-project-metadata`,children:[(0,L.jsx)(`strong`,{className:`local-console-project-date`,children:r}),(0,L.jsx)(Bk,{path:n})]}),(0,L.jsx)(`span`,{className:`local-console-project-actions`,children:o})]})})}function Hk(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Uk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Wk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Gk={};function Kk(e,t){return((t||Gk).jsx?Wk:Uk).test(e)}var qk=/[ \t\n\f\r]/g;function Jk(e){return typeof e==`object`?e.type===`text`?Yk(e.value):!1:Yk(e)}function Yk(e){return e.replace(qk,``)===``}var Xk=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Xk.prototype.normal={},Xk.prototype.property={},Xk.prototype.space=void 0;function Zk(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Xk(n,r,t)}function Qk(e){return e.toLowerCase()}var $k=class{constructor(e,t){this.attribute=t,this.property=e}};$k.prototype.attribute=``,$k.prototype.booleanish=!1,$k.prototype.boolean=!1,$k.prototype.commaOrSpaceSeparated=!1,$k.prototype.commaSeparated=!1,$k.prototype.defined=!1,$k.prototype.mustUseProperty=!1,$k.prototype.number=!1,$k.prototype.overloadedBoolean=!1,$k.prototype.property=``,$k.prototype.spaceSeparated=!1,$k.prototype.space=void 0;var eA=s({boolean:()=>nA,booleanish:()=>rA,commaOrSpaceSeparated:()=>sA,commaSeparated:()=>oA,number:()=>X,overloadedBoolean:()=>iA,spaceSeparated:()=>aA}),tA=0,nA=cA(),rA=cA(),iA=cA(),X=cA(),aA=cA(),oA=cA(),sA=cA();function cA(){return 2**++tA}var lA=Object.keys(eA),uA=class extends $k{constructor(e,t,n,r){let i=-1;if(super(e,t),dA(this,`space`,r),typeof n==`number`)for(;++i<lA.length;){let e=lA[i];dA(this,lA[i],(n&eA[e])===eA[e])}}};uA.prototype.defined=!0;function dA(e,t,n){n&&(e[t]=n)}function fA(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new uA(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Qk(r)]=r,n[Qk(a.attribute)]=r}return new Xk(t,n,e.space)}var pA=fA({properties:{ariaActiveDescendant:null,ariaAtomic:rA,ariaAutoComplete:null,ariaBusy:rA,ariaChecked:rA,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:aA,ariaCurrent:null,ariaDescribedBy:aA,ariaDetails:null,ariaDisabled:rA,ariaDropEffect:aA,ariaErrorMessage:null,ariaExpanded:rA,ariaFlowTo:aA,ariaGrabbed:rA,ariaHasPopup:null,ariaHidden:rA,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:aA,ariaLevel:X,ariaLive:null,ariaModal:rA,ariaMultiLine:rA,ariaMultiSelectable:rA,ariaOrientation:null,ariaOwns:aA,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:rA,ariaReadOnly:rA,ariaRelevant:null,ariaRequired:rA,ariaRoleDescription:aA,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:rA,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function mA(e,t){return t in e?e[t]:t}function hA(e,t){return mA(e,t.toLowerCase())}var gA=fA({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:oA,acceptCharset:aA,accessKey:aA,action:null,allow:null,allowFullScreen:nA,allowPaymentRequest:nA,allowUserMedia:nA,alt:null,as:null,async:nA,autoCapitalize:null,autoComplete:aA,autoFocus:nA,autoPlay:nA,blocking:aA,capture:null,charSet:null,checked:nA,cite:null,className:aA,cols:X,colSpan:null,content:null,contentEditable:rA,controls:nA,controlsList:aA,coords:X|oA,crossOrigin:null,data:null,dateTime:null,decoding:null,default:nA,defer:nA,dir:null,dirName:null,disabled:nA,download:iA,draggable:rA,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:nA,formTarget:null,headers:aA,height:X,hidden:iA,high:X,href:null,hrefLang:null,htmlFor:aA,httpEquiv:aA,id:null,imageSizes:null,imageSrcSet:null,inert:nA,inputMode:null,integrity:null,is:null,isMap:nA,itemId:null,itemProp:aA,itemRef:aA,itemScope:nA,itemType:aA,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:nA,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:nA,muted:nA,name:null,nonce:null,noModule:nA,noValidate:nA,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:nA,optimum:X,pattern:null,ping:aA,placeholder:null,playsInline:nA,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:nA,referrerPolicy:null,rel:aA,required:nA,reversed:nA,rows:X,rowSpan:X,sandbox:aA,scope:null,scoped:nA,seamless:nA,selected:nA,shadowRootClonable:nA,shadowRootDelegatesFocus:nA,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:rA,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:nA,useMap:null,value:rA,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:aA,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:nA,declare:nA,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:nA,noHref:nA,noShade:nA,noWrap:nA,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:rA,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:nA,disableRemotePlayback:nA,prefix:null,property:null,results:X,security:null,unselectable:null},space:`html`,transform:hA}),_A=fA({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:sA,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:aA,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:nA,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:oA,g2:oA,glyphName:oA,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:sA,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:aA,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:sA,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:sA,rev:sA,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:sA,requiredFeatures:sA,requiredFonts:sA,requiredFormats:sA,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:sA,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:sA,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:sA,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:mA}),vA=fA({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),yA=fA({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:hA}),bA=fA({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),xA={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},SA=/[A-Z]/g,CA=/-[a-z]/g,wA=/^data[-\w.:]+$/i;function TA(e,t){let n=Qk(t),r=t,i=$k;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&wA.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(CA,DA);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!CA.test(e)){let n=e.replace(SA,EA);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=uA}return new i(r,t)}function EA(e){return`-`+e.toLowerCase()}function DA(e){return e.charAt(1).toUpperCase()}var OA=Zk([pA,gA,vA,yA,bA],`html`),kA=Zk([pA,_A,vA,yA,bA],`svg`);function AA(e){return e.join(` `).trim()}var jA=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
50
50
|
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),MA=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(jA());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),NA=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),PA=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(MA()),r=NA();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),FA=LA(`end`),IA=LA(`start`);function LA(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function RA(e){let t=IA(e),n=FA(e);if(t&&n)return{start:t,end:n}}function zA(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?VA(e.position):`start`in e||`end`in e?VA(e):`line`in e||`column`in e?BA(e):``}function BA(e){return HA(e&&e.line)+`:`+HA(e&&e.column)}function VA(e){return BA(e&&e.start)+`-`+BA(e&&e.end)}function HA(e){return e&&typeof e==`number`?e:1}var UA=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=zA(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};UA.prototype.file=``,UA.prototype.name=``,UA.prototype.reason=``,UA.prototype.message=``,UA.prototype.stack=``,UA.prototype.column=void 0,UA.prototype.line=void 0,UA.prototype.ancestors=void 0,UA.prototype.cause=void 0,UA.prototype.fatal=void 0,UA.prototype.place=void 0,UA.prototype.ruleId=void 0,UA.prototype.source=void 0;var WA=l(PA(),1),GA={}.hasOwnProperty,KA=new Map,qA=/[A-Z]/g,JA=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),YA=new Set([`td`,`th`]),XA=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function ZA(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=cj(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=sj(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?kA:OA,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=QA(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function QA(e,t,n){if(t.type===`element`)return $A(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return ej(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return nj(e,t,n);if(t.type===`mdxjsEsm`)return tj(e,t);if(t.type===`root`)return rj(e,t,n);if(t.type===`text`)return ij(e,t)}function $A(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=kA,e.schema=i),e.ancestors.push(t);let a=mj(e,t.tagName,!1),o=lj(e,t),s=dj(e,t);return JA.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Jk(e):!0})),aj(e,o,a,t),oj(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function ej(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}hj(e,t.position)}function tj(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);hj(e,t.position)}function nj(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=kA,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:mj(e,t.name,!0),o=uj(e,t),s=dj(e,t);return aj(e,o,a,t),oj(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function rj(e,t,n){let r={};return oj(r,dj(e,t)),e.create(t,e.Fragment,r,n)}function ij(e,t){return t.value}function aj(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function oj(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function sj(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function cj(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=IA(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function lj(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&GA.call(t.properties,i)){let a=fj(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&YA.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function uj(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else hj(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else hj(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function dj(e,t){let n=[],r=-1,i=e.passKeys?new Map:KA;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=QA(e,a,o);s!==void 0&&n.push(s)}return n}function fj(e,t,n){let r=TA(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Hk(n):AA(n)),r.property===`style`){let t=typeof n==`object`?n:pj(e,String(n));return e.stylePropertyNameCase===`css`&&(t=gj(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?xA[r.property]||r.property:r.attribute,n]}}function pj(e,t){try{return(0,WA.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new UA("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=XA+`#cannot-parse-style-attribute`,r}}function mj(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=Kk(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=Kk(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return GA.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);hj(e)}function hj(e,t){let n=new UA("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=XA+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function gj(e){let t={},n;for(n in e)GA.call(e,n)&&(t[_j(n)]=e[n]);return t}function _j(e){let t=e.replace(qA,vj);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function vj(e){return`-`+e.toLowerCase()}var yj={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},bj={};function xj(e,t){let n=t||bj;return Sj(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function Sj(e,t,n){if(wj(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return Cj(e.children,t,n)}return Array.isArray(e)?Cj(e,t,n):``}function Cj(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Sj(e[i],t,n);return r.join(``)}function wj(e){return!!(e&&typeof e==`object`)}var Tj=document.createElement(`i`);function Ej(e){let t=`&`+e+`;`;Tj.innerHTML=t;let n=Tj.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Dj(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Oj(e,t){return e.length>0?(Dj(e,e.length,0,t),e):t}var kj={}.hasOwnProperty;function Aj(e){let t={},n=-1;for(;++n<e.length;)jj(t,e[n]);return t}function jj(e,t){let n;for(n in t){let r=(kj.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){kj.call(r,a)||(r[a]=[]);let e=i[a];Mj(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Mj(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Dj(e,0,0,r)}function Nj(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function Pj(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Fj=qj(/[A-Za-z]/),Ij=qj(/[\dA-Za-z]/),Lj=qj(/[#-'*+\--9=?A-Z^-~]/);function Rj(e){return e!==null&&(e<32||e===127)}var zj=qj(/\d/),Bj=qj(/[\dA-Fa-f]/),Vj=qj(/[!-/:-@[-`{-~]/);function Hj(e){return e!==null&&e<-2}function Uj(e){return e!==null&&(e<0||e===32)}function Wj(e){return e===-2||e===-1||e===32}var Gj=qj(/\p{P}|\p{S}/u),Kj=qj(/\s/);function qj(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Jj(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&Ij(e.charCodeAt(n+1))&&Ij(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Yj(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Wj(r)?(e.enter(n),s(r)):t(r)}function s(r){return Wj(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Xj={tokenize:Zj};function Zj(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Yj(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return Hj(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Qj={tokenize:eM},$j={tokenize:tM};function eM(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return Dj(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check($j,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt($j,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return Hj(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;Dj(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function tM(e,t,n){return Yj(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function nM(e){if(e===null||Uj(e)||Kj(e))return 1;if(Gj(e))return 2}function rM(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var iM={name:`attention`,resolveAll:aM,tokenize:oM};function aM(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};sM(d,-c),sM(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Oj(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Oj(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=Oj(l,rM(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Oj(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Oj(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Dj(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function oM(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=nM(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=nM(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function sM(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var cM={name:`autolink`,tokenize:lM};function lM(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return Fj(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||Ij(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||Ij(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||Rj(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Lj(t)?(e.consume(t),l):n(t)}function u(e){return Ij(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||Ij(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var uM={partial:!0,tokenize:dM};function dM(e,t,n){return r;function r(t){return Wj(t)?Yj(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||Hj(e)?t(e):n(e)}}var fM={continuation:{tokenize:mM},exit:hM,name:`blockQuote`,tokenize:pM};function pM(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Wj(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function mM(e,t,n){let r=this;return i;function i(t){return Wj(t)?Yj(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(fM,t,n)(r)}}function hM(e){e.exit(`blockQuote`)}var gM={name:`characterEscape`,tokenize:_M};function _M(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Vj(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var vM={name:`characterReference`,tokenize:yM};function yM(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=Ij,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Bj,u):(e.enter(`characterReferenceValue`),a=7,o=zj,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===Ij&&!Ej(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var bM={partial:!0,tokenize:CM},xM={concrete:!0,name:`codeFenced`,tokenize:SM};function SM(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Wj(t)?Yj(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||Hj(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(bM,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||Hj(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Wj(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Yj(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||Hj(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||Hj(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Wj(t)?Yj(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||Hj(t)?e.check(bM,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||Hj(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Wj(t)?Yj(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Wj(t)?Yj(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||Hj(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function CM(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var wM={name:`codeIndented`,tokenize:EM},TM={partial:!0,tokenize:DM};function EM(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Yj(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):Hj(t)?e.attempt(TM,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||Hj(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function DM(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):Hj(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Yj(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):Hj(e)?i(e):n(e)}}var OM={name:`codeText`,previous:AM,resolve:kM,tokenize:jM};function kM(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function AM(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function jM(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):Hj(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||Hj(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var MM=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&NM(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),NM(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),NM(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);NM(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);NM(this.left,t.reverse())}}};function NM(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function PM(e){let t={},n=-1,r,i,a,o,s,c,l,u=new MM(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,FM(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return Dj(e,0,1/0,u.slice(0)),!l}function FM(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var IM={resolve:RM,tokenize:zM},LM={partial:!0,tokenize:BM};function RM(e){return PM(e),e}function zM(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):Hj(t)?e.check(LM,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function BM(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Yj(e,a,`linePrefix`)}function a(i){if(i===null||Hj(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function VM(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||Rj(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||Hj(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Uj(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||Rj(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function HM(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):Hj(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||Hj(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Wj(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function UM(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):Hj(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Yj(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||Hj(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function WM(e,t){let n;return r;function r(i){return Hj(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Wj(i)?Yj(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var GM={name:`definition`,tokenize:qM},KM={partial:!0,tokenize:JM};function qM(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return HM.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Pj(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Uj(t)?WM(e,l)(t):l(t)}function l(t){return VM(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(KM,d,d)(t)}function d(t){return Wj(t)?Yj(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||Hj(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function JM(e,t,n){return r;function r(t){return Uj(t)?WM(e,i)(t):n(t)}function i(t){return UM(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Wj(t)?Yj(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||Hj(e)?t(e):n(e)}}var YM={name:`hardBreakEscape`,tokenize:XM};function XM(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return Hj(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var ZM={name:`headingAtx`,resolve:QM,tokenize:$M};function QM(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},Dj(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function $M(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Uj(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||Hj(n)?(e.exit(`atxHeading`),t(n)):Wj(n)?Yj(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Uj(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var eN=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),tN=[`pre`,`script`,`style`,`textarea`],nN={concrete:!0,name:`htmlFlow`,resolveTo:aN,tokenize:oN},rN={partial:!0,tokenize:cN},iN={partial:!0,tokenize:sN};function aN(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function oN(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:P):Fj(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):Fj(a)?(e.consume(a),i=4,r.interrupt?t:P):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:P):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return Fj(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Uj(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&tN.includes(l)?(i=1,r.interrupt?t(s):O(s)):eN.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||Ij(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Wj(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||Fj(t)?(e.consume(t),b):Wj(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||Ij(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Wj(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Wj(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||Hj(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Uj(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Wj(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||Hj(t)?O(t):Wj(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),ee):t===60&&i===1?(e.consume(t),M):t===62&&i===4?(e.consume(t),F):t===63&&i===3?(e.consume(t),P):t===93&&i===5?(e.consume(t),N):Hj(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(rN,ne,k)(t)):t===null||Hj(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(iN,A,ne)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||Hj(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function ee(t){return t===45?(e.consume(t),P):O(t)}function M(t){return t===47?(e.consume(t),o=``,te):O(t)}function te(t){if(t===62){let n=o.toLowerCase();return tN.includes(n)?(e.consume(t),F):O(t)}return Fj(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),te):O(t)}function N(t){return t===93?(e.consume(t),P):O(t)}function P(t){return t===62?(e.consume(t),F):t===45&&i===2?(e.consume(t),P):O(t)}function F(t){return t===null||Hj(t)?(e.exit(`htmlFlowData`),ne(t)):(e.consume(t),F)}function ne(n){return e.exit(`htmlFlow`),t(n)}}function sN(e,t,n){let r=this;return i;function i(t){return Hj(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function cN(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(uM,t,n)}}var lN={name:`htmlText`,tokenize:uN};function uN(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):Fj(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):Fj(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):Hj(t)?(o=d,M(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ee(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):Hj(t)?(o=h,M(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ee(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ee(t):Hj(t)?(o=v,M(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):Hj(t)?(o=y,M(t)):(e.consume(t),y)}function b(e){return e===62?ee(e):y(e)}function x(t){return Fj(t)?(e.consume(t),S):n(t)}function S(t){return t===45||Ij(t)?(e.consume(t),S):C(t)}function C(t){return Hj(t)?(o=C,M(t)):Wj(t)?(e.consume(t),C):ee(t)}function w(t){return t===45||Ij(t)?(e.consume(t),w):t===47||t===62||Uj(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ee):t===58||t===95||Fj(t)?(e.consume(t),E):Hj(t)?(o=T,M(t)):Wj(t)?(e.consume(t),T):ee(t)}function E(t){return t===45||t===46||t===58||t===95||Ij(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):Hj(t)?(o=D,M(t)):Wj(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):Hj(t)?(o=O,M(t)):Wj(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):Hj(t)?(o=k,M(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Uj(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||Uj(e)?T(e):n(e)}function ee(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function M(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return Wj(t)?Yj(e,N,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):N(t)}function N(t){return e.enter(`htmlTextData`),o(t)}}var dN={name:`labelEnd`,resolveAll:hN,resolveTo:gN,tokenize:_N},fN={tokenize:vN},pN={tokenize:yN},mN={tokenize:bN};function hN(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&Dj(e,0,e.length,n),e}function gN(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=Oj(s,e.slice(a+1,a+r+3)),s=Oj(s,[[`enter`,u,t]]),s=Oj(s,rM(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Oj(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=Oj(s,e.slice(o+1)),s=Oj(s,[[`exit`,c,t]]),Dj(e,a,e.length,s),e}function _N(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(Pj(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(fN,u,o?u:d)(t):t===91?e.attempt(pN,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(mN,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function vN(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Uj(t)?WM(e,a)(t):a(t)}function a(t){return t===41?u(t):VM(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Uj(t)?WM(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?UM(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Uj(t)?WM(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function yN(e,t,n){let r=this;return i;function i(t){return HM.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Pj(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function bN(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var xN={name:`labelStartImage`,resolveAll:dN.resolveAll,tokenize:SN};function SN(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var CN={name:`labelStartLink`,resolveAll:dN.resolveAll,tokenize:wN};function wN(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var TN={name:`lineEnding`,tokenize:EN};function EN(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Yj(e,t,`linePrefix`)}}var DN={name:`thematicBreak`,tokenize:ON};function ON(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||Hj(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Wj(t)?Yj(e,s,`whitespace`)(t):s(t))}}var kN={continuation:{tokenize:NN},exit:FN,name:`list`,tokenize:MN},AN={partial:!0,tokenize:IN},jN={partial:!0,tokenize:PN};function MN(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:zj(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(DN,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return zj(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(uM,r.interrupt?n:u,e.attempt(AN,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Wj(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function NN(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(uM,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Yj(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Wj(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(jN,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Yj(e,e.attempt(kN,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function PN(e,t,n){let r=this;return Yj(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function FN(e){e.exit(this.containerState.type)}function IN(e,t,n){let r=this;return Yj(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Wj(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var LN={name:`setextUnderline`,resolveTo:RN,tokenize:zN};function RN(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function zN(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Wj(t)?Yj(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||Hj(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var BN={tokenize:VN};function VN(e){let t=this,n=e.attempt(uM,r,e.attempt(this.parser.constructs.flowInitial,i,Yj(e,e.attempt(this.parser.constructs.flow,i,e.attempt(IM,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var HN={resolveAll:KN()},UN=GN(`string`),WN=GN(`text`);function GN(e){return{resolveAll:KN(e===`text`?qN:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function KN(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function qN(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var JN=s({attentionMarkers:()=>nP,contentInitial:()=>XN,disable:()=>rP,document:()=>YN,flow:()=>QN,flowInitial:()=>ZN,insideSpan:()=>tP,string:()=>$N,text:()=>eP}),YN={42:kN,43:kN,45:kN,48:kN,49:kN,50:kN,51:kN,52:kN,53:kN,54:kN,55:kN,56:kN,57:kN,62:fM},XN={91:GM},ZN={[-2]:wM,[-1]:wM,32:wM},QN={35:ZM,42:DN,45:[LN,DN],60:nN,61:LN,95:DN,96:xM,126:xM},$N={38:vM,92:gM},eP={[-5]:TN,[-4]:TN,[-3]:TN,33:xN,38:vM,42:iM,60:[cM,lN],91:CN,92:[YM,gM],93:dN,95:iM,96:OM},tP={null:[iM,HN]},nP={null:[42,95]},rP={null:[]};function iP(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=Oj(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=rM(a,l.events,l),l.events):[]}function f(e,t){return oP(p(e),t)}function p(e){return aP(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){Hj(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Dj(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function aP(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function oP(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
51
51
|
`;break;case-3:o=`\r
|
|
52
52
|
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function sP(e){let t={constructs:Aj([JN,...(e||{}).extensions||[]]),content:n(Xj),defined:[],document:n(Qj),flow:n(BN),lazy:{},string:n(UN),text:n(WN)};return t;function n(e){return n;function n(n){return iP(t,e,n)}}}function cP(e){for(;!PM(e););return e}var lP=/[\0\t\n\r]/g;function uP(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(lP.lastIndex=u,c=lP.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var dP=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function fP(e){return e.replace(dP,pP)}function pP(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return Nj(n.slice(t?2:1),t?16:10)}return Ej(n)||e}var mP={}.hasOwnProperty;function hP(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),gP(n)(cP(sP(n).document().write(uP()(e,t,!0))))}function gP(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ye),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(he),blockQuote:a(ue),characterEscape:T,characterReference:T,codeFenced:a(de),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(de,o),codeText:a(fe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(pe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(me),hardBreakEscape:a(ge),hardBreakTrailing:a(ge),htmlFlow:a(_e,o),htmlFlowData:T,htmlText:a(_e,o),htmlTextData:T,image:a(ve),label:o,link:a(ye),listItem:a(xe),listItemValue:f,listOrdered:a(be,d),listUnordered:a(be),paragraph:a(Se),reference:re,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(he),strong:a(Ce),thematicBreak:a(Te)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:le,autolinkProtocol:ce,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:oe,characterReference:se,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(M),label:N,labelText:te,lineEnding:D,link:c(ee),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ie,resourceDestinationString:P,resourceTitleString:F,resource:ne,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};vP(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];mP.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||bP).call(a,void 0,e[0])}for(r.position={start:_P(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:_P(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:_P(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||bP).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+zA({start:e.start,end:e.end})+`): it’s not open`);n.position.end=_P(e.end)}function u(){return xj(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Pj(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=we(),n.position={start:_P(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=_P(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=_P(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function te(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=fP(t),n.identifier=Pj(t).toLowerCase()}function N(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function P(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function F(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ne(){this.data.inReference=void 0}function re(){this.data.referenceType=`collapsed`}function ie(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Pj(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ae(e){this.data.characterReferenceType=e.type}function oe(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=Nj(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=Ej(t);let i=this.stack[this.stack.length-1];i.value+=r}function se(e){let t=this.stack.pop();t.position.end=_P(e.end)}function ce(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function le(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ue(){return{type:`blockquote`,children:[]}}function de(){return{type:`code`,lang:null,meta:null,value:``}}function fe(){return{type:`inlineCode`,value:``}}function pe(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function me(){return{type:`emphasis`,children:[]}}function he(){return{type:`heading`,depth:0,children:[]}}function ge(){return{type:`break`}}function _e(){return{type:`html`,value:``}}function ve(){return{type:`image`,title:null,url:``,alt:null}}function ye(){return{type:`link`,title:null,url:``,children:[]}}function be(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function xe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Se(){return{type:`paragraph`,children:[]}}function Ce(){return{type:`strong`,children:[]}}function we(){return{type:`text`,value:``}}function Te(){return{type:`thematicBreak`}}}function _P(e){return{line:e.line,column:e.column,offset:e.offset}}function vP(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?vP(e,r):yP(e,r)}}function yP(e,t){let n;for(n in t)if(mP.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function bP(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+zA({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+zA({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+zA({start:t.start,end:t.end})+`) is still open`)}function xP(e){let t=this;t.parser=n;function n(n){return hP(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function SP(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function CP(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
@@ -66,5 +66,5 @@ Error generating stack: `+e.message+`
|
|
|
66
66
|
`)||n!==t.length-1)return null;let r=e.slice(0,-1);if(!t.startsWith(r))return null;let i=t.slice(r.length,-1);return i===``?null:{nextValue:`${e}${i}`,nextCaret:e.length+i.length}},fe=(e,t,n,r=!1)=>{let i=b.current;if(i===null)return{nextValue:e,nextCaret:t};let a=n??i.finalData;return a!==void 0&&(b.current={...i,finalData:a}),a!==void 0&&a!==``&&e.slice(i.start,i.start+i.data.length)===i.data&&e.slice(i.start+i.data.length,i.start+i.data.length+a.length)===a?(b.current=null,{nextValue:`${e.slice(0,i.start)}${e.slice(i.start+i.data.length)}`,nextCaret:Math.max(i.start,t-i.data.length)}):a!==void 0&&a!==``&&e.slice(i.start,i.start+a.length)===a?(b.current=null,{nextValue:e,nextCaret:t}):(r&&a!==void 0&&(b.current=null),{nextValue:e,nextCaret:t})},pe=()=>{let t=h.current,n=t===null||!ne(t)?T:ie(t).end;if(RI(e,n)!==null){w(!0),E(n),O(0),oe(n);return}let r=n===0?``:e[n-1]??``,i=r!==``&&FI.test(r)?` @`:`@`,a=`${e.slice(0,n)}${i}${e.slice(n)}`,o=n+i.length;w(!0),E(o),O(0),ce(a,o)};(0,I.useEffect)(()=>{i===void 0||g.current===i||(g.current=i,pe())},[i]),(0,I.useEffect)(()=>{O(0)},[A?.start,A?.query]),(0,I.useLayoutEffect)(()=>{let t=h.current;if(t===null)return;let n=zI(e,A),r=HI(n);if(!v.current){let i=F(t)!==e,a=t.querySelector(`[data-mention-value]`)!==null,o=(UI(n)||a)&&x.current!==r;(i||o)&&WI(t,n),x.current=r,e===``&&(y.current=null,b.current=null)}_.current!==null&&(ae(t,_.current),_.current=null)},[A,e]);let me=({clearCompositionSeedOnMiss:e=!1,compositionData:t}={})=>{let n=h.current;if(n===null)return;let r=fe(F(n),ie(n).end,t,e);ce(r.nextValue,r.nextCaret)},he=n=>{if(v.current||GI(n)){f?.(n);return}if(ee){if(n.key===`ArrowDown`){n.preventDefault(),O(e=>(e+1)%j.length);return}if(n.key===`ArrowUp`){n.preventDefault(),O(e=>(e-1+j.length)%j.length);return}if(n.key===`Enter`&&!n.shiftKey&&!n.metaKey||n.key===`Tab`){let e=j[M];if(e===void 0)return;n.preventDefault(),se(e);return}}let i=h.current;if(i!==null&&(n.key===`Backspace`||n.key===`Delete`)){let t=ie(i);if(t.start!==t.end){n.preventDefault(),y.current=null,b.current=null,ce(`${e.slice(0,t.start)}${e.slice(t.end)}`,t.start);return}if(n.key===`Backspace`&&t.start>0&&e[t.start-1]===`
|
|
67
67
|
`){n.preventDefault(),y.current=null,b.current=null,ce(`${e.slice(0,t.start-1)}${e.slice(t.start)}`,t.start-1);return}if(n.key===`Delete`&&e[t.start]===`
|
|
68
68
|
`){n.preventDefault(),y.current=null,b.current=null,ce(`${e.slice(0,t.start)}${e.slice(t.start+1)}`,t.start);return}let r=BI(e).find(r=>n.key===`Backspace`?t.start>r.start&&t.start<=r.end||t.start===r.end+1&&e[r.end]===` `:t.start>=r.start&&t.start<r.end);if(r!==void 0){n.preventDefault(),y.current=null,b.current=null;let i=n.key===`Backspace`&&t.start===r.end+1&&e[r.end]===` `?r.end+1:r.end;ce(`${e.slice(0,r.start)}${e.slice(i)}`,r.start);return}if(n.key===`Backspace`&&t.start>0){n.preventDefault(),y.current=null,b.current=null,ce(`${e.slice(0,t.start-1)}${e.slice(t.start)}`,t.start-1);return}if(n.key===`Delete`&&t.start<e.length){n.preventDefault(),y.current=null,b.current=null,ce(`${e.slice(0,t.start)}${e.slice(t.start+1)}`,t.start);return}}if(t&&n.key===`Enter`){if(n.preventDefault(),r&&!n.shiftKey&&!n.metaKey){i?.closest(`form`)?.requestSubmit();return}ue();return}if(!t&&n.key===`Enter`){n.preventDefault(),i?.closest(`form`)?.requestSubmit();return}f?.(n)},ge=t=>{if(v.current||GI(t))return;let n=h.current;if(n===null)return;let r=F(n),i=ie(n).end,a=de(r,i),o=a?.nextValue??r,s=a?.nextCaret??i,c=KI(t);if(c.inputType===`insertText`&&qI(c.data)){let t=s-c.data.length,n=`${o.slice(0,t)}${o.slice(s)}`;y.current=t>=0&&n===e?{data:c.data,start:t,end:s,valueBefore:n,createdAt:Date.now()}:null}else y.current=null;let l=fe(o,s,void 0,!0);ce(l.nextValue,l.nextCaret)},_e=e=>{if(v.current||GI(e))return;let t=KI(e);if(t.inputType===`insertParagraph`||t.inputType===`insertLineBreak`){ue()&&e.preventDefault();return}y.current=null},ve=t=>{t.preventDefault();let n=t.clipboardData.getData(`text/plain`),r=h.current;if(r===null)return;let i=ie(r);ce(`${e.slice(0,i.start)}${n}${e.slice(i.end)}`,i.start+n.length)},ye=()=>{let e=h.current;e===null||!ne(e)||E(ie(e).end)},be=J(`mention-input-editor`,t?`is-multiline`:`is-singleline`,c),xe=ee?(0,L.jsx)(`div`,{className:`mention-menu`,id:S,role:`listbox`,"aria-label":`Mention people`,children:j.map((e,t)=>(0,L.jsx)(`button`,{className:J(`mention-option`,t===M?`is-selected`:void 0),type:`button`,role:`option`,id:`${S}-option-${t}`,"aria-selected":t===M,onMouseEnter:()=>O(t),onMouseDown:t=>{t.preventDefault(),se(e)},children:(0,L.jsxs)(`span`,{className:`mention-option-text`,children:[`@`,e.handle]})},e.id))}):null,Se=a?.current;return(0,L.jsxs)(`span`,{className:J(`mention-input`,t?`is-multiline`:void 0),children:[(0,L.jsx)(`div`,{className:be,contentEditable:!N,role:`textbox`,"aria-label":P,"aria-multiline":t,"aria-disabled":N,"aria-expanded":ee,...ee?{"aria-controls":S}:{},...te===void 0?{}:{"aria-activedescendant":te},"data-placeholder":m.placeholder,"data-max-rows":n,onBlur:e=>{w(!1),l?.(e)},onClick:e=>{ye(),u?.(e)},onFocus:e=>{w(!0),ye(),d?.(e)},onCompositionStart:()=>{v.current=!0;let e=h.current,t=y.current;if(y.current=null,e!==null&&t!==null&&Date.now()-t.createdAt<500&&F(e).slice(t.start,t.end)===t.data){b.current=t,_.current=null,E(t.start),s(t.valueBefore);let n=zI(t.valueBefore,null);WI(e,n),x.current=HI(n),ae(e,t.start)}else b.current=null},onCompositionEnd:e=>{v.current=!1;let t=KI(e);me(t.data===null?{}:{compositionData:t.data})},onBeforeInput:_e,onInput:ge,onKeyDown:he,onKeyUp:e=>{!v.current&&!GI(e)&&ye(),p?.(e)},onPaste:ve,ref:h,suppressContentEditableWarning:!0}),Se==null?xe:(0,iS.createPortal)(xe,Se)]})}function ZI(e){return(0,L.jsx)(Ox,{...e})}function QI({avatar:e,author:t,time:n,requestStatus:r,children:i,system:a=!1,className:o,...s}){return(0,L.jsxs)(`article`,{className:J(`message`,a?`is-system`:void 0,o),...s,children:[(0,L.jsxs)(`div`,{className:`message-byline`,children:[e,(0,L.jsxs)(`div`,{className:`message-meta`,children:[(0,L.jsx)(`span`,{className:`message-author`,children:t}),n===void 0?null:(0,L.jsx)(`span`,{className:`message-time`,children:n}),r===void 0?null:(0,L.jsx)(`span`,{className:`message-time message-request-status`,role:`status`,children:r})]})]}),(0,L.jsx)(`div`,{className:`message-content`,children:(0,L.jsx)(`div`,{className:`message-card`,children:i})})]})}function $I({children:e,className:t,...n}){return(0,L.jsx)(`div`,{className:J(`message-markdown`,t),...n,children:(0,L.jsx)(wI,{components:uL,children:e})})}function eL({children:e}){return(0,L.jsx)(`p`,{children:JI(e)})}function tL({children:e}){return(0,L.jsx)(`li`,{children:JI(e)})}function nL({children:e}){return(0,L.jsx)(`strong`,{children:JI(e)})}function rL({children:e}){return(0,L.jsx)(`em`,{children:JI(e)})}function iL({children:e}){return(0,L.jsx)(`h1`,{children:JI(e)})}function aL({children:e}){return(0,L.jsx)(`h2`,{children:JI(e)})}function oL({children:e}){return(0,L.jsx)(`h3`,{children:JI(e)})}function sL({children:e}){return(0,L.jsx)(`h4`,{children:JI(e)})}function cL({children:e}){return(0,L.jsx)(`h5`,{children:JI(e)})}function lL({children:e}){return(0,L.jsx)(`h6`,{children:JI(e)})}var uL={p:eL,li:tL,strong:nL,em:rL,h1:iL,h2:aL,h3:oL,h4:sL,h5:cL,h6:lL};function dL({name:e,category:t,imageUrl:n,className:r,"aria-label":i,...a}){let o=t===`image`&&n!==void 0;return(0,L.jsx)(`button`,{type:`button`,"aria-label":i??`Open ${t===`image`?`image`:`file`} ${e}`,className:J(`reference-message-card`,t===`image`?`is-image`:`is-file`,r),...a,children:o?(0,L.jsx)(`img`,{className:`reference-message-image`,src:n,alt:e,loading:`lazy`,decoding:`async`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`reference-message-icon`,"aria-hidden":`true`,children:t===`image`?(0,L.jsx)(vx,{}):(0,L.jsx)(hx,{})}),(0,L.jsx)(`span`,{className:`reference-message-main`,children:(0,L.jsx)(`strong`,{children:e})})]})})}function fL({children:e,composer:t,empty:n,title:r=`Chat`,subtitle:i,actions:a,streamRef:o,streamOverlay:s,onStreamScroll:c,dropUploadPending:l=!1,onDropFiles:u,className:d,...f}){return(0,L.jsxs)(jI,{className:J(`panel chat-panel chat-primary`,d),"aria-label":`Group chat`,dropLabel:`Drop references to upload`,pending:l,onFilesUpload:u,...f,children:[(0,L.jsxs)(`div`,{className:`panel-header`,children:[(0,L.jsxs)(`div`,{className:`panel-title`,children:[(0,L.jsx)(hS,{icon:(0,L.jsx)(ZI,{"aria-hidden":`true`})}),(0,L.jsxs)(`div`,{className:`panel-title-copy`,children:[(0,L.jsx)(`h3`,{children:r}),i===void 0?null:(0,L.jsx)(`div`,{className:`panel-subtitle`,children:i})]})]}),a===void 0?null:(0,L.jsx)(`div`,{className:`panel-actions`,children:a})]}),(0,L.jsxs)(`div`,{className:`chat-stream-frame`,children:[(0,L.jsx)(`div`,{className:`chat-stream`,ref:o,onScroll:c,children:e??n}),s===void 0?null:(0,L.jsx)(`div`,{className:`chat-stream-overlay`,children:s})]}),t]})}function pL({value:e,placeholder:t,ariaLabel:n,maxLength:r,saving:i=!1,disabled:a=!1,allowEmpty:o=!1,onUpdate:s,className:c,...l}){let u=(0,I.useRef)(null),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(e),[h,g]=(0,I.useState)(!1),_=i||h,v=!a&&!_&&s!==void 0,y=e.trim(),b=y.length===0;(0,I.useEffect)(()=>{d||m(e)},[d,e]),(0,I.useEffect)(()=>{d&&(u.current?.focus(),u.current?.select())},[d]);let x=()=>{m(e),f(!1)},S=()=>{let e=p.trim();if(!o&&e.length===0){x();return}if(e===y){f(!1);return}s===void 0||_||(g(!0),Promise.resolve(s(e)).then(()=>{f(!1)}).catch(()=>void 0).finally(()=>{g(!1)}))},C=e=>{if(e.key===`Enter`){e.preventDefault(),S();return}e.key===`Escape`&&(e.preventDefault(),x())};return(0,L.jsx)(`span`,{className:J(`inline-editable-text`,b?`is-empty`:void 0,d?`is-editing`:void 0,v?void 0:`is-disabled`,c),...l,children:d?(0,L.jsx)(`input`,{ref:u,className:`inline-editable-text-input`,"aria-label":n,value:p,maxLength:r,disabled:_,onBlur:S,onChange:e=>m(e.currentTarget.value),onKeyDown:C}):(0,L.jsx)(`button`,{className:`inline-editable-text-button`,type:`button`,"aria-label":n,disabled:!v,onClick:()=>f(!0),children:b?t:y})})}var mL={bare:``,quiet:`quiet-button`,pill:`pill-action`,action:`action-button`};function hL({variant:e=`pill`,label:t,pendingLabel:n=t,pending:r=!1,disabled:i=!1,iconOnly:a=!1,accept:o,icon:s,onFileUpload:c,className:l,...u}){let d=i||r||c===void 0,f=r?n:t,p=e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t!==void 0&&c?.(t)};return(0,L.jsxs)(`label`,{...u,className:J(mL[e],d?`is-disabled`:void 0,l),"aria-disabled":d,"aria-busy":r,"aria-label":u[`aria-label`]??f,title:u.title??f,children:[(0,L.jsx)(`input`,{type:`file`,accept:o,disabled:d,onChange:p}),s??(r?(0,L.jsx)(Cx,{className:`is-spinning`,"aria-hidden":`true`}):(0,L.jsx)(lx,{"aria-hidden":`true`})),a?null:(0,L.jsx)(`span`,{children:f})]})}function gL({value:e,pending:t=!1,uploadPending:n=!1,placeholder:r=`Write a message`,mentionOptions:i,onValueChange:a,onComposerSubmit:o,onFileUpload:s,className:c,...l}){let[u,d]=(0,I.useState)(0),f=(0,I.useRef)(null);return(0,L.jsx)(`form`,{className:J(`composer`,c),"aria-label":`Message composer`,onSubmit:o,...l,children:(0,L.jsxs)(`div`,{className:`composer-input-shell`,ref:f,children:[(0,L.jsx)(XI,{"aria-label":`Message`,placeholder:r,value:e,multiline:!0,maxRows:8,submitOnEnter:!0,mentionRequestKey:u,menuPortalTargetRef:f,...i===void 0?{}:{mentionOptions:i},onValueChange:a}),(0,L.jsxs)(`div`,{className:`composer-tools`,"aria-label":`Message tools`,children:[(0,L.jsx)(`button`,{className:`composer-tool-button composer-mention-button`,type:`button`,"aria-label":`Mention people`,title:`Mention people`,onClick:()=>d(e=>e+1),children:(0,L.jsx)(Qb,{"aria-hidden":`true`})}),(0,L.jsx)(hL,{variant:`bare`,className:`composer-tool-button composer-upload-button`,label:`Upload image`,pendingLabel:`Uploading image`,pending:n,accept:`image/*`,icon:(0,L.jsx)(vx,{"aria-hidden":`true`}),iconOnly:!0,onFileUpload:s}),(0,L.jsx)(hL,{variant:`bare`,className:`composer-tool-button composer-upload-button`,label:`Upload file`,pendingLabel:`Uploading file`,pending:n,icon:(0,L.jsx)(hx,{"aria-hidden":`true`}),iconOnly:!0,onFileUpload:s}),(0,L.jsx)(`button`,{className:`composer-tool-button composer-send-button`,type:`submit`,disabled:e.trim()===``||t,"aria-label":t?`Sending message`:`Send message`,title:t?`Sending message`:`Send message`,children:(0,L.jsx)(Wx,{"aria-hidden":`true`})})]})]})})}function _L(e){return(0,L.jsx)(Mx,{...e})}var vL={confirmed:(0,L.jsx)(tx,{"aria-hidden":`true`}),question:(0,L.jsx)(ax,{"aria-hidden":`true`}),"task-change":(0,L.jsx)(Yx,{"aria-hidden":`true`})};function yL({kind:e,children:t,className:n,...r}){return(0,L.jsxs)(`div`,{className:J(`scratchpad-row`,`is-${e}`,n),...r,children:[(0,L.jsx)(`span`,{className:`scratchpad-marker`,"aria-hidden":`true`,children:vL[e]}),(0,L.jsx)(`p`,{children:t})]})}function bL({compiledTasks:e=[],onOpenCompiledTask:t}){return(0,L.jsxs)(`section`,{className:`scratchpad-submitted-receipt`,"aria-label":`Submitted to Worklist`,children:[(0,L.jsxs)(`div`,{className:`scratchpad-submitted-receipt-header`,children:[(0,L.jsx)(`strong`,{children:`Submitted to Worklist`}),(0,L.jsx)(tx,{className:`scratchpad-submitted-receipt-check`,"aria-hidden":`true`})]}),e.length===0?(0,L.jsxs)(`div`,{className:`scratchpad-submitted-empty`,role:`status`,children:[(0,L.jsx)(Yx,{"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`scratchpad-submitted-empty-copy`,children:[(0,L.jsx)(`span`,{children:`No new task created`}),(0,L.jsx)(`small`,{children:`This Scratchpad was submitted, but no Worklist task was added.`})]})]}):(0,L.jsx)(`div`,{className:`scratchpad-submitted-task-list`,children:e.map(e=>(0,L.jsxs)(`button`,{className:`scratchpad-submitted-task`,disabled:t===void 0,onClick:()=>t?.(e.taskId),type:`button`,children:[(0,L.jsxs)(`span`,{className:`scratchpad-submitted-task-copy`,children:[(0,L.jsx)(`span`,{children:e.title}),(0,L.jsx)(`small`,{children:e.moduleName})]}),(0,L.jsx)(rx,{"aria-hidden":`true`})]},e.taskId))})]})}function xL({title:e,summary:t,sections:n,updatedLabel:r,updatedLabelPrefix:i=`Updated`,footerNote:a,submitAvailable:o,pages:s,empty:c,actionsDisabled:l=!1,showSubmitAction:u=!0,compact:d=!1,presentation:f=`panel`,syncPending:p=!1,submitPending:m=!1,onSubmitScratchpad:h,onOpenCompiledTask:g,className:_,...v}){let y=s!==void 0&&s.length>0,b=(0,I.useMemo)(()=>s!==void 0&&s.length>0?s:[{key:`current`,title:e,summary:t,sections:n,...r===void 0?{}:{updatedLabel:r},updatedLabelPrefix:i,...a===void 0?{}:{footerNote:a},...o===void 0?{}:{submitAvailable:o}}],[a,s,n,o,t,e,r,i]),x=Math.max(0,b.length-1),S=b[x]?.key,[C,w]=(0,I.useState)(x);(0,I.useEffect)(()=>{w(x)},[x,S]);let T=Math.min(C,Math.max(0,b.length-1)),E=b[T]??{key:`current`,title:e,summary:t,sections:n,...r===void 0?{}:{updatedLabel:r},updatedLabelPrefix:i,...a===void 0?{}:{footerNote:a},...o===void 0?{}:{submitAvailable:o}},D=p||m,O=m?`Running`:p?`Refreshing`:`Run`,k=E.submitAvailable??E.sections.length>0,A=l||D||!k||E.submitted===!0;return(0,L.jsx)(mS,{title:`Scratchpad`,frameless:f===`document`,icon:(0,L.jsx)(_L,{"aria-hidden":`true`}),className:J(`scratchpad-panel`,d?`is-compact`:void 0,f===`document`?`is-document`:void 0,_),"aria-busy":D,...v,children:(0,L.jsxs)(`div`,{className:`scratchpad-panel-body scratchpad`,children:[!y&&E.sections.length===0?c??(0,L.jsx)(`div`,{}):(0,L.jsxs)(`div`,{className:J(`scratchpad-content`,E.submitted===!0?`is-submitted`:void 0),children:[(0,L.jsx)(`div`,{className:`scratchpad-head`,children:(0,L.jsx)(`div`,{children:(0,L.jsx)(`h4`,{children:E.title})})}),(0,L.jsx)(`p`,{className:`scratchpad-summary`,children:E.summary}),E.sections.map(e=>(0,L.jsxs)(`section`,{className:`scratchpad-section`,"aria-labelledby":e.id,children:[(0,L.jsx)(`span`,{className:`scratchpad-label`,id:e.id,children:e.label}),(0,L.jsx)(`div`,{className:`scratchpad-list`,children:e.rows.map(t=>(0,L.jsx)(yL,{kind:t.kind,children:t.text},`${e.id}:${t.text}`))})]},e.id)),E.submitted===!0?(0,L.jsx)(bL,{compiledTasks:E.compiledTasks??[],...g===void 0?{}:{onOpenCompiledTask:g}}):null]},E.key),!d&&b.length>1?(0,L.jsx)(`div`,{className:`scratchpad-history-nav`,children:(0,L.jsx)(pS,{"aria-label":`Scratchpad history`,currentPage:T,maxVisible:7,pageAriaLabel:e=>`Scratchpad page ${e+1}`,pageCount:b.length,onPageChange:w})}):null,(0,L.jsxs)(`div`,{className:`scratchpad-footer`,children:[E.footerNote===void 0?null:(0,L.jsx)(`p`,{className:J(`scratchpad-footer-note`,E.footerNote.tone===`error`?`is-error`:void 0),title:E.footerNote.text,children:E.footerNote.text}),d?null:(0,L.jsx)(`div`,{className:`scratchpad-submit-context`,children:E.updatedLabel===void 0?null:(0,L.jsxs)(`span`,{className:`scratchpad-updated-at`,children:[(0,L.jsx)(`span`,{children:E.updatedLabelPrefix??`Updated`}),(0,L.jsx)(`span`,{children:E.updatedLabel})]})}),u?(0,L.jsx)(`div`,{className:`scratchpad-footer-actions`,children:(0,L.jsxs)(Cw,{className:J(`scratchpad-submit-button`,D?`is-pending`:void 0),type:`button`,"aria-busy":D,disabled:A,onClick:h,children:[D?(0,L.jsx)(Cx,{"aria-hidden":`true`}):(0,L.jsx)(Nx,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:O})]})}):null]})]})})}function SL(e){return e===`done`?(0,L.jsx)(tx,{"aria-hidden":`true`}):e===`failed`?(0,L.jsx)(ox,{"aria-hidden":`true`}):e===`pending`?(0,L.jsx)(eS,{"aria-hidden":`true`}):e===`running`?(0,L.jsx)(Cx,{"aria-hidden":`true`}):(0,L.jsx)(sx,{"aria-hidden":`true`})}function CL(e){return e===`complete`?`Complete`:e===`failed`?`Failed`:e===`pending`?`Needs input`:`Running`}function wL(e){return(0,L.jsx)(nS,{"aria-hidden":`true`,"data-tone":e})}function TL({title:e,summary:t,tone:n,steps:r,metaLabel:i,className:a,...o}){let s=i??CL(n),c=o[`aria-label`]??`${e}. ${s}. ${t}`;return(0,L.jsx)(mS,{title:e,icon:wL(n),className:J(`execution-progress-panel`,`is-${n}`,a),"aria-label":c,...o,children:(0,L.jsx)(`div`,{className:`execution-progress-body`,children:(0,L.jsx)(`div`,{className:`execution-progress-list`,children:r.map(e=>(0,L.jsxs)(`div`,{className:J(`execution-progress-step`,`is-${e.status}`),children:[(0,L.jsx)(`span`,{className:J(`execution-progress-marker`,`is-${e.status}`),"aria-hidden":`true`,children:SL(e.status)}),(0,L.jsxs)(`span`,{className:`execution-progress-step-content`,children:[(0,L.jsxs)(`span`,{className:`execution-progress-step-title`,children:[(0,L.jsx)(`span`,{className:`execution-progress-step-label`,children:e.label}),e.elapsedLabel===void 0?null:(0,L.jsxs)(`span`,{className:`execution-progress-step-elapsed`,children:[` (`,e.elapsedLabel,`)`]})]}),e.detail===void 0&&e.detailPrefix===void 0?null:(0,L.jsxs)(`span`,{className:`execution-progress-step-detail`,children:[e.detailPrefix===void 0?null:(0,L.jsx)(`span`,{className:`execution-progress-step-detail-prefix`,children:e.detailPrefix}),e.detailPrefix===void 0||e.detail===void 0?null:(0,L.jsx)(`span`,{className:`execution-progress-step-detail-separator`,"aria-hidden":`true`,children:` · `}),e.detail]}),e.activityLabel===void 0?null:(0,L.jsx)(`span`,{className:`execution-progress-step-activity`,children:e.activityLabel}),e.metrics===void 0||e.metrics.length===0?null:(0,L.jsx)(`span`,{className:`execution-progress-step-metrics`,children:e.metrics.map(e=>(0,L.jsx)(`span`,{className:`execution-progress-step-metric`,children:e},e))})]})]},e.id))})})})}function EL({brand:e,projectName:t,showProjectName:n=!0,meta:r,actions:i,activeTab:a,refreshing:o=!1,onSelectTab:s,onRefresh:c,children:l,className:u,...d}){return(0,L.jsx)(`main`,{className:J(`embedded-project-page`,u),...d,children:(0,L.jsxs)(`section`,{className:`embedded-project-surface`,children:[(0,L.jsxs)(`header`,{className:`embedded-project-header`,children:[(0,L.jsx)(`div`,{className:`embedded-project-brand`,children:e}),!n&&r===void 0?null:(0,L.jsxs)(`div`,{className:`embedded-project-identity`,children:[n?(0,L.jsx)(`h1`,{children:t}):null,r===void 0?null:(0,L.jsx)(`p`,{children:r})]}),i===void 0&&c===void 0?null:(0,L.jsxs)(`div`,{className:`embedded-project-actions`,children:[i,c===void 0?null:(0,L.jsx)(Y,{"aria-label":o?`Refreshing project`:`Refresh project`,className:`embedded-project-refresh`,disabled:o,onClick:c,type:`button`,children:o?(0,L.jsx)(Cx,{"aria-hidden":`true`,className:`is-spinning`}):(0,L.jsx)(zx,{"aria-hidden":`true`})})]})]}),a===void 0?null:(0,L.jsx)(`nav`,{className:`embedded-project-tabs`,"aria-label":`Project sections`,children:[`project`,`work`,`artifacts`,`timeline`].map(e=>(0,L.jsx)(`button`,{"aria-current":a===e?`page`:void 0,className:a===e?`is-active`:void 0,onClick:()=>s?.(e),type:`button`,children:e===`project`?`Project`:e===`work`?`Tasks`:e===`timeline`?`Timeline`:`Artifacts`},e))}),(0,L.jsx)(`div`,{className:`embedded-project-body`,children:l})]})})}function DL({message:e,diagnosticId:t,rows:n,onCopy:r}){let[i,a]=(0,I.useState)(`idle`);return(0,L.jsxs)(`div`,{className:`embedded-project-diagnostic`,children:[e===void 0?null:(0,L.jsx)(`p`,{children:e}),(0,L.jsxs)(`p`,{className:`embedded-project-diagnostic-id`,children:[`Diagnostic ID `,(0,L.jsx)(`code`,{children:t})]}),(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{children:`Diagnostic details`}),(0,L.jsx)(`dl`,{"aria-label":`Feishu diagnostic details`,children:n.map(([e,t])=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:e}),(0,L.jsx)(`dd`,{children:t})]},e))})]}),(0,L.jsx)(Y,{type:`button`,disabled:i===`pending`,onClick:()=>{a(`pending`),Promise.resolve().then(r).then(()=>a(`copied`),()=>a(`failed`))},children:`Copy diagnostics`}),(0,L.jsx)(`span`,{"aria-live":`polite`,children:i===`copied`?`Copied.`:i===`failed`?`Copy unavailable. Select and copy the details above.`:null})]})}function OL({open:e,title:t,onClose:n,children:r}){let i=(0,I.useRef)(null);return(0,L.jsx)(qD,{open:e,onOpenChange:e=>{e||n()},children:(0,L.jsxs)(ZD,{children:[(0,L.jsx)($D,{className:`bottom-sheet-overlay`}),(0,L.jsxs)(rO,{className:`bottom-sheet`,"aria-describedby":void 0,onOpenAutoFocus:()=>{i.current=document.activeElement instanceof HTMLElement?document.activeElement:null},onCloseAutoFocus:e=>{e.preventDefault(),i.current?.isConnected&&i.current.focus()},children:[(0,L.jsxs)(`header`,{className:`bottom-sheet-header`,children:[(0,L.jsx)(cO,{children:t}),(0,L.jsx)(fO,{asChild:!0,children:(0,L.jsx)(Y,{className:`bottom-sheet-close`,type:`button`,"aria-label":`Close details`,children:(0,L.jsx)(rS,{"aria-hidden":`true`})})})]}),(0,L.jsx)(`div`,{className:`bottom-sheet-body`,children:r})]})]})})}function kL({tone:e=`neutral`,compact:t=!1,asChild:n=!1,className:r,...i}){return(0,L.jsx)(n?sw:`div`,{className:J(`chat-event-card`,`is-${e}`,t?`is-compact`:void 0,r),...i})}function AL({as:e=`div`,icon:t,title:n,meta:r,action:i,className:a,...o}){return(0,L.jsxs)(e,{className:J(`chat-event-card-header`,a),...o,children:[(0,L.jsx)(jL,{children:t}),(0,L.jsxs)(`span`,{className:`chat-event-card-title`,children:[(0,L.jsx)(`strong`,{children:n}),r===void 0?null:(0,L.jsx)(`span`,{className:`chat-event-card-meta`,children:r})]}),i]})}function jL({className:e,...t}){return(0,L.jsx)(`span`,{className:J(`chat-event-card-status-icon`,e),...t})}function ML({className:e,...t}){return(0,L.jsx)(`div`,{className:J(`chat-event-card-body`,e),...t})}function NL({className:e,...t}){return(0,L.jsx)(`footer`,{className:J(`chat-event-card-footer`,e),...t})}function PL(e){return e===`done`?`success`:e===`failed`?`danger`:e===`pending`?`warning`:`neutral`}function FL(e){return e===`done`?(0,L.jsx)(tx,{"aria-hidden":`true`}):e===`failed`?(0,L.jsx)(rS,{"aria-hidden":`true`}):(0,L.jsx)(Ex,{"aria-hidden":`true`})}function IL({title:e,summary:t,request:n,messages:r,draft:i,contextLabel:a,defaultOpen:o,readOnly:s=!1,replyCount:c,status:l,statusLabel:u,mentionOptions:d,sendPending:f=!1,submitPending:p=!1,onDraftChange:m,onSendMessage:h,onSubmitRound:g,className:_,...v}){let y=t.trim()===``?n:t,b=a===void 0?y:`${y} (${a})`,[x,S]=(0,I.useState)(o??!0),C=l??(s?`done`:`pending`),w=u??(s?`submitted`:`needs input`),T=c??r.length,E=p||T===0,D=T===0?`No replies`:`${T} ${T===1?`reply`:`replies`}`,O=PL(C),k=`${w} · ${D}`,A=(0,L.jsxs)(ML,{className:`chat-clarification-card-body`,children:[(0,L.jsx)(`div`,{className:`chat-event-thread`,children:r.map(e=>(0,L.jsxs)(`article`,{className:`chat-event-message`,children:[e.avatar,(0,L.jsxs)(`div`,{className:`chat-event-message-copy`,children:[(0,L.jsxs)(`div`,{className:`message-meta`,children:[(0,L.jsx)(`span`,{className:`message-author`,children:e.author}),e.time===void 0?null:(0,L.jsx)(`span`,{className:`message-time`,children:e.time})]}),(0,L.jsx)(`p`,{children:(0,L.jsx)(YI,{children:e.body})})]})]},e.id))}),s?null:(0,L.jsx)(`form`,{className:`chat-event-composer`,"aria-label":`Round reply`,onSubmit:h,children:(0,L.jsxs)(`div`,{className:`composer-input-shell chat-event-composer-input-shell`,children:[(0,L.jsx)(XI,{type:`text`,"aria-label":`Round message`,value:i,placeholder:`Reply in this round`,multiline:!0,maxRows:4,submitOnEnter:!0,...d===void 0?{}:{mentionOptions:d},onValueChange:m}),(0,L.jsx)(`div`,{className:`composer-tools chat-event-composer-tools`,"aria-label":`Round message tools`,children:(0,L.jsx)(`button`,{className:`composer-tool-button composer-send-button chat-event-send-button`,type:`submit`,disabled:i.trim()===``||f,"aria-label":f?`Sending round message`:`Send round message`,title:f?`Sending round message`:`Send round message`,children:(0,L.jsx)(Wx,{"aria-hidden":`true`})})})]})})]});return(0,L.jsx)(`article`,{className:J(`message is-chat-event`,_),...v,children:s?(0,L.jsx)(kL,{tone:O,asChild:!0,children:(0,L.jsxs)(`details`,{className:`chat-clarification-card`,open:x,"aria-label":b,onToggle:e=>S(e.currentTarget.open),children:[(0,L.jsx)(AL,{as:`summary`,icon:FL(C),title:e,meta:k,action:(0,L.jsx)(`span`,{className:`chat-event-card-toggle`,"aria-hidden":`true`,children:(0,L.jsx)(nx,{})})}),A]})}):(0,L.jsx)(kL,{tone:O,asChild:!0,children:(0,L.jsxs)(`section`,{className:`chat-clarification-card is-fixed-open`,"aria-label":b,children:[(0,L.jsx)(AL,{icon:FL(C),title:e,meta:k,tabIndex:-1,action:(0,L.jsxs)(Cw,{className:`chat-event-primary-action`,type:`button`,"aria-label":T===0?`Reply before submitting round`:`Submit round`,"aria-busy":p,disabled:E,title:T===0?`Reply before submitting round`:`Submit round`,onClick:g,children:[p?(0,L.jsx)(Cx,{"aria-hidden":`true`}):(0,L.jsx)(tx,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`button-label`,children:p?`Submitting`:`Submit`})]})}),A]})})})}function LL({decision:e,disabled:t,onDecide:n}){let r=e.tone===`primary`?Cw:Y,i=e.decisionId.startsWith(`allow`)?(0,L.jsx)(tx,{"aria-hidden":`true`}):(0,L.jsx)(rS,{"aria-hidden":`true`});return(0,L.jsxs)(r,{type:`button`,className:J(`chat-approval-card-decision`,e.tone===`primary`?`is-primary`:void 0,e.tone===`danger`?`is-danger`:void 0),disabled:t,onClick:()=>n(e.decisionId),children:[i,(0,L.jsx)(`span`,{className:`button-label`,children:e.label})]})}function RL(e,t){return e===`pending`?`warning`:e===`resolved`?`success`:/expired|cancelled/iu.test(t)?`neutral`:`danger`}function zL(e){return e===`success`?(0,L.jsx)(tx,{"aria-hidden":`true`}):e===`danger`?(0,L.jsx)(rS,{"aria-hidden":`true`}):e===`neutral`?(0,L.jsx)(cx,{"aria-hidden":`true`}):(0,L.jsx)(qx,{"aria-hidden":`true`})}function BL({title:e,summary:t,reason:n,status:r,statusLabel:i,detailLabel:a,detail:o,detailCode:s=!1,decisions:c=[],decisionPending:l=!1,resolutionLabel:u,defaultOpen:d,onDecide:f,className:p,...m}){let[h,g]=(0,I.useState)(d??r===`pending`),_=RL(r,i),v=[...c].sort((e,t)=>e.tone===t.tone?0:e.tone===`primary`?-1:+(t.tone===`primary`)),y=r===`pending`&&f!==void 0?(0,L.jsx)(NL,{className:`chat-approval-card-actions`,children:v.map(e=>(0,L.jsx)(LL,{decision:e,disabled:l,onDecide:f},e.decisionId))}):null,b=(0,L.jsx)(ML,{className:`chat-approval-card-body`,children:(0,L.jsxs)(`div`,{className:`chat-approval-card-content`,children:[(0,L.jsx)(`p`,{className:`chat-approval-card-summary`,children:t}),n===void 0?null:(0,L.jsx)(`p`,{className:`chat-approval-card-reason`,children:n}),o===void 0?null:(0,L.jsxs)(`div`,{className:`chat-approval-card-detail`,children:[a===void 0?null:(0,L.jsx)(`span`,{className:`chat-approval-card-detail-label`,children:a}),s?(0,L.jsx)(`code`,{className:`chat-approval-card-detail-code`,children:o}):(0,L.jsx)(`span`,{className:`chat-approval-card-detail-text`,children:o})]}),r===`pending`||u===void 0?null:(0,L.jsx)(`p`,{className:`chat-approval-card-resolution`,children:u})]})});return(0,L.jsx)(`article`,{className:J(`message is-chat-event`,p),...m,children:r===`pending`?(0,L.jsx)(kL,{tone:_,asChild:!0,children:(0,L.jsxs)(`section`,{className:`chat-approval-card is-fixed-open`,"aria-label":t,children:[(0,L.jsx)(AL,{icon:zL(_),title:e,meta:i,tabIndex:-1}),b,y]})}):(0,L.jsx)(kL,{tone:_,asChild:!0,children:(0,L.jsxs)(`details`,{className:`chat-approval-card`,open:h,"aria-label":t,onToggle:e=>g(e.currentTarget.open),children:[(0,L.jsx)(AL,{as:`summary`,icon:zL(_),title:e,meta:i,action:(0,L.jsx)(`span`,{className:`chat-event-card-toggle`,"aria-hidden":`true`,children:(0,L.jsx)(nx,{})})}),b]})})})}function VL({state:e,className:t,disabled:n,onClick:r,...i}){let a=e===`retrying`,o=e===`retried`,s=a?`Retrying`:o?`Retried`:`Retry`;return(0,L.jsxs)(Y,{...i,onClick:r,className:J(`task-retry-action`,t),disabled:n===!0||r===void 0||a||o,"aria-label":s,"aria-busy":a?`true`:void 0,type:`button`,children:[a?(0,L.jsx)(Cx,{className:`is-spinning`,"aria-hidden":`true`}):o?(0,L.jsx)(tx,{"aria-hidden":`true`}):(0,L.jsx)(Vx,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:s})]})}function HL({status:e,title:t,taskId:n,taskTitle:r,summary:i,moduleName:a,finalNote:o,generatedFiles:s=[],errorCode:c,onOpenTask:l,retryState:u,onRetry:d,className:f,...p}){let m=o?.trim()??``,h=i.trim(),g=m.length>0?m:h,_=e===`completed`?`Task completed`:`Task failed`;return(0,L.jsx)(`article`,{className:J(`message is-chat-event is-task-result`,f),...p,children:(0,L.jsxs)(kL,{tone:e===`completed`?`success`:`danger`,className:J(`chat-task-result-card`,`is-${e}`),children:[(0,L.jsxs)(`button`,{className:`chat-task-result-card-open`,disabled:l===void 0,onClick:()=>l?.(n),type:`button`,"aria-label":`${t}: ${r}`,children:[(0,L.jsx)(jL,{"aria-hidden":`true`,children:e===`completed`?(0,L.jsx)(tx,{}):(0,L.jsx)(rS,{})}),(0,L.jsxs)(`span`,{className:`chat-task-result-card-main`,children:[(0,L.jsx)(`span`,{className:`chat-task-result-card-state`,children:_}),(0,L.jsx)(`strong`,{children:r}),a===void 0?null:(0,L.jsx)(`span`,{className:`chat-task-result-card-module`,children:a}),g.length===0?null:(0,L.jsx)(`span`,{className:`chat-task-result-card-summary`,children:g}),c===void 0?null:(0,L.jsx)(`span`,{className:`chat-task-result-card-error-code`,children:c}),s.length===0?null:(0,L.jsx)(`span`,{className:`chat-task-result-card-files`,"aria-label":`Generated files`,children:s.map(e=>(0,L.jsxs)(`span`,{className:`chat-task-result-card-file`,children:[(0,L.jsx)(hx,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:e.name})]},e.path))})]}),(0,L.jsx)(`span`,{className:`chat-task-result-card-arrow`,"aria-hidden":`true`,children:(0,L.jsx)(rx,{})})]}),u===void 0?null:(0,L.jsx)(`footer`,{className:`chat-task-result-card-actions`,children:(0,L.jsx)(VL,{state:u,onClick:d})})]})})}function UL({status:e}){return e===`done`?(0,L.jsx)(`span`,{className:`task-check`,"aria-hidden":`true`,children:(0,L.jsx)(tx,{})}):e===`pending`?(0,L.jsx)(`span`,{className:`task-check`,"aria-hidden":`true`,children:(0,L.jsx)(kx,{})}):e===`failed`?(0,L.jsx)(`span`,{className:`task-check`,"aria-hidden":`true`,children:(0,L.jsx)(rS,{})}):e===`running`?(0,L.jsx)(`span`,{className:`task-check`,"aria-hidden":`true`,children:(0,L.jsx)(Cx,{})}):(0,L.jsx)(`span`,{className:`task-check`,"aria-hidden":`true`})}function WL({title:e,status:t,selected:n=!1,className:r,type:i=`button`,...a}){return(0,L.jsxs)(`button`,{className:J(`task-row`,n?`is-selected`:void 0,`is-${t}`,r),type:i,"aria-current":n?`true`:void 0,...a,children:[(0,L.jsx)(UL,{status:t}),(0,L.jsx)(`div`,{className:`task-row-main`,children:(0,L.jsx)(`div`,{className:`task-title-line`,children:(0,L.jsx)(`strong`,{children:e})})})]})}function GL({label:e,value:t,code:n=!1,status:r}){return(0,L.jsxs)(`div`,{className:`detail-row`,children:[(0,L.jsx)(`span`,{children:e}),r===void 0?n?(0,L.jsx)(`code`,{children:t}):(0,L.jsx)(`strong`,{children:t}):(0,L.jsx)(`strong`,{children:(0,L.jsx)(Ew,{status:r,children:t})})]})}function KL({rows:e}){return(0,L.jsx)(L.Fragment,{children:e.map((e,t)=>(0,I.createElement)(GL,{...e,key:`${e.label}-${t}`}))})}function qL({...e}){return(0,L.jsx)(WL,{...e})}function JL({detail:e,placeholder:t,missingTaskId:n,stacked:r=!1}){if(e===void 0){let e=t?.title??(n===void 0?`No task selected`:`Task not found`),i=t?.description??(n===void 0?`Select a task to inspect its contract, latest result, and run history.`:`No task exists for ${n}. Select another task from the Worklist.`);return(0,L.jsxs)(`aside`,{className:J(`task-detail-card`,r?`is-stacked`:void 0),"aria-label":`Selected task details`,children:[(0,L.jsx)(`div`,{className:`task-detail-head`,children:(0,L.jsx)(`h4`,{children:e})}),(0,L.jsx)(`p`,{children:i})]})}return(0,L.jsxs)(`aside`,{className:J(`task-detail-card`,r?`is-stacked`:void 0),"aria-label":`Selected task details`,children:[(0,L.jsxs)(`div`,{className:`task-detail-head`,children:[(0,L.jsx)(Ew,{status:e.status,children:e.status}),(0,L.jsx)(`h4`,{children:e.title})]}),(0,L.jsx)(`p`,{children:e.summary}),(0,L.jsxs)(`section`,{className:`task-detail-section`,"aria-label":`Task contract`,children:[(0,L.jsx)(`span`,{className:`task-section-label`,children:`Task contract`}),(0,L.jsx)(KL,{rows:e.contractRows})]}),(0,L.jsxs)(`section`,{className:`task-detail-section task-evidence-section`,"aria-label":`Evidence`,children:[(0,L.jsx)(`span`,{className:`task-section-label`,children:`Evidence`}),(0,L.jsx)(KL,{rows:e.evidenceRows??e.resultRows})]}),e.retryAction===void 0?null:(0,L.jsx)(`div`,{className:`task-detail-retry-row`,children:(0,L.jsx)(VL,{state:e.retryAction.state,onClick:e.retryAction.onRetry})}),(0,L.jsxs)(`section`,{className:`task-detail-section`,"aria-label":`Run result history`,children:[(0,L.jsx)(`span`,{className:`task-section-label`,children:`Run result history`}),e.runResults.length===0?(0,L.jsx)(`p`,{children:`No run result yet.`}):(0,L.jsx)(`div`,{className:`run-result-list`,children:e.runResults.map(e=>(0,L.jsx)(`article`,{className:`run-result-item`,children:(0,L.jsxs)(`div`,{className:`run-result-item-head`,children:[(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:e.title}),e.meta===void 0?null:(0,L.jsx)(`small`,{children:e.meta})]}),e.status===void 0?null:(0,L.jsx)(Ew,{status:e.status,children:e.status})]})},e.id))})]})]})}function YL({modules:e,taskCount:t,detail:n,detailPlaceholder:r,layout:i=`split`,detailOpen:a=!1,onCloseDetail:o,missingTaskId:s,runNote:c,onSelectTask:l,empty:u,className:d,...f}){let p=i!==`split`,m=(0,L.jsx)(JL,{...n===void 0?{}:{detail:n},placeholder:r,...s===void 0?{}:{missingTaskId:s},stacked:p});return(0,L.jsxs)(mS,{title:`Worklist`,frameless:i===`sheet`,icon:(0,L.jsx)(Sx,{"aria-hidden":`true`}),action:(0,L.jsx)(`div`,{className:`worklist-header-summary`,children:(0,L.jsx)(`span`,{className:`mini-meta`,children:t===1?`1 task`:`${t} tasks`})}),className:J(`tasks worklist-page-panel`,d),...f,children:[(0,L.jsxs)(`div`,{className:J(`worklist-page-body`,p?`is-stacked`:void 0),children:[c===void 0?null:(0,L.jsx)(`p`,{className:`worklist-run-note`,children:c}),e.length===0?(0,L.jsx)(`div`,{className:`worklist-page-empty`,children:u??(0,L.jsx)(`div`,{className:`reference-empty`,children:`No compiled tasks`})}):(0,L.jsxs)(`div`,{className:J(`task-board-body`,p?`is-stacked`:void 0),children:[(0,L.jsx)(`div`,{className:J(`task-list`,p?`is-stacked`:void 0),"aria-label":`Tasks`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`task-section`,children:[(0,L.jsx)(`span`,{className:`task-section-label`,children:e.label}),e.rows.map(e=>(0,L.jsx)(qL,{title:e.title,status:e.status,onClick:()=>l?.(e.id),...e.selected===void 0?{}:{selected:e.selected}},e.id))]},e.label))}),i===`sheet`?null:m]})]}),i===`sheet`?(0,L.jsx)(OL,{open:a,title:`Details`,onClose:()=>o?.(),children:m}):null]})}function XL({sections:e,statuses:t=[],className:n,...r}){return(0,L.jsxs)(`section`,{className:J(`settings-sheet`,n),"aria-labelledby":`settings-title`,...r,children:[(0,L.jsxs)(`header`,{className:`settings-sheet-head`,children:[(0,L.jsxs)(`div`,{className:`panel-title`,children:[(0,L.jsx)(hS,{icon:(0,L.jsx)(Kx,{"aria-hidden":`true`})}),(0,L.jsx)(`h3`,{id:`settings-title`,children:`Settings`})]}),t.length===0?null:(0,L.jsx)(`div`,{className:`panel-actions`,children:t.map(e=>(0,L.jsx)(ww,{className:`task-tag`,tone:e.tone,children:e.label},e.label))})]}),e.map(e=>(0,L.jsxs)(`section`,{className:`settings-section`,id:e.id,"aria-label":e.title,children:[(0,L.jsx)(`div`,{className:`settings-section-title`,children:(0,L.jsx)(`h4`,{children:e.title})}),(0,L.jsx)(`div`,{className:`settings-section-body`,children:e.rows.map(e=>(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`field-label`,children:e.label}),e.value===void 0?(0,L.jsx)(`span`,{}):e.plain===!0?(0,L.jsx)(`div`,{className:`settings-row-value`,children:e.value}):(0,L.jsx)(`strong`,{children:e.value})]},e.label))})]},e.id))]})}function ZL({value:e,options:t,maxLength:n,canEdit:r=!1,discovering:i=!1,saving:a=!1,onDiscover:o,onUpdate:s}){let[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(e),[f,p]=(0,I.useState)(e),m=u.trim(),h=i||a;return(0,I.useEffect)(()=>{c||(d(e),p(e))},[c,e]),!r||s===void 0?(0,L.jsx)(`span`,{className:`settings-model-readonly`,children:e}):c?(0,L.jsxs)(`form`,{className:`settings-model-editor`,"aria-label":`Change model`,onSubmit:e=>{e.preventDefault(),!(m.length===0||m===f||s===void 0)&&Promise.resolve(s(m,f)).then(e=>{e.kind===`saved`?l(!1):e.kind===`stale`&&p(e.currentValue)}).catch(()=>void 0)},children:[(0,L.jsx)(Nw,{autoComplete:`off`,"aria-label":`Model`,value:u,options:t,maxLength:n,maxVisibleOptions:8,disabled:a,onValueChange:d,placeholder:`Choose or enter a model`,autoFocus:!0}),(0,L.jsxs)(`div`,{className:`settings-model-editor-footer`,children:[(0,L.jsx)(`span`,{className:`settings-model-editor-status`,"aria-live":`polite`,children:i?`Loading models…`:`Choose a model or enter its name.`}),(0,L.jsxs)(`div`,{className:`settings-model-editor-actions`,children:[(0,L.jsx)(Y,{className:`settings-model-editor-action`,type:`button`,disabled:a,onClick:()=>{d(e),p(e),l(!1)},children:`Cancel`}),(0,L.jsx)(Cw,{className:`settings-model-editor-action`,type:`submit`,disabled:h||m.length===0||m===f,children:a?`Saving…`:`Save`})]})]})]}):(0,L.jsx)(`button`,{"aria-label":`Change model from ${e}`,className:`settings-value-button settings-model-change-button`,type:`button`,onClick:()=>{d(e),p(e),l(!0),Promise.resolve(o?.()).catch(()=>void 0)},children:e})}function QL({row:e}){return e.category===`image`?(0,L.jsx)(vx,{"aria-hidden":`true`}):e.canPreview===!1?(0,L.jsx)(px,{"aria-hidden":`true`}):e.selected===!0?(0,L.jsx)(fx,{"aria-hidden":`true`}):e.extension===`md`||e.extension===`txt`?(0,L.jsx)(mx,{"aria-hidden":`true`}):(0,L.jsx)(hx,{"aria-hidden":`true`})}function $L({row:e,onSelectFile:t}){return(0,L.jsxs)(`button`,{className:J(`reference-row`,e.selected===!0?`is-selected`:void 0),type:`button`,"aria-current":e.selected===!0?`true`:void 0,onClick:()=>t?.(e.path),children:[(0,L.jsx)(`span`,{className:`reference-file-icon`,"aria-hidden":`true`,children:(0,L.jsx)(QL,{row:e})}),(0,L.jsxs)(`span`,{className:`reference-row-main`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`span`,{children:e.meta})]})]})}function eR({name:e,rows:t,onSelectFile:n}){return(0,L.jsxs)(`details`,{className:`reference-folder-group`,children:[(0,L.jsxs)(`summary`,{className:`reference-folder-head`,children:[(0,L.jsx)(`span`,{className:`reference-file-icon`,"aria-hidden":`true`,children:(0,L.jsx)(_x,{})}),(0,L.jsxs)(`span`,{className:`reference-row-main`,children:[(0,L.jsx)(`strong`,{children:e}),(0,L.jsxs)(`span`,{children:[t.length,` `,t.length===1?`file`:`files`]})]})]}),(0,L.jsx)(`div`,{className:`reference-folder-files`,children:t.map(e=>(0,L.jsx)($L,{row:e,...n===void 0?{}:{onSelectFile:n}},e.path))})]})}function tR(e){let t=new Map;for(let n of e){if(n.folderGroup===void 0)continue;let e=t.get(n.folderGroup)??[];e.push(n),t.set(n.folderGroup,e)}return[...t.entries()].map(([e,t])=>({name:e,rows:t}))}function nR({title:e=`References`,description:t,files:n,detail:r,uploadPending:i=!1,fileSortMode:a=`time`,empty:o,onSelectFile:s,onUploadFile:c,onDropFiles:l,onFileSortModeChange:u,className:d,...f}){let p=n.filter(e=>e.category===`image`),m=n.filter(e=>e.category!==`image`),h=m.filter(e=>e.folderGroup===void 0),g=tR(m),_=e=>(0,L.jsx)(`div`,{className:`reference-image-strip`,role:`list`,"aria-label":`Reference images`,onWheel:e=>{Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(e.currentTarget.scrollLeft+=e.deltaY,e.preventDefault())},children:e.map(e=>(0,L.jsxs)(`button`,{className:J(`reference-image-tile`,e.selected===!0?`is-selected`:void 0),type:`button`,"aria-current":e.selected===!0?`true`:void 0,"aria-label":`Open ${e.name}`,onClick:()=>s?.(e.path),children:[e.thumbnailUrl===void 0?(0,L.jsx)(`span`,{className:`reference-image-tile-fallback`,"aria-hidden":`true`,children:(0,L.jsx)(vx,{})}):(0,L.jsx)(`img`,{src:e.thumbnailUrl,alt:e.name,loading:`lazy`,decoding:`async`}),(0,L.jsx)(`span`,{children:e.name})]},e.path))}),v=e=>e.map(e=>(0,L.jsx)($L,{row:e,...s===void 0?{}:{onSelectFile:s}},e.path)),y=l??(c===void 0?void 0:e=>{for(let t of e)c(t)});return(0,L.jsxs)(jI,{className:J(`panel references-panel`,t===void 0?void 0:`has-description`,d),"aria-label":e,dropLabel:`Drop reference files to upload`,pending:i,onFilesUpload:y,...f,children:[(0,L.jsxs)(`div`,{className:`panel-header`,children:[(0,L.jsxs)(`div`,{className:`panel-title`,children:[(0,L.jsx)(hS,{icon:(0,L.jsx)(mx,{"aria-hidden":`true`})}),(0,L.jsx)(`h3`,{children:e})]}),c===void 0?null:(0,L.jsx)(`div`,{className:`panel-actions`,children:(0,L.jsx)(hL,{variant:`action`,className:`reference-upload-button`,label:`Upload`,pendingLabel:`Uploading`,pending:i,onFileUpload:c})})]}),t===void 0?null:(0,L.jsx)(`p`,{className:`reference-panel-description`,children:t}),(0,L.jsx)(`div`,{className:`reference-board-body`,children:n.length===0?(0,L.jsx)(`div`,{className:`reference-board-empty`,children:o??(0,L.jsx)(`div`,{className:`reference-empty`,children:`No reference files`})}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`reference-list`,"aria-label":`Reference file list`,children:[p.length===0?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`reference-section-label`,children:`Images`}),_(p)]}),m.length===0?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`reference-files-head`,children:[(0,L.jsx)(`div`,{className:`reference-section-label`,children:`Files`}),u===void 0?null:(0,L.jsxs)(`div`,{className:`reference-list-toolbar`,role:`toolbar`,"aria-label":`Sort files`,children:[(0,L.jsx)(`button`,{className:J(`reference-sort-button`,a===`time`?`is-active`:void 0),type:`button`,"aria-label":`Sort files by upload time`,"aria-pressed":a===`time`,onClick:()=>u(`time`),children:(0,L.jsx)(cx,{"aria-hidden":`true`})}),(0,L.jsx)(`button`,{className:J(`reference-sort-button`,a===`type`?`is-active`:void 0),type:`button`,"aria-label":`Sort files by type`,"aria-pressed":a===`type`,onClick:()=>u(`type`),children:(0,L.jsx)(Zx,{"aria-hidden":`true`})})]})]}),v(h),g.map(e=>(0,L.jsx)(eR,{name:e.name,rows:e.rows,...s===void 0?{}:{onSelectFile:s}},e.name))]})]}),(0,L.jsxs)(`aside`,{className:`reference-detail-card`,"aria-label":`Selected reference content`,children:[(0,L.jsxs)(`div`,{className:`reference-detail-head`,children:[(0,L.jsx)(`h4`,{children:r?.title??`No file selected`}),r?.meta===void 0?null:(0,L.jsx)(`p`,{children:r.meta})]}),(0,L.jsxs)(`div`,{className:`reference-detail-section`,children:[(0,L.jsx)(`span`,{className:`task-section-label`,children:`Summary`}),(0,L.jsx)(`p`,{className:`reference-summary`,children:r?.summary??`Summary not available yet`}),r?.summaryStatus===void 0?null:(0,L.jsx)(`p`,{className:`reference-summary-status`,children:r.summaryStatus})]}),(0,L.jsxs)(`div`,{className:`reference-detail-section`,children:[(0,L.jsx)(`span`,{className:`task-section-label`,children:`Content`}),r?.content===void 0?r?.imageUrl===void 0?(0,L.jsx)(`p`,{className:`reference-content`,children:r?.unavailableReason??`Select a reference file`}):(0,L.jsx)(`img`,{className:`reference-image-preview`,src:r.imageUrl,alt:r.title,decoding:`async`}):(0,L.jsx)(`pre`,{className:`reference-content`,children:(0,L.jsx)(`code`,{children:r.content})})]})]})]})})]})}function rR(e){return e.status===`loading`?{status:`running`,label:`Loading`}:e.status===`not_declared`?{status:`todo`,label:`No artifact`}:e.status===`invalid`?{status:`failed`,label:`Invalid`}:e.status===`updating`?{status:`running`,label:`Updating`}:e.previewStatus===`ready`?null:e.previewStatus===`starting`?{status:`running`,label:`Starting`}:e.previewStatus===`failed`?{status:`failed`,label:`Failed`}:{status:`todo`,label:`Idle`}}function iR({state:e,empty:t,emptyWatermark:n,iframeRef:r,onPreviewLoad:i}){if(e.status===`declared`&&e.previewStatus===`ready`&&e.previewUrl!==void 0)return(0,L.jsx)(`iframe`,{className:`artifact-iframe`,src:e.previewUrl,title:`${e.title} artifact preview`,sandbox:`allow-scripts allow-forms allow-same-origin`,referrerPolicy:`no-referrer`,ref:r,onLoad:i});let a,o=`neutral`;return e.status===`loading`?a=`Loading artifact`:e.status===`updating`?a=`Artifact is updating`:e.status===`not_declared`?a=`No artifact`:e.status===`invalid`?(o=`error`,a=`Invalid artifact. ${e.message}`):e.previewStatus===`starting`?a=`Preview is starting`:e.previewStatus===`failed`?(o=`error`,a=e.errorMessage??`Preview failed`):a=`Preview is idle`,(0,L.jsx)(`div`,{className:`artifact-empty-preview`,role:e.status===`invalid`?`alert`:void 0,children:t??(0,L.jsx)(aS,{tone:o,watermark:n,children:a})})}function aR({state:e,presentation:t=`panel`,error:n=null,empty:r,emptyWatermark:i,headerAction:a,iframeRef:o,onPreviewLoad:s,className:c,...l}){let u=n===null?e:{status:`invalid`,message:n},d=rR(u);return(0,L.jsxs)(`section`,{className:J(`panel artifacts-panel`,t===`preview`&&`is-frameless`,c),"aria-label":`Artifacts`,...l,children:[t===`preview`?null:(0,L.jsxs)(`div`,{className:`panel-header`,children:[(0,L.jsxs)(`div`,{className:`panel-title`,children:[(0,L.jsx)(hS,{icon:(0,L.jsx)(Ax,{"aria-hidden":`true`})}),(0,L.jsx)(`h3`,{children:`Artifacts`})]}),(0,L.jsxs)(`div`,{className:`panel-actions`,children:[a,d===null?null:(0,L.jsx)(Ew,{status:d.status,children:d.label})]})]}),(0,L.jsx)(`div`,{className:`artifact-board-body`,children:(0,L.jsx)(`div`,{className:`artifact-preview-frame`,"aria-label":`Current artifact`,children:(0,L.jsx)(iR,{state:u,empty:r,emptyWatermark:i,...o===void 0?{}:{iframeRef:o},...s===void 0?{}:{onPreviewLoad:s}})})})]})}function oR(e){return e.accessibleName?.trim()||e.textExcerpt?.trim()||void 0}function sR(e){let t=e.role?.trim()||e.tagName.trim()||e.elementKind,n=oR(e);return n===void 0?t:`${t} “${n}”`}function cR({active:e,pending:t=!1,className:n,...r}){let i=(0,L.jsxs)(L.Fragment,{children:[e?(0,L.jsx)(tx,{"aria-hidden":`true`}):(0,L.jsx)(Fx,{"aria-hidden":`true`}),t?`Submitting…`:e?`Submit comments`:`Comments`]});return e?(0,L.jsx)(Cw,{className:J(`artifact-comments-action`,`is-active`,n),type:`button`,...r,children:i}):(0,L.jsx)(Y,{className:J(`artifact-comments-action`,n),type:`button`,...r,children:i})}function lR({author:e,avatar:t,comment:n,annotations:r,selectedTarget:i,selectedTime:a,stale:o=!1,bridgeUnavailableReason:s,sendDisabledReason:c,onCommentChange:l,onAddAnnotation:u,onCancelSelection:d,onRemoveAnnotation:f,onReset:p,className:m,...h}){let g=i!==void 0&&n.trim().length>0&&!o;function _(e){e.preventDefault(),g&&u()}function v(e){e.key!==`Enter`||e.shiftKey||e.metaKey||e.nativeEvent.isComposing||(e.preventDefault(),g&&u())}return(0,L.jsxs)(`aside`,{className:J(`artifact-comments-rail`,m),"aria-label":`Artifact comments`,...h,children:[o?(0,L.jsxs)(`div`,{className:`artifact-comments-state is-warning`,role:`status`,children:[(0,L.jsx)(`strong`,{children:`Artifact updated`}),(0,L.jsx)(`span`,{children:`These comments belong to an earlier preview.`}),(0,L.jsx)(Y,{type:`button`,onClick:p,children:`Start over`})]}):null,s===void 0?null:(0,L.jsxs)(`div`,{className:`artifact-comments-state is-warning`,role:`status`,children:[(0,L.jsx)(`strong`,{children:`Comments unavailable`}),(0,L.jsx)(`span`,{children:s})]}),c===void 0?null:(0,L.jsxs)(`div`,{className:`artifact-comments-state is-warning`,role:`status`,children:[(0,L.jsx)(`strong`,{children:`Comments cannot be submitted yet`}),(0,L.jsx)(`span`,{children:c})]}),r.map((n,r)=>(0,L.jsxs)(QI,{"aria-label":`Comment ${r+1} on ${sR(n.target)}`,author:e,avatar:t,className:`artifact-comment-card is-sent`,...n.time===void 0?{}:{time:n.time},children:[(0,L.jsx)(`p`,{children:n.comment}),(0,L.jsx)(Sw,{className:`artifact-comment-dismiss`,label:`Remove comment ${r+1}`,icon:(0,L.jsx)(rS,{"aria-hidden":`true`}),type:`button`,onClick:()=>f(r)})]},n.key)),i===void 0||o?null:(0,L.jsxs)(QI,{"aria-label":`Comment on ${sR(i)}`,author:e,avatar:t,className:`artifact-comment-card is-composing`,...a===void 0?{}:{time:a},children:[(0,L.jsx)(Sw,{className:`artifact-comment-dismiss`,label:`Cancel selected element`,icon:(0,L.jsx)(rS,{"aria-hidden":`true`}),type:`button`,onClick:d}),(0,L.jsx)(`form`,{className:`artifact-comment-composer composer`,onSubmit:_,children:(0,L.jsxs)(`div`,{className:`composer-input-shell`,children:[(0,L.jsx)(`textarea`,{"aria-label":`Comment for selected element`,autoFocus:!0,maxLength:1e3,placeholder:`Write a comment`,rows:1,value:n,onChange:e=>l(e.target.value),onKeyDown:v}),(0,L.jsx)(`div`,{className:`composer-tools`,children:(0,L.jsx)(`button`,{"aria-label":`Add comment`,className:`composer-tool-button composer-send-button`,disabled:!g,title:`Add comment`,type:`submit`,children:(0,L.jsx)(Wx,{"aria-hidden":`true`})})})]})})]})]})}function uR({artifactTitle:e,summary:t,annotations:n,onViewAnnotation:r,className:i,...a}){let o=t?.trim()||n[0]?.comment.trim()||`Artifact feedback`;return(0,L.jsxs)(`details`,{className:J(`artifact-feedback-card`,i),...a,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(Dx,{"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`artifact-feedback-card-heading`,children:[(0,L.jsx)(`strong`,{children:e}),(0,L.jsxs)(`span`,{children:[n.length,` `,n.length===1?`note`:`notes`]}),(0,L.jsx)(`small`,{children:o})]}),(0,L.jsx)(nx,{className:`artifact-feedback-card-chevron`,"aria-hidden":`true`})]}),(0,L.jsxs)(`div`,{className:`artifact-feedback-card-body`,children:[t?.trim()?(0,L.jsx)(`p`,{className:`artifact-feedback-card-summary`,children:t}):null,(0,L.jsx)(`ol`,{children:n.map((e,t)=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`span`,{className:`artifact-feedback-note-index`,children:t+1}),(0,L.jsxs)(`span`,{className:`artifact-feedback-note-copy`,children:[(0,L.jsx)(`strong`,{children:sR(e.target)}),(0,L.jsx)(`small`,{children:e.documentUrl}),(0,L.jsx)(`span`,{children:e.comment}),e.canView&&r!==void 0?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(t),children:[(0,L.jsx)(wx,{"aria-hidden":`true`}),`View in Artifact`]}):null]})]},`${e.documentUrl}:${t}`))})]})]})}function dR({row:e}){return e.selected===!0?(0,L.jsx)(fx,{"aria-hidden":`true`}):(0,L.jsx)(Jx,{"aria-hidden":`true`})}function fR({skills:e,communityLinks:t=[],detail:n,readOnly:r=!1,detailFeedback:i,uploadPending:a=!1,deletePending:o=!1,empty:s,onSelectSkill:c,onUploadSkill:l,onDeleteSkill:u,className:d,...f}){let p=e.find(e=>e.selected===!0)?.name,m=t.length>0;return(0,L.jsxs)(`section`,{className:J(`panel references-panel skills-panel`,d),"aria-label":`Skills`,...f,children:[(0,L.jsxs)(`div`,{className:`panel-header`,children:[(0,L.jsxs)(`div`,{className:`panel-title`,children:[(0,L.jsx)(hS,{icon:(0,L.jsx)(Jx,{"aria-hidden":`true`})}),(0,L.jsx)(`h3`,{children:`Skills`})]}),r?null:(0,L.jsx)(`div`,{className:`panel-actions`,children:(0,L.jsx)(hL,{variant:`action`,className:`reference-upload-button`,label:`Upload`,pendingLabel:`Uploading`,pending:a,accept:`.zip,application/zip,application/x-zip-compressed`,onFileUpload:l})})]}),(0,L.jsx)(`div`,{className:`reference-board-body`,children:e.length===0&&!m?(0,L.jsx)(`div`,{className:`reference-board-empty`,children:s??(0,L.jsx)(`div`,{className:`reference-empty`,children:`No skills`})}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`reference-list`,"aria-label":`Skill list`,children:[m?(0,L.jsxs)(`div`,{className:`skill-community-section`,"aria-label":`Skill communities`,children:[(0,L.jsx)(`div`,{className:`reference-section-label`,children:`Skill communities`}),(0,L.jsx)(`div`,{className:`skill-community-grid`,children:t.map(e=>(0,L.jsxs)(`a`,{className:`skill-community-card`,href:e.href,target:`_blank`,rel:`noreferrer`,children:[(0,L.jsx)(`span`,{className:`skill-community-card-icon`,"aria-hidden":`true`,children:(0,L.jsx)(xx,{})}),(0,L.jsx)(`span`,{className:`skill-community-card-main`,children:(0,L.jsx)(`strong`,{children:e.title})})]},e.href))})]}):null,e.length===0?null:(0,L.jsx)(`div`,{className:`reference-section-label`,children:`User skills`}),e.map(e=>(0,L.jsxs)(`button`,{className:J(`reference-row`,e.selected===!0?`is-selected`:void 0),type:`button`,"aria-label":`Select skill ${e.name}`,"aria-current":e.selected===!0?`true`:void 0,onClick:()=>c?.(e.name),children:[(0,L.jsx)(`span`,{className:`reference-file-icon`,"aria-hidden":`true`,children:(0,L.jsx)(dR,{row:e})}),(0,L.jsxs)(`span`,{className:`reference-row-main`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`span`,{children:e.shortDescription??e.description})]})]},e.name))]}),(0,L.jsx)(`aside`,{className:`reference-detail-card`,"aria-label":`Selected skill content`,children:e.length===0?(0,L.jsx)(`div`,{className:`reference-board-empty`,children:s??(0,L.jsx)(`div`,{className:`reference-empty`,children:`No skills`})}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`reference-detail-head skill-detail-head`,children:[(0,L.jsxs)(`div`,{className:`skill-detail-title`,children:[(0,L.jsx)(`h4`,{children:n?.title??`No skill selected`}),n?.description===void 0?null:(0,L.jsx)(`p`,{children:n.description}),n?.updatedLabel===void 0?null:(0,L.jsx)(`p`,{children:n.updatedLabel})]}),r||p===void 0||u===void 0?null:(0,L.jsxs)(Y,{className:`skill-delete-button`,type:`button`,disabled:o,"aria-busy":o,onClick:()=>u(p),children:[(0,L.jsx)($x,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:o?`Deleting`:`Delete`})]})]}),(0,L.jsxs)(`div`,{className:`reference-detail-section`,children:[i,(0,L.jsx)(`span`,{className:`task-section-label`,children:`SKILL.md`}),n?.skillMd===void 0?(0,L.jsx)(`p`,{className:`reference-content`,children:n?.unavailableReason??`Select a skill`}):(0,L.jsx)(`pre`,{className:`reference-content`,children:(0,L.jsx)(`code`,{"aria-label":`Skill markdown for ${n.title}`,children:n.skillMd})})]})]})})]})})]})}function pR({label:e,children:t}){return(0,L.jsxs)(`section`,{className:`timeline-trace-section`,children:[(0,L.jsx)(`span`,{className:`timeline-trace-label`,children:e}),(0,L.jsx)(`div`,{className:`timeline-trace-section-body`,children:t})]})}function mR(e){return e.replaceAll(`_`,` `)}function hR(e){return e===`passed`?`success`:e===`failed`?`error`:`warning`}function gR(e){return e.status===`promoted`?`success`:e.status===`not_promoted`?`error`:`neutral`}function _R(e){if(e.skipReasonSummary!==void 0)return e.skipReasonSummary;switch(e.checks){case`passed`:return`All validation checks passed.`;case`failed`:return`Validation checks failed.`;case`skipped`:return`Validation was skipped.`}}function vR(e){if(e.summary!==void 0)return e.summary;switch(e.status){case`promoted`:return`Changes were promoted after verification.`;case`not_promoted`:return`Changes were not promoted.`;case`not_attempted`:return`Promotion was not attempted.`}}function yR(e){switch(e){case`added`:return`+`;case`modified`:return`~`;case`deleted`:return`-`;case`renamed`:return`~`;case`unknown`:return`?`}}var bR=3;function xR({expanded:e,collapsedLabel:t,expandedLabel:n,onClick:r}){return(0,L.jsxs)(`button`,{"aria-expanded":e,className:J(`timeline-trace-more`,e&&`is-expanded`),onClick:r,type:`button`,children:[(0,L.jsx)(`span`,{children:e?n:t}),(0,L.jsx)(nx,{"aria-hidden":`true`})]})}function SR({expanded:e,hiddenCount:t,label:n,onClick:r}){return t<=0?null:(0,L.jsx)(xR,{collapsedLabel:`Show ${t} more ${n}${t===1?``:`s`}`,expanded:e,expandedLabel:`Show fewer ${n}s`,onClick:r})}function CR(e){let t=[];return(e.origin!==void 0||e.decisions!==void 0||e.clarification!==void 0)&&t.push({id:`context`,label:`Context`,tone:`neutral`}),e.contract!==void 0&&t.push({id:`contract`,label:`Contract`,tone:`neutral`}),(e.result!==void 0||e.changes!==void 0)&&t.push({id:`result`,label:`Result`,tone:e.tone}),e.verification!==void 0&&t.push({id:`checks`,label:`Checks`,tone:hR(e.verification.checks)}),e.promotion!==void 0&&t.push({id:`promotion`,label:`Promotion`,tone:gR(e.promotion)}),e.checkpoint!==void 0&&t.push({id:`checkpoint`,label:`Checkpoint`,tone:e.tone}),t}function wR({trace:e}){let t=CR(e),n=e.links.filter(e=>e.onClick!==void 0),[r,i]=(0,I.useState)(()=>new Set),a=r.has(`origin`),o=r.has(`decisions`),s=r.has(`clarification-answers`),c=r.has(`scope`),l=r.has(`changes`),u=r.has(`checkpoint`),d=r.has(`generated-files`),f=e.origin?.snippets??[],p=e.decisions===void 0||o?e.decisions??[]:e.decisions.slice(0,bR),m=e.clarification?.answers===void 0||s?e.clarification?.answers??[]:e.clarification.answers.slice(0,bR),h=e.contract===void 0||c?e.contract?.scope??[]:e.contract.scope.slice(0,bR),g=e.checkpoint===void 0||u?e.checkpoint?.items??[]:e.checkpoint.items.slice(0,bR),_=e.checkpoint?.generatedFiles===void 0||d?e.checkpoint?.generatedFiles??[]:e.checkpoint.generatedFiles.slice(0,bR);function v(e){i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,L.jsxs)(`div`,{className:J(`timeline-trace-card`,`is-${e.tone}`),children:[e.summary===void 0||e.result!==void 0?null:(0,L.jsx)(`p`,{className:`timeline-trace-summary`,children:e.summary}),t.length===0?null:(0,L.jsx)(`ol`,{className:`timeline-trace-path`,"aria-label":`Recorded task trace`,children:t.map(e=>(0,L.jsxs)(`li`,{className:`is-${e.tone}`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`}),(0,L.jsx)(`strong`,{children:e.label})]},e.id))}),e.origin===void 0?null:(0,L.jsxs)(pR,{label:`Origin`,children:[e.origin.title===void 0?null:(0,L.jsx)(`strong`,{className:`timeline-trace-title`,children:e.origin.title}),e.origin.summary===void 0?null:(0,L.jsx)(`p`,{children:e.origin.summary}),e.origin.unavailableReason===void 0?null:(0,L.jsx)(`small`,{className:`timeline-trace-muted`,children:e.origin.unavailableReason}),f.length>0?(0,L.jsx)(xR,{collapsedLabel:`Show ${f.length} source message${f.length===1?``:`s`}`,expanded:a,expandedLabel:`Show fewer source messages`,onClick:()=>v(`origin`)}):e.origin.sourceCount===void 0?null:(0,L.jsxs)(`small`,{className:`timeline-trace-muted`,children:[e.origin.sourceCount,` source message`,e.origin.sourceCount===1?``:`s`]}),!a||f.length===0?null:(0,L.jsx)(`ul`,{className:`timeline-trace-snippet-list`,children:f.map(e=>(0,L.jsx)(`li`,{className:`timeline-trace-snippet`,children:e.onClick===void 0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{children:[e.author,` · `,e.createdAt]}),(0,L.jsx)(`p`,{children:e.body})]}):(0,L.jsxs)(`button`,{className:`timeline-trace-snippet-button`,onClick:e.onClick,type:`button`,children:[(0,L.jsxs)(`span`,{children:[e.author,` · `,e.createdAt]}),(0,L.jsx)(`p`,{children:e.body})]})},e.id))})]}),e.decisions===void 0||e.decisions.length===0?null:(0,L.jsxs)(pR,{label:`Accepted Context`,children:[(0,L.jsx)(`ul`,{className:`timeline-trace-list`,children:p.map(e=>(0,L.jsxs)(`li`,{children:[e.title===void 0?null:(0,L.jsx)(ww,{tone:`neutral`,children:e.title}),(0,L.jsx)(`span`,{children:e.summary})]},e.id))}),(0,L.jsx)(SR,{expanded:o,hiddenCount:Math.max(e.decisions.length-bR,0),label:`context item`,onClick:()=>v(`decisions`)})]}),e.clarification===void 0?null:(0,L.jsxs)(pR,{label:`Clarification`,children:[e.clarification.title===void 0?null:(0,L.jsx)(`strong`,{className:`timeline-trace-title`,children:e.clarification.title}),e.clarification.summary===void 0?null:(0,L.jsx)(`p`,{children:e.clarification.summary}),e.clarification.request===void 0?null:(0,L.jsx)(`p`,{children:e.clarification.request}),e.clarification.status===void 0&&e.clarification.answerCount===void 0?null:(0,L.jsxs)(`div`,{className:`timeline-trace-inline`,children:[e.clarification.status===void 0?null:(0,L.jsx)(ww,{tone:e.clarification.status===`active`?`warning`:`success`,children:e.clarification.status===`active`?`needs input`:`resolved`}),e.clarification.answerCount===void 0?null:(0,L.jsxs)(`small`,{className:`timeline-trace-muted`,children:[e.clarification.answerCount,` answer`,e.clarification.answerCount===1?``:`s`]})]}),e.clarification.answers===void 0||e.clarification.answers.length===0?null:(0,L.jsx)(`ul`,{className:`timeline-trace-snippet-list`,children:m.map(e=>(0,L.jsx)(`li`,{className:`timeline-trace-snippet`,children:e.onClick===void 0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{children:[e.author,` · `,e.createdAt]}),(0,L.jsx)(`p`,{children:e.body})]}):(0,L.jsxs)(`button`,{className:`timeline-trace-snippet-button`,onClick:e.onClick,type:`button`,children:[(0,L.jsxs)(`span`,{children:[e.author,` · `,e.createdAt]}),(0,L.jsx)(`p`,{children:e.body})]})},e.id))}),e.clarification.answers===void 0?null:(0,L.jsx)(SR,{expanded:s,hiddenCount:Math.max(e.clarification.answers.length-bR,0),label:`answer`,onClick:()=>v(`clarification-answers`)})]}),e.contract===void 0?null:(0,L.jsxs)(pR,{label:`Contract`,children:[(0,L.jsx)(`p`,{children:e.contract.goal}),h.length===0?null:(0,L.jsx)(`ul`,{className:`timeline-trace-list is-bulleted`,children:h.map((e,t)=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`span`,{children:e})},`scope-${t}`))}),(0,L.jsx)(SR,{expanded:c,hiddenCount:Math.max(e.contract.scope.length-bR,0),label:`scope item`,onClick:()=>v(`scope`)}),c&&e.contract.truncated===!0?(0,L.jsx)(`small`,{className:`timeline-trace-muted`,children:`Additional scope items are outside this bounded audit preview.`}):null]}),e.result===void 0?null:(0,L.jsxs)(pR,{label:`Result`,children:[(0,L.jsx)(`p`,{children:e.result.summary}),e.result.errorCode===void 0?null:(0,L.jsx)(`code`,{className:`timeline-trace-code`,children:e.result.errorCode})]}),e.changes===void 0?null:(0,L.jsxs)(pR,{label:`Changes`,children:[e.changes.items.length===0?(0,L.jsx)(`p`,{className:`timeline-trace-muted`,children:`No repo changes recorded.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(xR,{collapsedLabel:`Show ${e.changes.items.length} file change${e.changes.items.length===1?``:`s`}`,expanded:l,expandedLabel:`Show fewer file changes`,onClick:()=>v(`changes`)}),l?(0,L.jsx)(`ul`,{className:`timeline-trace-diff-list`,children:e.changes.items.map(e=>(0,L.jsxs)(`li`,{className:`is-${e.status}`,children:[(0,L.jsx)(`span`,{className:`timeline-trace-diff-mark`,children:yR(e.status)}),(0,L.jsx)(`code`,{children:e.previousPath===void 0?e.path:`${e.previousPath} -> ${e.path}`})]},`${e.status}:${e.path}`))}):null]}),l&&e.changes.totalCount>e.changes.items.length?(0,L.jsxs)(`small`,{className:`timeline-trace-muted`,children:[e.changes.totalCount-e.changes.items.length,` additional files are outside this bounded audit preview.`]}):null]}),e.verification===void 0?null:(0,L.jsx)(pR,{label:`Verification`,children:(0,L.jsxs)(`div`,{className:`timeline-trace-inline`,children:[(0,L.jsx)(ww,{tone:hR(e.verification.checks),children:mR(e.verification.checks)}),(0,L.jsx)(`p`,{children:_R(e.verification)})]})}),e.promotion===void 0?null:(0,L.jsx)(pR,{label:`Promotion`,children:(0,L.jsxs)(`div`,{className:`timeline-trace-inline`,children:[(0,L.jsx)(ww,{tone:gR(e.promotion),children:mR(e.promotion.status)}),(0,L.jsx)(`p`,{children:vR(e.promotion)})]})}),e.checkpoint===void 0?null:(0,L.jsxs)(pR,{label:`Checkpoint`,children:[(0,L.jsxs)(`div`,{className:`timeline-trace-counters`,children:[(0,L.jsxs)(`span`,{children:[e.checkpoint.counters.completed,` completed`]}),(0,L.jsxs)(`span`,{children:[e.checkpoint.counters.failed,` failed`]}),(0,L.jsxs)(`span`,{children:[e.checkpoint.counters.remaining,` remaining`]})]}),(0,L.jsx)(`ul`,{className:`timeline-trace-list`,children:g.map(e=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(ww,{tone:e.status===`done`?`success`:`error`,children:e.status===`done`?`done`:`failed`}),(0,L.jsx)(`strong`,{children:e.title}),(0,L.jsx)(`span`,{children:e.summary})]},e.id))}),(0,L.jsx)(SR,{expanded:u,hiddenCount:Math.max(e.checkpoint.items.length-bR,0),label:`checkpoint item`,onClick:()=>v(`checkpoint`)}),e.checkpoint.generatedFiles===void 0||e.checkpoint.generatedFiles.length===0?null:(0,L.jsx)(`ul`,{className:`timeline-trace-file-list`,children:_.map(e=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`code`,{children:e.path})]},e.id))}),e.checkpoint.generatedFiles===void 0?null:(0,L.jsx)(SR,{expanded:d,hiddenCount:Math.max(e.checkpoint.generatedFiles.length-bR,0),label:`generated file`,onClick:()=>v(`generated-files`)}),(u||d)&&e.checkpoint.truncated===!0?(0,L.jsx)(`small`,{className:`timeline-trace-muted`,children:`Additional checkpoint evidence is outside this bounded audit preview.`}):null]}),n.length===0?null:(0,L.jsx)(pR,{label:`Links`,children:(0,L.jsx)(`div`,{className:`timeline-trace-links`,children:n.map(e=>(0,L.jsxs)(Y,{className:`timeline-trace-link`,onClick:e.onClick,type:`button`,children:[(0,L.jsx)(dx,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:e.label})]},e.id))})})]})}function TR({item:e,presentation:t=`panel`,expanded:n,active:r,onActivate:i,onToggle:a}){let o=e.trace,s=o!==void 0,c=e.tone??`neutral`,l=c===`error`?(0,L.jsx)(rS,{"aria-hidden":`true`}):c===`warning`?(0,L.jsx)(kx,{"aria-hidden":`true`}):c===`sync`?(0,L.jsx)(Cx,{"aria-hidden":`true`}):(0,L.jsx)(tx,{"aria-hidden":`true`});return(0,L.jsxs)(`li`,{className:J(`timeline-event-item`,s?`has-trace`:void 0,n?`is-expanded`:void 0,r?`is-current`:void 0,e.tone===void 0?void 0:`is-${e.tone}`),id:`timeline-event-${e.id}`,children:[t===`sheet`?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`time`,{className:`timeline-event-time`,children:e.occurredAt}),(0,L.jsx)(`div`,{className:`timeline-event-marker`,"aria-hidden":`true`})]}),(0,L.jsxs)(`div`,{className:`timeline-event-main`,children:[(0,L.jsxs)(`button`,{"aria-expanded":s&&t===`panel`?n:void 0,"aria-haspopup":s&&t===`sheet`?`dialog`:void 0,className:`timeline-event-toggle`,disabled:!s,onClick:()=>{i(),a?.()},type:`button`,children:[(0,L.jsx)(`span`,{className:J(`timeline-event-status-icon`,`is-${c}`),"aria-hidden":`true`,children:l}),(0,L.jsxs)(`span`,{className:`timeline-event-copy`,children:[(0,L.jsx)(`span`,{className:`timeline-event-stage`,children:e.stageLabel??(e.kind===`checkpoint`?`Checkpoint`:`Task event`)}),(0,L.jsxs)(`span`,{className:`timeline-event-title-line`,children:[(0,L.jsx)(`h4`,{children:e.taskTitle??e.title}),e.tokenLabel===void 0?null:(0,L.jsx)(`span`,{className:`timeline-event-token`,children:e.tokenLabel})]}),t===`sheet`?(0,L.jsx)(`time`,{className:`timeline-event-time`,children:e.occurredAt}):null]}),s?t===`sheet`?(0,L.jsx)(rx,{className:`timeline-event-chevron`,"aria-hidden":`true`}):(0,L.jsx)(nx,{className:`timeline-event-chevron`,"aria-hidden":`true`}):null]}),o!==void 0&&n?(0,L.jsx)(wR,{trace:o}):null]})]})}function ER(e){let t=new Map;for(let n of e){let e=n.taskId===void 0?`event:${n.id}`:`task:${n.taskId}`,r=t.get(e);r===void 0?t.set(e,{id:e,title:n.taskTitle??n.title,...n.taskId===void 0?{}:{taskId:n.taskId},items:[n]}):r.items.push(n)}return[...t.values()]}function DR({items:e,empty:t,className:n,...r}){let[i,a]=(0,I.useState)(),o=e.find(e=>e.id===i);return(0,L.jsxs)(mS,{title:`Timeline`,frameless:!0,className:J(`timeline-panel is-sheet`,n),...r,children:[(0,L.jsx)(`section`,{className:`timeline-events`,"aria-label":`Project timeline`,children:e.length===0?t:(0,L.jsx)(`ol`,{className:`timeline-event-list`,children:e.map(e=>(0,L.jsx)(TR,{item:e,presentation:`sheet`,expanded:!1,active:o?.id===e.id,onActivate:()=>a(e.id)},e.id))})}),(0,L.jsx)(OL,{open:o?.trace!==void 0,title:`Details`,onClose:()=>a(void 0),children:o?.trace===void 0?null:(0,L.jsxs)(`div`,{className:`timeline-sheet-detail`,children:[(0,L.jsxs)(`header`,{className:`timeline-sheet-detail-header`,children:[(0,L.jsx)(`h3`,{children:o.taskTitle??o.title}),(0,L.jsx)(`span`,{children:o.stageLabel??o.title}),(0,L.jsx)(`time`,{children:o.occurredAt})]}),(0,L.jsx)(wR,{trace:o.trace})]},o.id)})]})}function OR({presentation:e=`panel`,tokenOverview:t,scoreUnits:n=[],defaultExpandedItemIds:r=[],...i}){return e===`sheet`?(0,L.jsx)(DR,{...i}):(0,L.jsx)(kR,{...i,tokenOverview:t,scoreUnits:n,defaultExpandedItemIds:r})}function kR({tokenOverview:e,items:t,scoreUnits:n=[],empty:r,defaultExpandedItemIds:i,className:a,...o}){let[s,c]=(0,I.useState)(()=>new Set(i??[])),[l,u]=(0,I.useState)(()=>n.at(-1)?.id),[d,f]=(0,I.useState)(0),p=(0,I.useRef)(null),m=ER(t),h=new Set(t.flatMap(e=>e.taskId===void 0?[]:[e.taskId])).size;(0,I.useEffect)(()=>{if(n.length===0){u(void 0);return}(l===void 0||!n.some(e=>e.id===l))&&u(n.at(-1)?.id)},[l,n]),(0,I.useEffect)(()=>{let e=p.current;if(e===null)return;let t=e;t.scrollLeft=t.scrollWidth;function n(e){if(Math.abs(e.deltaY)<=Math.abs(e.deltaX))return;let n=Math.max(0,t.scrollWidth-t.clientWidth),r=Math.min(n,Math.max(0,t.scrollLeft+e.deltaY));r!==t.scrollLeft&&(e.preventDefault(),t.scrollLeft=r)}return t.addEventListener(`wheel`,n,{passive:!1}),()=>t.removeEventListener(`wheel`,n)},[n.length]),(0,I.useEffect)(()=>{let e=p.current;if(e===null)return;let t=()=>f(e.clientWidth);if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[n.length]);function g(e,t=!1){u(e),t&&(c(t=>new Set(t).add(e)),window.requestAnimationFrame(()=>{document.getElementById(`timeline-event-${e}`)?.scrollIntoView({behavior:`smooth`,block:`center`})}))}function _(e){c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,L.jsx)(mS,{className:J(`timeline-panel`,a),title:`Timeline`,icon:(0,L.jsx)(ex,{"aria-hidden":`true`}),...o,children:(0,L.jsxs)(`div`,{className:`timeline-board-body`,children:[(0,L.jsxs)(`section`,{className:`timeline-events`,"aria-label":`Project timeline`,children:[(0,L.jsx)(`div`,{className:`timeline-audit-header`,children:(0,L.jsxs)(`div`,{className:`timeline-audit-intro`,children:[(0,L.jsx)(`h4`,{children:`Task traceability`}),(0,L.jsxs)(`div`,{className:`timeline-audit-meta`,"aria-label":`Timeline record summary`,children:[(0,L.jsx)(`span`,{children:h===1?`1 task`:`${h} tasks`}),(0,L.jsx)(`span`,{children:t.length===1?`1 record`:`${t.length} records`})]})]})}),t.length===0?r:(0,L.jsx)(`div`,{className:`timeline-task-groups`,children:m.map(e=>(0,L.jsxs)(`section`,{className:`timeline-task-group`,"aria-label":e.title,children:[(0,L.jsxs)(`header`,{className:`timeline-task-group-head`,children:[(0,L.jsx)(`span`,{children:e.taskId===void 0?`Project record`:`Task trace`}),(0,L.jsx)(`strong`,{children:e.title})]}),(0,L.jsx)(`ol`,{className:`timeline-event-list`,children:e.items.map(e=>(0,L.jsx)(TR,{active:l===e.id,expanded:s.has(e.id),item:e,onActivate:()=>g(e.id),onToggle:()=>_(e.id)},e.id))})]},e.id))})]}),(0,L.jsxs)(`section`,{className:`timeline-overview`,"aria-label":`Timeline score and token usage`,children:[n.length===0?null:(0,L.jsx)(`div`,{className:`timeline-score-index`,ref:p,role:`group`,"aria-label":`Timeline score index`,children:(0,L.jsx)(lC,{"aria-label":`Timeline event score`,...l===void 0?{}:{activeUnitId:l},edgePadding:0,minimumWidth:d,onUnitSelect:e=>g(e,!0),openingBarline:`double`,openingClef:`treble`,horizontalSpacingScale:mC,reveal:!0,scale:fC,units:n})}),(0,L.jsxs)(`div`,{className:`timeline-overview-token`,"aria-label":`Total tokens`,children:[(0,L.jsx)(`span`,{children:`Total tokens`}),(0,L.jsx)(`strong`,{children:e.totalLabel})]})]})]})})}function AR({value:e,pending:t,canSubmit:n,onChange:r,onSubmit:i,feedback:a}){let o=(0,I.useId)();return(0,L.jsxs)(`form`,{className:`embedded-connection-form`,onSubmit:e=>{e.preventDefault(),n&&!t&&i()},children:[(0,L.jsx)(`h2`,{children:`Connect Tutti`}),(0,L.jsx)(Fw,{label:`Connection code or command`,htmlFor:o,children:(0,L.jsx)(jw,{id:o,name:`connection`,value:e,onChange:e=>r(e.target.value),placeholder:`Paste from Local Console`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,maxLength:256,disabled:t,required:!0})}),(0,L.jsx)(Cw,{type:`submit`,disabled:t||!n,children:t?`Connecting…`:`Connect`}),a]})}var jR=`/assets/Tutti-square-BqFU7F0D.png`,MR=`/assets/Tutti-B7gEyTp1.png`,NR=`/assets/tutti_avatar-_0Yc-cMJ.png`,PR=`/assets/avatar-avery-CkLXb185.svg`,FR=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2080%2080'%20fill='none'%20shape-rendering='auto'%20aria-hidden='true'%3e%3c!--%20Generated%20by%20DiceBear%20(https://dicebear.com)%20--%3e%3cmetadata%20xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23'%20xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'%20xmlns:dc='http://purl.org/dc/elements/1.1/'%20xmlns:dcterms='http://purl.org/dc/terms/'%3e%3crdf:RDF%3e%3crdf:Description%3e%3cdc:title%3eDylan!%20The%20Avatar%20Generator%3c/dc:title%3e%3cdc:creator%3eNatalia%20Spivak%3c/dc:creator%3e%3cdc:source%20xsi:type='dcterms:URI'%3ehttps://www.figma.com/community/file/1356575240759683500%3c/dc:source%3e%3cdcterms:license%20xsi:type='dcterms:URI'%3ehttps://creativecommons.org/licenses/by/4.0/%3c/dcterms:license%3e%3cdc:rights%3eRemix%20of%20“Dylan!%20The%20Avatar%20Generator”%20(https://www.figma.com/community/file/1356575240759683500)%20by%20“Natalia%20Spivak”,%20licensed%20under%20“CC%20BY%204.0”%20(https://creativecommons.org/licenses/by/4.0/)%3c/dc:rights%3e%3c/rdf:Description%3e%3c/rdf:RDF%3e%3c/metadata%3e%3cdefs%3e%3cg%20id='mood-happy-7dff0831'%3e%3cpath%20d='M.04%2017.04c2.41%209.29%2015.16%2012.28%2022.34%206.67a14%2014%200%200%200%204.7-7.22c.36-1.28-1.57-1.8-1.93-.57-1.24%204.23-4.33%207.4-8.68%208.33-3.77.8-8.03-.1-11.05-2.52a10%2010%200%200%201-3.45-5.26c-.32-1.25-2.25-.72-1.93.53'%20fill='black'/%3e%3c/g%3e%3cg%20id='hair-shortCurls-7dff0831'%3e%3cpath%20d='m15.3%2027.49%201.58%204.38%201.06-9.52s2.27%201.27%203.44-.26.16-3.47.16-3.47%201.81.55%203.31-.8c1.87-1.67%201.26-3.46%201.26-3.46s1.71%201.9%204.5%201.1c2.77-.8%203.14-2.76%203.14-2.76s.56%202.18%203.4%202.12%203.2-2.01%203.2-2.01%200%202.43%202.43%203.14%203.43-1.24%203.43-1.24c0%20.02-.9%202.39.66%203.76%201.44%201.26%203.5.35%203.5.35s-.73%202.3.77%203.62c1.6%201.4%203.48.6%203.48.6l.77%208.34%201.8-3.8s1.4-.13%202.72.15c0%20.01%202.58-2.78%201.15-5.9s-3.64-2.86-3.64-2.86%201.95-3.05.13-5.65-4.94-1.96-4.94-1.96%201.18-3.52-1.68-5.27-5.92.46-5.92.46-.1-3.7-3.2-4.16c-3.26-.48-4.58%202.66-4.58%202.66s-1.35-2.89-4.14-2.44c-2.8.44-3.32%203.53-3.32%203.53S27.32%203.57%2024.92%205s-1.8%204.51-1.8%204.51-2.98-2.24-5.32-.23-.14%205.1-.14%205.1-3.87-1.12-5.04%201.8%201.66%204.95%201.66%204.95-5.35%201.16-2.82%207.33c0%200%20.6-.27%202.02-.62s1.8-.38%201.8-.38z'%20fill='%23000000'/%3e%3c/g%3e%3cclipPath%20id='clip-7dff0831'%3e%3crect%20width='80'%20height='80'%20rx='0'%20ry='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23clip-7dff0831)'%3e%3crect%20width='80'%20height='80'%20fill='%23e5f4ec'/%3e%3cpath%20d='M19.07%2030.47s1.57-20.23%2021.59-20.23S62.3%2030.55%2062.3%2030.55s9.43-.8%209.43%207.6c0%208.42-9.28%207.13-9.28%207.13S60.9%2067.15%2042.03%2067.15c-21.11%200-23.4-20.8-23.4-20.8s-9%20.72-9.93-6.25c-1.08-8.2%2010.37-9.64%2010.37-9.64'%20fill='%23c26450'/%3e%3cpath%20d='m64.3%2039.49.46-.41.1-.09c.12-.1-.13.1-.02.02l.24-.17q.5-.35%201.06-.62l.26-.12.05-.02.05-.02.58-.21q.6-.18%201.2-.28c.52-.08.85-.76.7-1.23-.18-.56-.67-.8-1.23-.7a9.3%209.3%200%200%200-4.87%202.43c-.38.36-.4%201.06%200%201.4.4.36%201%20.4%201.4%200zm-51.8-1.16.14.01c-.27-.02-.11-.01-.04%200l.3.05.52.14.28.09.12.05c.02%200%20.22.09.06.02-.14-.1%200-.04.03-.03l.15.06.26.13.47.3.27.22q.47.38.83.83c.33.4%201.07.37%201.41%200%20.4-.43.36-.98%200-1.4a7.3%207.3%200%200%200-4.84-2.53c-.52-.06-1.02.5-1%201%20.03.59.44.94%201%201m18.3-1.9v4.54c0%20.52.46%201.02%201%201s1-.44%201-1V36.4c0-.52-.46-1.02-1-1s-1%20.44-1%201M49.2%2036l-.15%204.81a1%201%200%200%200%201%201c.56-.02.98-.44%201-1l.15-4.8a1%201%200%200%200-1-1%201%201%200%200%200-1%201'%20fill='black'/%3e%3cuse%20transform='translate(27.82%2026.75)'%20href='%23mood-happy-7dff0831'/%3e%3cuse%20transform='translate(3.78%202.95)'%20href='%23hair-shortCurls-7dff0831'/%3e%3c/g%3e%3c/svg%3e`,IR=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2080%2080'%20fill='none'%20shape-rendering='auto'%20aria-hidden='true'%3e%3c!--%20Generated%20by%20DiceBear%20(https://dicebear.com)%20--%3e%3cmetadata%20xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23'%20xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'%20xmlns:dc='http://purl.org/dc/elements/1.1/'%20xmlns:dcterms='http://purl.org/dc/terms/'%3e%3crdf:RDF%3e%3crdf:Description%3e%3cdc:title%3eDylan!%20The%20Avatar%20Generator%3c/dc:title%3e%3cdc:creator%3eNatalia%20Spivak%3c/dc:creator%3e%3cdc:source%20xsi:type='dcterms:URI'%3ehttps://www.figma.com/community/file/1356575240759683500%3c/dc:source%3e%3cdcterms:license%20xsi:type='dcterms:URI'%3ehttps://creativecommons.org/licenses/by/4.0/%3c/dcterms:license%3e%3cdc:rights%3eRemix%20of%20“Dylan!%20The%20Avatar%20Generator”%20(https://www.figma.com/community/file/1356575240759683500)%20by%20“Natalia%20Spivak”,%20licensed%20under%20“CC%20BY%204.0”%20(https://creativecommons.org/licenses/by/4.0/)%3c/dc:rights%3e%3c/rdf:Description%3e%3c/rdf:RDF%3e%3c/metadata%3e%3cdefs%3e%3cg%20id='mood-happy-46c131e2'%3e%3cpath%20d='M.04%2017.04c2.41%209.29%2015.16%2012.28%2022.34%206.67a14%2014%200%200%200%204.7-7.22c.36-1.28-1.57-1.8-1.93-.57-1.24%204.23-4.33%207.4-8.68%208.33-3.77.8-8.03-.1-11.05-2.52a10%2010%200%200%201-3.45-5.26c-.32-1.25-2.25-.72-1.93.53'%20fill='black'/%3e%3c/g%3e%3cg%20id='hair-fluffy-46c131e2'%3e%3cpath%20d='M16.45%2029.48s13.74%2023.53%203.86%2028.24C9.05%2063.08-1.2%2048.01.1%2036.77s10.96-16.35%2010.96-16.35-.58-9.5%209.2-15.04c9.78-5.55%2016.64.44%2016.64.44s8.06-5.9%2015.5-1.37c7.46%204.53%207.26%2014.68%207.26%2014.68s13.74-.56%2013.65%2016.47c-.08%2015.17-10.03%2022.94-16.8%2021.6-10.45-2.07%201.27-29.22%201.27-29.22s-14.4%201.04-20.14-9.75c0%200-4%205.95-9.7%208.62a32%2032%200%200%201-11.47%202.64z'%20fill='%231d5dff'/%3e%3c/g%3e%3cclipPath%20id='clip-46c131e2'%3e%3crect%20width='80'%20height='80'%20rx='0'%20ry='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23clip-46c131e2)'%3e%3crect%20width='80'%20height='80'%20fill='%23fbf0d1'/%3e%3cpath%20d='M19.07%2030.47s1.57-20.23%2021.59-20.23S62.3%2030.55%2062.3%2030.55s9.43-.8%209.43%207.6c0%208.42-9.28%207.13-9.28%207.13S60.9%2067.15%2042.03%2067.15c-21.11%200-23.4-20.8-23.4-20.8s-9%20.72-9.93-6.25c-1.08-8.2%2010.37-9.64%2010.37-9.64'%20fill='%23c26450'/%3e%3cpath%20d='m64.3%2039.49.46-.41.1-.09c.12-.1-.13.1-.02.02l.24-.17q.5-.35%201.06-.62l.26-.12.05-.02.05-.02.58-.21q.6-.18%201.2-.28c.52-.08.85-.76.7-1.23-.18-.56-.67-.8-1.23-.7a9.3%209.3%200%200%200-4.87%202.43c-.38.36-.4%201.06%200%201.4.4.36%201%20.4%201.4%200zm-51.8-1.16.14.01c-.27-.02-.11-.01-.04%200l.3.05.52.14.28.09.12.05c.02%200%20.22.09.06.02-.14-.1%200-.04.03-.03l.15.06.26.13.47.3.27.22q.47.38.83.83c.33.4%201.07.37%201.41%200%20.4-.43.36-.98%200-1.4a7.3%207.3%200%200%200-4.84-2.53c-.52-.06-1.02.5-1%201%20.03.59.44.94%201%201m18.3-1.9v4.54c0%20.52.46%201.02%201%201s1-.44%201-1V36.4c0-.52-.46-1.02-1-1s-1%20.44-1%201M49.2%2036l-.15%204.81a1%201%200%200%200%201%201c.56-.02.98-.44%201-1l.15-4.8a1%201%200%200%200-1-1%201%201%200%200%200-1%201'%20fill='black'/%3e%3cuse%20transform='translate(27.82%2026.75)'%20href='%23mood-happy-46c131e2'/%3e%3cuse%20transform='translate(3.78%202.95)'%20href='%23hair-fluffy-46c131e2'/%3e%3c/g%3e%3c/svg%3e`,LR=`/assets/ode-to-joy-SNBUPr3-.svg`,RR=jR,zR=MR,BR=NR,VR={logoSrc:MR,tuttiAvatarSrc:NR,scoreSrc:LR,humanAvatars:{fey:FR,avery:PR,jun:IR}};function HR({onClick:e}){let t=(0,L.jsx)(Ow,{src:zR,label:`Tutti`});return e===void 0?t:(0,L.jsx)(Aw,{logo:t,label:`Tutti Project Center`,onClick:e})}function UR({onClick:e,label:t}){return(0,L.jsx)(Aw,{logo:(0,L.jsx)(Ow,{src:zR,className:`tutti-logo`}),...t===void 0?{}:{label:t},onClick:e})}function WR({diagnostic:e,showMessage:t=!0}){let n=[[`Diagnostic ID`,e.diagnosticId],[`Web release`,e.webRelease],[`Stage`,e.stage],[`Request`,e.stage===`document_input_validation`?`Local validation (not sent)`:void 0],[`Error kind`,e.errorKind],[`HTTP status`,e.httpStatus?.toString()],[`Reason code`,e.reasonCode],[`Platform stage`,e.platformStage],[`Platform code`,e.platformCode?.toString()]].filter(e=>e[1]!==void 0);return(0,L.jsx)(DL,{...t?{message:e.message}:{},diagnosticId:e.diagnosticId,rows:n.filter(([e])=>e!==`Diagnostic ID`),onCopy:()=>navigator.clipboard.writeText([e.message,...n.map(([e,t])=>`${e}: ${t}`)].join(`
|
|
69
|
-
`))},e.diagnosticId)}function GR({loading:e,pending:t,unbound:n,value:r,canSubmit:i,error:a,onChange:o,onConnect:s,onRefresh:c}){let l=a===void 0?void 0:(0,L.jsx)(WR,{diagnostic:a});return(0,L.jsx)(EL,{brand:(0,L.jsx)(UR,{label:`Tutti`}),projectName:`Connect Tutti`,showProjectName:!1,refreshing:e||t,onRefresh:c,children:e?(0,L.jsx)(oS,{count:3}):n?(0,L.jsx)(AR,{value:r,pending:t,canSubmit:i,onChange:o,onSubmit:s,feedback:l}):(0,L.jsx)(aS,{details:l,children:`Connection entry unavailable.`})})}var KR=`https://lf1-cdn-tos.bytegoofy.com/goofy/lark/op/h5-js-sdk-1.5.48.js`,qR=15e3,JR=[fg],YR=class extends Error{constructor(e,t,n,r){super(e.replaceAll(`_`,` `)),this.code=e,this.stage=t,this.errno=n,this.platformDetail=r,this.name=`FeishuH5AuthorizationError`}};function XR(e){let t=[];typeof e.errCode==`number`&&Number.isSafeInteger(e.errCode)&&t.push(`errCode ${e.errCode}`);for(let n of[e.errString,e.errMsg]){if(typeof n!=`string`)continue;let e=Array.from(n,e=>{let t=e.charCodeAt(0);return t<=31||t===127?` `:e}).join(``).replace(/\s+/gu,` `).trim();e!==``&&!t.includes(e)&&t.push(e)}if(t.length===0)return;let n=t.join(` · `);return n.length<=180?n:`${n.slice(0,177)}...`}function ZR(e){return typeof e.errno==`number`&&Number.isSafeInteger(e.errno)?e.errno:void 0}function QR(e,t){return new Promise((n,r)=>{let i=!1,a=!1,o=!1,s=e=>{i||(i=!0,clearTimeout(c),`error`in e?r(e.error):n(e.code))},c=setTimeout(()=>s({error:new YR(`client_unavailable`)}),t.timeoutMs??qR),l=()=>{if(!(a||i)){if(a=!0,e.allowLegacyFallback===!1){s({error:new YR(`request_failed`,`request_access`)});return}if(t.client.requestAuthCode===void 0){s({error:new YR(o?`request_failed`:`client_unavailable`,o?`request_access`:`request_auth_code`)});return}t.client.requestAuthCode({appId:e.appId,success:e=>{typeof e.code!=`string`||e.code.trim()===``?s({error:new YR(`request_failed`,`request_auth_code`)}):s({code:e.code})},fail:e=>s({error:new YR(`request_failed`,`request_auth_code`,ZR(e),XR(e))})})}},u=()=>{if(!(o||i)){if(o=!0,t.client.requestAccess===void 0){l();return}t.client.requestAccess({appID:e.appId,scopeList:[...e.scopes??JR],state:e.state,success:t=>{if(typeof t.code!=`string`||t.code.trim()===``){s({error:new YR(`request_failed`,`request_access`)});return}if(t.state!==void 0&&t.state!==e.state){s({error:new YR(`state_mismatch`,`request_access`)});return}s({code:t.code})},fail:e=>{let t=ZR(e);if(t===103){l();return}s({error:new YR(`request_failed`,`request_access`,t,XR(e))})}})}};t.sdk===void 0?u():(t.sdk.error(e=>{s({error:new YR(`request_failed`,`sdk`,ZR(e))})}),t.sdk.ready(u))})}var $R=null;function ez(e){return e.tt===void 0?null:{client:e.tt,...e.h5sdk===void 0?{}:{sdk:e.h5sdk}}}function tz(e=window,t=document){let n=ez(e);if(n!==null)return Promise.resolve(n);if($R!==null)return $R;let r=new Promise((n,r)=>{let i=t.createElement(`script`),a=setTimeout(()=>{i.remove(),r(new YR(`client_unavailable`))},qR);i.async=!0,i.crossOrigin=`anonymous`,i.src=KR,i.onload=()=>{clearTimeout(a);let t=ez(e);t===null?r(new YR(`client_unavailable`)):n(t)},i.onerror=()=>{clearTimeout(a),r(new YR(`client_unavailable`))},t.head.append(i)}).catch(e=>{throw $R=null,e});return $R=r,r}async function nz(e){return await QR(e,await tz())}var rz=`scratchpad-submit-1`,iz=class extends Error{constructor(e,t,n){super(e.replaceAll(`_`,` `)),this.stage=e,this.cause=t,this.diagnostics=n,this.name=`FeishuProjectOpenError`}};function az(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID().replaceAll(`-`,``);if(typeof globalThis.crypto?.getRandomValues==`function`){let e=new Uint8Array(16);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`.padEnd(16,`0`)}function oz(){let e={diagnosticId:`fdiag_${az()}`,webRelease:rz};if(!kn(e.diagnosticId)||!An(e.webRelease))throw Error(`Feishu diagnostics could not be initialized`);return e}function sz(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cz(e){return typeof e==`string`&&/^[a-z][a-z0-9_]{0,95}$/u.test(e)?e:void 0}function lz(e){let t=e,n=new Set;for(;t instanceof iz&&!n.has(t);)n.add(t),t=t.cause;return t}function uz(e){if(e instanceof iz){if(e.cause instanceof YR){if(e.stage===`document_authorization_request_access`)return e.stage;if(e.cause.stage===`sdk`)return`h5_sdk`;if(e.cause.stage===`request_auth_code`)return`h5_request_auth_code`;if(e.cause.stage===`request_access`)return`h5_request_access`}return e.stage}return e instanceof YR?e.stage===`sdk`?`h5_sdk`:e.stage===`request_auth_code`?`h5_request_auth_code`:`h5_request_access`:`browser_runtime`}function dz(e,t){return e instanceof iz&&e.diagnostics!==void 0?e.diagnostics:t}function fz(e){return sz(e.details)?cz(e.details.reason_code)??e.code:e.code}function pz(e){let t=lz(e);if(e instanceof iz&&e.stage.startsWith(`connection_`)){let e=t instanceof Gt?fz(t):void 0;return e===`connection_input_invalid`?`Paste a connection code or the full /tutti connect command.`:e===`pairing_code_invalid_or_expired`||e===`pairing_code_already_consumed`?`Get a current connection code from Local Console and try again.`:e===`connection_state_invalid_or_expired`?`This authorization attempt expired. Click Connect to try again.`:e===`connection_entry_unavailable`?`This group entry is unavailable. Send /tutti connect in the group to request the current entry.`:e?.includes(`bound`)||e?.includes(`binding`)?`This group or project already has a connection, or its connection is unavailable. Refresh to check. Existing connections will not be replaced.`:`Tutti could not verify or connect this group. Refresh to check its current connection; share the diagnostics if it persists.`}if(e instanceof iz&&e.stage===`reference_authorization_status`){let e=t instanceof Gt?fz(t):void 0;return e===`reference_owner_required`?`Ask the project owner to open this access request.`:e===`reference_authorization_not_found`?`This access request is no longer available. Ask Tutti to try reading again.`:`Document access could not be checked. Refresh this entry and share the diagnostics if it persists.`}if(t instanceof Gt&&t.code===`response_parse_error`)return`Tutti received an unexpected server response. Refresh to try again; if it persists, share the diagnostics.`;if(e instanceof iz){if([`skills_list`,`skill_detail`,`project_timeline`].includes(e.stage)){let t=lz(e),n=t instanceof Gt?fz(t):void 0;return n===`host_read_surfaces_unsupported`?`Update the project's local Tutti runtime to view this section.`:n===`skill_read_limit_exceeded`?`These skills exceed the sidebar read limit. No partial instructions are shown.`:t instanceof Gt&&t.statusCode===503?`The project’s local Tutti runtime is offline or temporarily unavailable.`:t instanceof Gt&&(t.statusCode===401||t.statusCode===403)?`Project access could not be verified. Reopen the project from Feishu.`:t instanceof Gt&&t.statusCode===404&&t.code!==`response_parse_error`?`This content is no longer available. Refresh this section to check again.`:`This section could not be loaded. Refresh to try again.`}if(e.stage===`external_reference_register`||e.stage===`external_reference_list`){let t=e.cause instanceof Gt?fz(e.cause):void 0;return e.stage===`external_reference_list`&&e.cause instanceof Gt&&[401,403].includes(e.cause.statusCode)?`Project access could not be verified. Reopen the project from Feishu.`:t?.startsWith(`reference_submission_`)?`This Reference request is no longer available. Reload References; submit the link again if the request expired.`:t===`reference_source_limit_reached`?`The project has reached its Reference source limit. Existing sources are unchanged.`:t===`reference_owner_required`?`Only the project Owner can add References.`:t===`reference_link_invalid`?`Use a standard Feishu Docx, Wiki or cloud file link.`:t===`feishu_user_drive_scope_missing`?`Authorize cloud file downloads and try again.`:t===`feishu_user_authorization_required`?`The Owner needs to authorize access, then retry this request.`:t===`document_wiki_type_unsupported`?`This Wiki node is not a Docx document. Use a direct cloud file link for ordinary files.`:`The Reference request could not be completed. Reload the list and try again; existing sources are unchanged.`}if(e.stage===`reference_summary_refresh`)return`The summary retry could not be requested. Your document connection and local snapshot are unchanged. Try again.`;if([`document_list`,`document_connect`,`document_refresh`].includes(e.stage)){let t=e.cause instanceof Gt?fz(e.cause):void 0;return t===`document_link_invalid`?`Use a Feishu Docx or Wiki link, or the actual Docx document ID.`:t===`document_wiki_authorization_required`?`Authorize Wiki node access and Feishu Docs, then try connecting again.`:t===`document_wiki_type_unsupported`?`This Wiki node is not a Docx document. Sheets and other resource types are not supported yet.`:t===`document_wiki_not_found`?`The Wiki node could not be found. Check the copied link.`:t===`document_wiki_access_denied`?`Your Feishu account cannot read this Wiki node. Check its sharing settings.`:t===`document_wiki_busy`?`Another Wiki connection is being checked. Try again shortly.`:t===`document_owner_required`?`Only the project Owner can connect or refresh documents.`:t===`document_authorization_required`?`Authorize Feishu Docs and try again.`:t===`document_source_limit_reached`?`This project has reached its document connection limit.`:t===`document_source_not_found`?`This document connection is no longer available. Reload the list.`:`The document request could not be completed. Your existing reference snapshots are unchanged. Try again.`}return(e.stage===`document_authorization_bootstrap`||e.stage===`document_authorization_exchange`)&&e.cause instanceof Gt?`Feishu could not authorize document access. Reopen this entry and try again.`:e.stage===`authorization_exchange`&&e.cause instanceof Gt&&(e.cause.statusCode===401||e.cause.statusCode===403||e.cause.statusCode===503)?`Feishu could not verify your identity or project group access. Try again after the app permissions are available.`:e.stage===`host_bootstrap`&&e.cause instanceof Gt&&e.cause.statusCode===503?`The project’s local Tutti runtime is offline or temporarily unavailable.`:e.stage===`browser_session_restore`?`This browser session expired. Reopen the project from Feishu and start the browser fallback again.`:e.stage===`browser_handoff_consume`?`This browser handoff expired or was already used. Reopen the project from Feishu and try again.`:pz(e.cause)}if(e instanceof YR){if(e.code===`client_unavailable`)return`Open this project through the Feishu app entry, not a regular browser link.`;if(e.code===`state_mismatch`)return`This Feishu authorization request expired. Try again.`;let t=[e.stage,e.errno===void 0?void 0:`errno ${e.errno}`,e.platformDetail].filter(e=>e!==void 0).join(`, `);return`Feishu could not authorize this app${t===``?``:` (${t})`}. Reopen it from Feishu and try again.`}return e instanceof Gt&&e.statusCode===403?`Your Feishu account must belong to the project group.`:e instanceof Gt&&e.statusCode===401?`Your project session expired. Reopen the project from Feishu.`:e instanceof Gt&&e.statusCode===429?`Too many requests. Wait a moment, then try again.`:e instanceof Gt&&e.statusCode===503?`The project’s local Tutti runtime is offline or temporarily unavailable.`:e instanceof Gt&&e.statusCode===404?`This project is no longer connected to the current Feishu group.`:e instanceof Gt&&e.statusCode>=500?`Tutti could not complete this request. Try again; if it persists, share the diagnostics.`:`Check your Feishu connection and try again.`}function mz(e,t){let n=gz(e,t);return`${n.message} Diagnostic ID: ${n.diagnosticId} · ${n.webRelease} · ${n.stage} · ${n.reasonCode??n.errorKind}${n.httpStatus===void 0?``:` · HTTP ${n.httpStatus}`}`}async function hz(e,t){let n=oz();try{return await t(n)}catch(t){throw new iz(e,t,n)}}function gz(e,t){let n=lz(e),r={...dz(e,t),message:pz(e),stage:uz(e)};if(n instanceof Gt){let e=sz(n.details)?n.details:void 0,t=cz(e?.authorization_stage),i=e?.platform_code;return{...r,errorKind:n.code,...n.statusCode<=0?{}:{httpStatus:n.statusCode},reasonCode:fz(n),...t===void 0?{}:{platformStage:t},...typeof i==`number`&&Number.isSafeInteger(i)?{platformCode:i}:{}}}return n instanceof YR?{...r,errorKind:n.code,reasonCode:n.code,...n.errno===void 0?{}:{platformCode:n.errno}}:n instanceof TypeError?{...r,errorKind:`unexpected_type_error`,reasonCode:`unexpected_type_error`}:{...r,errorKind:`unexpected_error`,reasonCode:`unexpected_error`}}var _z={success:3e3,error:9e3,warning:6e3,info:4500},vz=5,yz=(0,I.createContext)(null);function bz(e){return e.persistent===!0||e.tone===`loading`?e.durationMs:e.durationMs??_z[e.tone]}function xz(e){return e.persistent??e.tone===`loading`}function Sz(e){return e.dismissible??e.tone!==`loading`}function Cz(e,t){let n=bz(t);return{id:e,tone:t.tone,title:t.title,persistent:xz(t),dismissible:Sz(t),...t.message===void 0?{}:{message:t.message},...n===void 0?{}:{durationMs:n}}}function wz(e,t){let n=t.tone===void 0,r={tone:t.tone??e.tone,title:t.title??e.title,...t.message===void 0?e.message===void 0?{}:{message:e.message}:{message:t.message},...t.durationMs===void 0?!n||e.durationMs===void 0?{}:{durationMs:e.durationMs}:{durationMs:t.durationMs},...t.persistent===void 0?!n||e.persistent===void 0?{}:{persistent:e.persistent}:{persistent:t.persistent},...t.dismissible===void 0?!n||e.dismissible===void 0?{}:{dismissible:e.dismissible}:{dismissible:t.dismissible}};return Cz(e.id,r)}function Tz(e){return[e.id,e.tone,e.title,e.message??``,e.durationMs??``,e.persistent===!0?`persistent`:`timed`].join(`:`)}function Ez({children:e}){let[t,n]=(0,I.useState)([]),r=(0,I.useRef)(new Map),i=(0,I.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]),a=(0,I.useCallback)(e=>{let t=Ht(),r=Cz(t,e);return n(e=>[...e,r].slice(-vz)),t},[]),o=(0,I.useCallback)((e,t)=>{if(e===void 0){a(t);return}n(n=>n.map(n=>n.id===e?wz(n,t):n))},[a]);(0,I.useEffect)(()=>{let e=new Set(t.map(e=>e.id));for(let[t,n]of r.current)e.has(t)||(window.clearTimeout(n.timeout),r.current.delete(t));for(let e of t){let t=r.current.get(e.id),n=Tz(e);if(t!==void 0&&t.key!==n&&(window.clearTimeout(t.timeout),r.current.delete(e.id)),e.persistent===!0||e.durationMs===void 0||r.current.has(e.id))continue;let a=window.setTimeout(()=>i(e.id),e.durationMs);r.current.set(e.id,{key:n,timeout:a})}},[i,t]),(0,I.useEffect)(()=>()=>{for(let e of r.current.values())window.clearTimeout(e.timeout);r.current.clear()},[]);let s=(0,I.useMemo)(()=>({notify:a,update:o,dismiss:i}),[i,a,o]);return(0,L.jsxs)(yz.Provider,{value:s,children:[e,(0,L.jsx)(dS,{notices:t,onDismiss:i})]})}function Dz(){let e=(0,I.useContext)(yz);if(e===null)throw Error(`useNotify must be used inside NotificationProvider`);return e}var Oz=`en-US`;function kz(e){if(e===void 0)return`Never`;let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString(Oz,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}):e}function Az(e){if(e===void 0)return`Unknown`;let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleDateString(Oz,{month:`short`,day:`numeric`,year:`numeric`}):`Unknown`}function jz(e,t=new Date){let n=new Date(e);if(!Number.isFinite(n.getTime()))return e;if(n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()){let e=Math.max(0,Math.floor((t.getTime()-n.getTime())/6e4));return e<1?`now`:e<60?`${e}m`:`${Math.floor(e/60)}h`}return n.toLocaleString(Oz,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function Mz(e){return e.toString().padStart(2,`0`)}function Nz(e){if(e===void 0)return`Never`;let t=new Date(e);return Number.isFinite(t.getTime())?`${t.getFullYear()}-${Mz(t.getMonth()+1)}-${Mz(t.getDate())} ${Mz(t.getHours())}:${Mz(t.getMinutes())}`:e}function Pz(e){let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleTimeString(Oz,{hour:`2-digit`,minute:`2-digit`}):``}function Fz(e){switch(e){case`online`:return`Host online`;case`offline`:return`Host offline`;case`unknown`:return`Host unknown`}}function Iz(e){return{...{running:{label:`Running`,tone:`sync`},pending:{label:`Needs input`,tone:`warning`},failed:{label:`Needs attention`,tone:`error`},idle:{label:`Idle`,tone:`neutral`}}[e.status],summary:e.summary}}function Lz(e){return{relayProjectRef:e.relay_project_ref,displayName:e.display_name,hostStatus:e.host_status,surface:e.surface,membershipLabel:e.role===`owner`?`Owner`:`Member`,lastOpenedLabel:kz(e.last_opened_at),canOpen:e.surface===`standalone`&&e.host_status===`online`}}function Rz(e){return{elementKind:e.element_kind,tagName:e.tag_name,...e.role===void 0?{}:{role:e.role},...e.accessible_name===void 0?{}:{accessibleName:e.accessible_name},...e.text_excerpt===void 0?{}:{textExcerpt:e.text_excerpt},...e.context.length===0?{}:{context:e.context.map(e=>e.accessible_name??e.role??e.tag_name)}}}function zz(e,t,n={}){let r=n.runActive??!1;if(e===void 0)return r?{status:`updating`}:{status:`loading`};if(e.status===`not_declared`)return r?{status:`updating`}:{status:`not_declared`};if(e.status===`invalid`)return r?{status:`updating`}:{status:`invalid`,message:e.error.message};let i={status:`declared`,title:e.artifact.title,previewStatus:e.preview.status,...e.preview.error_message===void 0?{}:{errorMessage:e.preview.error_message}};return e.preview.status===`ready`?t.previewUrl===void 0?r?{status:`updating`}:t.errorMessage===void 0?{...i,previewStatus:t.pending?`starting`:`failed`,...t.pending?{}:{errorMessage:`Preview session is unavailable`}}:{...i,previewStatus:`failed`,errorMessage:t.errorMessage}:{...i,previewUrl:t.previewUrl}:r?{status:`updating`}:i}function Bz(e){return e?.status===`declared`&&e.preview.status===`ready`?{status:`live`}:{status:`hidden`}}function Vz(e){return e.status===`declared`&&e.previewStatus===`ready`?{status:`live`}:{status:`hidden`}}function Hz(e){return{kind:`initials`,initials:k_(Wz(e)),color:`blue`}}function Uz(e){return e.author.ref===void 0||!Rt(e.author.ref,Pt.relayAccount)?null:{kind:`image`,image_url:`/api/v1/accounts/${encodeURIComponent(e.author.ref)}/avatar`,initials:k_(Wz(e)),color:`blue`}}function Wz(e){return wn(e)===`operator`?`${e.author.display_name??`Dev Observer`} (operator)`:e.author.display_name??(e.author.kind===`human`?`Member`:`Tutti`)}function Gz(e,t={}){if(e.author.kind===`agent`||e.author.kind===`system`&&wn(e)!==`operator`)return{avatarKind:`tutti`,online:!1};if(e.author.avatar!==void 0)return{avatarKind:`member`,avatar:e.author.avatar,online:t[e.author.ref??``]?.online??!1};let n=e.author.ref===void 0?void 0:t[e.author.ref];return n===void 0?{avatarKind:`member`,avatar:Uz(e)??Hz(e),online:!1}:{avatarKind:`member`,avatar:n.avatar,online:n.online??!1}}function Kz(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function qz(e,t={}){let n={id:e.id,messageKind:e.message_kind,isClarificationAnswer:wn(e)!==null,author:Wz(e),body:e.body,createdAt:e.created_at,time:Pz(e.created_at),...t.requestStatus===void 0?{}:{requestStatus:t.requestStatus},...Gz(e,t.authorProfiles)};if(e.refs?.workflow_ref!==void 0&&(n.workflowRef=e.refs.workflow_ref),e.refs?.reference_file!==void 0){let r=e.refs.reference_file;n.referenceFile={path:r.path,name:r.name,category:r.category,...r.media_type===void 0?{}:{mediaType:r.media_type},sizeBytes:r.size_bytes,...r.category===`image`&&r.blob_oid!==void 0&&t.referenceAssetUrl!==void 0?{imageUrl:t.referenceAssetUrl(r.path,`thumbnail`,r.blob_oid)}:{}}}if(e.clarification_card!==void 0&&(n.clarificationCard={threadId:e.clarification_card.thread_id,roundId:e.clarification_card.round_id,...e.clarification_card.title===void 0?{}:{title:e.clarification_card.title},summary:e.clarification_card.summary,status:e.clarification_card.status,isCurrentRound:e.clarification_card.is_current_round}),e.refs?.task_result!==void 0){let r=e.refs.task_result,i=r.latest_run_result_id===void 0?r.retry_action:t.taskRetryState?.(r.task_id,r.latest_run_result_id,r.retry_action)??r.retry_action;n.taskResult={title:r.title,status:r.status,taskId:r.task_id,taskTitle:r.task_title,summary:r.summary,...r.module_name===void 0?{}:{moduleName:r.module_name},...r.latest_run_result_id===void 0?{}:{latestRunResultId:r.latest_run_result_id},...r.final_note===void 0?{}:{finalNote:r.final_note},...r.generated_files===void 0?{}:{generatedFiles:r.generated_files.map(e=>({path:e.path,name:e.name,meta:e.media_type===void 0?Kz(e.size_bytes):`${e.media_type} · ${Kz(e.size_bytes)}`,...e.group===void 0?{}:{group:e.group}}))},...r.error_code===void 0?{}:{errorCode:r.error_code},...i===void 0?{}:{retryState:i}}}if(e.refs?.artifact_feedback!==void 0){let r=e.refs.artifact_feedback,i=r.preview_generation===t.artifactFeedbackPreviewGeneration;n.artifactFeedback={artifactTitle:r.artifact_title,...r.summary===void 0?{}:{summary:r.summary},annotations:r.annotations.map(e=>({documentUrl:e.document_url,comment:e.comment,target:Rz(e.target.snapshot),canView:i}))}}return n}function Jz(e){return e.state===`none`?null:{threadId:e.thread.id,roundId:e.round.id,...e.round.answer_revision===void 0?{}:{answerRevision:e.round.answer_revision},cardMessageId:e.round.card_message_id,title:e.round.request_payload.title??`Clarification`,summary:e.round.request_payload.summary,request:e.round.request_payload.request,ownerLabel:e.thread.owner.kind===`task`?`Task-bound clarification ${e.thread.owner.task_id}`:`Workflow clarification`,status:e.round.status}}function Yz(e){let t=e.resolution.decided_by,n=t===void 0?``:` by ${t.display_name}`;return`${e.resolution.label}${n}`}function Xz(e){return e.resolution.outcome===`accepted`?{status:`resolved`,statusLabel:`resolved`}:{status:`expired`,statusLabel:e.resolution.outcome}}function Zz(e){return e.reason??e.summary}function Qz(e){if(e===void 0||e.state===`none`)return null;let t=e.request;return e.state===`pending`?{approvalId:t.approval_id,title:t.title,summary:Zz(t),requestedAt:t.requested_at,...t.command?.text===void 0?{}:{detailLabel:`Codex wants to run`,detail:t.command.text,detailCode:!0},status:`pending`,statusLabel:`needs approval`,decisions:t.decisions.map(e=>({decisionId:e.decision_id,label:e.label,tone:e.tone}))}:{approvalId:t.approval_id,title:t.title,summary:Zz(t),requestedAt:t.requested_at,...t.command?.text===void 0?{}:{detailLabel:`Codex wants to run`,detail:t.command.text,detailCode:!0},...Xz(e),decisions:[],resolutionLabel:Yz(e)}}function $z(e){return e.state===`ready`?[e.topic,e.background_summary,...e.current_consensus,...e.open_questions,...e.task_changes].some(e=>e.trim().length>0):!1}function eB(e){let t=e.map(e=>e.trim()).filter(e=>e.length>0).join(`; `);return t.length===0?void 0:t}function tB(e){return[{id:`scratchpad-confirmed`,label:`CONFIRMED`,rows:e.current_consensus.map(e=>({kind:`confirmed`,text:e}))},{id:`scratchpad-questions`,label:`OPEN QUESTIONS`,rows:e.open_questions.map(e=>({kind:`question`,text:e}))}].filter(e=>e.rows.length>0)}function nB(e){let t=eB(e.task_changes);return{key:`current:${e.updated_at??`unknown`}`,title:e.topic||`Current Scratchpad`,summary:e.background_summary||`No background summary`,submitAvailable:$z(e),sections:tB(e),...e.updated_at===void 0?{}:{updatedLabel:jz(e.updated_at)},...t===void 0?{}:{footerNote:{text:t,tone:`neutral`}}}}function rB(e){return{key:`submitted:${e.submitted_by_workflow_ref??e.submitted_at??`current`}`,title:e.topic||`Current Scratchpad`,summary:e.background_summary||`No background summary`,submitAvailable:!1,sections:tB(e),submitted:!0,updatedLabelPrefix:`Submitted`,...e.submitted_at===void 0?e.updated_at===void 0?{}:{updatedLabel:jz(e.updated_at)}:{updatedLabel:jz(e.submitted_at)}}}function iB(e){return{key:`receipt:${e.workflow_ref}`,title:e.topic||`Current Scratchpad`,summary:e.background_summary||`No background summary`,submitAvailable:!1,sections:tB(e),submitted:!0,updatedLabelPrefix:`Submitted`,updatedLabel:jz(e.submitted_at),...e.compiled_tasks===void 0||e.compiled_tasks.length===0?{}:{compiledTasks:e.compiled_tasks.map(e=>({taskId:e.task_id,title:e.title,moduleName:e.module_name,status:e.status}))}}}function aB(e){return[...e].reverse().map(iB)}function oB(e){let t=aB(e.receipts);return e.state===`ready`?[...t,nB(e)]:e.state===`submitted`&&t.length===0?[rB(e)]:t}function sB(e){let t=e.refs?.scratchpad_source;return t===void 0?e.scope.kind===`main_chat`?e.message_kind===`user_text`&&e.author.kind===`human`?!0:e.message_kind===`agent_text`&&e.author.kind===`agent`?e.refs?.workflow_ref===void 0&&e.refs?.activity_ref===void 0:!1:!1:t===`include`}function cB(e,t){let n=e.updated_at??(e.state===`submitted`?e.submitted_at:void 0);return t.some(e=>sB(e)?n===void 0||e.created_at>n:!1)}function lB(e,t=[]){let n=cB(e,t),r=oB(e),i=n?r.map((e,t)=>t===r.length-1?{...e,submitAvailable:!0}:e):r;if(i.length>0){let e=i[i.length-1];if(e===void 0)throw Error(`Scratchpad pages unexpectedly empty`);return{title:e.title,summary:e.summary,submitAvailable:e.submitAvailable,sections:e.sections,...e.updatedLabel===void 0?{}:{updatedLabel:e.updatedLabel},...e.updatedLabelPrefix===void 0?{}:{updatedLabelPrefix:e.updatedLabelPrefix},...e.footerNote===void 0?{}:{footerNote:e.footerNote},pages:i}}if(e.state!==`ready`)return{title:`Current Scratchpad`,summary:`Scratchpad empty. Discuss more, tutti together!.`,sections:[],submitAvailable:n};let a=nB(e);return{...a,submitAvailable:a.submitAvailable||n}}function uB(e,t=[],n){let r=lB(e,t);if(n===void 0)return r;let i={text:n,tone:`neutral`};return{...r,footerNote:i,...r.pages===void 0?{}:{pages:r.pages.map((e,t)=>t===r.pages.length-1?{...e,footerNote:i}:e)}}}function dB(e,t){let n=e.modules.map(e=>({label:e.module.name,rows:e.tasks.map(e=>({id:e.id,title:e.title,status:e.status,selected:e.id===t}))})).filter(e=>e.rows.length>0);return{modules:n,taskCount:n.reduce((e,t)=>e+t.rows.length,0)}}function fB(e){return e.modules.flatMap(e=>e.tasks)}function pB(e){return e.replace(/\s+/gu,` `).trim()}function mB(e,t=`None`){let n=pB(e??``);return n.length===0?t:n}function hB(e){let t=e.map(pB).filter(e=>e.length>0);return t.length===0?`None`:t.join(`
|
|
69
|
+
`))},e.diagnosticId)}function GR({loading:e,pending:t,unbound:n,value:r,canSubmit:i,error:a,onChange:o,onConnect:s,onRefresh:c}){let l=a===void 0?void 0:(0,L.jsx)(WR,{diagnostic:a});return(0,L.jsx)(EL,{brand:(0,L.jsx)(UR,{label:`Tutti`}),projectName:`Connect Tutti`,showProjectName:!1,refreshing:e||t,onRefresh:c,children:e?(0,L.jsx)(oS,{count:3}):n?(0,L.jsx)(AR,{value:r,pending:t,canSubmit:i,onChange:o,onSubmit:s,feedback:l}):(0,L.jsx)(aS,{details:l,children:`Connection entry unavailable.`})})}var KR=`https://lf1-cdn-tos.bytegoofy.com/goofy/lark/op/h5-js-sdk-1.5.48.js`,qR=15e3,JR=[fg],YR=class extends Error{constructor(e,t,n,r){super(e.replaceAll(`_`,` `)),this.code=e,this.stage=t,this.errno=n,this.platformDetail=r,this.name=`FeishuH5AuthorizationError`}};function XR(e){let t=[];typeof e.errCode==`number`&&Number.isSafeInteger(e.errCode)&&t.push(`errCode ${e.errCode}`);for(let n of[e.errString,e.errMsg]){if(typeof n!=`string`)continue;let e=Array.from(n,e=>{let t=e.charCodeAt(0);return t<=31||t===127?` `:e}).join(``).replace(/\s+/gu,` `).trim();e!==``&&!t.includes(e)&&t.push(e)}if(t.length===0)return;let n=t.join(` · `);return n.length<=180?n:`${n.slice(0,177)}...`}function ZR(e){return typeof e.errno==`number`&&Number.isSafeInteger(e.errno)?e.errno:void 0}function QR(e,t){return new Promise((n,r)=>{let i=!1,a=!1,o=!1,s=e=>{i||(i=!0,clearTimeout(c),`error`in e?r(e.error):n(e.code))},c=setTimeout(()=>s({error:new YR(`client_unavailable`)}),t.timeoutMs??qR),l=()=>{if(!(a||i)){if(a=!0,e.allowLegacyFallback===!1){s({error:new YR(`request_failed`,`request_access`)});return}if(t.client.requestAuthCode===void 0){s({error:new YR(o?`request_failed`:`client_unavailable`,o?`request_access`:`request_auth_code`)});return}t.client.requestAuthCode({appId:e.appId,success:e=>{typeof e.code!=`string`||e.code.trim()===``?s({error:new YR(`request_failed`,`request_auth_code`)}):s({code:e.code})},fail:e=>s({error:new YR(`request_failed`,`request_auth_code`,ZR(e),XR(e))})})}},u=()=>{if(!(o||i)){if(o=!0,t.client.requestAccess===void 0){l();return}t.client.requestAccess({appID:e.appId,scopeList:[...e.scopes??JR],state:e.state,success:t=>{if(typeof t.code!=`string`||t.code.trim()===``){s({error:new YR(`request_failed`,`request_access`)});return}if(t.state!==void 0&&t.state!==e.state){s({error:new YR(`state_mismatch`,`request_access`)});return}s({code:t.code})},fail:e=>{let t=ZR(e);if(t===103){l();return}s({error:new YR(`request_failed`,`request_access`,t,XR(e))})}})}};t.sdk===void 0?u():(t.sdk.error(e=>{s({error:new YR(`request_failed`,`sdk`,ZR(e))})}),t.sdk.ready(u))})}var $R=null;function ez(e){return e.tt===void 0?null:{client:e.tt,...e.h5sdk===void 0?{}:{sdk:e.h5sdk}}}function tz(e=window,t=document){let n=ez(e);if(n!==null)return Promise.resolve(n);if($R!==null)return $R;let r=new Promise((n,r)=>{let i=t.createElement(`script`),a=setTimeout(()=>{i.remove(),r(new YR(`client_unavailable`))},qR);i.async=!0,i.crossOrigin=`anonymous`,i.src=KR,i.onload=()=>{clearTimeout(a);let t=ez(e);t===null?r(new YR(`client_unavailable`)):n(t)},i.onerror=()=>{clearTimeout(a),r(new YR(`client_unavailable`))},t.head.append(i)}).catch(e=>{throw $R=null,e});return $R=r,r}async function nz(e){return await QR(e,await tz())}var rz=`scratchpad-submit-1`,iz=class extends Error{constructor(e,t,n){super(e.replaceAll(`_`,` `)),this.stage=e,this.cause=t,this.diagnostics=n,this.name=`FeishuProjectOpenError`}};function az(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID().replaceAll(`-`,``);if(typeof globalThis.crypto?.getRandomValues==`function`){let e=new Uint8Array(16);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`.padEnd(16,`0`)}function oz(){let e={diagnosticId:`fdiag_${az()}`,webRelease:rz};if(!kn(e.diagnosticId)||!An(e.webRelease))throw Error(`Feishu diagnostics could not be initialized`);return e}function sz(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cz(e){return typeof e==`string`&&/^[a-z][a-z0-9_]{0,95}$/u.test(e)?e:void 0}function lz(e){let t=e,n=new Set;for(;t instanceof iz&&!n.has(t);)n.add(t),t=t.cause;return t}function uz(e){if(e instanceof iz){if(e.cause instanceof YR){if(e.stage===`document_authorization_request_access`)return e.stage;if(e.cause.stage===`sdk`)return`h5_sdk`;if(e.cause.stage===`request_auth_code`)return`h5_request_auth_code`;if(e.cause.stage===`request_access`)return`h5_request_access`}return e.stage}return e instanceof YR?e.stage===`sdk`?`h5_sdk`:e.stage===`request_auth_code`?`h5_request_auth_code`:`h5_request_access`:`browser_runtime`}function dz(e,t){return e instanceof iz&&e.diagnostics!==void 0?e.diagnostics:t}function fz(e){return sz(e.details)?cz(e.details.reason_code)??e.code:e.code}function pz(e){let t=lz(e);if(e instanceof iz&&e.stage.startsWith(`connection_`)){let e=t instanceof Gt?fz(t):void 0;return e===`connection_input_invalid`?`Paste a connection code or the full /tutti connect command.`:e===`pairing_code_invalid_or_expired`||e===`pairing_code_already_consumed`?`Get a current connection code from Local Console and try again.`:e===`connection_state_invalid_or_expired`?`This authorization attempt expired. Click Connect to try again.`:e===`connection_entry_unavailable`?`This group entry is unavailable. Send /tutti connect in the group to request the current entry.`:e?.includes(`bound`)||e?.includes(`binding`)?`This group or project already has a connection, or its connection is unavailable. Refresh to check. Existing connections will not be replaced.`:`Tutti could not verify or connect this group. Refresh to check its current connection; share the diagnostics if it persists.`}if(e instanceof iz&&e.stage===`reference_authorization_status`){let e=t instanceof Gt?fz(t):void 0;return e===`reference_owner_required`?`Ask the project owner to open this access request.`:e===`reference_authorization_not_found`?`This access request is no longer available. Ask Tutti to try reading again.`:`Document access could not be checked. Refresh this entry and share the diagnostics if it persists.`}if(t instanceof Gt&&t.code===`response_parse_error`)return`Tutti received an unexpected server response. Refresh to try again; if it persists, share the diagnostics.`;if(e instanceof iz){if([`skills_list`,`skill_detail`,`project_timeline`].includes(e.stage)){let t=lz(e),n=t instanceof Gt?fz(t):void 0;return n===`host_read_surfaces_unsupported`?`Update the project's local Tutti runtime to view this section.`:n===`skill_read_limit_exceeded`?`These skills exceed the sidebar read limit. No partial instructions are shown.`:t instanceof Gt&&t.statusCode===503?`The project’s local Tutti runtime is offline or temporarily unavailable.`:t instanceof Gt&&(t.statusCode===401||t.statusCode===403)?`Project access could not be verified. Reopen the project from Feishu.`:t instanceof Gt&&t.statusCode===404&&t.code!==`response_parse_error`?`This content is no longer available. Refresh this section to check again.`:`This section could not be loaded. Refresh to try again.`}if(e.stage===`external_reference_register`||e.stage===`external_reference_list`){let t=e.cause instanceof Gt?fz(e.cause):void 0;return e.stage===`external_reference_list`&&e.cause instanceof Gt&&[401,403].includes(e.cause.statusCode)?`Project access could not be verified. Reopen the project from Feishu.`:t?.startsWith(`reference_submission_`)?`This Reference request is no longer available. Reload References; submit the link again if the request expired.`:t===`reference_source_limit_reached`?`The project has reached its Reference source limit. Existing sources are unchanged.`:t===`reference_owner_required`?`Only the project Owner can add References.`:t===`reference_link_invalid`?`Use a standard Feishu Docx, Wiki or cloud file link.`:t===`feishu_user_drive_scope_missing`?`Authorize cloud file downloads and try again.`:t===`feishu_user_authorization_required`?`The Owner needs to authorize access, then retry this request.`:t===`document_wiki_type_unsupported`?`This Wiki node is not a Docx document. Use a direct cloud file link for ordinary files.`:`The Reference request could not be completed. Reload the list and try again; existing sources are unchanged.`}if(e.stage===`reference_summary_refresh`)return`The summary retry could not be requested. Your document connection and local snapshot are unchanged. Try again.`;if([`document_list`,`document_connect`,`document_refresh`].includes(e.stage)){let t=e.cause instanceof Gt?fz(e.cause):void 0;return t===`document_link_invalid`?`Use a Feishu Docx or Wiki link, or the actual Docx document ID.`:t===`document_wiki_authorization_required`?`Authorize Wiki node access and Feishu Docs, then try connecting again.`:t===`document_wiki_type_unsupported`?`This Wiki node is not a Docx document. Sheets and other resource types are not supported yet.`:t===`document_wiki_not_found`?`The Wiki node could not be found. Check the copied link.`:t===`document_wiki_access_denied`?`Your Feishu account cannot read this Wiki node. Check its sharing settings.`:t===`document_wiki_busy`?`Another Wiki connection is being checked. Try again shortly.`:t===`document_owner_required`?`Only the project Owner can connect or refresh documents.`:t===`document_authorization_required`?`Authorize Feishu Docs and try again.`:t===`document_source_limit_reached`?`This project has reached its document connection limit.`:t===`document_source_not_found`?`This document connection is no longer available. Reload the list.`:`The document request could not be completed. Your existing reference snapshots are unchanged. Try again.`}return(e.stage===`document_authorization_bootstrap`||e.stage===`document_authorization_exchange`)&&e.cause instanceof Gt?`Feishu could not authorize document access. Reopen this entry and try again.`:e.stage===`authorization_exchange`&&e.cause instanceof Gt&&(e.cause.statusCode===401||e.cause.statusCode===403||e.cause.statusCode===503)?`Feishu could not verify your identity or project group access. Try again after the app permissions are available.`:e.stage===`host_bootstrap`&&e.cause instanceof Gt&&e.cause.statusCode===503?`The project’s local Tutti runtime is offline or temporarily unavailable.`:e.stage===`browser_session_restore`?`This browser session expired. Reopen the project from Feishu and start the browser fallback again.`:e.stage===`browser_handoff_consume`?`This browser handoff expired or was already used. Reopen the project from Feishu and try again.`:pz(e.cause)}if(e instanceof YR){if(e.code===`client_unavailable`)return`Open this project through the Feishu app entry, not a regular browser link.`;if(e.code===`state_mismatch`)return`This Feishu authorization request expired. Try again.`;let t=[e.stage,e.errno===void 0?void 0:`errno ${e.errno}`,e.platformDetail].filter(e=>e!==void 0).join(`, `);return`Feishu could not authorize this app${t===``?``:` (${t})`}. Reopen it from Feishu and try again.`}return e instanceof Gt&&e.statusCode===403?`Your Feishu account must belong to the project group.`:e instanceof Gt&&e.statusCode===401?`Your project session expired. Reopen the project from Feishu.`:e instanceof Gt&&e.statusCode===429?`Too many requests. Wait a moment, then try again.`:e instanceof Gt&&e.statusCode===503?`The project’s local Tutti runtime is offline or temporarily unavailable.`:e instanceof Gt&&e.statusCode===404?`This project is no longer connected to the current Feishu group.`:e instanceof Gt&&e.statusCode>=500?`Tutti could not complete this request. Try again; if it persists, share the diagnostics.`:`Check your Feishu connection and try again.`}function mz(e,t){let n=gz(e,t);return`${n.message} Diagnostic ID: ${n.diagnosticId} · ${n.webRelease} · ${n.stage} · ${n.reasonCode??n.errorKind}${n.httpStatus===void 0?``:` · HTTP ${n.httpStatus}`}`}async function hz(e,t){let n=oz();try{return await t(n)}catch(t){throw new iz(e,t,n)}}function gz(e,t){let n=lz(e),r={...dz(e,t),message:pz(e),stage:uz(e)};if(n instanceof Gt){let e=sz(n.details)?n.details:void 0,t=cz(e?.authorization_stage),i=e?.platform_code;return{...r,errorKind:n.code,...n.statusCode<=0?{}:{httpStatus:n.statusCode},reasonCode:fz(n),...t===void 0?{}:{platformStage:t},...typeof i==`number`&&Number.isSafeInteger(i)?{platformCode:i}:{}}}return n instanceof YR?{...r,errorKind:n.code,reasonCode:n.code,...n.errno===void 0?{}:{platformCode:n.errno}}:n instanceof TypeError?{...r,errorKind:`unexpected_type_error`,reasonCode:`unexpected_type_error`}:{...r,errorKind:`unexpected_error`,reasonCode:`unexpected_error`}}var _z={success:3e3,error:9e3,warning:6e3,info:4500},vz=5,yz=(0,I.createContext)(null);function bz(e){return e.persistent===!0||e.tone===`loading`?e.durationMs:e.durationMs??_z[e.tone]}function xz(e){return e.persistent??e.tone===`loading`}function Sz(e){return e.dismissible??e.tone!==`loading`}function Cz(e,t){let n=bz(t);return{id:e,tone:t.tone,title:t.title,persistent:xz(t),dismissible:Sz(t),...t.message===void 0?{}:{message:t.message},...n===void 0?{}:{durationMs:n}}}function wz(e,t){let n=t.tone===void 0,r={tone:t.tone??e.tone,title:t.title??e.title,...t.message===void 0?e.message===void 0?{}:{message:e.message}:{message:t.message},...t.durationMs===void 0?!n||e.durationMs===void 0?{}:{durationMs:e.durationMs}:{durationMs:t.durationMs},...t.persistent===void 0?!n||e.persistent===void 0?{}:{persistent:e.persistent}:{persistent:t.persistent},...t.dismissible===void 0?!n||e.dismissible===void 0?{}:{dismissible:e.dismissible}:{dismissible:t.dismissible}};return Cz(e.id,r)}function Tz(e){return[e.id,e.tone,e.title,e.message??``,e.durationMs??``,e.persistent===!0?`persistent`:`timed`].join(`:`)}function Ez({children:e}){let[t,n]=(0,I.useState)([]),r=(0,I.useRef)(new Map),i=(0,I.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]),a=(0,I.useCallback)(e=>{let t=Ht(),r=Cz(t,e);return n(e=>[...e,r].slice(-vz)),t},[]),o=(0,I.useCallback)((e,t)=>{if(e===void 0){a(t);return}n(n=>n.map(n=>n.id===e?wz(n,t):n))},[a]);(0,I.useEffect)(()=>{let e=new Set(t.map(e=>e.id));for(let[t,n]of r.current)e.has(t)||(window.clearTimeout(n.timeout),r.current.delete(t));for(let e of t){let t=r.current.get(e.id),n=Tz(e);if(t!==void 0&&t.key!==n&&(window.clearTimeout(t.timeout),r.current.delete(e.id)),e.persistent===!0||e.durationMs===void 0||r.current.has(e.id))continue;let a=window.setTimeout(()=>i(e.id),e.durationMs);r.current.set(e.id,{key:n,timeout:a})}},[i,t]),(0,I.useEffect)(()=>()=>{for(let e of r.current.values())window.clearTimeout(e.timeout);r.current.clear()},[]);let s=(0,I.useMemo)(()=>({notify:a,update:o,dismiss:i}),[i,a,o]);return(0,L.jsxs)(yz.Provider,{value:s,children:[e,(0,L.jsx)(dS,{notices:t,onDismiss:i})]})}function Dz(){let e=(0,I.useContext)(yz);if(e===null)throw Error(`useNotify must be used inside NotificationProvider`);return e}var Oz=`en-US`;function kz(e){if(e===void 0)return`Never`;let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString(Oz,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}):e}function Az(e){if(e===void 0)return`Unknown`;let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleDateString(Oz,{month:`short`,day:`numeric`,year:`numeric`}):`Unknown`}function jz(e,t=new Date){let n=new Date(e);if(!Number.isFinite(n.getTime()))return e;if(n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()){let e=Math.max(0,Math.floor((t.getTime()-n.getTime())/6e4));return e<1?`now`:e<60?`${e}m`:`${Math.floor(e/60)}h`}return n.toLocaleString(Oz,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function Mz(e){return e.toString().padStart(2,`0`)}function Nz(e){if(e===void 0)return`Never`;let t=new Date(e);return Number.isFinite(t.getTime())?`${t.getFullYear()}-${Mz(t.getMonth()+1)}-${Mz(t.getDate())} ${Mz(t.getHours())}:${Mz(t.getMinutes())}`:e}function Pz(e){let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleTimeString(Oz,{hour:`2-digit`,minute:`2-digit`}):``}function Fz(e){switch(e){case`online`:return`Host online`;case`offline`:return`Host offline`;case`unknown`:return`Host unknown`}}function Iz(e){let t={running:{label:`Running`,tone:`sync`},pending:{label:`Needs input`,tone:`warning`},failed:{label:`Needs attention`,tone:`error`},idle:{label:`Idle`,tone:`neutral`}},n=e.active_activity,r=t[e.status].label;if(e.status===`running`&&n!==void 0)if(n.activity_kind===`run`)r=`Running task`;else switch(n.workflow_kind){case`context_sync`:r=`Updating docs`;break;case`task_compile`:r=`Preparing tasks`;break;case`project_context_bootstrap`:r=`Preparing project`;break;case`scratchpad_refresh`:r=`Refreshing`;break;case`reference_summary_refresh`:r=`Reading files`;break;case`follow_up_check`:r=`Reviewing input`;break}return{...t[e.status],label:r,summary:e.summary}}function Lz(e){return{relayProjectRef:e.relay_project_ref,displayName:e.display_name,hostStatus:e.host_status,surface:e.surface,membershipLabel:e.role===`owner`?`Owner`:`Member`,lastOpenedLabel:kz(e.last_opened_at),canOpen:e.surface===`standalone`&&e.host_status===`online`}}function Rz(e){return{elementKind:e.element_kind,tagName:e.tag_name,...e.role===void 0?{}:{role:e.role},...e.accessible_name===void 0?{}:{accessibleName:e.accessible_name},...e.text_excerpt===void 0?{}:{textExcerpt:e.text_excerpt},...e.context.length===0?{}:{context:e.context.map(e=>e.accessible_name??e.role??e.tag_name)}}}function zz(e,t,n={}){let r=n.runActive??!1;if(e===void 0)return r?{status:`updating`}:{status:`loading`};if(e.status===`not_declared`)return r?{status:`updating`}:{status:`not_declared`};if(e.status===`invalid`)return r?{status:`updating`}:{status:`invalid`,message:e.error.message};let i={status:`declared`,title:e.artifact.title,previewStatus:e.preview.status,...e.preview.error_message===void 0?{}:{errorMessage:e.preview.error_message}};return e.preview.status===`ready`?t.previewUrl===void 0?r?{status:`updating`}:t.errorMessage===void 0?{...i,previewStatus:t.pending?`starting`:`failed`,...t.pending?{}:{errorMessage:`Preview session is unavailable`}}:{...i,previewStatus:`failed`,errorMessage:t.errorMessage}:{...i,previewUrl:t.previewUrl}:r?{status:`updating`}:i}function Bz(e){return e?.status===`declared`&&e.preview.status===`ready`?{status:`live`}:{status:`hidden`}}function Vz(e){return e.status===`declared`&&e.previewStatus===`ready`?{status:`live`}:{status:`hidden`}}function Hz(e){return{kind:`initials`,initials:k_(Wz(e)),color:`blue`}}function Uz(e){return e.author.ref===void 0||!Rt(e.author.ref,Pt.relayAccount)?null:{kind:`image`,image_url:`/api/v1/accounts/${encodeURIComponent(e.author.ref)}/avatar`,initials:k_(Wz(e)),color:`blue`}}function Wz(e){return wn(e)===`operator`?`${e.author.display_name??`Dev Observer`} (operator)`:e.author.display_name??(e.author.kind===`human`?`Member`:`Tutti`)}function Gz(e,t={}){if(e.author.kind===`agent`||e.author.kind===`system`&&wn(e)!==`operator`)return{avatarKind:`tutti`,online:!1};if(e.author.avatar!==void 0)return{avatarKind:`member`,avatar:e.author.avatar,online:t[e.author.ref??``]?.online??!1};let n=e.author.ref===void 0?void 0:t[e.author.ref];return n===void 0?{avatarKind:`member`,avatar:Uz(e)??Hz(e),online:!1}:{avatarKind:`member`,avatar:n.avatar,online:n.online??!1}}function Kz(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function qz(e,t={}){let n={id:e.id,messageKind:e.message_kind,isClarificationAnswer:wn(e)!==null,author:Wz(e),body:e.body,createdAt:e.created_at,time:Pz(e.created_at),...t.requestStatus===void 0?{}:{requestStatus:t.requestStatus},...Gz(e,t.authorProfiles)};if(e.refs?.workflow_ref!==void 0&&(n.workflowRef=e.refs.workflow_ref),e.refs?.reference_file!==void 0){let r=e.refs.reference_file;n.referenceFile={path:r.path,name:r.name,category:r.category,...r.media_type===void 0?{}:{mediaType:r.media_type},sizeBytes:r.size_bytes,...r.category===`image`&&r.blob_oid!==void 0&&t.referenceAssetUrl!==void 0?{imageUrl:t.referenceAssetUrl(r.path,`thumbnail`,r.blob_oid)}:{}}}if(e.clarification_card!==void 0&&(n.clarificationCard={threadId:e.clarification_card.thread_id,roundId:e.clarification_card.round_id,...e.clarification_card.title===void 0?{}:{title:e.clarification_card.title},summary:e.clarification_card.summary,status:e.clarification_card.status,isCurrentRound:e.clarification_card.is_current_round}),e.refs?.task_result!==void 0){let r=e.refs.task_result,i=r.latest_run_result_id===void 0?r.retry_action:t.taskRetryState?.(r.task_id,r.latest_run_result_id,r.retry_action)??r.retry_action;n.taskResult={title:r.title,status:r.status,taskId:r.task_id,taskTitle:r.task_title,summary:r.summary,...r.module_name===void 0?{}:{moduleName:r.module_name},...r.latest_run_result_id===void 0?{}:{latestRunResultId:r.latest_run_result_id},...r.final_note===void 0?{}:{finalNote:r.final_note},...r.generated_files===void 0?{}:{generatedFiles:r.generated_files.map(e=>({path:e.path,name:e.name,meta:e.media_type===void 0?Kz(e.size_bytes):`${e.media_type} · ${Kz(e.size_bytes)}`,...e.group===void 0?{}:{group:e.group}}))},...r.error_code===void 0?{}:{errorCode:r.error_code},...i===void 0?{}:{retryState:i}}}if(e.refs?.artifact_feedback!==void 0){let r=e.refs.artifact_feedback,i=r.preview_generation===t.artifactFeedbackPreviewGeneration;n.artifactFeedback={artifactTitle:r.artifact_title,...r.summary===void 0?{}:{summary:r.summary},annotations:r.annotations.map(e=>({documentUrl:e.document_url,comment:e.comment,target:Rz(e.target.snapshot),canView:i}))}}return n}function Jz(e){return e.state===`none`?null:{threadId:e.thread.id,roundId:e.round.id,...e.round.answer_revision===void 0?{}:{answerRevision:e.round.answer_revision},cardMessageId:e.round.card_message_id,title:e.round.request_payload.title??`Clarification`,summary:e.round.request_payload.summary,request:e.round.request_payload.request,ownerLabel:e.thread.owner.kind===`task`?`Task-bound clarification ${e.thread.owner.task_id}`:`Workflow clarification`,status:e.round.status}}function Yz(e){let t=e.resolution.decided_by,n=t===void 0?``:` by ${t.display_name}`;return`${e.resolution.label}${n}`}function Xz(e){return e.resolution.outcome===`accepted`?{status:`resolved`,statusLabel:`resolved`}:{status:`expired`,statusLabel:e.resolution.outcome}}function Zz(e){return e.reason??e.summary}function Qz(e){if(e===void 0||e.state===`none`)return null;let t=e.request;return e.state===`pending`?{approvalId:t.approval_id,title:t.title,summary:Zz(t),requestedAt:t.requested_at,...t.command?.text===void 0?{}:{detailLabel:`Codex wants to run`,detail:t.command.text,detailCode:!0},status:`pending`,statusLabel:`needs approval`,decisions:t.decisions.map(e=>({decisionId:e.decision_id,label:e.label,tone:e.tone}))}:{approvalId:t.approval_id,title:t.title,summary:Zz(t),requestedAt:t.requested_at,...t.command?.text===void 0?{}:{detailLabel:`Codex wants to run`,detail:t.command.text,detailCode:!0},...Xz(e),decisions:[],resolutionLabel:Yz(e)}}function $z(e){return e.state===`ready`?[e.topic,e.background_summary,...e.current_consensus,...e.open_questions,...e.task_changes].some(e=>e.trim().length>0):!1}function eB(e){let t=e.map(e=>e.trim()).filter(e=>e.length>0).join(`; `);return t.length===0?void 0:t}function tB(e){return[{id:`scratchpad-confirmed`,label:`CONFIRMED`,rows:e.current_consensus.map(e=>({kind:`confirmed`,text:e}))},{id:`scratchpad-questions`,label:`OPEN QUESTIONS`,rows:e.open_questions.map(e=>({kind:`question`,text:e}))}].filter(e=>e.rows.length>0)}function nB(e){let t=eB(e.task_changes);return{key:`current:${e.updated_at??`unknown`}`,title:e.topic||`Current Scratchpad`,summary:e.background_summary||`No background summary`,submitAvailable:$z(e),sections:tB(e),...e.updated_at===void 0?{}:{updatedLabel:jz(e.updated_at)},...t===void 0?{}:{footerNote:{text:t,tone:`neutral`}}}}function rB(e){return{key:`submitted:${e.submitted_by_workflow_ref??e.submitted_at??`current`}`,title:e.topic||`Current Scratchpad`,summary:e.background_summary||`No background summary`,submitAvailable:!1,sections:tB(e),submitted:!0,updatedLabelPrefix:`Submitted`,...e.submitted_at===void 0?e.updated_at===void 0?{}:{updatedLabel:jz(e.updated_at)}:{updatedLabel:jz(e.submitted_at)}}}function iB(e){return{key:`receipt:${e.workflow_ref}`,title:e.topic||`Current Scratchpad`,summary:e.background_summary||`No background summary`,submitAvailable:!1,sections:tB(e),submitted:!0,updatedLabelPrefix:`Submitted`,updatedLabel:jz(e.submitted_at),...e.compiled_tasks===void 0||e.compiled_tasks.length===0?{}:{compiledTasks:e.compiled_tasks.map(e=>({taskId:e.task_id,title:e.title,moduleName:e.module_name,status:e.status}))}}}function aB(e){return[...e].reverse().map(iB)}function oB(e){let t=aB(e.receipts);return e.state===`ready`?[...t,nB(e)]:e.state===`submitted`&&t.length===0?[rB(e)]:t}function sB(e){let t=e.refs?.scratchpad_source;return t===void 0?e.scope.kind===`main_chat`?e.message_kind===`user_text`&&e.author.kind===`human`?!0:e.message_kind===`agent_text`&&e.author.kind===`agent`?e.refs?.workflow_ref===void 0&&e.refs?.activity_ref===void 0:!1:!1:t===`include`}function cB(e,t){let n=e.updated_at??(e.state===`submitted`?e.submitted_at:void 0);return t.some(e=>sB(e)?n===void 0||e.created_at>n:!1)}function lB(e,t=[]){let n=cB(e,t),r=oB(e),i=n?r.map((e,t)=>t===r.length-1?{...e,submitAvailable:!0}:e):r;if(i.length>0){let e=i[i.length-1];if(e===void 0)throw Error(`Scratchpad pages unexpectedly empty`);return{title:e.title,summary:e.summary,submitAvailable:e.submitAvailable,sections:e.sections,...e.updatedLabel===void 0?{}:{updatedLabel:e.updatedLabel},...e.updatedLabelPrefix===void 0?{}:{updatedLabelPrefix:e.updatedLabelPrefix},...e.footerNote===void 0?{}:{footerNote:e.footerNote},pages:i}}if(e.state!==`ready`)return{title:`Current Scratchpad`,summary:`Scratchpad empty. Discuss more, tutti together!.`,sections:[],submitAvailable:n};let a=nB(e);return{...a,submitAvailable:a.submitAvailable||n}}function uB(e,t=[],n){let r=lB(e,t);if(n===void 0)return r;let i={text:n,tone:`neutral`};return{...r,footerNote:i,...r.pages===void 0?{}:{pages:r.pages.map((e,t)=>t===r.pages.length-1?{...e,footerNote:i}:e)}}}function dB(e,t){let n=e.modules.map(e=>({label:e.module.name,rows:e.tasks.map(e=>({id:e.id,title:e.title,status:e.status,selected:e.id===t}))})).filter(e=>e.rows.length>0);return{modules:n,taskCount:n.reduce((e,t)=>e+t.rows.length,0)}}function fB(e){return e.modules.flatMap(e=>e.tasks)}function pB(e){return e.replace(/\s+/gu,` `).trim()}function mB(e,t=`None`){let n=pB(e??``);return n.length===0?t:n}function hB(e){let t=e.map(pB).filter(e=>e.length>0);return t.length===0?`None`:t.join(`
|
|
70
70
|
`)}function gB(e){return e.status===`promoted`?`promoted`:e.status===`not_promoted`?`not promoted`:`not attempted`}function _B(e){return e.result_kind===`needs_human`?`needs human`:e.result_kind===`failed`?`failed`:e.result_kind===`finished`?e.outcome??`finished`:`none`}function vB(e){if(e.result_kind===`needs_human`)return`pending`;if(e.result_kind===`failed`)return`failed`;if(e.result_kind===`finished`)return e.outcome===`completed`?`done`:`failed`}function yB(e){return e.result_kind===`needs_human`?`pending`:e.result_kind===`failed`?`failed`:e.outcome===`completed`?`done`:`failed`}function bB(e){return e.result_kind===`needs_human`?`Needs human`:e.result_kind===`failed`?`Failed`:e.outcome===`completed`?`Finished`:`Finished with failure`}function xB(e){return{id:e.id,title:bB(e),meta:Nz(e.created_at),status:yB(e)}}function SB(e,t,n={}){if(e===void 0)return;let r=e.detail.result,i=e.detail.contract,a=vB(r),o=[a===void 0?{label:`STATUS`,value:_B(r)}:{label:`STATUS`,value:_B(r),status:a}];return r.updated_at!==void 0&&o.push({label:`UPDATED`,value:Nz(r.updated_at)}),o.push({label:`RESULT`,value:mB(r.summary,`No run result yet.`)}),r.checks!==void 0&&o.push({label:`CHECKS`,value:r.checks}),r.docs!==void 0&&o.push({label:`DOCS`,value:r.docs}),r.promotion!==void 0&&o.push({label:`PROMOTE`,value:gB(r.promotion)}),r.error_code!==void 0&&o.push({label:`ERROR`,value:r.error_code}),r.retryable!==void 0&&o.push({label:`RETRY`,value:r.retryable?`can retry`:`needs new scope`}),{taskId:e.task.id,title:e.task.title,status:e.task.status,summary:mB(e.task.summary),contractRows:[{label:`GOAL`,value:i.goal||`None`},{label:`SCOPE`,value:hB(i.scope)}],resultRows:o,evidenceRows:o,runResults:(t?.items??[]).map(xB),...r.retry_action===void 0||n.includeRetryAction===!1?{}:{retryAction:{state:r.retry_action}}}}var CB=new Intl.DateTimeFormat(Oz,{year:`numeric`,month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}),wB={connected:`Connected`,reconnecting:`Reconnecting`,unavailable:`Unavailable`},TB={configured:`Configured`,invalid:`Needs attention`,not_configured:`Not configured`,managed:`Tutti trial`},EB={provider_auth_invalid:`API key is invalid`,provider_quota_or_billing_required:`Quota or billing needs attention`,provider_rate_limited:`Provider rate limit reached`,provider_model_unavailable:`Selected model is unavailable`,provider_network_error:`Provider could not be reached`,unknown:`Provider validation failed`};function DB(e){let t=new Date(e);return Number.isFinite(t.getTime())?CB.format(t):e}function OB(e){return e===`owner`?`Owner`:`Member`}function kB(e){return e.status===`managed`?{status:TB.managed,model:`Tutti`}:e.status===`not_configured`?{status:TB[e.status]}:{status:TB[e.status],...e.default_model===void 0?{}:{model:e.default_model},...e.validated_at===void 0?{}:{lastValidated:DB(e.validated_at)},...e.status!==`invalid`||e.invalid_reason_code===void 0?{}:{issue:EB[e.invalid_reason_code]}}}function AB(e,t){let n=(t?.members??[]).map(e=>({key:e.account_ref,displayName:e.display_name,avatar:e.avatar}));return n.some(t=>t.key===e.account.account_ref)?n:[...n,{key:e.account.account_ref,displayName:e.account.display_name,avatar:e.account.avatar}]}function jB(e,t,n,r){return{connectionStatus:{label:wB[e.relay.status],tone:e.relay.status===`connected`?`live`:`warning`},project:{displayName:e.project.display_name,description:e.project.description??``,members:AB(t,r)},access:{...e.relay.join_url===void 0?{}:{inviteLink:e.relay.join_url},...e.relay.join_token_expires_at===void 0?{}:{inviteExpires:DB(e.relay.join_token_expires_at)},signedInAs:{displayName:t.account.display_name,avatar:t.account.avatar},role:OB(t.membership.label),joined:DB(t.membership.joined_at)},provider:kB(n),tutti:{version:e.server.version}}}var MB=new Intl.NumberFormat(`en-US`),NB=UC(`beethoven-ode-to-joy`);function PB(e){return[...e].reverse().map((e,t)=>{let n=NB.units[t%NB.units.length];if(n===void 0)throw Error(`Timeline score theme unexpectedly has no units`);return{...n,id:e.id,label:`Open ${e.stageLabel??e.title}`}})}function FB(e){return MB.format(e)}function IB(e){if(e!==void 0)switch(e){case`completed`:return`success`;case`failed`:return`error`;case`needs_human`:return`warning`}}function LB(e){if(e.kind===`task_accepted`)return`Task accepted`;if(e.kind===`checkpoint`)return`Checkpoint`;switch(e.update_state){case`completed`:return`Task completed`;case`failed`:return`Task failed`;case`needs_input`:return`Needs input`;default:return`Task update`}}function RB(e,t){let n=Date.parse(e.occurred_at),r=Date.parse(t.occurred_at),i=Number.isFinite(n)&&Number.isFinite(r)?r-n:t.occurred_at.localeCompare(e.occurred_at);return i===0?t.id.localeCompare(e.id):i}function zB(e,t={}){let n=e.token_usage?.total_tokens??0,r=IB(e.status),i={id:e.id,title:e.task_title??e.title,occurredAt:Nz(e.occurred_at),kind:e.kind,stageLabel:LB(e)};return r!==void 0&&(i.tone=r),n>0&&(i.tokenLabel=`${FB(n)} tokens`),e.task_id!==void 0&&(i.taskId=e.task_id),e.task_title!==void 0&&(i.taskTitle=e.task_title),e.trace_card!==void 0&&(i.trace=VB(e.trace_card,t)),i}function BB(e,t){if(e.kind===`worklist_task`&&e.task_id!==void 0){let n=t.onOpenWorklistTask,r=e.task_id;return n===void 0?void 0:()=>n(r)}if(e.kind===`chat_message`&&e.message_id!==void 0){let n=t.onOpenChatMessage,r=e.message_id;return n===void 0?void 0:()=>n(r)}if(e.kind===`reference_file`&&e.path!==void 0){let n=t.onOpenReferenceFile,r=e.path;return n===void 0?void 0:()=>n(r)}}function VB(e,t={}){return{tone:e.tone,...e.summary===void 0?{}:{summary:e.summary},...e.origin===void 0?{}:{origin:{...e.origin.title===void 0?{}:{title:e.origin.title},...e.origin.summary===void 0?{}:{summary:e.origin.summary},...e.origin.unavailable_reason===void 0?{}:{unavailableReason:e.origin.unavailable_reason},...e.origin.source_count===void 0?{}:{sourceCount:e.origin.source_count},...e.origin.snippets===void 0?{}:{snippets:e.origin.snippets.map(e=>({id:e.message_id,author:e.author,body:e.body,createdAt:Nz(e.created_at),...t.onOpenChatMessage===void 0?{}:{onClick:()=>t.onOpenChatMessage?.(e.message_id)}}))}}},...e.decisions===void 0?{}:{decisions:e.decisions.map((e,t)=>({id:`${t}:${e.source??`decision`}`,...e.title===void 0?{}:{title:e.title},summary:e.summary}))},...e.clarification===void 0?{}:{clarification:{...e.clarification.title===void 0?{}:{title:e.clarification.title},...e.clarification.summary===void 0?{}:{summary:e.clarification.summary},...e.clarification.request===void 0?{}:{request:e.clarification.request},...e.clarification.status===void 0?{}:{status:e.clarification.status},...e.clarification.answer_count===void 0?{}:{answerCount:e.clarification.answer_count},...e.clarification.answers===void 0?{}:{answers:e.clarification.answers.map(e=>({id:e.message_id,author:e.author,body:e.body,createdAt:Nz(e.created_at),...t.onOpenChatMessage===void 0?{}:{onClick:()=>t.onOpenChatMessage?.(e.message_id)}}))}}},...e.contract===void 0?{}:{contract:{goal:e.contract.goal,scope:e.contract.scope,...e.contract.truncated===void 0?{}:{truncated:e.contract.truncated}}},...e.result===void 0?{}:{result:{summary:e.result.summary,...e.result.error_code===void 0?{}:{errorCode:e.result.error_code}}},...e.changes===void 0?{}:{changes:{items:e.changes.items.map(e=>({status:e.status,path:e.path,...e.previous_path===void 0?{}:{previousPath:e.previous_path}})),totalCount:e.changes.total_count,truncated:e.changes.truncated}},...e.verification===void 0?{}:{verification:{checks:e.verification.checks,...e.verification.skip_reason_code===void 0?{}:{skipReasonCode:e.verification.skip_reason_code},...e.verification.skip_reason_summary===void 0?{}:{skipReasonSummary:e.verification.skip_reason_summary}}},...e.promotion===void 0?{}:{promotion:{status:e.promotion.status,...e.promotion.commit_short_oid===void 0?{}:{commitShortOid:e.promotion.commit_short_oid},...e.promotion.summary===void 0?{}:{summary:e.promotion.summary},...e.promotion.reason_code===void 0?{}:{reasonCode:e.promotion.reason_code}}},...e.checkpoint===void 0?{}:{checkpoint:{counters:e.checkpoint.counters,items:e.checkpoint.items.map(e=>({id:e.task_id,title:e.title,status:e.status,summary:e.summary})),...e.checkpoint.generated_files===void 0?{}:{generatedFiles:e.checkpoint.generated_files.map(e=>({id:e.path,name:e.name,path:e.path}))},...e.checkpoint.truncated===void 0?{}:{truncated:e.checkpoint.truncated}}},links:e.links.flatMap(e=>{let n=e.task_id??e.message_id??e.path,r=BB(e,t);return r===void 0?[]:[{id:`${e.kind}:${n??e.label}`,label:e.label,onClick:r}]})}}function HB(e,t={}){let n=e.usage_overview,r=[...e.items].sort(RB).map(e=>zB(e,t));return{tokenOverview:{totalLabel:FB(n.total_tokens)},items:r,scoreUnits:PB(r)}}var UB=[{id:`prepare`,label:`Preparing workspace`},{id:`implement`,label:`Implementing with Codex`},{id:`validate`,label:`Validating result`},{id:`save`,label:`Saving result`}],WB=[{id:`workspace_inspect`,summary:`inspecting the persistent project workspace`,displayStageId:`prepare`},{id:`artifact_candidate_validate`,summary:`validating the candidate Artifact preview`,displayStageId:`validate`},{id:`provider_task_run`,summary:`running Codex task implementation`,displayStageId:`implement`},{id:`provider_retry`,summary:`retrying Codex task after a transient provider failure`,displayStageId:`implement`},{id:`candidate_diff_collect`,summary:`collecting candidate changes`,displayStageId:`validate`},{id:`checks`,summary:`running project checks`,displayStageId:`validate`},{id:`post_checks_diff_collect`,summary:`rechecking candidate changes after checks`,displayStageId:`validate`},{id:`accepted_checkpoint`,summary:`saving the validated project state as an accepted checkpoint`,displayStageId:`save`},{id:`promotion_reconcile`,summary:`reconciling promotion after mainline changed`,displayStageId:`save`},{id:`self_correction`,summary:`retrying task implementation after pipeline feedback`,displayStageId:`implement`}],GB={scratchpad_refresh:{key:`scratchpad_refresh`,label:`Refreshing Scratchpad`,target:{kind:`scratchpad`}},project_context_bootstrap:{key:`project_context_bootstrap`,label:`Preparing project context`,target:{kind:`scratchpad`}},task_compile:{key:`task_compile`,label:`Compiling Worklist tasks`,target:{kind:`scratchpad`}},context_sync:{key:`context_sync`,label:`Synchronizing project context`,target:{kind:`worklist`}},reference_summary_refresh:{key:`reference_summary_refresh`,label:`Processing reference`,target:{kind:`references`}},recovery_check:{key:`recovery_check`,label:`Recovering workspace`,target:{kind:`worklist`}},follow_up_check:{key:`follow_up_check`,label:`Checking follow-up`,target:{kind:`worklist`}}},KB=`Tutti is working on`,qB=new Set([`scratchpad_refresh`]),JB=`task_compile`,YB=`project_context_bootstrap`,XB=3,ZB={analyzing_task:`Analyzing the task`,searching_codebase:`Searching the codebase`,reading_files:`Reading project files`,planning:`Planning the next change`,editing_files:`Editing project files`,running_checks:`Running project checks`,running_command:`Running a project command`,using_tool:`Using a project tool`,waiting_for_approval:`Waiting for approval`,preparing_result:`Preparing the result`,reading_context:`Reading project context`,finalizing:`Preparing the result`};function QB(e){if(e===void 0)return null;if(typeof e==`number`)return Number.isFinite(e)?e:null;if(e instanceof Date)return e.getTime();let t=Date.parse(e);return Number.isNaN(t)?null:t}function $B(e){return QB(e.now)??Date.now()}function eV(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;if(t<60)return`${t}m${n}s`;let r=Math.floor(t/60),i=t%60;return`${r}h${String(i).padStart(2,`0`)}m`}function tV(e,t){let n=QB(e);if(n!==null)return eV(Math.max(0,Math.floor(($B(t)-n)/1e3)))}function nV(e,t){return tV(e.active_activity?.started_at??e.runtime?.started_at,t)}function rV(e){let t=e.runtime;if(t===void 0)return;let n=e.active_activity?.activity_ref;if(!(n!==void 0&&t.activity_ref!==n))return t}function iV(e){if(e<1e3)return String(e);if(e<1e6){let t=e/1e3;return`${e<1e5?t.toFixed(1).replace(/\.0$/u,``):String(Math.round(t))}k`}return`${(e/1e6).toFixed(1).replace(/\.0$/u,``)}m`}function aV(e){let t=oV(e);return t===void 0?[]:[t]}function oV(e){let t=e?.token_usage?.total_tokens;return t===void 0?void 0:`${iV(t)} tokens`}function sV(e){if(e?.current_action_detail!==void 0)return e.current_action_detail;let t=e?.current_action;return t===void 0?e?.token_usage===void 0?void 0:ZB.analyzing_task:ZB[t]}function cV(e,t){if(e?.current_action!==`analyzing_task`||e.current_action_started_at===void 0)return;let n=QB(e.current_action_started_at);if(n===null)return;let r=Math.max(0,Math.floor(($B(t)-n)/1e3));if(!(r<XB))return`Thinking for ${eV(r)}`}function lV(e){let t={};return e.active_activity?.activity_ref!==void 0&&(t.activityRef=e.active_activity.activity_ref),e.active_activity?.workflow_ref!==void 0&&(t.workflowRef=e.active_activity.workflow_ref),e.active_task?.id!==void 0&&(t.taskId=e.active_task.id),Object.keys(t).length===0?void 0:t}function uV(e,t,n){return e===`context_sync`&&t.last_conclusion?.task_id!==void 0?{kind:`task`,taskId:t.last_conclusion.task_id}:n.target}function dV(e){return WB[_V(e)]??WB[0]}function fV(e){return UB.findIndex(t=>t.id===e)}function pV(e){return UB[fV(dV(e).displayStageId)]??UB[0]}function mV(e){if(e.status!==`running`||e.active_activity?.activity_kind!==`procedure`)return null;let t=e.active_activity.workflow_kind;if(t===void 0||qB.has(t))return null;let n=GB[t],r=uV(t,e,n);return{key:`procedure:${n.key}`,label:n.label,title:n.label,tone:`running`,target:r}}function hV(e,t){if(e.status!==`running`||e.active_activity?.activity_kind!==`procedure`)return null;let n=e.active_activity.workflow_kind;if(n===void 0||qB.has(n))return null;let r=GB[n],i=uV(n,e,r),a=lV(e),o=rV(e),s=n===JB?aV(o):[],c=n===YB?`Creating project context for the first time`:void 0,l=tV(e.active_activity?.started_at??o?.started_at,t);return{key:`procedure:${r.key}`,title:KB,summary:e.summary,tone:`running`,metaLabel:r.label,completionTarget:i,...a===void 0?{}:{completionSource:a},steps:[{id:`procedure:${r.key}:active`,label:r.label,status:`running`,...l===void 0?{}:{elapsedLabel:l},...c===void 0?{}:{detail:c},...s.length===0?{}:{metrics:s}}]}}function gV(e){let t=e.indexOf(` - `);return t===-1?``:e.slice(t+3).trim().replace(/\.$/u,``)}function _V(e){let t=gV(e).toLocaleLowerCase();if(t===``)return 0;let n=WB.findIndex(e=>t.includes(e.summary.toLocaleLowerCase()));return n===-1?0:n}function vV(e,t){if(e.status!==`running`||e.active_task===void 0)return null;let n=fV(dV(e.summary).displayStageId),r=pV(e.summary),i=lV(e),a=rV(e),o=nV(e,t);return{key:`run:${e.active_task.id}`,title:KB,summary:e.active_task.title,tone:`running`,metaLabel:r.label,completionTarget:{kind:`task`,taskId:e.active_task.id},...i===void 0?{}:{completionSource:i},steps:UB.map((e,r)=>{let i=r<n?`done`:r===n?`running`:`waiting`,s=r===n,c=e.id===`implement`,l=s&&c?sV(a):void 0,u=s&&c?oV(a):void 0,d=s&&c?cV(a,t):void 0;return{id:e.id,label:e.label,status:i,...s&&o!==void 0?{elapsedLabel:o}:{},...u===void 0?{}:{detailPrefix:u},...l===void 0?{}:{detail:l},...d===void 0?{}:{activityLabel:d}}})}}function yV(e,t){if(e.status!==`running`||e.active_activity?.workflow_kind!==`context_sync`||e.last_conclusion?.kind!==`completed`||e.last_conclusion.task_id===void 0)return null;let n=lV(e),r=nV(e,t);return{key:`context-sync:${e.last_conclusion.task_id}`,title:KB,summary:e.summary,tone:`running`,metaLabel:`Synchronizing context`,completionTarget:{kind:`task`,taskId:e.last_conclusion.task_id},...n===void 0?{}:{completionSource:n},steps:[{id:`task_complete`,label:`Task completed`,status:`done`},{id:`context_sync`,label:`Synchronizing project context`,status:`running`,...r===void 0?{}:{elapsedLabel:r}}]}}function bV(e){let t=e.blocked_by?.kind===`approval`?{kind:`approval`}:{kind:`clarification`};return{key:`pending:${e.blocked_by?.kind===`approval`?e.blocked_by.approval_id:e.blocked_by?.kind===`clarification`?e.blocked_by.round_id:e.updated_at}`,title:KB,summary:e.summary,tone:`pending`,metaLabel:`Needs input`,completionTarget:t,steps:[{id:`waiting_for_input`,label:`Needs input`,status:`pending`}]}}function xV(e){let t=e.last_conclusion?.task_id??(e.status===`failed`?e.active_task?.id:void 0);return t===void 0&&e.status!==`failed`?null:{key:`failed:${t??e.updated_at}`,title:KB,summary:e.last_conclusion?.summary??e.summary,tone:`failed`,metaLabel:`Failed`,...t===void 0?{}:{completionTarget:{kind:`task`,taskId:t}},steps:[{id:`run_failed`,label:`Run failed`,status:`failed`}]}}function SV(e,t={}){let n=vV(e,t);if(n!==null)return n;let r=yV(e,t);if(r!==null)return r;let i=hV(e,t);return i===null?e.status===`pending`?bV(e):e.status===`failed`?xV(e):null:i}function CV(e){let t=e.activeTaskCompileClarification&&!e.activeScratchpadRefreshFromSubmit&&!e.activeProjectContextBootstrap&&!e.activeTaskCompile,n=[],r=tV(e.startedAt,e);if(e.activeProjectContextBootstrap)n.push({id:`scratchpad_submit:project_context`,label:`Preparing project context`,status:`running`,...r===void 0?{}:{elapsedLabel:r},detail:`Creating project context for the first time`});else if(e.activeTaskCompile||e.activeScratchpadRefreshFromSubmit){let t=e.activeTaskCompile?aV(e.runtime):[];n.push({id:`scratchpad_submit:task_compile`,label:`Compiling Worklist tasks`,status:`running`,...r===void 0?{}:{elapsedLabel:r},...t.length===0?{}:{metrics:t}})}else n.push({id:`scratchpad_submit:task_compile`,label:`Compiling Worklist tasks`,status:t?`done`:`running`});t&&n.push({id:`scratchpad_submit:needs_input`,label:`Needs input`,status:`pending`});let i=n.find(e=>e.status===`running`||e.status===`pending`)?.label??`Compiling Worklist tasks`;return{key:`scratchpad-submit`,title:KB,summary:t?`Task compilation needs a decision before Worklist can update.`:`Preparing the Scratchpad for formal tasks.`,tone:t?`pending`:`running`,metaLabel:t?`Needs input`:i,completionTarget:t?{kind:`clarification`}:{kind:`scratchpad`},steps:n}}function wV(e,t){return{...e,key:`${e.key}:complete`,title:KB,summary:t,tone:`complete`,metaLabel:`Complete`,steps:e.steps.map(e=>({...e,status:`done`}))}}function TV(e,t){let n=e.completionSource;return n===void 0?!0:n.activityRef===void 0?n.workflowRef===void 0?n.taskId===void 0?!0:t.task_id===n.taskId:t.workflow_ref===n.workflowRef:t.activity_ref===n.activityRef}function EV(e){if(e.status===`idle`)return[];let t=[];if(e.status===`pending`){let n=e.blocked_by?.kind===`approval`?{kind:`approval`}:{kind:`clarification`};t.push({key:`pending`,label:`Needs input`,title:`Needs input`,tone:`pending`,target:n})}let n=e.last_conclusion?.kind===`failed`?e.last_conclusion.task_id:e.status===`failed`?e.active_task?.id??e.last_conclusion?.task_id:void 0;if(n!==void 0&&t.push({key:`failed`,label:`Run failed`,tone:`failed`,target:{kind:`task`,taskId:n}}),e.status===`running`&&e.active_task!==void 0){let n=pV(e.summary);t.push({key:`running`,label:n.label,title:n.label,tone:`running`,target:{kind:`task`,taskId:e.active_task.id}})}let r=mV(e);return r!==null&&t.push(r),t}var DV=`http://127.0.0.1:4370`;function OV(){return typeof window<`u`?window.location.origin:DV}function kV(){let e=`https://tutti.now`;return typeof e==`string`?e:OV()}var AV=kV(),jV={relayBaseUrl:AV},MV=3e4,Z={relayRoot:[`relay`],me:[`relay`,`me`],recentProjects:[`relay`,`projects`,`recent`],accountProjects:[`relay`,`account-projects`],projectPresence:e=>[`relay`,`projects`,e,`presence`],relayJoinRoot:[`relay`,`join`],join:e=>[`relay`,`join`,e],bootstrap:e=>[`host`,e,`bootstrap`],hostRoot:e=>[`host`,e],hostSession:e=>[`host`,e,`session`],hostWorkspace:e=>[`host`,e,`workspace`],messages:e=>[`host`,e,`messages`,`main_chat`],messagesWindow:(e,t)=>[...Z.messages(e),{limit:t}],messagesAround:(e,t,n)=>[...Z.messages(e),{around:t,limit:n}],messageHistory:(e,t,n)=>[...Z.messages(e),{history:t,limit:n}],scratchpad:e=>[`host`,e,`scratchpad`],worklist:e=>[`host`,e,`worklist`],readState:e=>[`host`,e,`read-state`],activeClarification:e=>[`host`,e,`clarification`,`active`],activeApproval:e=>[`host`,e,`approval`,`active`],noActiveClarificationRoundMessages:e=>[`host`,e,`clarification-round-messages`,`none`],clarificationRoundMessages:(e,t)=>[`host`,e,`clarification-round-messages`,t],task:(e,t)=>[`host`,e,`task`,t],taskDetail:(e,t)=>[`host`,e,`task-detail`,t],taskRunResults:(e,t)=>[`host`,e,`task-run-results`,t],executionStatus:e=>[`host`,e,`execution-status`],providerConfig:e=>[`host`,e,`provider-config`],providerUsage:e=>[`host`,e,`provider-usage`],projectTimeline:e=>[`host`,e,`project-timeline`],viewerRoot:e=>[`host`,e,`viewer`],viewerFile:(e,t)=>[`host`,e,`viewer`,`file`,t],referenceFiles:e=>[`host`,e,`references`,`files`],artifacts:e=>[`host`,e,`artifacts`],artifactPreviewSession:(e,t)=>[`relay`,e,`artifact-preview-session`,t],skills:e=>[`host`,e,`skills`],skillDetail:(e,t)=>[`host`,e,`skills`,t]};function NV(){return`${window.location.pathname}${window.location.search}${window.location.hash}`}function Q(e,t={}){t.replace===!0?window.history.replaceState(null,``,e):window.history.pushState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function PV(e){let t=new URL(e,window.location.origin);Q(`${t.pathname}${t.search}${t.hash}`)}function FV(){let[e,t]=(0,I.useState)(NV);return(0,I.useEffect)(()=>{let e=()=>{t(NV())};return window.addEventListener(`popstate`,e),e(),()=>{window.removeEventListener(`popstate`,e)}},[]),(0,I.useMemo)(()=>{let t=new URL(e,window.location.origin);return Ib(t.pathname,t.search)},[e])}function $(e){return e instanceof Error?e.message:`Request failed`}function IV(e){e.invalidateQueries({queryKey:Z.me}),e.invalidateQueries({queryKey:Z.recentProjects}),e.invalidateQueries({queryKey:Z.accountProjects})}function LV(e,t){if(t!==void 0)for(let n of t)switch(n.kind){case`all`:e.invalidateQueries({queryKey:Z.relayRoot});break;case`me`:e.invalidateQueries({queryKey:Z.me});break;case`recent_projects`:e.invalidateQueries({queryKey:Z.recentProjects}),e.invalidateQueries({queryKey:Z.accountProjects});break;case`join_entries`:e.invalidateQueries({queryKey:Z.relayJoinRoot});break;case`project_presence`:Rt(n.relay_project_ref,Pt.relayProject)&&e.invalidateQueries({queryKey:Z.projectPresence(n.relay_project_ref)});break}}function RV(e){let t=et(),n=(0,I.useMemo)(()=>Gn(jV),[]);(0,I.useEffect)(()=>{if(e)try{let e=n.connectEvents({onReady:e=>{e.payload.replay.status===`missed`&&t.invalidateQueries({queryKey:Z.relayRoot})},onInvalidate:e=>{LV(t,e)}});return()=>{e.close()}}catch{return}},[e,t,n])}function zV(e,t,n){if(n!==void 0)for(let r of n)switch(r.kind){case`all`:e.invalidateQueries({queryKey:Z.hostRoot(t)});break;case`workspace`:e.invalidateQueries({queryKey:Z.hostWorkspace(t)}),e.invalidateQueries({queryKey:Z.projectTimeline(t)});break;case`session`:e.invalidateQueries({queryKey:Z.hostSession(t)});break;case`bootstrap`:e.invalidateQueries({queryKey:Z.bootstrap(t)});break;case`messages`:r.scope===`main_chat`?e.invalidateQueries({queryKey:Z.messages(t)}):e.invalidateQueries({queryKey:Z.clarificationRoundMessages(t,r.round_id)});break;case`scratchpad`:e.invalidateQueries({queryKey:Z.scratchpad(t)});break;case`worklist`:e.invalidateQueries({queryKey:Z.worklist(t)});break;case`read_state`:e.invalidateQueries({queryKey:Z.readState(t)});break;case`task`:e.invalidateQueries({queryKey:Z.task(t,r.task_id)});break;case`task_detail`:e.invalidateQueries({queryKey:Z.taskDetail(t,r.task_id)});break;case`task_run_results`:e.invalidateQueries({queryKey:Z.taskRunResults(t,r.task_id)}),e.invalidateQueries({queryKey:Z.projectTimeline(t)});break;case`execution_status`:e.invalidateQueries({queryKey:Z.executionStatus(t)});break;case`approval`:e.invalidateQueries({queryKey:Z.activeApproval(t)});break;case`provider_config`:e.invalidateQueries({queryKey:Z.providerConfig(t)});break;case`provider_usage`:e.invalidateQueries({queryKey:Z.providerUsage(t)}),e.invalidateQueries({queryKey:Z.projectTimeline(t)});break;case`project_timeline`:e.invalidateQueries({queryKey:Z.projectTimeline(t)});break;case`viewer`:e.invalidateQueries({queryKey:Z.viewerRoot(t)}),e.invalidateQueries({queryKey:Z.projectTimeline(t)}),(r.path===void 0||r.path.startsWith(`docs/reference`))&&e.invalidateQueries({queryKey:Z.referenceFiles(t)}),r.path!==void 0&&e.invalidateQueries({queryKey:Z.viewerFile(t,r.path)});break;case`skills`:e.invalidateQueries({queryKey:Z.skills(t)});break;case`artifacts`:e.invalidateQueries({queryKey:Z.artifacts(t)});break;case`recovery_summaries`:e.invalidateQueries({queryKey:Z.projectTimeline(t)});break;case`activity`:break;case`clarification`:e.invalidateQueries({queryKey:Z.activeClarification(t)}),e.invalidateQueries({queryKey:Z.projectTimeline(t)}),r.round_id!==void 0&&e.invalidateQueries({queryKey:Z.clarificationRoundMessages(t,r.round_id)});break}}function BV(){return{items:[],window:{has_older:!1,has_newer:!1,limit:50}}}function VV(){return{modules:[]}}function HV(){return{id:`current`,state:`empty`,topic:``,background_summary:``,current_consensus:[],open_questions:[],task_changes:[],receipts:[]}}function UV(e){return{chat:e?.scopes.chat.has_unread===!0,worklist:e?.scopes.worklist.has_unread===!0,references:e?.scopes.references.has_unread===!0,skills:e?.scopes.skills.has_unread===!0}}function WV({enabled:e,hostClient:t,relayProjectRef:n,readState:r,scope:i}){let a=et(),o=(0,I.useRef)(null),s=gt({mutationFn:e=>t.markRead({scope:i,up_to_event_cursor:e}),onSuccess:e=>{zV(a,n,e.invalidates)},onError:()=>{o.current=null}});(0,I.useEffect)(()=>{if(!e||r===void 0)return;let t=r.scopes[i];if(!t.has_unread){t.read_event_cursor>=t.latest_event_cursor&&(o.current=null);return}let n=`${i}:${t.latest_event_cursor}`;o.current===n||s.isPending||(o.current=n,s.mutate(t.latest_event_cursor))},[e,s,r,i])}function GV(){return{state:`none`}}function KV(e){return{status:`idle`,summary:`Idle`,updated_at:e}}function qV(e){return e.active_activities??(e.active_activity===void 0?[]:[e.active_activity])}function JV(e,t,n){return qV(e).some(e=>e.workflow_kind===t?n===void 0||(e.lane??`foreground`)===n:!1)}function YV(e){return e.blocked_by?.kind===`clarification`||e.blocked_by?.kind===`approval`?!0:qV(e).some(e=>e.activity_kind===`run`?!0:(e.lane??`foreground`)===`foreground`)}function XV(e,t){let n=`/projects/${encodeURIComponent(zt(e))}/references`;return t===void 0?n:`${n}?path=${encodeURIComponent(t)}`}function ZV(e){return`/projects/${encodeURIComponent(zt(e))}/artifacts`}function QV(e,t){let n=`/projects/${encodeURIComponent(zt(e))}/worklist`;return t===void 0?n:`${n}?task=${encodeURIComponent(t)}`}function $V(e,t){return`${en(e)}?message=${encodeURIComponent(t)}`}function eH(e){return`/projects/${encodeURIComponent(zt(e))}/settings`}function tH(e){return`/projects/${encodeURIComponent(zt(e))}/timeline`}function nH(e,t){let n=`/projects/${encodeURIComponent(zt(e))}/skills`;return t===void 0?n:`${n}?skill=${encodeURIComponent(t)}`}function rH(e,t){switch(t.target.kind){case`approval`:case`clarification`:case`scratchpad`:return en(e);case`worklist`:return QV(e);case`references`:return XV(e);case`task`:return QV(e,t.target.taskId)}}function iH(e,t){Q(rH(e,t))}function aH(e,t){let n=fB(e);if(t!==void 0&&n.some(e=>e.id===t))return t;for(let e of[`running`,`pending`,`failed`,`todo`,`done`]){let t=n.find(t=>t.status===e);if(t!==void 0)return t.id}}function oH(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function sH(e){switch(e){case`binary`:return`Binary file`;case`too_large`:return`File too large`;case`unsupported_encoding`:return`Unsupported encoding`;case`restricted_path`:case`secret_like`:return`Restricted file`;default:return`Preview unavailable`}}function cH(e){if(!(e===void 0||e.kind===`text`))return sH(e.reason)}function lH(e){return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function uH(e){if(globalThis.crypto?.subtle===void 0)throw Error(`This browser does not support file upload hashing.`);return`sha256:${lH(await globalThis.crypto.subtle.digest(`SHA-256`,await e.arrayBuffer()))}`}async function dH(e){if(e.file.size<=0)throw Error(`Upload file cannot be empty.`);let t=Xg(e.purpose);if(e.file.size>t)throw Error(`Upload file cannot exceed ${oH(t)}.`);let n=await uH(e.file),r=e.file.type===``?void 0:e.file.type,i=Gn(jV),a=e.purpose===`skill_zip`?{relay_project_ref:e.relayProjectRef,purpose:`skill_zip`,file_name:e.file.name,size_bytes:e.file.size,sha256:n,...r===void 0?{}:{media_type:r}}:{relay_project_ref:e.relayProjectRef,purpose:`reference_file`,file_name:e.file.name,size_bytes:e.file.size,sha256:n,...r===void 0?{}:{media_type:r}},o=await i.startUpload(a);if(o.result===void 0)throw Error(`Upload session could not be started.`);let s=new Headers(o.result.put.headers??{});r!==void 0&&!s.has(`content-type`)&&s.set(`content-type`,r);let c;try{c=await fetch(o.result.put.url,{method:o.result.put.method,headers:s,body:e.file})}catch{throw Error(`File upload failed while sending the file to upload storage. Check that R2 CORS allows PUT from this Web origin.`)}if(!c.ok)throw Error(`File upload failed while sending the file to upload storage (${c.status}).`);return{upload_id:o.result.upload.upload_id,file_name:o.result.upload.file_name,size_bytes:o.result.upload.size_bytes,sha256:o.result.upload.sha256,...o.result.upload.media_type===void 0?{}:{media_type:o.result.upload.media_type}}}function fH(e){let t=et(),n=Dz(),[r,i]=(0,I.useState)(`identity`),[a,o]=(0,I.useState)(null),[s,c]=(0,I.useState)({email:``,displayName:``,code:``}),l=gt({mutationFn:async()=>{let e=s.email.trim(),t=await Xn(jV,{email:e});if(t.result===void 0)throw Error(`Login challenge was not returned`);return{challenge:t.result.challenge,disposition:t.disposition,email:e}},onSuccess:({challenge:e,disposition:t,email:r})=>{o(e),c(e=>({...e,code:``})),i(`code`),n.notify({tone:`success`,title:t.kind===`otp_already_pending`?`Verification email already sent`:`Verification email sent`,message:t.kind===`otp_already_pending`?`Verification email already sent to ${r}.`:`Verification email sent to ${r}.`})}}),u=gt({mutationFn:async()=>{if(a===null)throw Error(`Login challenge is missing`);return ir(jV,{challenge_ref:a.challenge_ref,code:s.code.trim()},s.email)},onSuccess:n=>{if(!n.account.profile_complete){t.invalidateQueries({queryKey:Z.me}),c(e=>({...e,displayName:``})),i(`profile`);return}IV(t),e?.()}}),d=gt({mutationFn:async()=>{let e=await Zn(jV,{display_name:s.displayName.trim()});if(e.result===void 0)throw Error(`Profile response was not returned`);return e.result.account},onSuccess:()=>{IV(t),e?.()}}),f=e=>{if(e.preventDefault(),r===`identity`&&s.email.trim()!==``){l.mutate();return}if(r===`code`&&a!==null&&s.code.trim()!==``){u.mutate();return}r===`profile`&&s.displayName.trim()!==``&&d.mutate()},p=l.isPending||u.isPending||d.isPending,m=r===`identity`?l.error:r===`code`?u.error??l.error:d.error;return{phase:r,form:s,pending:p,submitDisabled:r===`identity`?s.email.trim()===``:r===`code`?a===null||s.code.replace(/\s+/gu,``).length!==6:s.displayName.trim()===``,challengeEmailHint:a?.email_hint??null,error:m===null?null:$(m),onChange:e=>{c(t=>({...t,...e,...e.code===void 0?{}:{code:e.code.replace(/\D/gu,``).slice(0,6)}}))},onSubmit:f,onBack:()=>{l.reset(),u.reset(),d.reset(),o(null),c(e=>({...e,code:``})),i(`identity`)}}}function pH(e){let t=et(),[n,r]=(0,I.useState)({email:``,displayName:``,code:``}),i=gt({mutationFn:async()=>{let e=await Zn(jV,{display_name:n.displayName.trim()});if(e.result===void 0)throw Error(`Profile response was not returned`);return e.result.account},onSuccess:()=>{IV(t),e?.()}});return{phase:`profile`,form:n,pending:i.isPending,submitDisabled:n.displayName.trim()===``,challengeEmailHint:null,error:i.error===null?null:$(i.error),onChange:e=>{r(t=>({...t,...e,...e.code===void 0?{}:{code:e.code.replace(/\D/gu,``).slice(0,6)}}))},onSubmit:e=>{e.preventDefault(),n.displayName.trim()!==``&&i.mutate()}}}var mH=mb(jV);function hH({entryRef:e}){let[t,n]=(0,I.useState)(``),[r,i]=(0,I.useState)(!0),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(),[d,f]=(0,I.useState)(0),p=(0,I.useRef)(!1),m=(0,I.useRef)(void 0);(0,I.useEffect)(()=>n(``),[e]),(0,I.useEffect)(()=>{let t=new AbortController;return m.current=t,p.current=!1,o(!1),i(!0),u(void 0),c(!1),hz(`connection_resolve`,async n=>{if(e===null||window.location.hash!==``)throw new Gt({message:`Invalid group entry`,code:`bad_request`,statusCode:0,retryable:!1,details:{reason_code:`connection_entry_unavailable`}});return mH.resolve(e,{signal:t.signal,diagnostics:n})}).then(e=>{t.signal.aborted||(e.kind===`bound`?Q(tn(e.relay_project_ref),{replace:!0}):c(!0))}).catch(e=>{t.signal.aborted||u(gz(e,oz()))}).finally(()=>{t.signal.aborted||i(!1)}),()=>t.abort()},[e,d]);async function h(){if(p.current||e===null||qy(t)===null)return;p.current=!0,o(!0),u(void 0);let r=m.current.signal;try{let i=await hz(`connection_resolve`,t=>mH.resolve(e,{signal:r,diagnostics:t}));if(r.aborted)return;if(i.kind===`bound`){n(``),Q(tn(i.relay_project_ref),{replace:!0});return}let a=await hz(`connection_bootstrap`,t=>mH.bootstrap(e,{signal:r,diagnostics:t}));if(r.aborted)return;let o=oz(),s;try{s=await nz({appId:a.app_id,state:a.state})}catch(e){throw new iz(`h5_request_access`,e,o)}if(r.aborted)return;let c=await hz(`connection_connect`,n=>mH.connect({entry_ref:e,state:a.state,authorization_code:s,input:t},{signal:r,diagnostics:n}));if(r.aborted)return;if(c.kind!==`bound`)throw new iz(`connection_connect`,Error(`connection_not_established`));n(``),Q(tn(c.relay_project_ref),{replace:!0})}catch(e){r.aborted||u(gz(e,oz()))}finally{m.current?.signal===r&&(p.current=!1,r.aborted||o(!1))}}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:{kind:`feishu_connection`,entryRef:e}}),(0,L.jsx)(GR,{loading:r,pending:a,unbound:s,value:t,canSubmit:qy(t)!==null,...l===void 0?{}:{error:l},onChange:n,onConnect:()=>void h(),onRefresh:()=>{p.current||f(e=>e+1)}})]})}var gH=`/assets/beethoven-symphony-5-opening-ypVy5SB4.svg`,_H=`/assets/beethoven-symphony-7-allegretto-B3bc-cZD.svg`,vH=`/assets/dvorak-symphony-9-largo-BEgNL3HB.svg`,yH=`/assets/mozart-symphony-18-allegro-B5-MrLL1.svg`,bH=`https://lets.tutti.now`,xH=`${bH}/start/create-a-project#connect-a-provider-and-choose-a-model`,SH={href:bH,target:`_blank`,rel:`noopener noreferrer`};function CH(){return(0,L.jsxs)(hO,{children:[`New to Tutti?`,` `,(0,L.jsx)(`a`,{...SH,"aria-label":`Read the Tutti documentation (opens in a new tab)`,children:`Read the docs`}),`.`]})}function wH(){return(0,L.jsx)(zw,{...SH,label:`Support Center`,icon:(0,L.jsx)(ax,{"aria-hidden":`true`})})}var TH=[gH,_H,vH,yH];function EH(){return TH[Math.min(TH.length-1,Math.floor(Math.random()*TH.length))]}function DH({backgroundPattern:e,children:t,...n}){let[r]=(0,I.useState)(EH);return(0,L.jsx)(WC,{...e===void 0?{backgroundImageSrc:r}:{backgroundPattern:e},...n,children:t})}function OH({actions:e,children:t,onBrandClick:n}){return(0,L.jsxs)(DH,{children:[(0,L.jsx)(GC,{brand:(0,L.jsx)(UR,{onClick:n}),actions:e}),t]})}function kH({children:e,label:t,onBrandClick:n}){return(0,L.jsx)(OH,{onBrandClick:n,children:(0,L.jsx)(qC,{"aria-label":t,children:e})})}function AH({auth:e,mobileAuth:t,onBrandClick:n}){return(0,L.jsx)(DH,{backgroundPattern:`dots`,className:`homepage-entry-page`,children:(0,L.jsx)(mO,{brand:(0,L.jsx)(UR,{onClick:n}),visual:(0,L.jsx)(YO,{assets:VR}),auth:e,mobileAuth:t,footer:(0,L.jsx)(CH,{})})})}function jH({phase:e,form:t,onChange:n}){return e===`code`?(0,L.jsx)(`div`,{className:`form-stack`,children:(0,L.jsx)(Fw,{label:`Email verification code`,children:(0,L.jsx)(jw,{autoComplete:`one-time-code`,inputMode:`numeric`,type:`text`,value:t.code,onChange:e=>n({code:e.target.value}),placeholder:`Enter email code`,maxLength:6})})}):e===`profile`?(0,L.jsxs)(`div`,{className:`form-stack`,children:[(0,L.jsx)(Fw,{label:`Display name`,children:(0,L.jsx)(jw,{autoComplete:`name`,type:`text`,value:t.displayName,onChange:e=>n({displayName:e.target.value}),placeholder:`username`})}),(0,L.jsx)(`p`,{className:`form-note`,children:`This name cannot be changed yet.`})]}):(0,L.jsx)(`div`,{className:`form-stack`,children:(0,L.jsx)(Fw,{label:`Email`,children:(0,L.jsx)(jw,{autoComplete:`email`,type:`email`,value:t.email,onChange:e=>n({email:e.target.value}),placeholder:`alex@example.com`})})})}function MH({surface:e,phase:t,form:n,pending:r,error:i,submitDisabled:a,submitLabel:o,pendingLabel:s,onChange:c,onSubmit:l,onBack:u}){let d={title:t===`profile`?`Choose display name`:`Sign in`,description:t===`profile`?`Set the name your teammates will see.`:t===`code`?`Enter your email verification code.`:`Use your email to continue.`,onSubmit:l,action:(0,L.jsxs)(Cw,{type:`submit`,disabled:a||r,children:[r?s??(t===`profile`?`Saving`:t===`code`?`Verifying`:`Sending code`):o??(t===`profile`?`Save name`:t===`code`?`Verify email code`:`Send code`),(0,L.jsx)(Zb,{"aria-hidden":`true`})]}),secondaryAction:t===`code`&&u!==void 0?(0,L.jsxs)(Y,{type:`button`,onClick:u,disabled:r,children:[(0,L.jsx)(Xb,{"aria-hidden":`true`}),`Change email`]}):void 0,feedback:i===null?void 0:(0,L.jsx)(Iw,{children:i}),children:(0,L.jsx)(jH,{phase:t,form:n,onChange:c})};return e===`card`?(0,L.jsx)(bk,{...d}):(0,L.jsx)(gO,{...d})}function NH(e){return(0,L.jsx)(MH,{...e,surface:`card`})}function PH(e){return(0,L.jsx)(MH,{...e,surface:`rail`})}function FH({onBrandClick:e,...t}){return(0,L.jsx)(AH,{onBrandClick:e,auth:(0,L.jsx)(PH,{...t}),mobileAuth:(0,L.jsx)(NH,{...t})})}function IH({nextKind:e,actionPending:t,loginForm:n,onRetry:r,onAccept:i,onOpen:a}){if(e===`loading`)return(0,L.jsx)(Y,{type:`button`,disabled:!0,children:`Loading`});if(e===`error`)return(0,L.jsx)(Y,{type:`button`,onClick:r,children:`Retry`});if(e===`invalid_or_expired`)return(0,L.jsxs)(Y,{type:`button`,disabled:!0,children:[(0,L.jsx)(eS,{"aria-hidden":`true`}),`Invalid invite`]});if(e===`login_required`){let e=n?.phase===`profile`?`Save name`:n?.phase===`code`?`Verify email code`:`Send code`,r=n?.phase===`profile`?`Saving`:n?.phase===`code`?`Verifying`:`Sending code`;return(0,L.jsxs)(Cw,{type:`submit`,disabled:t||n?.submitDisabled===!0,children:[t?r:e,(0,L.jsx)(Zb,{"aria-hidden":`true`})]})}return e===`accept_join`?(0,L.jsxs)(Cw,{type:`button`,disabled:t,onClick:i,children:[t?`Joining`:`Accept and open workspace`,(0,L.jsx)(Zb,{"aria-hidden":`true`})]}):e===`open_workspace`?(0,L.jsxs)(Cw,{type:`button`,disabled:t,onClick:a,children:[t?`Opening`:`Open workspace`,(0,L.jsx)(Zb,{"aria-hidden":`true`})]}):(0,L.jsxs)(Y,{type:`button`,disabled:!0,children:[(0,L.jsx)(Lx,{"aria-hidden":`true`}),`Host offline`]})}function LH({nextKind:e,error:t}){return e===`loading`?null:e===`error`?(0,L.jsx)(aS,{tone:`error`,icon:(0,L.jsx)(eS,{"aria-hidden":`true`}),children:t??`Invite unavailable`}):e===`invalid_or_expired`?(0,L.jsx)(aS,{tone:`error`,icon:(0,L.jsx)(eS,{"aria-hidden":`true`}),children:`Join token is invalid or expired`}):e===`host_offline`?(0,L.jsx)(aS,{tone:`warning`,icon:(0,L.jsx)(Lx,{"aria-hidden":`true`}),children:`Host is offline`}):null}function RH({projectName:e,description:t,hostLabel:n,hostOnline:r,nextKind:i,accountLabel:a,membershipLabel:o,actionPending:s,error:c,loginForm:l,onBrandClick:u,onRetry:d,onAccept:f,onOpen:p}){let m=i===`login_required`&&l!==void 0;return(0,L.jsx)(kH,{label:`Join project`,onBrandClick:u,children:(0,L.jsxs)(bk,{title:`Join project`,description:t,onSubmit:e=>{if(m){l.onSubmit(e);return}e.preventDefault()},action:(0,L.jsx)(IH,{nextKind:i,actionPending:m?l.pending:s,...m?{loginForm:l}:{},onAccept:f,onOpen:p,...d===void 0?{}:{onRetry:d}}),secondaryAction:m&&l.phase===`code`&&l.onBack!==void 0?(0,L.jsxs)(Y,{type:`button`,onClick:l.onBack,disabled:l.pending,children:[(0,L.jsx)(Xb,{"aria-hidden":`true`}),`Change email`]}):void 0,feedback:(0,L.jsxs)(L.Fragment,{children:[m&&l.error!==null?(0,L.jsx)(Iw,{children:l.error}):null,(0,L.jsx)(LH,{nextKind:i,error:c}),c===null||i===`error`?null:(0,L.jsx)(Iw,{children:c})]}),children:[(0,L.jsx)(xk,{projectName:e,hostLabel:n,hostOnline:r}),m?(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(jH,{phase:l.phase,form:l.form,onChange:l.onChange})}):(0,L.jsx)(Sk,{label:a===null?`Account`:`Signed in as`,value:a??`Sign in required`,action:o===null?null:(0,L.jsx)(`span`,{className:`quiet-link`,children:o})})]})})}var zH=`http://127.0.0.1:4370`;function BH(){let e=`https://tutti.now`;return typeof e==`string`?e:typeof window<`u`&&window.location.port!==`4372`?window.location.origin:zH}function VH(e){try{return new URL(e,BH()).toString()}catch{return e}}function HH({avatar:e,label:t,plain:n=!1,online:r=!1}){return(0,L.jsx)(ZC,{label:t,tone:e.color,plain:n,online:r,initials:e.initials,...e.kind===`image`?{imageUrl:VH(e.image_url)}:{}})}function UH({label:e=`Tutti`}){return(0,L.jsx)(ZC,{label:e,tone:`green`,className:`is-system`,imageUrl:BR,icon:(0,L.jsx)($b,{"aria-hidden":`true`})})}function WH({message:e}){return e.avatarKind===`tutti`?(0,L.jsx)(UH,{label:e.author}):(0,L.jsx)(HH,{avatar:e.avatar??{kind:`initials`,initials:k_(e.author),color:`blue`},label:e.author})}function GH({supportingContent:e,state:t,onRetry:n,onBrandClick:r,onSelectTab:i,onSelectTask:a,onCloseTask:o,onSubmitScratchpad:s,onRoundDraftChange:c,onSendRoundMessage:l,onSubmitRound:u,onDecideApproval:d,onOpenInBrowser:f,browserOpenUrl:p,onBrowserOpenLinkClick:m,scratchpadSubmitPending:h=!1,scratchpadSyncPending:g=!1,scratchpadActionsDisabled:_=!1,roundSendPending:v=!1,roundSubmitPending:y=!1,approvalDecisionPending:b=!1,browserOpenPending:x=!1}){let[S,C]=(0,I.useState)(!1);if(t.kind===`loading`)return(0,L.jsx)(EL,{brand:(0,L.jsx)(UR,{label:`Reload Tutti project`,onClick:r}),projectName:`Opening Tutti`,meta:`Feishu project`,children:(0,L.jsx)(oS,{count:3})});if(t.kind===`error`)return(0,L.jsx)(EL,{brand:(0,L.jsx)(UR,{label:`Reload Tutti project`,onClick:r}),projectName:`Tutti isn’t available`,meta:`Feishu project`,onRefresh:n,children:(0,L.jsx)(aS,{icon:(0,L.jsx)(eS,{"aria-hidden":`true`}),tone:`warning`,details:(0,L.jsx)(WR,{diagnostic:t,showMessage:!1}),children:t.message})});let w=t.activeClarification??null,T=t.clarificationMessages??[],E=t.activeApproval??null;return(0,L.jsxs)(EL,{activeTab:t.activeTab,actions:w!==null||E!==null?(0,L.jsx)(Y,{className:`embedded-project-status-action`,"aria-label":`Review required input`,onClick:()=>C(!0),children:(0,L.jsx)(ww,{tone:t.projectStatus.tone??`neutral`,children:t.projectStatus.label})}):(0,L.jsx)(ww,{tone:t.projectStatus.tone??`neutral`,children:t.projectStatus.label}),brand:(0,L.jsx)(UR,{label:`Reload Tutti project`,onClick:r}),projectName:t.projectName,showProjectName:!1,refreshing:t.refreshing,onRefresh:n,onSelectTab:i,children:[t.refreshMessage===void 0?null:(0,L.jsx)(`div`,{className:`embedded-project-refresh-message`,role:`status`,children:(0,L.jsx)(WR,{diagnostic:t.refreshMessage})}),(0,L.jsxs)(OL,{open:S&&(w!==null||E!==null),title:`Needs your input`,onClose:()=>C(!1),children:[w===null?null:(0,L.jsx)(IL,{title:w.title,summary:w.summary,request:w.request,contextLabel:w.ownerLabel,messages:T.map(e=>({id:e.id,author:e.author,body:e.body,time:e.time,avatar:(0,L.jsx)(WH,{message:e})})),replyCount:w.answerRevision??T.filter(e=>e.isClarificationAnswer??e.messageKind===`user_text`).length,draft:t.roundDraft??``,defaultOpen:!0,readOnly:w.status!==`writable`,status:w.status===`writable`?`pending`:`done`,statusLabel:w.status===`writable`?`needs input`:`submitted`,sendPending:v,submitPending:y,onDraftChange:e=>c?.(e),onSendMessage:e=>{e.preventDefault(),l?.()},onSubmitRound:()=>u?.()}),E===null?null:(0,L.jsx)(BL,{title:E.title,summary:E.summary,...E.reason===void 0?{}:{reason:E.reason},...E.detail===void 0?{}:{detail:E.detail,...E.detailLabel===void 0?{}:{detailLabel:E.detailLabel},...E.detailCode===void 0?{}:{detailCode:E.detailCode}},status:E.status,statusLabel:E.statusLabel,decisions:E.decisions,decisionPending:b,...E.resolutionLabel===void 0?{}:{resolutionLabel:E.resolutionLabel},onDecide:e=>d?.(E.approvalId,e)})]}),t.activeTab===`timeline`?(0,L.jsx)(`div`,{className:`embedded-project-supporting`,children:e}):t.activeTab===`project`?(0,L.jsx)(`div`,{className:`embedded-project-stack`,children:(0,L.jsx)(xL,{...t.scratchpad,presentation:`document`,compact:!0,empty:(0,L.jsx)(aS,{children:`Start with a conversation in the group.`}),showSubmitAction:!0,submitPending:h,syncPending:g,actionsDisabled:_||s===void 0,...s===void 0?{}:{onSubmitScratchpad:s},onOpenCompiledTask:a})}):t.activeTab===`work`?(0,L.jsx)(`div`,{className:`embedded-project-work`,children:(0,L.jsx)(YL,{layout:`sheet`,detailOpen:t.worklist.detailOpen??!1,...o===void 0?{}:{onCloseDetail:o},modules:t.worklist.modules,taskCount:t.worklist.taskCount,...t.worklist.detail===void 0?{}:{detail:t.worklist.detail},...t.worklist.detailPlaceholder===void 0?{}:{detailPlaceholder:t.worklist.detailPlaceholder},empty:(0,L.jsx)(aS,{children:`No tasks yet.`}),onSelectTask:a})}):(0,L.jsxs)(`div`,{className:`embedded-project-artifacts`,children:[(0,L.jsx)(aR,{presentation:`preview`,state:t.artifacts,error:t.artifactError??null}),(0,L.jsx)(`footer`,{className:`embedded-project-artifact-actions`,children:f===void 0?void 0:p===void 0?(0,L.jsxs)(xw,{"aria-label":x?`Opening in browser`:`Open in browser`,className:`embedded-project-browser-action`,disabled:x,onClick:f,type:`button`,variant:`quiet`,children:[x?(0,L.jsx)(Cx,{"aria-hidden":`true`,className:`is-spinning`}):(0,L.jsx)(dx,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:x?`Opening`:`Open in browser`})]}):(0,L.jsx)(xw,{asChild:!0,className:`embedded-project-browser-action`,variant:`quiet`,children:(0,L.jsxs)(`a`,{"aria-label":`Open in browser`,href:p,onClick:m,rel:`noopener noreferrer`,target:`_blank`,children:[(0,L.jsx)(dx,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:`Open in browser`})]})})})]})]})}function KH(e){let{form:t,onChange:n,pending:r,models:i}=e;return(0,L.jsx)(zk,{title:`Configure your model`,description:(0,L.jsxs)(L.Fragment,{children:[`Use an`,` `,(0,L.jsx)(Lw,{href:xH,icon:(0,L.jsx)(ax,{"aria-hidden":`true`}),children:`OpenAI Responses API`}),` `,`endpoint. Credentials stay on this computer.`]}),children:(0,L.jsxs)(Ik,{children:[(0,L.jsx)(Fw,{label:`Base URL`,children:(0,L.jsx)(jw,{type:`url`,autoComplete:`off`,disabled:r,value:t.baseUrl,onChange:e=>n({baseUrl:e.target.value}),placeholder:`Enter Provider Base URL`})}),(0,L.jsx)(Fw,{label:`API key`,children:(0,L.jsx)(jw,{type:`password`,autoComplete:`off`,disabled:r,value:t.apiKey,onChange:e=>n({apiKey:e.target.value}),placeholder:`Enter API key`})}),(0,L.jsx)(Fw,{label:`Model`,children:(0,L.jsx)(Nw,{"aria-label":`Model`,autoComplete:`off`,value:t.model,options:i,maxVisibleOptions:8,disabled:r,onValueChange:e=>n({model:e}),placeholder:`Choose or enter a model`})}),(0,L.jsx)(Y,{type:`button`,disabled:r||!t.baseUrl.trim()||!t.apiKey.trim(),onClick:e.onDiscover,children:r?`Checking models`:`Check models`})]})})}function qH({pending:e,onSignOut:t}){return(0,L.jsxs)(Y,{type:`button`,onClick:t,disabled:e,children:[(0,L.jsx)(Tx,{"aria-hidden":`true`}),`Sign out`]})}function JH(e){return e.existingProjectId===void 0?[`surface`,`folder`,...e.surface===`standalone`?[`details`]:[],`provider`,...e.accessMode===`byok`?[`model`]:[]]:[`provider`]}function YH(e,t){switch(e){case`folder`:return t.workspacePath.trim()!==``;case`details`:return t.displayName.trim()!==``;case`model`:return!!(t.baseUrl.trim()&&t.apiKey.trim()&&t.model.trim());default:return!0}}function XH(e){return(e.status===`online`||e.status===`reconnecting`)&&(e.provider_status===`configured`||e.provider_status===`managed`)}function ZH(e){return(e.status===`stopped`||e.status===`stale`||e.status===`relay-unavailable`)&&(e.provider_status===`configured`||e.provider_status===`managed`)}function QH(e){return e.status===`online`?`online`:e.status===`reconnecting`?`connecting`:`stopped`}function $H(e,t){let n=Date.parse(e.activity_at??``),r=Date.parse(t.activity_at??``),i=Number.isNaN(n)?0:n;return(Number.isNaN(r)?0:r)-i||e.display_name.localeCompare(t.display_name,`en`)||e.project_id.localeCompare(t.project_id,`en`)}function eU({project:e,pending:t,showPrimary:n=!0,onLaunch:r,onOpen:i,onCopyInvite:a,onConnectFeishu:o,onStop:s,onAuthorize:c}){return e.status===`online`||e.status===`reconnecting`?e.surface_profile.kind===`feishu`?(0,L.jsxs)(L.Fragment,{children:[n?(0,L.jsxs)(Cw,{type:`button`,disabled:t,onClick:o,children:[(0,L.jsx)(xx,{"aria-hidden":`true`}),`Connect`]}):null,(0,L.jsxs)(Y,{type:`button`,disabled:t,onClick:s,children:[(0,L.jsx)(Xx,{"aria-hidden":`true`}),`Stop`]})]}):(0,L.jsxs)(L.Fragment,{children:[n?(0,L.jsxs)(Cw,{type:`button`,disabled:t||e.open_url===void 0,onClick:i,children:[(0,L.jsx)(Zb,{"aria-hidden":`true`}),`Open`]}):null,(0,L.jsxs)(Y,{type:`button`,disabled:t,onClick:a,children:[(0,L.jsx)(xx,{"aria-hidden":`true`}),`Invite`]}),(0,L.jsxs)(Y,{type:`button`,disabled:t,onClick:s,children:[(0,L.jsx)(Xx,{"aria-hidden":`true`}),`Stop`]})]}):(0,L.jsxs)(L.Fragment,{children:[n?(0,L.jsxs)(Y,{type:`button`,disabled:t||!ZH(e),onClick:r,children:[(0,L.jsx)(Bx,{"aria-hidden":`true`}),`Resume`]}):null,c===void 0||e.relay_project_ref===void 0?null:(0,L.jsx)(Y,{type:`button`,disabled:t,onClick:c,children:e.provider_status===`managed`?`Authorize again`:`Use Tutti trial`})]})}function tU({createDisabled:e,packageUpdateAction:t,projectsLoading:n,onCreate:r,onPackageUpdate:i,onRefresh:a}){return(0,L.jsxs)(L.Fragment,{children:[t===void 0?null:(0,L.jsx)(wk,{description:t.description,descriptionId:`local-console-package-update-description`,disabledTrigger:t.disabled,"aria-live":`polite`,action:(0,L.jsx)(Y,{type:`button`,disabled:t.disabled,onClick:i,children:t.label})}),(0,L.jsx)(Sw,{type:`button`,label:`Refresh projects`,icon:(0,L.jsx)(zx,{"aria-hidden":`true`}),disabled:n,onClick:a}),(0,L.jsxs)(Cw,{type:`button`,disabled:e,onClick:r,children:[(0,L.jsx)(Fx,{"aria-hidden":`true`}),`New project`]})]})}function nU({version:e,accountName:t,projectCenterHref:n,form:r,models:i,projects:a,projectsLoading:o,sessionLoading:s,sessionError:c,createOpen:l,createStep:u,modelDiscoveryPending:d,launchPending:f,projectActionPending:p,signOutPending:m,packageUpdateAction:h,onChange:g,onCreateOpenChange:_,onCreateSubmit:v,onCreateBack:y,onChooseFolder:b,onRefresh:x,onLaunchExisting:S,onAuthorizeExisting:C,onOpenProject:w,onCopyInvite:T,onConnectFeishu:E,onFeishuConnectionOpenChange:D,onCopyFeishuCommand:O,onStopProject:k,onPackageUpdate:A,onSignOut:j,feishuConnection:ee,managedPrepared:M=!1,managedStage:te,creditNote:N,onDiscoverModels:P,renderSurface:F}){let ne=JH(r),re=M,ie=ne.indexOf(u),ae=ie===ne.length-1,oe=d||f,se=YH(u,r),ce=a.filter(XH).sort($H),le=a.filter(ZH).sort($H),ue=[...ce,...le],de=e=>(0,I.createElement)(Vk,{title:e.display_name,status:QH(e),path:e.workspace_path,createdLabel:Az(e.created_at),...e.provider_model?.trim()?{modelLabel:e.provider_model.trim()}:{},...e.surface_profile.kind===`feishu`?{surfaceLabel:`Feishu`}:{},actions:(0,L.jsx)(eU,{project:e,pending:p===e.project_id,onLaunch:()=>S(e),onOpen:()=>w(e),onCopyInvite:()=>T(e),onConnectFeishu:()=>E(e),onStop:()=>k(e),...C===void 0?{}:{onAuthorize:()=>C(e)}}),key:e.project_id}),fe=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(Fk,{open:l,onOpenChange:_,steps:ne.map(e=>e[0].toUpperCase()+e.slice(1)),currentStep:Math.max(0,ie),closeDisabled:oe,explicitCloseOnly:!0,onSubmit:v,backAction:re||ie===0?void 0:(0,L.jsxs)(Y,{type:`button`,disabled:oe,onClick:y,children:[(0,L.jsx)(Xb,{"aria-hidden":`true`}),`Back`]}),action:(0,L.jsxs)(Cw,{type:`submit`,disabled:!se||oe||s||te===`checking`,children:[ae?(0,L.jsx)(Bx,{"aria-hidden":`true`}):(0,L.jsx)(Zb,{"aria-hidden":`true`}),re?te===`checking`?`Checking access`:te===`validating`?`Checking model access`:te===`launching`?`Starting project`:`Check and continue`:ae?f?`Preparing`:`Launch and continue`:r.existingProjectId===void 0?`Continue`:`Launch and continue`]}),children:[u===`folder`?(0,L.jsx)(zk,{title:`Project folder`,description:`Choose an existing folder on this machine. It can be empty or contain an existing project.`,children:(0,L.jsxs)(Lk,{children:[(0,L.jsx)(jw,{"aria-label":`Project folder`,autoComplete:`off`,value:r.workspacePath,onChange:e=>g({workspacePath:e.target.value}),placeholder:`Enter an absolute project folder path`,autoFocus:!0}),(0,L.jsxs)(Y,{type:`button`,onClick:b,children:[(0,L.jsx)(gx,{"aria-hidden":`true`}),`Choose folder`]})]})}):null,u===`details`?(0,L.jsx)(zk,{title:`Project details`,description:`Describe what you want to build with this project.`,children:(0,L.jsxs)(Ik,{children:[(0,L.jsx)(Fw,{label:`Project name`,className:`local-console-field-wide`,children:(0,L.jsx)(jw,{autoComplete:`off`,value:r.displayName,maxLength:80,onChange:e=>g({displayName:e.target.value}),placeholder:`Enter a project name`,autoFocus:!0})}),(0,L.jsx)(Fw,{label:`Project description (optional)`,className:`local-console-field-wide`,children:(0,L.jsx)(Mw,{value:r.description,maxLength:160,onChange:e=>g({description:e.target.value}),placeholder:`A short project description helps Tutti produce better code`})})]})}):null,u===`provider`&&!re?(0,L.jsxs)(L.Fragment,{children:[r.existingProjectId===void 0?null:(0,L.jsxs)(`p`,{children:[`Enable trial access for `,r.displayName,`. Files and collaboration surface stay unchanged. Switching from a custom endpoint starts new model sessions; existing sessions are not moved to another model.`]}),(0,L.jsx)(tk,{value:r.accessMode,onValueChange:e=>g({accessMode:e}),tuttiLogo:(0,L.jsx)(kw,{src:zR}),customIcon:(0,L.jsx)(Px,{"aria-hidden":`true`}),creditNote:N,disabled:oe,customDisabled:r.existingProjectId!==void 0}),r.accessMode===`managed`?(0,L.jsx)(rU,{}):null]}):null,u===`model`?(0,L.jsx)(KH,{form:r,models:i,pending:oe,onChange:g,onDiscover:P}):null,re?(0,L.jsx)(zk,{title:`Starting your project`,description:`Tutti will check model access and start this project. If a check fails, your setup is kept here.`,children:(0,L.jsx)(ik,{items:[{label:`Project`,value:r.displayName},{label:`Folder`,value:r.workspacePath,mono:!0},{label:`Model access`,value:`Tutti credit`}]})}):null,u===`surface`&&!re?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(nk,{value:r.surface,disabled:oe,onValueChange:e=>g({surface:e}),tuttiLogo:(0,L.jsx)(kw,{src:zR}),feishuIcon:(0,L.jsx)(Ox,{"aria-hidden":`true`})}),(0,L.jsx)(`p`,{children:`Each project uses one collaboration surface. This choice cannot be changed later.`})]}):null]}),ee===null?null:(0,L.jsx)(kk,{open:!0,onOpenChange:D,projectName:ee.projectName,state:ee.state,...ee.command===void 0?{}:{command:ee.command},...ee.unavailableMessage===void 0?{}:{unavailableMessage:ee.unavailableMessage},onCopyCommand:O})]});return F?F(fe):(0,L.jsx)(OH,{onBrandClick:x,children:(0,L.jsxs)(KC,{children:[(0,L.jsxs)(Ck,{className:`local-console-card`,title:`Projects`,accountName:t,accountAction:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Y,{asChild:!0,children:(0,L.jsx)(`a`,{href:new URL(`/projects?panel=credits`,n).toString(),target:`_blank`,rel:`noopener noreferrer`,children:`Credits`})}),(0,L.jsx)(qH,{pending:m,onSignOut:j})]}),"aria-label":`Tutti Local Console`,children:[(0,L.jsx)(Ek,{items:[{id:`joined`,label:`Your projects`,href:n},{id:`local`,label:`This computer`,href:`/console`,current:!0}],action:(0,L.jsx)(tU,{createDisabled:s||c!==null,projectsLoading:o,onCreate:()=>_(!0),onPackageUpdate:A,onRefresh:x,...h===void 0?{}:{packageUpdateAction:h}})}),(0,L.jsx)(jk,{"aria-label":`Projects on this computer`,children:o||s?(0,L.jsx)(Mk,{"aria-label":`Loading local projects`,children:(0,L.jsx)(oS,{})}):c===null?ue.length===0?(0,L.jsx)(Mk,{children:(0,L.jsx)(aS,{children:`No available projects on this computer.`})}):ue.map(de):(0,L.jsx)(Mk,{children:(0,L.jsx)(aS,{children:c})})}),e===void 0?null:(0,L.jsxs)(`footer`,{className:`local-console-version`,"aria-label":`Tutti version ${e}`,children:[`Tutti `,e]})]}),fe]})})}function rU(){return(0,L.jsx)(`p`,{children:`Launching uses your signed-in account's Tutti credit for this team's AI work, including background tasks on this computer. You can revoke access in Account. Test credit only; no payment is enabled.`})}function iU({onBrandClick:e,sessionError:t=null,...n}){let r={...n,error:n.error??t};return(0,L.jsx)(AH,{onBrandClick:e,auth:(0,L.jsx)(PH,{...r}),mobileAuth:(0,L.jsx)(NH,{...r})})}function aU(e,t,n){let r=n.trim().toLocaleLowerCase(`en`),i=e.filter(e=>(t===`account`?e.account!==void 0:e.local!==void 0)&&e.title.toLocaleLowerCase(`en`).includes(r));return{available:i.filter(e=>t===`computer`||e.account?.hostStatus===`online`),unavailable:i.filter(e=>t===`account`&&e.account?.hostStatus!==`online`)}}function oU(e,t,n){let r=t.filter(e=>![`workspace-missing`,`workspace-replaced`,`invalid`].includes(e.status)&&(e.provider_status===`configured`||e.provider_status===`managed`)),i=e.map(e=>({key:`account:${e.relayProjectRef}`,title:e.displayName,surface:e.surface??`standalone`,account:e})),a=[];for(let e of r){let t=i.filter(t=>e.relay_origin===n&&e.relay_project_ref!==void 0&&t.account?.relayProjectRef===e.relay_project_ref&&t.surface===e.surface_profile.kind),o=r.filter(t=>t.relay_origin===e.relay_origin&&t.relay_project_ref===e.relay_project_ref);t.length===1&&o.length===1?t[0].local=e:a.push({key:`local:${e.project_id}`,title:e.display_name,surface:e.surface_profile.kind,local:e})}return[...i,...a]}function sU(e){let[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(``),[a,o]=(0,I.useState)(null),[s,c]=(0,I.useState)(!1),l=e.local,u=l!==void 0&&l.sessionError===null,d=t&&u;(0,I.useEffect)(()=>{u||(n(!1),i(``),o(null),c(!1))},[u]);let f=e=>{e!==d&&(n(e),i(``),c(!1),o(null))},{available:p,unavailable:m}=aU(oU(e.projects,u?l.projects:[],e.relayOrigin??``),d?`computer`:`account`,r),h=[...p,...s?m:[]].some(e=>e.key===a);(0,I.useEffect)(()=>{h||o(null)},[h]);let g=e=>{f(!0),o(e.key)},_=t=>{if(d&&t.local&&l){let e=t.local,n=l.projectActionPending!==null||l.launchPending;return e.status===`online`||e.status===`reconnecting`?t.surface===`feishu`?(0,L.jsx)(Y,{type:`button`,disabled:n,onClick:()=>l.onConnectFeishu(e),children:`Connect`}):(0,L.jsx)(Y,{type:`button`,disabled:n||!e.open_url,onClick:()=>l.onOpenProject(e),children:`Open`}):(0,L.jsx)(Y,{type:`button`,disabled:n,onClick:()=>l.onLaunchExisting(e),children:`Resume`})}return t.account?.canOpen?(0,L.jsx)(Y,{type:`button`,disabled:e.openPending,onClick:()=>e.onOpenProject(t.account.relayProjectRef),children:`Open`}):t.surface===`feishu`?(0,L.jsx)(`span`,{children:`In Feishu`}):null},v=t=>(0,L.jsx)(fk,{title:t.title,status:d?t.local?.status===`online`?`online`:t.local?.status===`reconnecting`?`connecting`:`stopped`:t.account.hostStatus,meta:`${t.surface===`feishu`?`Feishu`:`Tutti Workspace`} · ${t.account?.membershipLabel??`Local only`}`,local:!d&&!!t.local,selected:t.key===a,onSelect:()=>o(e=>e===t.key?null:t.key),action:_(t),children:(0,L.jsxs)(pk,{title:t.title,actions:(0,L.jsxs)(L.Fragment,{children:[d&&t.local&&l?(0,L.jsx)(eU,{project:t.local,showPrimary:!1,pending:l.projectActionPending!==null||l.launchPending,onLaunch:()=>l.onLaunchExisting(t.local),onOpen:()=>l.onOpenProject(t.local),onCopyInvite:()=>l.onCopyInvite(t.local),onConnectFeishu:()=>l.onConnectFeishu(t.local),onStop:()=>l.onStopProject(t.local),...l.onAuthorizeExisting?{onAuthorize:()=>l.onAuthorizeExisting(t.local)}:{}}):null,!d&&t.local?(0,L.jsx)(Y,{type:`button`,onClick:()=>g(t),children:`Manage on this computer`}):null,t.account?(0,L.jsx)(Y,{type:`button`,onClick:()=>e.onProjectDetails?.(t.account),children:`Project settings`}):null]}),children:[(0,L.jsx)(`p`,{children:t.surface===`feishu`?`Collaboration happens in your Feishu group.`:`Your shared Tutti workspace.`}),d&&t.local?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{children:t.local.workspace_path}),(0,L.jsx)(`p`,{children:t.local.status===`online`||t.local.status===`reconnecting`?`Running on this computer`:`Stopped on this computer`})]}):null]})},`${d?`computer`:`account`}:${t.key}`);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(ck,{brand:(0,L.jsx)(UR,{onClick:e.onBrandClick}),account:e.accountActions??(e.account?(0,L.jsx)(qH,{pending:e.logoutPending,onSignOut:e.onLogout}):null),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Y,{type:`button`,onClick:()=>e.onJoinOpenChange(!0),children:`Join project`}),u?(0,L.jsxs)(Cw,{type:`button`,disabled:l.sessionLoading,onClick:()=>l.onCreateOpenChange(!0),children:[(0,L.jsx)(Fx,{"aria-hidden":`true`}),`New project`]}):(0,L.jsx)(Cw,{asChild:!0,children:(0,L.jsxs)(`a`,{href:e.localScopeHref,onClick:e.onRequestNewProject??e.onLocalScopeSelect,children:[(0,L.jsx)(Fx,{"aria-hidden":`true`}),`New project`]})})]}),toolbar:{local:d,connected:u,onLocalChange:f,search:r,onSearchChange:e=>{i(e),c(!!e.trim())}},rail:(0,L.jsx)(mk,{state:u?`connected`:e.connectionState===`lost`?`lost`:`disconnected`,...l?.version?{version:l.version}:{},children:u?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(dk,{children:[(0,L.jsx)(Sw,{type:`button`,label:`Refresh projects`,icon:(0,L.jsx)(zx,{"aria-hidden":`true`}),disabled:l.projectsLoading,onClick:l.onRefresh}),(0,L.jsx)(Y,{type:`button`,onClick:e.onDisconnect,children:`Disconnect`})]}),l.packageUpdateAction?(0,L.jsx)(Y,{type:`button`,disabled:l.packageUpdateAction.disabled,onClick:l.onPackageUpdate,title:l.packageUpdateAction.description,children:l.packageUpdateAction.label}):null]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Cw,{asChild:!0,children:(0,L.jsx)(`a`,{href:e.localScopeHref,onClick:e.onLocalScopeSelect,children:`Connect this computer`})}),(0,L.jsx)(Y,{asChild:!0,children:(0,L.jsx)(`a`,{href:`tutti://projects`,children:`Open Local Console`})})]})}),children:[(d?l.projectsLoading:e.loading)?(0,L.jsx)(oS,{}):null,!d&&e.error?(0,L.jsx)(aS,{tone:`error`,children:e.error}):null,!(d?l.projectsLoading:e.loading)&&p.length+m.length===0?(0,L.jsx)(aS,{children:r?`No matching projects.`:`No projects yet.`}):null,p.map(v),m.length>0?(0,L.jsx)(uk,{count:m.length,open:s,onOpenChange:c,children:m.map(v)}):null,!d&&e.truncated?(0,L.jsx)(aS,{children:`Only your 100 most recent account projects are shown.`}):null]}),e.localDialogs,(0,L.jsx)(Pk,{open:e.joinOpen,onOpenChange:e.onJoinOpenChange,inputLabel:`Invitation link or message`,placeholder:`Paste an invitation link or message`,value:e.joinLinkForm.value,error:e.joinLinkForm.error,onValueChange:e.joinLinkForm.onChange,"aria-label":`Join a project`,onSubmit:t=>{t.preventDefault(),e.joinLinkForm.onSubmit()}}),(0,L.jsx)(Ok,{open:e.localHandoffOpen,onOpenChange:e.onLocalHandoffOpenChange,status:e.localHandoffStatus,description:e.localHandoffStatus===`failed`?`Connection was not completed. Allow local network access if prompted, or update Tutti and try again. Open Local Console is available as a fallback.${e.connectionDiagnostic?` Diagnostic: ${e.connectionDiagnostic}`:``}`:`Open Tutti when prompted. Allow this page to connect to your local network if your browser asks.`,command:`npm install -g @xfey/tutti && tutti`,onCopyCommand:e.onCopyLaunchCommand,retryHref:e.localHandoffRetryHref,onRetry:e.onLocalScopeSelect})]})}function cU({form:e,pending:t,tokenMissing:n,onChange:r}){return(0,L.jsxs)(`div`,{className:`form-stack`,children:[(0,L.jsx)(Fw,{label:`Project name`,children:(0,L.jsx)(jw,{autoComplete:`off`,disabled:t||n,type:`text`,value:e.projectName,onChange:e=>r({projectName:e.target.value}),placeholder:`tutti-default`})}),(0,L.jsx)(Fw,{label:`OpenAI API key`,children:(0,L.jsx)(jw,{autoComplete:`off`,disabled:t||n,type:`password`,value:e.apiKey,onChange:e=>r({apiKey:e.target.value}),placeholder:`sk-...`})}),(0,L.jsx)(Fw,{label:`Base URL`,children:(0,L.jsx)(jw,{autoComplete:`off`,disabled:t||n,type:`url`,value:e.baseUrl,onChange:e=>r({baseUrl:e.target.value}),placeholder:`https://api.openai.com/v1`})}),(0,L.jsx)(Fw,{label:`Default model`,children:(0,L.jsx)(jw,{autoComplete:`off`,disabled:t||n,type:`text`,value:e.defaultModel,onChange:e=>r({defaultModel:e.target.value}),placeholder:`gpt-5.5`})})]})}function lU({form:e,statusLabel:t,configured:n,loading:r,pending:i,openProjectPending:a=!1,tokenMissing:o,error:s,success:c,onChange:l,onSubmit:u,onRetry:d,onBrandClick:f}){let p=i||a;return(0,L.jsx)(kH,{label:`Project setup`,onBrandClick:f,children:(0,L.jsxs)(bk,{title:`Project setup`,description:`Configure the provider for this project.`,size:`wide`,onSubmit:u,action:o?(0,L.jsxs)(Y,{type:`button`,disabled:!0,children:[(0,L.jsx)(eS,{"aria-hidden":`true`}),`Missing token`]}):s!==null&&r?(0,L.jsx)(Y,{type:`button`,onClick:d,children:`Retry`}):a?(0,L.jsxs)(Y,{type:`button`,disabled:!0,children:[(0,L.jsx)(Zb,{"aria-hidden":`true`}),`Opening project`]}):(0,L.jsxs)(Cw,{type:`submit`,disabled:i||e.apiKey.trim()===``||e.projectName.trim()===``,children:[i?`Saving`:`Save provider`,(0,L.jsx)(Hx,{"aria-hidden":`true`})]}),feedback:(0,L.jsxs)(L.Fragment,{children:[c===null?null:(0,L.jsx)(aS,{icon:(0,L.jsx)(ix,{"aria-hidden":`true`}),children:c}),s===null?null:(0,L.jsx)(Iw,{children:s})]}),children:[(0,L.jsx)(xk,{projectName:`OpenAI provider`,hostLabel:t,hostOnline:n,members:(0,L.jsx)(bx,{"aria-hidden":`true`})}),(0,L.jsx)(Sk,{label:`Status`,value:r?`Loading`:t,action:n?(0,L.jsx)(ix,{"aria-hidden":`true`}):null}),(0,L.jsx)(cU,{form:e,pending:p,tokenMissing:o,onChange:l})]})})}function uU({tone:e}){return e===`pending`?(0,L.jsx)(eS,{"aria-hidden":`true`}):e===`failed`?(0,L.jsx)(ox,{"aria-hidden":`true`}):e===`done`?(0,L.jsx)(tx,{"aria-hidden":`true`}):(0,L.jsx)(Cx,{"aria-hidden":`true`})}function dU({members:e}){return e===void 0||e.length===0?null:(0,L.jsx)(QC,{"aria-label":`Members`,children:e.map(e=>(0,L.jsx)(HH,{avatar:e.avatar,label:e.displayName},e.key))})}function fU({activePage:e,statusShortcuts:t,unread:n,artifactSignal:r,mobileContext:i,rail:a,children:o,onOpenProjectCenter:s,onOpenChat:c,onOpenWorklist:l,onOpenReferences:u,onOpenArtifacts:d,onOpenSkills:f,onOpenTimeline:p,onOpenSettings:m,onActivateStatusShortcut:h,getStatusShortcutAriaControls:g}){let _=e!==`chat`&&n?.chat===!0,v=e!==`worklist`&&n?.worklist===!0,y=r?.status===`live`,b=e!==`references`&&n?.references===!0,x=e!==`skills`&&n?.skills===!0;return(0,L.jsx)(JC,{children:(0,L.jsx)(YC,{...a===void 0?{}:{rail:a},children:(0,L.jsx)(XC,{className:`is-headerless`,sidebar:(0,L.jsxs)(Rw,{brand:(0,L.jsx)(HR,{...s===void 0?{}:{onClick:s}}),mobileTitle:i.title,...i.meta===void 0?{}:{mobileMeta:i.meta},...i.action===void 0?{}:{mobileAction:i.action},...t.length===0?{}:{status:t.map(e=>(0,I.createElement)(Vw,{icon:(0,L.jsx)(uU,{tone:e.tone}),label:e.label,tone:e.tone,onClick:()=>h?.(e),...g?.(e)===void 0?{}:{"aria-controls":g(e)},key:e.key}))},footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(wH,{}),(0,L.jsx)(Bw,{icon:(0,L.jsx)(Gx,{"aria-hidden":`true`}),label:`Settings`,active:e===`settings`,onClick:e===`settings`?void 0:m})]}),children:[(0,L.jsx)(Bw,{icon:(0,L.jsx)(ZI,{"aria-hidden":`true`}),label:`Chat`,active:e===`chat`,badge:_?{label:`Unread messages`}:!1,onClick:e===`chat`?void 0:c}),(0,L.jsx)(Bw,{icon:(0,L.jsx)(Sx,{"aria-hidden":`true`}),label:`Worklist`,active:e===`worklist`,badge:v?{label:`Unread worklist updates`}:!1,onClick:e===`worklist`?void 0:l}),(0,L.jsx)(Bw,{icon:(0,L.jsx)(Ax,{"aria-hidden":`true`}),label:`Artifacts`,active:e===`artifacts`,badge:y?{label:`Live preview available`,text:`Live`,variant:`pill`}:!1,onClick:e===`artifacts`?void 0:d}),(0,L.jsx)(Bw,{icon:(0,L.jsx)(mx,{"aria-hidden":`true`}),label:`References`,active:e===`references`,badge:b?{label:`New reference files`}:!1,onClick:e===`references`?void 0:u}),(0,L.jsx)(Bw,{icon:(0,L.jsx)(Jx,{"aria-hidden":`true`}),label:`Skills`,active:e===`skills`,badge:x?{label:`New skill updates`}:!1,onClick:e===`skills`?void 0:f}),(0,L.jsx)(Bw,{icon:(0,L.jsx)(ex,{"aria-hidden":`true`}),label:`Timeline`,active:e===`timeline`,onClick:e===`timeline`?void 0:p})]}),children:o})})})}function pU(){return(0,L.jsx)(Ow,{src:zR,className:`empty-state-brand-logo`})}function mU(e){return(0,L.jsx)(aS,{watermark:(0,L.jsx)(pU,{}),...e})}var hU=`tutti.execution-score-themes.v1`,gU=40,_U={assignments:[],bag:[]};function vU(){return{assignments:[],bag:[]}}function yU(){try{return typeof window>`u`?null:window.sessionStorage}catch{return null}}function bU(e,t){if(typeof e!=`object`||!e)return null;let n=e;if(!Array.isArray(n.assignments)||!Array.isArray(n.bag))return null;let r=n.assignments.filter(e=>typeof e==`object`&&!!e&&typeof e.identity==`string`&&t.has(String(e.themeId))),i=n.bag.filter(e=>typeof e==`string`&&t.has(e)),a=typeof n.recent==`string`&&t.has(n.recent)?n.recent:void 0;return{assignments:r,bag:i,...a===void 0?{}:{recent:a}}}function xU(e,t){if(e===null)return _U;try{let n=e.getItem(hU);return n===null?vU():bU(JSON.parse(n),t)??vU()}catch{return _U}}function SU(e,t){if(_U=t,e!==null)try{e.setItem(hU,JSON.stringify(t))}catch{}}function CU(e,t,n){let r=e.map(e=>e.id);for(let e=r.length-1;e>0;--e){let t=Math.min(e,Math.max(0,Math.floor(n()*(e+1))));[r[e],r[t]]=[r[t],r[e]]}if(r.length>1&&r[0]===t){let e=r.findIndex(e=>e!==t);[r[0],r[e]]=[r[e],r[0]]}return r}function wU(e,t={}){let n=t.themes??HC;if(n.length===0)throw Error(`Execution score themes are unavailable`);let r=new Map(n.map(e=>[e.id,e])),i=new Set(r.keys()),a=t.storage===void 0?yU():t.storage,o=xU(a,i),s=o.assignments.find(t=>t.identity===e),c=s===void 0?void 0:r.get(s.themeId);if(c!==void 0)return c;let l=t.random??Math.random,u=o.bag.length>0?[...o.bag]:CU(n,o.recent,l),d=u.shift(),f=d===void 0?void 0:r.get(d);if(f===void 0)throw Error(`Execution score themes are unavailable`);return SU(a,{assignments:[...o.assignments,{identity:e,themeId:f.id}].slice(-gU),bag:u,recent:f.id}),f}function TU(e){return`round-card-${e}`}function EU(e){return`approval-card-${e}`}function DU(e){return`chat-message-${e}`}var OU=`workspace-scratchpad`,kU=720,AU=80,jU=160,MU=96,NU=160,PU=2;function FU(e){return e.completionSource?.activityRef??e.completionSource?.workflowRef??e.completionSource?.taskId??e.key}function IU({progress:e}){let t=FU(e),[n]=(0,I.useState)(()=>wU(t)),r=(0,I.useRef)(t),i=(0,I.useRef)(e.tone),[a,o]=(0,I.useState)(null);if((0,I.useEffect)(()=>{let n=r.current,a=i.current;if(r.current=t,i.current=e.tone,e.tone!==`running`||a===`pending`||n===t){o(null);return}o(t);let s=window.setTimeout(()=>{o(e=>e===t?null:e)},kU);return()=>{window.clearTimeout(s)}},[e.tone,t]),e.tone===`running`||e.tone===`pending`||e.tone===`complete`){let r=e.tone===`running`&&a===t,i=e.steps.find(e=>e.status===`running`||e.status===`pending`)??e.steps.at(-1),o=e.completionTarget?.kind===`task`?`Task completed`:`Procedure completed`,s=e.tone===`complete`?void 0:i?.detail??(e.tone===`pending`?e.summary:void 0),c=e.tone===`complete`?void 0:i?.detailPrefix,l=e.tone===`complete`?void 0:i?.activityLabel,u=e.tone===`complete`?void 0:i?.elapsedLabel,d=e.tone===`complete`?void 0:i?.metrics,f=e.tone===`running`&&i?.id===`implement`&&s!==void 0;return(0,L.jsx)(wC,{stageLabel:r?`Loading the next movement…`:e.tone===`complete`?o:i?.label??e.summary,...r||s===void 0?{}:{stageDetail:s},...r||c===void 0?{}:{stageDetailPrefix:c},...r||l===void 0?{}:{stageActivity:l},...r||!f?{}:{detailMode:`live`},...r||u===void 0?{}:{elapsedLabel:u},...r||d===void 0?{}:{metrics:d},scoreLabel:r?`Loading the next movement score`:e.tone===`complete`?`${o} score cadence`:e.tone===`pending`?`Execution score paused while waiting for input`:`${i?.label??`Execution`} running score using ${n.shortName}`,state:r?`handoff`:e.tone===`complete`?`complete`:e.tone===`pending`?`paused`:`running`,units:n.units,playbackBpm:n.tempo,openingClef:n.clef,keySignatureFifths:n.keySignatureFifths,timeSignature:n.meter})}return(0,L.jsx)(TL,{title:e.title,summary:e.summary,tone:e.tone,steps:e.steps,...e.metaLabel===void 0?{}:{metaLabel:e.metaLabel}})}function LU(e){if(e===void 0)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function RU(e,t){if(e===null)return null;let n=LU(e.requestedAt);if(n===null)return t.length;let r=t.findIndex(e=>{let t=LU(e.createdAt);return t!==null&&t>n});return r===-1?t.length:r}function zU(e,{focusSelector:t}={}){let n=typeof document>`u`?null:document.getElementById(e);n!==null&&(n.scrollIntoView({block:`center`}),t!==void 0&&n.querySelector(t)?.focus({preventScroll:!0}))}function BU(e){return e.messageKind===`system_notice`&&e.workflowRef!==void 0&&(e.body.startsWith(`Worklist updated with `)||e.body===`Worklist is already covered by existing tasks.`)}function VU(e,t){if(t===void 0)return;let n=t.label.trim(),r=t.handle?.trim()??n;if(n===``||r===``)return;let i=r.toLocaleLowerCase();e.has(i)||e.set(i,{id:t.id,label:n,handle:r})}function HU({members:e,messages:t,clarificationMessagesByRoundId:n}){let r=new Map;VU(r,{id:`tutti`,label:`Tutti`,handle:`tutti`});for(let t of e)VU(r,{id:t.key,label:t.displayName});for(let e of t)VU(r,{id:`message:${e.author}`,label:e.author,...e.avatarKind===`tutti`?{handle:`tutti`}:{}});for(let e of Object.values(n))for(let t of e)VU(r,{id:`round-message:${t.author}`,label:t.author,...t.avatarKind===`tutti`?{handle:`tutti`}:{}});return[...r.values()]}function UU({message:e}){return e.avatarKind===`tutti`?(0,L.jsx)(UH,{label:e.author}):(0,L.jsx)(HH,{avatar:e.avatar??{kind:`initials`,initials:k_(e.author),color:`blue`},label:e.author,online:e.online})}function WU({projectName:e,projectDescription:t=``,members:n,messages:r,scratchpad:i,executionProgress:a=null,activeApproval:o=null,activeClarification:s,clarificationMessagesByRoundId:c,statusShortcuts:l,unread:u,artifactSignal:d,draft:f,roundDraft:p,sendPending:m,scratchpadSyncPending:h=!1,scratchpadActionsDisabled:g=!1,scratchpadSubmitPending:_=!1,referenceUploadPending:v=!1,focusMessageId:y=null,messageHistoryIdentity:b=`latest`,initialMessagePosition:x=y===null?`latest`:`focus`,hasOlderMessages:S=!1,hasNewerMessages:C=!1,loadingOlderMessages:w=!1,loadingNewerMessages:T=!1,historyConnectedToLatest:E=!0,roundSendPending:D=!1,roundSubmitPending:O=!1,submittedRoundId:k=null,approvalDecisionPending:A=!1,projectNameSaving:j=!1,projectDescriptionSaving:ee=!1,loading:M=!1,unavailable:te=!1,onDraftChange:N,onMessageFocused:P,onInitialMessagePositioned:F,onLoadOlderMessages:ne,onLoadNewerMessages:re,onJumpToLatest:ie,onUploadReferenceFile:ae,onOpenReferenceFile:oe,onRoundDraftChange:se,onSendMessage:ce,onSendRoundMessage:le,onSubmitRound:ue,onDecideApproval:de,onSubmitScratchpad:fe,onUpdateProjectDisplayName:pe,onUpdateProjectDescription:me,onOpenProjectCenter:he,onOpenWorklist:ge,onOpenWorklistTask:_e,onRetryTask:ve,onOpenReferences:ye,onOpenArtifacts:be,onViewArtifactFeedback:xe,onOpenSkills:Se,onOpenTimeline:Ce,onOpenSettings:we,onActivateStatusShortcut:Te}){let[Ee,De]=(0,I.useState)(!1),Oe=(0,I.useRef)(null),ke=(0,I.useRef)(!1),Ae=(0,I.useRef)(null),je=(0,I.useRef)(null),Me=(0,I.useRef)(!0),Ne=(0,I.useRef)(void 0),Pe=(0,I.useRef)(b),Fe=(0,I.useRef)(null),Ie=(0,L.jsx)(pL,{className:`chat-project-title-edit`,value:e,placeholder:`Untitled project`,ariaLabel:`Edit project name`,maxLength:AU,saving:j,disabled:M,...pe===void 0?{}:{onUpdate:pe}}),Le=(0,L.jsx)(pL,{className:`chat-project-description-edit`,value:t,placeholder:`Add a project description`,ariaLabel:`Edit project description`,maxLength:jU,allowEmpty:!0,saving:ee,disabled:M,...me===void 0?{}:{onUpdate:me}}),Re=s!==null&&r.some(e=>e.id===s.cardMessageId),ze=new Map;for(let e of r)e.clarificationCard!==void 0&&e.workflowRef!==void 0&&ze.set(e.workflowRef,e.clarificationCard.roundId);let Be=new Map;for(let e of r){if(!BU(e)||e.workflowRef===void 0)continue;let t=ze.get(e.workflowRef);t!==void 0&&Be.set(t,{...e,id:`round-result:${e.id}`,messageKind:`agent_text`,author:`Tutti`,avatarKind:`tutti`,online:!1})}let Ve=e=>{let t=c[e]??[],n=Be.get(e);return n===void 0||t.some(e=>e.body===n.body)?t:[...t,n]},He=HU({members:n,messages:r,clarificationMessagesByRoundId:c}),Ue=ae===void 0?void 0:e=>{for(let t of e)ae(t)};(0,I.useLayoutEffect)(()=>{Pe.current!==b&&(Pe.current=b,ke.current=!1,Ae.current=null,Ne.current=void 0)},[b]),(0,I.useLayoutEffect)(()=>{let e=Ae.current;if(e!==null){if(r[0]?.id!==e.firstMessageId){let t=Oe.current;t!==null&&(t.scrollTop=e.scrollTop+Math.max(0,t.scrollHeight-e.scrollHeight),Me.current=t.scrollHeight-t.clientHeight-t.scrollTop<=PU),Ae.current=null;return}w||(Ae.current=null)}},[w,r]),(0,I.useEffect)(()=>{if(y===null||!r.some(e=>e.id===y))return;ke.current=!0,zU(DU(y));let e=Oe.current;e!==null&&(Me.current=e.scrollHeight-e.clientHeight-e.scrollTop<=PU),P?.()},[y,r,P]),(0,I.useEffect)(()=>{if(ke.current||M||te||x!==`latest`||y!==null||r.length===0&&s===null&&o===null)return;let e=Oe.current;if(e===null)return;let t=window.requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight,Me.current=!0,ke.current=!0});return()=>window.cancelAnimationFrame(t)},[o,s,y,M,r,te]),(0,I.useEffect)(()=>{if(ke.current||M||te||x!==`start`||y!==null)return;let e=Oe.current;if(e===null)return;let t=window.requestAnimationFrame(()=>{e.scrollTop=0,Me.current=e.scrollHeight<=e.clientHeight+PU,ke.current=!0,F?.()});return()=>window.cancelAnimationFrame(t)},[y,x,M,r,F,te]);let We=()=>{if(!S||w||Ae.current!==null||ne===void 0)return;let e=Oe.current;e!==null&&(Ae.current={firstMessageId:r[0]?.id,scrollHeight:e.scrollHeight,scrollTop:e.scrollTop},ne())},Ge=()=>{!C||T||re===void 0||re()},Ke=e=>{let t=e.currentTarget;Me.current=t.scrollHeight-t.clientHeight-t.scrollTop<=PU,je.current!==null&&window.cancelAnimationFrame(je.current),je.current=window.requestAnimationFrame(()=>{if(je.current=null,t.scrollTop<=MU){We();return}t.scrollHeight-t.clientHeight-t.scrollTop<=NU&&Ge()})};(0,I.useEffect)(()=>()=>{je.current!==null&&window.cancelAnimationFrame(je.current)},[]),(0,I.useEffect)(()=>{if(M||te||w||T||!ke.current)return;let e=Oe.current;if(e===null||e.scrollHeight>e.clientHeight+PU)return;let t=window.requestAnimationFrame(()=>{S?We():C&&Ge()});return()=>window.cancelAnimationFrame(t)},[C,S,M,T,w,r,te]);let qe=r.at(-1)?.id;(0,I.useEffect)(()=>{let e=Ne.current;if(Ne.current=qe,e===void 0||e===qe||!E||!Me.current||!ke.current||Ae.current!==null)return;let t=Oe.current;if(t===null)return;let n=window.requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight,Me.current=!0});return()=>window.cancelAnimationFrame(n)},[E,qe]);let Je=({key:e,roundId:t,title:n,summary:r,request:i,contextLabel:a,writable:o})=>{let c=Ve(t),l=(s?.roundId===t?s.answerRevision:void 0)??c.filter(e=>e.isClarificationAnswer??e.messageKind===`user_text`).length;return(0,L.jsx)(IL,{id:TU(t),tabIndex:-1,title:n,summary:r,request:i,...a===void 0?{}:{contextLabel:a},messages:c.map(e=>({id:e.id,author:e.author,body:e.body,time:e.time,avatar:(0,L.jsx)(UU,{message:e})})),replyCount:l,draft:o?p:``,defaultOpen:!0,readOnly:!o,status:o?`pending`:`done`,statusLabel:o?`needs input`:`submitted`,mentionOptions:He,sendPending:o&&D,submitPending:o&&O,onDraftChange:se,onSendMessage:le,onSubmitRound:ue},`${e}:${o?`writable`:`sealed`}`)},Ye=e=>{if(e.target.kind===`approval`&&o!==null){if(!E){Fe.current=e,ie?.();return}zU(EU(o.approvalId),{focusSelector:`.chat-event-card-header`});return}if(e.target.kind===`clarification`&&s!==null){if(!E&&!Re){Fe.current=e,ie?.();return}zU(TU(s.roundId),{focusSelector:`.chat-event-card-header`});return}if(e.target.kind===`scratchpad`){zU(OU);return}Te?.(e)};(0,I.useEffect)(()=>{let e=Fe.current;if(!E||M||e===null)return;Fe.current=null;let t=window.requestAnimationFrame(()=>{e.target.kind===`approval`&&o!==null?zU(EU(o.approvalId),{focusSelector:`.chat-event-card-header`}):e.target.kind===`clarification`&&s!==null&&zU(TU(s.roundId),{focusSelector:`.chat-event-card-header`})});return()=>window.cancelAnimationFrame(t)},[o,s,E,M,r]);let Xe=e=>s===null?null:Je({key:e,roundId:s.roundId,title:s.title,summary:s.summary,request:s.request,contextLabel:s.ownerLabel,writable:s.status===`writable`&&s.roundId!==k}),Ze=()=>o===null?null:(0,L.jsx)(BL,{id:EU(o.approvalId),tabIndex:-1,title:o.title,summary:o.summary,...o.reason===void 0?{}:{reason:o.reason},...o.detail===void 0?{}:{detail:o.detail,...o.detailLabel===void 0?{}:{detailLabel:o.detailLabel},...o.detailCode===void 0?{}:{detailCode:o.detailCode}},status:o.status,statusLabel:o.statusLabel,decisions:o.decisions,decisionPending:A,...o.resolutionLabel===void 0?{}:{resolutionLabel:o.resolutionLabel},onDecide:e=>de?.(o.approvalId,e)},`approval:${o.approvalId}:${o.status}`),Qe=e=>{let t=e.clarificationCard;if(t===void 0)return null;let n=s!==null&&s.roundId===t.roundId;return Je({key:e.id,roundId:t.roundId,title:n&&s!==null?s.title:t.title??`Clarification round ${t.roundId.slice(-4)}`,summary:n&&s!==null?s.summary:t.summary,request:n&&s!==null?s.request:t.summary,...n&&s!==null?{contextLabel:s.ownerLabel}:{},writable:n&&t.status===`writable`&&t.roundId!==k})},$e=e=>{if(BU(e)&&ze.has(e.workflowRef??``))return null;if(e.messageKind===`clarification_card`)return Qe(e);if(s!==null&&e.id===s.cardMessageId)return Xe(e.id);if(e.taskResult!==void 0)return(0,L.jsx)(HL,{id:DU(e.id),tabIndex:-1,className:e.id===y?`is-focused`:void 0,title:e.taskResult.title,status:e.taskResult.status,taskId:e.taskResult.taskId,taskTitle:e.taskResult.taskTitle,summary:e.taskResult.summary,...e.taskResult.moduleName===void 0?{}:{moduleName:e.taskResult.moduleName},...e.taskResult.finalNote===void 0?{}:{finalNote:e.taskResult.finalNote},...e.taskResult.generatedFiles===void 0?{}:{generatedFiles:e.taskResult.generatedFiles},...e.taskResult.errorCode===void 0?{}:{errorCode:e.taskResult.errorCode},...e.taskResult.retryState===void 0?{}:{retryState:e.taskResult.retryState},...e.taskResult.retryState===void 0||e.taskResult.latestRunResultId===void 0||ve===void 0?{}:{onRetry:()=>ve(e.taskResult.taskId,e.taskResult.latestRunResultId)},..._e===void 0?{}:{onOpenTask:_e}},e.id);let t=e.referenceFile;return(0,I.createElement)(QI,{id:DU(e.id),tabIndex:-1,author:e.author,time:e.time,...e.requestStatus===void 0?{}:{requestStatus:e.requestStatus},avatar:(0,L.jsx)(UU,{message:e}),className:e.id===y?`is-focused`:void 0,key:e.id},e.artifactFeedback===void 0?t===void 0?e.messageKind===`agent_text`?(0,L.jsx)($I,{children:e.body}):(0,L.jsx)(`p`,{children:(0,L.jsx)(YI,{children:e.body})}):(0,L.jsx)(dL,{name:t.name,category:t.category,...t.imageUrl===void 0?{}:{imageUrl:t.imageUrl},onClick:()=>oe?.(t.path)}):(0,L.jsx)(uR,{artifactTitle:e.artifactFeedback.artifactTitle,annotations:e.artifactFeedback.annotations,...e.artifactFeedback.summary===void 0?{}:{summary:e.artifactFeedback.summary},...xe===void 0?{}:{onViewAnnotation:t=>xe(e.id,t)}}))},et=E?RU(o,r):null,tt=()=>{let e=s!==null&&(Re||E)||o!==null&&E;return r.length===0&&!e&&!w&&!T?(0,L.jsx)(mU,{children:`No messages yet`}):(0,L.jsxs)(L.Fragment,{children:[w?(0,L.jsx)(`div`,{className:`chat-history-status`,role:`status`,children:`Loading earlier messages…`}):null,!E||Re?null:Xe(`active-round`),r.map((e,t)=>(0,L.jsxs)(I.Fragment,{children:[et===t?Ze():null,$e(e)]},`timeline:${e.id}`)),et===r.length?Ze():null,T?(0,L.jsx)(`div`,{className:`chat-history-status`,role:`status`,children:`Loading newer messages…`}):null]})},nt=(e,t=!1)=>(0,L.jsx)(xL,{id:e,tabIndex:-1,compact:t,title:i.title,summary:i.summary,sections:i.sections,submitAvailable:i.submitAvailable,...i.pages===void 0?{}:{pages:i.pages},...i.footerNote===void 0?{}:{footerNote:i.footerNote},...i.updatedLabelPrefix===void 0?{}:{updatedLabelPrefix:i.updatedLabelPrefix},syncPending:h,actionsDisabled:g,submitPending:_,onSubmitScratchpad:fe,..._e===void 0?{}:{onOpenCompiledTask:_e},empty:(0,L.jsx)(mU,{children:`Scratchpad empty. Discuss more, tutti together!`}),...i.updatedLabel===void 0?{}:{updatedLabel:i.updatedLabel}}),rt=(0,L.jsx)(`div`,{className:`chat-panel-actions`,children:(0,L.jsx)(dU,{members:n})});return(0,L.jsxs)(fU,{activePage:`chat`,statusShortcuts:l,mobileContext:{title:e,action:(0,L.jsx)(Bw,{className:h?`mobile-scratchpad-trigger is-syncing`:`mobile-scratchpad-trigger`,type:`button`,label:Ee?`Close Scratchpad`:`Open Scratchpad`,active:Ee,"aria-expanded":Ee,"aria-controls":`${OU}-mobile-sheet`,icon:(0,L.jsx)(_L,{"aria-hidden":`true`}),onClick:()=>De(e=>!e)})},...u===void 0?{}:{unread:u},...d===void 0?{}:{artifactSignal:d},onOpenProjectCenter:he,onOpenWorklist:ge,onOpenReferences:ye,onOpenArtifacts:be,onOpenSkills:Se,onOpenTimeline:Ce,onOpenSettings:we,onActivateStatusShortcut:Ye,getStatusShortcutAriaControls:e=>e.target.kind===`approval`&&o!==null&&E?EU(o.approvalId):e.target.kind===`clarification`&&s!==null&&(E||Re)?TU(s.roundId):e.target.kind===`scratchpad`?OU:void 0,children:[(0,L.jsxs)(`section`,{className:`workspace-grid is-tutti chat-workspace-grid`,"aria-label":`Chat workspace`,children:[M?(0,L.jsx)(fL,{title:Ie,subtitle:Le,actions:rt,children:(0,L.jsx)(oS,{})}):te?(0,L.jsx)(fL,{title:Ie,subtitle:Le,actions:rt,children:(0,L.jsx)(mU,{children:`Workspace unavailable`})}):(0,L.jsx)(fL,{title:Ie,subtitle:Le,actions:rt,streamRef:Oe,onStreamScroll:Ke,streamOverlay:C&&ie!==void 0?(0,L.jsx)(Y,{className:`chat-jump-latest`,type:`button`,onClick:ie,children:`Jump to latest`}):void 0,dropUploadPending:v,...Ue===void 0?{}:{onDropFiles:Ue},composer:(0,L.jsx)(gL,{value:f,pending:m,uploadPending:v,mentionOptions:He,onValueChange:N,onComposerSubmit:ce,...ae===void 0?{}:{onFileUpload:ae}}),empty:(0,L.jsx)(mU,{children:`No messages yet`}),children:tt()}),(0,L.jsxs)(`div`,{className:a===null?`chat-side-column`:`chat-side-column has-progress`,children:[nt(OU),a===null?null:(0,L.jsx)(IU,{progress:a})]})]}),Ee?(0,L.jsxs)(`div`,{className:`mobile-scratchpad-layer is-open`,id:`${OU}-mobile-sheet`,children:[(0,L.jsx)(`button`,{className:`mobile-scratchpad-backdrop`,type:`button`,"aria-label":`Close Scratchpad`,onClick:()=>De(!1)}),(0,L.jsxs)(`section`,{className:`mobile-scratchpad-card`,role:`dialog`,"aria-modal":`true`,"aria-label":`Scratchpad`,children:[(0,L.jsxs)(`div`,{className:`mobile-scratchpad-card-head`,children:[(0,L.jsx)(`h2`,{children:`Scratchpad`}),(0,L.jsx)(Sw,{className:`mobile-scratchpad-close`,type:`button`,label:`Close Scratchpad`,icon:(0,L.jsx)(rS,{"aria-hidden":`true`}),onClick:()=>De(!1)})]}),(0,L.jsx)(`div`,{className:`mobile-scratchpad-card-body`,children:nt(`${OU}-mobile`,!0)})]})]}):null]})}function GU({statusShortcuts:e,unread:t,state:n,loading:r=!1,unavailable:i=!1,feedback:a,iframeRef:o,onPreviewLoad:s,onOpenProjectCenter:c,onOpenChat:l,onOpenWorklist:u,onOpenReferences:d,onOpenSkills:f,onOpenTimeline:p,onOpenSettings:m,onActivateStatusShortcut:h}){let g=r?{status:`loading`}:i?{status:`not_declared`}:n,_=a?.supported===!0?(0,L.jsx)(cR,{active:a.open,disabled:a.open?!a.canSubmit:!a.ready,...a.submitPending===void 0?{}:{pending:a.submitPending},title:a.open?a.submitDisabledReason??`Submit comments`:a.ready?`Comments`:a.unavailableReason??`Preparing comments`,onClick:a.open?a.onSubmit:a.onOpen}):void 0,v=a?.supported===!0?(0,L.jsx)(Bw,{type:`button`,label:a.open?`Submit comments`:`Comments`,active:a.open,disabled:a.open?!a.canSubmit:!a.ready,icon:a.open?(0,L.jsx)(tx,{"aria-hidden":`true`}):(0,L.jsx)(Fx,{"aria-hidden":`true`}),onClick:a.open?a.onSubmit:a.onOpen}):void 0,y=a?.open===!0?(0,L.jsx)(lR,{...a.rail,author:a.author.displayName,avatar:(0,L.jsx)(HH,{avatar:a.author.avatar,label:a.author.displayName})}):void 0;return(0,L.jsx)(fU,{activePage:`artifacts`,statusShortcuts:e,mobileContext:{title:g.status===`declared`?g.title:`Artifacts`,...v===void 0?{}:{action:v}},...t===void 0?{}:{unread:t},artifactSignal:Vz(g),...y===void 0?{}:{rail:y},onOpenProjectCenter:c,onOpenChat:l,onOpenWorklist:u,onOpenReferences:d,onOpenSkills:f,onOpenTimeline:p,onOpenSettings:m,onActivateStatusShortcut:h,children:(0,L.jsx)(`section`,{className:`workspace-grid artifacts-workspace-grid`,"aria-label":`Artifacts`,children:(0,L.jsx)(aR,{state:g,..._===void 0?{}:{headerAction:_},...o===void 0?{}:{iframeRef:o},...s===void 0?{}:{onPreviewLoad:s},...i?{empty:(0,L.jsx)(mU,{children:`Workspace unavailable`})}:{},emptyWatermark:(0,L.jsx)(pU,{})})})})}function KU({statusShortcuts:e,unread:t,artifactSignal:n,files:r,detail:i,uploadPending:a=!1,fileSortMode:o=`time`,loading:s=!1,unavailable:c=!1,onOpenProjectCenter:l,onOpenChat:u,onOpenWorklist:d,onOpenArtifacts:f,onOpenSkills:p,onOpenTimeline:m,onOpenSettings:h,onActivateStatusShortcut:g,onSelectFile:_,onUploadFile:v,onFileSortModeChange:y}){let b=s||c;return(0,L.jsx)(fU,{activePage:`references`,statusShortcuts:e,mobileContext:{title:`References`,action:(0,L.jsx)(hL,{variant:`bare`,className:`sidebar-button reference-upload-button`,label:`Upload reference`,pendingLabel:`Uploading reference`,pending:a,iconOnly:!0,onFileUpload:v})},...t===void 0?{}:{unread:t},...n===void 0?{}:{artifactSignal:n},onOpenProjectCenter:l,onOpenChat:u,onOpenWorklist:d,onOpenArtifacts:f,onOpenSkills:p,onOpenTimeline:m,onOpenSettings:h,onActivateStatusShortcut:g,children:(0,L.jsx)(`section`,{className:`workspace-grid references-workspace-grid`,"aria-label":`Reference files`,children:(0,L.jsx)(nR,{files:b?[]:r,...s?{detail:{title:`Loading`,unavailableReason:`Loading`}}:c?{detail:{title:`References unavailable`,unavailableReason:`Workspace unavailable`}}:i===void 0?{}:{detail:i},uploadPending:a,fileSortMode:o,empty:s?(0,L.jsx)(mU,{children:`Loading reference files`}):c?(0,L.jsx)(mU,{children:`Workspace unavailable`}):(0,L.jsx)(mU,{children:`No reference files`}),onSelectFile:_,onUploadFile:v,...y===void 0?{}:{onFileSortModeChange:y}})})})}var qU=6,JU=`......`,YU=80,XU=160;function ZU(e){let t=document.createElement(`canvas`).getContext(`2d`);if(t===null)return null;let n=window.getComputedStyle(e);return t.font=[n.fontStyle,n.fontVariant,n.fontWeight,n.fontSize,n.fontFamily].join(` `),e=>t.measureText(e).width}function QU(e,t,n){if(n(e)<=t)return e;let r=e.slice(-qU),i=Math.max(0,e.length-r.length),a=0,o=i;for(;a<o;){let i=Math.ceil((a+o)/2);n(`${e.slice(0,i)}${JU}${r}`)<=t?a=i:o=i-1}return`${e.slice(0,a)}${JU}${r}`}function $U({value:e}){let t=(0,I.useRef)(null),[n,r]=(0,I.useState)(e);return(0,I.useEffect)(()=>{let n=t.current;if(n===null)return;let i=()=>{let t=ZU(n),i=n.getBoundingClientRect().width;if(t===null||i<=0){r(e);return}let a=QU(e,i,t);r(e=>e===a?e:a)};i();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(i);return a?.observe(n),window.addEventListener(`resize`,i),()=>{a?.disconnect(),window.removeEventListener(`resize`,i)}},[e]),(0,L.jsx)(`span`,{ref:t,className:`settings-masked-link`,title:e,"aria-label":e,children:n})}function eW({value:e,onCopy:t}){return t===void 0?(0,L.jsx)($U,{value:e}):(0,L.jsx)(`button`,{className:`settings-value-button settings-link-copy-button`,type:`button`,"aria-label":`Copy invite link`,onClick:t,children:(0,L.jsx)($U,{value:e})})}function tW({avatar:e,displayName:t}){return(0,L.jsxs)(`div`,{className:`settings-identity`,children:[(0,L.jsx)(HH,{avatar:e,label:t}),(0,L.jsx)(`strong`,{children:t})]})}function nW({members:e}){return(0,L.jsx)(`div`,{className:`settings-member-list`,children:e.map(e=>(0,I.createElement)(tW,{...e,key:e.key}))})}function rW({settings:e,onCopyJoinUrl:t}){return{label:`Invite link`,value:e.access.inviteLink===void 0?`Not available`:(0,L.jsx)(eW,{value:e.access.inviteLink,onCopy:t}),...e.access.inviteLink===void 0?{}:{plain:!0}}}function iW({settings:e,projectNameSaving:t,projectDescriptionSaving:n,providerModelOptions:r,providerModelEditable:i,providerModelDiscovering:a,providerModelSaving:o,onCopyJoinUrl:s,onUpdateProjectDisplayName:c,onUpdateProjectDescription:l,onDiscoverProviderModels:u,onUpdateProviderDefaultModel:d}){return[{id:`settings-project`,title:`Project`,rows:[{label:`Project name`,plain:!0,value:(0,L.jsx)(pL,{value:e.project.displayName,placeholder:`Untitled project`,ariaLabel:`Project name`,maxLength:YU,saving:t,...c===void 0?{}:{onUpdate:c}})},{label:`Description`,plain:!0,value:(0,L.jsx)(pL,{value:e.project.description,placeholder:`Add a project description`,ariaLabel:`Project description`,maxLength:XU,allowEmpty:!0,saving:n,...l===void 0?{}:{onUpdate:l}})},{label:`Members`,plain:!0,value:(0,L.jsx)(nW,{members:e.project.members})}]},{id:`settings-access`,title:`Access`,rows:[rW({settings:e,onCopyJoinUrl:s}),...e.access.inviteExpires===void 0?[]:[{label:`Invite expires`,value:e.access.inviteExpires}],{label:`Signed in as`,plain:!0,value:(0,L.jsx)(tW,{...e.access.signedInAs},`signed-in-account`)},{label:`Role`,value:e.access.role},{label:`Joined`,value:e.access.joined}]},{id:`settings-provider`,title:`AI provider`,rows:[{label:`Status`,value:e.provider.status},...e.provider.model===void 0?[]:[{label:`Model`,plain:!0,value:(0,L.jsx)(ZL,{value:e.provider.model,options:r,maxLength:256,canEdit:i,discovering:a,saving:o,...u===void 0?{}:{onDiscover:u},...d===void 0?{}:{onUpdate:d}})}],...e.provider.lastValidated===void 0?[]:[{label:`Last validated`,value:e.provider.lastValidated}],...e.provider.issue===void 0?[]:[{label:`Issue`,value:e.provider.issue}]]},{id:`settings-tutti`,title:`Tutti`,rows:[{label:`Version`,value:e.tutti.version}]}]}function aW({settings:e,statusShortcuts:t,unread:n,artifactSignal:r,loading:i=!1,unavailable:a=!1,projectNameSaving:o=!1,projectDescriptionSaving:s=!1,providerModelOptions:c=[],providerModelEditable:l=!1,providerModelDiscovering:u=!1,providerModelSaving:d=!1,onOpenProjectCenter:f,onOpenChat:p,onOpenWorklist:m,onOpenReferences:h,onOpenArtifacts:g,onOpenSkills:_,onOpenTimeline:v,onActivateStatusShortcut:y,onCopyJoinUrl:b,onUpdateProjectDisplayName:x,onUpdateProjectDescription:S,onDiscoverProviderModels:C,onUpdateProviderDefaultModel:w}){return(0,L.jsx)(fU,{activePage:`settings`,statusShortcuts:t,mobileContext:{title:`Settings`},...n===void 0?{}:{unread:n},...r===void 0?{}:{artifactSignal:r},onOpenProjectCenter:f,onOpenChat:p,onOpenWorklist:m,onOpenReferences:h,onOpenArtifacts:g,onOpenSkills:_,onOpenTimeline:v,onActivateStatusShortcut:y,children:(0,L.jsx)(`section`,{className:`workspace-grid settings-workspace-grid`,"aria-label":`Settings`,children:(0,L.jsx)(`div`,{className:`settings-page-grid`,children:i?(0,L.jsx)(`section`,{className:`settings-sheet`,"aria-label":`Loading settings`,children:(0,L.jsx)(mU,{children:`Loading settings`})}):a?(0,L.jsx)(`section`,{className:`settings-sheet`,"aria-label":`Settings unavailable`,children:(0,L.jsx)(mU,{children:`Workspace unavailable`})}):e===void 0?(0,L.jsx)(`section`,{className:`settings-sheet`,"aria-label":`Settings unavailable`,children:(0,L.jsx)(mU,{children:`Settings unavailable`})}):(0,L.jsx)(XL,{statuses:[e.connectionStatus],sections:iW({settings:e,projectNameSaving:o,projectDescriptionSaving:s,providerModelOptions:c,providerModelEditable:l,providerModelDiscovering:u,providerModelSaving:d,onCopyJoinUrl:b,onUpdateProjectDisplayName:x,onUpdateProjectDescription:S,onDiscoverProviderModels:C,onUpdateProviderDefaultModel:w})})})})})}var oW=[{title:`Awesome GitHub Copilot Skills`,href:`https://awesome-copilot.github.com/skills/`},{title:`Anthropic official skills`,href:`https://github.com/anthropics/skills`},{title:`Claude Skills Marketplace`,href:`https://claudeskills.info/skills/`}];function sW({statusShortcuts:e,unread:t,artifactSignal:n,skills:r,detail:i,uploadPending:a=!1,deletePending:o=!1,loading:s=!1,unavailable:c=!1,onOpenProjectCenter:l,onOpenChat:u,onOpenWorklist:d,onOpenReferences:f,onOpenArtifacts:p,onOpenTimeline:m,onOpenSettings:h,onActivateStatusShortcut:g,onSelectSkill:_,onUploadSkill:v,onDeleteSkill:y}){let b=s||c;return(0,L.jsx)(fU,{activePage:`skills`,statusShortcuts:e,mobileContext:{title:`Skills`,action:(0,L.jsx)(hL,{variant:`bare`,className:`sidebar-button reference-upload-button`,label:`Upload skill`,pendingLabel:`Uploading skill`,pending:a,accept:`.zip,application/zip,application/x-zip-compressed`,iconOnly:!0,onFileUpload:v})},...t===void 0?{}:{unread:t},...n===void 0?{}:{artifactSignal:n},onOpenProjectCenter:l,onOpenChat:u,onOpenWorklist:d,onOpenReferences:f,onOpenArtifacts:p,onOpenTimeline:m,onOpenSettings:h,onActivateStatusShortcut:g,children:(0,L.jsx)(`section`,{className:`workspace-grid references-workspace-grid`,"aria-label":`Skills`,children:(0,L.jsx)(fR,{skills:b?[]:r,communityLinks:b?[]:oW,...s?{detail:{title:`Loading`,unavailableReason:`Loading`}}:c?{detail:{title:`Skills unavailable`,unavailableReason:`Workspace unavailable`}}:i===void 0?{}:{detail:i},uploadPending:a,deletePending:o,empty:s?(0,L.jsx)(mU,{children:`Loading skills`}):c?(0,L.jsx)(mU,{children:`Workspace unavailable`}):(0,L.jsx)(mU,{children:`No skills`}),onSelectSkill:_,onUploadSkill:v,onDeleteSkill:y})})})}function cW({timeline:e,statusShortcuts:t,unread:n,artifactSignal:r,loading:i=!1,unavailable:a=!1,onOpenProjectCenter:o,onOpenChat:s,onOpenWorklist:c,onOpenReferences:l,onOpenArtifacts:u,onOpenSkills:d,onOpenSettings:f,onActivateStatusShortcut:p}){return(0,L.jsx)(fU,{activePage:`timeline`,statusShortcuts:t,mobileContext:{title:`Timeline`},...n===void 0?{}:{unread:n},...r===void 0?{}:{artifactSignal:r},onOpenProjectCenter:o,onOpenChat:s,onOpenWorklist:c,onOpenReferences:l,onOpenArtifacts:u,onOpenSkills:d,onOpenSettings:f,onActivateStatusShortcut:p,children:(0,L.jsx)(`section`,{className:`workspace-grid timeline-workspace-grid`,"aria-label":`Timeline workspace`,children:i?(0,L.jsx)(`section`,{className:`panel timeline-panel`,"aria-label":`Loading timeline`,children:(0,L.jsx)(mU,{children:`Loading timeline`})}):a?(0,L.jsx)(`section`,{className:`panel timeline-panel`,"aria-label":`Timeline unavailable`,children:(0,L.jsx)(mU,{children:`Workspace unavailable`})}):e===void 0?(0,L.jsx)(`section`,{className:`panel timeline-panel`,"aria-label":`Timeline unavailable`,children:(0,L.jsx)(mU,{children:`Timeline unavailable`})}):(0,L.jsx)(OR,{tokenOverview:e.tokenOverview,items:e.items,scoreUnits:e.scoreUnits,empty:(0,L.jsx)(mU,{children:`No timeline events yet`})})})})}function lW({statusShortcuts:e,unread:t,artifactSignal:n,modules:r,taskCount:i,detail:a,missingTaskId:o,runNote:s,loading:c=!1,unavailable:l=!1,onOpenProjectCenter:u,onOpenChat:d,onOpenReferences:f,onOpenArtifacts:p,onOpenSkills:m,onOpenTimeline:h,onOpenSettings:g,onActivateStatusShortcut:_,onSelectTask:v}){return(0,L.jsx)(fU,{activePage:`worklist`,statusShortcuts:e,mobileContext:{title:`Worklist`,meta:i===1?`1 task`:`${i} tasks`},...t===void 0?{}:{unread:t},...n===void 0?{}:{artifactSignal:n},onOpenProjectCenter:u,onOpenChat:d,onOpenReferences:f,onOpenArtifacts:p,onOpenSkills:m,onOpenTimeline:h,onOpenSettings:g,onActivateStatusShortcut:_,children:(0,L.jsx)(`section`,{className:`workspace-grid worklist-workspace-grid`,"aria-label":`Worklist workspace`,children:c?(0,L.jsx)(`section`,{className:`panel tasks worklist-page-panel`,"aria-label":`Loading Worklist`,children:(0,L.jsx)(mU,{children:`Loading Worklist`})}):l?(0,L.jsx)(`section`,{className:`panel tasks worklist-page-panel`,"aria-label":`Worklist unavailable`,children:(0,L.jsx)(mU,{children:`Workspace unavailable`})}):(0,L.jsx)(YL,{modules:r,taskCount:i,...a===void 0?{}:{detail:a},...o===void 0?{}:{missingTaskId:o},...s==null?{}:{runNote:s},onSelectTask:v,empty:(0,L.jsx)(mU,{children:`No compiled tasks`})})})})}function uW(e){return(0,L.jsx)(kH,{label:`Tutti trial access`,onBrandClick:e.onBrandClick,children:(0,L.jsxs)(bk,{title:e.authorized?`Trial access authorized`:`Authorize Tutti trial`,description:e.authorized?`Local Console will verify this authorization, check model access and start the project. You can return to Local Console.`:`Confirm only if you started this request in Local Console on your computer.`,onSubmit:t=>{t.preventDefault(),e.onAuthorize()},action:e.authorized?void 0:(0,L.jsx)(Cw,{type:`submit`,disabled:e.pending||e.expired,children:e.pending?`Authorizing`:`Authorize trial access`}),feedback:e.error===null?void 0:(0,L.jsx)(Iw,{children:e.error}),children:[(0,L.jsx)(zk,{title:e.projectName,description:`${e.surface} · Tutti`,children:(0,L.jsxs)(`p`,{children:[`Account: `,e.accountEmail]})}),e.authorized?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{children:`This computer may run AI tasks for this project, including team requests and background work, using your test allowance. There is no payment or recharge authorization.`}),(0,L.jsx)(`p`,{children:`Access continues until revoked. Signing out does not stop authorized project work.`}),e.expired?(0,L.jsx)(Iw,{children:`This request expired. Start again in Local Console.`}):null,(0,L.jsx)(Y,{type:`button`,disabled:e.pending,onClick:e.onSignInAgain,children:`Sign in again / switch account`})]})]})})}var dW=W.Object({kind:W.Literal(`clarification`),round_id:oh,version:W.Integer({minimum:0}),answer_revision:W.Integer({minimum:0}),closed_reason:W.Optional(W.Union([W.Literal(`resolved`),W.Literal(`contract_changed`),W.Literal(`cancelled`)])),state:W.Union([W.Literal(`writable`),W.Literal(`submitted`),W.Literal(`continued`),W.Literal(`closed`)]),title:W.String({minLength:1,maxLength:512}),request:W.String({minLength:1,maxLength:4e3}),opened_at:G},{additionalProperties:!1}),fW=W.String({minLength:1,maxLength:64,pattern:`^[a-z][a-z0-9_-]*$`}),pW=W.String({minLength:1,maxLength:256,pattern:`^[^\\u0000-\\u001f\\u007f]+$`}),mW=W.String({minLength:1,maxLength:512,pattern:`^[^\\u0000-\\u001f\\u007f]+$`}),hW=W.Object({platform:fW,installation_ref:pW},{additionalProperties:!1}),gW=W.Object({installation:hW,conversation_ref:mW,thread_ref:W.Optional(mW),parent_message_ref:W.Optional(mW),root_message_ref:W.Optional(mW)},{additionalProperties:!1}),_W=W.Object({conversation:gW,message_ref:mW},{additionalProperties:!1}),vW=W.Object({installation:hW,subject_kind:W.Union([W.Literal(`human`),W.Literal(`bot`),W.Literal(`app`),W.Literal(`system`)]),subject_ref:mW},{additionalProperties:!1}),yW=W.Object({kind:W.Literal(`human`),account_ref:uh,display_name:W.String({minLength:1,maxLength:256}),membership:W.Object({relay_project_ref:lh,label:W.Union([W.Literal(`owner`),W.Literal(`member`)])},{additionalProperties:!1}),channel:W.Union([W.Literal(`platform_chat`),W.Literal(`platform_h5`),W.Literal(`platform_card_callback`),W.Literal(`platform_document_sync`)]),external_subject:vW,binding_ref:pW,verified_at:G},{additionalProperties:!1}),bW=W.Object({kind:W.Literal(`system`),purpose:W.Union([W.Literal(`live_ingestion`),W.Literal(`history_backfill`),W.Literal(`revision_observation`),W.Literal(`attachment_handoff`),W.Literal(`projection_retry`),W.Literal(`reconciliation`)]),installation:hW,binding_ref:W.Optional(pW),verified_at:G},{additionalProperties:!1}),xW=W.Object({...yW.properties,kind:W.Literal(`bot`),purpose:W.Literal(`development_operator`),channel:W.Literal(`platform_chat`)},{additionalProperties:!1});W.Union([yW,bW]);var SW=W.Object({account_ref:uh,display_name:W.String({minLength:1,maxLength:256}),external_subject:vW},{additionalProperties:!1}),CW=W.Object({external_subject:vW},{additionalProperties:!1}),wW=W.Object({external_subject:vW,account_ref:W.Optional(uh),display_text:W.Optional(W.String({minLength:1,maxLength:256})),target_kind:W.Union([W.Literal(`person`),W.Literal(`tutti`)])},{additionalProperties:!1}),TW=W.Union([W.Object({kind:W.Literal(`text`),text:W.String({minLength:1,maxLength:1e5}),mentions:W.Array(wW,{maxItems:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`post`),text:W.String({minLength:1,maxLength:1e5}),mentions:W.Array(wW,{maxItems:128})},{additionalProperties:!1})]),EW=W.Object({attachment_ref:mW,attachment_kind:W.Union([W.Literal(`file`),W.Literal(`image`),W.Literal(`audio`),W.Literal(`video`),W.Literal(`other`)]),file_name:W.Optional(W.String({minLength:1,maxLength:512})),media_type:W.Optional(W.String({minLength:1,maxLength:255})),declared_size_bytes:W.Optional(W.Integer({minimum:0,maximum:2**53-1}))},{additionalProperties:!1}),DW=W.Object({attachment:EW,size_bytes:W.Integer({minimum:1,maximum:2**53-1}),sha256:W.String({pattern:`^sha256:[0-9a-f]{64}$`}),media_type:W.String({minLength:1,maxLength:255}),verified_at:G},{additionalProperties:!1}),OW=W.Object({locator:_W,author:CW,attachment:EW,external_created_at:G,observed_at:G,adapter_version:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),kW=W.Object({external_references:W.Optional(W.Array(C_,{minItems:1,maxItems:16})),locator:_W,revision_ref:mW,author:SW,content:TW,attachments:W.Array(EW,{maxItems:64}),external_created_at:G,observed_at:G,adapter_version:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),AW=W.Object({external_references:W.Optional(W.Array(C_,{minItems:1,maxItems:16})),locator:_W,revision_ref:mW,author:CW,content:TW,attachments:W.Array(EW,{maxItems:64}),external_created_at:G,observed_at:G,adapter_version:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),jW=W.Union([W.Object({kind:W.Literal(`edited`),locator:_W,revision_ref:mW,content:TW,attachments:W.Array(EW,{maxItems:64}),external_updated_at:G,observed_at:G,adapter_version:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`deleted`),locator:_W,revision_ref:mW,external_updated_at:G,observed_at:G,adapter_version:W.String({minLength:1,maxLength:128})},{additionalProperties:!1})]),MW=W.Object({receipt_key:pW,installation:hW,external_event_ref:mW,event_kind:W.Union([W.Literal(`conversation_source`),W.Literal(`conversation_revision`),W.Literal(`attachment`),W.Literal(`card_action`)]),received_at:G,attempt:W.Integer({minimum:1,maximum:1e6})},{additionalProperties:!1}),NW=W.Object({kind:W.Literal(`conversation_source`),receipt:MW,actor:bW,source:kW},{additionalProperties:!1}),PW=W.Object({kind:W.Literal(`conversation_revision`),receipt:MW,actor:bW,observation:jW},{additionalProperties:!1});W.Union([NW,PW]);var FW=W.Union([W.Object({kind:W.Literal(`created`),message_id:Zm},{additionalProperties:!1}),W.Object({kind:W.Literal(`duplicate`),message_id:Zm},{additionalProperties:!1}),W.Object({kind:W.Literal(`revision_recorded`),message_id:Zm,revision_ref:mW},{additionalProperties:!1}),W.Object({kind:W.Literal(`stale_revision`),message_id:Zm,revision_ref:mW},{additionalProperties:!1}),W.Object({kind:W.Literal(`unsupported`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`unauthorized`),reason_code:W.Optional(W.String({minLength:1,maxLength:128}))},{additionalProperties:!1}),W.Object({kind:W.Literal(`binding_missing`)},{additionalProperties:!1}),W.Object({kind:W.Literal(`host_unavailable`),retryable:W.Literal(!0),reason_code:W.Optional(W.String({minLength:1,maxLength:128})),retry_after:W.Optional(G)},{additionalProperties:!1}),W.Object({kind:W.Literal(`host_incompatible`),retryable:W.Literal(!0),reason_code:W.Union([W.Literal(`integration_source_ingestion_unsupported`),W.Literal(`integration_attachment_ingestion_unsupported`),W.Literal(`integration_managed_reference_ingestion_unsupported`),W.Literal(`integration_clarification_unsupported`)])},{additionalProperties:!1}),W.Object({kind:W.Literal(`invalid`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1})]);W.Object({protocol_version:W.Union([W.Literal(2),W.Literal(3)]),command_id:ch,relay_project_ref:lh,binding_ref:pW,receipt:MW,source:AW,clarification_round_ref:W.Optional(oh)},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),command_id:ch,relay_project_ref:lh,binding_ref:pW,receipt:MW,source:OW,content:DW},{additionalProperties:!1});var IW=W.Union([W.Object({kind:W.Literal(`staged`),upload:i_,put:a_},{additionalProperties:!1}),W.Object({kind:W.Literal(`unauthorized`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`invalid`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`unavailable`),retryable:W.Literal(!0),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1})]);W.Object({protocol_version:W.Literal(1),disposition:IW},{additionalProperties:!1});var LW=W.String({minLength:20,maxLength:20,pattern:`^[A-Z2-7]+$`});W.Union([W.Object({state:W.Literal(`account_handoff_required`)},{additionalProperties:!1}),W.Object({state:W.Literal(`pairing_required`),pairing_code:LW,command:W.String({minLength:1,maxLength:128}),expires_at:G,visibility:W.Literal(`visible_once`)},{additionalProperties:!1}),W.Object({state:W.Literal(`pairing_required`),expires_at:W.Optional(G),visibility:W.Literal(`not_recoverable`)},{additionalProperties:!1}),W.Object({state:W.Literal(`connected`)},{additionalProperties:!1})]),W.Object({protocol_version:W.Literal(1),pairing_code:LW,binding_ref:pW,installation:hW,conversation_ref:mW,external_subject:vW,observed_at:G},{additionalProperties:!1});var RW=W.Union([W.Object({kind:W.Literal(`bound`),relay_project_ref:lh,project_display_name:W.String({minLength:1,maxLength:256})},{additionalProperties:!1}),W.Object({kind:W.Literal(`duplicate`),relay_project_ref:lh,project_display_name:W.String({minLength:1,maxLength:256})},{additionalProperties:!1}),W.Object({kind:W.Literal(`invalid`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`unauthorized`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`conflict`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1})]);W.Object({protocol_version:W.Literal(1),disposition:RW},{additionalProperties:!1});var zW=W.Object({source_ref:pW,adapter_key:W.Literal(`feishu_docx`),installation:hW,external_subject:vW,reference_path:W.String({minLength:1,maxLength:1024})},{additionalProperties:!1}),BW=W.Object({size_bytes:W.Integer({minimum:0,maximum:2**53-1}),sha256:W.String({pattern:`^sha256:[0-9a-f]{64}$`}),media_type:W.Literal(`text/plain; charset=utf-8`)},{additionalProperties:!1});W.Object({protocol_version:W.Literal(1),command_id:ch,operation_ref:pW,relay_project_ref:lh,binding_ref:pW,source:zW,remote_revision_ref:mW,expected_host_blob_oid:W.Optional(W.String({pattern:`^[0-9a-f]{40,64}$`})),content:BW},{additionalProperties:!1});var VW=IW;W.Object({protocol_version:W.Literal(1),disposition:VW},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),command_id:ch,operation_ref:pW,relay_project_ref:lh,binding_ref:pW,source:zW,remote_revision_ref:mW,expected_host_blob_oid:W.Optional(W.String({pattern:`^[0-9a-f]{40,64}$`})),content:BW,staged_upload:W.Object(Qg,{additionalProperties:!1})},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),command_id:ch,operation_ref:pW,relay_project_ref:lh,binding_ref:pW,source:zW,remote_revision_ref:mW,expected_host_blob_oid:W.Optional(W.String({pattern:`^[0-9a-f]{40,64}$`})),content:BW,staged_upload:W.Object(Qg,{additionalProperties:!1}),actor:yW},{additionalProperties:!1});var HW=W.Union([W.Object({kind:W.Union([W.Literal(`created`),W.Literal(`updated`),W.Literal(`unchanged`)]),current_blob_oid:W.String({pattern:`^[0-9a-f]{40,64}$`})},{additionalProperties:!1}),W.Object({kind:W.Literal(`duplicate`),outcome:W.Union([W.Literal(`created`),W.Literal(`updated`),W.Literal(`unchanged`)]),current_blob_oid:W.String({pattern:`^[0-9a-f]{40,64}$`})},{additionalProperties:!1}),W.Object({kind:W.Literal(`host_unavailable`),retryable:W.Literal(!0),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`host_incompatible`),retryable:W.Literal(!0),reason_code:W.Literal(`integration_managed_reference_ingestion_unsupported`)},{additionalProperties:!1}),W.Object({kind:W.Union([W.Literal(`invalid`),W.Literal(`unauthorized`),W.Literal(`conflict`)]),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1})]);W.Object({protocol_version:W.Literal(1),disposition:HW},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),command_id:ch,relay_project_ref:lh,binding_ref:pW,receipt:MW,actor:W.Union([yW,xW]),source:kW,clarification_round_ref:W.Optional(oh)},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),command_id:ch,relay_project_ref:lh,binding_ref:pW,receipt:MW,source:OW,staged_upload:W.Object(Qg,{additionalProperties:!1})},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),command_id:ch,relay_project_ref:lh,binding_ref:pW,receipt:MW,actor:yW,source:OW,staged_upload:W.Object(Qg,{additionalProperties:!1})},{additionalProperties:!1}),W.Union([W.Object({protocol_version:W.Literal(1),relay_project_ref:lh,installation:hW,binding_ref:pW,receipt_key:pW,verified_at:G},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),relay_project_ref:lh,installation:hW,binding_ref:pW,operation_ref:pW,verified_at:G},{additionalProperties:!1})]),W.Object({protocol_version:W.Literal(1),disposition:FW},{additionalProperties:!1});var UW=W.Object({kind:W.Literal(`text`),text:W.String({minLength:1,maxLength:4e3}),clarification_round_ref:W.Optional(oh)},{additionalProperties:!1}),WW=W.String({minLength:1,maxLength:128,pattern:`^cardrev_[0-9a-f]{32}$`}),GW=W.Object({decision_id:W.String({minLength:1,maxLength:256}),kind:W.Union([W.Literal(`allow_once`),W.Literal(`allow_session`),W.Literal(`deny`),W.Literal(`cancel`)]),label:W.String({minLength:1,maxLength:256}),tone:W.Union([W.Literal(`primary`),W.Literal(`neutral`),W.Literal(`danger`)])},{additionalProperties:!1}),KW=W.Object({kind:W.Literal(`approval_request`),approval_id:W.String({minLength:1,maxLength:256}),card_revision:WW,title:W.String({minLength:1,maxLength:512}),summary:W.String({minLength:1,maxLength:4e3}),reason:W.Optional(W.String({minLength:1,maxLength:2e3})),requested_at:G,expires_at:W.Optional(G),decisions:W.Array(GW,{minItems:1,maxItems:8})},{additionalProperties:!1}),qW=W.Union([UW,KW,dW]),JW=W.Object({kind:W.Union([W.Literal(`chat_response`),W.Literal(`needs_input`),W.Literal(`task_completed`),W.Literal(`task_failed`)]),event_key:mW,subject:W.Object({kind:W.Union([W.Literal(`message`),W.Literal(`clarification_round`),W.Literal(`approval_request`),W.Literal(`task_result`)]),ref:mW},{additionalProperties:!1}),target:W.Object({kind:W.Union([W.Literal(`project`),W.Literal(`work`)])},{additionalProperties:!1})},{additionalProperties:!1}),YW={protocol_version:W.Literal(1),intent_ref:ch,relay_project_ref:lh,installation:hW,binding_ref:pW,canonical_message_ref:W.Optional(Zm),trigger_message_ref:W.Optional(Zm),content:qW,event:W.Optional(JW),created_at:G,attempt:W.Integer({minimum:1,maximum:1e6})};W.Object(YW,{additionalProperties:!1});var XW=W.Object({...YW,conversation_ref:mW},{additionalProperties:!1}),ZW=W.Object({conversation_ref:mW,message_ref:mW,action_ref:pW,card_revision:WW,external_subject:vW},{additionalProperties:!1});W.Object({protocol_version:W.Literal(1),command_id:ch,relay_project_ref:lh,binding_ref:pW,receipt:MW,callback:ZW,approval_id:W.String({minLength:1,maxLength:256}),decision_id:W.String({minLength:1,maxLength:256})},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),command_id:ch,relay_project_ref:lh,binding_ref:pW,receipt:MW,actor:yW,callback:W.Object({message_ref:mW,action_ref:pW,card_revision:WW},{additionalProperties:!1}),approval_id:W.String({minLength:1,maxLength:256}),decision_id:W.String({minLength:1,maxLength:256})},{additionalProperties:!1});var QW=W.Union([W.Object({kind:W.Literal(`accepted`)},{additionalProperties:!1}),W.Object({kind:W.Literal(`stale_approval`)},{additionalProperties:!1}),W.Object({kind:W.Literal(`decision_unavailable`)},{additionalProperties:!1}),W.Object({kind:W.Literal(`interrupted`),retry_with_new_command_id:W.Boolean()},{additionalProperties:!1}),W.Object({kind:W.Literal(`unauthorized`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`invalid`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`host_unavailable`),retryable:W.Literal(!0),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`host_incompatible`),retryable:W.Literal(!0),reason_code:W.Literal(`integration_approval_decision_unsupported`)},{additionalProperties:!1})]);W.Object({protocol_version:W.Literal(1),disposition:QW},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),installation:hW},{additionalProperties:!1}),W.Union([W.Object({protocol_version:W.Literal(1),disposition:W.Object({kind:W.Literal(`idle`),retry_after_ms:W.Integer({minimum:100,maximum:6e4})},{additionalProperties:!1})},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),disposition:W.Object({kind:W.Literal(`claimed`),claim_ref:pW,claim_expires_at:G,intent:XW},{additionalProperties:!1})},{additionalProperties:!1})]);var $W=W.Union([W.Object({kind:W.Literal(`accepted`),delivery_ref:pW},{additionalProperties:!1}),W.Object({kind:W.Literal(`duplicate`),delivery_ref:pW},{additionalProperties:!1}),W.Object({kind:W.Literal(`rejected`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1})]);W.Object({protocol_version:W.Literal(1),installation:hW,claim_ref:pW,intent_ref:ch,disposition:$W},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),disposition:W.Union([W.Object({kind:W.Literal(`acknowledged`)},{additionalProperties:!1}),W.Object({kind:W.Literal(`stale`),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1})])},{additionalProperties:!1});var eG=W.Union([W.Object({kind:W.Literal(`accepted`),delivery_ref:pW},{additionalProperties:!1}),W.Object({kind:W.Literal(`duplicate`),delivery_ref:pW},{additionalProperties:!1}),W.Object({kind:W.Literal(`unavailable`),retryable:W.Literal(!0),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Union([W.Literal(`invalid`),W.Literal(`unauthorized`),W.Literal(`unsupported`)]),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1})]);W.Object({protocol_version:W.Literal(1),disposition:eG},{additionalProperties:!1});var tG=W.String({minLength:1,maxLength:4096,pattern:`^[^\\u0000-\\u001f\\u007f]+$`}),nG=W.String({minLength:36,maxLength:36,pattern:`^feishu_user_[a-f0-9]{24}$`});W.Object({version:W.Literal(1),installation_ref:W.String({minLength:1,maxLength:512}),external_subject_ref:W.String({minLength:9,maxLength:508,pattern:`^open_id:[A-Za-z0-9_-]{1,500}$`}),access_token:tG,refresh_token:tG,access_expires_at:G,refresh_expires_at:W.Optional(G),scopes:W.Array(W.String({minLength:1,maxLength:256}),{minItems:1,maxItems:32,uniqueItems:!0}),authorized_at:G},{additionalProperties:!1}),W.Object({credential_ref:nG,updated_at:G},{additionalProperties:!1});var rG={authority:W.Object({project_ref:lh,installation_ref:W.String({minLength:1,maxLength:512}),binding_ref:W.String({minLength:1,maxLength:512}),external_subject_ref:W.String({pattern:`^open_id:[A-Za-z0-9_-]{1,500}$`}),role:W.Union([W.Literal(`owner`),W.Literal(`member`)])},{additionalProperties:!1}),diagnostic_id:W.Optional(W.String({pattern:`^fdiag_[a-f0-9]{32}$`}))};W.Union([W.Object({...rG,action:W.Literal(`list`)},{additionalProperties:!1}),W.Object({...rG,action:W.Literal(`connect`),document_id:W.String({pattern:`^[A-Za-z0-9]{27}$`})},{additionalProperties:!1}),W.Object({...rG,action:W.Literal(`connect_wiki`),node_token:W.String({pattern:`^[A-Za-z0-9]{1,999}$`})},{additionalProperties:!1}),W.Object({...rG,action:W.Literal(`refresh`),source_ref:m_,...h_.properties},{additionalProperties:!1})]);var iG={authority:W.Object({project_ref:lh,installation_ref:W.String({minLength:1,maxLength:512}),binding_ref:W.String({minLength:1,maxLength:512}),external_subject_ref:W.String({pattern:`^open_id:[A-Za-z0-9_-]{1,500}$`}),role:W.Union([W.Literal(`owner`),W.Literal(`member`)])},{additionalProperties:!1}),request_ref:W.String({pattern:`^eref_[a-f0-9]{32}$`})},aG={source_ref:__};W.Union([W.Object({...iG,action:W.Literal(`list`),include_pending:W.Optional(W.Boolean())},{additionalProperties:!1}),W.Object({...iG,action:W.Literal(`register`),document_url:W.String({minLength:1,maxLength:2048})},{additionalProperties:!1}),W.Object({...iG,action:W.Literal(`confirm`),submission_ref:x_},{additionalProperties:!1}),W.Object({...iG,...aG,action:W.Literal(`prepare`)},{additionalProperties:!1}),W.Object({...iG,action:W.Literal(`resolve`),document_url:W.String({minLength:1,maxLength:2048})},{additionalProperties:!1}),W.Object({...iG,action:W.Literal(`authorization_status`),authorization_ref:v_},{additionalProperties:!1}),W.Object({...iG,...aG,action:W.Literal(`transfer`),transfer_ref:W.String({pattern:`^transfer_[a-f0-9]{32}$`}),put_url:W.String({maxLength:8192,pattern:`^https://`}),headers:W.Record(W.String({maxLength:128}),W.String({maxLength:2048}))},{additionalProperties:!1})]);var oG=W.Object({source:C_,revision:W.String({minLength:1,maxLength:256}),sha256:W.String({pattern:`^[a-f0-9]{64}$`}),size_bytes:W.Integer({minimum:0,maximum:10485760}),media_type:W.String({minLength:1,maxLength:128}),transfer_ref:W.String({pattern:`^transfer_[a-f0-9]{32}$`})},{additionalProperties:!1});W.Object({...oG.properties,upload_id:W.Optional(mh)},{additionalProperties:!1}),W.Object({supports_drive_files:W.Optional(W.Boolean()),invocation_ref:W.Optional(rh),project_identity:W.Object({source:W.Literal(`git_config`),project_id:Xm},{additionalProperties:!1}),host_auth:W.Object({kind:W.Literal(`host_registration_secret_v1`),secret:W.String({minLength:1,maxLength:512})},{additionalProperties:!1}),relay_project_ref:lh,host_connection_ref:gh,request_ref:iG.request_ref,action:W.Union([W.Literal(`list`),W.Literal(`read`),W.Literal(`resolve`)]),source_ref:W.Optional(__),document_url:W.Optional(W.String({minLength:1,maxLength:2048}))},{additionalProperties:!1});var sG={protocol_version:W.Literal(1),command_id:ch,relay_project_ref:lh,binding_ref:pW,operation_ref:pW,conversation:gW,external_subject:vW,origin:W.Union([W.Object({kind:W.Literal(`development_operator`)},{additionalProperties:!1}),W.Object({kind:W.Literal(`card_callback`),message_ref:mW,action_ref:pW},{additionalProperties:!1})]),operation:W.Union([W.Object({kind:W.Literal(`query`),round_id:W.Optional(oh)},{additionalProperties:!1}),W.Object({kind:W.Literal(`submit`),round_id:oh,expected_answer_revision:W.Integer({minimum:0})},{additionalProperties:!1})])};W.Object(sG,{additionalProperties:!1}),W.Object({...sG,actor:W.Union([yW,xW])},{additionalProperties:!1}),W.Object({protocol_version:W.Literal(1),disposition:W.Union([W.Object({kind:W.Literal(`queried`),active:Nv,selected:W.Optional(Fv)},{additionalProperties:!1}),W.Object({kind:W.Literal(`submitted`),response:Hv},{additionalProperties:!1}),W.Object({kind:W.Union([W.Literal(`invalid`),W.Literal(`unauthorized`)]),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1}),W.Object({kind:W.Literal(`unavailable`),retryable:W.Boolean(),reason_code:W.String({minLength:1,maxLength:128})},{additionalProperties:!1})])},{additionalProperties:!1}),W.Union([W.Object({action:W.Literal(`resolve`),entry_ref:Jy,diagnostic_id:W.Optional(W.String({pattern:`^fdiag_[a-f0-9]{32}$`}))},{additionalProperties:!1}),W.Object({action:W.Literal(`connect`),entry_ref:Jy,external_subject_ref:W.String({pattern:`^open_id:[A-Za-z0-9_-]{1,128}$`}),input:W.String({minLength:1,maxLength:256}),diagnostic_id:W.Optional(W.String({pattern:`^fdiag_[a-f0-9]{32}$`}))},{additionalProperties:!1})]),W.Object({installation_ref:W.String({minLength:1,maxLength:256}),conversation_ref:W.String({pattern:`^oc_[A-Za-z0-9_-]{1,128}$`}),projection:Yy},{additionalProperties:!1}),W.Object({version:W.Literal(1),audience:W.Literal(`tutti-managed-models`),issuer:W.String({minLength:1,maxLength:200}),account_ref:uh,relay_project_ref:lh,nonce:ch,issued_at:W.Integer({minimum:0}),expires_at:W.Integer({minimum:0})},{additionalProperties:!1}),W.Object({relay_project_ref:lh},{additionalProperties:!1});var cG=e=>W.String({pattern:`^${e}${Mt}$`}),lG=cG(Pt.managedCreation),uG=cG(Pt.hostInstallation),dG=cG(Pt.hostDelegation),fG=cG(Pt.projectModelGrant),pG=W.String({pattern:`^[A-Za-z0-9_-]{43}$`}),mG=W.String({pattern:`^sha256:[a-f0-9]{64}$`}),hG=W.String({pattern:`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$`});function gG(e){let t=Date.parse(e);return Number.isFinite(t)&&new Date(t).toISOString()===e}var _G=W.Object({request_ref:ch,project_id:Xm,surface:W.Union([W.Literal(`standalone`),W.Literal(`feishu`)]),existing_relay_project_ref:W.Optional(lh),installation_ref:uG,installation_secret_hash:mG,handoff_token_hash:mG,host_registration_secret_hash:mG,trial_consent:W.Literal(`trial-project-v1`),expires_before:W.Optional(hG)},{additionalProperties:!1});W.Object({console_token:pG,preparation:_G},{additionalProperties:!1}),W.Object({kind:W.Literal(`managed_project_authority_v2`),creation_ref:lG,handoff_token:pG,installation_ref:uG,installation_secret:pG},{additionalProperties:!1}),W.Object({delegation_ref:dG,installation_ref:uG,installation_secret:pG,relay_project_ref:lh,project_id:Xm,host_registration_secret:W.String({minLength:32,maxLength:256})},{additionalProperties:!1});var vG=W.Object({delegation_ref:dG,grant_ref:fG,relay_project_ref:lh,installation_ref:uG,funding_kind:W.Literal(`trial`),expires_at:W.Null(),state:W.Literal(`active`),model_access:W.Union([W.Literal(`runtime_authority_required`),W.Literal(`not_enabled`)])},{additionalProperties:!1}),yG=W.Object({creation_ref:lG,project_id:Xm,surface:W.Union([W.Literal(`standalone`),W.Literal(`feishu`)]),installation_ref:uG,expires_at:hG,state:W.Union([W.Literal(`prepared`),W.Literal(`activated`),W.Literal(`expired`),W.Literal(`revoked`)]),relay_project_ref:W.Optional(lh)},{additionalProperties:!1});W.Object({request_ref:ch,project_id:Xm,installation_ref:uG,installation_secret:pG,handoff_token:pG,host_registration_secret:W.String({minLength:32,maxLength:256})},{additionalProperties:!1}),W.Object({request_ref:ch,account_ref:uh,creation:yG,authority:W.Optional(vG)},{additionalProperties:!1}),W.Object({command_id:ch,target:W.Union([W.Object({kind:W.Literal(`grant`),ref:fG},{additionalProperties:!1}),W.Object({kind:W.Literal(`delegation`),ref:dG},{additionalProperties:!1}),W.Object({kind:W.Literal(`installation`),ref:uG},{additionalProperties:!1}),W.Object({kind:W.Literal(`creation`),ref:lG},{additionalProperties:!1})])},{additionalProperties:!1}),W.Object({version:W.Literal(2),audience:W.Literal(`tutti-creation-validation`),issuer:W.String({minLength:1,maxLength:200}),account_ref:uh,creation_ref:lG,project_id:Xm,installation_ref:uG,creation_expires_at:W.Integer({minimum:0}),nonce:ch,issued_at:W.Integer({minimum:0}),expires_at:W.Integer({minimum:0})},{additionalProperties:!1}),W.Object({creation_ref:lG,project_id:Xm,installation_ref:uG,route_ref:W.String({pattern:`^[a-z0-9][a-z0-9-]{1,60}$`}),state:W.Union([W.Literal(`started`),W.Literal(`succeeded`),W.Literal(`failed`),W.Literal(`unknown`)]),reason_code:W.Union([W.Literal(`validation_started`),W.Literal(`validation_succeeded`),W.Literal(`validation_route_unavailable`),W.Literal(`validation_http_rejected`),W.Literal(`validation_response_invalid`),W.Literal(`validation_transport_unknown`),W.Literal(`validation_interrupted`)]),http_status:W.Union([W.Null(),W.Integer({minimum:100,maximum:599})])},{additionalProperties:!1});var bG={account_ref:uh,relay_project_ref:lh,delegation_ref:dG,grant_ref:fG,installation_ref:uG},xG={issuer:W.String({minLength:1,maxLength:200}),nonce:ch,issued_at:W.Integer({minimum:0}),expires_at:W.Integer({minimum:0})};W.Object({version:W.Literal(3),audience:W.Literal(`tutti-managed-runtime`),...xG,...bG,funding_kind:W.Literal(`trial`)},{additionalProperties:!1}),W.Object({version:W.Literal(1),audience:W.Literal(`tutti-managed-revocation`),...xG,...bG},{additionalProperties:!1}),W.Object({authorization:W.String({pattern:`^tma3\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]{86}$`,maxLength:3500}),expires_at:W.Integer({minimum:0}),control_origin:W.String({minLength:1,maxLength:500}),delegation_ref:dG},{additionalProperties:!1});var SG=e=>W.String({pattern:`^${e}${Mt}$`}),CG=SG(Pt.managedSession),wG=SG(Pt.managedCredential),TG=W.String({pattern:`^[a-z0-9][a-z0-9-]{1,60}$`}),EG=W.Object({base_url:W.String({minLength:1,maxLength:500}),model:W.String({pattern:`^tutti-[a-z0-9-]{1,80}$`})},{additionalProperties:!1});W.Object({session_ref:CG,route_ref:TG,disposition:W.Union([W.Literal(`created`),W.Literal(`existing`)]),provider:EG},{additionalProperties:!1});var DG=W.Object({credential_ref:wG,session_ref:CG,device_ref:SG(Pt.managedDevice),state:W.Union([W.Literal(`creating`),W.Literal(`active`),W.Literal(`expired`),W.Literal(`revoking`),W.Literal(`revoked`)]),expires_at:W.Integer({minimum:0}),quota_cap:W.Integer({minimum:1})},{additionalProperties:!1}),OG=W.Object({base_url:W.String({minLength:1,maxLength:500}),model:W.String({pattern:`^tutti-[a-z0-9-]{1,80}$`}),api_key:W.String({minLength:16,maxLength:1024,pattern:`^[^\\s]+$`})},{additionalProperties:!1});W.Union([W.Object({disposition:W.Literal(`issued`),credential:DG,route_ref:TG,provider:OG},{additionalProperties:!1}),W.Object({disposition:W.Literal(`already_issued`),credential:DG},{additionalProperties:!1})]),W.Object({disposition:W.Literal(`revoked`),credential:DG},{additionalProperties:!1}),W.Object({version:W.Literal(1),audience:W.Literal(`tutti-managed-account-read`),issuer:W.String({minLength:1,maxLength:200}),account_ref:uh,nonce:ch,issued_at:W.Integer({minimum:0}),expires_at:W.Integer({minimum:0})},{additionalProperties:!1}),W.Union([W.Literal(`in_progress`),W.Literal(`completed`),W.Literal(`failed`)]),W.Object({kind:W.Literal(`interrupted`),retry_with_new_command_id:W.Boolean()},{additionalProperties:!1});var kG=W.Union(w_.map(e=>W.Literal(e))),AG=W.Union([W.Object({kind:W.Literal(`initials`),initials:W.String({minLength:1}),color:kG},{additionalProperties:!1}),W.Object({kind:W.Literal(`image`),image_url:W.String({minLength:1}),initials:W.String({minLength:1}),color:kG},{additionalProperties:!1})]);W.Object({account_ref:uh,display_name:W.String({minLength:1}),avatar:AG,membership:W.Object({label:W.Union([W.Literal(`owner`),W.Literal(`member`)]),relay_project_ref:lh,joined_at:G},{additionalProperties:!1}),client_session_id:fh,client_session_created_at:G},{additionalProperties:!1}),W.Object({platform_session_ref:ph,account_ref:uh,display_name:W.String({minLength:1}),avatar:AG,membership:W.Object({label:W.Union([W.Literal(`owner`),W.Literal(`member`)]),relay_project_ref:lh,joined_at:G},{additionalProperties:!1}),binding_ref:W.String({minLength:1,maxLength:512}),installation_ref:W.String({minLength:1,maxLength:512}),external_subject_ref:W.String({minLength:1,maxLength:512}),platform_session_created_at:G,platform_session_expires_at:G},{additionalProperties:!1});var jG=W.Object({version:W.Literal(2),display_name:W.String({minLength:1,maxLength:80}),preparation:_G},{additionalProperties:!1});function MG(e){if(!e.startsWith(`#managed_request=`))return null;let t=e.slice(17);return Od(ch,t)?t:null}function NG(e){if(e.length>8192||!e.startsWith(`#trial=`))return null;try{let t=JSON.parse(decodeURIComponent(e.slice(7)));return!Od(jG,t)||!t.display_name.trim()||t.preparation.expires_before===void 0||!gG(t.preparation.expires_before)?null:t}catch{return null}}function PG(e){let t=new URL(e);if(t.protocol!==`https:`&&!(t.protocol===`http:`&&t.hostname===`127.0.0.1`)||t.username||t.password||t.pathname!==`/`||t.search||t.hash)throw Error(`Managed authorization origin is invalid.`);return t}function FG(e){if(PG(e.relay_origin),!Od(jG,{version:2,display_name:e.draft.display_name,preparation:e.preparation})||!e.draft.display_name.trim()||e.preparation.expires_before===void 0||!gG(e.preparation.expires_before))throw Error(`Managed authorization entry is invalid.`)}function IG(e){if(!(e instanceof Gt))return`Tutti could not complete this step. Try again from Local Console.`;let t={console_setup_access_invalid:`Your computer sign-in has expired or predates this update. Close this dialog, sign out and sign in to Local Console again.`,account_session_required:`Sign in to Local Console again before starting this project.`,fresh_authentication_required:`Sign in again to confirm this computer and project with a fresh email code.`,authority_target_not_found:`Project access was not confirmed. Choose Check and continue to retry this setup.`,managed_preparation_expired:`This request expired. Close the dialog and start a new request.`,managed_creation_not_validated:`Model validation has not succeeded. Check the authorization and try again.`,managed_existing_project_requires_opt_in:`This is an existing Tutti project. Resume it with its current access; automatic enrollment is disabled.`,managed_trial_not_enabled:`This account is not enabled for the internal Tutti trial.`,managed_validation_unknown:`The model check outcome is unknown. It will not be retried automatically. Contact support before starting a new request.`,managed_validation_failed:`The model access check failed. No automatic retry was started. Review the connection before starting a new request.`,managed_project_must_be_stopped:`Stop this project before changing its model access.`,host_delegation_already_active:`This computer is already authorized. Revoke its access in Account before authorizing it again.`,host_delegation_revocation_pending:`The previous access is revoked. Wait for gateway key reconciliation in Account before authorizing again.`,managed_reauthorization_conflict:`Finish or close the existing authorization request before restoring access.`,project_owner_required:`Sign in as the project's existing owner. Feishu identity linking is not available yet.`},n=/^[a-z0-9_]{1,100}$/u.test(e.code)?e.code:`request_failed`;return`${t[n]??`Tutti could not complete this step.`} (${n}, HTTP ${e.statusCode}${e.requestId?`, ID ${e.requestId}`:``})`}function LG({entry:e}){let t=et(),n=R({queryKey:Z.me,queryFn:()=>Kn(jV)}),r=fH(),i=pH(),a=(0,I.useRef)(null),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(Date.now());(0,I.useEffect)(()=>{let e=window.setInterval(()=>p(Date.now()),1e3);return()=>{window.clearInterval(e),a.current?.abort()}},[]);let m=f>=Date.parse(e.preparation.expires_before);async function h(){if(a.current||m||c)return;let t=new AbortController;a.current=t,s(!0),d(null);let n={baseUrl:jV.relayBaseUrl,credentials:`include`};try{let r;try{r=await fb(n,e.preparation,t.signal)}catch(i){if(!(i instanceof Gt)||i.statusCode!==0&&i.statusCode<500)throw i;try{r=await pb(n,e.preparation.request_ref,t.signal)}catch{throw i}}if(r.project_id!==e.preparation.project_id||r.installation_ref!==e.preparation.installation_ref||r.surface!==e.preparation.surface||r.state!==`prepared`&&r.state!==`activated`)throw Error(`Authority readback mismatch`);t.signal.aborted||l(!0)}catch(e){t.signal.aborted||d(IG(e))}finally{a.current===t&&(a.current=null,s(!1))}}async function g(){if(!a.current){a.current=new AbortController,s(!0);try{await Qn(jV),t.removeQueries({queryKey:Z.me}),await n.refetch(),d(null)}catch(e){d(IG(e))}finally{a.current=null,s(!1)}}}return n.isLoading?null:n.data?.account.profile_complete?(0,L.jsx)(uW,{projectName:e.display_name,surface:e.preparation.surface===`feishu`?`Feishu`:`Tutti Workspace`,accountEmail:n.data.account.email,pending:o,authorized:c,expired:m,error:u,onAuthorize:()=>void h(),onSignInAgain:()=>void g(),onBrandClick:()=>{window.location.assign(`/projects`)}}):(0,L.jsx)(FH,{...n.data?.account?i:r,onBrandClick:()=>{window.location.assign(`/projects`)}})}function RG(){let[e]=(0,I.useState)(()=>NG(window.location.hash));return(0,I.useEffect)(()=>{window.history.replaceState(null,``,window.location.pathname)},[]),e===null?(0,L.jsx)(uW,{projectName:`Invalid trial request`,surface:``,accountEmail:``,pending:!1,authorized:!1,expired:!0,error:`Reopen trial authorization from Local Console.`,onAuthorize:()=>{},onSignInAgain:()=>{},onBrandClick:()=>{window.location.assign(`/projects`)}}):(0,L.jsx)(LG,{entry:e})}function zG(){return(0,I.useEffect)(()=>Q(`/projects?panel=credits`,{replace:!0}),[]),null}var BG=`tutti.workspace-onboarding.v1`,VG={version:1,start_chat_pending:!1,tour_pending:!1};function HG(){try{return typeof window>`u`?null:window.sessionStorage}catch{return null}}function UG(e){return e.storage===void 0?HG():e.storage}function WG(e,t){return`${BG}:${e}:${t}`}function GG(e){if(typeof e!=`object`||!e)return null;let t=e;return t.version===1&&typeof t.start_chat_pending==`boolean`&&typeof t.tour_pending==`boolean`?{version:1,start_chat_pending:t.start_chat_pending,tour_pending:t.tour_pending}:null}function KG(e,t,n){if(e!==null)try{if(!n.start_chat_pending&&!n.tour_pending){e.removeItem(t);return}e.setItem(t,JSON.stringify(n))}catch{}}function qG(e,t,n={}){let r=UG(n);if(r===null)return{...VG};try{let n=r.getItem(WG(e,t));return n===null?{...VG}:GG(JSON.parse(n))??{...VG}}catch{return{...VG}}}function JG(e,t,n={}){KG(UG(n),WG(e,t),{version:1,start_chat_pending:!0,tour_pending:!0})}function YG(e,t,n,r){let i=UG(r),a=qG(e,t,{storage:i});a[n]&&KG(i,WG(e,t),{...a,[n]:!1})}function XG(e,t,n={}){YG(e,t,`start_chat_pending`,n)}function ZG(e,t,n={}){YG(e,t,`tour_pending`,n)}function QG({joinToken:e}){let t=et(),n=R({queryKey:Z.join(e),queryFn:()=>$n(jV,e)}),r=fH(()=>{n.refetch()}),i=pH(()=>{n.refetch()}),a=gt({mutationFn:()=>er(jV,e),onSuccess:n=>{IV(t),t.invalidateQueries({queryKey:Z.join(e)}),n.disposition.kind===`joined`&&n.result!==void 0&&JG(n.result.account.account_ref,n.result.relay_project.relay_project_ref),n.result?.relay_project.host_status===`online`&&Q(en(n.result.relay_project.relay_project_ref))}}),o=gt({mutationFn:e=>tr(jV,e),onSuccess:e=>{IV(t),e.disposition.kind===`opened`&&e.result?.open_url!==void 0&&PV(e.result.open_url)}}),s=n.data;RV(s?.account!==void 0);let c=s?.relay_project?.display_name??`Project`,l=s?.relay_project?.host_status??`unknown`,u=s?.account?.profile_complete===!1,d=u?`login_required`:n.isLoading?`loading`:n.error===null?s?.next.kind??`invalid_or_expired`:`error`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:{kind:`join`,joinToken:e},projectDisplayName:s?.relay_project?.display_name??null}),(0,L.jsx)(RH,{projectName:c,description:d===`invalid_or_expired`?`This invite can no longer be used.`:`You have been invited to join ${c}.`,hostLabel:Fz(l),hostOnline:l===`online`,nextKind:d,accountLabel:s?.account?.display_name??null,membershipLabel:s?.membership?.label??null,actionPending:a.isPending||o.isPending,error:n.error===null?a.error===null?o.error===null?null:$(o.error):$(a.error):$(n.error),onBrandClick:()=>Q(`/`),onRetry:()=>void n.refetch(),onAccept:()=>a.mutate(),onOpen:()=>{s?.next.kind===`open_workspace`&&o.mutate(s.next.relay_project_ref)},...d===`login_required`?{loginForm:u?i:r}:{}})]})}async function $G(e,t,n=`docx`){let r;try{r=await Ob(jV,e,{diagnostics:t,profile:n})}catch(e){throw new iz(`document_authorization_bootstrap`,e,t)}let i;try{i=await nz({appId:r.app_id,state:r.state,scopes:r.authorization_scopes,allowLegacyFallback:!1})}catch(e){throw new iz(`document_authorization_request_access`,e,t)}try{await kb(jV,{relayProjectRef:e,state:r.state,authorizationCode:i},{diagnostics:t})}catch(e){throw new iz(`document_authorization_exchange`,e,t)}}function eK({read:e}){return e.error===void 0?e.fetching?e.data===void 0?(0,L.jsx)(oS,{count:3}):(0,L.jsx)(`p`,{className:`reference-content`,role:`status`,children:`Updating…`}):null:(0,L.jsxs)(`div`,{className:`embedded-project-refresh-message`,role:`status`,children:[e.data===void 0?null:(0,L.jsx)(`p`,{children:`Showing the last loaded snapshot. It may be out of date.`}),(0,L.jsx)(WR,{diagnostic:e.error})]})}function tK(e){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(eK,{read:e.read}),e.read.data===void 0?(0,L.jsx)(aS,{children:e.read.error?`Timeline unavailable.`:`Loading timeline…`}):(0,L.jsx)(OR,{...e.read.data,presentation:`sheet`,empty:(0,L.jsx)(aS,{children:`No timeline events yet.`})})]})}var nK={root:e=>[`feishu-project`,e],supporting:e=>[`feishu-project`,e,`supporting`],skills:e=>[`feishu-project`,e,`supporting`,`skills`],skillDetails:e=>[`feishu-project`,e,`supporting`,`skill`],skillDetail:(e,t)=>[`feishu-project`,e,`supporting`,`skill`,t],timeline:e=>[`feishu-project`,e,`supporting`,`timeline`],bootstrap:e=>[`feishu-project`,e,`bootstrap`],scratchpad:e=>[`feishu-project`,e,`scratchpad`],worklist:e=>[`feishu-project`,e,`worklist`],executionStatus:e=>[`feishu-project`,e,`execution-status`],artifacts:e=>[`feishu-project`,e,`artifacts`],artifactPreviewSession:(e,t)=>[`feishu-project`,e,`artifact-preview-session`,t],activeClarification:e=>[`feishu-project`,e,`active-clarification`],clarificationMessages:(e,t)=>[`feishu-project`,e,`clarification-messages`,t],activeApproval:e=>[`feishu-project`,e,`active-approval`],referenceFiles:e=>[`feishu-project`,e,`reference-files`],viewerFiles:e=>[`feishu-project`,e,`viewer-file`],viewerFile:(e,t)=>[`feishu-project`,e,`viewer-file`,t],taskDetail:(e,t)=>[`feishu-project`,e,`task-detail`,t],taskRunResults:(e,t)=>[`feishu-project`,e,`task-run-results`,t]};function rK(e,t){e.invalidateQueries({queryKey:nK.root(t)})}function iK(e,t,n){if(n===void 0)return;if(n.some(e=>e.kind===`all`)){rK(e,t);return}for(let r of n)switch(r.kind){case`all`:break;case`bootstrap`:case`workspace`:case`session`:e.invalidateQueries({queryKey:nK.bootstrap(t)});break;case`scratchpad`:e.invalidateQueries({queryKey:nK.scratchpad(t)});break;case`worklist`:e.invalidateQueries({queryKey:nK.worklist(t)});break;case`task`:case`task_detail`:e.invalidateQueries({queryKey:nK.taskDetail(t,r.task_id)});break;case`task_run_results`:e.invalidateQueries({queryKey:nK.taskRunResults(t,r.task_id)});break;case`messages`:r.scope===`clarification_round`&&e.invalidateQueries({queryKey:nK.clarificationMessages(t,r.round_id)});break;case`clarification`:e.invalidateQueries({queryKey:nK.activeClarification(t)}),r.round_id!==void 0&&e.invalidateQueries({queryKey:nK.clarificationMessages(t,r.round_id)});break;case`approval`:e.invalidateQueries({queryKey:nK.activeApproval(t)});break;case`execution_status`:case`activity`:e.invalidateQueries({queryKey:nK.executionStatus(t)});break;case`viewer`:(r.path===void 0||r.path.startsWith(`docs/reference`))&&(e.invalidateQueries({queryKey:nK.referenceFiles(t)}),e.invalidateQueries({queryKey:nK.viewerFiles(t)}));break;case`artifacts`:e.invalidateQueries({queryKey:nK.artifacts(t)});break;case`read_state`:case`provider_config`:case`provider_usage`:case`project_timeline`:case`skills`:case`recovery_summaries`:break}let r=new Map,i=e=>r.set(JSON.stringify(e),e);for(let e of n)e.kind===`skills`&&(i(nK.skills(t)),i(nK.skillDetails(t))),([`workspace`,`viewer`,`worklist`,`task`,`task_detail`,`task_run_results`,`clarification`,`project_timeline`,`provider_usage`].includes(e.kind)||e.kind===`messages`&&e.scope===`clarification_round`)&&i(nK.timeline(t));for(let t of r.values())e.invalidateQueries({queryKey:t})}function aK(e){return e.streamStatus!==`open`&&e.nowMs-e.lastRefreshAtMs>=(e.throttleMs??3e4)}function oK(e,t,n,r){let i=R({queryKey:e,queryFn:async({signal:e})=>{let n=oz();try{return await r({signal:e,diagnostics:n})}catch(e){throw new iz(t,e,n)}},enabled:n,retry:!1,staleTime:3e4,refetchOnMount:`always`,refetchOnWindowFocus:!1}),a=i.error instanceof iz?i.error.cause:i.error,o=a instanceof Gt&&a.statusCode>=400&&a.statusCode<500;return{...i.data===void 0||o?{}:{data:i.data},...i.error===null?{}:{error:gz(i.error,oz())},fetching:n&&i.isFetching}}function sK(e,t){let{data:n,...r}=e;return{...r,...n===void 0?{}:{data:t(n)}}}function cK({client:e,relayProjectRef:t,onSelectTask:n}){return(0,L.jsx)(tK,{read:sK(oK(nK.timeline(t),`project_timeline`,!0,t=>e.getProjectTimeline(t)),e=>HB(e,{onOpenWorklistTask:n}))})}function lK(e){let{tracker:t,execution:n,scratchpad:r,clarification:i,approval:a}=e,o=e.submission&&t?.kind===`activity`&&t.workflowRef!==void 0&&e.submission.operation.ref!==t.workflowRef?void 0:e.submission;if(o!==void 0&&t?.kind!==`request`){let e=o?.status===`running`||o?.status===`waiting_input`;return{activeSubmit:e,settled:o?.status===`succeeded`||o?.status===`failed`,failure:o?.status===`failed`?o.failure:void 0,submitPending:e,syncPending:JV(n,`scratchpad_refresh`),actionsDisabled:o?.status===`unknown`||o===null&&t!==null||YV(n)||i.state===`active`||a.state===`pending`}}let s=t?.kind===`activity`?t:void 0,c=e=>s!==void 0&&(e.activity_ref===s.activityRef||s.workflowRef!==void 0&&e.workflow_ref===s.workflowRef),l=qV(n).some(c),u=i.state===`active`&&i.thread.owner.kind===`task_compile`,d=l||u||JV(n,`task_compile`,`foreground`)||JV(n,`project_context_bootstrap`,`foreground`)||JV(n,`scratchpad_refresh`,`foreground`),f=s!==void 0&&(r.receipts.some(c)||r.state===`submitted`&&c({...r.submitted_by_activity_ref===void 0?{}:{activity_ref:r.submitted_by_activity_ref},...r.submitted_by_workflow_ref===void 0?{}:{workflow_ref:r.submitted_by_workflow_ref}})),p=n.last_conclusion,m=!d&&p?.kind===`failed`&&c(p)?p:void 0,h=f||m!==void 0;return{activeSubmit:d,settled:h,failure:m,submitPending:d||t!==null&&t.kind!==`unconfirmed`&&!h,syncPending:JV(n,`scratchpad_refresh`),actionsDisabled:t?.kind===`unconfirmed`||YV(n)||i.state===`active`||a.state===`pending`}}function uK(e,t){if(e.disposition.kind!==`accepted`&&e.disposition.kind!==`already_running`)return null;let n=e.result?.activity_ref,r=e.result?.submission_ref??e.result?.workflow_ref;return n===void 0?r===void 0?null:{kind:`unconfirmed`,commandId:t}:{kind:`activity`,activityRef:n,...r===void 0?{}:{workflowRef:r}}}function dK(e,t,n){return!t||e instanceof Gt&&[400,401,403,404,409,422].includes(e.statusCode)?null:{kind:`unconfirmed`,commandId:n}}function fK(e){let t=e.tracker?.kind===`unconfirmed`?{command_id:e.tracker.commandId}:e.tracker?.kind===`activity`&&e.tracker.workflowRef?{workflow_ref:e.tracker.workflowRef}:{},n=R({queryKey:[...e.key,`submission`,t],queryFn:({signal:n})=>e.read(t,n),enabled:e.enabled&&e.tracker?.kind!==`request`,retry:!1,refetchInterval:t=>t.state.error?15e3:t.state.data?.request?.status===`running`||t.state.data?.request?.status===`waiting_input`||e.tracker!==null?1500:1e4,refetchIntervalInBackground:!1,staleTime:0}),r=n.fetchStatus===`paused`?`reconnecting`:n.isError?n.data?`stale`:`unknown`:n.data?`current`:`unknown`;return{...n,request:e.enabled?n.data?.request:void 0,observation:r,note:e.enabled?pK(n.data?.request,r,e.tracker):void 0}}function pK(e,t,n){if(n?.kind!==`request`){if(!e&&n?.kind===`unconfirmed`)return`Acceptance is not confirmed. Check the project status before submitting again.`;if(t!==`current`&&(e?.status===`running`||e?.status===`waiting_input`||n!==null))return`Reconnecting. The latest request status is not confirmed; do not run it again yet.`;if(e?.status===`unknown`)return`Request status is unavailable. Refresh before starting another run.`;if(e?.status===`failed`)return`Tasks were not prepared. Review Scratchpad before running again. Diagnostic ID: ${e.failure.diagnostic_id}`}}var mK=1500,hK=6e4;function gK(e){let{client:t,relayProjectRef:n}=e,r=et(),i=Dz(),[a,o]=(0,I.useState)(null),s=(0,I.useRef)(!1),c=(0,I.useRef)(Vt()),l=fK({enabled:e.requestStatusSupported,key:nK.worklist(n),tracker:a,read:(n,r)=>t.getWorklistSubmission(n,{signal:r,diagnostics:e.diagnostics})}),u=gt({mutationFn:()=>hz(`worklist_submit`,async n=>({response:await t.submitWorklist(e.scratchpad.updated_at===void 0?{}:{expected_scratchpad_updated_at:e.scratchpad.updated_at},{commandId:c.current},{diagnostics:n}),diagnostics:n})),onMutate:()=>(o({kind:`request`}),i.notify({tone:`loading`,title:`Running Scratchpad`})),onSuccess:({response:e},t,a)=>{let s=e.disposition.kind===`accepted`;o(uK(e,c.current)),iK(r,n,e.invalidates),i.update(a,{tone:s?`success`:`warning`,title:s?`Scratchpad run started`:`Scratchpad run not started`,message:e.disposition.kind===`already_running`?`Tutti is already processing work.`:s?`Tutti is preparing Worklist tasks.`:`Refresh the project and review its current status.`})},onError:(t,n,r)=>{o(dK(t,e.requestStatusSupported,c.current)),i.update(r,{tone:`warning`,title:`Scratchpad acceptance not confirmed`,message:mz(t,e.diagnostics)})},onSettled:()=>{s.current=!1}}),d=lK({...e,tracker:a,...l.request===void 0?{}:{submission:l.request}}),f=u.data?.diagnostics??e.diagnostics;(0,I.useEffect)(()=>{a===null||!d.settled||(o(null),iK(r,n,[{kind:`worklist`}]),d.failure!==void 0&&i.notify({tone:`error`,title:`Scratchpad run failed`,message:`Tutti could not prepare tasks. Review the project status before retrying. Diagnostic ID: ${f.diagnosticId} · ${f.webRelease} · worklist_submit · submit_chain_failed`}))},[a,d.settled,d.failure,f,i,r,n]);let p=d.submitPending;return(0,I.useEffect)(()=>{if(!p)return;let e=window.setInterval(()=>{if(document.visibilityState!==`hidden`)for(let e of[nK.scratchpad(n),nK.executionStatus(n),nK.activeClarification(n)])r.refetchQueries({queryKey:e,exact:!0,type:`active`},{cancelRefetch:!1})},mK);return()=>window.clearInterval(e)},[p,r,n]),(0,I.useEffect)(()=>{if(e.requestStatusSupported||a?.kind!==`activity`||d.activeSubmit||d.settled)return;let t=window.setTimeout(()=>{o(null),i.notify({tone:`warning`,title:`Scratchpad status could not be confirmed`,message:`The request was accepted, but its latest status is unavailable. Refresh the project before retrying. Diagnostic ID: ${f.diagnosticId} · ${f.webRelease} · worklist_submit · submit_status_unconfirmed`})},hK);return()=>window.clearTimeout(t)},[e.requestStatusSupported,a,d.activeSubmit,d.settled,f,i]),{note:l.note,submitPending:u.isPending||d.submitPending,syncPending:d.syncPending,actionsDisabled:d.actionsDisabled,submit:()=>{s.current||d.submitPending||d.syncPending||d.actionsDisabled||(s.current=!0,c.current=Vt(),u.mutate())}}}function _K({access:e,loading:t,pending:n,error:r,onAuthorize:i,onRefresh:a}){return(0,L.jsx)(EL,{brand:(0,L.jsx)(UR,{label:`Tutti`,onClick:a}),projectName:`Document access`,onRefresh:a,refreshing:t||n,children:t?(0,L.jsx)(oS,{count:3}):r?(0,L.jsx)(aS,{details:(0,L.jsx)(WR,{diagnostic:r}),children:`Document access unavailable.`}):(0,L.jsx)(aS,{details:e?.status===`pending`?(0,L.jsx)(Cw,{disabled:n,onClick:i,children:n?`Authorizing…`:`Authorize document access`}):void 0,children:e?.status===`authorized`?`Access is ready. Return to the group and retry the question, or continue the task from its pending step.`:e?.status===`expired`?`This access request expired. Ask Tutti to try reading again.`:`Tutti needs the project owner's permission to read the requested material.`})})}function vK(e){let t=new URLSearchParams(e).getAll(`access_request`);return t.length===1&&/^ref_auth_[a-f0-9]{32}$/u.test(t[0])?t[0]:void 0}function yK({project:e,authorizationRef:t,prepareSession:n}){let[r,i]=(0,I.useState)(0),[a,o]=(0,I.useState)(),[s,c]=(0,I.useState)(!0),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(),p=(0,I.useRef)(!1),m=(0,I.useRef)(0);(0,I.useEffect)(()=>{let r=new AbortController;m.current+=1;let i=oz();return c(!0),f(void 0),o(void 0),n(e,r.signal,i).then(()=>gb(jV,e).authorization(t,{diagnostics:i,signal:r.signal})).then(e=>{r.signal.aborted||o(e)}).catch(e=>{r.signal.aborted||f(gz(new iz(`reference_authorization_status`,e,i),i))}).finally(()=>{r.signal.aborted||c(!1)}),()=>{r.abort(),m.current+=1}},[e,t,n,r]);let h=async()=>{if(p.current||a?.status!==`pending`)return;p.current=!0,u(!0),f(void 0);let n=m.current,r=oz();try{if(await $G(e,r,a.profile),n!==m.current)return;let i=await gb(jV,e).authorization(t,{diagnostics:r});n===m.current&&o(i)}catch(e){n===m.current&&f(gz(e instanceof iz?e:new iz(`reference_authorization_status`,e,r),r))}finally{p.current=!1,n===m.current&&u(!1)}};return(0,L.jsx)(_K,{loading:s,pending:l,...a===void 0?{}:{access:a},...d===void 0?{}:{error:d},onAuthorize:()=>void h(),onRefresh:()=>{p.current||i(e=>e+1)}})}var bK=3e4;function xK(e){if(!(e===void 0||e.disposition.kind===`issued`))return e.disposition.kind===`invalid_manifest`?e.disposition.message:e.disposition.kind===`preview_not_ready`?e.disposition.message??`Preview is not ready`:e.disposition.kind===`not_declared`?`Artifact is no longer declared`:`Preview session expired before it could be opened`}function SK(e){return e===void 0?!1:e.disposition.kind!==`issued`||e.result===void 0?e.disposition.kind===`preview_not_ready`||e.disposition.kind===`interrupted`?1e3:!1:Math.max(1e3,Date.parse(e.result.expires_at)-Date.now()-bK)}function CK(e){return e?.disposition.kind===`issued`?e.result?.bootstrap_url:void 0}var wK=`tutti_feishu_handoff`,TK=/^[A-Za-z0-9_-]{43}$/u;function EK(e){let t=new URLSearchParams(e),n=t.getAll(`view`),r=t.getAll(`open`);return n.length===1&&n[0]===`artifacts`&&r.length===1&&r[0]===`browser`&&!t.has(`authorize`)&&!t.has(`access_request`)&&!t.has(`lk_jump_to_browser`)}function DK(e,t){let n=new URL(`${e.pathname}${e.search}${e.hash}`,e.origin);n.searchParams.delete(`open`),t.replaceState(t.state,``,`${n.pathname}${n.search}${n.hash}`)}function OK(e){let t=`#${wK}=`,n=e.hash.startsWith(t)?e.hash.slice(t.length):void 0,r=n!==void 0&&TK.test(n)?n:void 0;return{systemBrowser:new URLSearchParams(e.search).get(`lk_jump_to_browser`)===`true`||r!==void 0,...r===void 0?{}:{handoffToken:r},shouldClearFragment:n!==void 0}}function kK(e,t){t.replaceState(t.state,``,`${e.pathname}${e.search}`)}function AK(e){if(!TK.test(e.handoffToken))throw TypeError(`Feishu browser handoff token is invalid`);let t=new URL(tn(e.relayProjectRef),e.origin);return t.searchParams.set(`lk_jump_to_browser`,`true`),t.searchParams.set(`view`,`artifacts`),t.hash=`${wK}=${e.handoffToken}`,t.toString()}function jK(e,t=(e,t)=>window.open(e,t)){if(new URL(e).searchParams.get(`lk_jump_to_browser`)!==`true`)throw TypeError(`Feishu system-browser URL is missing the browser jump parameter`);let n=t(e,`_blank`);return n===null?!1:(n.opener=null,!0)}var MK=2e4;function NK(e,t){return e?.previewGeneration===t?e:{previewGeneration:t,annotations:[]}}function PK(e,t){return e!==null&&e.previewGeneration!==t}var FK=(0,I.createContext)(null);function IK(e){let t=e.intervalMs??MK,n=e.setIntervalFn??window.setInterval.bind(window),r=e.clearIntervalFn??window.clearInterval.bind(window),i=!0,a=!1,o=!1,s=()=>{!i||a||(a=!0,e.renew().then(()=>{i&&!o&&(o=!0,e.onInitialRenewed?.())}).catch(()=>void 0).finally(()=>{a=!1}))};s();let c=n(s,t);return()=>{i=!1,r(c)}}function LK({relayProjectRef:e,hostClient:t,enabled:n,feedbackEnabled:r,children:i}){let[a,o]=(0,I.useState)(null),[s,c]=(0,I.useState)(null),l=(0,I.useRef)(0),u=R({queryKey:Z.artifacts(e),queryFn:()=>t.getArtifacts(),enabled:n,staleTime:MV}),d=u.data?.artifact,f=d?.status===`declared`;(0,I.useEffect)(()=>{if(!(!n||!f))return IK({renew:()=>t.renewArtifactPreviewLease(),onInitialRenewed:()=>{u.refetch()}})},[u.refetch,f,n,t]);let p=d!==void 0,m=d?.status===`declared`?d.preview_generation:void 0,h=(0,I.useCallback)(e=>{o(t=>NK(t,e))},[]),g=(0,I.useCallback)(e=>{o(t=>{if(t===null||t.annotations.length>=64)return t;let{createdAt:n,...r}=e;return l.current+=1,{...t,annotations:[...t.annotations,{...r,createdAt:n,key:`artifact-feedback-note-${l.current}`}]}})},[]),_=(0,I.useCallback)(e=>{o(t=>t===null?null:{...t,annotations:t.annotations.filter((t,n)=>n!==e)})},[]),v=(0,I.useCallback)(()=>o(null),[]),y=(0,I.useCallback)(e=>c(e),[]),b=(0,I.useCallback)(()=>c(null),[]),x=(0,I.useMemo)(()=>({artifact:d,sidebarSignal:Bz(d),loading:!p&&n&&u.isLoading,unavailable:!p&&n&&u.error!==null,feedbackEnabled:r,feedbackDraft:a,feedbackDraftStale:PK(a,m),beginFeedbackDraft:h,addFeedbackAnnotation:g,removeFeedbackAnnotation:_,clearFeedbackDraft:v,pendingActivation:s,requestFeedbackActivation:y,clearFeedbackActivation:b}),[g,d,u.error,u.isLoading,h,b,v,m,n,a,r,p,s,_,y]);return(0,L.jsx)(FK.Provider,{value:x,children:i})}function RK(){let e=(0,I.useContext)(FK);if(e===null)throw Error(`Workspace Artifact runtime is unavailable`);return e}function zK({relayProjectRef:e}){return(0,I.useEffect)(()=>{window.location.replace(tn(e))},[e]),null}async function BK(e,t,n,r=!1){let i;try{await Db(jV,e,{signal:t,diagnostics:n});return}catch(e){if(!Yt(e))throw new iz(`session_current`,e,n);i=e}if(r)throw new iz(`browser_session_restore`,i,n);let a;try{a=await Tb(jV,e,{signal:t,diagnostics:n})}catch(e){throw new iz(`authorization_bootstrap`,e,n)}let o;try{o=await nz({appId:a.app_id,state:a.state})}catch(e){throw new iz(`h5_request_access`,e,n)}try{await Eb(jV,{relayProjectRef:e,state:a.state,authorizationCode:o},{signal:t,diagnostics:n})}catch(e){throw new iz(`authorization_exchange`,e,n)}}async function VK(e,t,n){try{await jb(jV,{relayProjectRef:e,handoffToken:t},{diagnostics:n})}catch(t){try{await Db(jV,e,{diagnostics:n});return}catch{throw new iz(`browser_handoff_consume`,t,n)}}}async function HK(e,t,n){try{return await n()}catch(n){throw new iz(e,n,t)}}function UK({relayProjectRef:e,diagnostics:t,browserEntry:n}){let r=(0,I.useMemo)(()=>wb(jV,e),[e]),[i,a]=(0,I.useState)({kind:`loading`}),o=(0,I.useRef)(null),s=(0,I.useRef)(!1),c=(0,I.useRef)(!1);(0,I.useEffect)(()=>{let r=new AbortController;return a({kind:`loading`}),(n.handoffToken!==void 0&&!s.current?(o.current??=VK(e,n.handoffToken,t),o.current.then(()=>{s.current=!0})):BK(e,r.signal,t,!0)).then(()=>{r.signal.aborted||a({kind:`ready`})}).catch(e=>{r.signal.aborted||a({kind:`error`,...gz(e,t)})}),()=>r.abort()},[n.handoffToken,t,e]);let l=i.kind===`ready`,u=R({queryKey:nK.artifacts(e),queryFn:({signal:e})=>HK(`artifacts`,t,()=>r.getArtifacts({signal:e,diagnostics:t})),enabled:l}),d=u.data?.artifact,f=d?.status===`declared`;(0,I.useEffect)(()=>{if(!(!l||!f))return IK({renew:()=>r.renewArtifactPreviewLease({diagnostics:t}),onInitialRenewed:()=>{u.refetch()}})},[f,u.refetch,r,t,l]);let p=d?.status===`declared`&&d.preview.status===`ready`&&d.preview.url!==void 0?`${d.preview_generation}:${d.preview.url}`:null,m=R({queryKey:nK.artifactPreviewSession(e,p??`not-ready`),queryFn:()=>HK(`artifact_preview_session`,t,()=>r.issueArtifactPreviewSession(void 0,void 0,{diagnostics:t})),enabled:l&&p!==null,staleTime:1/0,retry:1,refetchInterval:e=>SK(e.state.data)}),h=m.data,g=m.error===null?xK(h):`${$(m.error)} Diagnostic ID: ${t.diagnosticId}`,_=CK(h);return(0,I.useEffect)(()=>{_===void 0||c.current||(c.current=!0,window.location.replace(_))},[_]),i.kind===`error`||u.error!==null||m.error!==null||g!==void 0||u.isFetched&&p===null?(0,L.jsx)(`main`,{role:`status`,children:`Artifact preview is unavailable.`}):null}function WK({relayProjectRef:e,diagnostics:t,onDiagnosticsChange:n,initialTab:r,authorizeDocument:i,openArtifactInBrowser:a}){let o=(0,I.useMemo)(()=>wb(jV,e),[e]),s=et(),c=Dz(),[l,u]=(0,I.useState)({kind:`loading`}),[d,f]=(0,I.useState)(r),[p,m]=(0,I.useState)(),[h,g]=(0,I.useState)(``),[_,v]=(0,I.useState)(!1),[y,b]=(0,I.useState)(),[x,S]=(0,I.useState)(),[C,w]=(0,I.useState)(a),[T,E]=(0,I.useState)(!1),D=(0,I.useRef)(!1),[O,k]=(0,I.useState)(),[A,j]=(0,I.useState)(0),ee=(0,I.useRef)(null),M=(0,I.useRef)(null),te=(0,I.useRef)(0),N=(0,I.useRef)(t),P=(0,I.useRef)(!1),F=(t,n)=>BK(e,t,n);(0,I.useEffect)(()=>{let e=new AbortController;u({kind:`loading`}),b(void 0);let t=N.current;return F(e.signal,t).then(()=>{e.signal.aborted||u({kind:`ready`})}).catch(n=>{e.signal.aborted||u({kind:`error`,...gz(n,t)})}),()=>e.abort()},[e]),(0,I.useEffect)(()=>()=>{ee.current?.abort()},[]);let ne=l.kind===`ready`;(0,I.useEffect)(()=>{if(!ne||!i||P.current)return;P.current=!0;let t=N.current,n=c.notify({tone:`loading`,title:`Authorizing Feishu Docs`});$G(e,t).then(()=>{let e=new URL(window.location.href);e.searchParams.delete(`authorize`),window.history.replaceState(null,``,`${e.pathname}${e.search}${e.hash}`),c.update(n,{tone:`success`,title:`Feishu Docs authorized`,message:`Document access is ready. Retry the question or task that needed access.`})}).catch(e=>{let r=gz(e,t);c.update(n,{tone:`error`,title:`Feishu Docs authorization failed`,message:`${r.message} Diagnostic ID: ${r.diagnosticId}`})})},[i,c,e,ne]);let re=R({queryKey:nK.bootstrap(e),queryFn:({signal:e})=>HK(`host_bootstrap`,N.current,()=>o.getBootstrap({signal:e,diagnostics:N.current})),enabled:ne}),ie=re.data?.workspace.capabilities.sse===!0;(0,I.useEffect)(()=>{!ne||!ie||re.data===void 0||k(t=>t?.relayProjectRef===e?t:{relayProjectRef:e,cursor:re.data.event_cursor})},[re.data,ie,e,ne]),(0,I.useEffect)(()=>{if(!ne||!ie||O?.relayProjectRef!==e)return;let t;try{t=o.connectEvents({after:O.cursor,onReady:t=>{t.payload.replay.status===`missed`&&rK(s,e)},onInvalidate:t=>{iK(s,e,t)}})}catch{M.current=null;return}return M.current=t,()=>{M.current===t&&(M.current=null),t.close()}},[o,O,A,ie,s,e,ne]),(0,I.useEffect)(()=>{let t=()=>{let t=Date.now(),n=M.current;aK({streamStatus:n?.status(),nowMs:t,lastRefreshAtMs:te.current})&&(te.current=t,rK(s,e),n===null?j(e=>e+1):n.retryNow())},n=()=>{document.visibilityState!==`hidden`&&t()};return window.addEventListener(`focus`,t),window.addEventListener(`online`,t),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`focus`,t),window.removeEventListener(`online`,t),document.removeEventListener(`visibilitychange`,n)}},[s,e]);let ae=R({queryKey:nK.scratchpad(e),queryFn:({signal:e})=>HK(`scratchpad`,N.current,()=>o.getScratchpad({signal:e,diagnostics:N.current})),enabled:ne}),oe=R({queryKey:nK.worklist(e),queryFn:({signal:e})=>HK(`worklist`,N.current,()=>o.getWorklist({signal:e,diagnostics:N.current})),enabled:ne}),se=R({queryKey:nK.executionStatus(e),queryFn:({signal:e})=>HK(`execution_status`,N.current,()=>o.getExecutionStatus({signal:e,diagnostics:N.current})),enabled:ne}),ce=R({queryKey:nK.artifacts(e),queryFn:({signal:e})=>HK(`artifacts`,N.current,()=>o.getArtifacts({signal:e,diagnostics:N.current})),enabled:ne,refetchInterval:C&&d===`artifacts`?1500:!1}),le=R({queryKey:nK.activeClarification(e),queryFn:({signal:e})=>HK(`clarification_active`,N.current,()=>o.getActiveClarification({signal:e,diagnostics:N.current})),enabled:ne}),ue=R({queryKey:nK.activeApproval(e),queryFn:({signal:e})=>HK(`approval_active`,N.current,()=>o.getActiveApproval({signal:e,diagnostics:N.current})),enabled:ne}),de=le.data??re.data?.snapshots.active_clarification??{state:`none`},fe=de.state===`active`?de.round.id:void 0,pe=R({queryKey:nK.clarificationMessages(e,fe??`none`),queryFn:({signal:e})=>HK(`clarification_messages`,N.current,()=>o.getClarificationRoundMessages(fe,{signal:e,diagnostics:N.current})),enabled:ne&&fe!==void 0}),me=ue.data??re.data?.snapshots.active_approval??{state:`none`},he=ce.data?.artifact,ge=he?.status===`declared`;(0,I.useEffect)(()=>{if(!(!ne||!ge))return IK({renew:()=>o.renewArtifactPreviewLease({diagnostics:N.current}),onInitialRenewed:()=>{ce.refetch()}})},[ge,ce.refetch,o,ne]);let _e=he?.status===`declared`&&he.preview.status===`ready`&&he.preview.url!==void 0?`${he.preview_generation}:${he.preview.url}`:null,ve=R({queryKey:nK.artifactPreviewSession(e,_e??`not-ready`),queryFn:()=>HK(`artifact_preview_session`,N.current,()=>o.issueArtifactPreviewSession(void 0,void 0,{diagnostics:N.current})),enabled:ne&&d===`artifacts`&&_e!==null,staleTime:1/0,retry:1,refetchInterval:e=>SK(e.state.data)}),ye=ve.data,be=ve.error===null?xK(ye):`${$(ve.error)} Diagnostic ID: ${N.current.diagnosticId}`,xe=CK(ye),Se=gt({mutationFn:()=>hz(`browser_handoff_create`,async t=>{let n=await Ab(jV,e,{diagnostics:t});return AK({origin:window.location.origin,relayProjectRef:e,handoffToken:n.handoff_token})}),onSuccess:e=>{jK(e)?S(void 0):(S(e),c.notify({tone:`warning`,title:`Browser handoff ready`,message:`Click Open in browser again to continue in your system browser.`}))},onError:e=>{c.notify({tone:`error`,title:`Browser handoff failed`,message:mz(e,N.current)})}}),Ce=(0,I.useCallback)(()=>{D.current=!0,w(!1)},[]),we=(0,I.useCallback)(()=>{if(Ce(),!Se.isPending){if(_e===null){c.notify({tone:`warning`,title:`Artifact preview is not ready`,message:`Open it after the current Artifact preview becomes available.`});return}S(void 0),Se.mutate()}},[Ce,Se.isPending,Se.mutate,_e,c]);(0,I.useEffect)(()=>{if(!C||!ne)return;let e=window.setTimeout(()=>E(!0),2e4);return()=>window.clearTimeout(e)},[C,ne]),(0,I.useEffect)(()=>{if(!(!C||D.current)){if(d!==`artifacts`||l.kind===`error`){Ce();return}if(ne){if(ce.isError||T){Ce(),c.notify({tone:`warning`,title:`Artifact browser entry unavailable`,message:ce.isError?mz(ce.error,N.current):`Preview preparation timed out. Use Open in browser when it is ready. Diagnostic ID: ${N.current.diagnosticId}`});return}!ce.isFetchedAfterMount||ce.isFetching||(_e!==null||he!==void 0&&(he.status!==`declared`||he.preview.status===`failed`))&&we()}}},[d,he,ce.error,ce.isError,ce.isFetchedAfterMount,ce.isFetching,C,T,Ce,c,_e,we,ne,l.kind]),(0,I.useEffect)(()=>{g(``)},[fe]);let Te=gK({requestStatusSupported:re.data?.workspace.capabilities.request_status_v1===!0,client:o,relayProjectRef:e,diagnostics:N.current,scratchpad:ae.data??HV(),execution:se.data??KV(new Date().toISOString()),clarification:de,approval:me}),Ee=gt({mutationFn:({roundId:e,body:t})=>hz(`clarification_message_send`,n=>o.sendClarificationRoundMessage(e,{body:t},void 0,{diagnostics:n})),onSuccess:t=>{if(iK(s,e,t.invalidates),t.disposition.kind===`created`){g(``);return}c.notify({tone:`warning`,title:`Reply not sent`,message:`The clarification changed. Review the current request and try again.`})},onError:e=>{c.notify({tone:`error`,title:`Reply send failed`,message:mz(e,N.current)})}}),De=gt({mutationFn:e=>hz(`clarification_submit`,t=>o.submitClarificationRound(e,de.state===`active`&&de.round.answer_revision!==void 0?{expected_answer_revision:de.round.answer_revision}:{},void 0,{diagnostics:t})),onMutate:()=>c.notify({tone:`loading`,title:`Submitting reply`}),onSuccess:(t,n,r)=>{iK(s,e,t.invalidates);let i=t.disposition.kind===`accepted`,a=t.disposition.kind===`already_submitted`;c.update(r,{tone:i?`success`:a?`info`:`warning`,title:i?`Reply submitted`:a?`Reply already submitted`:`Reply not submitted`,...i||a?{}:{message:t.disposition.kind===`no_answers`?`Add an answer before submitting.`:`The clarification or its answers changed. Review the current request and submit again.`}})},onError:(e,t,n)=>{c.update(n,{tone:`error`,title:`Reply submit failed`,message:mz(e,N.current)})}}),Oe=gt({mutationFn:({approvalId:e,decisionId:t})=>hz(`approval_decide`,n=>o.decideApproval(e,{decision_id:t},void 0,{diagnostics:n})),onMutate:()=>c.notify({tone:`loading`,title:`Sending decision`}),onSuccess:(t,n,r)=>{iK(s,e,t.invalidates);let i=t.disposition.kind===`accepted`;c.update(r,{tone:i?`success`:`warning`,title:i?`Decision sent`:`Decision not applied`,...i?{}:{message:`The approval changed. Review its current state.`}})},onError:(e,t,n)=>{c.update(n,{tone:`error`,title:`Decision failed`,message:mz(e,N.current)})}}),ke=oe.data;(0,I.useEffect)(()=>{if(ke===void 0)return;let e=fB(ke);m(t=>t!==void 0&&e.some(e=>e.id===t)?t:void 0)},[ke]);let Ae=R({queryKey:nK.taskDetail(e,p??`none`),queryFn:({signal:e})=>HK(`task_detail`,N.current,()=>o.getTaskDetail(p,{signal:e,diagnostics:N.current})),enabled:ne&&p!==void 0}),je=R({queryKey:nK.taskRunResults(e,p??`none`),queryFn:({signal:e})=>HK(`task_run_results`,N.current,()=>o.getTaskRunResults(p,{limit:5},{signal:e,diagnostics:N.current})),enabled:ne&&p!==void 0}),Me=re.data!==void 0&&ae.data!==void 0&&oe.data!==void 0&&se.data!==void 0&&le.data!==void 0&&ue.data!==void 0&&(fe===void 0||pe.data!==void 0),Ne=()=>{if(_)return;ee.current?.abort();let t=new AbortController;ee.current=t;let r=oz();N.current=r,n(r),v(!0),b(void 0),(async()=>{try{if(await F(t.signal,r),t.signal.aborted)return;u({kind:`ready`});let n=ce.refetch({throwOnError:!0});await Promise.all([s.invalidateQueries({queryKey:nK.supporting(e)}),re.refetch({throwOnError:!0}),ae.refetch({throwOnError:!0}),oe.refetch({throwOnError:!0}),se.refetch({throwOnError:!0}),n,le.refetch({throwOnError:!0}),ue.refetch({throwOnError:!0}),...fe===void 0?[]:[pe.refetch({throwOnError:!0})],...p===void 0?[]:[Ae.refetch({throwOnError:!0}),je.refetch({throwOnError:!0})]]);let i=(await n).data?.artifact,a=i?.status===`declared`&&i.preview.status===`ready`&&i.preview.url!==void 0?`${i.preview_generation}:${i.preview.url}`:null;d===`artifacts`&&_e!==null&&a===_e&&await ve.refetch({throwOnError:!0})}catch(e){if(t.signal.aborted)return;let n=gz(e,r);Me?b(n):u({kind:`error`,...n})}finally{t.signal.aborted||(ee.current=null,v(!1))}})()},Pe=e=>{m(e),f(`work`)},Fe=re.data?.workspace.project.display_name??null,Ie;if(re.data===void 0||ae.data===void 0||oe.data===void 0||se.data===void 0||le.data===void 0||ue.data===void 0||fe!==void 0&&pe.data===void 0){let e=re.error??ae.error??oe.error??se.error??le.error??ue.error??pe.error;Ie=l.kind===`error`?l:e===null?{kind:`loading`}:{kind:`error`,...gz(e,t)}}else{let e=re.data,t=ae.data,n=oe.data,r=se.data,i=y??(l.kind===`error`?l:void 0),a=dB(n,p),o=SB(Ae.data,je.data,{includeRetryAction:!1}),s=p===void 0?void 0:Ae.error!==null||je.error!==null?{title:`Task details unavailable`,description:`Refresh this project and try again.`}:o===void 0?{title:`Loading task details`,description:`Reading the latest task contract and Run results.`}:void 0,c=r.active_activity?.activity_kind===`run`||r.active_activities?.some(e=>e.activity_kind===`run`)===!0,u=zz(he,{...xe===void 0?{}:{previewUrl:xe},pending:_e!==null&&xe===void 0&&be===void 0,...be===void 0?{}:{errorMessage:be}},{runActive:c}),f=he===void 0&&ce.error!==null?`${$(ce.error)} Diagnostic ID: ${N.current.diagnosticId}`:void 0;Ie={kind:`ready`,projectName:e.workspace.project.display_name,accountName:e.session.account.display_name,membershipLabel:e.session.membership.label,hostVersion:e.workspace.server.version,activeTab:d,refreshing:_,...i===void 0?{}:{refreshMessage:i},projectStatus:Iz(r),scratchpad:uB(t,[],Te.note),activeClarification:Jz(de),clarificationMessages:(pe.data?.items??[]).map(e=>qz(e)),roundDraft:h,activeApproval:Qz(me),worklist:{modules:a.modules,taskCount:a.taskCount,detailOpen:p!==void 0,...o===void 0?{}:{detail:o},...s===void 0?{}:{detailPlaceholder:s}},artifacts:u,...f===void 0?{}:{artifactError:f}}}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:{kind:`feishu_project`,relayProjectRef:e},projectDisplayName:Fe}),(0,L.jsx)(GH,{state:Ie,supportingContent:d===`timeline`?(0,L.jsx)(cK,{client:o,relayProjectRef:e,onSelectTask:Pe},d):void 0,onRetry:Ne,onBrandClick:()=>window.location.reload(),onSelectTab:e=>{S(void 0),m(void 0),f(e)},onSelectTask:Pe,onCloseTask:()=>m(void 0),onOpenInBrowser:we,...x===void 0?{}:{browserOpenUrl:x,onBrowserOpenLinkClick:()=>S(void 0)},onSubmitScratchpad:Te.submit,onRoundDraftChange:g,onSendRoundMessage:()=>{fe!==void 0&&h.trim()!==``&&Ee.mutate({roundId:fe,body:h.trim()})},onSubmitRound:()=>{fe!==void 0&&De.mutate(fe)},onDecideApproval:(e,t)=>Oe.mutate({approvalId:e,decisionId:t}),scratchpadSubmitPending:Te.submitPending,scratchpadSyncPending:Te.syncPending,scratchpadActionsDisabled:Te.actionsDisabled,roundSendPending:Ee.isPending,roundSubmitPending:De.isPending,approvalDecisionPending:Oe.isPending,browserOpenPending:Se.isPending})]})}var GK=class extends I.Component{state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(){}render(){return this.state.error===void 0?this.props.children:this.props.artifactPresentation===!0?(0,L.jsx)(`main`,{role:`status`,children:`Artifact preview is unavailable.`}):(0,L.jsx)(GH,{state:{kind:`error`,...gz(new iz(`browser_runtime`,this.state.error,this.props.diagnostics),this.props.diagnostics)},onRetry:()=>window.location.reload(),onBrandClick:()=>window.location.reload(),onSelectTab:()=>void 0,onSelectTask:()=>void 0})}};function KK(e){let t=new URLSearchParams(e).getAll(`view`);return t.length===1&&(t[0]===`work`||t[0]===`artifacts`||t[0]===`timeline`)?t[0]:`project`}function qK(e){let t=new URLSearchParams(e).getAll(`authorize`);return t.length===1&&t[0]===`docx`}function JK({relayProjectRef:e}){let[t,n]=(0,I.useState)(oz),r=(0,I.useMemo)(()=>OK(window.location),[]),i=(0,I.useMemo)(()=>KK(window.location.search),[]),a=(0,I.useMemo)(()=>vK(window.location.search),[]),o=(0,I.useMemo)(()=>qK(window.location.search),[]),s=(0,I.useMemo)(()=>EK(window.location.search),[]);return(0,I.useEffect)(()=>{r.shouldClearFragment&&kK(window.location,window.history),s&&DK(window.location,window.history)},[r.shouldClearFragment,s]),(0,L.jsx)(GK,{diagnostics:t,artifactPresentation:r.systemBrowser,children:r.systemBrowser?(0,L.jsx)(UK,{browserEntry:r,diagnostics:t,relayProjectRef:e}):a===void 0?(0,L.jsx)(WK,{diagnostics:t,initialTab:i,authorizeDocument:o,openArtifactInBrowser:s,relayProjectRef:e,onDiagnosticsChange:n},e):(0,L.jsx)(yK,{project:e,authorizationRef:a,prepareSession:BK})})}function YK(){Q(`/projects`,{replace:!0})}function XK(){let e=R({queryKey:Z.me,queryFn:()=>Kn(jV)}),t=fH(YK);return(0,I.useEffect)(()=>{e.data!==void 0&&YK()},[e.data]),e.isLoading||e.data!==void 0?null:(0,L.jsx)(iU,{...t,onBrandClick:()=>Q(`/`),sessionError:e.error===null||Yt(e.error)?null:`Tutti could not check your current session. You can still try signing in.`})}var ZK=`/account/local-console`,QK=/^[A-Za-z0-9_-]{32,128}$/u;function $K(e){return QK.test(e)}function eq(e){if(!/^[1-9]\d{0,4}$/u.test(e))return null;let t=Number(e);return Number.isInteger(t)&&t<=65535?t:null}function tq(e){if(!$K(e.accessToken))throw Error(`Local Console account continuation token is invalid.`);let t=new URL(e.localOrigin),n=eq(t.port);if(t.protocol!==`http:`||t.hostname!==`127.0.0.1`||n===null)throw Error(`Local Console account continuation requires an exact loopback origin.`);let r=new URL(ZK,e.webBaseUrl);return r.search=``,r.hash=new URLSearchParams({access_token:e.accessToken,local_port:String(n),...e.intent===`sign_out`?{intent:`sign_out`}:{}}).toString(),r.toString()}function nq(e){let t=e.startsWith(`#`)?e.slice(1):e,n=new URLSearchParams(t),r=n.getAll(`intent`),i=r.length===0?`authenticate`:r[0];if(n.size!==2&&n.size!==3||n.getAll(`access_token`).length!==1||n.getAll(`local_port`).length!==1||r.length>1||n.size===3&&r.length!==1||n.size===2&&r.length!==0||i!==`authenticate`&&i!==`sign_out`)return null;let a=n.get(`access_token`)??``,o=eq(n.get(`local_port`)??``);return!$K(a)||o===null?null:{accessToken:a,localPort:o,intent:i}}function rq(e,t){let n=t.trim();if(n===``||n.length>80)throw Error(`Local Console account display name is invalid.`);let r=new URL(`http://127.0.0.1:${e.localPort}/console`);return r.hash=new URLSearchParams({access_token:e.accessToken,account_display_name:n}).toString(),r.toString()}function iq(e){let t=e.startsWith(`#`)?e.slice(1):e,n=new URLSearchParams(t);if(n.size!==1&&n.size!==2||n.getAll(`access_token`).length!==1||n.getAll(`account_display_name`).length>1||n.size===2&&n.getAll(`account_display_name`).length!==1)return null;let r=n.get(`access_token`)??``,i=n.get(`account_display_name`)?.trim();return!$K(r)||i!==void 0&&(i===``||i.length>80)?null:{accessToken:r,...i===void 0?{}:{accountDisplayName:i}}}function aq(e){let t=e.trim().replace(/[\\/]+$/u,``);return t===``?``:t.slice(Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`))+1).slice(0,80)}function oq(e){return e.surface===`feishu`&&e.existingProjectId===void 0?{display_name:aq(e.workspacePath)||`Untitled project`}:{display_name:e.displayName.trim(),...e.description.trim()?{description:e.description.trim()}:{}}}function sq(e=``){return{workspacePath:e,displayName:aq(e),description:``,baseUrl:``,apiKey:``,model:``,surface:`standalone`,accessMode:`managed`}}function cq(e,t,n){return{...e,workspacePath:t,...n?{}:{displayName:aq(t)}}}function lq(e){switch(e){case`console_busy`:return`Wait for the current Local Console action to finish.`;case`host_busy`:return`Wait for active project work or questions to finish.`;case`host_identity_unverified`:return`Stop or reopen the affected project before updating.`;case`update_in_progress`:return`Another Tutti update is already in progress.`;case`update_recovery_required`:return`Run tutti again after closing this page to recover the interrupted update.`;case`global_prefix_read_only`:return`Use your normal terminal installation environment to update Tutti.`;case`npm_install_failed`:return`The npm installation failed. Refresh to check whether it can be retried.`;case`post_install_validation_failed`:return`The installed package could not be verified. Run tutti again to recover.`;case`completion_start_failed`:case`completion_failed`:case`worker_crashed`:return`The update was interrupted. Run tutti again to recover.`;case`host_restore_failed`:return`Tutti updated, but one or more local projects could not restart.`;case`installation_not_global`:case`custom_home`:case`npm_unavailable`:case`npm_global_root_mismatch`:case`npm_version_unsupported`:case`registry_unavailable`:case void 0:return`Tutti cannot update from this Local Console.`}}function uq(e){if(e.status!==`updating`)return e.status===`blocked`||e.status===`failed`?lq(e.reason_code):void 0;switch(e.phase){case`stopping_hosts`:return`Safely stopping online projects.`;case`installing`:return`Installing the new Tutti version.`;case`restarting`:return`Restarting local projects.`;case`preparing`:case void 0:return`Preparing the update.`}}function dq(e){let t=e.update;if(t===null||t.status===`up_to_date`||t.latest_version===void 0&&t.status!==`updating`&&t.status!==`failed`)return;let n=e.checking&&t.status===`ready`?`Checking update readiness.`:uq(t);return{label:t.status===`updating`?`Updating…`:`Restart and Update`,disabled:t.status!==`ready`||!t.can_update||e.checking||e.starting,...n===void 0?{}:{description:n}}}function fq(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length===0?t:n}function pq({inviterName:e,projectName:t,joinUrl:n}){return`${fq(e,`A teammate`)} invited you to join the Tutti project “${fq(t,`Untitled project`)}”.\n\nOpen the invitation link:\n${n.trim()}`}function mq(e){return new Gt({code:e,statusCode:409,message:e,retryable:!1})}async function hq(e){let{client:t,prepared:n,signal:r}=e,i=n.draft.request_ref,a=t=>{if(r.throwIfAborted(),t.draft.request_ref!==i||t.draft.project_id!==n.draft.project_id||t.draft.surface!==n.draft.surface||t.relay_origin!==n.relay_origin||t.preparation.installation_ref!==n.preparation.installation_ref)throw mq(`managed_preparation_mismatch`);return e.onRead(t),t};e.onStage(`checking`);let o=a(await t.reconcileManagedProject(i,AbortSignal.any([r,AbortSignal.timeout(15e3)])));if(o.draft.state===`awaiting_authorization`)throw mq(`authority_target_not_found`);if(o.draft.state===`validation_unknown`||o.draft.state===`validation_failed`||(o.draft.state===`prepared`&&(e.onStage(`validating`),o=a(await t.validateManagedProject(i,AbortSignal.any([r,AbortSignal.timeout(9e4)])))),o.draft.state!==`validated`&&o.draft.state!==`registered`))throw mq(`managed_${o.draft.state}`);r.throwIfAborted(),e.onStage(`launching`);let s=await t.launchManagedProject(i,AbortSignal.any([r,AbortSignal.timeout(12e4)]));return r.throwIfAborted(),s}var gq=sq();function _q(e,t){let n={projectId:e.project_id,projectName:e.display_name};return t.state===`connected`?{...n,state:`connected`}:t.state===`account_handoff_required`?{...n,state:`account_handoff_required`}:t.visibility===`visible_once`?{...n,state:`pairing_required`,command:t.command}:{...n,state:`not_recoverable`}}function vq(){return AV}function yq(){window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}`)}function bq(){let e=window.open(`about:blank`,`_blank`);return e!==null&&(e.opener=null),e}function xq({connection:e,renderSurface:t,initialCreateOpen:n=!1}={}){let r=Sq(e,n);return(0,L.jsx)(nU,{...r,...t?{renderSurface:e=>t(r,e)}:{}})}function Sq(e,t=!1){let n=Dz(),r=(0,I.useRef)(void 0),i=(0,I.useRef)(void 0),a=(0,I.useRef)(!1),o=(0,I.useRef)(!1),s=(0,I.useRef)(null),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(`Checking credit…`),f=(0,I.useRef)(MG(window.location.hash)),[p,m]=(0,I.useState)(null),h=(0,I.useRef)(null),g=(0,I.useRef)(!1),_=(0,I.useRef)(0),v=(0,I.useRef)(null),y=(0,I.useRef)(!1),b=(0,I.useMemo)(()=>e?.client??sb({baseUrl:window.location.origin,csrfToken:()=>r.current,contextToken:()=>i.current}),[e?.client]),[x,S]=(0,I.useState)(null),[C,w]=(0,I.useState)(null),[T,E]=(0,I.useState)(gq),D=(0,I.useRef)(!1),O=(0,I.useRef)({baseUrl:``,apiKey:``}),[k,A]=(0,I.useState)([]),[j,ee]=(0,I.useState)(t),[M,te]=(0,I.useState)(`surface`),[N,P]=(0,I.useState)([]),[F,ne]=(0,I.useState)(!0),re=(0,I.useRef)(!1),[ie,ae]=(0,I.useState)(!1),[oe,se]=(0,I.useState)(!1),[ce,le]=(0,I.useState)(null),[ue,de]=(0,I.useState)(null),[fe,pe]=(0,I.useState)(!1),[me,he]=(0,I.useState)(!1),[ge,_e]=(0,I.useState)(!1),[ve,ye]=(0,I.useState)(null);async function be(){if(!(r.current===void 0||re.current)){re.current=!0,ne(!0);try{P((await b.getProjects()).projects)}catch(t){if(e?.signal.aborted)return;n.notify({tone:`error`,title:`Projects unavailable`,message:$(t)})}finally{re.current=!1,ne(!1)}}}async function xe(e={}){h.current?.abort();let t=new AbortController;h.current=t,pe(!0);try{de(await b.getPackageUpdate({refresh:e.refresh===!0,signal:t.signal}))}catch{}finally{h.current===t&&(h.current=null,pe(!1))}}(0,I.useEffect)(()=>{a.current||(a.current=!0,(async()=>{try{let t=e?null:iq(window.location.hash);if(t!==null){yq();let e=await b.exchangeSession(t.accessToken,t.accountDisplayName);r.current=e.csrf_token,i.current=e.context_token}let a=e?.bootstrap??await b.getBootstrap();if(r.current=a.csrf_token,a.account_gate?.status===`required`){let e=await b.createAccountContinuation();window.location.replace(tq({accessToken:e.access_token,localOrigin:window.location.origin,webBaseUrl:vq()}));return}if(S(a),w(null),await Promise.all([be(),xe()]),f.current!==null)try{let e=await b.readManagedProject(f.current);FG(e),m(e),E({...sq(e.draft.workspace_path),displayName:e.draft.display_name,description:e.draft.description??``,surface:e.draft.surface,...e.draft.existing_project_id===void 0?{}:{existingProjectId:e.draft.existing_project_id}}),ee(!0),te(`provider`)}catch(e){n.notify({tone:`warning`,title:`Trial request could not be restored`,message:IG(e)})}}catch(e){ne(!1),w($(e))}})())},[b]),(0,I.useEffect)(()=>()=>{h.current?.abort(),s.current?.abort()},[]),(0,I.useEffect)(()=>{if(d(`Checking credit…`),!j||M!==`provider`||p!==null||x===null)return;let e=new AbortController;return b.readAccountUsage(e.signal).then(t=>{e.signal.aborted||d(t.state===`ready`?`${t.remaining.toLocaleString(`en`)} test credit remaining`:`No test credit account yet`)}).catch(()=>{e.signal.aborted||d(`Credit unavailable · Check Account`)}),()=>e.abort()},[b,j,M,p,x]),(0,I.useEffect)(()=>{if(x===null||e)return;let t=window.setInterval(()=>{b.heartbeat().catch(()=>void 0)},6e4);return()=>window.clearInterval(t)},[x,b,e]),(0,I.useEffect)(()=>{if(!e||!x)return;let t=()=>{document.visibilityState!==`hidden`&&be()},n=window.setInterval(t,3e4);return window.addEventListener(`focus`,t),()=>{window.clearInterval(n),window.removeEventListener(`focus`,t)}},[e,x,b]),(0,I.useEffect)(()=>{if(x===null||ue?.latest_version===void 0||ue.status===`up_to_date`||ue.status===`failed`)return;let e=window.setInterval(()=>void xe(),ue.status===`updating`?2e3:15e3);return()=>window.clearInterval(e)},[x,ue?.latest_version,ue?.status]),(0,I.useEffect)(()=>{let e=x?.package_update_completion;e===void 0||y.current||(y.current=!0,n.notify(e.restart_failure_count===0?{tone:`success`,title:`Tutti updated to ${e.target_version}`}:{tone:`warning`,title:`Tutti updated to ${e.target_version}`,message:`${e.restart_failure_count} local project${e.restart_failure_count===1?``:`s`} could not restart.`}))},[x,n]),(0,I.useEffect)(()=>{if(ue?.status!==`failed`)return;let e=ue.reason_code??`update_failed`;v.current!==e&&(v.current=e,n.notify({tone:`error`,title:`Tutti update did not complete`,message:lq(ue.reason_code)}))},[n,ue]);async function Se(){try{let e=await b.pickFolder();e.kind===`selected`?Ie({workspacePath:e.path}):e.kind===`unavailable`&&n.notify({tone:`info`,title:`Use a folder path`,message:e.message})}catch(e){n.notify({tone:`error`,title:`Folder picker unavailable`,message:$(e)})}}async function Ce(){let e={baseUrl:T.baseUrl.trim(),apiKey:T.apiKey.trim()},t=()=>O.current.baseUrl.trim()===e.baseUrl&&O.current.apiKey.trim()===e.apiKey;ae(!0);try{let r=await b.discoverModels({base_url:e.baseUrl,api_key:e.apiKey});if(!t())return;r.kind===`ok`?(A(r.models),E(e=>({...e,model:``}))):(A([]),n.notify({tone:`error`,title:`Provider check failed`,message:r.reason===`model_list_empty`?`The endpoint did not return any available models.`:`Check the Base URL and API key, then try again.`}))}catch(e){if(!t())return;A([]),n.notify({tone:`error`,title:`Provider check failed`,message:$(e)})}finally{ae(!1)}}async function we(){if(!o.current){o.current=!0,se(!0);try{let e=await b.launchProject({workspace_path:T.workspacePath.trim(),surface:T.surface,project:oq(T),provider:{base_url:T.baseUrl.trim(),api_key:T.apiKey.trim(),model:T.model.trim()}});Le(),e.join_url===void 0?(await be(),Oe(e.project,e.feishu_setup)):window.location.assign(e.join_url)}catch(e){n.notify({tone:`error`,title:`Launch failed`,message:$(e)})}finally{o.current=!1,se(!1)}}}async function Te(){if(o.current)return;o.current=!0;let t=new AbortController;s.current=t,se(!0);let r=null;try{let n=await b.prepareManagedProject({request_ref:p?.draft.request_ref??Vt(),workspace_path:T.workspacePath.trim(),...oq(T),surface:T.surface,...T.existingProjectId===void 0?{}:{existing_project_id:T.existingProjectId}},t.signal);t.signal.throwIfAborted(),FG(n),m(n),E(e=>({...e,displayName:n.draft.display_name,description:n.draft.description??``})),r=n,window.history.replaceState(null,``,`${e?window.location.pathname+window.location.search:`/console`}#managed_request=${n.draft.request_ref}`)}catch(e){if(t.signal.aborted)return;n.notify({tone:`error`,title:`Trial preparation failed`,message:IG(e)})}finally{o.current=!1,se(!1),s.current===t&&(s.current=null)}r!==null&&!t.signal.aborted&&Ee(r)}async function Ee(e=p){if(o.current||s.current||e===null)return;let t=new AbortController;s.current=t;try{e.draft.state===`awaiting_authorization`&&(o.current=!0,se(!0),l(`checking`),await b.authorizeManagedProject(e.draft.request_ref,t.signal),t.signal.throwIfAborted());let n=await hq({client:b,prepared:e,signal:t.signal,onRead:m,onStage:e=>{l(e),o.current=!0,se(!0)}});Le(),n.join_url===void 0?(await be(),Oe(n.project,n.feishu_setup)):window.location.assign(n.join_url)}catch(e){t.signal.aborted||n.notify({tone:`error`,title:`Managed launch paused`,message:IG(e)})}finally{s.current===t&&(s.current=null,o.current=!1,se(!1),l(null))}}async function De(e){le(e.project_id);try{let t=await b.launchProject({workspace_path:e.workspace_path});await be(),e.surface_profile.kind===`feishu`?Oe(t.project,t.feishu_setup):n.notify({tone:`success`,title:`${e.display_name} is ready`})}catch(e){let t=e instanceof Gt&&e.code===`provider_configuration_required`;n.notify({tone:t?`warning`:`error`,title:t?`Provider required`:`Launch failed`,message:t?`Use New project with this folder to update its Provider configuration.`:$(e)})}finally{le(null)}}function Oe(e,t){let n=++_.current;if(t!==void 0){ye(_q(e,t));return}ye({projectId:e.project_id,projectName:e.display_name,state:`loading`}),b.getFeishuSetup(e.project_id).then(t=>{_.current===n&&ye(_q(e,t))}).catch(t=>{_.current===n&&ye({projectId:e.project_id,projectName:e.display_name,state:`unavailable`,unavailableMessage:$(t)})})}function ke(e){e||(_.current+=1,ye(null))}async function Ae(e){try{await navigator.clipboard.writeText(e),n.notify({tone:`success`,title:`Connection command copied`})}catch{n.notify({tone:`error`,title:`Could not copy connection command`})}}async function je(e){le(e.project_id);try{let t=await b.refreshInvite(e.project_id);await navigator.clipboard.writeText(pq({inviterName:``,projectName:e.display_name,joinUrl:t.join_url})),n.notify({tone:`success`,title:`Invitation copied`})}catch(e){n.notify({tone:`error`,title:`Invite unavailable`,message:$(e)})}finally{le(null)}}async function Me(e){if(e.open_url===void 0)return;let t=bq();le(e.project_id);try{let r=await b.openProject(e.project_id);P(e=>e.map(e=>e.project_id===r.project.project_id?r.project:e)),t===null?window.location.assign(r.handoff.url):t.location.replace(r.handoff.url),r.host_update===`updated`?n.notify({tone:`success`,title:`${e.display_name} updated`}):r.host_update===`deferred_busy`?n.notify({tone:`info`,title:`Opened without updating`,message:`Try Open again after the current project activity finishes.`}):r.host_update===`deferred_unsupported`?n.notify({tone:`info`,title:`Opened with the current Host`,message:`Stop and Resume this project once to enable safe automatic updates.`}):r.host_update===`deferred_unavailable`&&n.notify({tone:`warning`,title:`Update deferred`,message:`The current Host could not be safely restarted, so the project opened as-is.`})}catch(e){t?.close(),n.notify({tone:`error`,title:`Open failed`,message:$(e)})}finally{le(null)}}async function Ne(e){le(e.project_id);try{await b.stopProject(e.project_id),ve?.projectId===e.project_id&&ke(!1),await Promise.all([be(),xe()]),n.notify({tone:`success`,title:`${e.display_name} stopped`})}catch(e){n.notify({tone:`error`,title:`Stop failed`,message:$(e)})}finally{le(null)}}async function Pe(){if(!(g.current||ue?.status!==`ready`||!ue.can_update)){g.current=!0,he(!0);try{de(await b.startPackageUpdate())}catch(e){e instanceof Gt&&e.statusCode===0?de({...ue,status:`updating`,can_update:!1,phase:`preparing`}):(n.notify({tone:`error`,title:`Update not started`,message:$(e)}),await xe())}finally{g.current=!1,he(!1)}}}async function Fe(){if(!ge){_e(!0);try{let e=await b.createAccountContinuation();window.location.replace(tq({accessToken:e.access_token,localOrigin:window.location.origin,webBaseUrl:vq(),intent:`sign_out`}))}catch(e){_e(!1),n.notify({tone:`error`,title:`Sign out failed`,message:$(e)})}}}function Ie(e){if(o.current||s.current)return;p!==null&&(m(null),yq()),e.displayName!==void 0&&(D.current=!0);let t=e.baseUrl!==void 0&&e.baseUrl!==T.baseUrl||e.apiKey!==void 0&&e.apiKey!==T.apiKey;t&&(A([]),O.current={baseUrl:e.baseUrl??T.baseUrl,apiKey:e.apiKey??T.apiKey}),E(n=>({...e.workspacePath===void 0?n:cq(n,e.workspacePath,D.current),...e,...t?{model:``}:{}}))}function Le(){s.current?.abort(),s.current=null,o.current=!1,se(!1),l(null),m(null),yq(),ee(!1),te(`surface`),A([]),O.current={baseUrl:``,apiKey:``},D.current=!1,E(sq())}function Re(e){if(!e){!ie&&!oe&&Le();return}let t=x?.invocation.source===`terminal`?x.invocation.current_directory:``;D.current=!1,O.current={baseUrl:``,apiKey:``},A([]),E(sq(t)),te(`surface`),ee(!0)}function ze(e){o.current||ce!==null||(m(null),yq(),E({...sq(e.workspace_path),displayName:e.display_name,surface:e.surface_profile.kind,existingProjectId:e.project_id}),te(`provider`),ee(!0))}function Be(e){if(e.preventDefault(),o.current||s.current||ie)return;if(p!==null){Ee();return}if(!YH(M,T))return;let t=JH(T),n=t[t.indexOf(M)+1];if(n!==void 0){te(n);return}T.accessMode===`managed`?Te():we()}function Ve(){p!==null||o.current||s.current||ie||te(e=>{let t=JH(T);return t[Math.max(0,t.indexOf(e)-1)]})}let He=dq({update:ue,checking:fe,starting:me});return{...x===null?{}:{version:x.version},accountName:x?.account_gate?.status===`ready`?x.account_gate.account?.display_name??`Signed in`:`Signed in`,projectCenterHref:new URL(`/projects`,AV).toString(),form:T,managedPrepared:p!==null,creditNote:u,onDiscoverModels:()=>void Ce(),models:k,projects:N,projectsLoading:F,sessionLoading:x===null&&C===null,sessionError:C,createOpen:j,createStep:M,modelDiscoveryPending:ie,launchPending:oe,managedStage:c,projectActionPending:ce,signOutPending:ge,feishuConnection:ve,...He===void 0?{}:{packageUpdateAction:He},onChange:Ie,onCreateOpenChange:Re,onCreateSubmit:Be,onCreateBack:Ve,onChooseFolder:()=>void Se(),onRefresh:()=>void Promise.all([be(),xe({refresh:!0})]),onLaunchExisting:e=>void De(e),onAuthorizeExisting:ze,onOpenProject:e=>void Me(e),onCopyInvite:e=>void je(e),onConnectFeishu:e=>Oe(e),onFeishuConnectionOpenChange:ke,onCopyFeishuCommand:e=>void Ae(e),onStopProject:e=>void Ne(e),onPackageUpdate:()=>void Pe(),onSignOut:()=>void Fe()}}function Cq(){return(0,I.useEffect)(()=>Q(`/projects`,{replace:!0}),[]),null}function wq({continuation:e}){let t=Dz(),n=et(),r=(0,I.useRef)(!1),[i,a]=(0,I.useState)(e.intent!==`sign_out`),o=(0,I.useCallback)(async n=>{if(!r.current){r.current=!0;try{await Yn(jV,e.accessToken,!0),window.location.replace(rq(e,n))}catch{t.notify({tone:`error`,title:`Local Console sign-in failed`,message:`Tutti could not create the private account handoff. Please try again.`}),Q(`/projects`,{replace:!0})}}},[e,t]),s=R({queryKey:Z.me,queryFn:()=>Kn(jV),enabled:i}),c=fH(),l=pH();if((0,I.useEffect)(()=>{if(e.intent!==`sign_out`)return;let r=!1;return Qn(jV).then(()=>{r||(n.removeQueries({queryKey:Z.me}),a(!0))}).catch(()=>{r||(t.notify({tone:`error`,title:`Sign out failed`}),Q(`/projects`,{replace:!0}))}),()=>{r=!0}},[e.intent,t,n]),(0,I.useEffect)(()=>{let e=s.data?.account;e?.profile_complete===!0&&o(e.display_name)},[s.data?.account,o]),!i||s.isLoading||s.data?.account.profile_complete===!0)return null;let u=s.data?.account.profile_complete===!1?l:c,d=s.error===null||Yt(s.error)?null:`Tutti could not check your current session. You can still try signing in.`;return(0,L.jsx)(FH,{...u,error:u.error??d,onBrandClick:()=>Q(`/`)})}function Tq(){let e=nq(window.location.hash);return e===null?(0,L.jsx)(Cq,{}):(0,L.jsx)(wq,{continuation:e})}function Eq(e){let t=t=>{let n=new Map;for(let r of e)n.set(r[t],[...n.get(r[t])??[],r]);return[...n.entries()].map(([e,t])=>({ref:e,entries:t,representative:t.find(e=>e.state===`active`)??t[0],active:t.some(e=>e.state===`active`),revocationPending:t.some(e=>e.downstream_keys===`pending`),revoked:t.every(e=>e.downstream_keys===`confirmed`)}))};return{projects:t(`grant_ref`),computers:t(`installation_ref`)}}function Dq({group:e}){return e.active?(0,L.jsx)(`small`,{children:e.revocationPending?`Enabled · previous access is still being disabled`:`Enabled`}):(0,L.jsx)(`small`,{children:e.revoked?`Disabled`:`Disabling…`})}function Oq(e){let t=t=>(0,L.jsx)(ok,{title:`Authorized ${kz(t.representative.created_at)}`,action:t.active?(0,L.jsx)(Y,{type:`button`,disabled:e.pending,onClick:()=>e.onSelect({kind:`grant`,ref:t.ref,label:t.representative.project_name}),children:`Disable Tutti credit`}):void 0,children:(0,L.jsx)(Dq,{group:t})},t.ref),n=e.groups.filter(e=>e.active),r=e.groups.filter(e=>!e.active);return(0,L.jsxs)(zk,{title:`Tutti credit`,children:[e.groups.length===0?(0,L.jsx)(`p`,{children:`No Tutti credit access is recorded for your account.`}):null,n.map(t),n.length===0&&r.length>0?(0,L.jsx)(`small`,{children:r.some(e=>!e.revoked)?`Disabling…`:`Disabled`}):null,r.length>0?(0,L.jsx)(Rk,{title:`Previous authorizations`,children:r.map(t)}):null]})}function kq(e){let t=Eq(e.overview.delegations);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(zk,{title:`Computers`,children:t.computers.length===0?(0,L.jsx)(`p`,{children:`No authorized computers.`}):t.computers.map(t=>(0,L.jsx)(ok,{title:`Computer …${t.ref.slice(-8)}`,description:`${new Set(t.entries.map(e=>e.relay_project_ref)).size} project(s)`,action:t.active?(0,L.jsx)(Y,{type:`button`,disabled:e.pending,onClick:()=>e.onSelect({kind:`installation`,ref:t.ref,label:`computer`}),children:`Disable Tutti credit`}):void 0,children:(0,L.jsx)(Dq,{group:t})},t.ref))}),(0,L.jsx)(zk,{title:`Browsers`,children:e.overview.sessions.map(t=>(0,L.jsx)(ok,{title:t.current?`This browser`:`Other browser`,description:`Signed in ${kz(t.created_at)}`,action:t.current?void 0:(0,L.jsx)(Y,{type:`button`,disabled:e.pending,onClick:()=>e.onSelect({kind:`session`,ref:t.session_ref,label:`browser`}),children:`Sign out`})},t.session_ref))})]})}function Aq(e){let t=e.confirmation,n=t?.kind===`session`?`Sign out this browser?`:t?.kind===`installation`?`Disable this computer’s Tutti credit?`:`Disable Tutti credit for this project?`,r=t?.kind===`session`?`Projects running on your computers will continue.`:t?.kind===`installation`?`Stops new model access for your projects on this computer. Files stay intact; requests already running may finish.`:`Stops new model access for “${t?.label??`this project`}”. Files and membership stay intact; requests already running may finish.`;return(0,L.jsx)(Nk,{className:`product-account-dialog`,open:e.panel!==null,onOpenChange:n=>{n||(t?e.onSelectRevoke(null):e.onClose())},title:t?n:e.panel===`credits`?`Credits`:e.panel===`account`?`Account`:e.project?.displayName??`Project details`,description:t?r:e.panel===`project`&&e.project?.surface===`feishu`?`Use this project in its Feishu group.`:void 0,closeDisabled:e.pending||e.logoutPending,headerAction:t?void 0:(0,L.jsx)(Sw,{type:`button`,label:`Refresh account`,icon:(0,L.jsx)(zx,{"aria-hidden":`true`}),disabled:e.loading||e.pending,onClick:e.onRefresh}),children:(0,L.jsx)(rk,{children:t?(0,L.jsxs)(Lk,{children:[(0,L.jsx)(Y,{type:`button`,disabled:e.pending,onClick:()=>e.onSelectRevoke(null),children:`Cancel`}),(0,L.jsx)(Cw,{type:`button`,disabled:e.pending,onClick:e.onConfirmRevoke,children:e.pending?`Updating…`:t.kind===`session`?`Sign out browser`:`Confirm disable`})]}):(0,L.jsxs)(L.Fragment,{children:[e.panel===`credits`?(0,L.jsxs)(L.Fragment,{children:[e.usageError?(0,L.jsx)(Iw,{children:e.usageError}):e.usage?.state===`ready`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ak,{items:[{label:`Available test credit`,value:e.usage.remaining.toLocaleString(`en`)}]}),(0,L.jsx)(Rk,{title:`Usage details`,children:(0,L.jsx)(ik,{items:[{label:`Used · all time`,value:e.usage.used.toLocaleString(`en`)},{label:`Requests · all time`,value:e.usage.request_count.toLocaleString(`en`)}]})})]}):e.usage?.state===`not_initialized`?(0,L.jsx)(aS,{children:`No Tutti credit yet.`}):(0,L.jsx)(oS,{}),(0,L.jsx)(`small`,{children:`Test credit only. Payments are not enabled.`})]}):null,e.panel===`project`?(0,L.jsxs)(L.Fragment,{children:[e.project?(0,L.jsx)(ik,{items:[{label:`Surface`,value:e.project.surface===`feishu`?`Feishu`:`Tutti Workspace`},{label:`Your role`,value:e.project.membershipLabel},{label:`Host`,value:e.project.hostStatus===`online`?`Online`:e.project.hostStatus===`offline`?`Offline`:`Unknown`}]}):(0,L.jsx)(aS,{children:`Project unavailable.`}),e.overviewError?(0,L.jsx)(Iw,{children:e.overviewError}):e.overview?e.project?(0,L.jsx)(Oq,{groups:Eq(e.overview.delegations.filter(t=>t.relay_project_ref===e.project?.relayProjectRef)).projects,pending:e.pending,onSelect:e.onSelectRevoke}):null:(0,L.jsx)(oS,{})]}):null,e.panel===`account`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ik,{items:[{label:`Name`,value:e.accountName},{label:`Email`,value:e.email}]}),(0,L.jsx)(Rk,{title:`Security`,children:e.overviewError?(0,L.jsx)(Iw,{children:e.overviewError}):e.overview?(0,L.jsx)(kq,{overview:e.overview,pending:e.pending,onSelect:e.onSelectRevoke}):(0,L.jsx)(oS,{})}),(0,L.jsxs)(zk,{title:`Sign out`,children:[(0,L.jsx)(`small`,{children:`Signing out won’t stop your projects.`}),(0,L.jsx)(Y,{type:`button`,disabled:e.logoutPending||e.pending,onClick:e.onSignOut,children:`Sign out`})]})]}):null,e.panel!==`credits`&&e.overview?.truncated?(0,L.jsx)(`small`,{children:`Only recent access records are shown. Contact support for older records.`}):null]})})})}var jq={overview:[`account-managed-access`],usage:[`account-managed-usage`]},Mq={baseUrl:jV.relayBaseUrl,credentials:`include`};function Nq(e,t){let n=et(),r=Dz(),i=R({queryKey:[...jq.overview,e],enabled:e!==null&&t,queryFn:({signal:e})=>cb(Mq,e),refetchOnWindowFocus:!0,refetchInterval:e=>e.state.data?.delegations.some(e=>e.downstream_keys===`pending`)?5e3:!1}),a=R({queryKey:[...jq.usage,e],enabled:e!==null,queryFn:({signal:e})=>lb(Mq,e),refetchOnWindowFocus:!0,staleTime:3e4}),[o,s]=(0,I.useState)(null),c=o?.account===e?o.target:null,[l,u]=(0,I.useState)(!1),d=(0,I.useRef)(!1),f=(0,I.useRef)({target:``,id:Vt()});async function p(){if(d.current||!c||!e)return;d.current=!0,u(!0);let t=`${e}/${c.kind}/${c.ref}`;f.current.target!==t&&(f.current={target:t,id:Vt()});try{c.kind===`session`?await db(Mq,c.ref):await ub(Mq,{command_id:f.current.id,target:{kind:c.kind,ref:c.ref}}),s(null),await n.invalidateQueries({queryKey:[...jq.overview,e]}),r.notify({tone:`success`,title:c.kind===`session`?`Browser signed out`:`Disabling Tutti credit`})}catch(e){r.notify({tone:`error`,title:`Change not confirmed`,message:IG(e)})}finally{d.current=!1,u(!1)}}return{overview:i.error===null?i.data:void 0,usage:a.error===null?a.data:void 0,overviewError:i.error===null?null:IG(i.error),usageError:a.error===null?null:IG(a.error),loading:i.isFetching||a.isFetching,pending:l,confirmation:c,selectRevoke:t=>s(t?{account:e,target:t}:null),confirmRevoke:()=>void p(),refresh:()=>{a.refetch(),t&&i.refetch()}}}var Pq=/^[A-Za-z0-9_-]{8,256}$/u,Fq=/https?:\/\/[^\s<>"'`“”‘’]+/giu,Iq=/(?:^|[\s("'“‘])((?:\/)?join\/[A-Za-z0-9_-]{8,256})(?=$|[\s?#.,;:!'"”’)\]}])/giu,Lq=/[.,;:!?)}\]]+$/u;function Rq(e){let t;try{t=decodeURIComponent(e)}catch{return null}return Pq.test(t)?t:null}function zq(e){let t=e.split(`/`).filter(Boolean);return t.length!==2||t[0]!==`join`?null:Rq(t[1]??``)}function Bq(e,t){let n=zq(t);n!==null&&e.add(`/join/${encodeURIComponent(n)}`)}function Vq(e,t){try{Bq(e,new URL(t.replace(Lq,``)).pathname)}catch{}}function Hq(e){let t=e.trim();if(t===``)return{kind:`empty`};let n=new Set;for(let e of t.matchAll(Fq))Vq(n,e[0]);for(let e of t.matchAll(Iq)){let t=e[1];if(t!==void 0)try{Bq(n,new URL(t,`https://tutti.invalid`).pathname)}catch{}}let r=Rq(t);return r!==null&&n.add(`/join/${encodeURIComponent(r)}`),n.size===0?{kind:`invalid`}:n.size>1?{kind:`ambiguous`}:{kind:`matched`,route:[...n][0]}}function Uq(e){return Jt(e,`project_membership_required`)?{tone:`warning`,title:`Join this project first`,message:`This account has not joined the project. Open its invitation link, or return to Local Console and copy a new invite.`}:{tone:`error`,title:`Project open failed`,message:$(e)}}var Wq=`tutti://projects`,Gq=3e4,Kq=/^[A-Za-z0-9_-]+$/u,qq=/^[A-Za-z0-9_-]{43}$/u,Jq=class extends Error{reason;constructor(e){super(`Tutti could not complete the desktop entry continuation.`),this.name=`DesktopEntryContinuationError`,this.reason=e}};function Yq(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/u,``)}function Xq(e,t){if(!Kq.test(e))throw new Jq(`invalid`);let n=`=`.repeat((4-e.length%4)%4),r;try{r=atob(e.replaceAll(`-`,`+`).replaceAll(`_`,`/`)+n)}catch{throw new Jq(`invalid`)}let i=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)i[e]=r.charCodeAt(e);if(t!==void 0&&i.length!==t||Yq(i)!==e)throw new Jq(`invalid`);return i}function Zq(e){return typeof e==`string`&&Rt(e,Pt.relayDesktopEntryContinuation)}function Qq(e){return typeof e==`string`&&e.length===43&&Kq.test(e)}function $q(e=globalThis.crypto){let t=new Uint8Array(32);e.getRandomValues(t);let n=Yq(t);if(n.length!==43)throw new Jq(`invalid`);return n}function eJ(e){if(!Zq(e.continuationRef)||!Qq(e.completionToken)||e.payloadKey.length!==43)throw new Jq(`invalid`);return Xq(e.payloadKey,32),`${Wq}?${new URLSearchParams({continuation:e.continuationRef,completion_token:e.completionToken,payload_key:e.payloadKey}).toString()}`}function tJ(e,t={}){let n=Date.parse(e.expires_at);if(!Number.isFinite(n)||n<=(t.nowMs??Date.now())||!Zq(e.continuation_ref))throw new Jq(`invalid`);let r=$q(t.cryptoImpl);return{continuationRef:e.continuation_ref,payloadKey:r,href:eJ({continuationRef:e.continuation_ref,completionToken:e.completion_token,payloadKey:r}),expiresAtMs:n}}function nJ(e){if(typeof e!=`object`||!e)throw new Jq(`invalid`);let t=e,n=t.iv,r=t.ciphertext;if(typeof n!=`string`||typeof r!=`string`||n.length!==16||r.length<24||r.length>4096)throw new Jq(`invalid`);return{iv:Xq(n,12),ciphertext:Xq(r)}}function rJ(e){let t;try{t=new URL(e)}catch{throw new Jq(`invalid`)}let n=t.port,r=Number(n);if(t.protocol!==`http:`||t.hostname!==`127.0.0.1`||!/^[1-9]\d{0,4}$/u.test(n)||!Number.isInteger(r)||r>65535||t.pathname!==`/console`||t.search!==``||t.username!==``||t.password!==``||t.hash===``)throw new Jq(`invalid`);let i=t.hash.slice(1),a=new URLSearchParams(i),o=a.get(`access_token`)??``;if(a.size!==1||a.getAll(`access_token`).length!==1||!qq.test(o)||i!==new URLSearchParams({access_token:o}).toString())throw new Jq(`invalid`);return t.toString()}async function iJ(e,t,n=globalThis.crypto){let r=Xq(t,32),i=nJ(e);try{let e=await n.subtle.importKey(`raw`,r,`AES-GCM`,!1,[`decrypt`]),t=await n.subtle.decrypt({name:`AES-GCM`,iv:i.iv},e,i.ciphertext);return rJ(new TextDecoder(`utf-8`,{fatal:!0}).decode(t))}catch(e){throw e instanceof Jq?e:new Jq(`invalid`)}}function aJ(e){let t=typeof e==`string`?Date.parse(e):NaN;if(!Number.isFinite(t))throw new Jq(`invalid`);return t}function oJ(e,t){return new Promise((n,r)=>{if(t.aborted){r(new Jq(`aborted`));return}let i=()=>{globalThis.clearTimeout(a),r(new Jq(`aborted`))},a=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e);t.addEventListener(`abort`,i,{once:!0})})}async function sJ(e){let t=e.nowMs??Date.now,n=e.wait??oJ,r=t()+(e.timeoutMs??2e4);for(;!e.signal.aborted&&t()<r;){let i;try{i=await e.read(e.prepared.continuationRef,e.signal)}catch(i){if(e.signal.aborted)throw new Jq(`aborted`);if(i instanceof Gt&&!i.retryable)throw new Jq(`unavailable`);let a=r-t();if(a<=0)break;await n(Math.min(e.pollIntervalMs??500,a),e.signal);continue}if(typeof i!=`object`||!i)throw new Jq(`invalid`);let a=i;if(!Zq(a.continuation_ref)||a.continuation_ref!==e.prepared.continuationRef)throw new Jq(`invalid`);let o=aJ(a.expires_at);if(o<=t())throw new Jq(`expired`);if(a.status===`ready`)return iJ(a.sealed_payload,e.prepared.payloadKey,e.cryptoImpl);if(a.status!==`pending`)throw new Jq(`invalid`);let s=Math.min(r,o)-t();if(s<=0)break;await n(Math.min(e.pollIntervalMs??500,s),e.signal)}throw e.signal.aborted?new Jq(`aborted`):new Jq(`timeout`)}function cJ(e,t){let[n,r]=(0,I.useState)(0),[i,a]=(0,I.useState)(null),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(`opening`),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=(0,I.useRef)(0),p=(0,I.useRef)(!1),m=(0,I.useCallback)(e=>{u.current=e,a(e)},[]);(0,I.useEffect)(()=>{d.current?.abort(),d.current=null,f.current+=1,p.current=!1,m(null),s(!1),l(`opening`)},[e,m]),(0,I.useEffect)(()=>{if(e===null)return;let t=u.current?.continuationRef??null,n=null,r=!1,i=window.setTimeout(()=>{n=new AbortController,qn(jV,{signal:n.signal}).then(t=>{r||m({accountRef:e,...tJ(t)})}).catch(()=>{!r&&t!==null&&u.current?.continuationRef===t&&m(null)})},0);return()=>{r=!0,window.clearTimeout(i),n?.abort()}},[e,n,m]),(0,I.useEffect)(()=>{if(i===null||i.accountRef!==e)return;let t=i.expiresAtMs-Date.now(),n=t>3e4?t-Gq:Math.max(1e3,Math.floor(t/2)),a=window.setTimeout(()=>{u.current?.continuationRef===i.continuationRef&&(m(null),r(e=>e+1))},Math.max(0,n));return()=>window.clearTimeout(a)},[e,i,m]),(0,I.useEffect)(()=>()=>{d.current?.abort()},[]);let h=(0,I.useCallback)(()=>{s(!0),l(`opening`),d.current?.abort();let n=u.current;if(n===null||n.accountRef!==e||n.expiresAtMs<=Date.now()){r(e=>e+1);return}r(e=>e+1);let i=new AbortController;d.current=i;let a=f.current+1;f.current=a,sJ({prepared:n,read:(e,t)=>Jn(jV,e,{signal:t}),signal:i.signal}).then(async e=>{if(!(f.current!==a||i.signal.aborted||p.current)){p.current=!0;try{t?(await t(e,i.signal),i.signal.aborted||s(!1),p.current=!1):window.location.replace(e)}catch(e){throw p.current=!1,e}}}).catch(e=>{f.current!==a||i.signal.aborted||e instanceof Jq&&e.reason===`aborted`||l(`failed`)}).finally(()=>{d.current===i&&(d.current=null)})},[e,m,t]),g=(0,I.useCallback)(e=>{s(e),e||(d.current?.abort(),d.current=null,f.current+=1,l(`opening`))},[]),_=(i!==null&&i.accountRef===e?i:null)?.href??`tutti://projects`;return{localScopeHref:_,localHandoffOpen:o,localHandoffStatus:c,localHandoffRetryHref:_,onLocalHandoffOpenChange:g,onLocalScopeSelect:h}}function lJ(e){let t=(0,I.useRef)(null),[n,r]=(0,I.useState)(null),i=n?.accountRef===e?.account_ref?n?.connection??null:null,[a,o]=(0,I.useState)(`disconnected`),[s,c]=(0,I.useState)(null),l=(0,I.useCallback)(()=>{t.current?.dispose(),t.current=null,r(null),o(`disconnected`),c(null)},[]);(0,I.useEffect)(()=>(l(),l),[e?.account_ref,l]);let u=(0,I.useCallback)(async(n,i)=>{if(e){l();try{let a=await Nb({accessUrl:n,accountDisplayName:e.display_name,signal:i,registerAccount:e=>Yn(jV,e,!0),onLost:()=>{l(),o(`lost`)}});if(i.aborted){a.dispose();return}t.current=a,r({accountRef:e.account_ref,connection:a})}catch(e){throw i.aborted||(o(`lost`),e instanceof Gt&&c([/^[a-z0-9_]{1,80}$/u.test(e.code)?e.code:`bridge_connection_failed`,e.requestId].filter(Boolean).join(` · `))),e}}},[e?.account_ref,e?.display_name,l]);return(0,I.useEffect)(()=>{if(!i)return;let e=!1,t=()=>{e||document.visibilityState===`hidden`||(e=!0,i.client.heartbeat().catch(()=>{}).finally(()=>{e=!1}))},n=window.setInterval(t,1e4);return window.addEventListener(`focus`,t),()=>{window.clearInterval(n),window.removeEventListener(`focus`,t)}},[i]),{connection:i,state:a,diagnostic:s,disconnect:l,connect:u}}function uJ({requestedOpenProjectRef:e,initialPanel:t}){let n=et(),r=Dz(),i=fH(),a=pH(),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(!1),f=(0,I.useRef)(!1),[p,m]=(0,I.useState)(t??null),[h,g]=(0,I.useState)(null);(0,I.useEffect)(()=>{m(t??null)},[t]);let _=(0,I.useRef)(null),v=R({queryKey:Z.me,queryFn:()=>Kn(jV)}),y=R({queryKey:[...Z.accountProjects,v.data?.account.account_ref],queryFn:({signal:e})=>Mb({baseUrl:jV.relayBaseUrl,credentials:`include`},e),enabled:v.error===null&&v.data?.account.profile_complete===!0,refetchOnWindowFocus:!0}),b=v.error===null&&v.data?.account.profile_complete===!0?v.data.account:null,x=Nq(b?.account_ref??null,p===`account`||p===`project`),S=lJ(b);RV(b!==null);let C=gt({mutationFn:e=>tr(jV,e),onSuccess:e=>{if(IV(n),e.disposition.kind===`opened`&&e.result?.open_url!==void 0){PV(e.result.open_url);return}r.notify({tone:`warning`,title:`Host is offline`})},onError:e=>{let t=Uq(e);r.notify({...t})}}),w=C.mutate;(0,I.useEffect)(()=>{e===void 0||v.data?.account.profile_complete!==!0||_.current===e||(_.current=e,w(e))},[v.data?.account.profile_complete,w,e]);let T=gt({mutationFn:()=>(S.disconnect(),Qn(jV)),onSuccess:()=>{m(null),g(null),x.selectRevoke(null),n.removeQueries({queryKey:jq.overview}),n.removeQueries({queryKey:jq.usage}),n.removeQueries({queryKey:Z.accountProjects}),n.invalidateQueries({queryKey:Z.relayRoot}),n.invalidateQueries({queryKey:Z.me}),n.invalidateQueries({queryKey:Z.recentProjects})},onError:e=>{r.notify({tone:`error`,title:`Sign out failed`,message:$(e)})}}),E=b??void 0,D=cJ(E?.profile_complete===!0?E.account_ref:null,S.connect),O=v.error!==null&&Yt(v.error)?i:v.data?.account!==void 0&&!v.data.account.profile_complete?a:null;if(O!==null)return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:{kind:`home`}}),(0,L.jsx)(FH,{...O,onBrandClick:()=>Q(`/`)})]});let k=(y.error===null?y.data?.projects??[]:[]).map(Lz),A=()=>{let e=Hq(o);if(e.kind!==`matched`){l(e.kind===`ambiguous`?`Paste one Tutti invitation at a time.`:`Paste a valid Tutti invitation.`);return}Q(e.route)},j=e=>{d(e),e||(s(``),l(null))},ee=(e,t)=>(0,L.jsx)(sU,{...e?{local:e}:{},localDialogs:t,connectionState:S.state,connectionDiagnostic:S.diagnostic,onDisconnect:S.disconnect,relayOrigin:new URL(jV.relayBaseUrl,window.location.origin).origin,account:E===void 0?null:{displayName:E.display_name},projects:k,truncated:y.data?.truncated??!1,accountActions:E?(0,L.jsx)(sk,{name:E.display_name,credit:x.usage?.state===`ready`?`Credits · ${x.usage.remaining.toLocaleString(`en`)}`:x.usageError?`Credits unavailable`:`Credits`,disabled:x.pending||T.isPending,onCredit:()=>m(`credits`),onAccount:()=>m(`account`)}):void 0,onProjectDetails:e=>{g(e.relayProjectRef),m(`project`)},loading:v.isLoading||y.isLoading,error:v.error===null?y.error===null?null:$(y.error):$(v.error),openPending:C.isPending,logoutPending:T.isPending,joinLinkForm:{value:o,error:c,onChange:e=>{s(e),l(null)},onSubmit:A},joinOpen:u,localScopeHref:D.localScopeHref,localHandoffOpen:D.localHandoffOpen,localHandoffStatus:D.localHandoffStatus,localHandoffRetryHref:D.localHandoffRetryHref,onJoinOpenChange:j,onLocalHandoffOpenChange:D.onLocalHandoffOpenChange,onLocalScopeSelect:()=>{f.current=!1,D.onLocalScopeSelect()},onRequestNewProject:()=>{f.current=!0,D.onLocalScopeSelect()},onCopyLaunchCommand:e=>{navigator.clipboard.writeText(e).then(()=>{r.notify({tone:`success`,title:`Command copied`})}).catch(()=>{r.notify({tone:`error`,title:`Copy failed`,message:`The browser could not copy the launch command.`})})},onBrandClick:()=>Q(`/`),onOpenProject:e=>C.mutate(e),onLogout:()=>T.mutate()});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:{kind:`project_center`}}),S.connection?(0,L.jsx)(xq,{connection:S.connection,initialCreateOpen:f.current,renderSurface:ee}):ee(),E?(0,L.jsx)(Aq,{panel:p,project:k.find(e=>e.relayProjectRef===h),accountName:E.display_name,email:E.email,...x,logoutPending:T.isPending,onSelectRevoke:x.selectRevoke,onConfirmRevoke:x.confirmRevoke,onRefresh:()=>{x.refresh(),y.refetch()},onSignOut:()=>T.mutate(),onClose:()=>{m(null),x.selectRevoke(null),t&&Q(`/projects`,{replace:!0})}}):null]})}function dJ(e){let t=e?.relay;if(t?.join_url_visibility===`visible_once`&&t.join_url!==void 0&&t.join_url.trim()!==``)return t.join_url}function fJ(e,t){try{return new URL(e).origin===new URL(t,e).origin}catch{return!1}}function pJ(e,t){let n=dJ(e);if(n!==void 0)return{kind:`join`,joinUrl:n};let r=e?.relay?.relay_project_ref;return r===void 0?{kind:`unavailable`,message:`Relay project is unavailable`}:fJ(t.currentOrigin,t.relayBaseUrl)?{kind:`relay_open`,relayProjectRef:r}:{kind:`unavailable`,message:`Open the latest Join URL printed by tutti launch.`}}var mJ=`gpt-5.5`,hJ=`/host-local/v1`;function gJ(){return new URL(window.location.href).searchParams.get(`token`)?.trim()??``}function _J(e){return{baseUrl:hJ,credentials:`same-origin`,headers:{authorization:`Bearer ${e}`}}}function vJ(e){return z(_J(e),`/provider/config`)}function yJ(e){return z(_J(e),`/launch-status`)}function bJ(e){return z(_J(e),`/project`)}function xJ(e,t){return z(_J(e),`/project`,{method:`POST`,body:t})}function SJ(e,t){return z(_J(e),`/provider/config`,{method:`POST`,body:t})}function CJ(e){return e===void 0?`loading`:e.status===`configured`?`configured`:e.status===`invalid`?`invalid`:`not configured`}function wJ(e){let t=e instanceof Error&&`code`in e?String(e.code):``;return t.startsWith(`provider_`)?t:$(e)}function TJ(){let e=gJ(),t=e===``,[n,r]=(0,I.useState)({projectName:``,apiKey:``,baseUrl:``,defaultModel:mJ}),[i,a]=(0,I.useState)(null),[o,s]=(0,I.useState)(null),c=(0,I.useRef)(!1),l=R({queryKey:[`host-local`,`provider-config`,e],queryFn:()=>vJ(e),enabled:!t}),u=R({queryKey:[`host-local`,`launch-status`,e],queryFn:()=>yJ(e),enabled:!t}),d=R({queryKey:[`host-local`,`project`,e],queryFn:()=>bJ(e),enabled:!t}),f=u.data,p=gt({mutationFn:e=>tr(jV,e.relayProjectRef),onSuccess:e=>{if(e.disposition.kind===`opened`&&e.result?.open_url!==void 0){PV(e.result.open_url);return}s(`Host is offline`)},onError:e=>{s($(e))}}),m=gt({mutationFn:async()=>{let t=n.projectName.trim(),r=d.data?.display_name.trim()??``;t!==``&&t!==r&&await xJ(e,{display_name:t});let i={api_key:n.apiKey.trim()},a=n.baseUrl.trim(),o=n.defaultModel.trim();return a!==``&&(i.base_url=a),o!==``&&(i.default_model=o),await SJ(e,i)},onSuccess:()=>{a(`Provider saved.`),r(e=>({...e,apiKey:``})),d.refetch(),l.refetch(),v()}}),h=l.data;(0,I.useEffect)(()=>{let e=d.data?.display_name;e!==void 0&&r(t=>t.projectName.trim()===``?{...t,projectName:e}:t)},[d.data?.display_name]),(0,I.useEffect)(()=>{t||h?.status!==`configured`||v()},[h?.status,t]);let g=t?`Setup token is missing.`:d.error===null?l.error===null?m.error===null?o:wJ(m.error):wJ(l.error):wJ(d.error);function _(e){e.preventDefault(),a(null),s(null),c.current=!1,!t&&n.apiKey.trim()!==``&&n.projectName.trim()!==``&&m.mutate()}async function v(){if(c.current)return;c.current=!0;let e=pJ(f??(await u.refetch()).data,{currentOrigin:window.location.origin,relayBaseUrl:AV});if(e.kind===`join`){window.location.assign(e.joinUrl);return}if(e.kind===`unavailable`){s(e.message);return}p.mutate({relayProjectRef:e.relayProjectRef})}return(0,L.jsx)(lU,{form:n,statusLabel:CJ(h),configured:h?.status===`configured`,loading:l.isLoading||d.isLoading,pending:m.isPending,tokenMissing:t,error:g,success:i,openProjectPending:p.isPending,onChange:e=>r(t=>({...t,...e})),onSubmit:_,onRetry:()=>void l.refetch(),onBrandClick:()=>Q(`/`)})}function EJ(e){return`${e.created_at}:${e.id}`}function DJ(e){return{kind:`initial`,entry:e}}function OJ(e,t=50){if(e.kind===`older`)return{before:e.before,limit:t};if(e.kind===`newer`)return{after:e.after,limit:t};switch(e.entry.kind){case`latest`:return{limit:t};case`start`:return{anchor:`start`,limit:t};case`around`:return{around:e.entry.messageId,limit:t}}}function kJ(e){let t=e.window.older_cursor;return e.window.has_older&&t!==void 0?{kind:`older`,before:t}:void 0}function AJ(e){let t=e.window.newer_cursor;return e.window.has_newer&&t!==void 0?{kind:`newer`,after:t}:void 0}function jJ(e,t=50){let n=e[0],r=e.at(-1);if(n===void 0||r===void 0)return{items:[],window:{has_older:!1,has_newer:!1,limit:t}};let i=new Map;for(let t of e)for(let e of t.items)i.set(e.id,e);let a=[...i.values()].sort((e,t)=>EJ(e).localeCompare(EJ(t))),o={has_older:n.window.has_older,has_newer:r.window.has_newer,limit:n.window.limit};return o.has_older&&n.window.older_cursor!==void 0&&(o.older_cursor=n.window.older_cursor),o.has_newer&&r.window.newer_cursor!==void 0&&(o.newer_cursor=r.window.newer_cursor),{items:a,window:o}}function MJ(e){let t=et(),n=Dz(),r=gt({mutationFn:t=>e.hostClient.retryTask(t.taskId,{expected_latest_run_result_id:t.runResultId}),onMutate:()=>n.notify({tone:`loading`,title:`Retrying task`}),onSuccess:(r,i,a)=>{if(zV(t,e.relayProjectRef,r.invalidates),r.disposition.kind===`accepted`){n.update(a,{tone:`success`,title:`Task retry started`});return}if(r.disposition.kind===`already_running`||r.disposition.kind===`retry_already_started`){n.update(a,{tone:`info`,title:`Task retry already started`});return}n.update(a,{tone:`warning`,title:`Task retry unavailable`,message:r.disposition.kind===`latest_run_result_changed`?`The task result changed. Review the latest result before retrying.`:r.disposition.kind===`retry_requires_resolution`?`This failure needs to be resolved before it can be retried safely.`:`The task cannot be retried in its current state.`})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Task retry failed`,message:$(e)})}});return{retry:(e,t)=>r.mutate({taskId:e,runResultId:t}),stateFor:(e,t,n)=>r.isPending&&r.variables?.taskId===e&&r.variables.runResultId===t?`retrying`:n}}function NJ(e){let t=e.enabled?e.messages.filter(e=>e.author.kind===`human`&&e.message_kind===`user_text`).slice(-8).map(e=>e.id):[],n=mt({queries:t.map(t=>({queryKey:[...e.key,`chat-request`,t],queryFn:async({signal:n})=>{try{return await e.read(t,n)}catch(e){if(e instanceof Gt&&e.statusCode===404)return null;throw e}},retry:!1,refetchIntervalInBackground:!1,refetchInterval:e=>e.state.error?15e3:e.state.data?.status===`queued`||e.state.data?.status===`running`?1500:!1,structuralSharing:(e,t)=>{let n=e,r=t;return n&&r&&n.operation.ref===r.operation.ref&&n.revision>r.revision?n:t}}))});return Object.fromEntries(n.flatMap((e,n)=>{let r=PJ(e.data,e.isError||e.fetchStatus===`paused`);return r===void 0?[]:[[t[n],r]]}))}function PJ(e,t){if(e)return t&&(e.status===`running`||e.status===`queued`)?`Answer status reconnecting`:e.status===`queued`?`Answer queued`:e.status===`running`?e.phase===`workspace_wait`?`Waiting for workspace`:`Preparing answer`:e.status===`succeeded`?`Answered`:`Answer not completed · Diagnostic ID: ${e.failure.diagnostic_id}`}var FJ=5400,IJ=1500;function LJ(e){let t=e.completionSource;return t?.activityRef??t?.workflowRef??t?.taskId??e.key}function RJ(e){switch(e.kind){case`accepted`:case`already_running`:return null;case`scratchpad_empty`:return{label:`Scratchpad is empty. Let it refresh before running.`,tone:`error`};case`stale_scratchpad`:return{label:`Scratchpad changed. Review the latest snapshot and run again.`,tone:`error`};case`provider_not_configured`:return{label:`Provider is not configured yet.`,tone:`error`};case`provider_unavailable`:return{label:`Provider unavailable: ${e.reason}.`,tone:`error`};case`interrupted`:return{label:`Run was interrupted. Try again.`,tone:`error`}}}function zJ(e,t){t.displayName.trim()===``||e.has(t.key)||e.set(t.key,t)}function BJ(e){if(e.author.kind!==`human`)return null;let t=e.author.display_name?.trim()||`Member`;return{key:e.author.ref===void 0?`message-author:${t.toLocaleLowerCase()}`:e.author.ref,displayName:t,avatar:e.author.avatar??{kind:`initials`,initials:k_(t),color:`blue`}}}function VJ({account:e,presence:t,messages:n=[]}){let r=new Map;e!==void 0&&zJ(r,{key:e.account_ref,displayName:e.display_name,avatar:e.avatar});for(let e of t?.sample_members??[])zJ(r,{key:e.account_ref,displayName:e.display_name,avatar:e.avatar});for(let e of t?.members??[])zJ(r,{key:e.account_ref,displayName:e.display_name,avatar:e.avatar});for(let e of n){let t=BJ(e);t!==null&&zJ(r,t)}return[...r.values()]}function HJ({account:e,presence:t}){let n={},r=(e,t)=>{let r=n[e];n[e]={avatar:t.avatar,online:r?.online===!0||t.online}};for(let e of t?.members??[])r(e.account_ref,{avatar:e.avatar,online:e.online});for(let e of t?.sample_members??[])r(e.account_ref,{avatar:e.avatar,online:!0});return e!==void 0&&r(e.account_ref,{avatar:e.avatar,online:!0}),n}function UJ({relayProjectRef:e}){let t=et(),n=Dz(),r=RK(),i=(0,I.useMemo)(()=>ob({...jV,relayProjectRef:e}),[e]),a=MJ({hostClient:i,relayProjectRef:e}),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(()=>Date.now()),[v,y]=(0,I.useState)(null),b=new URL(NV(),window.location.origin).searchParams.get(`message`),x=b!==null&&Rt(b,Pt.message)?b:void 0,[S,C]=(0,I.useState)(()=>x===void 0?{kind:`latest`}:{kind:`around`,messageId:x}),w=(0,I.useRef)(null),T=(0,I.useRef)(null),E=(0,I.useRef)(null),[D,O]=(0,I.useState)(null),k=f!==null;(0,I.useEffect)(()=>{x!==void 0&&(S.kind!==`around`||S.messageId!==x)&&C({kind:`around`,messageId:x})},[S,x]);let A=(t=null)=>{C({kind:`latest`}),y(t),x!==void 0&&Q(en(e),{replace:!0})},j=R({queryKey:Z.bootstrap(e),queryFn:()=>i.getBootstrap(),staleTime:MV}),ee=j.data?.session.account.account_ref,M=ee===void 0?null:`${ee}:${e}`,te=x!==void 0||M!==null&&D===M;(0,I.useEffect)(()=>{M===null||D===M||(x===void 0&&ee!==void 0&&C(qG(ee,e).start_chat_pending?{kind:`start`}:{kind:`latest`}),O(M))},[ee,M,e,x,D]);let N=_t({queryKey:Z.messageHistory(e,S,50),queryFn:({pageParam:e})=>i.getMessages(OJ(e)),initialPageParam:DJ(S),getPreviousPageParam:e=>kJ(e),getNextPageParam:e=>AJ(e),enabled:j.isSuccess&&te,staleTime:MV}),P=R({queryKey:Z.scratchpad(e),queryFn:()=>i.getScratchpad(),enabled:j.isSuccess,staleTime:MV,refetchInterval:k?IJ:!1}),F=R({queryKey:Z.activeClarification(e),queryFn:()=>i.getActiveClarification(),enabled:j.isSuccess,staleTime:MV,refetchInterval:k?IJ:!1}),ne=R({queryKey:Z.activeApproval(e),queryFn:()=>i.getActiveApproval(),enabled:j.isSuccess,staleTime:MV}),re=R({queryKey:Z.executionStatus(e),queryFn:()=>i.getExecutionStatus(),enabled:j.isSuccess,staleTime:MV,refetchInterval:k?IJ:!1}),ie=R({queryKey:Z.readState(e),queryFn:()=>i.getReadState(),enabled:j.isSuccess,staleTime:MV}),ae=R({queryKey:Z.projectPresence(e),queryFn:()=>nr(jV,e),enabled:j.isSuccess,staleTime:MV,refetchInterval:6e4});RV(j.isSuccess);let oe=gt({mutationFn:e=>i.updateProjectDisplayName({display_name:e}),onMutate:e=>n.notify({tone:`loading`,title:`Saving project name`,message:e}),onSuccess:(r,i,a)=>{zV(t,e,r.invalidates??[{kind:`workspace`},{kind:`bootstrap`}]),n.update(a,{tone:`success`,title:`Project name saved`,message:i})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Project name save failed`,message:`${t}: ${$(e)}`})}}),se=gt({mutationFn:e=>i.updateProjectDescription({description:e}),onMutate:e=>n.notify({tone:`loading`,title:`Saving project description`,...e.length===0?{}:{message:e}}),onSuccess:(r,i,a)=>{zV(t,e,r.invalidates??[{kind:`workspace`},{kind:`bootstrap`}]),n.update(a,{tone:`success`,title:`Project description saved`,...i.length===0?{}:{message:i}})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Project description save failed`,message:$(e)})}}),ce=gt({mutationFn:({body:e,commandId:t})=>i.sendMainChatMessage({body:e},{commandId:t}),onSuccess:(n,r)=>{w.current=null,s(e=>e.trim()===r.body?``:e),n.result?.message!==void 0&&(S.kind===`latest`&&!N.hasNextPage?y(n.result.message.id):A(n.result.message.id)),zV(t,e,n.invalidates)},onError:e=>{n.notify({tone:`error`,title:`Message send failed`,message:$(e)})}}),le=gt({mutationFn:async t=>{let n=await dH({relayProjectRef:e,purpose:`reference_file`,file:t});return i.uploadReferenceFile(n)},onMutate:e=>n.notify({tone:`loading`,title:`Uploading reference`,message:e.name}),onSuccess:(r,i,a)=>{let o=r.result?.message;o!==void 0&&(S.kind===`latest`&&!N.hasNextPage?y(o.id):A(o.id)),zV(t,e,r.invalidates),n.update(a,{tone:`success`,title:`Reference uploaded`,message:r.result?.file.name??i.name})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Reference upload failed`,message:$(e)})}}),ue=fK({enabled:j.data?.workspace.capabilities.request_status_v1===!0,key:Z.worklist(e),tracker:f,read:(e,t)=>i.getWorklistSubmission(e,t)}),de=(0,I.useRef)(Vt()),fe=(0,I.useRef)(!1),pe=gt({mutationFn:e=>i.submitWorklist(e===void 0?{}:{expected_scratchpad_updated_at:e},{commandId:de.current}),onMutate:()=>(p({kind:`request`}),n.notify({tone:`loading`,title:`Running Scratchpad`})),onSuccess:(r,i,a)=>{if(r.disposition.kind===`accepted`)p(uK(r,de.current)),n.update(a,{tone:`success`,title:`Scratchpad run started`,message:`Tutti is preparing Worklist tasks.`});else if(r.disposition.kind===`already_running`)p(uK(r,de.current)),n.update(a,{tone:`info`,title:`Already running`,message:`Tutti is already processing work.`});else{p(null);let e=RJ(r.disposition);n.update(a,{tone:e?.tone??`warning`,title:`Scratchpad run blocked`,...e?.label===void 0?{}:{message:e.label}})}zV(t,e,r.invalidates)},onError:(e,t,r)=>{p(dK(e,j.data?.workspace.capabilities.request_status_v1===!0,de.current)),n.update(r,{tone:`warning`,title:`Scratchpad acceptance not confirmed`,message:$(e)})},onSettled:()=>{fe.current=!1}}),me=j.data,he=HJ({account:me?.session.account,presence:ae.data?.presence}),ge=me?.generated_at??new Date(0).toISOString(),_e=N.data===void 0?void 0:jJ(N.data.pages,50),ve=_e??(te&&S.kind===`latest`?me?.snapshots.main_chat:void 0)??BV(),ye=N.data!==void 0&&N.hasPreviousPage===!0,be=NJ({enabled:me?.workspace.capabilities.request_status_v1===!0,key:[`host`,e],messages:ve.items,read:(e,t)=>i.getChatRequestStatus(e,t)}),xe=N.data!==void 0&&N.hasNextPage===!0,Se=S.kind===`latest`||S.kind===`start`&&!xe||S.kind===`around`&&ve.items.length>0&&!xe,Ce=S.kind===`around`?`around:${S.messageId}`:S.kind,we=S.kind===`around`?`focus`:S.kind===`start`?`start`:`latest`,Te=me!==void 0&&(!te||_e===void 0&&N.isLoading&&(S.kind!==`latest`||me.snapshots.main_chat===void 0)),Ee=P.data??me?.snapshots.scratchpad??HV(),De=ie.data??me?.snapshots.read_state;WV({enabled:j.isSuccess,hostClient:i,relayProjectRef:e,readState:De,scope:`chat`});let Oe=F.data??me?.snapshots.active_clarification??GV(),ke=ne.data??me?.snapshots.active_approval??{state:`none`},Ae=Oe.state===`active`?Oe.round.id:void 0;(0,I.useEffect)(()=>{u!==null&&(Ae===void 0||u!==Ae)&&d(null)},[Ae,u]);let je=Oe.state===`active`&&Oe.thread.owner.kind===`task_compile`,Me=(0,I.useMemo)(()=>{let e=new Set;for(let t of ve.items)t.clarification_card!==void 0&&e.add(t.clarification_card.round_id);return Ae!==void 0&&e.add(Ae),[...e]},[Ae,ve.items]),Ne=mt({queries:Me.map(t=>({queryKey:Z.clarificationRoundMessages(e,t),queryFn:()=>i.getClarificationRoundMessages(t,{anchor:`start`,limit:50}),enabled:j.isSuccess}))}),Pe=gt({mutationFn:({roundId:e,body:t})=>i.sendClarificationRoundMessage(e,{body:t}),onSuccess:n=>{l(``),zV(t,e,n.invalidates)},onError:e=>{n.notify({tone:`error`,title:`Reply send failed`,message:$(e)})}}),Fe=gt({mutationFn:e=>i.submitClarificationRound(e,Oe.state===`active`&&Oe.round.answer_revision!==void 0?{expected_answer_revision:Oe.round.answer_revision}:{}),onMutate:e=>(d(e),n.notify({tone:`loading`,title:`Submitting reply`})),onSuccess:(r,i,a)=>{zV(t,e,r.invalidates);let o=r.disposition.kind===`accepted`||r.disposition.kind===`already_submitted`;o||d(e=>e===i?null:e),n.update(a,{tone:o?`success`:`warning`,title:o?`Reply submitted`:`Reply not submitted`,...o?{}:{message:r.disposition.kind===`no_answers`?`Add an answer before submitting.`:`The clarification or its answers changed. Review it and submit again.`}})},onError:(e,t,r)=>{d(e=>e===t?null:e),n.update(r,{tone:`error`,title:`Reply submit failed`,message:$(e)})}}),Ie=gt({mutationFn:({approvalId:e,decisionId:t})=>i.decideApproval(e,{decision_id:t}),onMutate:()=>n.notify({tone:`loading`,title:`Sending decision`}),onSuccess:(r,i,a)=>{zV(t,e,r.invalidates),n.update(a,{tone:`success`,title:`Decision sent`})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Decision failed`,message:$(e)})}}),Le=Object.fromEntries(Me.map((e,t)=>[e,(Ne[t]?.data??BV()).items.map(e=>qz(e,{authorProfiles:he,taskRetryState:a.stateFor}))])),Re=VJ({account:me?.session.account,presence:ae.data?.presence,messages:[...ve.items,...Ne.flatMap(e=>e.data?.items??[])]}),ze=re.data??me?.snapshots.execution_status??KV(ge),Be=qV(ze),Ve=JV(ze,`scratchpad_refresh`),He=JV(ze,`scratchpad_refresh`,`foreground`),Ue=JV(ze,`task_compile`,`foreground`),We=JV(ze,`project_context_bootstrap`,`foreground`),Ge=f?.kind===`activity`?f.activityRef:void 0,Ke=lK({tracker:f,execution:ze,scratchpad:Ee,clarification:Oe,approval:ke,...ue.request===void 0?{}:{submission:ue.request}});(0,I.useEffect)(()=>{f===null||f.kind===`request`||Ke.settled&&(p(null),Ke.failure!==void 0&&n.notify({tone:`error`,title:`Scratchpad run failed`,message:`Tasks were not prepared. Review Scratchpad before running again.`}))},[f,ue.isSuccess,ue.request,Ke.settled,Ke.failure,n]);let qe=Ge!==void 0&&Be.some(e=>e.activity_ref===Ge)&&Be.some(e=>e.activity_ref===Ge&&e.workflow_kind===`scratchpad_refresh`)||f!==null&&He,Je=Ve,Ye=pe.isPending||Ke.submitPending,Xe=ze.status!==`idle`||Ye||m!==null;(0,I.useEffect)(()=>{if(!Xe)return;_(Date.now());let e=window.setInterval(()=>{_(Date.now())},1e3);return()=>{window.clearInterval(e)}},[Xe]);let Ze=Be.some(e=>e.activity_kind===`procedure`&&(e.lane??`foreground`)===`foreground`),Qe=Be.some(e=>e.activity_kind===`run`),$e=Ke.actionsDisabled||(Qe||Ze)&&!Je&&!Ye,tt=EV(ze),nt={key:`scratchpad-submit`,label:je?`Needs input`:qe?`Compiling Worklist tasks`:We?`Preparing project context`:Ue?`Compiling Worklist tasks`:`Preparing Worklist`,title:je?`Needs input`:`Preparing Scratchpad for Worklist.`,tone:je?`pending`:`running`,target:je?{kind:`clarification`}:{kind:`scratchpad`}},rt=Ye&&tt.length===0?[nt]:tt,it=SV(ze,{now:g}),at=Be.find(e=>(e.lane??`foreground`)===`foreground`?e.workflow_kind===`project_context_bootstrap`&&We||e.workflow_kind===`task_compile`&&Ue||e.workflow_kind===`scratchpad_refresh`&&qe?!0:Ge!==void 0&&e.activity_ref===Ge:!1),ot=(Ye?CV({activeScratchpadRefreshFromSubmit:qe,activeProjectContextBootstrap:We,activeTaskCompile:Ue,activeTaskCompileClarification:je,now:g,...at?.started_at===void 0?{}:{startedAt:at.started_at},...ze.runtime===void 0?{}:{runtime:ze.runtime}}):null)??it;(0,I.useEffect)(()=>{ot!==null&&(T.current=ot,h(null))},[ot]),(0,I.useEffect)(()=>{if(!Ve||ot!==null)return;let e=T.current;if(e?.completionSource===void 0)return;let t=`hidden:${LJ(e)}`;if(E.current===t)return;E.current=t;let n=wV(e,e.summary);h(n),T.current=null;let r=window.setTimeout(()=>{h(e=>e?.key===n.key?null:e)},FJ);return()=>{window.clearTimeout(r)}},[ot,Ve]),(0,I.useEffect)(()=>{if(ot!==null||ze.status!==`idle`)return;let e=ze.last_conclusion;if(e?.kind!==`completed`)return;let t=e.activity_ref??`${e.kind}:${e.task_id??`none`}:${e.occurred_at}`;if(E.current===t)return;let n=T.current;if(n===null)return;if(!TV(n,e)){T.current=null;return}E.current=t;let r=wV(n,e.summary);h(r);let i=window.setTimeout(()=>{h(e=>e?.key===r.key?null:e),T.current=null},FJ);return()=>{window.clearTimeout(i)}},[ot,ze.last_conclusion?.activity_ref,ze.last_conclusion?.kind,ze.last_conclusion?.occurred_at,ze.last_conclusion?.summary,ze.last_conclusion?.task_id,ze.status]);let st=ot??m,ct=m===null?null:{key:`completed`,label:`Completed`,tone:`done`,target:m.completionTarget??{kind:`scratchpad`}},lt=ct===null?rt:[ct,...rt],ut=e=>{e.preventDefault();let t=o.trim();if(t!==``&&!ce.isPending){let e=w.current?.body===t?w.current:{body:t,commandId:Vt()};w.current=e,ce.mutate(e)}},dt=e=>{e.preventDefault();let t=c.trim();t!==``&&Ae!==void 0&&!Pe.isPending&&Pe.mutate({roundId:Ae,body:t})},ft=te&&_e===void 0&&N.error!==null&&(S.kind!==`latest`||me?.snapshots.main_chat===void 0),pt=me===void 0&&j.error!==null||ft;return(0,I.useEffect)(()=>{x!==void 0&&y(x)},[x]),(0,L.jsx)(WU,{projectName:me?.workspace.project.display_name??`Workspace`,projectDescription:me?.workspace.project.description??``,members:Re,messages:ve.items.map(e=>qz(e,{...be[e.id]===void 0?{}:{requestStatus:be[e.id]},authorProfiles:he,taskRetryState:a.stateFor,referenceAssetUrl:(e,t,n)=>i.viewerAssetUrl({path:e,variant:t,v:n})})),scratchpad:uB(Ee,ve.items,ue.note),executionProgress:st,activeApproval:Qz(ke),activeClarification:Jz(Oe),clarificationMessagesByRoundId:Le,statusShortcuts:lt,unread:UV(De),artifactSignal:r.sidebarSignal,draft:o,roundDraft:c,sendPending:ce.isPending,focusMessageId:v,messageHistoryIdentity:Ce,initialMessagePosition:we,hasOlderMessages:ye,hasNewerMessages:xe,loadingOlderMessages:N.isFetchingPreviousPage,loadingNewerMessages:N.isFetchingNextPage,historyConnectedToLatest:Se,submittedRoundId:u,referenceUploadPending:le.isPending,scratchpadSyncPending:Je,scratchpadActionsDisabled:$e,scratchpadSubmitPending:Ye,roundSendPending:Pe.isPending,roundSubmitPending:Fe.isPending,approvalDecisionPending:Ie.isPending,projectNameSaving:oe.isPending,projectDescriptionSaving:se.isPending,loading:me===void 0&&j.isLoading||Te,unavailable:pt,onDraftChange:e=>{w.current?.body!==e.trim()&&(w.current=null),s(e)},onMessageFocused:()=>y(null),onInitialMessagePositioned:()=>{S.kind===`start`&&N.isSuccess&&ee!==void 0&&XG(ee,e)},onLoadOlderMessages:()=>{N.fetchPreviousPage()},onLoadNewerMessages:()=>{N.fetchNextPage({cancelRefetch:!1})},onJumpToLatest:()=>A(),onUploadReferenceFile:e=>le.mutate(e),onOpenReferenceFile:t=>Q(XV(e,t)),onRoundDraftChange:l,onSendMessage:ut,onSendRoundMessage:dt,onSubmitRound:()=>{Ae!==void 0&&Fe.mutate(Ae)},onDecideApproval:(e,t)=>Ie.mutate({approvalId:e,decisionId:t}),onSubmitScratchpad:()=>{fe.current||Ye||$e||(fe.current=!0,de.current=Vt(),pe.mutate(Ee.updated_at))},onUpdateProjectDisplayName:async e=>{await oe.mutateAsync(e)},onUpdateProjectDescription:async e=>{await se.mutateAsync(e)},onOpenProjectCenter:()=>Q(`/projects`),onOpenWorklist:()=>Q(QV(e)),onOpenWorklistTask:t=>Q(QV(e,t)),onRetryTask:(e,t)=>a.retry(e,t),onOpenReferences:()=>Q(XV(e)),onOpenArtifacts:()=>Q(ZV(e)),onViewArtifactFeedback:(t,n)=>{let i=ve.items.find(e=>e.id===t)?.refs?.artifact_feedback,a=i?.annotations[n];i===void 0||a===void 0||(r.requestFeedbackActivation({messageId:t,annotationIndex:n,previewGeneration:i.preview_generation,documentUrl:a.document_url,target:a.target}),Q(ZV(e)))},onOpenSkills:()=>Q(nH(e)),onOpenTimeline:()=>Q(tH(e)),onOpenSettings:()=>Q(eH(e)),onActivateStatusShortcut:t=>iH(e,t)})}function WJ(e){return Yt(e)?Jt(e,`relay_session_invalid`)?`client_session`:`account_session`:null}function GJ(e){return e===`client_session`?{title:`Workspace session expired`,message:`Open the project again from Project Center.`}:{title:`Sign in required`,message:`Sign in to Tutti before opening this workspace.`}}function KJ(e){return e===`client_session`?`/projects`:`/`}function qJ({relayProjectRef:e,children:t}){let n=et(),r=Dz(),i=(0,I.useMemo)(()=>ob({...jV,relayProjectRef:e}),[e]),a=(0,I.useRef)(void 0),o=(0,I.useRef)(null),s=R({queryKey:Z.bootstrap(e),queryFn:()=>i.getBootstrap(),staleTime:MV}),c=WJ(s.error),l=c===null&&s.data?.workspace.capabilities.sse===!0;return a.current===void 0&&s.data!==void 0&&(a.current=s.data.event_cursor),(0,I.useEffect)(()=>{if(c===null)return;let t=`${e}:${c}`;o.current!==t&&(o.current=t,r.notify({tone:`warning`,...GJ(c)}),Q(KJ(c),{replace:!0}))},[c,r,e]),(0,I.useEffect)(()=>{if(!l)return;let t=i.connectEvents({...a.current===void 0?{}:{after:a.current},onReady:t=>{t.payload.replay.status===`missed`&&n.invalidateQueries({queryKey:Z.hostRoot(e)})},onInvalidate:t=>{zV(n,e,t)},onError:()=>void 0});return()=>t.close()},[i,n,e,l]),(0,L.jsxs)(LK,{relayProjectRef:e,hostClient:i,enabled:c===null&&s.isSuccess,feedbackEnabled:s.data?.workspace.capabilities.artifact_feedback===!0,children:[(0,L.jsx)(Bb,{route:{kind:`workspace`,relayProjectRef:e},projectDisplayName:s.data?.workspace.project.display_name??null}),c===null?t:null]})}function JJ({relayProjectRef:e}){let t=(0,I.useMemo)(()=>ob({...jV,relayProjectRef:e}),[e]),n=R({queryKey:Z.bootstrap(e),queryFn:()=>t.getBootstrap(),staleTime:MV}).data?.session.account.account_ref,r=n===void 0?null:`${n}:${e}`,[i,a]=(0,I.useState)({identity:null,pending:!1}),[o,s]=(0,I.useState)(!1),c=WO();(0,I.useEffect)(()=>{n===void 0||r===null||i.identity===r||a({identity:r,pending:qG(n,e).tour_pending})},[n,r,i.identity,e]);let l=t=>{ZG(t,e),a({identity:r,pending:!1})};return(0,L.jsxs)(L.Fragment,{children:[c&&r!==null&&i.identity===r&&i.pending&&n!==void 0&&typeof document<`u`?(0,iS.createPortal)((0,L.jsx)(ZO,{onOpen:()=>{l(n),s(!0)},onDismiss:()=>l(n)}),document.body):null,(0,L.jsx)(QO,{assets:VR,open:o,onOpenChange:s})]})}var YJ=`tutti.artifact-inspector`,XJ=128,ZJ=128,QJ=2048,$J=6,eY=240,tY=[`expanded`,`selected`,`checked`,`pressed`,`disabled`];function nY(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rY(e,t){return Object.keys(e).every(e=>t.includes(e))}function iY(e,t,n=!1){return typeof e==`string`&&e.length<=t&&(n||e.length>0)}function aY(e){return{protocol:YJ,version:1,channel_id:e.channelId,...e.requestId===void 0?{}:{request_id:e.requestId},type:e.type,payload:e.payload}}function oY(e){return nY(e)?e.protocol===`tutti.artifact-inspector`&&e.version===1&&iY(e.channel_id,XJ)&&(e.request_id===void 0||iY(e.request_id,ZJ))&&iY(e.type,64)&&`payload`in e:!1}function sY(e){if(!iY(e,QJ))return!1;try{return new URL(e,`https://artifact.invalid`).origin===`https://artifact.invalid`&&e.startsWith(`/`)}catch{return!1}}function cY(e,t){return e===void 0||iY(e,t)}function lY(e){return nY(e)&&rY(e,[`tag_name`,`role`,`accessible_name`])&&iY(e.tag_name,64)&&cY(e.role,64)&&cY(e.accessible_name,160)}function uY(e){if(!nY(e)||!Array.isArray(e.context)||e.context.length>3||!rY(e,[`element_kind`,`tag_name`,`role`,`accessible_name`,`text_excerpt`,`context`,`state`]))return!1;let t=e.state;return t!==void 0&&(!nY(t)||!rY(t,tY)||!Object.values(t).every(e=>typeof e==`boolean`))?!1:(e.element_kind===`control`||e.element_kind===`content`||e.element_kind===`container`)&&iY(e.tag_name,64)&&cY(e.role,64)&&cY(e.accessible_name,160)&&cY(e.text_excerpt,280)&&e.context.every(lY)}function dY(e){return nY(e)&&rY(e,[`id`,`test_id`])&&cY(e.id,128)&&cY(e.test_id,160)&&(e.id!==void 0||e.test_id!==void 0)}function fY(e){return!nY(e)||!rY(e,[`version`,`explicit_anchor`,`stable_attributes`,`semantic_path`,`selector_path`])||e.version!==1||!Array.isArray(e.semantic_path)||e.semantic_path.length>4||!Array.isArray(e.selector_path)||e.selector_path.length===0||e.selector_path.length>4?!1:cY(e.explicit_anchor,160)&&(e.stable_attributes===void 0||dY(e.stable_attributes))&&e.semantic_path.every(e=>nY(e)&&rY(e,[`role`,`accessible_name`])&&(e.role!==void 0||e.accessible_name!==void 0)&&cY(e.role,64)&&cY(e.accessible_name,160))&&e.selector_path.every(e=>nY(e)&&rY(e,[`root`,`selector`])&&(e.root===`document`||e.root===`open_shadow_root`)&&iY(e.selector,1024))}function pY(e){return!nY(e)||!rY(e,[`snapshot`,`anchor`,`fallback_context`])||!uY(e.snapshot)||!fY(e.anchor)?!1:e.fallback_context===void 0||nY(e.fallback_context)&&rY(e.fallback_context,[`snapshot`,`anchor`])&&uY(e.fallback_context.snapshot)&&fY(e.fallback_context.anchor)}function mY(e){return nY(e)&&Number.isInteger(e.candidate_index)&&Number(e.candidate_index)>=0&&Number(e.candidate_index)<$J&&uY(Object.fromEntries(Object.entries(e).filter(([e])=>e!==`candidate_index`)))}function hY(e){return!oY(e)||!nY(e.payload)?!1:e.type===`ready`?rY(e.payload,[`document_url`,`inspector_version`])&&sY(e.payload.document_url)&&e.payload.inspector_version===1:e.type===`candidates`?rY(e.payload,[`capture_id`,`recommended_index`,`items`])&&iY(e.payload.capture_id,ZJ)&&Number.isInteger(e.payload.recommended_index)&&Number(e.payload.recommended_index)>=0&&Array.isArray(e.payload.items)&&e.payload.items.length>0&&e.payload.items.length<=$J&&Number(e.payload.recommended_index)<e.payload.items.length&&e.payload.items.every(mY):e.type===`selection`?rY(e.payload,[`target`])&&pY(e.payload.target):e.type===`resolution`?rY(e.payload,[`status`])&&(e.payload.status===`exact`||e.payload.status===`context_only`||e.payload.status===`ambiguous`||e.payload.status===`missing`):e.type===`document_changed`?rY(e.payload,[`document_url`])&&sY(e.payload.document_url):e.type===`unavailable`?rY(e.payload,[`reason`])&&iY(e.payload.reason,eY):!1}var gY=5e3,_Y=class extends Error{constructor(e){super(e),this.name=`ArtifactInspectorControllerError`}};function vY(e){let t;try{t=new URL(e)}catch{throw new _Y(`Artifact preview origin is invalid`)}if(t.protocol!==`https:`&&t.protocol!==`http:`||t.origin!==e)throw new _Y(`Artifact preview origin must be exact`);return t.origin}var yY=class{#e;#t;#n;#r;#i;#a;#o;#s;#c=null;#l=null;#u=!1;#d=!1;#f=0;#p=new Map;constructor(e){this.#e=e.iframe,this.#t=vY(e.targetOrigin),this.#n=e.onEvent,this.#r=e.requestTimeoutMs??gY,this.#i=e.createChannelId??(()=>crypto.randomUUID()),this.#a=e.createMessageChannel??(()=>new MessageChannel),this.#o=e.setTimeoutFn??window.setTimeout.bind(window),this.#s=e.clearTimeoutFn??window.clearTimeout.bind(window)}get ready(){return this.#u}connect(){if(this.#d)throw new _Y(`Artifact inspector controller is disposed`);let e=this.#e.contentWindow;if(e===null)throw new _Y(`Artifact preview is not mounted`);this.#_(`Artifact preview document changed`);let t=this.#i();if(t.length===0||t.length>128)throw new _Y(`Artifact inspector channel is invalid`);let n=this.#a();this.#c=t,this.#l=n.port1,this.#l.addEventListener(`message`,this.#g),this.#l.start();try{e.postMessage(aY({channelId:t,type:`connect`,payload:{}}),this.#t,[n.port2])}catch(e){throw this.#_(`Artifact inspector connection failed`),e}}activate(){this.#m(`activate`,{})}deactivate(){this.#m(`deactivate`,{})}clearHighlight(){this.#m(`clear_highlight`,{})}confirmCandidate(e,t){return this.#h(`confirm_candidate`,{capture_id:e,candidate_index:t},`selection`).then(e=>{if(e.type!==`selection`)throw new _Y(`Artifact inspector selection response is invalid`);return e.payload.target})}resolve(e){return this.#h(`resolve`,{target:e},`resolution`).then(e=>{if(e.type!==`resolution`)throw new _Y(`Artifact inspector resolution response is invalid`);return e.payload.status})}dispose(){if(!this.#d){if(this.#l!==null)try{this.deactivate()}catch{}this.#d=!0,this.#_(`Artifact inspector controller was disposed`)}}#m(e,t){let n=this.#l,r=this.#c;if(this.#d||n===null||r===null||!this.#u)throw new _Y(`Artifact inspector is not ready`);n.postMessage(aY({channelId:r,type:e,payload:t}))}#h(e,t,n){let r=this.#l,i=this.#c;if(this.#d||r===null||i===null||!this.#u)return Promise.reject(new _Y(`Artifact inspector is not ready`));let a=`${i}:${++this.#f}`;return new Promise((o,s)=>{let c=this.#o(()=>{this.#p.delete(a),s(new _Y(`Artifact inspector request timed out`))},this.#r);this.#p.set(a,{expectedType:n,resolve:o,reject:s,timeout:c}),r.postMessage(aY({channelId:i,requestId:a,type:e,payload:t}))})}#g=e=>{let t=e.data,n=this.#c;if(n===null||!hY(t)||t.channel_id!==n)return;t.type===`ready`&&(this.#u=!0);let r=t.request_id;if(r!==void 0){let e=this.#p.get(r);e!==void 0&&(t.type===`unavailable`?(this.#s(e.timeout),this.#p.delete(r),e.reject(new _Y(t.payload.reason))):t.type===e.expectedType&&(this.#s(e.timeout),this.#p.delete(r),e.resolve(t)))}this.#n?.(t)};#_(e){this.#u=!1;for(let t of this.#p.values())this.#s(t.timeout),t.reject(new _Y(e));this.#p.clear(),this.#l!==null&&(this.#l.removeEventListener(`message`,this.#g),this.#l.close()),this.#l=null,this.#c=null}},bY=4e3;function xY(e){if(e!==void 0)try{let t=new URL(e,window.location.href);return t.protocol===`https:`||t.protocol===`http:`?t.origin:void 0}catch{return}}function SY(e){return(e.summary?.length??0)+e.annotations.reduce((e,t)=>e+t.comment.length,0)}function CY(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength}function wY({relayProjectRef:e}){let t=RK(),n=Dz(),r=et(),i=(0,I.useMemo)(()=>ob({...jV,relayProjectRef:e}),[e]),a=(0,I.useMemo)(()=>Gn(jV),[]),o=(0,I.useRef)(null),s=(0,I.useRef)(null),c=(0,I.useRef)(null),l=(0,I.useRef)(null),u=(0,I.useRef)(null),[d,f]=(0,I.useState)(void 0),[p,m]=(0,I.useState)(!1),[h,g]=(0,I.useState)(void 0),[_,v]=(0,I.useState)(void 0),[y,b]=(0,I.useState)(!1),[x,S]=(0,I.useState)(void 0),[C,w]=(0,I.useState)(void 0),[T,E]=(0,I.useState)(``),D=R({queryKey:Z.bootstrap(e),queryFn:()=>i.getBootstrap(),staleTime:MV}),O=R({queryKey:Z.executionStatus(e),queryFn:()=>i.getExecutionStatus(),enabled:D.isSuccess,staleTime:MV}),k=R({queryKey:Z.readState(e),queryFn:()=>i.getReadState(),enabled:D.isSuccess,staleTime:MV}),A=D.data,j=A?.generated_at??new Date(0).toISOString(),ee=k.data??A?.snapshots.read_state,M=O.data??A?.snapshots.execution_status??KV(j),te=M.active_activity?.activity_kind===`run`||M.active_activities?.some(e=>e.activity_kind===`run`)===!0,N=t.artifact,P=N?.status===`declared`&&N.preview.status===`ready`&&N.preview.url!==void 0?N.preview.url:null,F=N?.status===`declared`?N.preview_generation:void 0,ne=R({queryKey:Z.artifactPreviewSession(e,P??`not-ready`),queryFn:()=>a.issueArtifactPreviewSession(e),enabled:P!==null,staleTime:1/0,retry:1,refetchInterval:e=>SK(e.state.data)}),re=ne.data,ie=re?.disposition.kind===`issued`?re.result?.bootstrap_url:void 0,ae=ne.error===null?xK(re):$(ne.error),oe=xY(ie);(0,I.useEffect)(()=>{f(ie)},[ie]);let se=(0,I.useCallback)(e=>{if(e.type===`ready`){m(!0),g(void 0),v(e.payload.document_url);return}if(e.type===`candidates`){g(void 0);let t=s.current;if(t===null){g(`Element selection is not ready.`);return}let n=e.payload.capture_id;u.current=n,t.confirmCandidate(n,e.payload.recommended_index).then(e=>{u.current===n&&(t.deactivate(),S(e),w(new Date().toISOString()),g(void 0))}).catch(e=>{u.current===n&&g($(e))}).finally(()=>{u.current===n&&(u.current=null)});return}if(e.type===`document_changed`){v(e.payload.document_url);return}e.type===`unavailable`&&g(e.payload.reason)},[]);(0,I.useEffect)(()=>{let e=o.current;if(e===null||oe===void 0)return;m(!1),g(void 0),v(void 0);let t=new yY({iframe:e,targetOrigin:oe,onEvent:se});s.current=t;try{t.connect()}catch(e){g($(e))}return()=>{t.dispose(),s.current===t&&(s.current=null)}},[se,oe]),(0,I.useEffect)(()=>{if(!t.feedbackEnabled||oe===void 0||p||P===null)return;let e=window.setTimeout(()=>{g(e=>e??`Element selection could not connect to this preview.`)},bY);return()=>window.clearTimeout(e)},[t.feedbackEnabled,p,oe,P]),(0,I.useEffect)(()=>{if(t.feedbackDraftStale){try{s.current?.deactivate(),s.current?.clearHighlight()}catch{}u.current=null,S(void 0),w(void 0)}},[t.feedbackDraftStale]);let ce=(0,I.useCallback)(()=>{m(!1),v(void 0);try{s.current?.connect()}catch(e){g($(e))}},[]),le=(0,I.useCallback)(()=>{g(void 0),u.current=null,S(void 0),w(void 0);try{s.current?.clearHighlight(),s.current?.activate()}catch(e){g($(e))}},[]),ue=(0,I.useCallback)(()=>{try{s.current?.deactivate(),s.current?.clearHighlight()}catch{}b(!1),u.current=null,S(void 0),w(void 0),E(``)},[]),de=(0,I.useCallback)(()=>{u.current=null,S(void 0),w(void 0),E(``),g(void 0);try{s.current?.clearHighlight(),s.current?.activate()}catch(e){g($(e))}},[]),fe=(0,I.useCallback)(()=>{if(F===void 0||!p)return;let e=t.feedbackDraft;b(!0),!(e!==null&&e.previewGeneration!==F)&&(t.beginFeedbackDraft(F),le())},[t,p,F,le]),pe=t.feedbackDraft,me=pe===null?null:{expected_preview_generation:pe.previewGeneration,annotations:pe.annotations.map(e=>({document_url:e.document_url,comment:e.comment.trim(),target:e.target}))},he=me!==null&&SY(me)>6e3,ge=me!==null&&CY(me)>65536,_e=gt({mutationFn:e=>i.sendMainChatMessage({artifact_feedback:e.payload},{commandId:e.commandId}),onSuccess:i=>{if(i.disposition.kind===`created`){c.current=null,t.clearFeedbackDraft(),ue(),zV(r,e,i.invalidates),n.notify({tone:`success`,title:`Artifact feedback sent`});let a=i.result?.message.id;Q(a===void 0?en(e):$V(e,a));return}i.disposition.kind===`artifact_changed`?n.notify({tone:`warning`,title:`Artifact changed`,message:`Start a new feedback batch from the current preview.`}):i.disposition.kind===`artifact_unavailable`?n.notify({tone:`warning`,title:`Artifact unavailable`,message:`The feedback draft was kept in this tab.`}):n.notify({tone:`error`,title:`Feedback send could not be confirmed`}),r.invalidateQueries({queryKey:Z.artifacts(e)})},onError:e=>{n.notify({tone:`error`,title:`Artifact feedback send failed`,message:$(e)})}}),ve=(0,I.useCallback)(()=>{if(me===null||me.annotations.length===0||t.feedbackDraftStale||he||ge||_e.isPending)return;let e=JSON.stringify(me),n=c.current?.serialized===e?c.current:{commandId:Vt(),payload:me,serialized:e};c.current=n,_e.mutate(n)},[t.feedbackDraftStale,me,ge,he,_e]);(0,I.useEffect)(()=>{let e=t.pendingActivation;if(e===null){l.current=null;return}let r=`${e.messageId}:${e.annotationIndex}`;if(F===void 0||N?.status!==`declared`||N.preview.status!==`ready`||e.previewGeneration!==F){n.notify({tone:`warning`,title:`Artifact feedback is from an earlier preview`}),t.clearFeedbackActivation();return}if(!p||oe===void 0||_===void 0){h!==void 0&&(n.notify({tone:`warning`,title:`Artifact element could not be located`,message:h}),t.clearFeedbackActivation());return}if(_!==e.documentUrl){let t=new URL(e.documentUrl,oe).toString();d!==t&&(m(!1),f(t));return}let i=s.current;i===null||l.current===r||(l.current=r,i.resolve(e.target).then(e=>{e===`exact`?n.notify({tone:`success`,title:`Artifact element highlighted`}):e===`context_only`?n.notify({tone:`warning`,title:`Only the surrounding context is still visible`}):e===`ambiguous`?n.notify({tone:`warning`,title:`The element is no longer unique in this preview`}):n.notify({tone:`warning`,title:`The element is not currently visible`})}).catch(e=>{n.notify({tone:`warning`,title:`Artifact element could not be located`,message:$(e)})}).finally(()=>{l.current=null,t.clearFeedbackActivation()}))},[N,t,p,_,F,d,h,oe,n]);let ye=d??ie,be=zz(N,{...ye===void 0?{}:{previewUrl:ye},pending:P!==null&&ye===void 0&&ae===void 0,...ae===void 0?{}:{errorMessage:ae}},{runActive:te}),xe=N!==void 0,Se=!xe&&(D.error!==null||t.unavailable),Ce=t.feedbackEnabled,we=Ce&&p&&be.status===`declared`&&be.previewStatus===`ready`,Te=pe?.annotations.map(e=>({key:e.key,documentUrl:e.document_url,comment:e.comment,time:Nz(e.createdAt),target:Rz(e.target.snapshot)}))??[],Ee=t.feedbackDraftStale?`Start over from the current Artifact before submitting.`:Te.length===0?`Add at least one comment before submitting.`:he?`Shorten these comments to 6,000 characters before submitting.`:ge?`Remove some comments before submitting this batch.`:void 0,De=Ee===void 0&&!_e.isPending;return(0,L.jsx)(GU,{statusShortcuts:EV(M),unread:UV(ee),state:be,loading:!xe&&(D.isLoading||t.loading),unavailable:Se,iframeRef:o,onPreviewLoad:ce,...A?.session.account===void 0?{}:{feedback:{supported:Ce,ready:we,open:y,canSubmit:De,submitPending:_e.isPending,...Ee===void 0?{}:{submitDisabledReason:Ee},...h===void 0?{}:{unavailableReason:h},author:{displayName:A.session.account.display_name,avatar:A.session.account.avatar},onOpen:fe,onSubmit:ve,rail:{comment:T,annotations:Te,...x===void 0?{}:{selectedTarget:Rz(x.snapshot)},...C===void 0?{}:{selectedTime:Nz(C)},stale:t.feedbackDraftStale,...h===void 0?{}:{bridgeUnavailableReason:h},...he||ge?{sendDisabledReason:he?`Shorten these comments to 6,000 characters before submitting.`:`Remove some comments before submitting this batch.`}:{},onCommentChange:e=>{c.current=null,E(e)},onCancelSelection:de,onAddAnnotation:()=>{if(!(x===void 0||_===void 0||T.trim().length===0)){c.current=null,t.addFeedbackAnnotation({document_url:_,comment:T.trim(),target:x,createdAt:C??new Date().toISOString()});try{s.current?.activate()}catch(e){g($(e))}S(void 0),w(void 0),E(``)}},onRemoveAnnotation:e=>{c.current=null,t.removeFeedbackAnnotation(e)},onReset:()=>{c.current=null,t.clearFeedbackDraft(),F!==void 0&&(t.beginFeedbackDraft(F),le())}}}},onOpenProjectCenter:()=>Q(`/projects`),onOpenChat:()=>Q(en(e)),onOpenWorklist:()=>Q(QV(e)),onOpenReferences:()=>Q(XV(e)),onOpenSkills:()=>Q(nH(e)),onOpenTimeline:()=>Q(tH(e)),onOpenSettings:()=>Q(eH(e)),onActivateStatusShortcut:t=>iH(e,t)})}function TY(e){let t=e.summary;return t===void 0||t.status===`missing`?{summaryStatus:`Summary not available yet`}:t.status===`stale`?{...t.text===void 0?{}:{summary:t.text},summaryStatus:`Summary may be out of date`}:t.status===`unavailable`?{...t.text===void 0?{}:{summary:t.text},summaryStatus:`Summary could not be generated`}:t.text===void 0?{summaryStatus:`Summary unavailable`}:{summary:t.text}}function EY(e){if(e.category===`image`)return[e.media_type??`Image`,oH(e.size_bytes)].join(` · `);let t=[oH(e.size_bytes)];return e.text_read.can_read||t.push(sH(e.text_read.blocked_reason)),t.join(` · `)}function DY(e){if(!e.path.startsWith(`docs/reference/`))return;let[t,n]=e.path.slice(15).split(`/`);if(!(t===void 0||t.length===0||n===void 0||t===`files`||t===`images`))return t}function OY(e,t=DY(e)){if(t===void 0){let t=e.category===`image`?`docs/reference/images/`:`docs/reference/files/`;return e.path.startsWith(t)?e.path.slice(t.length):e.name}return e.path.slice(`docs/reference/${t}/`.length)}function kY(e,t){let n=DY(e);return{path:e.path,name:OY(e,n),meta:EY(e),...n===void 0?{}:{folderGroup:n},selected:t.selected,canPreview:e.text_read.can_read,category:e.category,...t.thumbnailUrl===void 0?{}:{thumbnailUrl:t.thumbnailUrl},...e.extension===void 0?{}:{extension:e.extension}}}function AY({relayProjectRef:e}){let t=et(),n=Dz(),r=RK(),i=(0,I.useMemo)(()=>ob({...jV,relayProjectRef:e}),[e]),a=new URL(NV(),window.location.origin).searchParams.get(`path`)??void 0,[o,s]=(0,I.useState)(a),[c,l]=(0,I.useState)(`time`),u=R({queryKey:Z.bootstrap(e),queryFn:()=>i.getBootstrap(),staleTime:MV}),d=R({queryKey:Z.referenceFiles(e),queryFn:()=>i.getReferenceFiles({limit:200}),enabled:u.isSuccess,staleTime:MV}),f=R({queryKey:Z.messagesWindow(e,200),queryFn:()=>i.getMessages({limit:200}),enabled:u.isSuccess,staleTime:MV}),p=R({queryKey:Z.executionStatus(e),queryFn:()=>i.getExecutionStatus(),enabled:u.isSuccess,staleTime:MV}),m=R({queryKey:Z.readState(e),queryFn:()=>i.getReadState(),enabled:u.isSuccess,staleTime:MV}),h=d.data?.items??[],g=(0,I.useMemo)(()=>{let e=new Map;for(let t of f.data?.items??[]){let n=t.refs?.reference_file;if(n===void 0)continue;let r=e.get(n.path);(r===void 0||t.created_at>r)&&e.set(n.path,t.created_at)}return e},[f.data?.items]),_=(0,I.useMemo)(()=>{let e=(e,t)=>e.name.localeCompare(t.name),t=(t,n)=>{let r=g.get(t.path)??``,i=g.get(n.path)??``;return r===i?e(t,n):i.localeCompare(r)},n=(e,n)=>{let r=e.extension??e.media_type??`file`,i=n.extension??n.media_type??`file`;return r===i?t(e,n):r.localeCompare(i)},r=[...h.filter(e=>e.category===`image`)].sort(t),i=[...h.filter(e=>e.category!==`image`)].sort(c===`time`?t:n);return[...r,...i]},[c,h,g]);(0,I.useEffect)(()=>{if(_.length===0){o!==void 0&&s(void 0);return}if(a!==void 0&&_.some(e=>e.path===a)){o!==a&&s(a);return}(o===void 0||!_.some(e=>e.path===o))&&s(_[0]?.path)},[_,a,o]);let v=h.find(e=>e.path===o),y=v?.category===`image`,b=v?.text_read.can_read===!0,x=R({queryKey:o===void 0?Z.viewerFile(e,`none`):Z.viewerFile(e,o),queryFn:()=>i.getViewerFile({path:o,max_bytes:204800}),enabled:u.isSuccess&&o!==void 0&&b&&!y,staleTime:MV}),S=gt({mutationFn:async t=>{let n=await dH({relayProjectRef:e,purpose:`reference_file`,file:t});return i.uploadReferenceFile(n)},onMutate:e=>n.notify({tone:`loading`,title:`Uploading reference`,message:e.name}),onSuccess:(r,i,a)=>{zV(t,e,r.invalidates),r.result?.file.path!==void 0&&(s(r.result.file.path),Q(XV(e,r.result.file.path))),n.update(a,{tone:`success`,title:`Reference uploaded`,message:r.result?.file.name??i.name})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Reference upload failed`,message:$(e)||t.name})}}),C=u.data,w=C?.generated_at??new Date(0).toISOString(),T=m.data??C?.snapshots.read_state;WV({enabled:u.isSuccess,hostClient:i,relayProjectRef:e,readState:T,scope:`references`});let E=p.data??C?.snapshots.execution_status??KV(w),D=_.map(e=>kY(e,{selected:e.path===o,...e.category!==`image`||e.blob_oid===void 0?{}:{thumbnailUrl:i.viewerAssetUrl({path:e.path,variant:`thumbnail`,v:e.blob_oid})}})),O=x.data?.content,k=(()=>{if(v===void 0)return{title:h.length===0?`No reference files`:`No file selected`,unavailableReason:h.length===0?`No reference files`:`Select a reference file`};if(O?.kind===`text`)return{title:v.name,meta:oH(v.size_bytes),...TY(v),content:O.text};if(y&&o!==void 0)return v.blob_oid===void 0?{title:v.name,meta:oH(v.size_bytes),...TY(v),unavailableReason:`Image version unavailable`}:{title:v.name,meta:oH(v.size_bytes),...TY(v),imageUrl:i.viewerAssetUrl({path:o,variant:`preview`,v:v.blob_oid})};let e=b&&x.isLoading?`Loading`:cH(O)??(b?void 0:sH(v.text_read.blocked_reason));return e===void 0?{title:v.name,meta:oH(v.size_bytes),...TY(v)}:{title:v.name,meta:oH(v.size_bytes),...TY(v),unavailableReason:e}})(),A=d.data!==void 0,j=!A&&(u.error!==null||d.error!==null);return(0,L.jsx)(KU,{statusShortcuts:EV(E),unread:UV(T),artifactSignal:r.sidebarSignal,files:D,detail:k,uploadPending:S.isPending,fileSortMode:c,loading:!A&&(u.isLoading||d.isLoading),unavailable:j,onOpenProjectCenter:()=>Q(`/projects`),onOpenChat:()=>Q(en(e)),onOpenWorklist:()=>Q(QV(e)),onOpenArtifacts:()=>Q(ZV(e)),onOpenSkills:()=>Q(nH(e)),onOpenTimeline:()=>Q(tH(e)),onOpenSettings:()=>Q(eH(e)),onActivateStatusShortcut:t=>iH(e,t),onSelectFile:t=>{s(t),Q(XV(e,t))},onUploadFile:e=>S.mutate(e),onFileSortModeChange:l})}var jY={provider_auth_invalid:`The existing API key was rejected.`,provider_quota_or_billing_required:`Quota or billing needs attention.`,provider_rate_limited:`The provider rate limit was reached. Try again shortly.`,provider_model_unavailable:`That model is unavailable for this provider.`,provider_network_error:`The provider could not be reached.`};function MY({relayProjectRef:e}){let t=et(),n=Dz(),r=RK(),[i,a]=(0,I.useState)([]),o=(0,I.useMemo)(()=>ob({...jV,relayProjectRef:e}),[e]),s=R({queryKey:Z.bootstrap(e),queryFn:()=>o.getBootstrap()}),c=R({queryKey:Z.hostWorkspace(e),queryFn:()=>o.getWorkspace(),enabled:s.isSuccess}),l=R({queryKey:Z.hostSession(e),queryFn:()=>o.getSession(),enabled:s.isSuccess}),u=R({queryKey:Z.providerConfig(e),queryFn:()=>o.getProviderConfig(),enabled:s.isSuccess}),d=R({queryKey:Z.executionStatus(e),queryFn:()=>o.getExecutionStatus(),enabled:s.isSuccess}),f=R({queryKey:Z.readState(e),queryFn:()=>o.getReadState(),enabled:s.isSuccess}),p=R({queryKey:Z.projectPresence(e),queryFn:()=>nr(jV,e),enabled:s.isSuccess,staleTime:MV,refetchInterval:6e4});RV(s.isSuccess);let m=gt({mutationFn:e=>o.updateProjectDisplayName({display_name:e}),onMutate:e=>n.notify({tone:`loading`,title:`Saving project name`,message:e}),onSuccess:(r,i,a)=>{zV(t,e,r.invalidates??[{kind:`workspace`},{kind:`bootstrap`}]),n.update(a,{tone:`success`,title:`Project name saved`,message:i})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Project name save failed`,message:`${t}: ${$(e)}`})}}),h=gt({mutationFn:e=>o.updateProjectDescription({description:e}),onMutate:e=>n.notify({tone:`loading`,title:`Saving project description`,...e.length===0?{}:{message:e}}),onSuccess:(r,i,a)=>{zV(t,e,r.invalidates??[{kind:`workspace`},{kind:`bootstrap`}]),n.update(a,{tone:`success`,title:`Project description saved`,...i.length===0?{}:{message:i}})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Project description save failed`,message:$(e)})}}),g=gt({mutationFn:()=>o.getProviderModels(),onSuccess:e=>{if(e.status===`available`){a(e.models);return}a([]),n.notify({tone:`warning`,title:`Model list unavailable`,message:`You can still enter a model name manually.`})},onError:e=>{a([]),n.notify({tone:`warning`,title:`Model list unavailable`,message:`${$(e)} You can still enter a model name manually.`})}}),_=gt({mutationFn:e=>o.updateProviderDefaultModel({default_model:e.defaultModel,expected_default_model:e.expectedDefaultModel}),onMutate:e=>n.notify({tone:`loading`,title:`Validating model`,message:e.defaultModel}),onSuccess:(r,i,a)=>{switch(zV(t,e,r.invalidates),r.disposition.kind){case`updated`:case`unchanged`:n.update(a,{tone:`success`,title:r.disposition.kind===`updated`?`Model saved`:`Model unchanged`,message:i.defaultModel});break;case`stale_default_model`:n.update(a,{tone:`warning`,title:`Model changed elsewhere`,message:`The current model is ${r.disposition.current_default_model}. Review and save again.`});break;case`validation_failed`:n.update(a,{tone:`error`,title:`Model validation failed`,message:jY[r.disposition.reason]});break;case`provider_unavailable`:n.update(a,{tone:`error`,title:`Provider unavailable`,message:`The project provider configuration is not ready.`});break;case`interrupted`:n.update(a,{tone:`warning`,title:`Model update interrupted`,message:`Try saving again.`});break}},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Model update failed`,message:$(e)})}}),v=s.data,y=v?.generated_at??new Date(0).toISOString(),b=f.data??v?.snapshots.read_state,x=c.data??v?.workspace,S=l.data??v?.session,C=u.data??v?.provider_config,w=d.data??v?.snapshots.execution_status??KV(y),T=x===void 0||S===void 0||C===void 0?void 0:jB(x,S,C,p.data?.presence),E=T===void 0&&(s.error!==null||c.error!==null||l.error!==null||u.error!==null),D=x?.relay.join_url,O=D===void 0||x===void 0||S===void 0?void 0:pq({inviterName:S.account.display_name,projectName:x.project.display_name,joinUrl:D}),k=S?.membership.label===`owner`&&x?.capabilities.provider_model_update===!0&&C?.status===`configured`,A=C?.status===`configured`?C.default_model:void 0,j=A===void 0||i.includes(A)?i:[A,...i];return(0,L.jsx)(aW,{...T===void 0?{}:{settings:T},statusShortcuts:EV(w),unread:UV(b),artifactSignal:r.sidebarSignal,loading:T===void 0&&(s.isLoading||c.isLoading||l.isLoading||u.isLoading),unavailable:E,projectNameSaving:m.isPending,projectDescriptionSaving:h.isPending,providerModelOptions:j,providerModelEditable:k,providerModelDiscovering:g.isPending,providerModelSaving:_.isPending,onOpenProjectCenter:()=>Q(`/projects`),onOpenChat:()=>Q(en(e)),onOpenWorklist:()=>Q(QV(e)),onOpenReferences:()=>Q(XV(e)),onOpenArtifacts:()=>Q(ZV(e)),onOpenSkills:()=>Q(nH(e)),onOpenTimeline:()=>Q(tH(e)),onActivateStatusShortcut:t=>iH(e,t),...O===void 0?{}:{onCopyJoinUrl:()=>{navigator.clipboard.writeText(O).then(()=>{n.notify({tone:`success`,title:`Invitation copied`})}).catch(()=>{n.notify({tone:`error`,title:`Copy failed`,message:`The browser could not copy the invite link.`})})}},onUpdateProjectDisplayName:async e=>{await m.mutateAsync(e)},onUpdateProjectDescription:async e=>{await h.mutateAsync(e)},...k?{onDiscoverProviderModels:async()=>{a([]),await g.mutateAsync()},onUpdateProviderDefaultModel:async(e,t)=>{try{let n=await _.mutateAsync({defaultModel:e,expectedDefaultModel:t});return n.disposition.kind===`updated`||n.disposition.kind===`unchanged`?{kind:`saved`}:n.disposition.kind===`stale_default_model`?{kind:`stale`,currentValue:n.disposition.current_default_model}:{kind:`failed`}}catch{return{kind:`failed`}}}}:{}})}function NY({relayProjectRef:e}){let t=et(),n=Dz(),r=RK(),i=(0,I.useMemo)(()=>ob({...jV,relayProjectRef:e}),[e]),a=new URL(NV(),window.location.origin).searchParams.get(`skill`)??void 0,[o,s]=(0,I.useState)(a),c=R({queryKey:Z.bootstrap(e),queryFn:()=>i.getBootstrap(),staleTime:MV}),l=R({queryKey:Z.skills(e),queryFn:()=>i.getSkills(),enabled:c.isSuccess,staleTime:MV}),u=R({queryKey:Z.executionStatus(e),queryFn:()=>i.getExecutionStatus(),enabled:c.isSuccess,staleTime:MV}),d=R({queryKey:Z.readState(e),queryFn:()=>i.getReadState(),enabled:c.isSuccess,staleTime:MV}),f=l.data?.items??[];(0,I.useEffect)(()=>{if(f.length===0){o!==void 0&&s(void 0);return}if(a!==void 0&&f.some(e=>e.name===a)){o!==a&&s(a);return}(o===void 0||!f.some(e=>e.name===o))&&s(f[0]?.name)},[a,o,f]);let p=R({queryKey:o===void 0?Z.skillDetail(e,`none`):Z.skillDetail(e,o),queryFn:()=>i.getSkill(o),enabled:c.isSuccess&&o!==void 0,staleTime:MV}),m=gt({mutationFn:async t=>{let n=await dH({relayProjectRef:e,purpose:`skill_zip`,file:t});return i.importSkillZip(n)},onMutate:e=>n.notify({tone:`loading`,title:`Uploading skill`,message:e.name}),onSuccess:(r,i,a)=>{zV(t,e,r.invalidates);let o=r.result?.skill.name??(r.disposition.kind===`created`||r.disposition.kind===`replaced`?r.disposition.skill_name:void 0);o!==void 0&&(s(o),Q(nH(e,o))),n.update(a,{tone:`success`,title:`Skill installed`,message:o??i.name})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Skill upload failed`,message:$(e)})}}),h=gt({mutationFn:e=>i.deleteSkill({skill_name:e}),onMutate:e=>n.notify({tone:`loading`,title:`Deleting skill`,message:e}),onSuccess:(r,i,a)=>{zV(t,e,r.invalidates);let c=r.disposition.kind===`deleted`||r.disposition.kind===`not_found`?r.disposition.skill_name:o,l=f.find(e=>e.name!==c);s(l?.name),Q(l===void 0?nH(e):nH(e,l.name)),n.update(a,{tone:`success`,title:`Skill deleted`,message:c??i})},onError:(e,t,r)=>{n.update(r,{tone:`error`,title:`Skill delete failed`,message:`${t}: ${$(e)}`})}}),g=c.data,_=g?.generated_at??new Date(0).toISOString(),v=d.data??g?.snapshots.read_state;WV({enabled:c.isSuccess,hostClient:i,relayProjectRef:e,readState:v,scope:`skills`});let y=u.data??g?.snapshots.execution_status??KV(_),b=f.map(e=>({name:e.name,description:e.description,...e.short_description===void 0?{}:{shortDescription:e.short_description},selected:e.name===o,...e.updated_at===void 0?{}:{updatedLabel:`Updated ${kz(e.updated_at)}`}})),x=f.find(e=>e.name===o),S=(()=>{let e=p.data?.skill;return e===void 0?o===void 0?{title:f.length===0?`No skills`:`No skill selected`,unavailableReason:f.length===0?`No user skills`:`Select a skill`}:{title:x?.name??o,...x?.description===void 0?{}:{description:x.description},unavailableReason:p.isLoading?`Loading`:`Skill unavailable`}:{title:e.name,description:e.description,...e.updated_at===void 0?{}:{updatedLabel:`Updated ${kz(e.updated_at)}`},skillMd:e.skill_md}})(),C=l.data!==void 0,w=!C&&(c.error!==null||l.error!==null);return(0,L.jsx)(sW,{statusShortcuts:EV(y),unread:UV(v),artifactSignal:r.sidebarSignal,skills:b,detail:S,uploadPending:m.isPending,deletePending:h.isPending,loading:!C&&(c.isLoading||l.isLoading),unavailable:w,onOpenProjectCenter:()=>Q(`/projects`),onOpenChat:()=>Q(en(e)),onOpenWorklist:()=>Q(QV(e)),onOpenReferences:()=>Q(XV(e)),onOpenArtifacts:()=>Q(ZV(e)),onOpenTimeline:()=>Q(tH(e)),onOpenSettings:()=>Q(eH(e)),onActivateStatusShortcut:t=>iH(e,t),onSelectSkill:t=>{s(t),Q(nH(e,t))},onUploadSkill:e=>m.mutate(e),onDeleteSkill:e=>h.mutate(e)})}function PY({relayProjectRef:e}){let t=RK(),n=(0,I.useMemo)(()=>ob({...jV,relayProjectRef:e}),[e]),r=R({queryKey:Z.bootstrap(e),queryFn:()=>n.getBootstrap(),staleTime:MV}),i=R({queryKey:Z.projectTimeline(e),queryFn:()=>n.getProjectTimeline(),enabled:r.isSuccess,staleTime:MV}),a=R({queryKey:Z.executionStatus(e),queryFn:()=>n.getExecutionStatus(),enabled:r.isSuccess,staleTime:MV}),o=R({queryKey:Z.readState(e),queryFn:()=>n.getReadState(),enabled:r.isSuccess,staleTime:MV}),s=r.data,c=s?.generated_at??new Date(0).toISOString(),l=o.data??s?.snapshots.read_state,u=a.data??s?.snapshots.execution_status??KV(c),d=i.data===void 0&&(r.error!==null||i.error!==null);return(0,L.jsx)(cW,{...i.data===void 0?{}:{timeline:HB(i.data,{onOpenWorklistTask:t=>Q(QV(e,t)),onOpenChatMessage:t=>Q($V(e,t)),onOpenReferenceFile:t=>Q(XV(e,t))})},statusShortcuts:EV(u),unread:UV(l),artifactSignal:t.sidebarSignal,loading:i.data===void 0&&(r.isLoading||i.isLoading),unavailable:d,onOpenProjectCenter:()=>Q(`/projects`),onOpenChat:()=>Q(en(e)),onOpenWorklist:()=>Q(QV(e)),onOpenReferences:()=>Q(XV(e)),onOpenArtifacts:()=>Q(ZV(e)),onOpenSkills:()=>Q(nH(e)),onOpenSettings:()=>Q(eH(e)),onActivateStatusShortcut:t=>iH(e,t)})}function FY({relayProjectRef:e}){let t=RK(),n=(0,I.useMemo)(()=>ob({...jV,relayProjectRef:e}),[e]),r=MJ({hostClient:n,relayProjectRef:e}),i=new URL(NV(),window.location.origin).searchParams.get(`task`)??void 0,[a,o]=(0,I.useState)(void 0),s=R({queryKey:Z.bootstrap(e),queryFn:()=>n.getBootstrap()}),c=R({queryKey:Z.worklist(e),queryFn:()=>n.getWorklist(),enabled:s.isSuccess}),l=R({queryKey:Z.executionStatus(e),queryFn:()=>n.getExecutionStatus(),enabled:s.isSuccess}),u=R({queryKey:Z.readState(e),queryFn:()=>n.getReadState(),enabled:s.isSuccess}),d=s.data,f=d?.generated_at??new Date(0).toISOString(),p=c.data??d?.snapshots.worklist??VV(),m=u.data??d?.snapshots.read_state;WV({enabled:s.isSuccess,hostClient:n,relayProjectRef:e,readState:m,scope:`worklist`});let h=(0,I.useMemo)(()=>fB(p),[p]),g=i!==void 0&&h.some(e=>e.id===i),_=i!==void 0&&!g?i:void 0;(0,I.useEffect)(()=>{if(i!==void 0){o(g?e=>e===i?e:i:void 0);return}if(h.length===0){o(void 0);return}(a===void 0||!h.some(e=>e.id===a))&&o(aH(p,void 0))},[g,i,a,h,p]);let v=R({queryKey:a===void 0?Z.taskDetail(e,`none`):Z.taskDetail(e,a),queryFn:()=>n.getTaskDetail(a),enabled:s.isSuccess&&a!==void 0}),y=R({queryKey:a===void 0?Z.taskRunResults(e,`none`):Z.taskRunResults(e,a),queryFn:()=>n.getTaskRunResults(a,{limit:50}),enabled:s.isSuccess&&a!==void 0}),b=l.data??d?.snapshots.execution_status??KV(f),x=dB(p,a),S=SB(v.data,y.data),C=v.data?.detail.result.latest_run_result_id,w=v.data?.detail.result.retry_action,T=S===void 0||C===void 0||w===void 0?S:{...S,retryAction:{state:r.stateFor(S.taskId,C,w)??w,onRetry:()=>r.retry(S.taskId,C)}},E=c.data!==void 0||d?.snapshots.worklist!==void 0,D=!E&&(s.error!==null||c.error!==null);return(0,L.jsx)(lW,{statusShortcuts:EV(b),unread:UV(m),artifactSignal:t.sidebarSignal,modules:x.modules,taskCount:x.taskCount,...T===void 0?{}:{detail:T},..._===void 0?{}:{missingTaskId:_},loading:!E&&(s.isLoading||c.isLoading),unavailable:D,onOpenProjectCenter:()=>Q(`/projects`),onOpenChat:()=>Q(en(e)),onOpenReferences:()=>Q(XV(e)),onOpenArtifacts:()=>Q(ZV(e)),onOpenSkills:()=>Q(nH(e)),onOpenTimeline:()=>Q(tH(e)),onOpenSettings:()=>Q(eH(e)),onActivateStatusShortcut:t=>iH(e,t),onSelectTask:t=>{o(t),Q(QV(e,t))}})}var IY=`is-scrollbar-active`,LY=1e3;function RY(e,t){let n=e.target;return n instanceof Element?n:t.scrollingElement??t.documentElement}function zY(e){let t=new Map,n=e=>{let n=t.get(e);n!==void 0&&(window.clearTimeout(n),t.delete(e)),e.classList.remove(IY)},r=e=>{let r=t.get(e);r!==void 0&&window.clearTimeout(r),e.classList.add(IY);let i=window.setTimeout(()=>n(e),LY);t.set(e,i)},i=t=>{r(RY(t,e))};return e.addEventListener(`scroll`,i,{capture:!0,passive:!0}),()=>{e.removeEventListener(`scroll`,i,!0);for(let[e,n]of t)window.clearTimeout(n),e.classList.remove(IY);t.clear()}}var BY=`--tutti-viewport-height`,VY=`--tutti-viewport-offset-top`;function HY(e,t=window){let n=e.documentElement,r=t.visualViewport,i=()=>{let e=r?.height??t.innerHeight,i=r?.offsetTop??0;n.style.setProperty(BY,`${Math.max(0,e)}px`),n.style.setProperty(VY,`${Math.max(0,i)}px`)};return i(),t.addEventListener(`resize`,i),t.addEventListener(`orientationchange`,i),r?.addEventListener(`resize`,i),r?.addEventListener(`scroll`,i),()=>{t.removeEventListener(`resize`,i),t.removeEventListener(`orientationchange`,i),r?.removeEventListener(`resize`,i),r?.removeEventListener(`scroll`,i),n.style.removeProperty(BY),n.style.removeProperty(VY)}}var UY=new Xe({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}});function WY(){let e=FV();if(e.kind===`managed_account`)return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:e}),(0,L.jsx)(zG,{})]});if(e.kind===`managed_project_consent`)return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:e}),(0,L.jsx)(RG,{})]});if(e.kind===`local_console`)return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:e}),(0,L.jsx)(xq,{})]});if(e.kind===`local_console_account_gate`)return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:e}),(0,L.jsx)(Tq,{})]});if(e.kind===`home`)return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:e}),(0,L.jsx)(XK,{})]});if(e.kind===`join`)return(0,L.jsx)(QG,{joinToken:e.joinToken});if(e.kind===`feishu_project`)return(0,L.jsx)(JK,{relayProjectRef:e.relayProjectRef});if(e.kind===`feishu_connection`)return(0,L.jsx)(hH,{entryRef:e.entryRef});if(e.kind===`legacy_feishu_project`)return(0,L.jsx)(zK,{relayProjectRef:e.relayProjectRef});if(e.kind===`setup`)return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bb,{route:e}),(0,L.jsx)(TJ,{})]});if(e.kind===`project_open`)return(0,L.jsx)(uJ,{requestedOpenProjectRef:e.relayProjectRef});if(e.kind===`workspace`||e.kind===`worklist`||e.kind===`references`||e.kind===`artifacts`||e.kind===`skills`||e.kind===`timeline`||e.kind===`settings`){let t=e.kind===`workspace`?(0,L.jsx)(UJ,{relayProjectRef:e.relayProjectRef}):e.kind===`worklist`?(0,L.jsx)(FY,{relayProjectRef:e.relayProjectRef}):e.kind===`references`?(0,L.jsx)(AY,{relayProjectRef:e.relayProjectRef}):e.kind===`artifacts`?(0,L.jsx)(wY,{relayProjectRef:e.relayProjectRef}):e.kind===`skills`?(0,L.jsx)(NY,{relayProjectRef:e.relayProjectRef}):e.kind===`timeline`?(0,L.jsx)(PY,{relayProjectRef:e.relayProjectRef}):(0,L.jsx)(MY,{relayProjectRef:e.relayProjectRef});return(0,L.jsxs)(qJ,{relayProjectRef:e.relayProjectRef,children:[t,(0,L.jsx)(JJ,{relayProjectRef:e.relayProjectRef})]},e.relayProjectRef)}return(0,L.jsx)(uJ,{...e.kind===`project_center`&&e.panel?{initialPanel:e.panel}:{}})}function GY(){return(0,I.useEffect)(()=>{let e=zY(document),t=HY(document);return()=>{e(),t()}},[]),(0,L.jsx)(tt,{client:UY,children:(0,L.jsx)(Ez,{children:(0,L.jsx)(WY,{})})})}function KY(e){let t=document.querySelector(`link[rel="icon"]`),n=t??document.createElement(`link`);n.rel=`icon`,n.type=`image/png`,n.sizes=`1204x1204`,n.href=e,t===null&&document.head.append(n)}KY(RR),(0,vt.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(I.StrictMode,{children:(0,L.jsx)(GY,{})}));export{q as C,ex as S,Cx as _,DO as a,rx as b,LO as c,Yx as d,Jx as f,Ox as g,Ax as h,PO as i,jO as l,Nx as m,yO as n,kO as o,Gx as p,IO as r,FO as s,_L as t,nS as u,Sx as v,Qe as w,tx as x,mx as y};
|